@vanira/sdk 0.0.90 → 0.0.91
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/dist/headless/index.cjs +88 -72
- package/dist/headless/index.js +6286 -6226
- package/dist/platforms/browser.cjs +1 -1
- package/dist/platforms/browser.js +5 -1
- package/dist/platforms/react-native.cjs +2 -2
- package/dist/platforms/react-native.js +251 -247
- package/dist/vanira-sdk.es.js +8042 -7982
- package/dist/vanira-sdk.js +92 -76
- package/dist/vanira-sdk.umd.js +112 -96
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var q = Object.defineProperty;
|
|
2
|
-
var X = (
|
|
3
|
-
var d = (
|
|
2
|
+
var X = (a, e, t) => e in a ? q(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
3
|
+
var d = (a, e, t) => X(a, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
class Z {
|
|
5
5
|
pause() {
|
|
6
6
|
}
|
|
@@ -41,8 +41,8 @@ class te {
|
|
|
41
41
|
}
|
|
42
42
|
if (i.data instanceof ArrayBuffer) {
|
|
43
43
|
try {
|
|
44
|
-
const
|
|
45
|
-
(r == null ? void 0 : r.event) === "client_tool_call" && t.onMessage({ text:
|
|
44
|
+
const n = new TextDecoder().decode(i.data), r = JSON.parse(n);
|
|
45
|
+
(r == null ? void 0 : r.event) === "client_tool_call" && t.onMessage({ text: n });
|
|
46
46
|
} catch {
|
|
47
47
|
}
|
|
48
48
|
return;
|
|
@@ -60,7 +60,7 @@ class te {
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
const ie = "https://api.vanira.io",
|
|
63
|
+
const ie = "https://api.vanira.io", s = {
|
|
64
64
|
Form: "vanira_form",
|
|
65
65
|
Calendar: "vanira_calendar",
|
|
66
66
|
Navigate: "vanira_navigate",
|
|
@@ -87,152 +87,156 @@ const ie = "https://api.vanira.io", o = {
|
|
|
87
87
|
KycDocumentCapture: "vanira_kyc_document_capture",
|
|
88
88
|
KycSelfieCapture: "vanira_kyc_selfie_capture",
|
|
89
89
|
KycSignatureCapture: "vanira_kyc_signature_capture"
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
}, ae = Object.values(s), ne = new Set(ae), re = /* @__PURE__ */ new Set([
|
|
91
|
+
s.KycDocumentCapture,
|
|
92
|
+
s.KycSelfieCapture,
|
|
93
|
+
s.KycSignatureCapture
|
|
94
94
|
]);
|
|
95
95
|
[
|
|
96
96
|
...re,
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
s.Form,
|
|
98
|
+
s.Upload,
|
|
99
|
+
s.Camera,
|
|
100
|
+
s.ClipRegion,
|
|
101
|
+
s.ScreenVision,
|
|
102
|
+
s.Navigate
|
|
99
103
|
];
|
|
100
|
-
function B(
|
|
101
|
-
return !!
|
|
104
|
+
function B(a) {
|
|
105
|
+
return !!a && ne.has(a);
|
|
102
106
|
}
|
|
103
|
-
function J(
|
|
104
|
-
if (typeof
|
|
107
|
+
function J(a) {
|
|
108
|
+
if (typeof a == "string")
|
|
105
109
|
try {
|
|
106
|
-
return JSON.parse(
|
|
110
|
+
return JSON.parse(a);
|
|
107
111
|
} catch {
|
|
108
112
|
return {};
|
|
109
113
|
}
|
|
110
|
-
return
|
|
114
|
+
return a && typeof a == "object" ? a : {};
|
|
111
115
|
}
|
|
112
116
|
const $ = {
|
|
113
|
-
type_on_whiteboard:
|
|
114
|
-
write_on_whiteboard:
|
|
115
|
-
write_on_white_board:
|
|
116
|
-
dom_typing_simulation:
|
|
117
|
-
write_latex_text:
|
|
118
|
-
write_latex_on_board:
|
|
119
|
-
latex_on_whiteboard:
|
|
120
|
-
show_geogebra:
|
|
121
|
-
geogebra_diagram:
|
|
122
|
-
geogebra:
|
|
123
|
-
erase_text:
|
|
124
|
-
dom_erase:
|
|
125
|
-
open_live_camera:
|
|
126
|
-
live_vision:
|
|
127
|
-
close_live_camera:
|
|
128
|
-
stop_live_camera:
|
|
129
|
-
open_live_screen:
|
|
130
|
-
close_live_screen:
|
|
131
|
-
screen_vision:
|
|
132
|
-
capture_screen_vision:
|
|
133
|
-
capture_screen:
|
|
134
|
-
tab_screenshot:
|
|
135
|
-
capture_tab:
|
|
136
|
-
capture_tab_screenshot:
|
|
137
|
-
screenshot_tab:
|
|
138
|
-
point_at:
|
|
139
|
-
point_at_screen:
|
|
140
|
-
draw_on_screen:
|
|
141
|
-
screen_draw:
|
|
142
|
-
clear_screen_draw:
|
|
143
|
-
clear_screen_annotations:
|
|
144
|
-
highlight_on_screen:
|
|
145
|
-
highlight_element_on_screen:
|
|
146
|
-
highlight_screen_element:
|
|
147
|
-
kyc_document_capture:
|
|
148
|
-
capture_id_document:
|
|
149
|
-
document_capture:
|
|
150
|
-
capture_kyc_document:
|
|
151
|
-
kyc_selfie_capture:
|
|
152
|
-
capture_selfie:
|
|
153
|
-
selfie_capture:
|
|
154
|
-
capture_kyc_selfie:
|
|
155
|
-
kyc_signature_capture:
|
|
156
|
-
capture_kyc_signature:
|
|
157
|
-
signature_capture:
|
|
117
|
+
type_on_whiteboard: s.TypeText,
|
|
118
|
+
write_on_whiteboard: s.TypeText,
|
|
119
|
+
write_on_white_board: s.TypeText,
|
|
120
|
+
dom_typing_simulation: s.TypeText,
|
|
121
|
+
write_latex_text: s.WriteLatexText,
|
|
122
|
+
write_latex_on_board: s.WriteLatexText,
|
|
123
|
+
latex_on_whiteboard: s.WriteLatexText,
|
|
124
|
+
show_geogebra: s.GeoGebra,
|
|
125
|
+
geogebra_diagram: s.GeoGebra,
|
|
126
|
+
geogebra: s.GeoGebra,
|
|
127
|
+
erase_text: s.EraseText,
|
|
128
|
+
dom_erase: s.EraseText,
|
|
129
|
+
open_live_camera: s.LiveVision,
|
|
130
|
+
live_vision: s.LiveVision,
|
|
131
|
+
close_live_camera: s.CloseLiveCamera,
|
|
132
|
+
stop_live_camera: s.CloseLiveCamera,
|
|
133
|
+
open_live_screen: s.LiveScreen,
|
|
134
|
+
close_live_screen: s.CloseLiveScreen,
|
|
135
|
+
screen_vision: s.ScreenVision,
|
|
136
|
+
capture_screen_vision: s.ScreenVision,
|
|
137
|
+
capture_screen: s.ScreenVision,
|
|
138
|
+
tab_screenshot: s.ScreenVision,
|
|
139
|
+
capture_tab: s.ScreenVision,
|
|
140
|
+
capture_tab_screenshot: s.ScreenVision,
|
|
141
|
+
screenshot_tab: s.ScreenVision,
|
|
142
|
+
point_at: s.PointAt,
|
|
143
|
+
point_at_screen: s.PointAt,
|
|
144
|
+
draw_on_screen: s.DrawOnScreen,
|
|
145
|
+
screen_draw: s.DrawOnScreen,
|
|
146
|
+
clear_screen_draw: s.ClearScreenDraw,
|
|
147
|
+
clear_screen_annotations: s.ClearScreenDraw,
|
|
148
|
+
highlight_on_screen: s.HighlightOnScreen,
|
|
149
|
+
highlight_element_on_screen: s.HighlightOnScreen,
|
|
150
|
+
highlight_screen_element: s.HighlightOnScreen,
|
|
151
|
+
kyc_document_capture: s.KycDocumentCapture,
|
|
152
|
+
capture_id_document: s.KycDocumentCapture,
|
|
153
|
+
document_capture: s.KycDocumentCapture,
|
|
154
|
+
capture_kyc_document: s.KycDocumentCapture,
|
|
155
|
+
kyc_selfie_capture: s.KycSelfieCapture,
|
|
156
|
+
capture_selfie: s.KycSelfieCapture,
|
|
157
|
+
selfie_capture: s.KycSelfieCapture,
|
|
158
|
+
capture_kyc_selfie: s.KycSelfieCapture,
|
|
159
|
+
kyc_signature_capture: s.KycSignatureCapture,
|
|
160
|
+
capture_kyc_signature: s.KycSignatureCapture,
|
|
161
|
+
signature_capture: s.KycSignatureCapture
|
|
158
162
|
}, j = {
|
|
159
|
-
vanira_tab_screenshot:
|
|
160
|
-
vanira_document_capture:
|
|
161
|
-
vanira_selfie_capture:
|
|
162
|
-
vanira_signature_capture:
|
|
163
|
-
vanira_kyc_signature:
|
|
163
|
+
vanira_tab_screenshot: s.ScreenVision,
|
|
164
|
+
vanira_document_capture: s.KycDocumentCapture,
|
|
165
|
+
vanira_selfie_capture: s.KycSelfieCapture,
|
|
166
|
+
vanira_signature_capture: s.KycSignatureCapture,
|
|
167
|
+
vanira_kyc_signature: s.KycSignatureCapture
|
|
164
168
|
};
|
|
165
|
-
function se(
|
|
166
|
-
const t =
|
|
169
|
+
function se(a, e) {
|
|
170
|
+
const t = a.commands ?? (e == null ? void 0 : e.commands) ?? a.construction ?? (e == null ? void 0 : e.construction) ?? a.geogebra_commands ?? (e == null ? void 0 : e.geogebra_commands) ?? a.script ?? (e == null ? void 0 : e.script);
|
|
167
171
|
return Array.isArray(t) ? t.some((i) => String(i).trim().length > 0) : typeof t == "string" && t.trim().length > 0;
|
|
168
172
|
}
|
|
169
|
-
function oe(
|
|
170
|
-
const t =
|
|
173
|
+
function oe(a, e) {
|
|
174
|
+
const t = a.material_id ?? (e == null ? void 0 : e.material_id) ?? a.materialId ?? (e == null ? void 0 : e.materialId);
|
|
171
175
|
return typeof t == "string" && t.trim().length > 0;
|
|
172
176
|
}
|
|
173
|
-
function ce(
|
|
174
|
-
const t =
|
|
177
|
+
function ce(a, e) {
|
|
178
|
+
const t = a.latex_text ?? (e == null ? void 0 : e.latex_text);
|
|
175
179
|
return typeof t == "string" && t.trim().length > 0;
|
|
176
180
|
}
|
|
177
|
-
function G(
|
|
178
|
-
const t =
|
|
181
|
+
function G(a, e) {
|
|
182
|
+
const t = a.text_to_type ?? (e == null ? void 0 : e.text_to_type) ?? a.text ?? (e == null ? void 0 : e.text) ?? a.value ?? (e == null ? void 0 : e.value);
|
|
179
183
|
return typeof t == "string" && t.trim().length > 0;
|
|
180
184
|
}
|
|
181
|
-
function le(
|
|
182
|
-
const t =
|
|
185
|
+
function le(a, e) {
|
|
186
|
+
const t = a.fields ?? (e == null ? void 0 : e.fields);
|
|
183
187
|
return Array.isArray(t) ? t.length > 0 : typeof t == "string" ? t.split(",").map((i) => i.trim()).filter(Boolean).length > 0 : !1;
|
|
184
188
|
}
|
|
185
|
-
function de(
|
|
186
|
-
const t =
|
|
189
|
+
function de(a, e) {
|
|
190
|
+
const t = a == null ? void 0 : a.preset_id;
|
|
187
191
|
if (typeof t == "string") {
|
|
188
192
|
if (B(t)) return t;
|
|
189
193
|
const r = j[t];
|
|
190
194
|
if (r) return r;
|
|
191
195
|
}
|
|
192
|
-
const
|
|
193
|
-
if (typeof
|
|
194
|
-
if (B(
|
|
195
|
-
const r = j[
|
|
196
|
+
const n = J(e).preset_id;
|
|
197
|
+
if (typeof n == "string") {
|
|
198
|
+
if (B(n)) return n;
|
|
199
|
+
const r = j[n];
|
|
196
200
|
if (r) return r;
|
|
197
201
|
}
|
|
198
202
|
}
|
|
199
|
-
function he(
|
|
203
|
+
function he(a, e, t) {
|
|
200
204
|
const i = J(e);
|
|
201
|
-
let
|
|
202
|
-
if (
|
|
203
|
-
return
|
|
204
|
-
if (
|
|
205
|
+
let n = de(a, i);
|
|
206
|
+
if (n === s.Form && G(i, a) && !le(i, a))
|
|
207
|
+
return s.TypeText;
|
|
208
|
+
if (n) return n;
|
|
205
209
|
const r = String(t ?? "").trim().toLowerCase();
|
|
206
210
|
if (r && $[r])
|
|
207
211
|
return $[r];
|
|
208
|
-
if (se(i,
|
|
209
|
-
return
|
|
210
|
-
if (ce(i,
|
|
211
|
-
return
|
|
212
|
-
if (G(i,
|
|
213
|
-
return
|
|
212
|
+
if (se(i, a) || oe(i, a))
|
|
213
|
+
return s.GeoGebra;
|
|
214
|
+
if (ce(i, a))
|
|
215
|
+
return s.WriteLatexText;
|
|
216
|
+
if (G(i, a))
|
|
217
|
+
return s.TypeText;
|
|
214
218
|
}
|
|
215
219
|
const T = "vanira_latest_call_id", k = "vanira_prospect_id";
|
|
216
|
-
function I(
|
|
217
|
-
return `vanira_latest_call_id_${
|
|
220
|
+
function I(a) {
|
|
221
|
+
return `vanira_latest_call_id_${a}`;
|
|
218
222
|
}
|
|
219
|
-
function b(
|
|
220
|
-
return `vanira_prospect_id_${
|
|
223
|
+
function b(a) {
|
|
224
|
+
return `vanira_prospect_id_${a}`;
|
|
221
225
|
}
|
|
222
|
-
function z(
|
|
223
|
-
return `vanira_call_meta_${
|
|
226
|
+
function z(a) {
|
|
227
|
+
return `vanira_call_meta_${a}`;
|
|
224
228
|
}
|
|
225
|
-
function S(
|
|
226
|
-
if (!
|
|
229
|
+
function S(a, e) {
|
|
230
|
+
if (!a) return null;
|
|
227
231
|
try {
|
|
228
|
-
return
|
|
232
|
+
return a.getItem(e);
|
|
229
233
|
} catch {
|
|
230
234
|
return null;
|
|
231
235
|
}
|
|
232
236
|
}
|
|
233
|
-
function W(
|
|
234
|
-
if (typeof window > "u" || !
|
|
235
|
-
const e = [], t = S(window.localStorage, z(
|
|
237
|
+
function W(a) {
|
|
238
|
+
if (typeof window > "u" || !a) return null;
|
|
239
|
+
const e = [], t = S(window.localStorage, z(a));
|
|
236
240
|
if (t)
|
|
237
241
|
try {
|
|
238
242
|
const h = JSON.parse(t);
|
|
@@ -243,33 +247,33 @@ function W(n) {
|
|
|
243
247
|
});
|
|
244
248
|
} catch {
|
|
245
249
|
}
|
|
246
|
-
const i = (h, _,
|
|
250
|
+
const i = (h, _, o) => {
|
|
247
251
|
h && e.push({
|
|
248
252
|
callId: h,
|
|
249
253
|
prospectId: _ || void 0,
|
|
250
|
-
updatedAt:
|
|
254
|
+
updatedAt: o
|
|
251
255
|
});
|
|
252
|
-
},
|
|
256
|
+
}, n = S(window.localStorage, b(a)), r = S(window.sessionStorage, b(a)), c = S(window.localStorage, k);
|
|
253
257
|
return i(
|
|
254
|
-
S(window.localStorage, I(
|
|
255
|
-
|
|
258
|
+
S(window.localStorage, I(a)),
|
|
259
|
+
n || c,
|
|
256
260
|
2
|
|
257
261
|
), i(
|
|
258
|
-
S(window.sessionStorage, I(
|
|
262
|
+
S(window.sessionStorage, I(a)),
|
|
259
263
|
r || c,
|
|
260
264
|
1
|
|
261
265
|
), i(S(window.localStorage, T), c, 0), i(S(window.sessionStorage, T), c, 0), e.length ? (e.sort((h, _) => _.updatedAt - h.updatedAt), e[0]) : null;
|
|
262
266
|
}
|
|
263
|
-
function ue(
|
|
264
|
-
var
|
|
265
|
-
if (typeof window > "u" || !
|
|
267
|
+
function ue(a, e, t) {
|
|
268
|
+
var n, r, c, h, _, o, u, l, p;
|
|
269
|
+
if (typeof window > "u" || !a || !e) return;
|
|
266
270
|
const i = {
|
|
267
271
|
callId: e,
|
|
268
272
|
prospectId: t,
|
|
269
273
|
updatedAt: Date.now()
|
|
270
274
|
};
|
|
271
275
|
try {
|
|
272
|
-
(
|
|
276
|
+
(n = window.localStorage) == null || n.setItem(z(a), JSON.stringify(i)), (r = window.localStorage) == null || r.setItem(I(a), e), (c = window.sessionStorage) == null || c.setItem(I(a), e), t && ((h = window.localStorage) == null || h.setItem(b(a), t), (_ = window.sessionStorage) == null || _.setItem(b(a), t)), (o = window.localStorage) == null || o.setItem(T, e), (u = window.sessionStorage) == null || u.setItem(T, e), t && ((l = window.localStorage) == null || l.setItem(k, t), (p = window.sessionStorage) == null || p.setItem(k, t));
|
|
273
277
|
} catch {
|
|
274
278
|
}
|
|
275
279
|
}
|
|
@@ -278,54 +282,54 @@ const pe = /* @__PURE__ */ new Set([
|
|
|
278
282
|
"clearAudio",
|
|
279
283
|
"client_tool_cancel"
|
|
280
284
|
]);
|
|
281
|
-
function _e(
|
|
282
|
-
if (!
|
|
283
|
-
const e =
|
|
285
|
+
function _e(a) {
|
|
286
|
+
if (!a || typeof a != "object") return !1;
|
|
287
|
+
const e = a.event;
|
|
284
288
|
return typeof e == "string" && pe.has(e);
|
|
285
289
|
}
|
|
286
290
|
const x = 16 * 1024, me = 256 * 1024;
|
|
287
|
-
function E(
|
|
288
|
-
return (
|
|
291
|
+
function E(a, e) {
|
|
292
|
+
return (a == null ? void 0 : a.readyState) === "open" && (e == null ? void 0 : e.readyState) === "open";
|
|
289
293
|
}
|
|
290
|
-
function fe(
|
|
294
|
+
function fe(a, e) {
|
|
291
295
|
return {
|
|
292
|
-
control: (
|
|
296
|
+
control: (a == null ? void 0 : a.readyState) ?? "missing",
|
|
293
297
|
mediaBytes: (e == null ? void 0 : e.readyState) ?? "missing"
|
|
294
298
|
};
|
|
295
299
|
}
|
|
296
|
-
async function ye(
|
|
297
|
-
if (E(
|
|
300
|
+
async function ye(a, e, t = 8e3) {
|
|
301
|
+
if (E(a, e))
|
|
298
302
|
return !0;
|
|
299
303
|
const i = Date.now() + t;
|
|
300
304
|
for (; Date.now() < i; ) {
|
|
301
|
-
if (E(
|
|
305
|
+
if (E(a, e))
|
|
302
306
|
return !0;
|
|
303
|
-
await new Promise((
|
|
307
|
+
await new Promise((n) => setTimeout(n, 50));
|
|
304
308
|
}
|
|
305
|
-
return E(
|
|
309
|
+
return E(a, e);
|
|
306
310
|
}
|
|
307
|
-
async function H(
|
|
308
|
-
for (;
|
|
311
|
+
async function H(a) {
|
|
312
|
+
for (; a.bufferedAmount > me; )
|
|
309
313
|
await new Promise((e) => setTimeout(e, 10));
|
|
310
314
|
}
|
|
311
|
-
async function Se(
|
|
315
|
+
async function Se(a) {
|
|
312
316
|
const {
|
|
313
317
|
bytes: e,
|
|
314
318
|
filename: t,
|
|
315
319
|
contentType: i,
|
|
316
|
-
reason:
|
|
320
|
+
reason: n,
|
|
317
321
|
message: r,
|
|
318
322
|
callId: c,
|
|
319
323
|
mediaBytesChannel: h,
|
|
320
324
|
sendControlEvent: _,
|
|
321
|
-
uploadId:
|
|
325
|
+
uploadId: o = crypto.randomUUID(),
|
|
322
326
|
uploadKind: u = "media"
|
|
323
|
-
} =
|
|
327
|
+
} = a, l = e.byteLength, p = l === 0 ? 0 : Math.ceil(l / x);
|
|
324
328
|
_("client_media_upload_start", {
|
|
325
329
|
data: {
|
|
326
|
-
upload_id:
|
|
330
|
+
upload_id: o,
|
|
327
331
|
call_id: c,
|
|
328
|
-
reason:
|
|
332
|
+
reason: n,
|
|
329
333
|
message: r,
|
|
330
334
|
filename: t,
|
|
331
335
|
content_type: i,
|
|
@@ -342,37 +346,37 @@ async function Se(n) {
|
|
|
342
346
|
}
|
|
343
347
|
return await H(h), _("client_media_upload_complete", {
|
|
344
348
|
data: {
|
|
345
|
-
upload_id:
|
|
349
|
+
upload_id: o,
|
|
346
350
|
call_id: c,
|
|
347
|
-
reason:
|
|
351
|
+
reason: n,
|
|
348
352
|
message: r,
|
|
349
353
|
chunk_count: p,
|
|
350
354
|
upload_kind: u
|
|
351
355
|
}
|
|
352
|
-
}), { media_id:
|
|
356
|
+
}), { media_id: o, url: "", content_type: i };
|
|
353
357
|
}
|
|
354
|
-
async function we(
|
|
355
|
-
return typeof
|
|
358
|
+
async function we(a) {
|
|
359
|
+
return typeof a.arrayBuffer == "function" ? a.arrayBuffer() : new Response(a).arrayBuffer();
|
|
356
360
|
}
|
|
357
361
|
const ge = 15e3, R = "vanira-connect-stall-prompt";
|
|
358
362
|
let v = null;
|
|
359
|
-
function ve(
|
|
363
|
+
function ve(a = ge) {
|
|
360
364
|
typeof window > "u" || (g(!1), v = setTimeout(() => {
|
|
361
365
|
v = null, Ce(), window.dispatchEvent(new CustomEvent("vanira:connect-stall"));
|
|
362
|
-
},
|
|
366
|
+
}, a));
|
|
363
367
|
}
|
|
364
|
-
function g(
|
|
365
|
-
v !== null && (clearTimeout(v), v = null),
|
|
368
|
+
function g(a = !0) {
|
|
369
|
+
v !== null && (clearTimeout(v), v = null), a && P();
|
|
366
370
|
}
|
|
367
371
|
function P() {
|
|
368
|
-
var
|
|
369
|
-
typeof document > "u" || (
|
|
372
|
+
var a;
|
|
373
|
+
typeof document > "u" || (a = document.getElementById(R)) == null || a.remove();
|
|
370
374
|
}
|
|
371
375
|
function Ce() {
|
|
372
376
|
var t, i;
|
|
373
377
|
if (typeof document > "u" || document.getElementById(R)) return;
|
|
374
|
-
const
|
|
375
|
-
|
|
378
|
+
const a = document.createElement("div");
|
|
379
|
+
a.id = R, a.setAttribute("role", "alertdialog"), a.setAttribute("aria-modal", "true"), a.setAttribute("aria-labelledby", "vanira-stall-title"), a.style.cssText = [
|
|
376
380
|
"position:fixed",
|
|
377
381
|
"inset:0",
|
|
378
382
|
"z-index:2147483646",
|
|
@@ -408,11 +412,11 @@ function Ce() {
|
|
|
408
412
|
<p style="margin:12px 0 0;font-size:12px;color:#888">
|
|
409
413
|
Tip: Ctrl+Shift+R (Windows) or Cmd+Shift+R (Mac)
|
|
410
414
|
</p>
|
|
411
|
-
`,
|
|
415
|
+
`, a.appendChild(e), document.body.appendChild(a), (t = e.querySelector("#vanira-stall-refresh")) == null || t.addEventListener("click", () => {
|
|
412
416
|
P(), window.location.reload();
|
|
413
417
|
}), (i = e.querySelector("#vanira-stall-dismiss")) == null || i.addEventListener("click", () => P());
|
|
414
418
|
}
|
|
415
|
-
function Te(
|
|
419
|
+
function Te(a) {
|
|
416
420
|
return null;
|
|
417
421
|
}
|
|
418
422
|
function C() {
|
|
@@ -469,7 +473,7 @@ class Ie {
|
|
|
469
473
|
_ !== this.lastRoute && this.handleRouteChange(_, r);
|
|
470
474
|
};
|
|
471
475
|
c > 0 ? window.setTimeout(h, c) : queueMicrotask(h);
|
|
472
|
-
}, t = () => e("popstate"), i = () => e("hashchange"),
|
|
476
|
+
}, t = () => e("popstate"), i = () => e("hashchange"), n = (r) => {
|
|
473
477
|
const c = r.detail;
|
|
474
478
|
if ((c == null ? void 0 : c.initiated_by) === "agent") {
|
|
475
479
|
e("vanira_navigate_agent", 120);
|
|
@@ -477,10 +481,10 @@ class Ie {
|
|
|
477
481
|
}
|
|
478
482
|
e("vanira_navigate", 120);
|
|
479
483
|
};
|
|
480
|
-
window.addEventListener("popstate", t), window.addEventListener("hashchange", i), window.addEventListener("vanira:navigate",
|
|
484
|
+
window.addEventListener("popstate", t), window.addEventListener("hashchange", i), window.addEventListener("vanira:navigate", n), this.cleanupFns.push(
|
|
481
485
|
() => window.removeEventListener("popstate", t),
|
|
482
486
|
() => window.removeEventListener("hashchange", i),
|
|
483
|
-
() => window.removeEventListener("vanira:navigate",
|
|
487
|
+
() => window.removeEventListener("vanira:navigate", n)
|
|
484
488
|
), this.originalPushState = history.pushState.bind(history), this.originalReplaceState = history.replaceState.bind(history), history.pushState = (...r) => {
|
|
485
489
|
this.originalPushState(...r), e("pushState");
|
|
486
490
|
}, history.replaceState = (...r) => {
|
|
@@ -501,12 +505,12 @@ class Ie {
|
|
|
501
505
|
}
|
|
502
506
|
!this.isReady() || Te() || this.sendRouteContext("route_changed", i, t, "user");
|
|
503
507
|
}
|
|
504
|
-
sendRouteContext(e, t, i,
|
|
508
|
+
sendRouteContext(e, t, i, n = "user") {
|
|
505
509
|
const r = C();
|
|
506
510
|
this.lastRoute = r;
|
|
507
511
|
const c = {
|
|
508
512
|
ui_state: "page_navigation",
|
|
509
|
-
navigation_led_by:
|
|
513
|
+
navigation_led_by: n,
|
|
510
514
|
current_route: r,
|
|
511
515
|
current_page: r,
|
|
512
516
|
user_action: e === "call_started" ? "call_started_on_page" : "user_navigated"
|
|
@@ -565,53 +569,53 @@ const y = class y {
|
|
|
565
569
|
d(this, "connectStallTimeoutMs");
|
|
566
570
|
var _;
|
|
567
571
|
if (!e.agentId) throw new Error("agentId is required");
|
|
568
|
-
const t = !!(e.apiKey || e.token), i = !!(e.serverUrl && e.callId),
|
|
572
|
+
const t = !!(e.apiKey || e.token), i = !!(e.serverUrl && e.callId), n = y.normalizeIceServers(
|
|
569
573
|
e.iceServers
|
|
570
574
|
);
|
|
571
575
|
if (!t && !i)
|
|
572
576
|
throw new Error(
|
|
573
577
|
"apiKey or token is required — or pass serverUrl and callId from a prior POST /calls/create"
|
|
574
578
|
);
|
|
575
|
-
this.agentId = e.agentId, this.sessionBehavior = e.sessionBehavior, this.serverUrl = (e.serverUrl || "").replace(/\/$/, ""), this.apiKey = e.apiKey, this.token = e.token, this.prospectName = e.prospectName, this.welcomeMessage = ((_ = e.welcomeMessage) == null ? void 0 : _.trim()) || void 0, this.extraDetails = e.extraDetails, this.backendUrl = (e.backendUrl || ie).replace(/\/$/, ""),
|
|
579
|
+
this.agentId = e.agentId, this.sessionBehavior = e.sessionBehavior, this.serverUrl = (e.serverUrl || "").replace(/\/$/, ""), this.apiKey = e.apiKey, this.token = e.token, this.prospectName = e.prospectName, this.welcomeMessage = ((_ = e.welcomeMessage) == null ? void 0 : _.trim()) || void 0, this.extraDetails = e.extraDetails, this.backendUrl = (e.backendUrl || ie).replace(/\/$/, ""), n.length && (this.iceServers = n), i && (this.callSessionLoaded = !0);
|
|
576
580
|
const r = typeof window < "u";
|
|
577
581
|
this.prospectId = e.prospectId;
|
|
578
582
|
const c = e.sessionBehavior === "continue";
|
|
579
583
|
if (c && r && !e.callId) {
|
|
580
|
-
const
|
|
581
|
-
|
|
584
|
+
const o = W(this.agentId);
|
|
585
|
+
o && (e.callId || (this.callId = o.callId), !this.prospectId && o.prospectId && (this.prospectId = o.prospectId));
|
|
582
586
|
}
|
|
583
587
|
if (!this.prospectId && r)
|
|
584
588
|
try {
|
|
585
|
-
const
|
|
586
|
-
this.prospectId = (
|
|
589
|
+
const o = W(this.agentId);
|
|
590
|
+
this.prospectId = (o == null ? void 0 : o.prospectId) || window.sessionStorage && window.sessionStorage.getItem("vanira_prospect_id") || window.localStorage && window.localStorage.getItem("vanira_prospect_id") || void 0;
|
|
587
591
|
} catch {
|
|
588
592
|
}
|
|
589
593
|
e.callId ? this.callId = e.callId : c || (this.callId = void 0);
|
|
590
594
|
const h = e.onSessionStarted;
|
|
591
|
-
this.onSessionStarted = (
|
|
592
|
-
h == null || h(
|
|
595
|
+
this.onSessionStarted = (o) => {
|
|
596
|
+
h == null || h(o), this.emit("session_started", o);
|
|
593
597
|
}, this.liveVision = e.liveVision, this.connectStallTimeoutMs = e.connectStallTimeoutMs ?? 15e3, this.onConnected = () => {
|
|
594
|
-
var
|
|
595
|
-
g(), this._status = "connected", (
|
|
598
|
+
var o;
|
|
599
|
+
g(), this._status = "connected", (o = e.onConnected) == null || o.call(e), this.emit("connected"), this.maybeAutoStartLiveCamera();
|
|
596
600
|
}, this.onDisconnected = () => {
|
|
597
|
-
var
|
|
598
|
-
g(), this._status = "disconnected", (
|
|
599
|
-
}, this.onError = (
|
|
601
|
+
var o;
|
|
602
|
+
g(), this._status = "disconnected", (o = e.onDisconnected) == null || o.call(e), this.emit("disconnected");
|
|
603
|
+
}, this.onError = (o) => {
|
|
600
604
|
var l;
|
|
601
605
|
g(), this._status = "error";
|
|
602
|
-
const u = typeof
|
|
603
|
-
(l = e.onError) == null || l.call(e,
|
|
604
|
-
}, this.onTranscription = (
|
|
606
|
+
const u = typeof o == "string" ? o : (o == null ? void 0 : o.message) || "Connection error";
|
|
607
|
+
(l = e.onError) == null || l.call(e, o), this.emit("error", u);
|
|
608
|
+
}, this.onTranscription = (o, u, l) => {
|
|
605
609
|
var p;
|
|
606
|
-
(p = e.onTranscription) == null || p.call(e,
|
|
610
|
+
(p = e.onTranscription) == null || p.call(e, o, u), this.emit("transcription", { text: o, isFinal: u, role: l });
|
|
607
611
|
}, this.onLocalStream = e.onLocalStream || (() => {
|
|
608
|
-
}), this.onRemoteTrack = (
|
|
612
|
+
}), this.onRemoteTrack = (o, u) => {
|
|
609
613
|
var l;
|
|
610
|
-
(l = e.onRemoteTrack) == null || l.call(e,
|
|
611
|
-
}, this.onClientToolCall = (
|
|
614
|
+
(l = e.onRemoteTrack) == null || l.call(e, o, u), this.emit("track", { track: o, stream: u });
|
|
615
|
+
}, this.onClientToolCall = (o) => {
|
|
612
616
|
var p;
|
|
613
|
-
(p = e.onClientToolCall) == null || p.call(e,
|
|
614
|
-
const u = (
|
|
617
|
+
(p = e.onClientToolCall) == null || p.call(e, o);
|
|
618
|
+
const u = (o == null ? void 0 : o.data) || o, l = {
|
|
615
619
|
name: String(u.name || u.tool_name || ""),
|
|
616
620
|
arguments: u.arguments || u.args || {},
|
|
617
621
|
tool_call_id: String(u.tool_call_id || u.call_id || ""),
|
|
@@ -620,10 +624,10 @@ const y = class y {
|
|
|
620
624
|
};
|
|
621
625
|
l.name && l.tool_call_id && this.emit("tool_call", l);
|
|
622
626
|
}, this.runtime = e.runtime, typeof window < "u" && e.trackRouteContext !== !1 && (this.routeTracker = new Ie({
|
|
623
|
-
sendContext: (
|
|
627
|
+
sendContext: (o) => this.sendContextUpdate(o),
|
|
624
628
|
isReady: () => {
|
|
625
|
-
var
|
|
626
|
-
return ((
|
|
629
|
+
var o;
|
|
630
|
+
return ((o = this.dataChannel) == null ? void 0 : o.readyState) === "open";
|
|
627
631
|
}
|
|
628
632
|
}));
|
|
629
633
|
}
|
|
@@ -664,9 +668,9 @@ const y = class y {
|
|
|
664
668
|
iceServers: i,
|
|
665
669
|
iceTransportPolicy: "all"
|
|
666
670
|
});
|
|
667
|
-
let
|
|
671
|
+
let n;
|
|
668
672
|
try {
|
|
669
|
-
|
|
673
|
+
n = await navigator.mediaDevices.getUserMedia({
|
|
670
674
|
audio: {
|
|
671
675
|
echoCancellation: !0,
|
|
672
676
|
noiseSuppression: !0,
|
|
@@ -686,16 +690,16 @@ const y = class y {
|
|
|
686
690
|
throw l;
|
|
687
691
|
}
|
|
688
692
|
if (this.isConnectCancelled(e)) {
|
|
689
|
-
|
|
693
|
+
n.getTracks().forEach((l) => l.stop());
|
|
690
694
|
return;
|
|
691
695
|
}
|
|
692
|
-
if (this.localStream =
|
|
693
|
-
|
|
696
|
+
if (this.localStream = n, !this.pc || this.isConnectCancelled(e)) {
|
|
697
|
+
n.getTracks().forEach((l) => l.stop());
|
|
694
698
|
return;
|
|
695
699
|
}
|
|
696
|
-
if (this.onLocalStream(
|
|
700
|
+
if (this.onLocalStream(n), n.getTracks().forEach((l) => {
|
|
697
701
|
var p;
|
|
698
|
-
(p = this.pc) == null || p.addTrack(l,
|
|
702
|
+
(p = this.pc) == null || p.addTrack(l, n);
|
|
699
703
|
}), !this.pc)
|
|
700
704
|
throw new Error("RTCPeerConnection was closed unexpectedly");
|
|
701
705
|
this.dataChannel = this.pc.createDataChannel("control"), this.dataChannel.onopen = () => {
|
|
@@ -745,7 +749,7 @@ const y = class y {
|
|
|
745
749
|
};
|
|
746
750
|
const h = await this.pc.createOffer();
|
|
747
751
|
if (this.isConnectCancelled(e) || (await this.pc.setLocalDescription(h), this.isConnectCancelled(e))) return;
|
|
748
|
-
const _ = this.serverUrl.includes("?") ? this.serverUrl : `${this.serverUrl}/webrtc?agent=${this.agentId}_${this.callId}`,
|
|
752
|
+
const _ = this.serverUrl.includes("?") ? this.serverUrl : `${this.serverUrl}/webrtc?agent=${this.agentId}_${this.callId}`, o = await fetch(_, {
|
|
749
753
|
method: "POST",
|
|
750
754
|
headers: { "Content-Type": "application/json" },
|
|
751
755
|
body: JSON.stringify({
|
|
@@ -755,11 +759,11 @@ const y = class y {
|
|
|
755
759
|
})
|
|
756
760
|
});
|
|
757
761
|
if (this.isConnectCancelled(e)) return;
|
|
758
|
-
if (!
|
|
759
|
-
const l = await
|
|
760
|
-
throw new Error(l.error || `HTTP ${
|
|
762
|
+
if (!o.ok) {
|
|
763
|
+
const l = await o.json();
|
|
764
|
+
throw new Error(l.error || `HTTP ${o.status}`);
|
|
761
765
|
}
|
|
762
|
-
const { answer: u } = await
|
|
766
|
+
const { answer: u } = await o.json();
|
|
763
767
|
if (this.isConnectCancelled(e) || !this.pc || (await this.pc.setRemoteDescription(u), this.isConnectCancelled(e)) || (this.remoteDescSet = !0, await this.flushPendingServerIce(), this.isConnectCancelled(e))) return;
|
|
764
768
|
this.startRemoteIcePolling(c);
|
|
765
769
|
} catch (i) {
|
|
@@ -780,8 +784,8 @@ const y = class y {
|
|
|
780
784
|
].join("|");
|
|
781
785
|
}
|
|
782
786
|
async postCreateCall(e, t, i) {
|
|
783
|
-
var h, _,
|
|
784
|
-
const
|
|
787
|
+
var h, _, o;
|
|
788
|
+
const n = await fetch(`${this.backendUrl}/calls/create`, {
|
|
785
789
|
method: "POST",
|
|
786
790
|
headers: e,
|
|
787
791
|
body: JSON.stringify({
|
|
@@ -796,11 +800,11 @@ const y = class y {
|
|
|
796
800
|
...i ? { call_id: i } : {}
|
|
797
801
|
})
|
|
798
802
|
});
|
|
799
|
-
if (!
|
|
800
|
-
const u = await
|
|
801
|
-
throw new Error(`[VaniraClient] createCall failed (${
|
|
803
|
+
if (!n.ok) {
|
|
804
|
+
const u = await n.json().catch(() => ({}));
|
|
805
|
+
throw new Error(`[VaniraClient] createCall failed (${n.status}): ${((o = u == null ? void 0 : u.detail) == null ? void 0 : o.message) || (u == null ? void 0 : u.message) || n.statusText}`);
|
|
802
806
|
}
|
|
803
|
-
const r = await
|
|
807
|
+
const r = await n.json();
|
|
804
808
|
if (!r.call_id || !r.worker_url)
|
|
805
809
|
throw new Error("[VaniraClient] /calls/create response missing call_id or worker_url");
|
|
806
810
|
const c = y.normalizeIceServers(r.ice_servers);
|
|
@@ -830,10 +834,10 @@ const y = class y {
|
|
|
830
834
|
throw new Error("[VaniraClient] apiKey or token is required to create a call session");
|
|
831
835
|
const e = { "Content-Type": "application/json" };
|
|
832
836
|
this.apiKey ? e["X-API-Key"] = this.apiKey : this.token && (e.Authorization = this.token.startsWith("Bearer ") ? this.token : `Bearer ${this.token}`);
|
|
833
|
-
const t = this.sessionBehavior === "continue" ? this.callId : void 0, i = this.sessionBehavior === "continue" ? "continue" : "new",
|
|
834
|
-
let r = y.inflightCreates.get(
|
|
835
|
-
r || (r = this.postCreateCall(e, i, t), y.inflightCreates.set(
|
|
836
|
-
y.inflightCreates.get(
|
|
837
|
+
const t = this.sessionBehavior === "continue" ? this.callId : void 0, i = this.sessionBehavior === "continue" ? "continue" : "new", n = this.createCallCacheKey(i, t);
|
|
838
|
+
let r = y.inflightCreates.get(n);
|
|
839
|
+
r || (r = this.postCreateCall(e, i, t), y.inflightCreates.set(n, r), r.finally(() => {
|
|
840
|
+
y.inflightCreates.get(n) === r && y.inflightCreates.delete(n);
|
|
837
841
|
}));
|
|
838
842
|
const c = await r;
|
|
839
843
|
this.applyCreateCallSession(c);
|
|
@@ -847,7 +851,7 @@ const y = class y {
|
|
|
847
851
|
if (!Array.isArray(e)) return [];
|
|
848
852
|
const t = [];
|
|
849
853
|
for (const i of e) {
|
|
850
|
-
const
|
|
854
|
+
const n = i == null ? void 0 : i.urls, r = Array.isArray(n) ? n.filter(Boolean) : typeof n == "string" && n.trim() ? [n.trim()] : [];
|
|
851
855
|
if (!r.length) continue;
|
|
852
856
|
const c = { urls: r.length === 1 ? r[0] : r }, h = i.username, _ = i.credential;
|
|
853
857
|
h && (c.username = h), _ && (c.credential = _), t.push(c);
|
|
@@ -883,8 +887,8 @@ const y = class y {
|
|
|
883
887
|
body: JSON.stringify({ candidate: e.toJSON() })
|
|
884
888
|
});
|
|
885
889
|
if (i.ok) {
|
|
886
|
-
const
|
|
887
|
-
await this.applyServerIceCandidates(
|
|
890
|
+
const n = await i.json();
|
|
891
|
+
await this.applyServerIceCandidates(n.candidates);
|
|
888
892
|
}
|
|
889
893
|
} catch {
|
|
890
894
|
}
|
|
@@ -930,8 +934,8 @@ const y = class y {
|
|
|
930
934
|
var i;
|
|
931
935
|
const t = Date.now() + 15e3;
|
|
932
936
|
for (; !this.icePollStop && Date.now() < t; ) {
|
|
933
|
-
const
|
|
934
|
-
if (
|
|
937
|
+
const n = (i = this.pc) == null ? void 0 : i.connectionState;
|
|
938
|
+
if (n === "connected" || n === "failed" || n === "closed") break;
|
|
935
939
|
try {
|
|
936
940
|
const r = await fetch(e, { method: "GET" });
|
|
937
941
|
if (r.ok) {
|
|
@@ -952,15 +956,15 @@ const y = class y {
|
|
|
952
956
|
sendEvent(e, t = {}) {
|
|
953
957
|
var i;
|
|
954
958
|
if (((i = this.dataChannel) == null ? void 0 : i.readyState) === "open") {
|
|
955
|
-
const
|
|
956
|
-
this.dataChannel.send(JSON.stringify(
|
|
959
|
+
const n = { event: e, ...t };
|
|
960
|
+
this.dataChannel.send(JSON.stringify(n));
|
|
957
961
|
}
|
|
958
962
|
}
|
|
959
963
|
/** Wait for control DataChannel, then send (live vision lifecycle events). */
|
|
960
964
|
async sendEventWhenReady(e, t = {}, i = 1e4) {
|
|
961
965
|
var r;
|
|
962
|
-
const
|
|
963
|
-
for (; Date.now() <
|
|
966
|
+
const n = Date.now() + i;
|
|
967
|
+
for (; Date.now() < n; ) {
|
|
964
968
|
if (((r = this.dataChannel) == null ? void 0 : r.readyState) === "open")
|
|
965
969
|
return this.sendEvent(e, t), !0;
|
|
966
970
|
await new Promise((c) => setTimeout(c, 50));
|
|
@@ -978,7 +982,7 @@ const y = class y {
|
|
|
978
982
|
name: "open_live_camera",
|
|
979
983
|
tool_call_id: `lv_${crypto.randomUUID()}`,
|
|
980
984
|
execution_mode: "fire_and_forget",
|
|
981
|
-
client_fields: { preset_id:
|
|
985
|
+
client_fields: { preset_id: s.LiveVision },
|
|
982
986
|
arguments: {
|
|
983
987
|
mode: "live",
|
|
984
988
|
scope: t,
|
|
@@ -1006,33 +1010,33 @@ const y = class y {
|
|
|
1006
1010
|
this.dispatchBoardAbort(
|
|
1007
1011
|
"User interrupted while LaTeX was writing",
|
|
1008
1012
|
void 0,
|
|
1009
|
-
|
|
1013
|
+
s.WriteLatexText
|
|
1010
1014
|
);
|
|
1011
1015
|
break;
|
|
1012
1016
|
case "transcription":
|
|
1013
1017
|
{
|
|
1014
|
-
const i = e.data && typeof e.data == "object" ? e.data : {},
|
|
1018
|
+
const i = e.data && typeof e.data == "object" ? e.data : {}, n = String(e.text ?? i.text ?? "").trim(), r = e.isFinal ?? e.is_final ?? i.isFinal ?? i.is_final, c = r === void 0 ? !0 : r === !0 || r === "true", h = String(
|
|
1015
1019
|
e.role ?? e.speaker ?? i.role ?? i.speaker ?? ""
|
|
1016
1020
|
).trim() || void 0;
|
|
1017
|
-
|
|
1021
|
+
n && this.onTranscription(n, c, h);
|
|
1018
1022
|
}
|
|
1019
1023
|
break;
|
|
1020
1024
|
case "mark":
|
|
1021
1025
|
break;
|
|
1022
1026
|
case "client_tool_cancel": {
|
|
1023
|
-
const
|
|
1024
|
-
this.dispatchBoardAbort("Tool cancelled by server",
|
|
1027
|
+
const n = (e.data || e).tool_call_id || e.tool_call_id;
|
|
1028
|
+
this.dispatchBoardAbort("Tool cancelled by server", n);
|
|
1025
1029
|
break;
|
|
1026
1030
|
}
|
|
1027
1031
|
case "client_tool_call": {
|
|
1028
|
-
const i = e.tool_call || e.data || e,
|
|
1029
|
-
|
|
1032
|
+
const i = e.tool_call || e.data || e, n = (i == null ? void 0 : i.tool_call_id) || (i == null ? void 0 : i.call_id) || e.tool_call_id || "";
|
|
1033
|
+
n && ((t = this.dataChannel) == null ? void 0 : t.readyState) === "open" && this.dataChannel.send(JSON.stringify({
|
|
1030
1034
|
event: "client_tool_ack",
|
|
1031
|
-
data: { tool_call_id:
|
|
1035
|
+
data: { tool_call_id: n }
|
|
1032
1036
|
}));
|
|
1033
1037
|
const r = (i == null ? void 0 : i.arguments) || (i == null ? void 0 : i.args) || {}, c = (i == null ? void 0 : i.client_fields) || {}, h = (i == null ? void 0 : i.name) || (i == null ? void 0 : i.tool_name) || "", _ = he(c, r, h);
|
|
1034
1038
|
if (h === "end_call") {
|
|
1035
|
-
|
|
1039
|
+
n && this.sendToolResult(n, {
|
|
1036
1040
|
status: "client_ack_end_call",
|
|
1037
1041
|
message: "Ending call."
|
|
1038
1042
|
}), window.setTimeout(() => this.disconnect(), 120);
|
|
@@ -1069,11 +1073,11 @@ const y = class y {
|
|
|
1069
1073
|
*/
|
|
1070
1074
|
setMicrophoneMuted(e) {
|
|
1071
1075
|
var t, i;
|
|
1072
|
-
this.micMuted = e, (t = this.localStream) == null || t.getAudioTracks().forEach((
|
|
1073
|
-
|
|
1074
|
-
}), (i = this.pc) == null || i.getSenders().forEach((
|
|
1076
|
+
this.micMuted = e, (t = this.localStream) == null || t.getAudioTracks().forEach((n) => {
|
|
1077
|
+
n.enabled = !e;
|
|
1078
|
+
}), (i = this.pc) == null || i.getSenders().forEach((n) => {
|
|
1075
1079
|
var r;
|
|
1076
|
-
((r =
|
|
1080
|
+
((r = n.track) == null ? void 0 : r.kind) === "audio" && (n.track.enabled = !e);
|
|
1077
1081
|
});
|
|
1078
1082
|
}
|
|
1079
1083
|
isMicrophoneMuted() {
|
|
@@ -1188,16 +1192,16 @@ const y = class y {
|
|
|
1188
1192
|
* the server adds client_media_upload_ready ack — use HTTP for frame JPEGs until then.
|
|
1189
1193
|
*/
|
|
1190
1194
|
async uploadMediaFrame(e, t = "camera_capture", i) {
|
|
1191
|
-
const
|
|
1195
|
+
const n = i && !(e instanceof File) ? new File([e], i, { type: e.type || "image/jpeg" }) : e, { media_id: r, url: c, contentType: h } = await this._postMediaUpload(n, t, !0);
|
|
1192
1196
|
if (!r || !c)
|
|
1193
1197
|
throw new Error("Frame upload failed: server response missing media_id or url");
|
|
1194
1198
|
return { media_id: r, url: c, content_type: h };
|
|
1195
1199
|
}
|
|
1196
1200
|
/** WebRTC media-bytes path (control start/complete + binary chunks). */
|
|
1197
|
-
async _uploadBytesViaDataChannel(e, t, i,
|
|
1201
|
+
async _uploadBytesViaDataChannel(e, t, i, n, r) {
|
|
1198
1202
|
if (!this.callId || !this.mediaBytesChannel)
|
|
1199
1203
|
throw new Error("Upload failed: call not ready for WebRTC media upload.");
|
|
1200
|
-
const c = r || (e instanceof File ? e.name :
|
|
1204
|
+
const c = r || (e instanceof File ? e.name : n === "frame" ? "frame.jpg" : "upload.bin"), h = e.type || (n === "frame" ? "image/jpeg" : "application/octet-stream"), _ = await we(e);
|
|
1201
1205
|
return Se({
|
|
1202
1206
|
bytes: _,
|
|
1203
1207
|
filename: c,
|
|
@@ -1206,36 +1210,36 @@ const y = class y {
|
|
|
1206
1210
|
message: i,
|
|
1207
1211
|
callId: this.callId,
|
|
1208
1212
|
mediaBytesChannel: this.mediaBytesChannel,
|
|
1209
|
-
sendControlEvent: (
|
|
1210
|
-
uploadKind:
|
|
1213
|
+
sendControlEvent: (o, u) => this.sendEvent(o, u),
|
|
1214
|
+
uploadKind: n
|
|
1211
1215
|
});
|
|
1212
1216
|
}
|
|
1213
1217
|
async _uploadMediaViaDataChannel(e, t, i) {
|
|
1214
|
-
const
|
|
1215
|
-
return { media_id:
|
|
1218
|
+
const n = await this._uploadBytesViaDataChannel(e, t, i, "media");
|
|
1219
|
+
return { media_id: n.media_id, url: n.url };
|
|
1216
1220
|
}
|
|
1217
1221
|
/** HTTP fallback — original uploadMedia behavior (unchanged). */
|
|
1218
1222
|
async _uploadMediaViaHTTP(e, t = "general", i = "") {
|
|
1219
|
-
const { media_id:
|
|
1223
|
+
const { media_id: n, url: r, contentType: c } = await this._postMediaUpload(e, t, !0);
|
|
1220
1224
|
return this.sendMediaUpdate({
|
|
1221
|
-
media_id:
|
|
1225
|
+
media_id: n,
|
|
1222
1226
|
media_url: r,
|
|
1223
1227
|
content_type: c,
|
|
1224
1228
|
reason: t,
|
|
1225
1229
|
message: i
|
|
1226
|
-
}), { media_id:
|
|
1230
|
+
}), { media_id: n, url: r };
|
|
1227
1231
|
}
|
|
1228
1232
|
async _postMediaUpload(e, t, i = !1) {
|
|
1229
1233
|
if (!this.serverUrl)
|
|
1230
1234
|
throw new Error("Upload failed: serverUrl is not set. Connect the VaniraClient first.");
|
|
1231
1235
|
if (!this.callId)
|
|
1232
1236
|
throw new Error("Upload failed: callId is missing.");
|
|
1233
|
-
const
|
|
1234
|
-
if (!
|
|
1237
|
+
const n = this.getWorkerOrigin();
|
|
1238
|
+
if (!n)
|
|
1235
1239
|
throw new Error(
|
|
1236
1240
|
"Upload failed: worker_url is not set. Connect the call before uploading media."
|
|
1237
1241
|
);
|
|
1238
|
-
const r = `${
|
|
1242
|
+
const r = `${n}/media/upload`, c = new FormData();
|
|
1239
1243
|
c.append("file", e), c.append("call_id", this.callId), c.append("reason", t);
|
|
1240
1244
|
const h = await fetch(r, {
|
|
1241
1245
|
method: "POST",
|
|
@@ -1249,10 +1253,10 @@ const y = class y {
|
|
|
1249
1253
|
}
|
|
1250
1254
|
throw new Error(`Upload failed: ${p}`);
|
|
1251
1255
|
}
|
|
1252
|
-
const _ = await h.json(),
|
|
1253
|
-
if (!
|
|
1256
|
+
const _ = await h.json(), o = _.media_id, u = _.url, l = _.content_type || e.type;
|
|
1257
|
+
if (!o || !u)
|
|
1254
1258
|
throw new Error("Upload failed: server response missing media_id or url");
|
|
1255
|
-
return i ? { media_id:
|
|
1259
|
+
return i ? { media_id: o, url: u, contentType: l } : { media_id: o, url: u, contentType: l };
|
|
1256
1260
|
}
|
|
1257
1261
|
// ─── Event emitter (replaces retired VaniraAI) ───────────────────────────
|
|
1258
1262
|
get status() {
|
|
@@ -1270,7 +1274,7 @@ const y = class y {
|
|
|
1270
1274
|
}
|
|
1271
1275
|
emit(e, t) {
|
|
1272
1276
|
var i;
|
|
1273
|
-
(i = this.listeners.get(e)) == null || i.forEach((
|
|
1277
|
+
(i = this.listeners.get(e)) == null || i.forEach((n) => n(t));
|
|
1274
1278
|
}
|
|
1275
1279
|
/** Alias for connect() — VaniraAI compatibility */
|
|
1276
1280
|
async start() {
|
|
@@ -1321,15 +1325,15 @@ const be = {
|
|
|
1321
1325
|
peer: new ee(),
|
|
1322
1326
|
dataChannel: new te()
|
|
1323
1327
|
};
|
|
1324
|
-
function Y(
|
|
1328
|
+
function Y(a) {
|
|
1325
1329
|
return new A({
|
|
1326
|
-
...
|
|
1330
|
+
...a,
|
|
1327
1331
|
runtime: xe
|
|
1328
1332
|
});
|
|
1329
1333
|
}
|
|
1330
1334
|
const Re = Y;
|
|
1331
|
-
function Ee(
|
|
1332
|
-
return Y(
|
|
1335
|
+
function Ee(a) {
|
|
1336
|
+
return Y(a);
|
|
1333
1337
|
}
|
|
1334
1338
|
const Pe = Ee;
|
|
1335
1339
|
export {
|