@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.
@@ -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
- M || (w.current?.focus(), h.confirm());
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(), ge = P.retryAt !== null && P.retryAt > B, V = ne(P, D, B), H = P.selectedAvatarId, U = (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
- }, W = I === "ready" ? { kind: "turn-off" } : I === "ending" ? { kind: "ending" } : R || I === "starting" || I === "connecting" ? { kind: "starting" } : P.offered ? {
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: !ge && H !== null && (I === "choosing" || I === "off" && P.avatars.includes(H))
38
- } : null, G = s(null), K = W?.kind === "turn-off";
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
- G.current = K ? E() : null;
41
- }, [K, E]);
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 (W !== null) switch (W.kind) {
47
+ if (G !== null) switch (G.kind) {
48
48
  case "turn-on":
49
- if (!W.ready || H === null) return;
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: H
55
+ avatarId: U
53
56
  });
54
57
  return;
55
58
  case "turn-off": {
56
- let e = G.current;
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 = H === null ? null : pe.get(H) ?? 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) => {
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 && H !== null ? ke(H) : 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);
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 && H !== null ? /* @__PURE__ */ d(re, {
102
+ X !== null && U !== null ? /* @__PURE__ */ d(re, {
100
103
  size: "frame",
101
- name: U(H),
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: V === null ? "sr-only" : "text-center text-sm text-text-secondary",
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: V ?? ""
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 === H, n = U(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 && H !== null ? /* @__PURE__ */ f("div", {
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(H)
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
- W === null ? null : /* @__PURE__ */ d("button", {
251
+ G === null ? null : /* @__PURE__ */ d("button", {
249
252
  ref: _e,
250
253
  type: "button",
251
254
  onClick: ve,
252
- "aria-disabled": W.kind === "turn-on" ? !W.ready : W.kind !== "turn-off",
253
- "aria-describedby": W.kind === "turn-on" ? k : void 0,
254
- className: W.kind === "turn-off" ? S : ae,
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": W.kind,
257
- children: W.kind === "turn-off" ? D.stop : W.kind === "starting" ? D.turnOnStarting : W.kind === "ending" ? D.stateEnding : D.consentConfirm
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 = class extends Error {
22
+ ], s = [
23
+ "person",
24
+ "workspace",
25
+ "everyone"
26
+ ], c = class extends Error {
23
27
  status;
24
28
  code;
25
29
  retryAfterSeconds;
26
- constructor(e, t, n) {
27
- super(`avatar api ${e} ${t}`), this.status = e, this.code = t, this.retryAfterSeconds = n, this.name = "AvatarApiError";
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 c(e = globalThis.crypto) {
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 l(e) {
44
+ function u(e) {
40
45
  return typeof e == "object" && !!e && !Array.isArray(e);
41
46
  }
42
- function u(e, t) {
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 = l(t) && l(t.error) ? Number(t.error.retryAfterSeconds) : NaN;
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 d(e) {
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
- async function f(e) {
56
- let t = await d(e), n = l(t) && l(t.error) && typeof t.error.code == "string" ? t.error.code : "http_error";
57
- return new s(e.status, n, u(e, t));
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 p(e) {
60
- if (!l(e) || typeof e.available != "boolean") throw new s(200, "invalid_response", null);
61
- let t = Array.isArray(e.avatars) ? e.avatars.flatMap((e) => l(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, c = e.available && t.length > 0 && i !== "" && a > 0;
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: c,
64
- reason: c ? null : n ?? "not_enabled",
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 m(e) {
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 h(e) {
79
- if (!l(e)) throw new s(201, "invalid_response", null);
80
- let { sessionId: t, livekitUrl: r, participantToken: i, avatarIdentity: a, connectBy: o, endsAt: c } = e, u = typeof o == "string" ? Date.parse(o) : NaN, d = typeof c == "string" ? Date.parse(c) : NaN;
81
- if (typeof t != "string" || !n.test(t) || typeof r != "string" || !m(r) || typeof i != "string" || i === "" || typeof a != "string" || a === "" || !Number.isFinite(u) || !Number.isFinite(d)) throw new s(201, "invalid_response", null);
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: u,
97
+ connectBy: l,
88
98
  endsAt: d
89
99
  };
90
100
  }
91
- var g = [
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 _(e, t) {
100
- if (!l(e) || !g.includes(e.state)) throw new s(200, "invalid_response", null);
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 v = (e) => new Promise((t) => {
117
+ var b = (e) => new Promise((t) => {
108
118
  setTimeout(t, e);
109
119
  });
110
- function y(e) {
111
- let t = e.fetchImpl ?? ((e, t) => fetch(e, t)), a = e.sleep ?? v, o = e.now ?? (() => Date.now()), c = e.startInProgressBudgetMs ?? 15e3, l = e.baseUrl.replace(/\/+$/, "");
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 s(401, "unauthenticated", null);
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 m(e, n) {
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 s(0, "network", null);
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 m(`${l}/availability`, {
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 p(await d(r));
148
- let i = await f(r);
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 s(400, "invalid_request", null);
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(), g = null, _ = !1, v = !1, y = null;
174
+ }), p = o(), h = null, g = !1, v = !1, y = null;
165
175
  for (;;) {
166
- let r = await u(!0, g);
167
- if (g = null, y !== null && o() - p > c) throw y;
168
- if (r["x-workspace-authorization"] === void 0) throw new s(403, "workspace_context_required", null);
169
- let i = await m(`${l}/sessions`, {
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 h(await d(i));
180
- let b = await f(i);
181
- if (i.status === 401 && !_) {
182
- _ = !0, g = {
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 > c || (await a(e), t?.aborted)) throw b;
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 s(400, "invalid_request", null);
203
- let r = await u(!1), i = await m(`${l}/sessions/${e}`, {
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 f(i);
209
- return _(await d(i), e);
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 s(400, "invalid_request", null);
213
- let i = await u(!1), a = await m(`${l}/sessions/${e}/end`, {
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 f(a);
223
- return _(await d(a), e);
232
+ if (!a.ok) throw await m(a);
233
+ return y(await f(a), e);
224
234
  }
225
235
  };
226
236
  }
227
- var b = new Set([
237
+ var S = new Set([
228
238
  "capacity",
229
239
  "rate-limited",
230
240
  "budget-exhausted"
231
241
  ]);
232
- function x(e) {
233
- if (!(e instanceof s)) return {
242
+ function C(e) {
243
+ if (!(e instanceof c)) return {
234
244
  problem: "connection",
235
245
  hide: !1
236
246
  };
237
- let t = S(e);
238
- return t.problem !== null && b.has(t.problem) && e.retryAfterSeconds !== 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 S(e) {
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 C(e) {
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, s as AvatarApiError, a as avatarApiBaseFromTtsEndpoint, C as avatarAvailabilityRefusal, c as avatarIdempotencyKey, x as avatarRefusalFor, y as createAvatarSessionClient };
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 {