realtime-avatar 0.30.0 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -53,6 +53,12 @@ lifecycle; the hook is not a shared audio-session lease. Camera publication stil
53
53
  server grant's permission and the caller's opt-in. Room callbacks/options continue to use LiveKit's
54
54
  public types and implementation; no separate connection state machine is introduced.
55
55
 
56
+ **On iOS, the room also clears an input mute an earlier call left on the app.** A server-closed room
57
+ can leave iOS 26's per-app input mute set, so later calls publish an unmuted track of silence. Each
58
+ time the room's own microphone goes live, `RealtimeAvatarLiveKitRoom` round-trips the audio engine's
59
+ mute once so the engine writes "unmuted" itself (iOS with the Voice Processing mute mode only; never
60
+ on Android). A room you compose yourself needs `useClearStaleInputMute(room)` inside it.
61
+
56
62
  **This is a native build upgrade, not an OTA-only change.** Rebuild iOS and Android binaries with
57
63
  RN3/WebRTC 144.2.0 before shipping JavaScript that requires them. Retain the previous SDK group for
58
64
  installed binaries that still use RN2, and isolate their OTA runtime/channel appropriately.
@@ -243,6 +249,98 @@ return new Response(await myTts(text, voice_id), { headers: { "content-type": "a
243
249
  Working endpoints: `apps/quickstart/nextjs-app-router/app/api/voice/route.ts` and `POST /api/voice`
244
250
  in `apps/quickstart/python-fastapi/main.py`.
245
251
 
252
+ ## Pre-rendered video
253
+
254
+ **Everything in one shot happens at the same time; shots play one after another.**
255
+
256
+ ```ts
257
+ const render = await rta.createRender({
258
+ avatarId: "ava_0123456789abcdef0123456789abcdef",
259
+ shots: [
260
+ { clipId: "gesture_send_flower", say: "你终于来了。今天……我有话想对你说。" },
261
+ { clipId: "idle_touch_collar", say: "别笑,我是认真的。", pauseAfterMs: 800 },
262
+ { say: "所以,今晚留下来。" },
263
+ ],
264
+ });
265
+ const done = await rta.waitForRender(render.id);
266
+ if (done.status === "failed") throw new Error(done.error?.message);
267
+ const { url, expiresAt } = await rta.getRenderAccess(done.id); // <video src={url}> plays it
268
+ ```
269
+
270
+ She sends the flower while she says the first line, touches her collar while she says the
271
+ second and then stays quiet for 800 ms, and says the last line without a new clip. The result is
272
+ an MP4 (H.264 + AAC, 25 fps) with the same face, clips, voice and lip-sync as a call, made
273
+ offline with no call and no LiveKit room. The avatar id is a placeholder: use your own
274
+ `avatarId`, and clip ids from `listClips(avatarId)`.
275
+
276
+ | Field | What it is |
277
+ | --- | --- |
278
+ | `avatarId` | The avatar. |
279
+ | `voiceId` | A voice from your workspace's voice library. |
280
+ | `voice` | An inline Fish voice, the same object a call takes: `{ provider: "fish", voice_id, model?, speed?, emotion?, language? }`. |
281
+ | `lipGain` | Mouth-motion amplitude, as on a call. Omit it for the default. |
282
+ | `shots` | The script: 1 to 50 shots, played one after another. |
283
+ | `shots[].clipId` | What she does: a ready clip from the avatar's clip library, or `"primary"` for the avatar's own video. Omit it to keep the current loop clip. |
284
+ | `shots[].say` | What she says, 1 to 1,000 characters after trimming whitespace; a blank `say` is refused. Speech starts when the shot starts. |
285
+ | `shots[].pauseAfterMs` | How long she stays silent after speaking, 0 to 10,000 ms. Default 0. |
286
+
287
+ **How long a shot lasts.** Its speech plus `pauseAfterMs`, or its clip's action if that is
288
+ longer, rounded up to 200 ms. A loop clip does not set a shot's length: a shot with only a loop
289
+ clip lasts 200 ms, so add `pauseAfterMs` to hold it.
290
+
291
+ **Which clips loop.** A clip loops if it is `"primary"` or in the avatar's idle pool
292
+ (`listClips(avatarId).behavior.idle.clips`); every other clip plays once, so a listening clip
293
+ or an action that is not also in the idle pool plays once. The clip list has no per-clip
294
+ `playback`; read `behavior.idle.clips` from it.
295
+
296
+ - **once**, an action: it plays exactly once from its first frame and is never cut. If the shot
297
+ runs longer, she continues on the loop clip from before the shot. The same clip in two shots
298
+ in a row plays twice.
299
+ - **loop**: it fills the shot, and the same loop clip in shots in a row continues without
300
+ restarting.
301
+
302
+ The video opens with about 400 ms and closes with about 600 ms on the current loop clip.
303
+
304
+ **Where each shot landed.** A `ready` render carries `timeline`, one entry per shot, in order.
305
+ Every time is milliseconds from the start of the video.
306
+
307
+ | Field | What it is |
308
+ | --- | --- |
309
+ | `index` | The shot's position in your `shots`, from 0. |
310
+ | `startMs` · `endMs` | When the shot starts and ends; the next shot starts at `endMs`. |
311
+ | `clipId` | The clip the shot played: the one you named, else the loop clip it kept, else `"primary"`. |
312
+ | `playback` | `"once"` or `"loop"`. |
313
+ | `speechStartMs` · `speechEndMs` | When she starts and stops speaking. `null` when the shot has no `say`. |
314
+ | `clipEndMs` | When the action finished. Once clips only, else `null`. |
315
+ | `afterClipId` | The loop clip shown after the action, when the shot outlasts it. Once clips only, else `null`. |
316
+
317
+ - **The key needs `renders:write` to create and `renders:read` to read.** Both are off on a new
318
+ key until you tick them; a key without the scope answers `403 insufficient_scope`.
319
+ - **`createRender` returns on acceptance.** A render is `queued`, then `rendering`, then `ready`
320
+ or `failed`. `waitForRender` returns a failed render rather than throwing, so `error.code`
321
+ (`asset_unavailable`, `tts_failed`, `too_long`, `render_failed`) stays a value you can branch
322
+ on. It throws only when its timeout (30 minutes by default) runs out, and that is not a
323
+ failure.
324
+ - **A `clipId` must be a READY clip of the avatar, or `"primary"`.** Otherwise the create is
325
+ refused with `422 render_clip_unavailable` before anything is charged. Run `waitForClips`
326
+ after changing the library.
327
+ - **The voice is `voiceId`, or `voice`, or neither for the avatar's own.** Sending both does not
328
+ compile, and the platform refuses it with `422`. Only a Fish voice renders: a `voiceId` the
329
+ workspace cannot see is `404 voice_not_found`, and an inline voice of another provider, a
330
+ `voiceId` that is not Fish, or, when neither was sent, an avatar whose own voice is not Fish
331
+ is `422 voice_unavailable`, refused before anything is charged. A render is never quietly
332
+ spoken in another voice. `render.voiceId` is the library voice it spoke with, `null` for an
333
+ inline `voice`.
334
+ - **Keep the render id, not the URL.** The URL is signed for an hour; ask `getRenderAccess`
335
+ again for a fresh one. The file itself is kept until you delete the account.
336
+ - **Limits.** Every shot sets at least one field (`pauseAfterMs: 0` alone does not count), at
337
+ least one shot has `say`, at most 4,000 characters of `say` in total and 16 different clips
338
+ besides `"primary"`. A script whose video would run past 180 seconds is refused with
339
+ `400 render_too_long` before any credits are held. A workspace may have 4 renders queued or rendering at once; the
340
+ next is `429 concurrency_limit_reached`, which clears when one settles.
341
+ - **Billing.** Per second of rendered video at the live per-second rate. A failed render is not
342
+ charged.
343
+
246
344
  ## Input source on room messages
247
345
 
248
346
  On React and React Native, `session.sendTurn(text)` automatically observes text.
@@ -304,6 +402,14 @@ rta.getRecording(recordingId)
304
402
  rta.getRecordingAccess(recordingId)
305
403
  rta.getConnectionHistory(sessionId) // bounded LiveKit observations; requires usage:read
306
404
 
405
+ // pre-rendered video (MP4, no live call); server only, requires renders:write / renders:read
406
+ rta.createRender({ avatarId, voiceId? | voice?, lipGain?, shots }) // 202 queued; one Idempotency-Key across retries
407
+ rta.waitForRender(renderId) // block until ready | failed; RETURNS a failed render, throws only on timeout
408
+ rta.getRender(renderId)
409
+ rta.listRenders({ limit?, cursor? })
410
+ rta.iterateRenders({ limit? }) // every render, paging handled
411
+ rta.getRenderAccess(renderId) // { id, url, expiresAt }; signed for an hour, renew when needed
412
+
307
413
  // avatars
308
414
  rta.createAvatarFromImage({ displayName, imageUrl, motionPrompt?, voice? }) // the only lane
309
415
  rta.createAvatarFromVideo({ displayName, videoUrl, voice? }) // DEPRECATED — closed, 422
@@ -1,4 +1,4 @@
1
- import { sessionModeSchema, liveKitSessionReleaseReasonSchema, RealtimeAvatar, ROUTE_TIMEOUT_MS, isQueued, RealtimeAvatarHttpError, RealtimeAvatarError } from './chunk-WXVBPMDN.js';
1
+ import { sessionModeSchema, liveKitSessionReleaseReasonSchema, RealtimeAvatar, ROUTE_TIMEOUT_MS, isQueued, RealtimeAvatarHttpError, RealtimeAvatarError } from './chunk-NKS5ZIWN.js';
2
2
  import { z } from 'zod';
3
3
 
4
4
  // ../http-client/src/generated/error-semantics.ts
@@ -297,6 +297,56 @@ var recordingAccessResponseSchema = z.object({
297
297
  url: z.string().url(),
298
298
  expiresAt: z.string().datetime({ offset: true })
299
299
  }).strict();
300
+ var RENDER_ID_PATTERN = /^rnd_[0-9a-f]{32}$/;
301
+ var renderIdSchema = z.string().regex(RENDER_ID_PATTERN, "render id must be rnd_ followed by 32 lowercase hex");
302
+ var RENDER_STATUSES = ["queued", "rendering", "ready", "failed"];
303
+ var renderStatusSchema = z.enum(RENDER_STATUSES);
304
+ var RENDER_FAILURE_CODES = ["asset_unavailable", "tts_failed", "too_long", "render_failed"];
305
+ var renderFailureCodeSchema = z.enum(RENDER_FAILURE_CODES);
306
+ var RENDER_PLAYBACKS = ["once", "loop"];
307
+ var renderPlaybackSchema = z.enum(RENDER_PLAYBACKS);
308
+ var renderErrorSchema = z.object({
309
+ code: renderFailureCodeSchema,
310
+ message: z.string().min(1)
311
+ }).strict();
312
+ var shotTimingSchema = z.object({
313
+ index: z.number().int().nonnegative().describe("The shot's position in your shots list, from 0."),
314
+ startMs: z.number().int().nonnegative().describe("When the shot starts."),
315
+ endMs: z.number().int().positive().describe("When the shot ends; the next shot starts here."),
316
+ clipId: z.string().min(1).describe('The clip the shot played: the one you named, else the loop clip it kept, else "primary".'),
317
+ playback: renderPlaybackSchema.describe("once: the clip's action played one time. loop: the clip filled the shot."),
318
+ speechStartMs: z.number().int().nonnegative().nullable().describe("When she starts speaking. Null when the shot has no say."),
319
+ speechEndMs: z.number().int().nonnegative().nullable().describe("When she stops speaking. Null when the shot has no say."),
320
+ clipEndMs: z.number().int().nonnegative().nullable().describe("When the action finished. Once clips only; null for a loop clip."),
321
+ afterClipId: z.string().min(1).nullable().describe("The loop clip shown after the action finished, when the shot outlasts it. Once clips only; otherwise null.")
322
+ }).strict();
323
+ var renderSchema = z.object({
324
+ id: renderIdSchema,
325
+ object: z.literal("render"),
326
+ status: renderStatusSchema,
327
+ avatarId: z.string().min(1),
328
+ voiceId: z.string().min(1).nullable().describe("The library voice the render speaks with: the voiceId you sent, else the avatar's own voice. Null when it speaks with the inline voice you sent."),
329
+ durationMs: z.number().int().positive().nullable().describe("Length of the rendered video. Set once status is ready."),
330
+ width: z.number().int().positive().nullable(),
331
+ height: z.number().int().positive().nullable(),
332
+ timeline: z.array(shotTimingSchema).nullable().describe("One entry per shot, in order. Set once status is ready."),
333
+ error: renderErrorSchema.nullable().describe("Set only when status is failed."),
334
+ createdAt: z.string().datetime({ offset: true }),
335
+ completedAt: z.string().datetime({ offset: true }).nullable()
336
+ }).strict();
337
+ var listRendersQuerySchema = z.object({
338
+ limit: z.coerce.number().int().min(1).max(100).default(50),
339
+ cursor: z.string().min(1).optional()
340
+ }).strict();
341
+ var listRendersResponseSchema = z.object({
342
+ data: z.array(renderSchema),
343
+ nextCursor: z.string().nullable()
344
+ }).strict();
345
+ var renderAccessResponseSchema = z.object({
346
+ id: renderIdSchema,
347
+ url: z.string().url(),
348
+ expiresAt: z.string().datetime({ offset: true })
349
+ }).strict();
300
350
  var schema02 = z.enum(["s1", "s2-pro", "s2.1-pro", "drama-3"]);
301
351
  var schema110 = z.enum(["speech-1.6", "speech-1.5", "s1-mini"]);
302
352
  var schema27 = z.union([schema02, schema110]);
@@ -317,6 +367,13 @@ function backoffMs(attempt, retryAfter) {
317
367
  return Math.random() * Math.min(500 * 2 ** attempt, 8e3);
318
368
  }
319
369
  var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
370
+ function pollBudget(options, defaults) {
371
+ const finite = (value, fallback) => typeof value === "number" && Number.isFinite(value) ? value : fallback;
372
+ return {
373
+ timeoutMs: finite(options.timeoutMs, defaults.timeoutMs),
374
+ pollMs: Math.max(1e3, finite(options.pollMs, defaults.pollMs))
375
+ };
376
+ }
320
377
  var PROXY_CLIENT_TIMEOUT_MS = 6e4;
321
378
  var ROUTE_TIMEOUT_MS = PROXY_CLIENT_TIMEOUT_MS - 1e4;
322
379
  function retryFits(attemptStartedAt, waitMs, deadline) {
@@ -861,7 +918,8 @@ function toSessionsPage(page) {
861
918
 
862
919
  // ../http-client/src/client.ts
863
920
  var DEFAULT_BASE_URL = "https://realtimeavatar.ai/api/v1";
864
- var SDK_VERSION = "0.30.0";
921
+ var RENDER_MISMATCH = "Render response did not match the SDK contract";
922
+ var SDK_VERSION = "0.32.0";
865
923
  var RealtimeAvatar = class {
866
924
  #apiKey;
867
925
  #baseUrl;
@@ -1186,8 +1244,7 @@ var RealtimeAvatar = class {
1186
1244
  * failed render and on timeout; a timeout is not a failure, so re-poll or call again.
1187
1245
  */
1188
1246
  async waitForLoop(avatarId, options = {}) {
1189
- const timeoutMs = options.timeoutMs ?? 20 * 6e4;
1190
- const pollMs = Math.max(1e3, options.pollMs ?? 1e4);
1247
+ const { timeoutMs, pollMs } = pollBudget(options, { timeoutMs: 20 * 6e4, pollMs: 1e4 });
1191
1248
  const deadline = Date.now() + timeoutMs;
1192
1249
  for (; ; ) {
1193
1250
  const avatar = await this.getAvatar(avatarId);
@@ -1217,8 +1274,7 @@ var RealtimeAvatar = class {
1217
1274
  * Throws only on timeout.
1218
1275
  */
1219
1276
  async waitForClips(avatarId, options = {}) {
1220
- const timeoutMs = options.timeoutMs ?? 20 * 6e4;
1221
- const pollMs = Math.max(1e3, options.pollMs ?? 1e4);
1277
+ const { timeoutMs, pollMs } = pollBudget(options, { timeoutMs: 20 * 6e4, pollMs: 1e4 });
1222
1278
  const deadline = Date.now() + timeoutMs;
1223
1279
  for (; ; ) {
1224
1280
  const library = await this.listClips(avatarId);
@@ -1284,19 +1340,11 @@ var RealtimeAvatar = class {
1284
1340
  const response = await this.#request("GET", `/usage/sessions${suffix}`, {
1285
1341
  headers: options.speechDiagnostics === true ? { "X-RTA-Speech-Diagnostics": "1" } : void 0
1286
1342
  });
1287
- const mismatch = "Usage sessions response did not match the SDK contract";
1288
- let raw;
1289
- try {
1290
- raw = await this.#json(response);
1291
- } catch (error) {
1292
- if (error instanceof SyntaxError) throw new RealtimeAvatarError(mismatch);
1293
- throw error;
1294
- }
1295
- const page = listUsageSessionsResponseSchema.safeParse(raw);
1296
- if (!page.success) {
1297
- throw new RealtimeAvatarError(mismatch);
1298
- }
1299
- return toSessionsPage(page.data);
1343
+ return toSessionsPage(await this.#contract(
1344
+ response,
1345
+ listUsageSessionsResponseSchema,
1346
+ "Usage sessions response did not match the SDK contract"
1347
+ ));
1300
1348
  }
1301
1349
  /**
1302
1350
  * Every session in a window, following the cursor for you.
@@ -1330,6 +1378,82 @@ var RealtimeAvatar = class {
1330
1378
  async getRecordingAccess(recordingId) {
1331
1379
  return recordingAccessResponseSchema.parse(await this.#json(await this.#request("GET", `/recordings/${encodeURIComponent(recordingId)}/access`)));
1332
1380
  }
1381
+ // ── renders (pre-rendered video) ─────────────────────────────────────────
1382
+ /**
1383
+ * Render an MP4 of the avatar performing a script of `shots`, offline, with no live call.
1384
+ * Everything in one shot happens at the same time; shots play one after another. Requires
1385
+ * `renders:write`, which a new key does not carry unless you tick it.
1386
+ *
1387
+ * `202` is acceptance: the render is `queued`, and `waitForRender` follows it to the end.
1388
+ * Every `clipId` must be a READY clip of this avatar or `"primary"`, or the request is refused
1389
+ * with `422 render_clip_unavailable` before anything is charged. The retry carries the same
1390
+ * `Idempotency-Key`, so a lost response never starts, or bills, a second render.
1391
+ */
1392
+ async createRender(input) {
1393
+ return this.#contract(await this.#request("POST", "/renders", { json: input }), renderSchema, RENDER_MISMATCH);
1394
+ }
1395
+ /** One render's status. Requires `renders:read`. */
1396
+ async getRender(renderId) {
1397
+ return this.#contract(await this.#request("GET", `/renders/${encodeURIComponent(renderId)}`), renderSchema, RENDER_MISMATCH);
1398
+ }
1399
+ /** This workspace's renders, newest first, one page. Requires `renders:read`. */
1400
+ async listRenders(options = {}) {
1401
+ const checked = listRendersQuerySchema.safeParse(options);
1402
+ if (!checked.success) {
1403
+ const issues = checked.error.issues.map((issue) => `${issue.path.join(".")} ${issue.message}`).join("; ");
1404
+ throw new RealtimeAvatarError(`Invalid listRenders options: ${issues}`);
1405
+ }
1406
+ const parsed = checked.data;
1407
+ const query = new URLSearchParams();
1408
+ if (options.limit !== void 0) query.set("limit", String(parsed.limit));
1409
+ if (parsed.cursor !== void 0) query.set("cursor", parsed.cursor);
1410
+ const suffix = query.size ? `?${query}` : "";
1411
+ return this.#contract(await this.#request("GET", `/renders${suffix}`), listRendersResponseSchema, RENDER_MISMATCH);
1412
+ }
1413
+ /** Every render, following `nextCursor` for you. */
1414
+ async *iterateRenders(options = {}) {
1415
+ let cursor = options.cursor;
1416
+ do {
1417
+ const page = await this.listRenders({ ...options, cursor });
1418
+ yield* page.data;
1419
+ cursor = page.nextCursor ?? void 0;
1420
+ } while (cursor);
1421
+ }
1422
+ /**
1423
+ * A signed download URL for a ready render. It expires at `expiresAt` (an hour); keep the
1424
+ * render id and ask again rather than storing the URL. `409 render_not_ready` before the
1425
+ * render is ready, `410 render_gone` if the file is no longer stored.
1426
+ */
1427
+ async getRenderAccess(renderId) {
1428
+ return this.#contract(
1429
+ await this.#request("GET", `/renders/${encodeURIComponent(renderId)}/access`),
1430
+ renderAccessResponseSchema,
1431
+ RENDER_MISMATCH
1432
+ );
1433
+ }
1434
+ /**
1435
+ * Block until a render settles, and return it: `ready` with its `timeline`, or `failed` with
1436
+ * `error.code`.
1437
+ *
1438
+ * A failed render is returned, not thrown, so its code stays a typed value you can branch on
1439
+ * (`too_long` means shorten the script; `tts_failed` and `render_failed` are worth one retry).
1440
+ * Throws only on timeout, which is not a failure: the render may still land, so poll again.
1441
+ * The default timeout is 30 minutes, the platform's own budget for one render.
1442
+ */
1443
+ async waitForRender(renderId, options = {}) {
1444
+ const { timeoutMs, pollMs } = pollBudget(options, { timeoutMs: 30 * 6e4, pollMs: 5e3 });
1445
+ const deadline = Date.now() + timeoutMs;
1446
+ for (; ; ) {
1447
+ const render = await this.getRender(renderId);
1448
+ if (render.status === "ready" || render.status === "failed") return render;
1449
+ if (Date.now() >= deadline) {
1450
+ throw new RealtimeAvatarError(
1451
+ `Render ${renderId} was still ${render.status} after ${Math.round(timeoutMs / 1e3)}s. This is a timeout, not a failure \u2014 the render may still land.`
1452
+ );
1453
+ }
1454
+ await sleep(pollMs);
1455
+ }
1456
+ }
1333
1457
  /** Read one session's bounded LiveKit connection history. Requires `usage:read`. */
1334
1458
  async getConnectionHistory(sessionId) {
1335
1459
  if (!sessionId) throw new RealtimeAvatarError("sessionId is required");
@@ -1391,6 +1515,22 @@ var RealtimeAvatar = class {
1391
1515
  }
1392
1516
  throw new RealtimeAvatarHttpError(response.status, code, text, response.headers.get("x-request-id") ?? void 0);
1393
1517
  }
1518
+ /**
1519
+ * A 2xx body validated against its contract schema. A mismatch, malformed JSON included,
1520
+ * throws one fixed message with no cause, so the rejected body never reaches a log.
1521
+ */
1522
+ async #contract(response, schema, mismatch) {
1523
+ let raw;
1524
+ try {
1525
+ raw = await this.#json(response);
1526
+ } catch (error) {
1527
+ if (error instanceof SyntaxError) throw new RealtimeAvatarError(mismatch);
1528
+ throw error;
1529
+ }
1530
+ const parsed = schema.safeParse(raw);
1531
+ if (!parsed.success) throw new RealtimeAvatarError(mismatch);
1532
+ return parsed.data;
1533
+ }
1394
1534
  };
1395
1535
  function isRecord(value) {
1396
1536
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -1519,4 +1659,4 @@ function isQueued(result) {
1519
1659
  return "queued" in result;
1520
1660
  }
1521
1661
 
1522
- export { DEFAULT_FISH_TTS_MODEL, ROUTE_TIMEOUT_MS, RealtimeAvatar, RealtimeAvatarError, RealtimeAvatarHttpError, RealtimeAvatarWebhookError, clipLibraryDeclarationSchema, fishTtsModelSchema, isQueued, listRecordingsResponseSchema, liveKitSessionReleaseReasonSchema, recordingAccessResponseSchema, recordingArtifactSchema, recordingModeSchema, sessionModeSchema, verifyTranscript, verifyVoiceWebhook };
1662
+ export { DEFAULT_FISH_TTS_MODEL, ROUTE_TIMEOUT_MS, RealtimeAvatar, RealtimeAvatarError, RealtimeAvatarHttpError, RealtimeAvatarWebhookError, clipLibraryDeclarationSchema, fishTtsModelSchema, isQueued, listRecordingsResponseSchema, listRendersResponseSchema, liveKitSessionReleaseReasonSchema, recordingAccessResponseSchema, recordingArtifactSchema, recordingModeSchema, renderAccessResponseSchema, renderSchema, sessionModeSchema, verifyTranscript, verifyVoiceWebhook };
package/dist/express.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as ProxyConfig } from './types-CgAEmIVE.js';
2
- import './types-Bv29uEAs.js';
1
+ import { P as ProxyConfig } from './types-su27kEw0.js';
2
+ import './types-BSSqsu_Z.js';
3
3
  import 'zod';
4
4
 
5
5
  type Expressish = {
package/dist/express.js CHANGED
@@ -1,5 +1,5 @@
1
- import { createProxyHandler } from './chunk-GLIEEJMW.js';
2
- import './chunk-WXVBPMDN.js';
1
+ import { createProxyHandler } from './chunk-NDCZABOK.js';
2
+ import './chunk-NKS5ZIWN.js';
3
3
  import './chunk-MCIXU6XP.js';
4
4
 
5
5
  // ../proxy/src/express.ts
package/dist/hono.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as ProxyConfig } from './types-CgAEmIVE.js';
2
- import './types-Bv29uEAs.js';
1
+ import { P as ProxyConfig } from './types-su27kEw0.js';
2
+ import './types-BSSqsu_Z.js';
3
3
  import 'zod';
4
4
 
5
5
  /**
package/dist/hono.js CHANGED
@@ -1,5 +1,5 @@
1
- import { createProxyHandler } from './chunk-GLIEEJMW.js';
2
- import './chunk-WXVBPMDN.js';
1
+ import { createProxyHandler } from './chunk-NDCZABOK.js';
2
+ import './chunk-NKS5ZIWN.js';
3
3
  import './chunk-MCIXU6XP.js';
4
4
 
5
5
  // ../proxy/src/hono.ts
package/dist/index.d.ts CHANGED
@@ -1,8 +1,146 @@
1
- import { a as CallPolicy, C as CallMode, S as StartCallResult, E as EndCallOptions, A as Avatar, b as AvatarUpdate, c as AvatarSourceSwap, d as ClipLibraryDeclaration, e as ClipLibraryUpdate, L as LoopRedirect, f as ClipLibrary, g as AssetKind, h as Asset, i as ListSessionsOptions, U as UsageSessionPage, j as UsageSession, k as ListRecordingsQuery, l as ListRecordingsResponse, R as RecordingArtifact, m as RecordingAccessResponse, n as CreditBalance, T as TranscriptPayload, V as VoiceWebhookRequest } from './types-Bv29uEAs.js';
2
- export { o as AvatarClip, p as CallConnection, q as CallQueued, r as ClipDeclaration, s as ClipLibraryPlan, t as ClipSource, u as ContextMessage, v as EndCallReason, w as ExternalLlm, x as RecordingArtifactStatus, y as RecordingMode, z as VideoPolicy, B as VoiceWebhook, D as VoiceWebhookErrorCode, F as isQueued, G as listRecordingsResponseSchema, H as recordingAccessResponseSchema, I as recordingArtifactSchema, J as recordingModeSchema } from './types-Bv29uEAs.js';
1
+ import { a as CallPolicy, C as CallMode, S as StartCallResult, E as EndCallOptions, A as Avatar, b as AvatarUpdate, c as AvatarSourceSwap, d as ClipLibraryDeclaration, e as ClipLibraryUpdate, L as LoopRedirect, f as ClipLibrary, g as AssetKind, h as Asset, i as ListSessionsOptions, U as UsageSessionPage, j as UsageSession, k as ListRecordingsQuery, l as ListRecordingsResponse, R as RecordingArtifact, m as RecordingAccessResponse, n as CreateRenderInput, o as CreditBalance, T as TranscriptPayload, V as VoiceWebhookRequest } from './types-BSSqsu_Z.js';
2
+ export { p as AvatarClip, q as CallConnection, r as CallQueued, s as ClipDeclaration, t as ClipLibraryPlan, u as ClipSource, v as ContextMessage, w as EndCallReason, x as ExternalLlm, y as RecordingArtifactStatus, z as RecordingMode, B as RenderShot, D as VideoPolicy, F as VoiceWebhook, G as VoiceWebhookErrorCode, H as isQueued, I as listRecordingsResponseSchema, J as recordingAccessResponseSchema, K as recordingArtifactSchema, M as recordingModeSchema } from './types-BSSqsu_Z.js';
3
3
  import { ConnectionHistoryResponse } from './connection-history.js';
4
4
  import { z } from 'zod';
5
5
 
6
+ /** The caller-tunable timing of a `waitFor*` poll loop. */
7
+ type PollOptions = {
8
+ timeoutMs?: number;
9
+ pollMs?: number;
10
+ };
11
+
12
+ declare const renderStatusSchema: z.ZodEnum<{
13
+ ready: "ready";
14
+ failed: "failed";
15
+ queued: "queued";
16
+ rendering: "rendering";
17
+ }>;
18
+ type RenderStatus = z.infer<typeof renderStatusSchema>;
19
+ declare const renderFailureCodeSchema: z.ZodEnum<{
20
+ asset_unavailable: "asset_unavailable";
21
+ tts_failed: "tts_failed";
22
+ too_long: "too_long";
23
+ render_failed: "render_failed";
24
+ }>;
25
+ type RenderFailureCode = z.infer<typeof renderFailureCodeSchema>;
26
+ declare const renderPlaybackSchema: z.ZodEnum<{
27
+ once: "once";
28
+ loop: "loop";
29
+ }>;
30
+ type RenderPlayback = z.infer<typeof renderPlaybackSchema>;
31
+ /** Where one shot landed in the video. Every time is milliseconds from the start of the video. */
32
+ declare const shotTimingSchema: z.ZodObject<{
33
+ index: z.ZodNumber;
34
+ startMs: z.ZodNumber;
35
+ endMs: z.ZodNumber;
36
+ clipId: z.ZodString;
37
+ playback: z.ZodEnum<{
38
+ once: "once";
39
+ loop: "loop";
40
+ }>;
41
+ speechStartMs: z.ZodNullable<z.ZodNumber>;
42
+ speechEndMs: z.ZodNullable<z.ZodNumber>;
43
+ clipEndMs: z.ZodNullable<z.ZodNumber>;
44
+ afterClipId: z.ZodNullable<z.ZodString>;
45
+ }, z.core.$strict>;
46
+ type ShotTiming = z.infer<typeof shotTimingSchema>;
47
+ declare const renderSchema: z.ZodObject<{
48
+ id: z.ZodString;
49
+ object: z.ZodLiteral<"render">;
50
+ status: z.ZodEnum<{
51
+ ready: "ready";
52
+ failed: "failed";
53
+ queued: "queued";
54
+ rendering: "rendering";
55
+ }>;
56
+ avatarId: z.ZodString;
57
+ voiceId: z.ZodNullable<z.ZodString>;
58
+ durationMs: z.ZodNullable<z.ZodNumber>;
59
+ width: z.ZodNullable<z.ZodNumber>;
60
+ height: z.ZodNullable<z.ZodNumber>;
61
+ timeline: z.ZodNullable<z.ZodArray<z.ZodObject<{
62
+ index: z.ZodNumber;
63
+ startMs: z.ZodNumber;
64
+ endMs: z.ZodNumber;
65
+ clipId: z.ZodString;
66
+ playback: z.ZodEnum<{
67
+ once: "once";
68
+ loop: "loop";
69
+ }>;
70
+ speechStartMs: z.ZodNullable<z.ZodNumber>;
71
+ speechEndMs: z.ZodNullable<z.ZodNumber>;
72
+ clipEndMs: z.ZodNullable<z.ZodNumber>;
73
+ afterClipId: z.ZodNullable<z.ZodString>;
74
+ }, z.core.$strict>>>;
75
+ error: z.ZodNullable<z.ZodObject<{
76
+ code: z.ZodEnum<{
77
+ asset_unavailable: "asset_unavailable";
78
+ tts_failed: "tts_failed";
79
+ too_long: "too_long";
80
+ render_failed: "render_failed";
81
+ }>;
82
+ message: z.ZodString;
83
+ }, z.core.$strict>>;
84
+ createdAt: z.ZodString;
85
+ completedAt: z.ZodNullable<z.ZodString>;
86
+ }, z.core.$strict>;
87
+ type Render = z.infer<typeof renderSchema>;
88
+ declare const listRendersQuerySchema: z.ZodObject<{
89
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
90
+ cursor: z.ZodOptional<z.ZodString>;
91
+ }, z.core.$strict>;
92
+ type ListRendersQuery = Partial<z.infer<typeof listRendersQuerySchema>>;
93
+ declare const listRendersResponseSchema: z.ZodObject<{
94
+ data: z.ZodArray<z.ZodObject<{
95
+ id: z.ZodString;
96
+ object: z.ZodLiteral<"render">;
97
+ status: z.ZodEnum<{
98
+ ready: "ready";
99
+ failed: "failed";
100
+ queued: "queued";
101
+ rendering: "rendering";
102
+ }>;
103
+ avatarId: z.ZodString;
104
+ voiceId: z.ZodNullable<z.ZodString>;
105
+ durationMs: z.ZodNullable<z.ZodNumber>;
106
+ width: z.ZodNullable<z.ZodNumber>;
107
+ height: z.ZodNullable<z.ZodNumber>;
108
+ timeline: z.ZodNullable<z.ZodArray<z.ZodObject<{
109
+ index: z.ZodNumber;
110
+ startMs: z.ZodNumber;
111
+ endMs: z.ZodNumber;
112
+ clipId: z.ZodString;
113
+ playback: z.ZodEnum<{
114
+ once: "once";
115
+ loop: "loop";
116
+ }>;
117
+ speechStartMs: z.ZodNullable<z.ZodNumber>;
118
+ speechEndMs: z.ZodNullable<z.ZodNumber>;
119
+ clipEndMs: z.ZodNullable<z.ZodNumber>;
120
+ afterClipId: z.ZodNullable<z.ZodString>;
121
+ }, z.core.$strict>>>;
122
+ error: z.ZodNullable<z.ZodObject<{
123
+ code: z.ZodEnum<{
124
+ asset_unavailable: "asset_unavailable";
125
+ tts_failed: "tts_failed";
126
+ too_long: "too_long";
127
+ render_failed: "render_failed";
128
+ }>;
129
+ message: z.ZodString;
130
+ }, z.core.$strict>>;
131
+ createdAt: z.ZodString;
132
+ completedAt: z.ZodNullable<z.ZodString>;
133
+ }, z.core.$strict>>;
134
+ nextCursor: z.ZodNullable<z.ZodString>;
135
+ }, z.core.$strict>;
136
+ type ListRendersResponse = z.infer<typeof listRendersResponseSchema>;
137
+ declare const renderAccessResponseSchema: z.ZodObject<{
138
+ id: z.ZodString;
139
+ url: z.ZodString;
140
+ expiresAt: z.ZodString;
141
+ }, z.core.$strict>;
142
+ type RenderAccessResponse = z.infer<typeof renderAccessResponseSchema>;
143
+
6
144
  interface RealtimeAvatarOptions {
7
145
  /** `tic_live_…` or `tic_test_…`. Server-side only — never ship this to a browser. */
8
146
  apiKey: string;
@@ -232,10 +370,7 @@ declare class RealtimeAvatar {
232
370
  * Resolves with the settled avatar — `sourceAssetId` is now the new loop. Throws on a
233
371
  * failed render and on timeout; a timeout is not a failure, so re-poll or call again.
234
372
  */
235
- waitForLoop(avatarId: string, options?: {
236
- timeoutMs?: number;
237
- pollMs?: number;
238
- }): Promise<Avatar>;
373
+ waitForLoop(avatarId: string, options?: PollOptions): Promise<Avatar>;
239
374
  /**
240
375
  * Block until every clip in the library has stopped moving.
241
376
  *
@@ -247,10 +382,7 @@ declare class RealtimeAvatar {
247
382
  *
248
383
  * Throws only on timeout.
249
384
  */
250
- waitForClips(avatarId: string, options?: {
251
- timeoutMs?: number;
252
- pollMs?: number;
253
- }): Promise<ClipLibrary>;
385
+ waitForClips(avatarId: string, options?: PollOptions): Promise<ClipLibrary>;
254
386
  /** The avatar's clip library: every non-retired clip, plus revision, anchor and eligibility. */
255
387
  listClips(avatarId: string): Promise<ClipLibrary>;
256
388
  /** Hand us a URL and we stream it into storage. Prefer this for anything large. */
@@ -297,6 +429,39 @@ declare class RealtimeAvatar {
297
429
  getRecording(recordingId: string): Promise<RecordingArtifact>;
298
430
  /** Renewable playback access. Keep recordingId in storage; URLs expire at expiresAt. */
299
431
  getRecordingAccess(recordingId: string): Promise<RecordingAccessResponse>;
432
+ /**
433
+ * Render an MP4 of the avatar performing a script of `shots`, offline, with no live call.
434
+ * Everything in one shot happens at the same time; shots play one after another. Requires
435
+ * `renders:write`, which a new key does not carry unless you tick it.
436
+ *
437
+ * `202` is acceptance: the render is `queued`, and `waitForRender` follows it to the end.
438
+ * Every `clipId` must be a READY clip of this avatar or `"primary"`, or the request is refused
439
+ * with `422 render_clip_unavailable` before anything is charged. The retry carries the same
440
+ * `Idempotency-Key`, so a lost response never starts, or bills, a second render.
441
+ */
442
+ createRender(input: CreateRenderInput): Promise<Render>;
443
+ /** One render's status. Requires `renders:read`. */
444
+ getRender(renderId: string): Promise<Render>;
445
+ /** This workspace's renders, newest first, one page. Requires `renders:read`. */
446
+ listRenders(options?: ListRendersQuery): Promise<ListRendersResponse>;
447
+ /** Every render, following `nextCursor` for you. */
448
+ iterateRenders(options?: ListRendersQuery): AsyncGenerator<Render>;
449
+ /**
450
+ * A signed download URL for a ready render. It expires at `expiresAt` (an hour); keep the
451
+ * render id and ask again rather than storing the URL. `409 render_not_ready` before the
452
+ * render is ready, `410 render_gone` if the file is no longer stored.
453
+ */
454
+ getRenderAccess(renderId: string): Promise<RenderAccessResponse>;
455
+ /**
456
+ * Block until a render settles, and return it: `ready` with its `timeline`, or `failed` with
457
+ * `error.code`.
458
+ *
459
+ * A failed render is returned, not thrown, so its code stays a typed value you can branch on
460
+ * (`too_long` means shorten the script; `tts_failed` and `render_failed` are worth one retry).
461
+ * Throws only on timeout, which is not a failure: the render may still land, so poll again.
462
+ * The default timeout is 30 minutes, the platform's own budget for one render.
463
+ */
464
+ waitForRender(renderId: string, options?: PollOptions): Promise<Render>;
300
465
  /** Read one session's bounded LiveKit connection history. Requires `usage:read`. */
301
466
  getConnectionHistory(sessionId: string): Promise<ConnectionHistoryResponse>;
302
467
  creditBalance(): Promise<CreditBalance>;
@@ -341,8 +506,13 @@ declare class RealtimeAvatarWebhookError extends RealtimeAvatarError {
341
506
  * | `loop_pending` · `anchor_pending` | 409 | one is already in flight — wait, then retry |
342
507
  * | `revision_conflict` | 409 | someone declared first. Re-read `listClips`, re-decide, re-declare |
343
508
  * | `clip_render_limit` | 429 | a true rate limit; nothing was applied. Retry later |
344
- * | `concurrency_limit_reached` | 429 | active and starting sessions occupy the limit; release one or wait for pending starts before retrying |
509
+ * | `concurrency_limit_reached` | 429 | active and starting sessions occupy the limit; release one or wait for pending starts before retrying. From `createRender`: the workspace already has 4 renders queued or rendering; retry when one settles |
345
510
  * | `clip_screen_unavailable` | 503 | the prose screen could not run. Retry |
511
+ * | `render_clip_unavailable` | 422 | a shot's `clipId` is neither a ready clip of that avatar nor `"primary"`. `waitForClips`, then render |
512
+ * | `render_not_ready` | 409 | `getRenderAccess` before the render is `ready`. `waitForRender` first |
513
+ * | `render_too_long` | 400 | the shots are estimated to make a video longer than 180 seconds; nothing was held. Shorten the script |
514
+ * | `render_export_unavailable` | 503 | pre-rendered video is not switched on for this deployment; nothing was charged, and retrying will not help |
515
+ * | `render_start_failed` | 503 | the render was created but could not be started; retry (the SDK already has). That attempt stays in `listRenders` as a `failed` render, not charged |
346
516
  *
347
517
  * Pose validation does NOT appear here: a rejected upload is not an error response at all.
348
518
  * The declaration is accepted, and that clip settles `status: "failed"` with the verdict in
@@ -436,4 +606,4 @@ declare const fishTtsModelSchema: z.ZodUnion<readonly [z.ZodEnum<{
436
606
  type FishTtsModel = z.infer<typeof fishTtsModelSchema>;
437
607
  declare const DEFAULT_FISH_TTS_MODEL: "s2.1-pro";
438
608
 
439
- export { Asset, AssetKind, Avatar, AvatarSourceSwap, AvatarUpdate, CallMode, CallPolicy, ClipLibrary, ClipLibraryDeclaration, ClipLibraryUpdate, CreditBalance, DEFAULT_FISH_TTS_MODEL, EndCallOptions, type FishTtsModel, ListRecordingsQuery, ListRecordingsResponse, ListSessionsOptions, LoopRedirect, RealtimeAvatar, RealtimeAvatarError, RealtimeAvatarHttpError, type RealtimeAvatarOptions, RealtimeAvatarWebhookError, RecordingAccessResponse, RecordingArtifact, type StartCallOptions, StartCallResult, TranscriptPayload, UsageSession, UsageSessionPage, VoiceWebhookRequest, type WebhookVerificationErrorCode, clipLibraryDeclarationSchema, fishTtsModelSchema, verifyTranscript, verifyVoiceWebhook };
609
+ export { Asset, AssetKind, Avatar, AvatarSourceSwap, AvatarUpdate, CallMode, CallPolicy, ClipLibrary, ClipLibraryDeclaration, ClipLibraryUpdate, CreateRenderInput, CreditBalance, DEFAULT_FISH_TTS_MODEL, EndCallOptions, type FishTtsModel, ListRecordingsQuery, ListRecordingsResponse, type ListRendersQuery, type ListRendersResponse, ListSessionsOptions, LoopRedirect, RealtimeAvatar, RealtimeAvatarError, RealtimeAvatarHttpError, type RealtimeAvatarOptions, RealtimeAvatarWebhookError, RecordingAccessResponse, RecordingArtifact, type Render, type RenderAccessResponse, type RenderFailureCode, type RenderPlayback, type RenderStatus, type ShotTiming, type StartCallOptions, StartCallResult, TranscriptPayload, UsageSession, UsageSessionPage, VoiceWebhookRequest, type WebhookVerificationErrorCode, clipLibraryDeclarationSchema, fishTtsModelSchema, listRendersResponseSchema, renderAccessResponseSchema, renderSchema, verifyTranscript, verifyVoiceWebhook };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { DEFAULT_FISH_TTS_MODEL, RealtimeAvatar, RealtimeAvatarError, RealtimeAvatarHttpError, RealtimeAvatarWebhookError, clipLibraryDeclarationSchema, fishTtsModelSchema, isQueued, listRecordingsResponseSchema, recordingAccessResponseSchema, recordingArtifactSchema, recordingModeSchema, verifyTranscript, verifyVoiceWebhook } from './chunk-WXVBPMDN.js';
1
+ export { DEFAULT_FISH_TTS_MODEL, RealtimeAvatar, RealtimeAvatarError, RealtimeAvatarHttpError, RealtimeAvatarWebhookError, clipLibraryDeclarationSchema, fishTtsModelSchema, isQueued, listRecordingsResponseSchema, listRendersResponseSchema, recordingAccessResponseSchema, recordingArtifactSchema, recordingModeSchema, renderAccessResponseSchema, renderSchema, verifyTranscript, verifyVoiceWebhook } from './chunk-NKS5ZIWN.js';
2
2
  import './chunk-MCIXU6XP.js';
package/dist/nextjs.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as ProxyConfig } from './types-CgAEmIVE.js';
2
- import './types-Bv29uEAs.js';
1
+ import { P as ProxyConfig } from './types-su27kEw0.js';
2
+ import './types-BSSqsu_Z.js';
3
3
  import 'zod';
4
4
 
5
5
  /**