@tambo-ai/react 0.60.0 → 0.62.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/dist/__tests__/util/validate-zod-schema.test.js +25 -0
- package/dist/__tests__/util/validate-zod-schema.test.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +3 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/use-tambo-voice.d.ts +21 -0
- package/dist/hooks/use-tambo-voice.d.ts.map +1 -0
- package/dist/hooks/use-tambo-voice.js +74 -0
- package/dist/hooks/use-tambo-voice.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/__tests__/tambo-mcp-provider.test.js +4 -4
- package/dist/mcp/__tests__/tambo-mcp-provider.test.js.map +1 -1
- package/dist/mcp/tambo-mcp-provider.d.ts +1 -1
- package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
- package/dist/mcp/tambo-mcp-provider.js +2 -2
- package/dist/mcp/tambo-mcp-provider.js.map +1 -1
- package/dist/providers/__tests__/tambo-thread-provider-initial-messages.test.js +1 -1
- package/dist/providers/__tests__/tambo-thread-provider-initial-messages.test.js.map +1 -1
- package/dist/providers/__tests__/tambo-thread-provider.test.js +170 -0
- package/dist/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
- package/dist/providers/tambo-provider.d.ts +2 -0
- package/dist/providers/tambo-provider.d.ts.map +1 -1
- package/dist/providers/tambo-provider.js +4 -2
- package/dist/providers/tambo-provider.js.map +1 -1
- package/dist/providers/tambo-thread-provider.d.ts +6 -0
- package/dist/providers/tambo-thread-provider.d.ts.map +1 -1
- package/dist/providers/tambo-thread-provider.js +112 -45
- package/dist/providers/tambo-thread-provider.js.map +1 -1
- package/dist/setupTests.js +10 -0
- package/dist/setupTests.js.map +1 -1
- package/dist/util/validate-zod-schema.d.ts.map +1 -1
- package/dist/util/validate-zod-schema.js +11 -0
- package/dist/util/validate-zod-schema.js.map +1 -1
- package/esm/__tests__/util/validate-zod-schema.test.js +25 -0
- package/esm/__tests__/util/validate-zod-schema.test.js.map +1 -1
- package/esm/hooks/index.d.ts +1 -0
- package/esm/hooks/index.d.ts.map +1 -1
- package/esm/hooks/index.js +1 -0
- package/esm/hooks/index.js.map +1 -1
- package/esm/hooks/use-tambo-voice.d.ts +21 -0
- package/esm/hooks/use-tambo-voice.d.ts.map +1 -0
- package/esm/hooks/use-tambo-voice.js +71 -0
- package/esm/hooks/use-tambo-voice.js.map +1 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/mcp/__tests__/tambo-mcp-provider.test.js +4 -4
- package/esm/mcp/__tests__/tambo-mcp-provider.test.js.map +1 -1
- package/esm/mcp/tambo-mcp-provider.d.ts +1 -1
- package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
- package/esm/mcp/tambo-mcp-provider.js +2 -2
- package/esm/mcp/tambo-mcp-provider.js.map +1 -1
- package/esm/providers/__tests__/tambo-thread-provider-initial-messages.test.js +1 -1
- package/esm/providers/__tests__/tambo-thread-provider-initial-messages.test.js.map +1 -1
- package/esm/providers/__tests__/tambo-thread-provider.test.js +170 -0
- package/esm/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
- package/esm/providers/tambo-provider.d.ts +2 -0
- package/esm/providers/tambo-provider.d.ts.map +1 -1
- package/esm/providers/tambo-provider.js +4 -2
- package/esm/providers/tambo-provider.js.map +1 -1
- package/esm/providers/tambo-thread-provider.d.ts +6 -0
- package/esm/providers/tambo-thread-provider.d.ts.map +1 -1
- package/esm/providers/tambo-thread-provider.js +112 -45
- package/esm/providers/tambo-thread-provider.js.map +1 -1
- package/esm/setupTests.js +10 -0
- package/esm/setupTests.js.map +1 -1
- package/esm/util/validate-zod-schema.d.ts.map +1 -1
- package/esm/util/validate-zod-schema.js +11 -0
- package/esm/util/validate-zod-schema.js.map +1 -1
- package/package.json +5 -4
|
@@ -56,6 +56,17 @@ function assertNoZodRecord(schema, contextName = "schema") {
|
|
|
56
56
|
visit(def.right, [...path, "&1"]);
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
|
+
if (current instanceof zod_1.z.ZodLazy) {
|
|
60
|
+
visit(def.getter(), path);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (current instanceof zod_1.z.ZodFunction) {
|
|
64
|
+
// Check the function arguments for z.record()
|
|
65
|
+
if (def.args instanceof zod_1.z.ZodTuple) {
|
|
66
|
+
visit(def.args, [...path, "args"]);
|
|
67
|
+
}
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
59
70
|
// ───────────── Wrapper / pass-through types ───────────
|
|
60
71
|
const potentialKeys = [
|
|
61
72
|
"schema",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-zod-schema.js","sourceRoot":"","sources":["../../src/util/validate-zod-schema.ts"],"names":[],"mappings":";;AASA,
|
|
1
|
+
{"version":3,"file":"validate-zod-schema.js","sourceRoot":"","sources":["../../src/util/validate-zod-schema.ts"],"names":[],"mappings":";;AASA,8CAgHC;AAzHD,6BAA2D;AAE3D;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAC/B,MAAkB,EAClB,WAAW,GAAG,QAAQ;IAEtB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAc,CAAC;IAE1C,MAAM,KAAK,GAAG,CAAC,OAAmB,EAAE,IAAc,EAAQ,EAAE;QAC1D,IACE,CAAC,OAAO;YACR,OAAO,OAAO,KAAK,QAAQ;YAC3B,CAAC,CAAC,OAAO,YAAY,OAAC,CAAC,OAAO,CAAC;YAE/B,OAAO;QACT,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;YAAE,OAAO;QAEjC,MAAM,GAAG,GAAQ,OAAO,CAAC,IAAI,CAAC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,aAAa,EAAE,CAAC;YAChC,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;YACzB,IAAI,KAAK,YAAY,OAAC,CAAC,OAAO;gBAAE,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;iBAC9C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBAC3B,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,YAAY,OAAC,CAAC,OAAO,IAAI,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;QACzE,CAAC;QAED,IAAI,OAAO,GAAG,EAAE,MAAM,KAAK,UAAU,EAAE,CAAC;YACtC,IAAI,CAAC;gBACH,MAAM,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;gBAChC,IAAI,UAAU,YAAY,OAAC,CAAC,OAAO;oBAAE,KAAK,CAAC,UAAU,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;YACpE,CAAC;YAAC,MAAM,CAAC;gBACP,uCAAuC;YACzC,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACpB,CAAC","sourcesContent":["import { z, ZodFirstPartyTypeKind, ZodTypeAny } from \"zod\";\n\n/**\n * Recursively walks a Zod schema and throws when it encounters `z.record()`.\n * Records are not serialisable to JSON-Schema in a way that the Tambo backend\n * understands, so they are disallowed.\n * @param schema The root Zod schema to inspect.\n * @param contextName A human-readable label echoed in the error message.\n */\nexport function assertNoZodRecord(\n schema: ZodTypeAny,\n contextName = \"schema\",\n): void {\n const visited = new WeakSet<ZodTypeAny>();\n\n const visit = (current: ZodTypeAny, path: string[]): void => {\n if (\n !current ||\n typeof current !== \"object\" ||\n !(current instanceof z.ZodType)\n )\n return;\n if (visited.has(current)) return;\n\n const def: any = current._def;\n const typeName: ZodFirstPartyTypeKind | undefined = def?.typeName;\n\n // ───────────────────── Disallowed ─────────────────────\n if (typeName === ZodFirstPartyTypeKind.ZodRecord) {\n const joined = path.length ? path.join(\".\") : \"(root)\";\n throw new Error(\n `z.record() is not supported in ${contextName}. ` +\n `Found at path \"${joined}\". ` +\n \"Replace it with z.object({ ... }) using explicit keys.\",\n );\n }\n\n visited.add(current);\n\n // ─────────────── Composite / container types ──────────\n if (current instanceof z.ZodObject) {\n for (const key of Object.keys(current.shape)) {\n visit(current.shape[key], [...path, key]);\n }\n return;\n }\n\n if (current instanceof z.ZodArray) {\n visit(current.element, [...path, \"[]\"]);\n return;\n }\n\n if (current instanceof z.ZodTuple) {\n current.items.forEach((item: ZodTypeAny, idx: number) =>\n visit(item, [...path, `${idx}`]),\n );\n return;\n }\n\n if (current instanceof z.ZodUnion) {\n def.options.forEach((opt: ZodTypeAny, idx: number) =>\n visit(opt, [...path, `|${idx}`]),\n );\n return;\n }\n\n if (current instanceof z.ZodDiscriminatedUnion) {\n current.options.forEach((opt: ZodTypeAny, idx: number) =>\n visit(opt, [...path, `|${idx}`]),\n );\n return;\n }\n\n if (current instanceof z.ZodIntersection) {\n visit(def.left, [...path, \"&0\"]);\n visit(def.right, [...path, \"&1\"]);\n return;\n }\n\n if (current instanceof z.ZodLazy) {\n visit(def.getter(), path);\n return;\n }\n\n if (current instanceof z.ZodFunction) {\n // Check the function arguments for z.record()\n if (def.args instanceof z.ZodTuple) {\n visit(def.args, [...path, \"args\"]);\n }\n return;\n }\n\n // ───────────── Wrapper / pass-through types ───────────\n const potentialKeys = [\n \"schema\",\n \"innerType\",\n \"type\",\n \"in\",\n \"out\",\n \"left\",\n \"right\",\n ] as const;\n\n for (const key of potentialKeys) {\n const maybe = def?.[key];\n if (maybe instanceof z.ZodType) visit(maybe, path);\n else if (Array.isArray(maybe))\n maybe.forEach((sub) => sub instanceof z.ZodType && visit(sub, path));\n }\n\n if (typeof def?.getter === \"function\") {\n try {\n const lazySchema = def.getter();\n if (lazySchema instanceof z.ZodType) visit(lazySchema, [...path]);\n } catch {\n // Ignore lazy getter execution errors.\n }\n }\n };\n\n visit(schema, []);\n}\n"]}
|
|
@@ -65,5 +65,30 @@ describe("assertNoZodRecord", () => {
|
|
|
65
65
|
const schema = z.record(z.string());
|
|
66
66
|
expect(() => assertNoZodRecord(schema, "mySchema")).toThrow('z.record() is not supported in mySchema. Found at path "(root)". Replace it with z.object({ ... }) using explicit keys.');
|
|
67
67
|
});
|
|
68
|
+
it("should handle ZodLazy schemas", () => {
|
|
69
|
+
const schema = z.lazy(() => z.record(z.string()));
|
|
70
|
+
expect(() => assertNoZodRecord(schema)).toThrow('z.record() is not supported in schema. Found at path "(root)". Replace it with z.object({ ... }) using explicit keys.');
|
|
71
|
+
});
|
|
72
|
+
it("should allow z.function() with valid arguments", () => {
|
|
73
|
+
const schema = z
|
|
74
|
+
.function()
|
|
75
|
+
.args(z.string(), z.number())
|
|
76
|
+
.returns(z.string());
|
|
77
|
+
expect(() => assertNoZodRecord(schema)).not.toThrow();
|
|
78
|
+
});
|
|
79
|
+
it("should throw when z.function() arguments contain z.record()", () => {
|
|
80
|
+
const schema = z.function().args(z.record(z.string())).returns(z.string());
|
|
81
|
+
expect(() => assertNoZodRecord(schema)).toThrow('z.record() is not supported in schema. Found at path "args.0". Replace it with z.object({ ... }) using explicit keys.');
|
|
82
|
+
});
|
|
83
|
+
it("should throw when z.function() arguments contain nested z.record()", () => {
|
|
84
|
+
const schema = z
|
|
85
|
+
.function()
|
|
86
|
+
.args(z.object({
|
|
87
|
+
name: z.string(),
|
|
88
|
+
metadata: z.record(z.string()),
|
|
89
|
+
}))
|
|
90
|
+
.returns(z.string());
|
|
91
|
+
expect(() => assertNoZodRecord(schema)).toThrow('z.record() is not supported in schema. Found at path "args.0.metadata". Replace it with z.object({ ... }) using explicit keys.');
|
|
92
|
+
});
|
|
68
93
|
});
|
|
69
94
|
//# sourceMappingURL=validate-zod-schema.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-zod-schema.test.js","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AC,OAAO,CAC7C,yHAAyH,CAC1H,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC5D,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;QAE3D,MAAM,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAC7C,kHAAkH,CACnH,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAEpC,MAAM,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CACzD,yHAAyH,CAC1H,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { assertNoZodRecord } from \"../../util/validate-zod-schema\";\n\ndescribe(\"assertNoZodRecord\", () => {\n it(\"should allow valid schemas without records\", () => {\n const schema = z.object({\n name: z.string(),\n age: z.number(),\n tags: z.array(z.string()),\n address: z.object({\n street: z.string(),\n city: z.string(),\n }),\n });\n\n expect(() => assertNoZodRecord(schema)).not.toThrow();\n });\n\n it(\"should throw when encountering a record at root level\", () => {\n const schema = z.record(z.string());\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"(root)\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a nested record\", () => {\n const schema = z.object({\n name: z.string(),\n metadata: z.record(z.string()),\n });\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"metadata\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in an array\", () => {\n const schema = z.object({\n items: z.array(z.record(z.string())),\n });\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"items.[]\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in a union\", () => {\n const schema = z.union([z.string(), z.record(z.number())]);\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"|1\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in an intersection\", () => {\n const schema = z.intersection(\n z.object({ name: z.string() }),\n z.object({ metadata: z.record(z.string()) }),\n );\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"&1.metadata\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in a discriminated union\", () => {\n const schema = z.discriminatedUnion(\"type\", [\n z.object({ type: z.literal(\"string\"), value: z.string() }),\n z.object({ type: z.literal(\"record\"), value: z.record(z.number()) }),\n ]);\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"|1.value\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in an optional field\", () => {\n const schema = z.object({\n optional: z.optional(z.record(z.string())),\n });\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"optional\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in a nullable field\", () => {\n const schema = z.object({\n nullable: z.nullable(z.record(z.string())),\n });\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"nullable\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in a tuple\", () => {\n const schema = z.tuple([z.string(), z.record(z.number())]);\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"1\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should use custom context name in error message\", () => {\n const schema = z.record(z.string());\n\n expect(() => assertNoZodRecord(schema, \"mySchema\")).toThrow(\n 'z.record() is not supported in mySchema. Found at path \"(root)\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"validate-zod-schema.test.js","sourceRoot":"","sources":["../../../src/__tests__/util/validate-zod-schema.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;YACtB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;YAChB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;YACf,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;YACzB,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;gBAChB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;gBAClB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;aACjB,CAAC;SACH,CAAC,CAAC;QAEH,MAAM,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAEpC,MAAM,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO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from \"zod\";\nimport { assertNoZodRecord } from \"../../util/validate-zod-schema\";\n\ndescribe(\"assertNoZodRecord\", () => {\n it(\"should allow valid schemas without records\", () => {\n const schema = z.object({\n name: z.string(),\n age: z.number(),\n tags: z.array(z.string()),\n address: z.object({\n street: z.string(),\n city: z.string(),\n }),\n });\n\n expect(() => assertNoZodRecord(schema)).not.toThrow();\n });\n\n it(\"should throw when encountering a record at root level\", () => {\n const schema = z.record(z.string());\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"(root)\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a nested record\", () => {\n const schema = z.object({\n name: z.string(),\n metadata: z.record(z.string()),\n });\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"metadata\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in an array\", () => {\n const schema = z.object({\n items: z.array(z.record(z.string())),\n });\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"items.[]\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in a union\", () => {\n const schema = z.union([z.string(), z.record(z.number())]);\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"|1\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in an intersection\", () => {\n const schema = z.intersection(\n z.object({ name: z.string() }),\n z.object({ metadata: z.record(z.string()) }),\n );\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"&1.metadata\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in a discriminated union\", () => {\n const schema = z.discriminatedUnion(\"type\", [\n z.object({ type: z.literal(\"string\"), value: z.string() }),\n z.object({ type: z.literal(\"record\"), value: z.record(z.number()) }),\n ]);\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"|1.value\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in an optional field\", () => {\n const schema = z.object({\n optional: z.optional(z.record(z.string())),\n });\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"optional\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in a nullable field\", () => {\n const schema = z.object({\n nullable: z.nullable(z.record(z.string())),\n });\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"nullable\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in a tuple\", () => {\n const schema = z.tuple([z.string(), z.record(z.number())]);\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"1\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should use custom context name in error message\", () => {\n const schema = z.record(z.string());\n\n expect(() => assertNoZodRecord(schema, \"mySchema\")).toThrow(\n 'z.record() is not supported in mySchema. Found at path \"(root)\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should handle ZodLazy schemas\", () => {\n const schema = z.lazy(() => z.record(z.string()));\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"(root)\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should allow z.function() with valid arguments\", () => {\n const schema = z\n .function()\n .args(z.string(), z.number())\n .returns(z.string());\n\n expect(() => assertNoZodRecord(schema)).not.toThrow();\n });\n\n it(\"should throw when z.function() arguments contain z.record()\", () => {\n const schema = z.function().args(z.record(z.string())).returns(z.string());\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"args.0\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n\n it(\"should throw when z.function() arguments contain nested z.record()\", () => {\n const schema = z\n .function()\n .args(\n z.object({\n name: z.string(),\n metadata: z.record(z.string()),\n }),\n )\n .returns(z.string());\n\n expect(() => assertNoZodRecord(schema)).toThrow(\n 'z.record() is not supported in schema. Found at path \"args.0.metadata\". Replace it with z.object({ ... }) using explicit keys.',\n );\n });\n});\n"]}
|
package/esm/hooks/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export { useTamboStreamingProps } from "./use-streaming-props";
|
|
|
5
5
|
export * from "./use-suggestions";
|
|
6
6
|
export { useTamboStreamStatus, type PropStatus, type StreamStatus, } from "./use-tambo-stream-status";
|
|
7
7
|
export { useTamboThreadList } from "./use-tambo-threads";
|
|
8
|
+
export { useTamboVoice } from "./use-tambo-voice";
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/hooks/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AACA,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,cAAc,mBAAmB,CAAC;AAClC,OAAO,EACL,oBAAoB,EACpB,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AACA,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,cAAc,mBAAmB,CAAC;AAClC,OAAO,EACL,oBAAoB,EACpB,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}
|
package/esm/hooks/index.js
CHANGED
|
@@ -6,4 +6,5 @@ export { useTamboStreamingProps } from "./use-streaming-props";
|
|
|
6
6
|
export * from "./use-suggestions";
|
|
7
7
|
export { useTamboStreamStatus, } from "./use-tambo-stream-status";
|
|
8
8
|
export { useTamboThreadList } from "./use-tambo-threads";
|
|
9
|
+
export { useTamboVoice } from "./use-tambo-voice";
|
|
9
10
|
//# sourceMappingURL=index.js.map
|
package/esm/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,cAAc,mBAAmB,CAAC;AAClC,OAAO,EACL,oBAAoB,GAGrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["// Export all hooks from this directory\nexport * from \"./react-query-hooks\";\nexport { useTamboComponentState } from \"./use-component-state\";\nexport { useTamboCurrentMessage } from \"./use-current-message\";\nexport { useTamboStreamingProps } from \"./use-streaming-props\";\nexport * from \"./use-suggestions\";\nexport {\n useTamboStreamStatus,\n type PropStatus,\n type StreamStatus,\n} from \"./use-tambo-stream-status\";\nexport { useTamboThreadList } from \"./use-tambo-threads\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,cAAc,mBAAmB,CAAC;AAClC,OAAO,EACL,oBAAoB,GAGrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["// Export all hooks from this directory\nexport * from \"./react-query-hooks\";\nexport { useTamboComponentState } from \"./use-component-state\";\nexport { useTamboCurrentMessage } from \"./use-current-message\";\nexport { useTamboStreamingProps } from \"./use-streaming-props\";\nexport * from \"./use-suggestions\";\nexport {\n useTamboStreamStatus,\n type PropStatus,\n type StreamStatus,\n} from \"./use-tambo-stream-status\";\nexport { useTamboThreadList } from \"./use-tambo-threads\";\nexport { useTamboVoice } from \"./use-tambo-voice\";\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exposes functionality to record speech and transcribe it using the Tambo API.
|
|
3
|
+
* @returns An object with:
|
|
4
|
+
* - startRecording: A function to start recording audio and reset the current transcript.
|
|
5
|
+
* - stopRecording: A function to stop recording audio and automatically kick off transcription.
|
|
6
|
+
* - isRecording: A boolean indicating if the user is recording audio.
|
|
7
|
+
* - isTranscribing: A boolean indicating if the audio is being transcribed.
|
|
8
|
+
* - transcript: The transcript of the recorded audio.
|
|
9
|
+
* - transcriptionError: An error message if the transcription fails.
|
|
10
|
+
* - mediaAccessError: An error message if microphone access fails.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useTamboVoice(): {
|
|
13
|
+
startRecording: () => void;
|
|
14
|
+
stopRecording: () => void;
|
|
15
|
+
isRecording: boolean;
|
|
16
|
+
mediaAccessError: string;
|
|
17
|
+
isTranscribing: boolean;
|
|
18
|
+
transcript: string | null;
|
|
19
|
+
transcriptionError: string | null;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=use-tambo-voice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-tambo-voice.d.ts","sourceRoot":"","sources":["../../src/hooks/use-tambo-voice.tsx"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa;;;;;;;;EAyE5B"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from "react";
|
|
2
|
+
import { useReactMediaRecorder } from "react-media-recorder";
|
|
3
|
+
import { useTamboClient } from "../providers/tambo-client-provider";
|
|
4
|
+
import { useTamboMutation } from "./react-query-hooks";
|
|
5
|
+
/**
|
|
6
|
+
* Exposes functionality to record speech and transcribe it using the Tambo API.
|
|
7
|
+
* @returns An object with:
|
|
8
|
+
* - startRecording: A function to start recording audio and reset the current transcript.
|
|
9
|
+
* - stopRecording: A function to stop recording audio and automatically kick off transcription.
|
|
10
|
+
* - isRecording: A boolean indicating if the user is recording audio.
|
|
11
|
+
* - isTranscribing: A boolean indicating if the audio is being transcribed.
|
|
12
|
+
* - transcript: The transcript of the recorded audio.
|
|
13
|
+
* - transcriptionError: An error message if the transcription fails.
|
|
14
|
+
* - mediaAccessError: An error message if microphone access fails.
|
|
15
|
+
*/
|
|
16
|
+
export function useTamboVoice() {
|
|
17
|
+
const [transcript, setTranscript] = useState(null);
|
|
18
|
+
const client = useTamboClient();
|
|
19
|
+
const { status, startRecording: startMediaRecording, stopRecording: stopMediaRecording, mediaBlobUrl, error: mediaAccessError, } = useReactMediaRecorder({
|
|
20
|
+
audio: true,
|
|
21
|
+
video: false,
|
|
22
|
+
blobPropertyBag: { type: "audio/webm" },
|
|
23
|
+
});
|
|
24
|
+
const isRecording = status === "recording";
|
|
25
|
+
const transcriptionMutation = useTamboMutation({
|
|
26
|
+
mutationFn: async (blobUrl) => {
|
|
27
|
+
const response = await fetch(blobUrl);
|
|
28
|
+
const audioBlob = await response.blob();
|
|
29
|
+
const file = new File([audioBlob], "recording.webm", {
|
|
30
|
+
type: "audio/webm",
|
|
31
|
+
});
|
|
32
|
+
return await client.beta.audio.transcribe({ file });
|
|
33
|
+
},
|
|
34
|
+
onSuccess: (transcription) => {
|
|
35
|
+
setTranscript(transcription);
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
// Trigger transcription when recording stops and we have a blob URL
|
|
39
|
+
const shouldTranscribe = status === "stopped" &&
|
|
40
|
+
mediaBlobUrl &&
|
|
41
|
+
!transcriptionMutation.isPending &&
|
|
42
|
+
!transcriptionMutation.isSuccess;
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (shouldTranscribe) {
|
|
45
|
+
transcriptionMutation.mutate(mediaBlobUrl);
|
|
46
|
+
}
|
|
47
|
+
}, [shouldTranscribe, mediaBlobUrl, transcriptionMutation]);
|
|
48
|
+
const startRecording = useCallback(() => {
|
|
49
|
+
if (isRecording)
|
|
50
|
+
return;
|
|
51
|
+
// Reset state when starting new recording
|
|
52
|
+
setTranscript(null);
|
|
53
|
+
transcriptionMutation.reset(); // Clear any previous mutation state
|
|
54
|
+
startMediaRecording();
|
|
55
|
+
}, [isRecording, startMediaRecording, transcriptionMutation]);
|
|
56
|
+
const stopRecording = useCallback(() => {
|
|
57
|
+
if (isRecording) {
|
|
58
|
+
stopMediaRecording();
|
|
59
|
+
}
|
|
60
|
+
}, [isRecording, stopMediaRecording]);
|
|
61
|
+
return {
|
|
62
|
+
startRecording,
|
|
63
|
+
stopRecording,
|
|
64
|
+
isRecording,
|
|
65
|
+
mediaAccessError: mediaAccessError ?? null,
|
|
66
|
+
isTranscribing: transcriptionMutation.isPending,
|
|
67
|
+
transcript,
|
|
68
|
+
transcriptionError: transcriptionMutation.error?.message ?? null,
|
|
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AACJ,CAAC","sourcesContent":["import { useCallback, useEffect, useState } from \"react\";\nimport { useReactMediaRecorder } from \"react-media-recorder\";\nimport { useTamboClient } from \"../providers/tambo-client-provider\";\nimport { useTamboMutation } from \"./react-query-hooks\";\n\n/**\n * Exposes functionality to record speech and transcribe it using the Tambo API.\n * @returns An object with:\n * - startRecording: A function to start recording audio and reset the current transcript.\n * - stopRecording: A function to stop recording audio and automatically kick off transcription.\n * - isRecording: A boolean indicating if the user is recording audio.\n * - isTranscribing: A boolean indicating if the audio is being transcribed.\n * - transcript: The transcript of the recorded audio.\n * - transcriptionError: An error message if the transcription fails.\n * - mediaAccessError: An error message if microphone access fails.\n */\nexport function useTamboVoice() {\n const [transcript, setTranscript] = useState<string | null>(null);\n const client = useTamboClient();\n const {\n status,\n startRecording: startMediaRecording,\n stopRecording: stopMediaRecording,\n mediaBlobUrl,\n error: mediaAccessError,\n } = useReactMediaRecorder({\n audio: true,\n video: false,\n blobPropertyBag: { type: \"audio/webm\" },\n });\n\n const isRecording = status === \"recording\";\n\n const transcriptionMutation = useTamboMutation<\n string,\n Error,\n string // blobUrl parameter\n >({\n mutationFn: async (blobUrl: string) => {\n const response = await fetch(blobUrl);\n const audioBlob = await response.blob();\n const file = new File([audioBlob], \"recording.webm\", {\n type: \"audio/webm\",\n });\n\n return await client.beta.audio.transcribe({ file });\n },\n onSuccess: (transcription) => {\n setTranscript(transcription);\n },\n });\n\n // Trigger transcription when recording stops and we have a blob URL\n const shouldTranscribe =\n status === \"stopped\" &&\n mediaBlobUrl &&\n !transcriptionMutation.isPending &&\n !transcriptionMutation.isSuccess;\n\n useEffect(() => {\n if (shouldTranscribe) {\n transcriptionMutation.mutate(mediaBlobUrl);\n }\n }, [shouldTranscribe, mediaBlobUrl, transcriptionMutation]);\n\n const startRecording = useCallback(() => {\n if (isRecording) return;\n\n // Reset state when starting new recording\n setTranscript(null);\n transcriptionMutation.reset(); // Clear any previous mutation state\n startMediaRecording();\n }, [isRecording, startMediaRecording, transcriptionMutation]);\n\n const stopRecording = useCallback(() => {\n if (isRecording) {\n stopMediaRecording();\n }\n }, [isRecording, stopMediaRecording]);\n\n return {\n startRecording,\n stopRecording,\n isRecording,\n mediaAccessError: mediaAccessError ?? null,\n isTranscribing: transcriptionMutation.isPending,\n transcript,\n transcriptionError: transcriptionMutation.error?.message ?? null,\n };\n}\n"]}
|
package/esm/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { useMessageImages, type StagedImage } from "./hooks/use-message-images";
|
|
|
5
5
|
export { useTamboStreamingProps } from "./hooks/use-streaming-props";
|
|
6
6
|
export * from "./hooks/use-suggestions";
|
|
7
7
|
export { useTamboStreamStatus, type PropStatus, type StreamStatus, } from "./hooks/use-tambo-stream-status";
|
|
8
|
+
export { useTamboVoice } from "./hooks/use-tambo-voice";
|
|
8
9
|
export { TamboClientProvider, TamboComponentProvider, TamboContextHelpersProvider, TamboPropStreamProvider, TamboProvider, TamboStubProvider, TamboThreadInputProvider, TamboThreadProvider, useIsTamboTokenUpdating, useTambo, useTamboClient, useTamboContextHelpers, useTamboGenerationStage, useTamboStream, useTamboThread, useTamboThreadInput, type TamboComponent, type TamboContextHelpersContextProps, type TamboContextHelpersProviderProps, type TamboRegistryContext, type TamboStubProviderProps, type TamboThreadInputContextProps, type TamboThreadProviderProps, } from "./providers";
|
|
9
10
|
export type { APIError, RateLimitError, TamboAIError, } from "@tambo-ai/typescript-sdk";
|
|
10
11
|
export type { Suggestion, SuggestionGenerateParams, SuggestionGenerateResponse, SuggestionListResponse, } from "@tambo-ai/typescript-sdk/resources/beta/threads/suggestions";
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AAExK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,6BAA6B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,wBAAwB,EACxB,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,6DAA6D,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,SAAS,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,eAAe,EACf,KAAK,kBAAkB,GACxB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAEnF,YAAY,EACV,0BAA0B,IAAI,qBAAqB,EACnD,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,qBAAqB,IAAI,gBAAgB,EACzC,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,GAChC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,+BAA+B,EAC/B,oBAAoB,GACrB,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,cAAc,GACf,MAAM,mBAAmB,CAAC"}
|
package/esm/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { useMessageImages } from "./hooks/use-message-images";
|
|
|
5
5
|
export { useTamboStreamingProps } from "./hooks/use-streaming-props";
|
|
6
6
|
export * from "./hooks/use-suggestions";
|
|
7
7
|
export { useTamboStreamStatus, } from "./hooks/use-tambo-stream-status";
|
|
8
|
+
export { useTamboVoice } from "./hooks/use-tambo-voice";
|
|
8
9
|
// Re-export provider components
|
|
9
10
|
export { TamboClientProvider, TamboComponentProvider, TamboContextHelpersProvider, TamboPropStreamProvider, TamboProvider, TamboStubProvider, TamboThreadInputProvider, TamboThreadProvider, useIsTamboTokenUpdating, useTambo, useTamboClient, useTamboContextHelpers, useTamboGenerationStage, useTamboStream, useTamboThread, useTamboThreadInput, } from "./providers";
|
|
10
11
|
export { useTamboThreadList } from "./hooks/use-tambo-threads";
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AAExK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAoB,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,oBAAoB,GAGrB,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AAExK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAoB,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,oBAAoB,GAGrB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,gCAAgC;AAChC,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,2BAA2B,EAC3B,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,QAAQ,EACR,cAAc,EACd,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,mBAAmB,GAQpB,MAAM,aAAa,CAAC;AAcrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAQ/D,OAAO,EACL,eAAe,GAEhB,MAAM,qCAAqC,CAAC;AAQ7C,OAAO,EACL,qBAAqB,IAAI,gBAAgB,GAG1C,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,+BAA+B,EAC/B,oBAAoB,GACrB,MAAM,yCAAyC,CAAC;AAEjD,0BAA0B;AAC1B,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAO3B,yEAAyE;AACzE,8BAA8B","sourcesContent":["/** Exports for the library. Only publically available exports are re-exported here. Anything not exported here is not supported and may change or break at any time. */\n\nexport { useTamboComponentState } from \"./hooks/use-component-state\";\nexport {\n TamboMessageProvider,\n useTamboCurrentMessage,\n} from \"./hooks/use-current-message\";\nexport { useMessageImages, type StagedImage } from \"./hooks/use-message-images\";\nexport { useTamboStreamingProps } from \"./hooks/use-streaming-props\";\nexport * from \"./hooks/use-suggestions\";\nexport {\n useTamboStreamStatus,\n type PropStatus,\n type StreamStatus,\n} from \"./hooks/use-tambo-stream-status\";\nexport { useTamboVoice } from \"./hooks/use-tambo-voice\";\n\n// Re-export provider components\nexport {\n TamboClientProvider,\n TamboComponentProvider,\n TamboContextHelpersProvider,\n TamboPropStreamProvider,\n TamboProvider,\n TamboStubProvider,\n TamboThreadInputProvider,\n TamboThreadProvider,\n useIsTamboTokenUpdating,\n useTambo,\n useTamboClient,\n useTamboContextHelpers,\n useTamboGenerationStage,\n useTamboStream,\n useTamboThread,\n useTamboThreadInput,\n type TamboComponent,\n type TamboContextHelpersContextProps,\n type TamboContextHelpersProviderProps,\n type TamboRegistryContext,\n type TamboStubProviderProps,\n type TamboThreadInputContextProps,\n type TamboThreadProviderProps,\n} from \"./providers\";\n\n// Re-export types from Tambo Node SDK\nexport type {\n APIError,\n RateLimitError,\n TamboAIError,\n} from \"@tambo-ai/typescript-sdk\";\nexport type {\n Suggestion,\n SuggestionGenerateParams,\n SuggestionGenerateResponse,\n SuggestionListResponse,\n} from \"@tambo-ai/typescript-sdk/resources/beta/threads/suggestions\";\nexport { useTamboThreadList } from \"./hooks/use-tambo-threads\";\nexport {\n type ComponentContextToolMetadata,\n type ComponentRegistry,\n type ParameterSpec,\n type RegisteredComponent,\n type TamboTool,\n} from \"./model/component-metadata\";\nexport {\n GenerationStage,\n type TamboThreadMessage,\n} from \"./model/generate-component-response\";\nexport { type TamboThread } from \"./model/tambo-thread\";\nexport { type InitialTamboThreadMessage } from \"./providers/tambo-thread-provider\";\n\nexport type {\n TamboInteractableComponent as InteractableComponent,\n TamboInteractableContext,\n} from \"./model/tambo-interactable\";\nexport {\n withTamboInteractable as withInteractable,\n type InteractableConfig,\n type WithTamboInteractableProps,\n} from \"./providers/hoc/with-tambo-interactable\";\nexport {\n useCurrentInteractablesSnapshot,\n useTamboInteractable,\n} from \"./providers/tambo-interactable-provider\";\n\n// Context helpers exports\nexport {\n currentPageContextHelper,\n currentTimeContextHelper,\n} from \"./context-helpers\";\nexport type {\n AdditionalContext,\n ContextHelperFn,\n ContextHelpers,\n} from \"./context-helpers\";\n\n// Note MCP exports like TamboMcpProvider are available separately in the\n// @tambo-ai/react/mcp package\n"]}
|
|
@@ -388,7 +388,7 @@ describe("TamboMcpProvider handler support", () => {
|
|
|
388
388
|
expect(latest.length).toBe(1);
|
|
389
389
|
});
|
|
390
390
|
// Verify MCPClient.create was called
|
|
391
|
-
expect(createSpy).toHaveBeenCalledWith("https://test.example", MCPTransport.
|
|
391
|
+
expect(createSpy).toHaveBeenCalledWith("https://test.example", MCPTransport.HTTP, undefined, undefined, undefined, expect.objectContaining({
|
|
392
392
|
elicitation: expect.any(Function),
|
|
393
393
|
}));
|
|
394
394
|
// Get the actual handler that was passed
|
|
@@ -403,7 +403,7 @@ describe("TamboMcpProvider handler support", () => {
|
|
|
403
403
|
await passedHandlers.elicitation(mockRequest, mockExtra);
|
|
404
404
|
expect(mockElicitationHandler).toHaveBeenCalledWith(mockRequest, mockExtra, expect.objectContaining({
|
|
405
405
|
url: "https://test.example",
|
|
406
|
-
transport: MCPTransport.
|
|
406
|
+
transport: MCPTransport.HTTP,
|
|
407
407
|
}));
|
|
408
408
|
});
|
|
409
409
|
it("should pass provider-level sampling handler to MCPClient.create", async () => {
|
|
@@ -424,7 +424,7 @@ describe("TamboMcpProvider handler support", () => {
|
|
|
424
424
|
expect(latest.length).toBe(1);
|
|
425
425
|
});
|
|
426
426
|
// Verify MCPClient.create was called with sampling handler
|
|
427
|
-
expect(createSpy).toHaveBeenCalledWith("https://test.example", MCPTransport.
|
|
427
|
+
expect(createSpy).toHaveBeenCalledWith("https://test.example", MCPTransport.HTTP, undefined, undefined, undefined, expect.objectContaining({
|
|
428
428
|
sampling: expect.any(Function),
|
|
429
429
|
}));
|
|
430
430
|
// Get the actual handler and verify it receives serverInfo
|
|
@@ -440,7 +440,7 @@ describe("TamboMcpProvider handler support", () => {
|
|
|
440
440
|
await passedHandlers.sampling(mockRequest, mockExtra);
|
|
441
441
|
expect(mockSamplingHandler).toHaveBeenCalledWith(mockRequest, mockExtra, expect.objectContaining({
|
|
442
442
|
url: "https://test.example",
|
|
443
|
-
transport: MCPTransport.
|
|
443
|
+
transport: MCPTransport.HTTP,
|
|
444
444
|
}));
|
|
445
445
|
});
|
|
446
446
|
it("should allow per-server handlers to override provider-level handlers", async () => {
|