@burdenoff/fe-libs 2026.1023.16 → 2026.1024.2
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/LiveAvatarStage.js +5 -1
- package/dist/shared/assistant/avatar/live/LiveAvatarTabView.js +28 -25
- package/dist/shared/assistant/avatar/live/avatarSessionClient.d.ts +17 -1
- package/dist/shared/assistant/avatar/live/avatarSessionClient.js +81 -64
- package/dist/shared/assistant/avatar/live/createLiveAvatarSeam.d.ts +1 -1
- package/dist/shared/assistant/avatar/live/createLiveAvatarSeam.js +61 -50
- package/dist/shared/assistant/avatar/live/liveAvatarController.d.ts +25 -5
- package/dist/shared/assistant/avatar/live/liveAvatarController.js +166 -156
- package/dist/shared/assistant/avatar/live/liveAvatarStatus.d.ts +5 -3
- package/dist/shared/assistant/avatar/live/liveAvatarStatus.js +4 -3
- package/dist/shared/assistant/avatar/useAvatarCopy.d.ts +9 -3
- package/dist/shared/assistant/avatar/useAvatarCopy.js +7 -1
- package/dist/shared/assistant/i18nManifest.d.ts +4 -0
- package/dist/shared/assistant/i18nManifest.js +4 -0
- package/package.json +1 -1
|
@@ -115,7 +115,11 @@ var f = "inline-flex h-8 items-center gap-1.5 rounded-full border border-border-
|
|
|
115
115
|
}), /* @__PURE__ */ u("button", {
|
|
116
116
|
type: "button",
|
|
117
117
|
onClick: () => {
|
|
118
|
-
|
|
118
|
+
if (M) {
|
|
119
|
+
h.recheckRetry();
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
w.current?.focus(), h.confirm();
|
|
119
123
|
},
|
|
120
124
|
"aria-describedby": M ? `${b} ${x}` : b,
|
|
121
125
|
"aria-disabled": M,
|
|
@@ -29,31 +29,34 @@ var y = "text-xs font-medium text-text-secondary", b = "text-xs text-text-muted"
|
|
|
29
29
|
}, [r]);
|
|
30
30
|
let { phase: I } = P, L = I === "starting" || I === "connecting" || I === "ready" || I === "ending", [R, z] = c(!1);
|
|
31
31
|
R && (I === "off" || I === "choosing" || I === "ready" || I === "ending") && z(!1);
|
|
32
|
-
let B = E(),
|
|
32
|
+
let B = E(), V = P.retryAt !== null && P.retryAt > B, H = ne(P, D, B), U = P.selectedAvatarId, W = (e) => {
|
|
33
33
|
let t = P.avatars.indexOf(e);
|
|
34
34
|
return de?.[e] ?? (t === -1 ? D.chooserNone : `${D.chooserLabel} ${t + 1}`);
|
|
35
|
-
},
|
|
35
|
+
}, G = I === "ready" ? { kind: "turn-off" } : I === "ending" ? { kind: "ending" } : R || I === "starting" || I === "connecting" ? { kind: "starting" } : P.offered ? {
|
|
36
36
|
kind: "turn-on",
|
|
37
|
-
ready: !
|
|
38
|
-
} : null,
|
|
37
|
+
ready: !V && U !== null && (I === "choosing" || I === "off" && P.avatars.includes(U))
|
|
38
|
+
} : null, K = s(null), ge = G?.kind === "turn-off";
|
|
39
39
|
ie(() => {
|
|
40
|
-
|
|
41
|
-
}, [
|
|
40
|
+
K.current = ge ? E() : null;
|
|
41
|
+
}, [ge, E]);
|
|
42
42
|
let _e = i((e) => {
|
|
43
43
|
if (e !== null) return () => {
|
|
44
44
|
e.ownerDocument.activeElement === e && N.current?.focus();
|
|
45
45
|
};
|
|
46
46
|
}, []), ve = () => {
|
|
47
|
-
if (
|
|
47
|
+
if (G !== null) switch (G.kind) {
|
|
48
48
|
case "turn-on":
|
|
49
|
-
if (!
|
|
49
|
+
if (!G.ready || U === null) {
|
|
50
|
+
V && r.recheckRetry();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
50
53
|
z(!0), I === "choosing" ? r.confirm() : r.requestOn({
|
|
51
54
|
start: !0,
|
|
52
|
-
avatarId:
|
|
55
|
+
avatarId: U
|
|
53
56
|
});
|
|
54
57
|
return;
|
|
55
58
|
case "turn-off": {
|
|
56
|
-
let e =
|
|
59
|
+
let e = K.current;
|
|
57
60
|
if (e !== null && E() - e < 1e3) return;
|
|
58
61
|
r.switchOff();
|
|
59
62
|
return;
|
|
@@ -61,7 +64,7 @@ var y = "text-xs font-medium text-text-secondary", b = "text-xs text-text-muted"
|
|
|
61
64
|
case "starting":
|
|
62
65
|
case "ending": return;
|
|
63
66
|
}
|
|
64
|
-
}, ye = te(F, me), q =
|
|
67
|
+
}, ye = te(F, me), q = U === null ? null : pe.get(U) ?? null, J = ye === "speaker" && F.avatarSpeaker !== null ? `${h}${F.avatarSpeaker}` : ye === "paired" && q !== null ? m : p, be = J === m ? q : J.startsWith(h) ? F.avatarSpeaker : null, Y = J === p ? O.activeVoiceName : be === null ? null : v(be, O.voiceChoices)?.name ?? null, xe = O.speakingMessageId !== null || O.spokenChunks !== null, Se = Y !== null && !C.live && !xe, Ce = O.activeVoiceName ? D.voiceModeMineNamed(_(O.activeVoiceName)) : D.voiceModeMine, we = (e) => {
|
|
65
68
|
if (e === p || e === m) {
|
|
66
69
|
T.setVoiceMode(e);
|
|
67
70
|
return;
|
|
@@ -73,7 +76,7 @@ var y = "text-xs font-medium text-text-secondary", b = "text-xs text-text-muted"
|
|
|
73
76
|
}, []), ke = (e) => {
|
|
74
77
|
let t = fe?.get(e);
|
|
75
78
|
return t === void 0 || Ee.has(t) ? null : t;
|
|
76
|
-
}, X = !L &&
|
|
79
|
+
}, X = !L && U !== null ? ke(U) : null, Z = L ? null : w === void 0 ? C.impossible ? D.askNeedsVoice : null : w === "by-typing" ? D.askByTyping : w === "needs-voice" ? D.askNeedsVoice : w === "nothing" ? D.askNothing : null, Ae = I === "off" && P.avatars.length === 0 && P.offered, [Q, je] = c(!1), $ = Ae && (Q || P.problem !== null);
|
|
77
80
|
return $ !== Q && je($), /* @__PURE__ */ f("div", {
|
|
78
81
|
ref: N,
|
|
79
82
|
tabIndex: -1,
|
|
@@ -96,9 +99,9 @@ var y = "text-xs font-medium text-text-secondary", b = "text-xs text-text-muted"
|
|
|
96
99
|
playsInline: !0,
|
|
97
100
|
"data-testid": "assistant-avatar-tab-video"
|
|
98
101
|
}) : null,
|
|
99
|
-
X !== null &&
|
|
102
|
+
X !== null && U !== null ? /* @__PURE__ */ d(re, {
|
|
100
103
|
size: "frame",
|
|
101
|
-
name: U
|
|
104
|
+
name: W(U),
|
|
102
105
|
src: X,
|
|
103
106
|
onError: Oe
|
|
104
107
|
}) : null,
|
|
@@ -121,10 +124,10 @@ var y = "text-xs font-medium text-text-secondary", b = "text-xs text-text-muted"
|
|
|
121
124
|
})
|
|
122
125
|
}),
|
|
123
126
|
/* @__PURE__ */ d("p", {
|
|
124
|
-
className:
|
|
127
|
+
className: H === null ? "sr-only" : "text-center text-sm text-text-secondary",
|
|
125
128
|
role: "status",
|
|
126
129
|
"data-testid": "assistant-avatar-tab-status",
|
|
127
|
-
children:
|
|
130
|
+
children: H ?? ""
|
|
128
131
|
}),
|
|
129
132
|
P.avatars.length > 1 && !L ? /* @__PURE__ */ f("fieldset", {
|
|
130
133
|
className: "flex min-w-0 flex-col gap-1.5",
|
|
@@ -135,7 +138,7 @@ var y = "text-xs font-medium text-text-secondary", b = "text-xs text-text-muted"
|
|
|
135
138
|
}), /* @__PURE__ */ d("div", {
|
|
136
139
|
className: "flex flex-wrap gap-2",
|
|
137
140
|
children: P.avatars.map((e) => {
|
|
138
|
-
let t = e ===
|
|
141
|
+
let t = e === U, n = W(e);
|
|
139
142
|
return /* @__PURE__ */ f("label", {
|
|
140
143
|
className: `${oe} ${t ? "border-transparent bg-action-primary-bg text-action-primary-text" : "border-border-default bg-bg-elevated text-text-secondary hover:bg-bg-raised hover:text-text-primary"}`,
|
|
141
144
|
title: t ? D.chooserSelected(n) : D.chooserOption(n),
|
|
@@ -164,7 +167,7 @@ var y = "text-xs font-medium text-text-secondary", b = "text-xs text-text-muted"
|
|
|
164
167
|
}, e);
|
|
165
168
|
})
|
|
166
169
|
})]
|
|
167
|
-
}) : P.avatars.length > 0 &&
|
|
170
|
+
}) : P.avatars.length > 0 && U !== null ? /* @__PURE__ */ f("div", {
|
|
168
171
|
className: "flex flex-col gap-0.5",
|
|
169
172
|
"data-testid": "assistant-avatar-tab-chosen",
|
|
170
173
|
children: [/* @__PURE__ */ f("p", {
|
|
@@ -174,7 +177,7 @@ var y = "text-xs font-medium text-text-secondary", b = "text-xs text-text-muted"
|
|
|
174
177
|
children: D.chooserLabel
|
|
175
178
|
}), /* @__PURE__ */ d("span", {
|
|
176
179
|
className: "truncate text-text-primary",
|
|
177
|
-
children: U
|
|
180
|
+
children: W(U)
|
|
178
181
|
})]
|
|
179
182
|
}), L && P.avatars.length > 1 ? /* @__PURE__ */ d("p", {
|
|
180
183
|
className: b,
|
|
@@ -245,16 +248,16 @@ var y = "text-xs font-medium text-text-secondary", b = "text-xs text-text-muted"
|
|
|
245
248
|
"data-testid": "assistant-avatar-tab-disclosure",
|
|
246
249
|
children: D.consent
|
|
247
250
|
}),
|
|
248
|
-
|
|
251
|
+
G === null ? null : /* @__PURE__ */ d("button", {
|
|
249
252
|
ref: _e,
|
|
250
253
|
type: "button",
|
|
251
254
|
onClick: ve,
|
|
252
|
-
"aria-disabled":
|
|
253
|
-
"aria-describedby":
|
|
254
|
-
className:
|
|
255
|
+
"aria-disabled": G.kind === "turn-on" ? !G.ready : G.kind !== "turn-off",
|
|
256
|
+
"aria-describedby": G.kind === "turn-on" ? k : void 0,
|
|
257
|
+
className: G.kind === "turn-off" ? S : ae,
|
|
255
258
|
"data-testid": "assistant-avatar-tab-switch",
|
|
256
|
-
"data-slot":
|
|
257
|
-
children:
|
|
259
|
+
"data-slot": G.kind,
|
|
260
|
+
children: G.kind === "turn-off" ? D.stop : G.kind === "starting" ? D.turnOnStarting : G.kind === "ending" ? D.stateEnding : D.consentConfirm
|
|
258
261
|
}),
|
|
259
262
|
$ ? /* @__PURE__ */ d("button", {
|
|
260
263
|
type: "button",
|
|
@@ -12,6 +12,13 @@ export declare function avatarApiBaseFromTtsEndpoint(ttsEndpoint: string | null
|
|
|
12
12
|
*/
|
|
13
13
|
declare const AVAILABILITY_REASONS: readonly ["workspace_context_required", "not_enabled", "not_permitted", "unavailable"];
|
|
14
14
|
export type AvatarAvailabilityReason = (typeof AVAILABILITY_REASONS)[number];
|
|
15
|
+
/**
|
|
16
|
+
* Whose budget a used-up credit cap names, in the error body's `scope` (the speech service's `BudgetScope`): the person's own, their
|
|
17
|
+
* workspace's, or everyone's together (the environment's daily or monthly budget). Only 429 `budget_exhausted` carries one, and a
|
|
18
|
+
* server that does not send it yet (today's) leaves it out.
|
|
19
|
+
*/
|
|
20
|
+
declare const BUDGET_SCOPES: readonly ["person", "workspace", "everyone"];
|
|
21
|
+
export type AvatarBudgetScope = (typeof BUDGET_SCOPES)[number];
|
|
15
22
|
export interface AvatarAvailability {
|
|
16
23
|
readonly available: boolean;
|
|
17
24
|
readonly reason: AvatarAvailabilityReason | null;
|
|
@@ -49,9 +56,13 @@ export declare class AvatarApiError extends Error {
|
|
|
49
56
|
/** The server's or the gateway's code, `invalid_response` for a body we refused, `network` for no answer. */
|
|
50
57
|
readonly code: string;
|
|
51
58
|
readonly retryAfterSeconds: number | null;
|
|
59
|
+
/** On `budget_exhausted` only, whose budget the body names when it is one of the three we know; null in every other answer. */
|
|
60
|
+
readonly scope: AvatarBudgetScope | null;
|
|
52
61
|
constructor(status: number,
|
|
53
62
|
/** The server's or the gateway's code, `invalid_response` for a body we refused, `network` for no answer. */
|
|
54
|
-
code: string, retryAfterSeconds: number | null
|
|
63
|
+
code: string, retryAfterSeconds: number | null,
|
|
64
|
+
/** On `budget_exhausted` only, whose budget the body names when it is one of the three we know; null in every other answer. */
|
|
65
|
+
scope?: AvatarBudgetScope | null);
|
|
55
66
|
}
|
|
56
67
|
export interface AvatarSessionClientOptions {
|
|
57
68
|
/** `https://<gateway>/api/avatar/v1` (avatarApiBaseFromTtsEndpoint). */
|
|
@@ -104,6 +115,11 @@ export interface AvatarRefusal {
|
|
|
104
115
|
* in seconds. Absent when it said nothing: the person is then told no time, and nothing waits for one.
|
|
105
116
|
*/
|
|
106
117
|
readonly retryAfterSeconds?: number;
|
|
118
|
+
/**
|
|
119
|
+
* With `budget-exhausted` only: whose budget is used up, when the server said (the person's own, their workspace's, or everyone's).
|
|
120
|
+
* Absent when it named none (today's server) and with every other refusal: the person is then told the general line.
|
|
121
|
+
*/
|
|
122
|
+
readonly scope?: AvatarBudgetScope;
|
|
107
123
|
}
|
|
108
124
|
/**
|
|
109
125
|
* The person's side of every failure (§3.4): the normal voice always continues; this says what to show. 404 means "not here" (the module
|
|
@@ -19,15 +19,20 @@ var o = [
|
|
|
19
19
|
"not_enabled",
|
|
20
20
|
"not_permitted",
|
|
21
21
|
"unavailable"
|
|
22
|
-
], s =
|
|
22
|
+
], s = [
|
|
23
|
+
"person",
|
|
24
|
+
"workspace",
|
|
25
|
+
"everyone"
|
|
26
|
+
], c = class extends Error {
|
|
23
27
|
status;
|
|
24
28
|
code;
|
|
25
29
|
retryAfterSeconds;
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
scope;
|
|
31
|
+
constructor(e, t, n, r = null) {
|
|
32
|
+
super(`avatar api ${e} ${t}`), this.status = e, this.code = t, this.retryAfterSeconds = n, this.scope = r, this.name = "AvatarApiError";
|
|
28
33
|
}
|
|
29
34
|
};
|
|
30
|
-
function
|
|
35
|
+
function l(e = globalThis.crypto) {
|
|
31
36
|
if (e && typeof e.randomUUID == "function") return e.randomUUID();
|
|
32
37
|
let t = new Uint8Array(16);
|
|
33
38
|
if (e && typeof e.getRandomValues == "function") e.getRandomValues(t);
|
|
@@ -36,38 +41,43 @@ function c(e = globalThis.crypto) {
|
|
|
36
41
|
let n = [...t].map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
37
42
|
return `${n.slice(0, 8)}-${n.slice(8, 12)}-${n.slice(12, 16)}-${n.slice(16, 20)}-${n.slice(20)}`;
|
|
38
43
|
}
|
|
39
|
-
function
|
|
44
|
+
function u(e) {
|
|
40
45
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
41
46
|
}
|
|
42
|
-
function
|
|
47
|
+
function d(e, t) {
|
|
43
48
|
let n = e.headers.get("retry-after"), r = n === null || n.trim() === "" ? NaN : Number(n);
|
|
44
49
|
if (Number.isFinite(r) && r >= 0) return r;
|
|
45
|
-
let i =
|
|
50
|
+
let i = u(t) && u(t.error) ? Number(t.error.retryAfterSeconds) : NaN;
|
|
46
51
|
return Number.isFinite(i) && i >= 0 ? i : null;
|
|
47
52
|
}
|
|
48
|
-
async function
|
|
53
|
+
async function f(e) {
|
|
49
54
|
try {
|
|
50
55
|
return await e.json();
|
|
51
56
|
} catch {
|
|
52
57
|
return null;
|
|
53
58
|
}
|
|
54
59
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
function p(e, t) {
|
|
61
|
+
if (e !== "budget_exhausted" || !u(t) || !u(t.error)) return null;
|
|
62
|
+
let { scope: n } = t.error;
|
|
63
|
+
return s.find((e) => e === n) ?? null;
|
|
58
64
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
async function m(e) {
|
|
66
|
+
let t = await f(e), n = u(t) && u(t.error) && typeof t.error.code == "string" ? t.error.code : "http_error";
|
|
67
|
+
return new c(e.status, n, d(e, t), p(n, t));
|
|
68
|
+
}
|
|
69
|
+
function h(e) {
|
|
70
|
+
if (!u(e) || typeof e.available != "boolean") throw new c(200, "invalid_response", null);
|
|
71
|
+
let t = Array.isArray(e.avatars) ? e.avatars.flatMap((e) => u(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;
|
|
62
72
|
return {
|
|
63
|
-
available:
|
|
64
|
-
reason:
|
|
73
|
+
available: s,
|
|
74
|
+
reason: s ? null : n ?? "not_enabled",
|
|
65
75
|
avatars: t,
|
|
66
76
|
consentVersion: i,
|
|
67
77
|
maxSessionSeconds: a
|
|
68
78
|
};
|
|
69
79
|
}
|
|
70
|
-
function
|
|
80
|
+
function g(e) {
|
|
71
81
|
try {
|
|
72
82
|
let n = new URL(e);
|
|
73
83
|
return n.protocol === "wss:" ? !0 : n.protocol === "ws:" && t.has(n.hostname.toLowerCase());
|
|
@@ -75,20 +85,20 @@ function m(e) {
|
|
|
75
85
|
return !1;
|
|
76
86
|
}
|
|
77
87
|
}
|
|
78
|
-
function
|
|
79
|
-
if (!
|
|
80
|
-
let { sessionId: t, livekitUrl: r, participantToken: i, avatarIdentity: a, connectBy: o, endsAt:
|
|
81
|
-
if (typeof t != "string" || !n.test(t) || typeof r != "string" || !
|
|
88
|
+
function _(e) {
|
|
89
|
+
if (!u(e)) throw new c(201, "invalid_response", null);
|
|
90
|
+
let { sessionId: t, livekitUrl: r, participantToken: i, avatarIdentity: a, connectBy: o, endsAt: s } = e, l = typeof o == "string" ? Date.parse(o) : NaN, d = typeof s == "string" ? Date.parse(s) : NaN;
|
|
91
|
+
if (typeof t != "string" || !n.test(t) || typeof r != "string" || !g(r) || typeof i != "string" || i === "" || typeof a != "string" || a === "" || !Number.isFinite(l) || !Number.isFinite(d)) throw new c(201, "invalid_response", null);
|
|
82
92
|
return {
|
|
83
93
|
sessionId: t,
|
|
84
94
|
livekitUrl: r,
|
|
85
95
|
participantToken: i,
|
|
86
96
|
avatarIdentity: a,
|
|
87
|
-
connectBy:
|
|
97
|
+
connectBy: l,
|
|
88
98
|
endsAt: d
|
|
89
99
|
};
|
|
90
100
|
}
|
|
91
|
-
var
|
|
101
|
+
var v = [
|
|
92
102
|
"starting",
|
|
93
103
|
"ready",
|
|
94
104
|
"ending",
|
|
@@ -96,22 +106,22 @@ var g = [
|
|
|
96
106
|
"failed",
|
|
97
107
|
"canceled"
|
|
98
108
|
];
|
|
99
|
-
function
|
|
100
|
-
if (!
|
|
109
|
+
function y(e, t) {
|
|
110
|
+
if (!u(e) || !v.includes(e.state)) throw new c(200, "invalid_response", null);
|
|
101
111
|
return {
|
|
102
112
|
sessionId: t,
|
|
103
113
|
state: e.state,
|
|
104
114
|
endedReason: typeof e.endedReason == "string" ? e.endedReason : null
|
|
105
115
|
};
|
|
106
116
|
}
|
|
107
|
-
var
|
|
117
|
+
var b = (e) => new Promise((t) => {
|
|
108
118
|
setTimeout(t, e);
|
|
109
119
|
});
|
|
110
|
-
function
|
|
111
|
-
let t = e.fetchImpl ?? ((e, t) => fetch(e, t)), a = e.sleep ??
|
|
120
|
+
function x(e) {
|
|
121
|
+
let t = e.fetchImpl ?? ((e, t) => fetch(e, t)), a = e.sleep ?? b, o = e.now ?? (() => Date.now()), s = e.startInProgressBudgetMs ?? 15e3, l = e.baseUrl.replace(/\/+$/, "");
|
|
112
122
|
async function u(t, n = null) {
|
|
113
123
|
let r = e.getAuthorization();
|
|
114
|
-
if (!r) throw new
|
|
124
|
+
if (!r) throw new c(401, "unauthenticated", null);
|
|
115
125
|
let i = { authorization: r };
|
|
116
126
|
if (t) {
|
|
117
127
|
let t = await e.getWorkspaceAuthorization(n === null ? { fresh: !1 } : {
|
|
@@ -123,7 +133,7 @@ function y(e) {
|
|
|
123
133
|
}
|
|
124
134
|
return i;
|
|
125
135
|
}
|
|
126
|
-
async function
|
|
136
|
+
async function d(e, n) {
|
|
127
137
|
try {
|
|
128
138
|
return await t(e, {
|
|
129
139
|
...n,
|
|
@@ -132,20 +142,20 @@ function y(e) {
|
|
|
132
142
|
redirect: "error"
|
|
133
143
|
});
|
|
134
144
|
} catch (e) {
|
|
135
|
-
throw n.signal?.aborted ? e : new
|
|
145
|
+
throw n.signal?.aborted ? e : new c(0, "network", null);
|
|
136
146
|
}
|
|
137
147
|
}
|
|
138
148
|
return {
|
|
139
149
|
async availability(e) {
|
|
140
150
|
let t = null;
|
|
141
151
|
for (;;) {
|
|
142
|
-
let n = await u(!0, t), r = await
|
|
152
|
+
let n = await u(!0, t), r = await d(`${l}/availability`, {
|
|
143
153
|
method: "GET",
|
|
144
154
|
headers: n,
|
|
145
155
|
signal: e
|
|
146
156
|
});
|
|
147
|
-
if (r.ok) return
|
|
148
|
-
let i = await
|
|
157
|
+
if (r.ok) return h(await f(r));
|
|
158
|
+
let i = await m(r);
|
|
149
159
|
if (r.status === 401 && t === null) {
|
|
150
160
|
t = {
|
|
151
161
|
error: i,
|
|
@@ -157,16 +167,16 @@ function y(e) {
|
|
|
157
167
|
}
|
|
158
168
|
},
|
|
159
169
|
async create(e, t) {
|
|
160
|
-
if (!r.test(e.avatarId) || !i.test(e.idempotencyKey)) throw new
|
|
170
|
+
if (!r.test(e.avatarId) || !i.test(e.idempotencyKey)) throw new c(400, "invalid_request", null);
|
|
161
171
|
let n = JSON.stringify({
|
|
162
172
|
avatarId: e.avatarId,
|
|
163
173
|
consentVersion: e.consentVersion
|
|
164
|
-
}), p = o(),
|
|
174
|
+
}), p = o(), h = null, g = !1, v = !1, y = null;
|
|
165
175
|
for (;;) {
|
|
166
|
-
let r = await u(!0,
|
|
167
|
-
if (
|
|
168
|
-
if (r["x-workspace-authorization"] === void 0) throw new
|
|
169
|
-
let i = await
|
|
176
|
+
let r = await u(!0, h);
|
|
177
|
+
if (h = null, y !== null && o() - p > s) throw y;
|
|
178
|
+
if (r["x-workspace-authorization"] === void 0) throw new c(403, "workspace_context_required", null);
|
|
179
|
+
let i = await d(`${l}/sessions`, {
|
|
170
180
|
method: "POST",
|
|
171
181
|
headers: {
|
|
172
182
|
...r,
|
|
@@ -176,10 +186,10 @@ function y(e) {
|
|
|
176
186
|
body: n,
|
|
177
187
|
signal: t
|
|
178
188
|
});
|
|
179
|
-
if (i.status === 201) return
|
|
180
|
-
let b = await
|
|
181
|
-
if (i.status === 401 && !
|
|
182
|
-
|
|
189
|
+
if (i.status === 201) return _(await f(i));
|
|
190
|
+
let b = await m(i);
|
|
191
|
+
if (i.status === 401 && !g) {
|
|
192
|
+
g = !0, h = {
|
|
183
193
|
error: b,
|
|
184
194
|
workspace: r["x-workspace-authorization"]
|
|
185
195
|
};
|
|
@@ -187,7 +197,7 @@ function y(e) {
|
|
|
187
197
|
}
|
|
188
198
|
if (i.status === 409 && b.code === "start_in_progress") {
|
|
189
199
|
let e = Math.max(250, (b.retryAfterSeconds ?? 1) * 1e3);
|
|
190
|
-
if (o() - p + e >
|
|
200
|
+
if (o() - p + e > s || (await a(e), t?.aborted)) throw b;
|
|
191
201
|
y = b;
|
|
192
202
|
continue;
|
|
193
203
|
}
|
|
@@ -199,18 +209,18 @@ function y(e) {
|
|
|
199
209
|
}
|
|
200
210
|
},
|
|
201
211
|
async status(e, t) {
|
|
202
|
-
if (!n.test(e)) throw new
|
|
203
|
-
let r = await u(!1), i = await
|
|
212
|
+
if (!n.test(e)) throw new c(400, "invalid_request", null);
|
|
213
|
+
let r = await u(!1), i = await d(`${l}/sessions/${e}`, {
|
|
204
214
|
method: "GET",
|
|
205
215
|
headers: r,
|
|
206
216
|
signal: t
|
|
207
217
|
});
|
|
208
|
-
if (!i.ok) throw await
|
|
209
|
-
return
|
|
218
|
+
if (!i.ok) throw await m(i);
|
|
219
|
+
return y(await f(i), e);
|
|
210
220
|
},
|
|
211
221
|
async end(e, { reason: t, keepalive: r = !1 }) {
|
|
212
|
-
if (!n.test(e)) throw new
|
|
213
|
-
let i = await u(!1), a = await
|
|
222
|
+
if (!n.test(e)) throw new c(400, "invalid_request", null);
|
|
223
|
+
let i = await u(!1), a = await d(`${l}/sessions/${e}/end`, {
|
|
214
224
|
method: "POST",
|
|
215
225
|
headers: {
|
|
216
226
|
...i,
|
|
@@ -219,28 +229,28 @@ function y(e) {
|
|
|
219
229
|
body: JSON.stringify({ reason: t }),
|
|
220
230
|
keepalive: r
|
|
221
231
|
});
|
|
222
|
-
if (!a.ok) throw await
|
|
223
|
-
return
|
|
232
|
+
if (!a.ok) throw await m(a);
|
|
233
|
+
return y(await f(a), e);
|
|
224
234
|
}
|
|
225
235
|
};
|
|
226
236
|
}
|
|
227
|
-
var
|
|
237
|
+
var S = new Set([
|
|
228
238
|
"capacity",
|
|
229
239
|
"rate-limited",
|
|
230
240
|
"budget-exhausted"
|
|
231
241
|
]);
|
|
232
|
-
function
|
|
233
|
-
if (!(e instanceof
|
|
242
|
+
function C(e) {
|
|
243
|
+
if (!(e instanceof c)) return {
|
|
234
244
|
problem: "connection",
|
|
235
245
|
hide: !1
|
|
236
246
|
};
|
|
237
|
-
let t =
|
|
238
|
-
return t.problem !== null &&
|
|
247
|
+
let t = w(e);
|
|
248
|
+
return t.problem !== null && S.has(t.problem) && e.retryAfterSeconds !== null ? {
|
|
239
249
|
...t,
|
|
240
250
|
retryAfterSeconds: e.retryAfterSeconds
|
|
241
251
|
} : t;
|
|
242
252
|
}
|
|
243
|
-
function
|
|
253
|
+
function w(e) {
|
|
244
254
|
if (e.status === 0) return {
|
|
245
255
|
problem: "connection",
|
|
246
256
|
hide: !1
|
|
@@ -294,19 +304,26 @@ function S(e) {
|
|
|
294
304
|
problem: "paused",
|
|
295
305
|
hide: !1
|
|
296
306
|
};
|
|
297
|
-
case "budget_exhausted": return {
|
|
307
|
+
case "budget_exhausted": return e.scope === null ? {
|
|
298
308
|
problem: "budget-exhausted",
|
|
299
309
|
hide: !1
|
|
310
|
+
} : {
|
|
311
|
+
problem: "budget-exhausted",
|
|
312
|
+
hide: !1,
|
|
313
|
+
scope: e.scope
|
|
300
314
|
};
|
|
301
315
|
case "avatar_unavailable": return {
|
|
302
316
|
problem: "unavailable",
|
|
303
317
|
hide: !1
|
|
304
318
|
};
|
|
305
|
-
case "provider_unavailable":
|
|
306
|
-
case "provider_out_of_credits": return {
|
|
319
|
+
case "provider_unavailable": return {
|
|
307
320
|
problem: "provider",
|
|
308
321
|
hide: !1
|
|
309
322
|
};
|
|
323
|
+
case "provider_out_of_credits": return {
|
|
324
|
+
problem: "provider-out-of-credits",
|
|
325
|
+
hide: !1
|
|
326
|
+
};
|
|
310
327
|
case "authentication_required":
|
|
311
328
|
case "unauthenticated":
|
|
312
329
|
case "untrusted_caller": return {
|
|
@@ -328,7 +345,7 @@ function S(e) {
|
|
|
328
345
|
};
|
|
329
346
|
}
|
|
330
347
|
}
|
|
331
|
-
function
|
|
348
|
+
function T(e) {
|
|
332
349
|
return e === "unavailable" ? {
|
|
333
350
|
problem: "capacity",
|
|
334
351
|
hide: !1
|
|
@@ -338,4 +355,4 @@ function C(e) {
|
|
|
338
355
|
};
|
|
339
356
|
}
|
|
340
357
|
//#endregion
|
|
341
|
-
export { e as AVATAR_API_PATH,
|
|
358
|
+
export { e as AVATAR_API_PATH, c as AvatarApiError, a as avatarApiBaseFromTtsEndpoint, T as avatarAvailabilityRefusal, l as avatarIdempotencyKey, C as avatarRefusalFor, x as createAvatarSessionClient };
|
|
@@ -45,7 +45,7 @@ export interface LiveAvatarSeamOptions {
|
|
|
45
45
|
readonly avatarVoiceStore?: LiveAvatarVoiceStore;
|
|
46
46
|
readonly scheduler?: AvatarScheduler;
|
|
47
47
|
readonly browserSupported?: () => boolean;
|
|
48
|
-
readonly controller?: Partial<Pick<LiveAvatarControllerDeps, 'createAudioElement' | 'releaseAudioElement' | 'startMeter' | 'decode' | 'now' | 'newIdempotencyKey' | 'subscribeWorkspaceChange' | 'subscribePageHide' | 'idleMs' | 'endBeforeDeadlineMs' | 'connectTimeoutMs' | 'trackerConfig' | 'maxDrainMs' | 'stallMs' | 'readinessProbe'>>;
|
|
48
|
+
readonly controller?: Partial<Pick<LiveAvatarControllerDeps, 'createAudioElement' | 'releaseAudioElement' | 'startMeter' | 'decode' | 'now' | 'newIdempotencyKey' | 'subscribeWorkspaceChange' | 'subscribePageHide' | 'subscribePageShow' | 'idleMs' | 'endBeforeDeadlineMs' | 'connectTimeoutMs' | 'trackerConfig' | 'maxDrainMs' | 'stallMs' | 'readinessProbe'>>;
|
|
49
49
|
}
|
|
50
50
|
/** The seam, plus what a host or a test may need of it. */
|
|
51
51
|
export interface LiveAvatarSeamHandle extends AssistantLiveAvatarSeam {
|