realtime-avatar 0.32.0 → 0.34.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 +56 -1
- package/dist/browser.d.ts +4 -89
- package/dist/browser.js +362 -1
- package/dist/chunk-6KQS7CTR.js +1 -0
- package/dist/{chunk-NKS5ZIWN.js → chunk-GPGNAQZV.js} +413 -170
- package/dist/{chunk-NDCZABOK.js → chunk-OVW4N5NH.js} +1 -13
- package/dist/express.d.ts +2 -2
- package/dist/express.js +2 -2
- package/dist/hono.d.ts +2 -2
- package/dist/hono.js +2 -2
- package/dist/index.d.ts +338 -3
- package/dist/index.js +2 -1
- package/dist/nextjs.d.ts +2 -2
- package/dist/nextjs.js +2 -2
- package/dist/{playout-delay-CtRZdtsj.d.ts → playout-delay-BzoM1BMN.d.ts} +135 -1
- package/dist/{proxy-client-BlaFxR6S.d.ts → proxy-client-CiTOjkg8.d.ts} +81 -3
- package/dist/react-native.d.ts +3 -3
- package/dist/react-native.js +624 -34
- package/dist/react.d.ts +12 -22
- package/dist/react.js +628 -35
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -1
- package/dist/tanstack-start.d.ts +2 -2
- package/dist/tanstack-start.js +2 -2
- package/dist/{types-su27kEw0.d.ts → types-Cdi7KWWj.d.ts} +1 -1
- package/dist/{types-BSSqsu_Z.d.ts → types-Cg_i1jhk.d.ts} +209 -18
- package/package.json +3 -3
|
@@ -347,52 +347,65 @@ var renderAccessResponseSchema = z.object({
|
|
|
347
347
|
url: z.string().url(),
|
|
348
348
|
expiresAt: z.string().datetime({ offset: true })
|
|
349
349
|
}).strict();
|
|
350
|
-
var schema02 = z.
|
|
351
|
-
var schema110 = z.
|
|
352
|
-
var schema27 = z.
|
|
353
|
-
var
|
|
350
|
+
var schema02 = z.string().min(1).max(200);
|
|
351
|
+
var schema110 = z.literal(1);
|
|
352
|
+
var schema27 = z.enum(["respond", "recovery", "initiative"]);
|
|
353
|
+
var schema32 = z.string().min(1).max(32);
|
|
354
|
+
var schema42 = z.union([schema27, schema32]);
|
|
355
|
+
var schema52 = z.enum(["draft", "accepted"]);
|
|
356
|
+
var schema62 = z.literal("external");
|
|
357
|
+
var schema72 = z.object({
|
|
358
|
+
"renderer": schema62
|
|
359
|
+
});
|
|
360
|
+
var schema82 = z.object({
|
|
361
|
+
"session_id": schema02,
|
|
362
|
+
"generation_id": schema02,
|
|
363
|
+
"version": schema110,
|
|
364
|
+
"purpose": schema42,
|
|
365
|
+
"admission": schema52,
|
|
366
|
+
"visible_character": schema72.optional()
|
|
367
|
+
});
|
|
368
|
+
var schema92 = z.string().min(1).max(200);
|
|
369
|
+
var schema102 = z.object({
|
|
370
|
+
"generation_id": schema02,
|
|
371
|
+
"utterance_id": schema92
|
|
372
|
+
});
|
|
373
|
+
var schema112 = z.literal("external_performance");
|
|
374
|
+
var schema122 = z.enum(["accepted", "dropped", "cancelled", "audio_released"]);
|
|
375
|
+
var schema132 = z.union([schema122, schema32]);
|
|
376
|
+
var schema142 = z.literal("unavailable");
|
|
377
|
+
var schema152 = z.literal("unavailable");
|
|
378
|
+
var schema162 = z.object({
|
|
379
|
+
"session_id": schema02,
|
|
380
|
+
"generation_id": schema02,
|
|
381
|
+
"kind": schema112,
|
|
382
|
+
"version": schema110,
|
|
383
|
+
"status": schema132,
|
|
384
|
+
"audible_checkpoint": schema142,
|
|
385
|
+
"audio_mapping": schema152
|
|
386
|
+
});
|
|
387
|
+
var externalTurnContextSchema = schema82;
|
|
388
|
+
var externalUtteranceSchema = schema102;
|
|
389
|
+
var externalPerformanceFrameSchema = schema162;
|
|
390
|
+
var schema03 = z.enum(["s1", "s2-pro", "s2.1-pro", "drama-3"]);
|
|
391
|
+
var schema111 = z.enum(["speech-1.6", "speech-1.5", "s1-mini"]);
|
|
392
|
+
var schema28 = z.union([schema03, schema111]);
|
|
393
|
+
var schema33 = z.enum(["whisper"]);
|
|
394
|
+
var schema43 = z.null();
|
|
395
|
+
var schema53 = z.union([schema33, schema43]);
|
|
396
|
+
var fishTtsModelSchema = schema28;
|
|
354
397
|
var DEFAULT_FISH_TTS_MODEL = "s2.1-pro";
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
var
|
|
358
|
-
var
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
function backoffMs(attempt, retryAfter) {
|
|
365
|
-
const server = retryAfter ? Number(retryAfter) * 1e3 : NaN;
|
|
366
|
-
if (Number.isFinite(server) && server >= 0) return Math.min(server, 2e4);
|
|
367
|
-
return Math.random() * Math.min(500 * 2 ** attempt, 8e3);
|
|
368
|
-
}
|
|
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
|
-
}
|
|
377
|
-
var PROXY_CLIENT_TIMEOUT_MS = 6e4;
|
|
378
|
-
var ROUTE_TIMEOUT_MS = PROXY_CLIENT_TIMEOUT_MS - 1e4;
|
|
379
|
-
function retryFits(attemptStartedAt, waitMs, deadline) {
|
|
380
|
-
const now = Date.now();
|
|
381
|
-
return now + waitMs + (now - attemptStartedAt) <= deadline;
|
|
382
|
-
}
|
|
383
|
-
function isTransient(cause) {
|
|
384
|
-
const name = cause?.name;
|
|
385
|
-
return name === "TimeoutError" || name === "TypeError" || name === "FetchError";
|
|
386
|
-
}
|
|
387
|
-
var schema03 = z.string().min(2).max(64);
|
|
388
|
-
var schema111 = z.array(schema03);
|
|
389
|
-
var schema28 = z.string().regex(new RegExp("\\S")).min(1).max(160);
|
|
390
|
-
var schema32 = z.array(schema28).max(1e3);
|
|
391
|
-
var schema42 = z.strictObject({
|
|
392
|
-
"language_codes": schema111.optional(),
|
|
393
|
-
"custom_vocabulary": schema32.optional()
|
|
398
|
+
var fishDeliverySchema = schema53;
|
|
399
|
+
var FISH_DELIVERY_MODELS = { "whisper": ["drama-3"] };
|
|
400
|
+
var schema04 = z.string().min(2).max(64);
|
|
401
|
+
var schema113 = z.array(schema04);
|
|
402
|
+
var schema29 = z.string().regex(new RegExp("\\S")).min(1).max(160);
|
|
403
|
+
var schema34 = z.array(schema29).max(1e3);
|
|
404
|
+
var schema44 = z.strictObject({
|
|
405
|
+
"language_codes": schema113.optional(),
|
|
406
|
+
"custom_vocabulary": schema34.optional()
|
|
394
407
|
});
|
|
395
|
-
var transcriptionWireSchema =
|
|
408
|
+
var transcriptionWireSchema = schema44;
|
|
396
409
|
var transcriptionOptionsSchema = z.object({
|
|
397
410
|
languageCodes: transcriptionWireSchema.shape.language_codes,
|
|
398
411
|
customVocabulary: transcriptionWireSchema.shape.custom_vocabulary
|
|
@@ -404,22 +417,66 @@ function transcriptionToWire(input) {
|
|
|
404
417
|
...options.customVocabulary !== void 0 ? { custom_vocabulary: options.customVocabulary } : {}
|
|
405
418
|
};
|
|
406
419
|
}
|
|
407
|
-
var
|
|
408
|
-
var contentPolicySchema =
|
|
409
|
-
var
|
|
410
|
-
var
|
|
411
|
-
var
|
|
412
|
-
var
|
|
413
|
-
var
|
|
414
|
-
var
|
|
415
|
-
"kind":
|
|
416
|
-
"code":
|
|
417
|
-
"message":
|
|
418
|
-
"status":
|
|
419
|
-
"fatal":
|
|
420
|
-
"request_id":
|
|
420
|
+
var schema05 = z.enum(["minor-sexual-content-v1", "safe-content-v1"]);
|
|
421
|
+
var contentPolicySchema = schema05;
|
|
422
|
+
var schema06 = z.literal("voice_error");
|
|
423
|
+
var schema114 = z.enum(["voice_webhook_url_not_allowed", "voice_webhook_unauthorized", "voice_webhook_unreachable", "voice_webhook_timeout", "voice_webhook_http_error", "voice_webhook_unsupported_audio", "voice_webhook_empty_audio"]);
|
|
424
|
+
var schema210 = z.string();
|
|
425
|
+
var schema35 = z.int().min(-9007199254740991).max(9007199254740991);
|
|
426
|
+
var schema45 = z.boolean();
|
|
427
|
+
var schema54 = z.object({
|
|
428
|
+
"kind": schema06,
|
|
429
|
+
"code": schema114,
|
|
430
|
+
"message": schema210,
|
|
431
|
+
"status": schema35.optional(),
|
|
432
|
+
"fatal": schema45,
|
|
433
|
+
"request_id": schema210.optional()
|
|
434
|
+
});
|
|
435
|
+
var voiceErrorFrameSchema = schema54;
|
|
436
|
+
var schema07 = z.string().min(1).max(200);
|
|
437
|
+
var schema115 = z.literal(1);
|
|
438
|
+
var schema211 = z.string().min(1).max(200);
|
|
439
|
+
var schema36 = z.int().min(1).max(9007199254740991);
|
|
440
|
+
var schema46 = z.literal(24e3);
|
|
441
|
+
var schema55 = z.literal("pcm_s16le");
|
|
442
|
+
z.object({
|
|
443
|
+
"session_id": schema07,
|
|
444
|
+
"generation_id": schema07,
|
|
445
|
+
"version": schema115,
|
|
446
|
+
"utterance_id": schema211,
|
|
447
|
+
"stream_id": schema07,
|
|
448
|
+
"epoch": schema36,
|
|
449
|
+
"sample_rate": schema46,
|
|
450
|
+
"channels": schema115,
|
|
451
|
+
"encoding": schema55
|
|
452
|
+
});
|
|
453
|
+
var schema73 = z.enum(["started", "progress", "finished", "cancelled"]);
|
|
454
|
+
var schema83 = z.int().min(0).max(144e4);
|
|
455
|
+
z.strictObject({
|
|
456
|
+
"session_id": schema07,
|
|
457
|
+
"generation_id": schema07,
|
|
458
|
+
"utterance_id": schema211,
|
|
459
|
+
"stream_id": schema07,
|
|
460
|
+
"epoch": schema36,
|
|
461
|
+
"status": schema73,
|
|
462
|
+
"samples": schema83
|
|
463
|
+
});
|
|
464
|
+
z.object({
|
|
465
|
+
"version": schema115,
|
|
466
|
+
"session_id": schema07,
|
|
467
|
+
"epoch": schema36
|
|
468
|
+
});
|
|
469
|
+
var schema116 = z.literal("external_llm_error");
|
|
470
|
+
var schema123 = z.enum(["external_llm_refused", "external_llm_failed"]);
|
|
471
|
+
var schema133 = z.string();
|
|
472
|
+
var schema143 = z.literal(true);
|
|
473
|
+
var schema153 = z.object({
|
|
474
|
+
"kind": schema116,
|
|
475
|
+
"code": schema123,
|
|
476
|
+
"message": schema133,
|
|
477
|
+
"fatal": schema143
|
|
421
478
|
});
|
|
422
|
-
var
|
|
479
|
+
var externalLlmErrorFrameSchema = schema153;
|
|
423
480
|
|
|
424
481
|
// ../client/src/wire.ts
|
|
425
482
|
var DEFAULT_AVATAR_ID = "maria";
|
|
@@ -488,8 +545,15 @@ var fishVoiceSpecSchema = z.object({
|
|
|
488
545
|
voice_id: z.string().min(1).max(120),
|
|
489
546
|
speed: z.number().min(0.5).max(2).nullable().optional(),
|
|
490
547
|
emotion: z.string().min(1).max(80).nullable().optional(),
|
|
491
|
-
language: z.string().min(2).max(16).nullable().optional()
|
|
492
|
-
|
|
548
|
+
language: z.string().min(2).max(16).nullable().optional(),
|
|
549
|
+
delivery: fishDeliverySchema.optional()
|
|
550
|
+
}).strict().superRefine((voice, ctx) => {
|
|
551
|
+
if (!voice.delivery) return;
|
|
552
|
+
const models = FISH_DELIVERY_MODELS[voice.delivery];
|
|
553
|
+
if (!models.includes(voice.model)) {
|
|
554
|
+
ctx.addIssue({ code: "custom", path: ["delivery"], message: `delivery "${voice.delivery}" needs model ${models.join(" | ")}` });
|
|
555
|
+
}
|
|
556
|
+
});
|
|
493
557
|
var voiceSpecSchema = z.discriminatedUnion("provider", [
|
|
494
558
|
cartesiaVoiceSpecSchema,
|
|
495
559
|
breezeVoiceSpecSchema,
|
|
@@ -717,7 +781,9 @@ z.discriminatedUnion("kind", [
|
|
|
717
781
|
endedFrameSchema,
|
|
718
782
|
behaviorStateFrameSchema,
|
|
719
783
|
clipAckFrameSchema,
|
|
720
|
-
voiceErrorFrameSchema2
|
|
784
|
+
voiceErrorFrameSchema2,
|
|
785
|
+
externalPerformanceFrameSchema,
|
|
786
|
+
externalLlmErrorFrameSchema
|
|
721
787
|
]);
|
|
722
788
|
var liveKitCapacitySnapshotSchema = z.object({
|
|
723
789
|
// Placement identity + per-worker session ceiling. These are always present on the
|
|
@@ -740,7 +806,7 @@ var liveKitCapacitySnapshotSchema = z.object({
|
|
|
740
806
|
recommended_retry_ms: z.number().int().nonnegative(),
|
|
741
807
|
load: z.number().min(0).max(1)
|
|
742
808
|
}).passthrough();
|
|
743
|
-
z.object({
|
|
809
|
+
var capacityBusyResponseSchema = z.object({
|
|
744
810
|
message: z.string().min(1),
|
|
745
811
|
capacity: liveKitCapacitySnapshotSchema,
|
|
746
812
|
queue_size: z.number().int().nonnegative(),
|
|
@@ -756,52 +822,151 @@ var liveKitSessionReleaseReasonSchema = z.enum([
|
|
|
756
822
|
"manual",
|
|
757
823
|
"idle_timeout"
|
|
758
824
|
]);
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
var
|
|
762
|
-
var
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
825
|
+
|
|
826
|
+
// ../http-client/src/retry.ts
|
|
827
|
+
var RETRYABLE_STATUS = /* @__PURE__ */ new Set([408, 500, 502, 503, 504]);
|
|
828
|
+
var MUTATING = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
|
|
829
|
+
function newIdempotencyKey() {
|
|
830
|
+
const c = globalThis.crypto;
|
|
831
|
+
if (c?.randomUUID) return c.randomUUID();
|
|
832
|
+
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
|
|
833
|
+
}
|
|
834
|
+
function backoffMs(attempt, retryAfter) {
|
|
835
|
+
const server = retryAfter ? Number(retryAfter) * 1e3 : NaN;
|
|
836
|
+
if (Number.isFinite(server) && server >= 0) return Math.min(server, 2e4);
|
|
837
|
+
return Math.random() * Math.min(500 * 2 ** attempt, 8e3);
|
|
838
|
+
}
|
|
839
|
+
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
840
|
+
function pollBudget(options, defaults) {
|
|
841
|
+
const finite = (value, fallback) => typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
842
|
+
return {
|
|
843
|
+
timeoutMs: finite(options.timeoutMs, defaults.timeoutMs),
|
|
844
|
+
pollMs: Math.max(1e3, finite(options.pollMs, defaults.pollMs))
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
var PROXY_CLIENT_TIMEOUT_MS = 6e4;
|
|
848
|
+
var ROUTE_TIMEOUT_MS = PROXY_CLIENT_TIMEOUT_MS - 1e4;
|
|
849
|
+
function retryFits(attemptStartedAt, waitMs, deadline) {
|
|
850
|
+
const now = Date.now();
|
|
851
|
+
return now + waitMs + (now - attemptStartedAt) <= deadline;
|
|
852
|
+
}
|
|
853
|
+
function isTransient(cause) {
|
|
854
|
+
const name = cause?.name;
|
|
855
|
+
return name === "TimeoutError" || name === "TypeError" || name === "FetchError";
|
|
856
|
+
}
|
|
857
|
+
var schema08 = z.string().min(1).max(160);
|
|
858
|
+
var schema117 = z.custom((value) => typeof value === "object" && value !== null && !Array.isArray(value));
|
|
859
|
+
var schema212 = z.enum(["cartesia", "fish"]);
|
|
860
|
+
var schema37 = z.string().min(1).max(240);
|
|
861
|
+
var schema47 = z.string().min(1).max(120);
|
|
862
|
+
var schema56 = z.number().min(0.5).max(2);
|
|
863
|
+
var schema64 = z.null();
|
|
864
|
+
var schema74 = z.union([schema56, schema64]);
|
|
865
|
+
var schema84 = z.string().min(1).max(80);
|
|
866
|
+
var schema94 = z.union([schema84, schema64]);
|
|
867
|
+
var schema104 = z.string().min(2).max(16);
|
|
868
|
+
var schema118 = z.union([schema104, schema64]);
|
|
869
|
+
var schema124 = z.strictObject({
|
|
870
|
+
"provider": schema212,
|
|
871
|
+
"voice_id": schema37,
|
|
872
|
+
"model": schema47.optional(),
|
|
873
|
+
"speed": schema74.optional(),
|
|
874
|
+
"emotion": schema94.optional(),
|
|
875
|
+
"language": schema118.optional()
|
|
772
876
|
});
|
|
773
|
-
var
|
|
774
|
-
var
|
|
775
|
-
var
|
|
776
|
-
var
|
|
777
|
-
var
|
|
778
|
-
var
|
|
779
|
-
var
|
|
780
|
-
var
|
|
781
|
-
var
|
|
782
|
-
var
|
|
783
|
-
var
|
|
784
|
-
var
|
|
785
|
-
var
|
|
786
|
-
"
|
|
787
|
-
"
|
|
788
|
-
|
|
877
|
+
var schema134 = z.string().min(8).max(80);
|
|
878
|
+
var schema144 = z.string();
|
|
879
|
+
var schema154 = z.enum(["video", "live2d"]);
|
|
880
|
+
var schema163 = z.enum(["image", "video"]);
|
|
881
|
+
var schema172 = z.enum(["realtime-avatar-live-v1", "realtime-avatar-video-v1"]);
|
|
882
|
+
var schema182 = z.union([schema134, schema64]);
|
|
883
|
+
var schema192 = z.enum(["draft", "preprocessing", "ready", "failed", "disabled", "deleted"]);
|
|
884
|
+
var schema202 = z.union([schema144, schema64]);
|
|
885
|
+
var schema213 = z.enum(["none", "queued", "generating", "ready", "failed"]);
|
|
886
|
+
var schema222 = z.enum(["local", "gemini", "openai"]);
|
|
887
|
+
var schema232 = z.string().max(200);
|
|
888
|
+
var schema242 = z.union([schema232, schema64]);
|
|
889
|
+
var schema252 = z.strictObject({
|
|
890
|
+
"provider": schema222,
|
|
891
|
+
"model": schema242.optional()
|
|
892
|
+
});
|
|
893
|
+
var schema262 = z.union([schema252, schema64]);
|
|
894
|
+
var schema272 = z.strictObject({
|
|
895
|
+
"id": schema134,
|
|
896
|
+
"tenantId": schema134,
|
|
897
|
+
"displayName": schema144,
|
|
898
|
+
"renderer": schema154,
|
|
899
|
+
"sourceKind": schema163,
|
|
900
|
+
"modelId": schema172,
|
|
901
|
+
"sourceAssetId": schema182,
|
|
902
|
+
"status": schema192,
|
|
903
|
+
"error": schema202,
|
|
904
|
+
"idleVideoStatus": schema213,
|
|
905
|
+
"defaultVoiceId": schema202,
|
|
906
|
+
"llm": schema262,
|
|
907
|
+
"createdAt": schema144,
|
|
908
|
+
"updatedAt": schema144
|
|
909
|
+
});
|
|
910
|
+
var createLive2dAvatarInputSchema = z.strictObject({
|
|
911
|
+
displayName: schema08,
|
|
912
|
+
settings: schema117.optional(),
|
|
913
|
+
metadata: schema117.optional(),
|
|
914
|
+
voice: schema124
|
|
915
|
+
});
|
|
916
|
+
var avatarResponseSchema = schema272;
|
|
917
|
+
var schema09 = z.url().regex(new RegExp("^https:\\/\\/")).max(500);
|
|
918
|
+
var schema119 = z.string().min(16).max(200);
|
|
919
|
+
var schema214 = z.string().min(1).max(200);
|
|
920
|
+
var schema38 = z.string().min(2).max(35);
|
|
921
|
+
var schema48 = z.literal([8e3, 16e3, 22050, 24e3, 44100, 48e3]);
|
|
922
|
+
var schema57 = z.int().min(1e3).max(15e3);
|
|
923
|
+
var schema65 = z.strictObject({
|
|
924
|
+
"url": schema09,
|
|
925
|
+
"secret": schema119,
|
|
926
|
+
"voice_id": schema214.optional(),
|
|
927
|
+
"language": schema38.optional(),
|
|
928
|
+
"sample_rate": schema48.optional(),
|
|
929
|
+
"timeout_ms": schema57.optional()
|
|
930
|
+
});
|
|
931
|
+
var schema75 = z.literal("voice.synthesize");
|
|
932
|
+
var schema85 = z.literal(1);
|
|
933
|
+
var schema95 = z.string().min(1).max(200);
|
|
934
|
+
var schema105 = z.string().min(1).max(200);
|
|
935
|
+
var schema1110 = z.object({
|
|
936
|
+
"generation_id": schema95,
|
|
937
|
+
"utterance_id": schema105
|
|
938
|
+
});
|
|
939
|
+
var schema125 = z.string().min(1).max(200);
|
|
940
|
+
var schema135 = z.string();
|
|
941
|
+
var schema145 = z.string().min(1).max(5e3);
|
|
942
|
+
var schema155 = z.string();
|
|
943
|
+
var schema164 = z.null();
|
|
944
|
+
var schema173 = z.union([schema155, schema164]);
|
|
945
|
+
var schema183 = z.string();
|
|
946
|
+
var schema193 = z.union([schema183, schema164]);
|
|
947
|
+
var schema203 = z.literal("pcm_s16le");
|
|
948
|
+
var schema215 = z.literal([8e3, 16e3, 22050, 24e3, 44100, 48e3]);
|
|
949
|
+
var schema223 = z.object({
|
|
950
|
+
"encoding": schema203,
|
|
951
|
+
"sample_rate": schema215,
|
|
952
|
+
"channels": schema85
|
|
789
953
|
});
|
|
790
|
-
var
|
|
791
|
-
var
|
|
792
|
-
var
|
|
793
|
-
var
|
|
794
|
-
"type":
|
|
795
|
-
"version":
|
|
796
|
-
"
|
|
797
|
-
"
|
|
798
|
-
"
|
|
799
|
-
"
|
|
800
|
-
"
|
|
801
|
-
"
|
|
802
|
-
"
|
|
954
|
+
var schema233 = z.string().min(1).max(64);
|
|
955
|
+
var schema243 = z.string().max(200);
|
|
956
|
+
var schema253 = z.record(schema233, schema243).refine((value) => Object.keys(value).length <= 16, { message: "Too many keys: at most 16" });
|
|
957
|
+
var schema263 = z.object({
|
|
958
|
+
"type": schema75,
|
|
959
|
+
"version": schema85,
|
|
960
|
+
"performance": schema1110.optional(),
|
|
961
|
+
"request_id": schema125,
|
|
962
|
+
"session_id": schema135,
|
|
963
|
+
"text": schema145,
|
|
964
|
+
"voice_id": schema173,
|
|
965
|
+
"language": schema193,
|
|
966
|
+
"output": schema223,
|
|
967
|
+
"client_metadata": schema253
|
|
803
968
|
});
|
|
804
|
-
var voiceWebhookWireSchema =
|
|
969
|
+
var voiceWebhookWireSchema = schema65;
|
|
805
970
|
var voiceWebhookOptionsSchema = z.strictObject({
|
|
806
971
|
url: voiceWebhookWireSchema.shape.url,
|
|
807
972
|
secret: voiceWebhookWireSchema.shape.secret,
|
|
@@ -821,88 +986,136 @@ function voiceWebhookToWire(input) {
|
|
|
821
986
|
...options.timeoutMs !== void 0 ? { timeout_ms: options.timeoutMs } : {}
|
|
822
987
|
};
|
|
823
988
|
}
|
|
824
|
-
var voiceWebhookRequestSchema =
|
|
825
|
-
var
|
|
826
|
-
var
|
|
827
|
-
var
|
|
828
|
-
var
|
|
829
|
-
var
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
989
|
+
var voiceWebhookRequestSchema = schema263;
|
|
990
|
+
var schema010 = z.url().regex(new RegExp("^\\s*[Hh][Tt][Tt][Pp][Ss]:\\/\\/")).max(500);
|
|
991
|
+
var schema120 = z.string().min(16).max(4096);
|
|
992
|
+
var schema216 = z.boolean();
|
|
993
|
+
var schema39 = z.literal("external");
|
|
994
|
+
var schema49 = z.strictObject({
|
|
995
|
+
"renderer": schema39
|
|
996
|
+
});
|
|
997
|
+
var schema58 = z.literal("v1");
|
|
998
|
+
var schema66 = z.literal("correlated_pcm_v1");
|
|
999
|
+
var schema76 = z.literal("v1");
|
|
1000
|
+
var schema86 = z.literal(true);
|
|
1001
|
+
var schema96 = z.object({
|
|
1002
|
+
"performance": schema76,
|
|
1003
|
+
"fail_closed": schema86
|
|
1004
|
+
});
|
|
1005
|
+
var schema106 = z.strictObject({
|
|
1006
|
+
"base_url": schema010,
|
|
1007
|
+
"token": schema120,
|
|
1008
|
+
"fail_closed": schema216.optional(),
|
|
1009
|
+
"visible_character": schema49.optional(),
|
|
1010
|
+
"performance": schema58.optional(),
|
|
1011
|
+
"audio_output": schema66.optional()
|
|
1012
|
+
}).superRefine((value, ctx) => {
|
|
1013
|
+
if (value["audio_output"] !== void 0) {
|
|
1014
|
+
const result = schema96.safeParse(value);
|
|
1015
|
+
if (!result.success) for (const issue of result.error.issues) ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1018
|
+
var externalLlmWireSchema = schema106;
|
|
1019
|
+
var externalLlmOptionsSchema = z.strictObject({
|
|
1020
|
+
baseUrl: externalLlmWireSchema.shape.base_url,
|
|
1021
|
+
token: externalLlmWireSchema.shape.token,
|
|
1022
|
+
failClosed: externalLlmWireSchema.shape.fail_closed,
|
|
1023
|
+
visibleCharacter: externalLlmWireSchema.shape.visible_character,
|
|
1024
|
+
performance: externalLlmWireSchema.shape.performance,
|
|
1025
|
+
audioOutput: externalLlmWireSchema.shape.audio_output
|
|
1026
|
+
});
|
|
1027
|
+
function externalLlmToWire(input) {
|
|
1028
|
+
const options = externalLlmOptionsSchema.parse(input);
|
|
1029
|
+
return externalLlmWireSchema.parse({
|
|
1030
|
+
base_url: options.baseUrl,
|
|
1031
|
+
token: options.token,
|
|
1032
|
+
...options.failClosed !== void 0 ? { fail_closed: options.failClosed } : {},
|
|
1033
|
+
...options.visibleCharacter !== void 0 ? { visible_character: options.visibleCharacter } : {},
|
|
1034
|
+
...options.performance !== void 0 ? { performance: options.performance } : {},
|
|
1035
|
+
...options.audioOutput !== void 0 ? { audio_output: options.audioOutput } : {}
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
var schema011 = z.string().min(8).max(80);
|
|
1039
|
+
var schema121 = z.enum(["eou", "llm", "tts", "decision", "hold", "e2e"]);
|
|
1040
|
+
var schema217 = z.literal("interrupt_stop");
|
|
1041
|
+
var schema310 = z.union([schema121, schema217]);
|
|
1042
|
+
var schema410 = z.int().max(9007199254740991).gt(0);
|
|
1043
|
+
var schema59 = z.number().min(0);
|
|
1044
|
+
var schema67 = z.strictObject({
|
|
1045
|
+
"count": schema410,
|
|
1046
|
+
"max": schema59,
|
|
1047
|
+
"p50": schema59,
|
|
1048
|
+
"p90": schema59
|
|
836
1049
|
});
|
|
837
|
-
var
|
|
838
|
-
var
|
|
839
|
-
var
|
|
840
|
-
var
|
|
841
|
-
var
|
|
842
|
-
var
|
|
843
|
-
var
|
|
844
|
-
var
|
|
845
|
-
"first_at":
|
|
846
|
-
"last_at":
|
|
847
|
-
"lines":
|
|
1050
|
+
var schema77 = z.partialRecord(schema310, schema67);
|
|
1051
|
+
var schema87 = z.literal("available");
|
|
1052
|
+
var schema97 = z.literal("dialogue");
|
|
1053
|
+
var schema107 = z.string().regex(new RegExp("^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d))|(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?)$"));
|
|
1054
|
+
var schema1111 = z.null();
|
|
1055
|
+
var schema126 = z.union([schema107, schema1111]);
|
|
1056
|
+
var schema136 = z.int().min(0).max(9007199254740991);
|
|
1057
|
+
var schema146 = z.strictObject({
|
|
1058
|
+
"first_at": schema126,
|
|
1059
|
+
"last_at": schema126,
|
|
1060
|
+
"lines": schema136
|
|
848
1061
|
});
|
|
849
|
-
var
|
|
850
|
-
"latency_ms":
|
|
851
|
-
"status":
|
|
852
|
-
"sourceRole":
|
|
853
|
-
"coverage":
|
|
1062
|
+
var schema156 = z.strictObject({
|
|
1063
|
+
"latency_ms": schema77,
|
|
1064
|
+
"status": schema87,
|
|
1065
|
+
"sourceRole": schema97,
|
|
1066
|
+
"coverage": schema146
|
|
854
1067
|
});
|
|
855
|
-
var
|
|
856
|
-
var
|
|
857
|
-
var
|
|
858
|
-
"status":
|
|
859
|
-
"reason":
|
|
1068
|
+
var schema165 = z.literal("unavailable");
|
|
1069
|
+
var schema174 = z.enum(["not_closed", "unconfigured", "missing", "invalid", "oversized", "unscorable", "no_measured_latency", "timeout", "aborted", "storage_unavailable"]);
|
|
1070
|
+
var schema184 = z.strictObject({
|
|
1071
|
+
"status": schema165,
|
|
1072
|
+
"reason": schema174
|
|
860
1073
|
});
|
|
861
|
-
var
|
|
862
|
-
var
|
|
863
|
-
var
|
|
864
|
-
var
|
|
865
|
-
var
|
|
866
|
-
var
|
|
867
|
-
var
|
|
868
|
-
var
|
|
869
|
-
var
|
|
870
|
-
var schema282 = z.union([
|
|
871
|
-
var schema292 = z.union([
|
|
1074
|
+
var schema194 = z.union([schema156, schema184]);
|
|
1075
|
+
var schema204 = z.string().min(1).max(200);
|
|
1076
|
+
var schema218 = z.union([schema204, schema1111]);
|
|
1077
|
+
var schema224 = z.string().regex(new RegExp("^[0-9a-f]{40}$"));
|
|
1078
|
+
var schema234 = z.union([schema224, schema1111]);
|
|
1079
|
+
var schema244 = z.literal("cloudflare-worker-version");
|
|
1080
|
+
var schema254 = z.literal("authenticated-worker-heartbeat");
|
|
1081
|
+
var schema264 = z.union([schema254, schema1111]);
|
|
1082
|
+
var schema273 = z.string().min(1).max(160);
|
|
1083
|
+
var schema282 = z.union([schema273, schema1111]);
|
|
1084
|
+
var schema292 = z.union([schema136, schema1111]);
|
|
872
1085
|
var schema30 = z.iso.datetime({ offset: true }).regex(new RegExp("^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"));
|
|
873
|
-
var schema31 = z.union([schema30,
|
|
1086
|
+
var schema31 = z.union([schema30, schema1111]);
|
|
874
1087
|
var schema322 = z.strictObject({
|
|
875
|
-
"deploymentSource":
|
|
876
|
-
"workerSource":
|
|
1088
|
+
"deploymentSource": schema244,
|
|
1089
|
+
"workerSource": schema264,
|
|
877
1090
|
"workerId": schema282,
|
|
878
1091
|
"podStartedAtMs": schema292,
|
|
879
1092
|
"workerObservedAt": schema31
|
|
880
1093
|
});
|
|
881
1094
|
var schema332 = z.strictObject({
|
|
882
|
-
"deploymentId":
|
|
883
|
-
"workerRevision":
|
|
1095
|
+
"deploymentId": schema218,
|
|
1096
|
+
"workerRevision": schema234,
|
|
884
1097
|
"provenance": schema322
|
|
885
1098
|
});
|
|
886
1099
|
var schema342 = z.string();
|
|
887
|
-
var schema352 = z.union([schema342,
|
|
888
|
-
var
|
|
889
|
-
var
|
|
890
|
-
var
|
|
891
|
-
var
|
|
892
|
-
"sessionId":
|
|
893
|
-
"speechDiagnostics":
|
|
1100
|
+
var schema352 = z.union([schema342, schema1111]);
|
|
1101
|
+
var schema362 = z.enum(["reserved", "started", "released", "failed"]);
|
|
1102
|
+
var schema372 = z.union([schema59, schema1111]);
|
|
1103
|
+
var schema382 = z.custom((value) => typeof value === "object" && value !== null && !Array.isArray(value));
|
|
1104
|
+
var schema392 = z.strictObject({
|
|
1105
|
+
"sessionId": schema011,
|
|
1106
|
+
"speechDiagnostics": schema194.optional(),
|
|
894
1107
|
"releaseIdentity": schema332.optional(),
|
|
895
1108
|
"avatarId": schema352,
|
|
896
1109
|
"avatarName": schema352,
|
|
897
|
-
"status":
|
|
1110
|
+
"status": schema362,
|
|
898
1111
|
"startedAt": schema352,
|
|
899
1112
|
"endedAt": schema352,
|
|
900
|
-
"activeSeconds":
|
|
1113
|
+
"activeSeconds": schema372,
|
|
901
1114
|
"billedCreditMicros": schema292,
|
|
902
|
-
"metadata":
|
|
1115
|
+
"metadata": schema382,
|
|
903
1116
|
"createdAt": schema342
|
|
904
1117
|
});
|
|
905
|
-
var schema40 = z.array(
|
|
1118
|
+
var schema40 = z.array(schema392);
|
|
906
1119
|
var schema41 = z.iso.datetime({ offset: true }).regex(new RegExp("^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"));
|
|
907
1120
|
var schema422 = z.strictObject({
|
|
908
1121
|
"data": schema40,
|
|
@@ -919,7 +1132,7 @@ function toSessionsPage(page) {
|
|
|
919
1132
|
// ../http-client/src/client.ts
|
|
920
1133
|
var DEFAULT_BASE_URL = "https://realtimeavatar.ai/api/v1";
|
|
921
1134
|
var RENDER_MISMATCH = "Render response did not match the SDK contract";
|
|
922
|
-
var SDK_VERSION = "0.
|
|
1135
|
+
var SDK_VERSION = "0.34.0";
|
|
923
1136
|
var RealtimeAvatar = class {
|
|
924
1137
|
#apiKey;
|
|
925
1138
|
#baseUrl;
|
|
@@ -974,9 +1187,9 @@ var RealtimeAvatar = class {
|
|
|
974
1187
|
if (options.contentPolicy !== void 0) body.content_policy = contentPolicySchema.parse(options.contentPolicy);
|
|
975
1188
|
if (options.clientTools) body.capabilities = ["client_tools"];
|
|
976
1189
|
if (options.llm !== void 0) {
|
|
977
|
-
const { backend, model,
|
|
1190
|
+
const { backend, model, ...endpoint } = options.llm;
|
|
978
1191
|
body.llm = model === void 0 ? { backend } : { backend, model };
|
|
979
|
-
body.external_llm =
|
|
1192
|
+
body.external_llm = externalLlmToWire(endpoint);
|
|
980
1193
|
}
|
|
981
1194
|
if (options.transcript !== void 0) {
|
|
982
1195
|
body.transcript_webhook = { url: options.transcript.url, secret: options.transcript.secret };
|
|
@@ -1121,6 +1334,24 @@ var RealtimeAvatar = class {
|
|
|
1121
1334
|
metadata: input.metadata
|
|
1122
1335
|
});
|
|
1123
1336
|
}
|
|
1337
|
+
/**
|
|
1338
|
+
* Register an app-owned Live2D rig for voice sessions. No assets, motion generation or
|
|
1339
|
+
* automatic voice casting: supply an explicit provider and voice_id, then mint with mode voice.
|
|
1340
|
+
*/
|
|
1341
|
+
async createLive2dAvatar(input) {
|
|
1342
|
+
const { voice, ...identity } = createLive2dAvatarInputSchema.parse(input);
|
|
1343
|
+
const body = {
|
|
1344
|
+
...identity,
|
|
1345
|
+
renderer: "live2d",
|
|
1346
|
+
sourceKind: "image",
|
|
1347
|
+
voice: { voice }
|
|
1348
|
+
};
|
|
1349
|
+
return this.#contract(
|
|
1350
|
+
await this.#request("POST", "/avatars", { json: body }),
|
|
1351
|
+
avatarResponseSchema,
|
|
1352
|
+
"Avatar response did not match the SDK contract"
|
|
1353
|
+
);
|
|
1354
|
+
}
|
|
1124
1355
|
async createAvatar(input) {
|
|
1125
1356
|
const body = {
|
|
1126
1357
|
displayName: input.displayName,
|
|
@@ -1558,6 +1789,7 @@ function toAvatar(raw) {
|
|
|
1558
1789
|
return {
|
|
1559
1790
|
id: String(a.id),
|
|
1560
1791
|
displayName: String(a.displayName ?? ""),
|
|
1792
|
+
renderer: avatarResponseSchema.shape.renderer.default("video").parse(a.renderer),
|
|
1561
1793
|
sourceKind: a.sourceKind === "video" ? "video" : "image",
|
|
1562
1794
|
status: a.status ?? "draft",
|
|
1563
1795
|
defaultVoiceId: a.defaultVoiceId ? String(a.defaultVoiceId) : null,
|
|
@@ -1658,5 +1890,16 @@ function timingSafeEqual(a, b) {
|
|
|
1658
1890
|
function isQueued(result) {
|
|
1659
1891
|
return "queued" in result;
|
|
1660
1892
|
}
|
|
1893
|
+
var proxyConnectRequestSchema = z.object({
|
|
1894
|
+
avatarId: z.string().min(1),
|
|
1895
|
+
mode: sessionModeSchema.optional()
|
|
1896
|
+
});
|
|
1897
|
+
var proxyEndRequestSchema = z.object({
|
|
1898
|
+
session_id: z.string().min(1).optional(),
|
|
1899
|
+
queue_ticket_id: z.string().min(1).optional(),
|
|
1900
|
+
reason: liveKitSessionReleaseReasonSchema.optional().catch(void 0)
|
|
1901
|
+
}).strict().refine((body) => body.session_id !== void 0 || body.queue_ticket_id !== void 0, {
|
|
1902
|
+
message: "session_id or queue_ticket_id is required"
|
|
1903
|
+
});
|
|
1661
1904
|
|
|
1662
|
-
export { DEFAULT_FISH_TTS_MODEL, ROUTE_TIMEOUT_MS, RealtimeAvatar, RealtimeAvatarError, RealtimeAvatarHttpError, RealtimeAvatarWebhookError, clipLibraryDeclarationSchema, fishTtsModelSchema, isQueued, listRecordingsResponseSchema, listRendersResponseSchema,
|
|
1905
|
+
export { DEFAULT_FISH_TTS_MODEL, FISH_DELIVERY_MODELS, ROUTE_TIMEOUT_MS, RealtimeAvatar, RealtimeAvatarError, RealtimeAvatarHttpError, RealtimeAvatarWebhookError, capacityBusyResponseSchema, clipLibraryDeclarationSchema, externalTurnContextSchema, externalUtteranceSchema, fishTtsModelSchema, isQueued, listRecordingsResponseSchema, listRendersResponseSchema, liveKitSessionGrantSchema, proxyConnectRequestSchema, proxyEndRequestSchema, recordingAccessResponseSchema, recordingArtifactSchema, recordingModeSchema, renderAccessResponseSchema, renderSchema, verifyTranscript, verifyVoiceWebhook };
|