@burdenoff/fe-libs 2026.1024.3 → 2026.1024.4
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/shared/assistant/avatar/live/LiveAvatarMinutes.d.ts +24 -0
- package/dist/shared/assistant/avatar/live/LiveAvatarMinutes.js +161 -0
- package/dist/shared/assistant/avatar/live/LiveAvatarStage.js +95 -73
- package/dist/shared/assistant/avatar/live/LiveAvatarTabView.d.ts +6 -0
- package/dist/shared/assistant/avatar/live/LiveAvatarTabView.js +195 -171
- package/dist/shared/assistant/avatar/live/avatarSessionClient.d.ts +77 -1
- package/dist/shared/assistant/avatar/live/avatarSessionClient.js +193 -72
- package/dist/shared/assistant/avatar/live/createLiveAvatarSeam.d.ts +14 -1
- package/dist/shared/assistant/avatar/live/createLiveAvatarSeam.js +65 -40
- package/dist/shared/assistant/avatar/live/liveAvatarController.d.ts +64 -2
- package/dist/shared/assistant/avatar/live/liveAvatarController.js +403 -242
- package/dist/shared/assistant/avatar/live/liveAvatarMinutesView.d.ts +127 -0
- package/dist/shared/assistant/avatar/live/liveAvatarMinutesView.js +168 -0
- package/dist/shared/assistant/avatar/live/liveAvatarStatus.d.ts +3 -0
- package/dist/shared/assistant/avatar/live/liveAvatarStatus.js +11 -7
- package/dist/shared/assistant/avatar/useAvatarCopy.d.ts +127 -2
- package/dist/shared/assistant/avatar/useAvatarCopy.js +116 -7
- package/dist/shared/assistant/i18nManifest.d.ts +32 -1
- package/dist/shared/assistant/i18nManifest.js +55 -24
- package/dist/shared/assistant/index.d.ts +2 -0
- package/dist/shared/assistant/ui/AssistantChatArea.js +17 -17
- package/dist/shared/assistant/ui/AssistantMarkdownRenderer.d.ts +5 -2
- package/dist/shared/assistant/ui/assistantLiveAvatarSeam.d.ts +10 -2
- package/dist/shared/assistant/ui/avatar/AssistantAvatarTab.js +78 -76
- package/dist/shared/assistant/ui/avatar/avatarAskGate.d.ts +2 -0
- package/dist/shared/assistant/ui/avatar/avatarAskGate.js +1 -0
- package/dist/shared/events/index.d.ts +2 -1
- package/dist/shared-assistant.js +227 -225
- package/package.json +1 -1
|
@@ -23,16 +23,34 @@ var o = [
|
|
|
23
23
|
"person",
|
|
24
24
|
"workspace",
|
|
25
25
|
"everyone"
|
|
26
|
-
], c =
|
|
26
|
+
], c = 2, l = [
|
|
27
|
+
"AVAILABLE",
|
|
28
|
+
"IN_USE",
|
|
29
|
+
"EXHAUSTED",
|
|
30
|
+
"UNAVAILABLE"
|
|
31
|
+
], u = [
|
|
32
|
+
"FREE_CEILING",
|
|
33
|
+
"ZERO_SESSION_LIMIT",
|
|
34
|
+
"NOT_INCLUDED",
|
|
35
|
+
"OWN_SESSION"
|
|
36
|
+
], d = {
|
|
37
|
+
IN_USE: ["OWN_SESSION"],
|
|
38
|
+
EXHAUSTED: ["FREE_CEILING", "NOT_INCLUDED"]
|
|
39
|
+
}, f = [
|
|
40
|
+
"FREE_CEILING",
|
|
41
|
+
"ZERO_SESSION_LIMIT",
|
|
42
|
+
"NOT_INCLUDED"
|
|
43
|
+
], p = class extends Error {
|
|
27
44
|
status;
|
|
28
45
|
code;
|
|
29
46
|
retryAfterSeconds;
|
|
30
47
|
scope;
|
|
31
|
-
|
|
32
|
-
|
|
48
|
+
minutesReason;
|
|
49
|
+
constructor(e, t, n, r = null, i = null) {
|
|
50
|
+
super(`avatar api ${e} ${t}`), this.status = e, this.code = t, this.retryAfterSeconds = n, this.scope = r, this.minutesReason = i, this.name = "AvatarApiError";
|
|
33
51
|
}
|
|
34
52
|
};
|
|
35
|
-
function
|
|
53
|
+
function m(e = globalThis.crypto) {
|
|
36
54
|
if (e && typeof e.randomUUID == "function") return e.randomUUID();
|
|
37
55
|
let t = new Uint8Array(16);
|
|
38
56
|
if (e && typeof e.getRandomValues == "function") e.getRandomValues(t);
|
|
@@ -41,43 +59,96 @@ function l(e = globalThis.crypto) {
|
|
|
41
59
|
let n = [...t].map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
42
60
|
return `${n.slice(0, 8)}-${n.slice(8, 12)}-${n.slice(12, 16)}-${n.slice(16, 20)}-${n.slice(20)}`;
|
|
43
61
|
}
|
|
44
|
-
function
|
|
62
|
+
function h(e) {
|
|
45
63
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
46
64
|
}
|
|
47
|
-
function
|
|
65
|
+
function g(e, t) {
|
|
48
66
|
let n = e.headers.get("retry-after"), r = n === null || n.trim() === "" ? NaN : Number(n);
|
|
49
67
|
if (Number.isFinite(r) && r >= 0) return r;
|
|
50
|
-
let i =
|
|
68
|
+
let i = h(t) && h(t.error) ? Number(t.error.retryAfterSeconds) : NaN;
|
|
51
69
|
return Number.isFinite(i) && i >= 0 ? i : null;
|
|
52
70
|
}
|
|
53
|
-
async function
|
|
71
|
+
async function _(e) {
|
|
54
72
|
try {
|
|
55
73
|
return await e.json();
|
|
56
74
|
} catch {
|
|
57
75
|
return null;
|
|
58
76
|
}
|
|
59
77
|
}
|
|
60
|
-
function
|
|
61
|
-
if (e !== "budget_exhausted" || !
|
|
78
|
+
function v(e, t) {
|
|
79
|
+
if (e !== "budget_exhausted" || !h(t) || !h(t.error)) return null;
|
|
62
80
|
let { scope: n } = t.error;
|
|
63
81
|
return s.find((e) => e === n) ?? null;
|
|
64
82
|
}
|
|
65
|
-
async function
|
|
66
|
-
let t = await
|
|
67
|
-
return new
|
|
83
|
+
async function y(e) {
|
|
84
|
+
let t = await _(e), n = h(t) && h(t.error) && typeof t.error.code == "string" ? t.error.code : "http_error", r = n === "minutes_exhausted" && h(t) && h(t.error) ? b(t.error.reason, f) : null;
|
|
85
|
+
return new p(e.status, n, g(e, t), v(n, t), r);
|
|
68
86
|
}
|
|
69
|
-
function
|
|
70
|
-
|
|
71
|
-
|
|
87
|
+
function b(e, t) {
|
|
88
|
+
return t.find((t) => t === e) ?? null;
|
|
89
|
+
}
|
|
90
|
+
function x(e) {
|
|
91
|
+
return typeof e == "number" && Number.isSafeInteger(e) && e >= 0 ? e : null;
|
|
92
|
+
}
|
|
93
|
+
function S(e) {
|
|
94
|
+
return e === null ? null : x(e) ?? void 0;
|
|
95
|
+
}
|
|
96
|
+
function C(e) {
|
|
97
|
+
if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(e)) return null;
|
|
98
|
+
let t = Date.parse(e);
|
|
99
|
+
return Number.isFinite(t) && new Date(t).toISOString() === e ? t : null;
|
|
100
|
+
}
|
|
101
|
+
function w(e) {
|
|
102
|
+
let t = x(e.availableMinutes), n = x(e.heldMinutes), r = x(e.freeMinutesPerMonth), i = x(e.freeRemaining), a = x(e.planMinutesPerMonth), o = x(e.planRemaining), s = x(e.carriedRemaining), c = S(e.personFreeCeiling), l = S(e.personFreeRemaining), u = C(e.resetsAt), { morePlanCreditsAvailable: d } = e;
|
|
103
|
+
return t === null || n === null || r === null || i === null || a === null || o === null || s === null || c === void 0 || l === void 0 || u === null || typeof d != "boolean" ? null : {
|
|
104
|
+
availableMinutes: t,
|
|
105
|
+
heldMinutes: n,
|
|
106
|
+
freeMinutesPerMonth: r,
|
|
107
|
+
freeRemaining: i,
|
|
108
|
+
planMinutesPerMonth: a,
|
|
109
|
+
planRemaining: o,
|
|
110
|
+
carriedRemaining: s,
|
|
111
|
+
personFreeCeiling: c,
|
|
112
|
+
personFreeRemaining: l,
|
|
113
|
+
resetsAt: u,
|
|
114
|
+
morePlanCreditsAvailable: d
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function T(e) {
|
|
118
|
+
if (!h(e) || e.version !== 2) return null;
|
|
119
|
+
let t = l.find((t) => t === e.state);
|
|
120
|
+
if (t === void 0) return null;
|
|
121
|
+
let n = null;
|
|
122
|
+
if (t !== "UNAVAILABLE" && (n = w(e), n === null || (t === "AVAILABLE" ? n.availableMinutes < 1 : n.availableMinutes !== 0))) return null;
|
|
123
|
+
let r = e.staleSeconds;
|
|
124
|
+
return {
|
|
125
|
+
state: t,
|
|
126
|
+
reason: b(e.reason, d[t] ?? []),
|
|
127
|
+
balance: n,
|
|
128
|
+
staleSeconds: typeof r == "number" && Number.isSafeInteger(r) && r >= 20 && r <= 120 ? r : null
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function E(e) {
|
|
132
|
+
if (!h(e)) return null;
|
|
133
|
+
let t = x(e.reserved);
|
|
134
|
+
return t === null || t < 1 || typeof e.limitedByBalance != "boolean" ? null : {
|
|
135
|
+
reserved: t,
|
|
136
|
+
limitedByBalance: e.limitedByBalance
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function D(e) {
|
|
140
|
+
if (!h(e) || typeof e.available != "boolean") throw new p(200, "invalid_response", null);
|
|
141
|
+
let t = Array.isArray(e.avatars) ? e.avatars.flatMap((e) => h(e) && typeof e.id == "string" && r.test(e.id) ? [e.id] : []) : [], n = o.find((t) => t === e.reason) ?? null, i = typeof e.consentVersion == "string" ? e.consentVersion : "", a = typeof e.maxSessionSeconds == "number" && Number.isFinite(e.maxSessionSeconds) ? e.maxSessionSeconds : 0, s = e.available && t.length > 0 && i !== "" && a > 0, c = T(e.minutes);
|
|
72
142
|
return {
|
|
73
143
|
available: s,
|
|
74
144
|
reason: s ? null : n ?? "not_enabled",
|
|
75
145
|
avatars: t,
|
|
76
146
|
consentVersion: i,
|
|
77
|
-
maxSessionSeconds: a
|
|
147
|
+
maxSessionSeconds: a,
|
|
148
|
+
...c === null ? {} : { minutes: c }
|
|
78
149
|
};
|
|
79
150
|
}
|
|
80
|
-
function
|
|
151
|
+
function O(e) {
|
|
81
152
|
try {
|
|
82
153
|
let n = new URL(e);
|
|
83
154
|
return n.protocol === "wss:" ? !0 : n.protocol === "ws:" && t.has(n.hostname.toLowerCase());
|
|
@@ -85,20 +156,23 @@ function g(e) {
|
|
|
85
156
|
return !1;
|
|
86
157
|
}
|
|
87
158
|
}
|
|
88
|
-
function
|
|
89
|
-
if (!
|
|
90
|
-
let { sessionId: t, livekitUrl: r, participantToken: i, avatarIdentity: a, connectBy: o, endsAt: s } = e,
|
|
91
|
-
if (typeof t != "string" || !n.test(t) || typeof r != "string" || !
|
|
159
|
+
function k(e) {
|
|
160
|
+
if (!h(e)) throw new p(201, "invalid_response", null);
|
|
161
|
+
let { sessionId: t, livekitUrl: r, participantToken: i, avatarIdentity: a, connectBy: o, endsAt: s } = e, c = typeof o == "string" ? Date.parse(o) : NaN, l = typeof s == "string" ? Date.parse(s) : NaN;
|
|
162
|
+
if (typeof t != "string" || !n.test(t) || typeof r != "string" || !O(r) || typeof i != "string" || i === "" || typeof a != "string" || a === "" || !Number.isFinite(c) || !Number.isFinite(l)) throw new p(201, "invalid_response", null);
|
|
163
|
+
let { maxSessionSeconds: u } = e, d = typeof u == "number" && Number.isSafeInteger(u) && u > 0 ? u : null, f = E(e.minutes);
|
|
92
164
|
return {
|
|
93
165
|
sessionId: t,
|
|
94
166
|
livekitUrl: r,
|
|
95
167
|
participantToken: i,
|
|
96
168
|
avatarIdentity: a,
|
|
97
|
-
connectBy:
|
|
98
|
-
endsAt:
|
|
169
|
+
connectBy: c,
|
|
170
|
+
endsAt: l,
|
|
171
|
+
...d === null ? {} : { maxSessionSeconds: d },
|
|
172
|
+
...f === null ? {} : { minutes: f }
|
|
99
173
|
};
|
|
100
174
|
}
|
|
101
|
-
var
|
|
175
|
+
var A = [
|
|
102
176
|
"starting",
|
|
103
177
|
"ready",
|
|
104
178
|
"ending",
|
|
@@ -106,22 +180,22 @@ var v = [
|
|
|
106
180
|
"failed",
|
|
107
181
|
"canceled"
|
|
108
182
|
];
|
|
109
|
-
function
|
|
110
|
-
if (!
|
|
183
|
+
function j(e, t) {
|
|
184
|
+
if (!h(e) || !A.includes(e.state)) throw new p(200, "invalid_response", null);
|
|
111
185
|
return {
|
|
112
186
|
sessionId: t,
|
|
113
187
|
state: e.state,
|
|
114
188
|
endedReason: typeof e.endedReason == "string" ? e.endedReason : null
|
|
115
189
|
};
|
|
116
190
|
}
|
|
117
|
-
var
|
|
191
|
+
var M = (e) => new Promise((t) => {
|
|
118
192
|
setTimeout(t, e);
|
|
119
193
|
});
|
|
120
|
-
function
|
|
121
|
-
let t = e.fetchImpl ?? ((e, t) => fetch(e, t)), a = e.sleep ??
|
|
122
|
-
async function
|
|
194
|
+
function N(e) {
|
|
195
|
+
let t = e.fetchImpl ?? ((e, t) => fetch(e, t)), a = e.sleep ?? M, o = e.now ?? (() => Date.now()), s = e.startInProgressBudgetMs ?? 15e3, c = e.baseUrl.replace(/\/+$/, "");
|
|
196
|
+
async function l(t, n = null) {
|
|
123
197
|
let r = e.getAuthorization();
|
|
124
|
-
if (!r) throw new
|
|
198
|
+
if (!r) throw new p(401, "unauthenticated", null);
|
|
125
199
|
let i = { authorization: r };
|
|
126
200
|
if (t) {
|
|
127
201
|
let t = await e.getWorkspaceAuthorization(n === null ? { fresh: !1 } : {
|
|
@@ -133,7 +207,7 @@ function x(e) {
|
|
|
133
207
|
}
|
|
134
208
|
return i;
|
|
135
209
|
}
|
|
136
|
-
async function
|
|
210
|
+
async function u(e, n) {
|
|
137
211
|
try {
|
|
138
212
|
return await t(e, {
|
|
139
213
|
...n,
|
|
@@ -142,20 +216,20 @@ function x(e) {
|
|
|
142
216
|
redirect: "error"
|
|
143
217
|
});
|
|
144
218
|
} catch (e) {
|
|
145
|
-
throw n.signal?.aborted ? e : new
|
|
219
|
+
throw n.signal?.aborted ? e : new p(0, "network", null);
|
|
146
220
|
}
|
|
147
221
|
}
|
|
148
222
|
return {
|
|
149
223
|
async availability(e) {
|
|
150
224
|
let t = null;
|
|
151
225
|
for (;;) {
|
|
152
|
-
let n = await
|
|
226
|
+
let n = await l(!0, t), r = await u(`${c}/availability`, {
|
|
153
227
|
method: "GET",
|
|
154
228
|
headers: n,
|
|
155
229
|
signal: e
|
|
156
230
|
});
|
|
157
|
-
if (r.ok) return
|
|
158
|
-
let i = await
|
|
231
|
+
if (r.ok) return D(await _(r));
|
|
232
|
+
let i = await y(r);
|
|
159
233
|
if (r.status === 401 && t === null) {
|
|
160
234
|
t = {
|
|
161
235
|
error: i,
|
|
@@ -167,16 +241,16 @@ function x(e) {
|
|
|
167
241
|
}
|
|
168
242
|
},
|
|
169
243
|
async create(e, t) {
|
|
170
|
-
if (!r.test(e.avatarId) || !i.test(e.idempotencyKey)) throw new
|
|
244
|
+
if (!r.test(e.avatarId) || !i.test(e.idempotencyKey)) throw new p(400, "invalid_request", null);
|
|
171
245
|
let n = JSON.stringify({
|
|
172
246
|
avatarId: e.avatarId,
|
|
173
247
|
consentVersion: e.consentVersion
|
|
174
|
-
}),
|
|
248
|
+
}), d = o(), f = null, m = !1, h = !1, g = null;
|
|
175
249
|
for (;;) {
|
|
176
|
-
let r = await
|
|
177
|
-
if (
|
|
178
|
-
if (r["x-workspace-authorization"] === void 0) throw new
|
|
179
|
-
let i = await
|
|
250
|
+
let r = await l(!0, f);
|
|
251
|
+
if (f = null, g !== null && o() - d > s) throw g;
|
|
252
|
+
if (r["x-workspace-authorization"] === void 0) throw new p(403, "workspace_context_required", null);
|
|
253
|
+
let i = await u(`${c}/sessions`, {
|
|
180
254
|
method: "POST",
|
|
181
255
|
headers: {
|
|
182
256
|
...r,
|
|
@@ -186,41 +260,41 @@ function x(e) {
|
|
|
186
260
|
body: n,
|
|
187
261
|
signal: t
|
|
188
262
|
});
|
|
189
|
-
if (i.status === 201) return
|
|
190
|
-
let
|
|
191
|
-
if (i.status === 401 && !
|
|
192
|
-
|
|
193
|
-
error:
|
|
263
|
+
if (i.status === 201) return k(await _(i));
|
|
264
|
+
let v = await y(i);
|
|
265
|
+
if (i.status === 401 && !m) {
|
|
266
|
+
m = !0, f = {
|
|
267
|
+
error: v,
|
|
194
268
|
workspace: r["x-workspace-authorization"]
|
|
195
269
|
};
|
|
196
270
|
continue;
|
|
197
271
|
}
|
|
198
|
-
if (i.status === 409 &&
|
|
199
|
-
let e = Math.max(250, (
|
|
200
|
-
if (o() -
|
|
201
|
-
|
|
272
|
+
if (i.status === 409 && v.code === "start_in_progress") {
|
|
273
|
+
let e = Math.max(250, (v.retryAfterSeconds ?? 1) * 1e3);
|
|
274
|
+
if (o() - d + e > s || (await a(e), t?.aborted)) throw v;
|
|
275
|
+
g = v;
|
|
202
276
|
continue;
|
|
203
277
|
}
|
|
204
|
-
if (i.status === 502 && !
|
|
205
|
-
|
|
278
|
+
if (i.status === 502 && !h) {
|
|
279
|
+
h = !0;
|
|
206
280
|
continue;
|
|
207
281
|
}
|
|
208
|
-
throw
|
|
282
|
+
throw v;
|
|
209
283
|
}
|
|
210
284
|
},
|
|
211
285
|
async status(e, t) {
|
|
212
|
-
if (!n.test(e)) throw new
|
|
213
|
-
let r = await
|
|
286
|
+
if (!n.test(e)) throw new p(400, "invalid_request", null);
|
|
287
|
+
let r = await l(!1), i = await u(`${c}/sessions/${e}`, {
|
|
214
288
|
method: "GET",
|
|
215
289
|
headers: r,
|
|
216
290
|
signal: t
|
|
217
291
|
});
|
|
218
|
-
if (!i.ok) throw await
|
|
219
|
-
return
|
|
292
|
+
if (!i.ok) throw await y(i);
|
|
293
|
+
return j(await _(i), e);
|
|
220
294
|
},
|
|
221
295
|
async end(e, { reason: t, keepalive: r = !1 }) {
|
|
222
|
-
if (!n.test(e)) throw new
|
|
223
|
-
let i = await
|
|
296
|
+
if (!n.test(e)) throw new p(400, "invalid_request", null);
|
|
297
|
+
let i = await l(!1), a = await u(`${c}/sessions/${e}/end`, {
|
|
224
298
|
method: "POST",
|
|
225
299
|
headers: {
|
|
226
300
|
...i,
|
|
@@ -229,28 +303,34 @@ function x(e) {
|
|
|
229
303
|
body: JSON.stringify({ reason: t }),
|
|
230
304
|
keepalive: r
|
|
231
305
|
});
|
|
232
|
-
if (!a.ok) throw await
|
|
233
|
-
return
|
|
306
|
+
if (!a.ok) throw await y(a);
|
|
307
|
+
return j(await _(a), e);
|
|
234
308
|
}
|
|
235
309
|
};
|
|
236
310
|
}
|
|
237
|
-
var
|
|
311
|
+
var P = new Set([
|
|
238
312
|
"capacity",
|
|
239
313
|
"rate-limited",
|
|
240
|
-
"budget-exhausted"
|
|
314
|
+
"budget-exhausted",
|
|
315
|
+
"minutes-in-use",
|
|
316
|
+
"minutes-in-use-self",
|
|
317
|
+
"minutes-unavailable"
|
|
241
318
|
]);
|
|
242
|
-
function
|
|
243
|
-
|
|
319
|
+
function F(e) {
|
|
320
|
+
return e.problem === null ? !1 : P.has(e.problem) ? !0 : e.problem === "minutes-exhausted" && e.minutesReason === "ZERO_SESSION_LIMIT";
|
|
321
|
+
}
|
|
322
|
+
function I(e) {
|
|
323
|
+
if (!(e instanceof p)) return {
|
|
244
324
|
problem: "connection",
|
|
245
325
|
hide: !1
|
|
246
326
|
};
|
|
247
|
-
let t =
|
|
248
|
-
return
|
|
327
|
+
let t = L(e);
|
|
328
|
+
return F(t) && e.retryAfterSeconds !== null ? {
|
|
249
329
|
...t,
|
|
250
330
|
retryAfterSeconds: e.retryAfterSeconds
|
|
251
331
|
} : t;
|
|
252
332
|
}
|
|
253
|
-
function
|
|
333
|
+
function L(e) {
|
|
254
334
|
if (e.status === 0) return {
|
|
255
335
|
problem: "connection",
|
|
256
336
|
hide: !1
|
|
@@ -312,6 +392,26 @@ function w(e) {
|
|
|
312
392
|
hide: !1,
|
|
313
393
|
scope: e.scope
|
|
314
394
|
};
|
|
395
|
+
case "minutes_exhausted": return e.minutesReason === null ? {
|
|
396
|
+
problem: "minutes-exhausted",
|
|
397
|
+
hide: !1
|
|
398
|
+
} : {
|
|
399
|
+
problem: "minutes-exhausted",
|
|
400
|
+
hide: !1,
|
|
401
|
+
minutesReason: e.minutesReason
|
|
402
|
+
};
|
|
403
|
+
case "minutes_in_use": return {
|
|
404
|
+
problem: "minutes-in-use",
|
|
405
|
+
hide: !1
|
|
406
|
+
};
|
|
407
|
+
case "minutes_in_use_self": return {
|
|
408
|
+
problem: "minutes-in-use-self",
|
|
409
|
+
hide: !1
|
|
410
|
+
};
|
|
411
|
+
case "minutes_unavailable": return {
|
|
412
|
+
problem: "minutes-unavailable",
|
|
413
|
+
hide: !1
|
|
414
|
+
};
|
|
315
415
|
case "avatar_unavailable": return {
|
|
316
416
|
problem: "unavailable",
|
|
317
417
|
hide: !1
|
|
@@ -345,7 +445,7 @@ function w(e) {
|
|
|
345
445
|
};
|
|
346
446
|
}
|
|
347
447
|
}
|
|
348
|
-
function
|
|
448
|
+
function R(e) {
|
|
349
449
|
return e === "unavailable" ? {
|
|
350
450
|
problem: "capacity",
|
|
351
451
|
hide: !1
|
|
@@ -354,5 +454,26 @@ function T(e) {
|
|
|
354
454
|
hide: !0
|
|
355
455
|
};
|
|
356
456
|
}
|
|
457
|
+
function z(e) {
|
|
458
|
+
if (e == null) return null;
|
|
459
|
+
switch (e.state) {
|
|
460
|
+
case "EXHAUSTED": return e.reason === null ? {
|
|
461
|
+
problem: "minutes-exhausted",
|
|
462
|
+
hide: !1
|
|
463
|
+
} : {
|
|
464
|
+
problem: "minutes-exhausted",
|
|
465
|
+
hide: !1,
|
|
466
|
+
minutesReason: e.reason
|
|
467
|
+
};
|
|
468
|
+
case "IN_USE": return e.reason === "OWN_SESSION" ? {
|
|
469
|
+
problem: "minutes-in-use-self",
|
|
470
|
+
hide: !1
|
|
471
|
+
} : {
|
|
472
|
+
problem: "minutes-in-use",
|
|
473
|
+
hide: !1
|
|
474
|
+
};
|
|
475
|
+
default: return null;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
357
478
|
//#endregion
|
|
358
|
-
export { e as AVATAR_API_PATH, c as AvatarApiError, a as avatarApiBaseFromTtsEndpoint,
|
|
479
|
+
export { e as AVATAR_API_PATH, c as AVATAR_MINUTES_CONTRACT_VERSION, u as AVATAR_MINUTES_REASONS, l as AVATAR_MINUTES_STATES, p as AvatarApiError, a as avatarApiBaseFromTtsEndpoint, R as avatarAvailabilityRefusal, m as avatarIdempotencyKey, z as avatarMinutesRefusal, I as avatarRefusalFor, N as createAvatarSessionClient };
|
|
@@ -7,6 +7,7 @@ import { AvatarRoom, AvatarScheduler } from './avatarPorts';
|
|
|
7
7
|
import { AvatarSessionClient } from './avatarSessionClient';
|
|
8
8
|
import { LiveAvatarVoiceStore } from './LiveAvatarTabView';
|
|
9
9
|
import { LiveAvatarController, LiveAvatarControllerDeps, LiveAvatarLogEvent, LiveAvatarPreferences } from './liveAvatarController';
|
|
10
|
+
import { LiveAvatarMinutesPurchase } from './liveAvatarMinutesView';
|
|
10
11
|
export interface LiveAvatarSeamOptions {
|
|
11
12
|
/** Display names for the avatar ids the server offers (it sends ids only); without one the chooser numbers them. */
|
|
12
13
|
readonly avatarNames?: Readonly<Record<string, string>>;
|
|
@@ -33,6 +34,18 @@ export interface LiveAvatarSeamOptions {
|
|
|
33
34
|
* person's stored choice always wins.
|
|
34
35
|
*/
|
|
35
36
|
readonly defaultAvatarVoiceMode?: AvatarVoiceDefault;
|
|
37
|
+
/**
|
|
38
|
+
* ★ BOFF-9446: whether this person may buy a plan (`access`, the host's purchase check, which follows `billing:create` on the
|
|
39
|
+
* organization's billing account): fe-libs cannot import billing. The Avatar tab asks it only where "See plans" could be offered (none
|
|
40
|
+
* left, or running low, while the server says a plan with more credits exists), and opens the app's plans page with the panel's own
|
|
41
|
+
* navigator (`onNavigate`), never by itself. Absent: nobody is offered "See plans" in the tab, and a person who has run out is told to
|
|
42
|
+
* ask their billing administrator about a plan with more avatar credits. Only `canPurchase` is read. Copied once, here: a host that
|
|
43
|
+
* changes its object later changes nothing.
|
|
44
|
+
*
|
|
45
|
+
* The host knows its own routes, so it says when the person comes back: from any billing page, `controller.refreshMinutes()`; from a
|
|
46
|
+
* plan checkout, `controller.checkMinutesPurchase()` (the tab then says "Checking your plan…" while it checks).
|
|
47
|
+
*/
|
|
48
|
+
readonly minutesPurchase?: LiveAvatarMinutesPurchase;
|
|
36
49
|
readonly onLog?: (event: LiveAvatarLogEvent) => void;
|
|
37
50
|
/** Overrides, for tests and for hosts with their own plumbing. Each defaults to the assistant's own. */
|
|
38
51
|
readonly client?: () => AvatarSessionClient | null;
|
|
@@ -45,7 +58,7 @@ export interface LiveAvatarSeamOptions {
|
|
|
45
58
|
readonly avatarVoiceStore?: LiveAvatarVoiceStore;
|
|
46
59
|
readonly scheduler?: AvatarScheduler;
|
|
47
60
|
readonly browserSupported?: () => boolean;
|
|
48
|
-
readonly controller?: Partial<Pick<LiveAvatarControllerDeps, 'createAudioElement' | 'releaseAudioElement' | 'startMeter' | 'decode' | 'now' | 'newIdempotencyKey' | 'subscribeWorkspaceChange' | 'subscribePageHide' | 'subscribePageShow' | 'idleMs' | 'endBeforeDeadlineMs' | 'connectTimeoutMs' | 'trackerConfig' | 'maxDrainMs' | 'stallMs' | 'readinessProbe'>>;
|
|
61
|
+
readonly controller?: Partial<Pick<LiveAvatarControllerDeps, 'createAudioElement' | 'releaseAudioElement' | 'startMeter' | 'decode' | 'now' | 'newIdempotencyKey' | 'subscribeWorkspaceChange' | 'subscribePageHide' | 'isPageVisible' | 'subscribePageVisible' | 'subscribePageShow' | 'idleMs' | 'endBeforeDeadlineMs' | 'connectTimeoutMs' | 'trackerConfig' | 'maxDrainMs' | 'stallMs' | 'readinessProbe'>>;
|
|
49
62
|
}
|
|
50
63
|
/** The seam, plus what a host or a test may need of it. */
|
|
51
64
|
export interface LiveAvatarSeamHandle extends AssistantLiveAvatarSeam {
|
|
@@ -90,15 +90,37 @@ function A(e, t) {
|
|
|
90
90
|
cancel: () => e.cancel()
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
function j() {
|
|
93
|
+
function j(e) {
|
|
94
|
+
if (e === void 0) return;
|
|
95
|
+
let { access: t } = e;
|
|
96
|
+
return { access: () => t.call(e) };
|
|
97
|
+
}
|
|
98
|
+
function M() {
|
|
94
99
|
if (typeof document > "u") return null;
|
|
95
100
|
let e = document.createElement("audio");
|
|
96
101
|
return e.autoplay = !0, e.hidden = !0, e.setAttribute("data-testid", "assistant-live-avatar-audio"), document.body.appendChild(e), e;
|
|
97
102
|
}
|
|
98
|
-
function
|
|
103
|
+
function N(e) {
|
|
99
104
|
if (!(typeof window > "u")) return (t) => (window.addEventListener(e, t), () => window.removeEventListener(e, t));
|
|
100
105
|
}
|
|
101
|
-
function
|
|
106
|
+
function P() {
|
|
107
|
+
if (typeof document > "u" || typeof document.addEventListener != "function") return;
|
|
108
|
+
let e = () => document.visibilityState !== "hidden";
|
|
109
|
+
return {
|
|
110
|
+
isVisible: e,
|
|
111
|
+
onShown: (t) => {
|
|
112
|
+
let n = () => {
|
|
113
|
+
e() && t();
|
|
114
|
+
}, r = (n) => {
|
|
115
|
+
"persisted" in n && n.persisted === !0 && e() && t();
|
|
116
|
+
}, i = typeof window < "u" && typeof window.addEventListener == "function" ? window : void 0;
|
|
117
|
+
return document.addEventListener("visibilitychange", n), i?.addEventListener("pageshow", r), () => {
|
|
118
|
+
document.removeEventListener("visibilitychange", n), i?.removeEventListener("pageshow", r);
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function F() {
|
|
102
124
|
if (!(typeof window > "u" || typeof document > "u")) return (e) => {
|
|
103
125
|
let t = window, n = document, r = () => {
|
|
104
126
|
n.visibilityState === "visible" && e();
|
|
@@ -108,24 +130,26 @@ function N() {
|
|
|
108
130
|
};
|
|
109
131
|
};
|
|
110
132
|
}
|
|
111
|
-
function
|
|
112
|
-
let t = e.preferences ?? O, n = e.controller ?? {}, r = n.subscribeWorkspaceChange ??
|
|
133
|
+
function I(e = {}) {
|
|
134
|
+
let t = e.preferences ?? O, n = e.controller ?? {}, r = n.subscribeWorkspaceChange ?? N("burdenoff:workspace-changed"), i = n.subscribePageHide ?? N("pagehide"), a = P(), o = n.isPageVisible ?? a?.isVisible, u = n.subscribePageVisible ?? a?.onShown, f = n.subscribePageShow ?? F(), T = n.now ?? (() => Date.now()), E = p({
|
|
113
135
|
client: e.client ?? D(),
|
|
114
136
|
openRoom: e.openRoom ?? m,
|
|
115
137
|
scheduler: e.scheduler ?? s,
|
|
116
138
|
preferences: t,
|
|
117
139
|
decode: n.decode ?? ((e, t) => l(e, { signal: t })),
|
|
118
|
-
createAudioElement: n.createAudioElement ??
|
|
140
|
+
createAudioElement: n.createAudioElement ?? M,
|
|
119
141
|
releaseAudioElement: n.releaseAudioElement ?? ((e) => {
|
|
120
142
|
e.srcObject = null, e.remove();
|
|
121
143
|
}),
|
|
122
144
|
startMeter: n.startMeter ?? ((e, t) => typeof MediaStream > "u" ? null : c(new MediaStream([e]), t)),
|
|
123
145
|
browserSupported: e.browserSupported ?? (() => w()),
|
|
124
|
-
now:
|
|
146
|
+
now: T,
|
|
125
147
|
newIdempotencyKey: n.newIdempotencyKey ?? (() => d()),
|
|
126
148
|
...r ? { subscribeWorkspaceChange: r } : {},
|
|
127
149
|
...i ? { subscribePageHide: i } : {},
|
|
128
|
-
...
|
|
150
|
+
...o ? { isPageVisible: o } : {},
|
|
151
|
+
...u ? { subscribePageVisible: u } : {},
|
|
152
|
+
...f ? { subscribePageShow: f } : {},
|
|
129
153
|
...n.idleMs === void 0 ? {} : { idleMs: n.idleMs },
|
|
130
154
|
...n.endBeforeDeadlineMs === void 0 ? {} : { endBeforeDeadlineMs: n.endBeforeDeadlineMs },
|
|
131
155
|
...n.connectTimeoutMs === void 0 ? {} : { connectTimeoutMs: n.connectTimeoutMs },
|
|
@@ -134,34 +158,34 @@ function P(e = {}) {
|
|
|
134
158
|
...n.stallMs === void 0 ? {} : { stallMs: n.stallMs },
|
|
135
159
|
...n.readinessProbe === void 0 ? {} : { readinessProbe: n.readinessProbe },
|
|
136
160
|
...e.onLog ? { onLog: e.onLog } : {}
|
|
137
|
-
}),
|
|
138
|
-
let i = v(
|
|
139
|
-
avatarVoices:
|
|
161
|
+
}), I = b(e.avatarVoices), L = e.avatarImages === void 0 ? null : _(e.avatarImages), R = e.avatarVoiceStore ?? k, z = () => R.getState(), B = j(e.minutesPurchase), V = (n, r) => {
|
|
162
|
+
let i = v(z(), {
|
|
163
|
+
avatarVoices: I,
|
|
140
164
|
avatarId: t.getState().avatarId,
|
|
141
165
|
...e.defaultAvatarVoiceMode ? { hostDefault: e.defaultAvatarVoiceMode } : {}
|
|
142
166
|
});
|
|
143
167
|
return i === null ? null : y(i, n, r.listVoices());
|
|
144
|
-
},
|
|
168
|
+
}, H = (e, t) => {
|
|
145
169
|
let n = {
|
|
146
170
|
...e,
|
|
147
171
|
voice: t
|
|
148
172
|
};
|
|
149
|
-
return n.audioOutput = x(
|
|
173
|
+
return n.audioOutput = x(E.createOutput(), () => {
|
|
150
174
|
n.voice = e.voice;
|
|
151
|
-
}, (e) =>
|
|
152
|
-
|
|
175
|
+
}, (e) => E.subscribe(() => {
|
|
176
|
+
E.getSnapshot().phase !== "ready" && e();
|
|
153
177
|
})), n;
|
|
154
178
|
};
|
|
155
179
|
return {
|
|
156
180
|
decorateSpeechEngine: (e) => {
|
|
157
181
|
let t = (t) => {
|
|
158
|
-
let n =
|
|
182
|
+
let n = V(t.lang, e), r = n === null ? t : {
|
|
159
183
|
...t,
|
|
160
184
|
voice: n
|
|
161
185
|
};
|
|
162
186
|
return {
|
|
163
187
|
voice: n,
|
|
164
|
-
target:
|
|
188
|
+
target: E.route(r, e)
|
|
165
189
|
};
|
|
166
190
|
}, n = null, r = () => {
|
|
167
191
|
let e = n;
|
|
@@ -169,12 +193,12 @@ function P(e = {}) {
|
|
|
169
193
|
}, i = (t, r, i) => {
|
|
170
194
|
let a = !0, o = !1, s = () => void 0, c = () => {
|
|
171
195
|
a && (a = !1, n === c && (n = null), s());
|
|
172
|
-
}, l = () => o ? !1 : (o = !0, c(), !0),
|
|
196
|
+
}, l = () => o ? !1 : (o = !0, c(), !0), u = () => {
|
|
173
197
|
!a || !l() || (e.cancel(), i?.onError?.("output-left"));
|
|
174
198
|
};
|
|
175
|
-
s =
|
|
176
|
-
|
|
177
|
-
}), n = c, r.audioOutput &&= A(r.audioOutput,
|
|
199
|
+
s = E.subscribe(() => {
|
|
200
|
+
E.getSnapshot().phase !== "ready" && u();
|
|
201
|
+
}), n = c, r.audioOutput &&= A(r.audioOutput, u), r.fallback = !1, e.speak(t, r, {
|
|
178
202
|
...i,
|
|
179
203
|
onEnd: () => {
|
|
180
204
|
l() && i?.onEnd?.();
|
|
@@ -203,8 +227,8 @@ function P(e = {}) {
|
|
|
203
227
|
}
|
|
204
228
|
let l = s === null ? {
|
|
205
229
|
...a,
|
|
206
|
-
audioOutput:
|
|
207
|
-
} :
|
|
230
|
+
audioOutput: E.createOutput()
|
|
231
|
+
} : H(a, s);
|
|
208
232
|
if (a.avatarOnly === !0) {
|
|
209
233
|
i(n, l, o);
|
|
210
234
|
return;
|
|
@@ -217,7 +241,7 @@ function P(e = {}) {
|
|
|
217
241
|
};
|
|
218
242
|
},
|
|
219
243
|
Stage: ({ expanded: t, fallback: n }) => /* @__PURE__ */ C(g, {
|
|
220
|
-
controller:
|
|
244
|
+
controller: E,
|
|
221
245
|
expanded: t,
|
|
222
246
|
fallback: n,
|
|
223
247
|
...e.avatarNames ? { avatarNames: e.avatarNames } : {}
|
|
@@ -225,33 +249,34 @@ function P(e = {}) {
|
|
|
225
249
|
enabled: {
|
|
226
250
|
subscribe: (e) => t.subscribe(e),
|
|
227
251
|
getSnapshot: () => t.getState().avatarEnabled,
|
|
228
|
-
switchOff: () =>
|
|
229
|
-
voiceLive: (e) =>
|
|
252
|
+
switchOff: () => E.switchOff(),
|
|
253
|
+
voiceLive: (e) => E.setVoiceLive(e)
|
|
230
254
|
},
|
|
231
255
|
tab: {
|
|
232
256
|
offered: {
|
|
233
|
-
subscribe: (e) =>
|
|
234
|
-
getSnapshot: () =>
|
|
257
|
+
subscribe: (e) => E.subscribe(e),
|
|
258
|
+
getSnapshot: () => E.getSnapshot().tabOffered
|
|
235
259
|
},
|
|
236
260
|
ask: {
|
|
237
|
-
subscribe: (e) =>
|
|
238
|
-
getSnapshot: () => h(
|
|
261
|
+
subscribe: (e) => E.subscribe(e),
|
|
262
|
+
getSnapshot: () => h(E.getSnapshot(), T())
|
|
239
263
|
},
|
|
240
|
-
setOpen: (e) =>
|
|
241
|
-
heldByVoice: () =>
|
|
264
|
+
setOpen: (e) => E.setTabOpen(e),
|
|
265
|
+
heldByVoice: () => E.getSnapshot().heldByVoice,
|
|
242
266
|
View: (t) => /* @__PURE__ */ C(S, {
|
|
243
267
|
...t,
|
|
244
|
-
controller:
|
|
245
|
-
avatarVoices:
|
|
246
|
-
voiceStore:
|
|
268
|
+
controller: E,
|
|
269
|
+
avatarVoices: I,
|
|
270
|
+
voiceStore: R,
|
|
247
271
|
...e.avatarNames ? { avatarNames: e.avatarNames } : {},
|
|
248
|
-
...
|
|
249
|
-
...e.defaultAvatarVoiceMode ? { defaultAvatarVoiceMode: e.defaultAvatarVoiceMode } : {}
|
|
272
|
+
...L ? { avatarImages: L } : {},
|
|
273
|
+
...e.defaultAvatarVoiceMode ? { defaultAvatarVoiceMode: e.defaultAvatarVoiceMode } : {},
|
|
274
|
+
...B ? { minutesPurchase: B } : {}
|
|
250
275
|
})
|
|
251
276
|
},
|
|
252
|
-
controller:
|
|
253
|
-
dispose: () =>
|
|
277
|
+
controller: E,
|
|
278
|
+
dispose: () => E.dispose()
|
|
254
279
|
};
|
|
255
280
|
}
|
|
256
281
|
//#endregion
|
|
257
|
-
export {
|
|
282
|
+
export { I as createLiveAvatarSeam, w as isLiveAvatarBrowserSupported, T as liveAvatarAuthorization, E as liveAvatarWorkspaceAuthorization };
|