@livekit/agents-plugin-cartesia 0.0.0-next-20260624041820

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.
Files changed (59) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +24 -0
  3. package/dist/index.cjs +36 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +3 -0
  6. package/dist/index.d.ts +3 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +14 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/models.cjs +35 -0
  11. package/dist/models.cjs.map +1 -0
  12. package/dist/models.d.cts +27 -0
  13. package/dist/models.d.ts +27 -0
  14. package/dist/models.d.ts.map +1 -0
  15. package/dist/models.js +9 -0
  16. package/dist/models.js.map +1 -0
  17. package/dist/stt.cjs +422 -0
  18. package/dist/stt.cjs.map +1 -0
  19. package/dist/stt.d.cts +53 -0
  20. package/dist/stt.d.ts +53 -0
  21. package/dist/stt.d.ts.map +1 -0
  22. package/dist/stt.js +407 -0
  23. package/dist/stt.js.map +1 -0
  24. package/dist/stt.test.cjs +17 -0
  25. package/dist/stt.test.cjs.map +1 -0
  26. package/dist/stt.test.d.cts +2 -0
  27. package/dist/stt.test.d.ts +2 -0
  28. package/dist/stt.test.d.ts.map +1 -0
  29. package/dist/stt.test.js +16 -0
  30. package/dist/stt.test.js.map +1 -0
  31. package/dist/tts.cjs +596 -0
  32. package/dist/tts.cjs.map +1 -0
  33. package/dist/tts.d.cts +56 -0
  34. package/dist/tts.d.ts +56 -0
  35. package/dist/tts.d.ts.map +1 -0
  36. package/dist/tts.js +596 -0
  37. package/dist/tts.js.map +1 -0
  38. package/dist/tts.test.cjs +17 -0
  39. package/dist/tts.test.cjs.map +1 -0
  40. package/dist/tts.test.d.cts +2 -0
  41. package/dist/tts.test.d.ts +2 -0
  42. package/dist/tts.test.d.ts.map +1 -0
  43. package/dist/tts.test.js +16 -0
  44. package/dist/tts.test.js.map +1 -0
  45. package/dist/types.cjs +124 -0
  46. package/dist/types.cjs.map +1 -0
  47. package/dist/types.d.cts +133 -0
  48. package/dist/types.d.ts +133 -0
  49. package/dist/types.d.ts.map +1 -0
  50. package/dist/types.js +87 -0
  51. package/dist/types.js.map +1 -0
  52. package/package.json +55 -0
  53. package/src/index.ts +19 -0
  54. package/src/models.ts +77 -0
  55. package/src/stt.test.ts +19 -0
  56. package/src/stt.ts +653 -0
  57. package/src/tts.test.ts +19 -0
  58. package/src/tts.ts +799 -0
  59. package/src/types.ts +116 -0
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var import_agents_plugin_openai = require("@livekit/agents-plugin-openai");
3
+ var import_agents_plugins_test = require("@livekit/agents-plugins-test");
4
+ var import_vitest = require("vitest");
5
+ var import_tts = require("./tts.cjs");
6
+ const hasCartesiaConfig = Boolean(process.env.CARTESIA_API_KEY && process.env.OPENAI_API_KEY);
7
+ if (hasCartesiaConfig) {
8
+ (0, import_vitest.describe)("Cartesia", async () => {
9
+ await (0, import_agents_plugins_test.tts)(new import_tts.TTS(), new import_agents_plugin_openai.STT());
10
+ });
11
+ } else {
12
+ (0, import_vitest.describe)("Cartesia", () => {
13
+ import_vitest.it.skip("requires CARTESIA_API_KEY and OPENAI_API_KEY", () => {
14
+ });
15
+ });
16
+ }
17
+ //# sourceMappingURL=tts.test.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/tts.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { STT } from '@livekit/agents-plugin-openai';\nimport { tts } from '@livekit/agents-plugins-test';\nimport { describe, it } from 'vitest';\nimport { TTS } from './tts.js';\n\nconst hasCartesiaConfig = Boolean(process.env.CARTESIA_API_KEY && process.env.OPENAI_API_KEY);\n\nif (hasCartesiaConfig) {\n describe('Cartesia', async () => {\n await tts(new TTS(), new STT());\n });\n} else {\n describe('Cartesia', () => {\n it.skip('requires CARTESIA_API_KEY and OPENAI_API_KEY', () => {});\n });\n}\n"],"mappings":";AAGA,kCAAoB;AACpB,iCAAoB;AACpB,oBAA6B;AAC7B,iBAAoB;AAEpB,MAAM,oBAAoB,QAAQ,QAAQ,IAAI,oBAAoB,QAAQ,IAAI,cAAc;AAE5F,IAAI,mBAAmB;AACrB,8BAAS,YAAY,YAAY;AAC/B,cAAM,gCAAI,IAAI,eAAI,GAAG,IAAI,gCAAI,CAAC;AAAA,EAChC,CAAC;AACH,OAAO;AACL,8BAAS,YAAY,MAAM;AACzB,qBAAG,KAAK,gDAAgD,MAAM;AAAA,IAAC,CAAC;AAAA,EAClE,CAAC;AACH;","names":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tts.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tts.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tts.test.d.ts","sourceRoot":"","sources":["../src/tts.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import { STT } from "@livekit/agents-plugin-openai";
2
+ import { tts } from "@livekit/agents-plugins-test";
3
+ import { describe, it } from "vitest";
4
+ import { TTS } from "./tts.js";
5
+ const hasCartesiaConfig = Boolean(process.env.CARTESIA_API_KEY && process.env.OPENAI_API_KEY);
6
+ if (hasCartesiaConfig) {
7
+ describe("Cartesia", async () => {
8
+ await tts(new TTS(), new STT());
9
+ });
10
+ } else {
11
+ describe("Cartesia", () => {
12
+ it.skip("requires CARTESIA_API_KEY and OPENAI_API_KEY", () => {
13
+ });
14
+ });
15
+ }
16
+ //# sourceMappingURL=tts.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/tts.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { STT } from '@livekit/agents-plugin-openai';\nimport { tts } from '@livekit/agents-plugins-test';\nimport { describe, it } from 'vitest';\nimport { TTS } from './tts.js';\n\nconst hasCartesiaConfig = Boolean(process.env.CARTESIA_API_KEY && process.env.OPENAI_API_KEY);\n\nif (hasCartesiaConfig) {\n describe('Cartesia', async () => {\n await tts(new TTS(), new STT());\n });\n} else {\n describe('Cartesia', () => {\n it.skip('requires CARTESIA_API_KEY and OPENAI_API_KEY', () => {});\n });\n}\n"],"mappings":"AAGA,SAAS,WAAW;AACpB,SAAS,WAAW;AACpB,SAAS,UAAU,UAAU;AAC7B,SAAS,WAAW;AAEpB,MAAM,oBAAoB,QAAQ,QAAQ,IAAI,oBAAoB,QAAQ,IAAI,cAAc;AAE5F,IAAI,mBAAmB;AACrB,WAAS,YAAY,YAAY;AAC/B,UAAM,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,CAAC;AAAA,EAChC,CAAC;AACH,OAAO;AACL,WAAS,YAAY,MAAM;AACzB,OAAG,KAAK,gDAAgD,MAAM;AAAA,IAAC,CAAC;AAAA,EAClE,CAAC;AACH;","names":[]}
package/dist/types.cjs ADDED
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var types_exports = {};
20
+ __export(types_exports, {
21
+ cartesiaChunkMessageSchema: () => cartesiaChunkMessageSchema,
22
+ cartesiaDoneMessageSchema: () => cartesiaDoneMessageSchema,
23
+ cartesiaErrorMessageSchema: () => cartesiaErrorMessageSchema,
24
+ cartesiaFlushDoneMessageSchema: () => cartesiaFlushDoneMessageSchema,
25
+ cartesiaMessageSchema: () => cartesiaMessageSchema,
26
+ cartesiaServerMessageSchema: () => cartesiaServerMessageSchema,
27
+ cartesiaTimestampsMessageSchema: () => cartesiaTimestampsMessageSchema,
28
+ cartesiaWordTimestampsSchema: () => cartesiaWordTimestampsSchema,
29
+ hasWordTimestamps: () => hasWordTimestamps,
30
+ isChunkMessage: () => isChunkMessage,
31
+ isDoneMessage: () => isDoneMessage,
32
+ isErrorMessage: () => isErrorMessage,
33
+ isFlushDoneMessage: () => isFlushDoneMessage,
34
+ isTimestampsMessage: () => isTimestampsMessage
35
+ });
36
+ module.exports = __toCommonJS(types_exports);
37
+ var import_zod = require("zod");
38
+ const cartesiaWordTimestampsSchema = import_zod.z.object({
39
+ words: import_zod.z.array(import_zod.z.string()),
40
+ start: import_zod.z.array(import_zod.z.number()),
41
+ end: import_zod.z.array(import_zod.z.number())
42
+ });
43
+ const cartesiaChunkMessageSchema = import_zod.z.object({
44
+ type: import_zod.z.literal("chunk"),
45
+ data: import_zod.z.string(),
46
+ done: import_zod.z.boolean(),
47
+ status_code: import_zod.z.number(),
48
+ step_time: import_zod.z.number(),
49
+ context_id: import_zod.z.string()
50
+ });
51
+ const cartesiaTimestampsMessageSchema = import_zod.z.object({
52
+ type: import_zod.z.literal("timestamps"),
53
+ done: import_zod.z.boolean(),
54
+ status_code: import_zod.z.number(),
55
+ context_id: import_zod.z.string(),
56
+ word_timestamps: cartesiaWordTimestampsSchema
57
+ });
58
+ const cartesiaDoneMessageSchema = import_zod.z.object({
59
+ type: import_zod.z.literal("done"),
60
+ done: import_zod.z.boolean(),
61
+ status_code: import_zod.z.number(),
62
+ context_id: import_zod.z.string()
63
+ });
64
+ const cartesiaFlushDoneMessageSchema = import_zod.z.object({
65
+ type: import_zod.z.literal("flush_done"),
66
+ done: import_zod.z.boolean(),
67
+ flush_done: import_zod.z.boolean(),
68
+ flush_id: import_zod.z.number(),
69
+ status_code: import_zod.z.number(),
70
+ context_id: import_zod.z.string()
71
+ });
72
+ const cartesiaErrorMessageSchema = import_zod.z.object({
73
+ type: import_zod.z.string(),
74
+ done: import_zod.z.boolean(),
75
+ error: import_zod.z.string(),
76
+ status_code: import_zod.z.number(),
77
+ context_id: import_zod.z.string()
78
+ });
79
+ const cartesiaServerMessageSchema = import_zod.z.discriminatedUnion("type", [
80
+ cartesiaChunkMessageSchema,
81
+ cartesiaTimestampsMessageSchema,
82
+ cartesiaDoneMessageSchema,
83
+ cartesiaFlushDoneMessageSchema
84
+ ]);
85
+ const cartesiaMessageSchema = import_zod.z.union([
86
+ cartesiaServerMessageSchema,
87
+ cartesiaErrorMessageSchema
88
+ ]);
89
+ function isChunkMessage(msg) {
90
+ return "type" in msg && msg.type === "chunk";
91
+ }
92
+ function isTimestampsMessage(msg) {
93
+ return "type" in msg && msg.type === "timestamps";
94
+ }
95
+ function isDoneMessage(msg) {
96
+ return "type" in msg && msg.type === "done";
97
+ }
98
+ function isFlushDoneMessage(msg) {
99
+ return "type" in msg && msg.type === "flush_done";
100
+ }
101
+ function isErrorMessage(msg) {
102
+ return "error" in msg && typeof msg.error === "string";
103
+ }
104
+ function hasWordTimestamps(msg) {
105
+ return isTimestampsMessage(msg);
106
+ }
107
+ // Annotate the CommonJS export names for ESM import in node:
108
+ 0 && (module.exports = {
109
+ cartesiaChunkMessageSchema,
110
+ cartesiaDoneMessageSchema,
111
+ cartesiaErrorMessageSchema,
112
+ cartesiaFlushDoneMessageSchema,
113
+ cartesiaMessageSchema,
114
+ cartesiaServerMessageSchema,
115
+ cartesiaTimestampsMessageSchema,
116
+ cartesiaWordTimestampsSchema,
117
+ hasWordTimestamps,
118
+ isChunkMessage,
119
+ isDoneMessage,
120
+ isErrorMessage,
121
+ isFlushDoneMessage,
122
+ isTimestampsMessage
123
+ });
124
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { z } from 'zod';\n\n// ============================================================================\n// Cartesia WebSocket API Schemas\n// Ref: https://docs.cartesia.ai/api-reference/tts/websocket\n// ============================================================================\n\n/** Word timestamps schema - contains timing info for each word */\nexport const cartesiaWordTimestampsSchema = z.object({\n words: z.array(z.string()),\n start: z.array(z.number()),\n end: z.array(z.number()),\n});\n\n/** Audio chunk message - type: \"chunk\" with base64-encoded audio data */\nexport const cartesiaChunkMessageSchema = z.object({\n type: z.literal('chunk'),\n data: z.string(),\n done: z.boolean(),\n status_code: z.number(),\n step_time: z.number(),\n context_id: z.string(),\n});\n\n/** Word timestamps message - type: \"timestamps\" with word timing data */\nexport const cartesiaTimestampsMessageSchema = z.object({\n type: z.literal('timestamps'),\n done: z.boolean(),\n status_code: z.number(),\n context_id: z.string(),\n word_timestamps: cartesiaWordTimestampsSchema,\n});\n\n/** Done message - type: \"done\" indicates completion */\nexport const cartesiaDoneMessageSchema = z.object({\n type: z.literal('done'),\n done: z.boolean(),\n status_code: z.number(),\n context_id: z.string(),\n});\n\n/** Flush done message - type: \"flush_done\" indicates flush completion */\nexport const cartesiaFlushDoneMessageSchema = z.object({\n type: z.literal('flush_done'),\n done: z.boolean(),\n flush_done: z.boolean(),\n flush_id: z.number(),\n status_code: z.number(),\n context_id: z.string(),\n});\n\n/** Error message - has error field */\nexport const cartesiaErrorMessageSchema = z.object({\n type: z.string(),\n done: z.boolean(),\n error: z.string(),\n status_code: z.number(),\n context_id: z.string(),\n});\n\n/** Union of all possible Cartesia server messages using discriminated union on 'type' */\nexport const cartesiaServerMessageSchema = z.discriminatedUnion('type', [\n cartesiaChunkMessageSchema,\n cartesiaTimestampsMessageSchema,\n cartesiaDoneMessageSchema,\n cartesiaFlushDoneMessageSchema,\n]);\n\n// Fallback schema for error messages (can't be in discriminated union due to dynamic type)\nexport const cartesiaMessageSchema = z.union([\n cartesiaServerMessageSchema,\n cartesiaErrorMessageSchema,\n]);\n\n// ============================================================================\n// Type exports from Zod schemas\n// ============================================================================\n\nexport type CartesiaWordTimestamps = z.infer<typeof cartesiaWordTimestampsSchema>;\nexport type CartesiaChunkMessage = z.infer<typeof cartesiaChunkMessageSchema>;\nexport type CartesiaTimestampsMessage = z.infer<typeof cartesiaTimestampsMessageSchema>;\nexport type CartesiaDoneMessage = z.infer<typeof cartesiaDoneMessageSchema>;\nexport type CartesiaFlushDoneMessage = z.infer<typeof cartesiaFlushDoneMessageSchema>;\nexport type CartesiaErrorMessage = z.infer<typeof cartesiaErrorMessageSchema>;\nexport type CartesiaServerMessage = z.infer<typeof cartesiaMessageSchema>;\n\n// ============================================================================\n// Helper type guards for message discrimination\n// ============================================================================\n\nexport function isChunkMessage(msg: CartesiaServerMessage): msg is CartesiaChunkMessage {\n return 'type' in msg && msg.type === 'chunk';\n}\n\nexport function isTimestampsMessage(msg: CartesiaServerMessage): msg is CartesiaTimestampsMessage {\n return 'type' in msg && msg.type === 'timestamps';\n}\n\nexport function isDoneMessage(msg: CartesiaServerMessage): msg is CartesiaDoneMessage {\n return 'type' in msg && msg.type === 'done';\n}\n\nexport function isFlushDoneMessage(msg: CartesiaServerMessage): msg is CartesiaFlushDoneMessage {\n return 'type' in msg && msg.type === 'flush_done';\n}\n\nexport function isErrorMessage(msg: CartesiaServerMessage): msg is CartesiaErrorMessage {\n return 'error' in msg && typeof msg.error === 'string';\n}\n\nexport function hasWordTimestamps(msg: CartesiaServerMessage): msg is CartesiaTimestampsMessage {\n return isTimestampsMessage(msg);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAkB;AAQX,MAAM,+BAA+B,aAAE,OAAO;AAAA,EACnD,OAAO,aAAE,MAAM,aAAE,OAAO,CAAC;AAAA,EACzB,OAAO,aAAE,MAAM,aAAE,OAAO,CAAC;AAAA,EACzB,KAAK,aAAE,MAAM,aAAE,OAAO,CAAC;AACzB,CAAC;AAGM,MAAM,6BAA6B,aAAE,OAAO;AAAA,EACjD,MAAM,aAAE,QAAQ,OAAO;AAAA,EACvB,MAAM,aAAE,OAAO;AAAA,EACf,MAAM,aAAE,QAAQ;AAAA,EAChB,aAAa,aAAE,OAAO;AAAA,EACtB,WAAW,aAAE,OAAO;AAAA,EACpB,YAAY,aAAE,OAAO;AACvB,CAAC;AAGM,MAAM,kCAAkC,aAAE,OAAO;AAAA,EACtD,MAAM,aAAE,QAAQ,YAAY;AAAA,EAC5B,MAAM,aAAE,QAAQ;AAAA,EAChB,aAAa,aAAE,OAAO;AAAA,EACtB,YAAY,aAAE,OAAO;AAAA,EACrB,iBAAiB;AACnB,CAAC;AAGM,MAAM,4BAA4B,aAAE,OAAO;AAAA,EAChD,MAAM,aAAE,QAAQ,MAAM;AAAA,EACtB,MAAM,aAAE,QAAQ;AAAA,EAChB,aAAa,aAAE,OAAO;AAAA,EACtB,YAAY,aAAE,OAAO;AACvB,CAAC;AAGM,MAAM,iCAAiC,aAAE,OAAO;AAAA,EACrD,MAAM,aAAE,QAAQ,YAAY;AAAA,EAC5B,MAAM,aAAE,QAAQ;AAAA,EAChB,YAAY,aAAE,QAAQ;AAAA,EACtB,UAAU,aAAE,OAAO;AAAA,EACnB,aAAa,aAAE,OAAO;AAAA,EACtB,YAAY,aAAE,OAAO;AACvB,CAAC;AAGM,MAAM,6BAA6B,aAAE,OAAO;AAAA,EACjD,MAAM,aAAE,OAAO;AAAA,EACf,MAAM,aAAE,QAAQ;AAAA,EAChB,OAAO,aAAE,OAAO;AAAA,EAChB,aAAa,aAAE,OAAO;AAAA,EACtB,YAAY,aAAE,OAAO;AACvB,CAAC;AAGM,MAAM,8BAA8B,aAAE,mBAAmB,QAAQ;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,MAAM,wBAAwB,aAAE,MAAM;AAAA,EAC3C;AAAA,EACA;AACF,CAAC;AAkBM,SAAS,eAAe,KAAyD;AACtF,SAAO,UAAU,OAAO,IAAI,SAAS;AACvC;AAEO,SAAS,oBAAoB,KAA8D;AAChG,SAAO,UAAU,OAAO,IAAI,SAAS;AACvC;AAEO,SAAS,cAAc,KAAwD;AACpF,SAAO,UAAU,OAAO,IAAI,SAAS;AACvC;AAEO,SAAS,mBAAmB,KAA6D;AAC9F,SAAO,UAAU,OAAO,IAAI,SAAS;AACvC;AAEO,SAAS,eAAe,KAAyD;AACtF,SAAO,WAAW,OAAO,OAAO,IAAI,UAAU;AAChD;AAEO,SAAS,kBAAkB,KAA8D;AAC9F,SAAO,oBAAoB,GAAG;AAChC;","names":[]}
@@ -0,0 +1,133 @@
1
+ import { z } from 'zod';
2
+ /** Word timestamps schema - contains timing info for each word */
3
+ export declare const cartesiaWordTimestampsSchema: z.ZodObject<{
4
+ words: z.ZodArray<z.ZodString>;
5
+ start: z.ZodArray<z.ZodNumber>;
6
+ end: z.ZodArray<z.ZodNumber>;
7
+ }, z.core.$strip>;
8
+ /** Audio chunk message - type: "chunk" with base64-encoded audio data */
9
+ export declare const cartesiaChunkMessageSchema: z.ZodObject<{
10
+ type: z.ZodLiteral<"chunk">;
11
+ data: z.ZodString;
12
+ done: z.ZodBoolean;
13
+ status_code: z.ZodNumber;
14
+ step_time: z.ZodNumber;
15
+ context_id: z.ZodString;
16
+ }, z.core.$strip>;
17
+ /** Word timestamps message - type: "timestamps" with word timing data */
18
+ export declare const cartesiaTimestampsMessageSchema: z.ZodObject<{
19
+ type: z.ZodLiteral<"timestamps">;
20
+ done: z.ZodBoolean;
21
+ status_code: z.ZodNumber;
22
+ context_id: z.ZodString;
23
+ word_timestamps: z.ZodObject<{
24
+ words: z.ZodArray<z.ZodString>;
25
+ start: z.ZodArray<z.ZodNumber>;
26
+ end: z.ZodArray<z.ZodNumber>;
27
+ }, z.core.$strip>;
28
+ }, z.core.$strip>;
29
+ /** Done message - type: "done" indicates completion */
30
+ export declare const cartesiaDoneMessageSchema: z.ZodObject<{
31
+ type: z.ZodLiteral<"done">;
32
+ done: z.ZodBoolean;
33
+ status_code: z.ZodNumber;
34
+ context_id: z.ZodString;
35
+ }, z.core.$strip>;
36
+ /** Flush done message - type: "flush_done" indicates flush completion */
37
+ export declare const cartesiaFlushDoneMessageSchema: z.ZodObject<{
38
+ type: z.ZodLiteral<"flush_done">;
39
+ done: z.ZodBoolean;
40
+ flush_done: z.ZodBoolean;
41
+ flush_id: z.ZodNumber;
42
+ status_code: z.ZodNumber;
43
+ context_id: z.ZodString;
44
+ }, z.core.$strip>;
45
+ /** Error message - has error field */
46
+ export declare const cartesiaErrorMessageSchema: z.ZodObject<{
47
+ type: z.ZodString;
48
+ done: z.ZodBoolean;
49
+ error: z.ZodString;
50
+ status_code: z.ZodNumber;
51
+ context_id: z.ZodString;
52
+ }, z.core.$strip>;
53
+ /** Union of all possible Cartesia server messages using discriminated union on 'type' */
54
+ export declare const cartesiaServerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
55
+ type: z.ZodLiteral<"chunk">;
56
+ data: z.ZodString;
57
+ done: z.ZodBoolean;
58
+ status_code: z.ZodNumber;
59
+ step_time: z.ZodNumber;
60
+ context_id: z.ZodString;
61
+ }, z.core.$strip>, z.ZodObject<{
62
+ type: z.ZodLiteral<"timestamps">;
63
+ done: z.ZodBoolean;
64
+ status_code: z.ZodNumber;
65
+ context_id: z.ZodString;
66
+ word_timestamps: z.ZodObject<{
67
+ words: z.ZodArray<z.ZodString>;
68
+ start: z.ZodArray<z.ZodNumber>;
69
+ end: z.ZodArray<z.ZodNumber>;
70
+ }, z.core.$strip>;
71
+ }, z.core.$strip>, z.ZodObject<{
72
+ type: z.ZodLiteral<"done">;
73
+ done: z.ZodBoolean;
74
+ status_code: z.ZodNumber;
75
+ context_id: z.ZodString;
76
+ }, z.core.$strip>, z.ZodObject<{
77
+ type: z.ZodLiteral<"flush_done">;
78
+ done: z.ZodBoolean;
79
+ flush_done: z.ZodBoolean;
80
+ flush_id: z.ZodNumber;
81
+ status_code: z.ZodNumber;
82
+ context_id: z.ZodString;
83
+ }, z.core.$strip>], "type">;
84
+ export declare const cartesiaMessageSchema: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
85
+ type: z.ZodLiteral<"chunk">;
86
+ data: z.ZodString;
87
+ done: z.ZodBoolean;
88
+ status_code: z.ZodNumber;
89
+ step_time: z.ZodNumber;
90
+ context_id: z.ZodString;
91
+ }, z.core.$strip>, z.ZodObject<{
92
+ type: z.ZodLiteral<"timestamps">;
93
+ done: z.ZodBoolean;
94
+ status_code: z.ZodNumber;
95
+ context_id: z.ZodString;
96
+ word_timestamps: z.ZodObject<{
97
+ words: z.ZodArray<z.ZodString>;
98
+ start: z.ZodArray<z.ZodNumber>;
99
+ end: z.ZodArray<z.ZodNumber>;
100
+ }, z.core.$strip>;
101
+ }, z.core.$strip>, z.ZodObject<{
102
+ type: z.ZodLiteral<"done">;
103
+ done: z.ZodBoolean;
104
+ status_code: z.ZodNumber;
105
+ context_id: z.ZodString;
106
+ }, z.core.$strip>, z.ZodObject<{
107
+ type: z.ZodLiteral<"flush_done">;
108
+ done: z.ZodBoolean;
109
+ flush_done: z.ZodBoolean;
110
+ flush_id: z.ZodNumber;
111
+ status_code: z.ZodNumber;
112
+ context_id: z.ZodString;
113
+ }, z.core.$strip>], "type">, z.ZodObject<{
114
+ type: z.ZodString;
115
+ done: z.ZodBoolean;
116
+ error: z.ZodString;
117
+ status_code: z.ZodNumber;
118
+ context_id: z.ZodString;
119
+ }, z.core.$strip>]>;
120
+ export type CartesiaWordTimestamps = z.infer<typeof cartesiaWordTimestampsSchema>;
121
+ export type CartesiaChunkMessage = z.infer<typeof cartesiaChunkMessageSchema>;
122
+ export type CartesiaTimestampsMessage = z.infer<typeof cartesiaTimestampsMessageSchema>;
123
+ export type CartesiaDoneMessage = z.infer<typeof cartesiaDoneMessageSchema>;
124
+ export type CartesiaFlushDoneMessage = z.infer<typeof cartesiaFlushDoneMessageSchema>;
125
+ export type CartesiaErrorMessage = z.infer<typeof cartesiaErrorMessageSchema>;
126
+ export type CartesiaServerMessage = z.infer<typeof cartesiaMessageSchema>;
127
+ export declare function isChunkMessage(msg: CartesiaServerMessage): msg is CartesiaChunkMessage;
128
+ export declare function isTimestampsMessage(msg: CartesiaServerMessage): msg is CartesiaTimestampsMessage;
129
+ export declare function isDoneMessage(msg: CartesiaServerMessage): msg is CartesiaDoneMessage;
130
+ export declare function isFlushDoneMessage(msg: CartesiaServerMessage): msg is CartesiaFlushDoneMessage;
131
+ export declare function isErrorMessage(msg: CartesiaServerMessage): msg is CartesiaErrorMessage;
132
+ export declare function hasWordTimestamps(msg: CartesiaServerMessage): msg is CartesiaTimestampsMessage;
133
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,133 @@
1
+ import { z } from 'zod';
2
+ /** Word timestamps schema - contains timing info for each word */
3
+ export declare const cartesiaWordTimestampsSchema: z.ZodObject<{
4
+ words: z.ZodArray<z.ZodString>;
5
+ start: z.ZodArray<z.ZodNumber>;
6
+ end: z.ZodArray<z.ZodNumber>;
7
+ }, z.core.$strip>;
8
+ /** Audio chunk message - type: "chunk" with base64-encoded audio data */
9
+ export declare const cartesiaChunkMessageSchema: z.ZodObject<{
10
+ type: z.ZodLiteral<"chunk">;
11
+ data: z.ZodString;
12
+ done: z.ZodBoolean;
13
+ status_code: z.ZodNumber;
14
+ step_time: z.ZodNumber;
15
+ context_id: z.ZodString;
16
+ }, z.core.$strip>;
17
+ /** Word timestamps message - type: "timestamps" with word timing data */
18
+ export declare const cartesiaTimestampsMessageSchema: z.ZodObject<{
19
+ type: z.ZodLiteral<"timestamps">;
20
+ done: z.ZodBoolean;
21
+ status_code: z.ZodNumber;
22
+ context_id: z.ZodString;
23
+ word_timestamps: z.ZodObject<{
24
+ words: z.ZodArray<z.ZodString>;
25
+ start: z.ZodArray<z.ZodNumber>;
26
+ end: z.ZodArray<z.ZodNumber>;
27
+ }, z.core.$strip>;
28
+ }, z.core.$strip>;
29
+ /** Done message - type: "done" indicates completion */
30
+ export declare const cartesiaDoneMessageSchema: z.ZodObject<{
31
+ type: z.ZodLiteral<"done">;
32
+ done: z.ZodBoolean;
33
+ status_code: z.ZodNumber;
34
+ context_id: z.ZodString;
35
+ }, z.core.$strip>;
36
+ /** Flush done message - type: "flush_done" indicates flush completion */
37
+ export declare const cartesiaFlushDoneMessageSchema: z.ZodObject<{
38
+ type: z.ZodLiteral<"flush_done">;
39
+ done: z.ZodBoolean;
40
+ flush_done: z.ZodBoolean;
41
+ flush_id: z.ZodNumber;
42
+ status_code: z.ZodNumber;
43
+ context_id: z.ZodString;
44
+ }, z.core.$strip>;
45
+ /** Error message - has error field */
46
+ export declare const cartesiaErrorMessageSchema: z.ZodObject<{
47
+ type: z.ZodString;
48
+ done: z.ZodBoolean;
49
+ error: z.ZodString;
50
+ status_code: z.ZodNumber;
51
+ context_id: z.ZodString;
52
+ }, z.core.$strip>;
53
+ /** Union of all possible Cartesia server messages using discriminated union on 'type' */
54
+ export declare const cartesiaServerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
55
+ type: z.ZodLiteral<"chunk">;
56
+ data: z.ZodString;
57
+ done: z.ZodBoolean;
58
+ status_code: z.ZodNumber;
59
+ step_time: z.ZodNumber;
60
+ context_id: z.ZodString;
61
+ }, z.core.$strip>, z.ZodObject<{
62
+ type: z.ZodLiteral<"timestamps">;
63
+ done: z.ZodBoolean;
64
+ status_code: z.ZodNumber;
65
+ context_id: z.ZodString;
66
+ word_timestamps: z.ZodObject<{
67
+ words: z.ZodArray<z.ZodString>;
68
+ start: z.ZodArray<z.ZodNumber>;
69
+ end: z.ZodArray<z.ZodNumber>;
70
+ }, z.core.$strip>;
71
+ }, z.core.$strip>, z.ZodObject<{
72
+ type: z.ZodLiteral<"done">;
73
+ done: z.ZodBoolean;
74
+ status_code: z.ZodNumber;
75
+ context_id: z.ZodString;
76
+ }, z.core.$strip>, z.ZodObject<{
77
+ type: z.ZodLiteral<"flush_done">;
78
+ done: z.ZodBoolean;
79
+ flush_done: z.ZodBoolean;
80
+ flush_id: z.ZodNumber;
81
+ status_code: z.ZodNumber;
82
+ context_id: z.ZodString;
83
+ }, z.core.$strip>], "type">;
84
+ export declare const cartesiaMessageSchema: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
85
+ type: z.ZodLiteral<"chunk">;
86
+ data: z.ZodString;
87
+ done: z.ZodBoolean;
88
+ status_code: z.ZodNumber;
89
+ step_time: z.ZodNumber;
90
+ context_id: z.ZodString;
91
+ }, z.core.$strip>, z.ZodObject<{
92
+ type: z.ZodLiteral<"timestamps">;
93
+ done: z.ZodBoolean;
94
+ status_code: z.ZodNumber;
95
+ context_id: z.ZodString;
96
+ word_timestamps: z.ZodObject<{
97
+ words: z.ZodArray<z.ZodString>;
98
+ start: z.ZodArray<z.ZodNumber>;
99
+ end: z.ZodArray<z.ZodNumber>;
100
+ }, z.core.$strip>;
101
+ }, z.core.$strip>, z.ZodObject<{
102
+ type: z.ZodLiteral<"done">;
103
+ done: z.ZodBoolean;
104
+ status_code: z.ZodNumber;
105
+ context_id: z.ZodString;
106
+ }, z.core.$strip>, z.ZodObject<{
107
+ type: z.ZodLiteral<"flush_done">;
108
+ done: z.ZodBoolean;
109
+ flush_done: z.ZodBoolean;
110
+ flush_id: z.ZodNumber;
111
+ status_code: z.ZodNumber;
112
+ context_id: z.ZodString;
113
+ }, z.core.$strip>], "type">, z.ZodObject<{
114
+ type: z.ZodString;
115
+ done: z.ZodBoolean;
116
+ error: z.ZodString;
117
+ status_code: z.ZodNumber;
118
+ context_id: z.ZodString;
119
+ }, z.core.$strip>]>;
120
+ export type CartesiaWordTimestamps = z.infer<typeof cartesiaWordTimestampsSchema>;
121
+ export type CartesiaChunkMessage = z.infer<typeof cartesiaChunkMessageSchema>;
122
+ export type CartesiaTimestampsMessage = z.infer<typeof cartesiaTimestampsMessageSchema>;
123
+ export type CartesiaDoneMessage = z.infer<typeof cartesiaDoneMessageSchema>;
124
+ export type CartesiaFlushDoneMessage = z.infer<typeof cartesiaFlushDoneMessageSchema>;
125
+ export type CartesiaErrorMessage = z.infer<typeof cartesiaErrorMessageSchema>;
126
+ export type CartesiaServerMessage = z.infer<typeof cartesiaMessageSchema>;
127
+ export declare function isChunkMessage(msg: CartesiaServerMessage): msg is CartesiaChunkMessage;
128
+ export declare function isTimestampsMessage(msg: CartesiaServerMessage): msg is CartesiaTimestampsMessage;
129
+ export declare function isDoneMessage(msg: CartesiaServerMessage): msg is CartesiaDoneMessage;
130
+ export declare function isFlushDoneMessage(msg: CartesiaServerMessage): msg is CartesiaFlushDoneMessage;
131
+ export declare function isErrorMessage(msg: CartesiaServerMessage): msg is CartesiaErrorMessage;
132
+ export declare function hasWordTimestamps(msg: CartesiaServerMessage): msg is CartesiaTimestampsMessage;
133
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,kEAAkE;AAClE,eAAO,MAAM,4BAA4B;;;;iBAIvC,CAAC;AAEH,yEAAyE;AACzE,eAAO,MAAM,0BAA0B;;;;;;;iBAOrC,CAAC;AAEH,yEAAyE;AACzE,eAAO,MAAM,+BAA+B;;;;;;;;;;iBAM1C,CAAC;AAEH,uDAAuD;AACvD,eAAO,MAAM,yBAAyB;;;;;iBAKpC,CAAC;AAEH,yEAAyE;AACzE,eAAO,MAAM,8BAA8B;;;;;;;iBAOzC,CAAC;AAEH,sCAAsC;AACtC,eAAO,MAAM,0BAA0B;;;;;;iBAMrC,CAAC;AAEH,yFAAyF;AACzF,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAKtC,CAAC;AAGH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAGhC,CAAC;AAMH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAClF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AACxF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC5E,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AACtF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAM1E,wBAAgB,cAAc,CAAC,GAAG,EAAE,qBAAqB,GAAG,GAAG,IAAI,oBAAoB,CAEtF;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,qBAAqB,GAAG,GAAG,IAAI,yBAAyB,CAEhG;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,qBAAqB,GAAG,GAAG,IAAI,mBAAmB,CAEpF;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,qBAAqB,GAAG,GAAG,IAAI,wBAAwB,CAE9F;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,qBAAqB,GAAG,GAAG,IAAI,oBAAoB,CAEtF;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,qBAAqB,GAAG,GAAG,IAAI,yBAAyB,CAE9F"}
package/dist/types.js ADDED
@@ -0,0 +1,87 @@
1
+ import { z } from "zod";
2
+ const cartesiaWordTimestampsSchema = z.object({
3
+ words: z.array(z.string()),
4
+ start: z.array(z.number()),
5
+ end: z.array(z.number())
6
+ });
7
+ const cartesiaChunkMessageSchema = z.object({
8
+ type: z.literal("chunk"),
9
+ data: z.string(),
10
+ done: z.boolean(),
11
+ status_code: z.number(),
12
+ step_time: z.number(),
13
+ context_id: z.string()
14
+ });
15
+ const cartesiaTimestampsMessageSchema = z.object({
16
+ type: z.literal("timestamps"),
17
+ done: z.boolean(),
18
+ status_code: z.number(),
19
+ context_id: z.string(),
20
+ word_timestamps: cartesiaWordTimestampsSchema
21
+ });
22
+ const cartesiaDoneMessageSchema = z.object({
23
+ type: z.literal("done"),
24
+ done: z.boolean(),
25
+ status_code: z.number(),
26
+ context_id: z.string()
27
+ });
28
+ const cartesiaFlushDoneMessageSchema = z.object({
29
+ type: z.literal("flush_done"),
30
+ done: z.boolean(),
31
+ flush_done: z.boolean(),
32
+ flush_id: z.number(),
33
+ status_code: z.number(),
34
+ context_id: z.string()
35
+ });
36
+ const cartesiaErrorMessageSchema = z.object({
37
+ type: z.string(),
38
+ done: z.boolean(),
39
+ error: z.string(),
40
+ status_code: z.number(),
41
+ context_id: z.string()
42
+ });
43
+ const cartesiaServerMessageSchema = z.discriminatedUnion("type", [
44
+ cartesiaChunkMessageSchema,
45
+ cartesiaTimestampsMessageSchema,
46
+ cartesiaDoneMessageSchema,
47
+ cartesiaFlushDoneMessageSchema
48
+ ]);
49
+ const cartesiaMessageSchema = z.union([
50
+ cartesiaServerMessageSchema,
51
+ cartesiaErrorMessageSchema
52
+ ]);
53
+ function isChunkMessage(msg) {
54
+ return "type" in msg && msg.type === "chunk";
55
+ }
56
+ function isTimestampsMessage(msg) {
57
+ return "type" in msg && msg.type === "timestamps";
58
+ }
59
+ function isDoneMessage(msg) {
60
+ return "type" in msg && msg.type === "done";
61
+ }
62
+ function isFlushDoneMessage(msg) {
63
+ return "type" in msg && msg.type === "flush_done";
64
+ }
65
+ function isErrorMessage(msg) {
66
+ return "error" in msg && typeof msg.error === "string";
67
+ }
68
+ function hasWordTimestamps(msg) {
69
+ return isTimestampsMessage(msg);
70
+ }
71
+ export {
72
+ cartesiaChunkMessageSchema,
73
+ cartesiaDoneMessageSchema,
74
+ cartesiaErrorMessageSchema,
75
+ cartesiaFlushDoneMessageSchema,
76
+ cartesiaMessageSchema,
77
+ cartesiaServerMessageSchema,
78
+ cartesiaTimestampsMessageSchema,
79
+ cartesiaWordTimestampsSchema,
80
+ hasWordTimestamps,
81
+ isChunkMessage,
82
+ isDoneMessage,
83
+ isErrorMessage,
84
+ isFlushDoneMessage,
85
+ isTimestampsMessage
86
+ };
87
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { z } from 'zod';\n\n// ============================================================================\n// Cartesia WebSocket API Schemas\n// Ref: https://docs.cartesia.ai/api-reference/tts/websocket\n// ============================================================================\n\n/** Word timestamps schema - contains timing info for each word */\nexport const cartesiaWordTimestampsSchema = z.object({\n words: z.array(z.string()),\n start: z.array(z.number()),\n end: z.array(z.number()),\n});\n\n/** Audio chunk message - type: \"chunk\" with base64-encoded audio data */\nexport const cartesiaChunkMessageSchema = z.object({\n type: z.literal('chunk'),\n data: z.string(),\n done: z.boolean(),\n status_code: z.number(),\n step_time: z.number(),\n context_id: z.string(),\n});\n\n/** Word timestamps message - type: \"timestamps\" with word timing data */\nexport const cartesiaTimestampsMessageSchema = z.object({\n type: z.literal('timestamps'),\n done: z.boolean(),\n status_code: z.number(),\n context_id: z.string(),\n word_timestamps: cartesiaWordTimestampsSchema,\n});\n\n/** Done message - type: \"done\" indicates completion */\nexport const cartesiaDoneMessageSchema = z.object({\n type: z.literal('done'),\n done: z.boolean(),\n status_code: z.number(),\n context_id: z.string(),\n});\n\n/** Flush done message - type: \"flush_done\" indicates flush completion */\nexport const cartesiaFlushDoneMessageSchema = z.object({\n type: z.literal('flush_done'),\n done: z.boolean(),\n flush_done: z.boolean(),\n flush_id: z.number(),\n status_code: z.number(),\n context_id: z.string(),\n});\n\n/** Error message - has error field */\nexport const cartesiaErrorMessageSchema = z.object({\n type: z.string(),\n done: z.boolean(),\n error: z.string(),\n status_code: z.number(),\n context_id: z.string(),\n});\n\n/** Union of all possible Cartesia server messages using discriminated union on 'type' */\nexport const cartesiaServerMessageSchema = z.discriminatedUnion('type', [\n cartesiaChunkMessageSchema,\n cartesiaTimestampsMessageSchema,\n cartesiaDoneMessageSchema,\n cartesiaFlushDoneMessageSchema,\n]);\n\n// Fallback schema for error messages (can't be in discriminated union due to dynamic type)\nexport const cartesiaMessageSchema = z.union([\n cartesiaServerMessageSchema,\n cartesiaErrorMessageSchema,\n]);\n\n// ============================================================================\n// Type exports from Zod schemas\n// ============================================================================\n\nexport type CartesiaWordTimestamps = z.infer<typeof cartesiaWordTimestampsSchema>;\nexport type CartesiaChunkMessage = z.infer<typeof cartesiaChunkMessageSchema>;\nexport type CartesiaTimestampsMessage = z.infer<typeof cartesiaTimestampsMessageSchema>;\nexport type CartesiaDoneMessage = z.infer<typeof cartesiaDoneMessageSchema>;\nexport type CartesiaFlushDoneMessage = z.infer<typeof cartesiaFlushDoneMessageSchema>;\nexport type CartesiaErrorMessage = z.infer<typeof cartesiaErrorMessageSchema>;\nexport type CartesiaServerMessage = z.infer<typeof cartesiaMessageSchema>;\n\n// ============================================================================\n// Helper type guards for message discrimination\n// ============================================================================\n\nexport function isChunkMessage(msg: CartesiaServerMessage): msg is CartesiaChunkMessage {\n return 'type' in msg && msg.type === 'chunk';\n}\n\nexport function isTimestampsMessage(msg: CartesiaServerMessage): msg is CartesiaTimestampsMessage {\n return 'type' in msg && msg.type === 'timestamps';\n}\n\nexport function isDoneMessage(msg: CartesiaServerMessage): msg is CartesiaDoneMessage {\n return 'type' in msg && msg.type === 'done';\n}\n\nexport function isFlushDoneMessage(msg: CartesiaServerMessage): msg is CartesiaFlushDoneMessage {\n return 'type' in msg && msg.type === 'flush_done';\n}\n\nexport function isErrorMessage(msg: CartesiaServerMessage): msg is CartesiaErrorMessage {\n return 'error' in msg && typeof msg.error === 'string';\n}\n\nexport function hasWordTimestamps(msg: CartesiaServerMessage): msg is CartesiaTimestampsMessage {\n return isTimestampsMessage(msg);\n}\n"],"mappings":"AAGA,SAAS,SAAS;AAQX,MAAM,+BAA+B,EAAE,OAAO;AAAA,EACnD,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,EACzB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,EACzB,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC;AACzB,CAAC;AAGM,MAAM,6BAA6B,EAAE,OAAO;AAAA,EACjD,MAAM,EAAE,QAAQ,OAAO;AAAA,EACvB,MAAM,EAAE,OAAO;AAAA,EACf,MAAM,EAAE,QAAQ;AAAA,EAChB,aAAa,EAAE,OAAO;AAAA,EACtB,WAAW,EAAE,OAAO;AAAA,EACpB,YAAY,EAAE,OAAO;AACvB,CAAC;AAGM,MAAM,kCAAkC,EAAE,OAAO;AAAA,EACtD,MAAM,EAAE,QAAQ,YAAY;AAAA,EAC5B,MAAM,EAAE,QAAQ;AAAA,EAChB,aAAa,EAAE,OAAO;AAAA,EACtB,YAAY,EAAE,OAAO;AAAA,EACrB,iBAAiB;AACnB,CAAC;AAGM,MAAM,4BAA4B,EAAE,OAAO;AAAA,EAChD,MAAM,EAAE,QAAQ,MAAM;AAAA,EACtB,MAAM,EAAE,QAAQ;AAAA,EAChB,aAAa,EAAE,OAAO;AAAA,EACtB,YAAY,EAAE,OAAO;AACvB,CAAC;AAGM,MAAM,iCAAiC,EAAE,OAAO;AAAA,EACrD,MAAM,EAAE,QAAQ,YAAY;AAAA,EAC5B,MAAM,EAAE,QAAQ;AAAA,EAChB,YAAY,EAAE,QAAQ;AAAA,EACtB,UAAU,EAAE,OAAO;AAAA,EACnB,aAAa,EAAE,OAAO;AAAA,EACtB,YAAY,EAAE,OAAO;AACvB,CAAC;AAGM,MAAM,6BAA6B,EAAE,OAAO;AAAA,EACjD,MAAM,EAAE,OAAO;AAAA,EACf,MAAM,EAAE,QAAQ;AAAA,EAChB,OAAO,EAAE,OAAO;AAAA,EAChB,aAAa,EAAE,OAAO;AAAA,EACtB,YAAY,EAAE,OAAO;AACvB,CAAC;AAGM,MAAM,8BAA8B,EAAE,mBAAmB,QAAQ;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,MAAM,wBAAwB,EAAE,MAAM;AAAA,EAC3C;AAAA,EACA;AACF,CAAC;AAkBM,SAAS,eAAe,KAAyD;AACtF,SAAO,UAAU,OAAO,IAAI,SAAS;AACvC;AAEO,SAAS,oBAAoB,KAA8D;AAChG,SAAO,UAAU,OAAO,IAAI,SAAS;AACvC;AAEO,SAAS,cAAc,KAAwD;AACpF,SAAO,UAAU,OAAO,IAAI,SAAS;AACvC;AAEO,SAAS,mBAAmB,KAA6D;AAC9F,SAAO,UAAU,OAAO,IAAI,SAAS;AACvC;AAEO,SAAS,eAAe,KAAyD;AACtF,SAAO,WAAW,OAAO,OAAO,IAAI,UAAU;AAChD;AAEO,SAAS,kBAAkB,KAA8D;AAC9F,SAAO,oBAAoB,GAAG;AAChC;","names":[]}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@livekit/agents-plugin-cartesia",
3
+ "version": "0.0.0-next-20260624041820",
4
+ "description": "Cartesia plugin for LiveKit Node Agents",
5
+ "main": "dist/index.js",
6
+ "require": "dist/index.cjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ "import": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "require": {
14
+ "types": "./dist/index.d.cts",
15
+ "default": "./dist/index.cjs"
16
+ }
17
+ },
18
+ "author": "LiveKit",
19
+ "type": "module",
20
+ "repository": "git@github.com:livekit/agents-js.git",
21
+ "license": "Apache-2.0",
22
+ "files": [
23
+ "dist",
24
+ "src",
25
+ "README.md"
26
+ ],
27
+ "devDependencies": {
28
+ "@livekit/rtc-node": "^0.13.29",
29
+ "@microsoft/api-extractor": "^7.35.0",
30
+ "@types/ws": "^8.5.10",
31
+ "tsup": "^8.3.5",
32
+ "typescript": "^5.0.0",
33
+ "@livekit/agents": "0.0.0-next-20260624041820",
34
+ "@livekit/agents-plugin-silero": "0.0.0-next-20260624041820",
35
+ "@livekit/agents-plugin-openai": "0.0.0-next-20260624041820",
36
+ "@livekit/agents-plugins-test": "0.0.0-next-20260624041820"
37
+ },
38
+ "dependencies": {
39
+ "ws": "^8.18.0"
40
+ },
41
+ "peerDependencies": {
42
+ "@livekit/rtc-node": "^0.13.29",
43
+ "zod": "^3.25.76 || ^4.1.8",
44
+ "@livekit/agents": "0.0.0-next-20260624041820"
45
+ },
46
+ "scripts": {
47
+ "build": "tsup --onSuccess \"pnpm build:types\"",
48
+ "build:types": "tsc --declaration --emitDeclarationOnly && node ../../scripts/copyDeclarationOutput.js",
49
+ "clean": "rm -rf dist",
50
+ "clean:build": "pnpm clean && pnpm build",
51
+ "lint": "eslint -f unix \"src/**/*.{ts,js}\"",
52
+ "api:check": "api-extractor run --typescript-compiler-folder ../../node_modules/typescript",
53
+ "api:update": "api-extractor run --local --typescript-compiler-folder ../../node_modules/typescript --verbose"
54
+ }
55
+ }
package/src/index.ts ADDED
@@ -0,0 +1,19 @@
1
+ // SPDX-FileCopyrightText: 2025 LiveKit, Inc.
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ import { Plugin } from '@livekit/agents';
5
+
6
+ export * from './stt.js';
7
+ export * from './tts.js';
8
+
9
+ class CartesiaPlugin extends Plugin {
10
+ constructor() {
11
+ super({
12
+ title: 'cartesia',
13
+ version: __PACKAGE_VERSION__,
14
+ package: __PACKAGE_NAME__,
15
+ });
16
+ }
17
+ }
18
+
19
+ Plugin.registerPlugin(new CartesiaPlugin());