@tambo-ai/react 0.66.1 → 0.66.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/use-current-message.d.ts +2 -0
- package/dist/hooks/use-current-message.d.ts.map +1 -1
- package/dist/hooks/use-current-message.js +1 -0
- package/dist/hooks/use-current-message.js.map +1 -1
- package/dist/hooks/use-current-message.test.js +5 -0
- package/dist/hooks/use-current-message.test.js.map +1 -1
- package/dist/model/component-metadata.d.ts +2 -2
- package/dist/model/component-metadata.d.ts.map +1 -1
- package/dist/model/component-metadata.js.map +1 -1
- package/dist/providers/tambo-interactable-provider-partial-updates.test.js +87 -87
- package/dist/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
- package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
- package/dist/providers/tambo-interactable-provider.js +46 -40
- package/dist/providers/tambo-interactable-provider.js.map +1 -1
- package/dist/providers/tambo-interactables-additional-context-edge-cases.test.js +8 -8
- package/dist/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -1
- package/dist/providers/tambo-interactables-additional-context.test.js +10 -10
- package/dist/providers/tambo-interactables-additional-context.test.js.map +1 -1
- package/dist/providers/tambo-registry-provider.test.js +28 -18
- package/dist/providers/tambo-registry-provider.test.js.map +1 -1
- package/dist/providers/tambo-registry-schema-compat.test.js +57 -28
- package/dist/providers/tambo-registry-schema-compat.test.js.map +1 -1
- package/dist/providers/tambo-thread-provider.test.js +21 -19
- package/dist/providers/tambo-thread-provider.test.js.map +1 -1
- package/dist/schema/alias.d.ts +3 -0
- package/dist/schema/alias.d.ts.map +1 -0
- package/dist/schema/alias.js +6 -0
- package/dist/schema/alias.js.map +1 -0
- package/dist/schema/json-schema.js +29 -29
- package/dist/schema/json-schema.js.map +1 -1
- package/dist/schema/schema.d.ts.map +1 -1
- package/dist/schema/schema.js +20 -9
- package/dist/schema/schema.js.map +1 -1
- package/dist/schema/schema.test.js +291 -3
- package/dist/schema/schema.test.js.map +1 -1
- package/dist/schema/standard-schema.js +8 -8
- package/dist/schema/standard-schema.js.map +1 -1
- package/dist/schema/validate.test.js +31 -31
- package/dist/schema/validate.test.js.map +1 -1
- package/dist/schema/zod.d.ts +1 -1
- package/dist/schema/zod.d.ts.map +1 -1
- package/dist/schema/zod.js +25 -24
- package/dist/schema/zod.js.map +1 -1
- package/dist/util/registry-validators.d.ts.map +1 -1
- package/dist/util/registry-validators.js +40 -0
- package/dist/util/registry-validators.js.map +1 -1
- package/dist/util/registry-validators.test.js +69 -0
- package/dist/util/registry-validators.test.js.map +1 -1
- package/dist/util/registry.d.ts +1 -5
- package/dist/util/registry.d.ts.map +1 -1
- package/dist/util/registry.js +1 -5
- package/dist/util/registry.js.map +1 -1
- package/dist/util/registry.test.js +80 -67
- package/dist/util/registry.test.js.map +1 -1
- package/esm/hooks/use-current-message.d.ts +2 -0
- package/esm/hooks/use-current-message.d.ts.map +1 -1
- package/esm/hooks/use-current-message.js +1 -0
- package/esm/hooks/use-current-message.js.map +1 -1
- package/esm/hooks/use-current-message.test.js +5 -0
- package/esm/hooks/use-current-message.test.js.map +1 -1
- package/esm/model/component-metadata.d.ts +2 -2
- package/esm/model/component-metadata.d.ts.map +1 -1
- package/esm/model/component-metadata.js.map +1 -1
- package/esm/providers/tambo-interactable-provider-partial-updates.test.js +1 -1
- package/esm/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
- package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
- package/esm/providers/tambo-interactable-provider.js +17 -11
- package/esm/providers/tambo-interactable-provider.js.map +1 -1
- package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js +1 -1
- package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -1
- package/esm/providers/tambo-interactables-additional-context.test.js +1 -1
- package/esm/providers/tambo-interactables-additional-context.test.js.map +1 -1
- package/esm/providers/tambo-registry-provider.test.js +16 -6
- package/esm/providers/tambo-registry-provider.test.js.map +1 -1
- package/esm/providers/tambo-registry-schema-compat.test.js +57 -28
- package/esm/providers/tambo-registry-schema-compat.test.js.map +1 -1
- package/esm/providers/tambo-thread-provider.test.js +8 -6
- package/esm/providers/tambo-thread-provider.test.js.map +1 -1
- package/esm/schema/alias.d.ts +3 -0
- package/esm/schema/alias.d.ts.map +1 -0
- package/esm/schema/alias.js +13 -0
- package/esm/schema/alias.js.map +1 -0
- package/esm/schema/json-schema.js +1 -1
- package/esm/schema/json-schema.js.map +1 -1
- package/esm/schema/schema.d.ts.map +1 -1
- package/esm/schema/schema.js +20 -9
- package/esm/schema/schema.js.map +1 -1
- package/esm/schema/schema.test.js +258 -3
- package/esm/schema/schema.test.js.map +1 -1
- package/esm/schema/standard-schema.js +1 -1
- package/esm/schema/standard-schema.js.map +1 -1
- package/esm/schema/validate.test.js +1 -1
- package/esm/schema/validate.test.js.map +1 -1
- package/esm/schema/zod.d.ts +1 -1
- package/esm/schema/zod.d.ts.map +1 -1
- package/esm/schema/zod.js +25 -24
- package/esm/schema/zod.js.map +1 -1
- package/esm/util/registry-validators.d.ts.map +1 -1
- package/esm/util/registry-validators.js +40 -0
- package/esm/util/registry-validators.js.map +1 -1
- package/esm/util/registry-validators.test.js +69 -0
- package/esm/util/registry-validators.test.js.map +1 -1
- package/esm/util/registry.d.ts +1 -5
- package/esm/util/registry.d.ts.map +1 -1
- package/esm/util/registry.js +1 -5
- package/esm/util/registry.js.map +1 -1
- package/esm/util/registry.test.js +80 -67
- package/esm/util/registry.test.js.map +1 -1
- package/package.json +1 -2
|
@@ -44,6 +44,8 @@ export interface TamboCurrentComponent {
|
|
|
44
44
|
interactableId?: string;
|
|
45
45
|
/** Description (only present for components wrapped with withInteractable) */
|
|
46
46
|
description?: string;
|
|
47
|
+
/** Thread ID from the message (only present when the component is part of a thread) */
|
|
48
|
+
threadId?: string;
|
|
47
49
|
}
|
|
48
50
|
/**
|
|
49
51
|
* Hook to access the current component information from the message context.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-current-message.d.ts","sourceRoot":"","sources":["../../src/hooks/use-current-message.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,sCAAsC,CAAC;AAI9C,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,EAAE,kBAAkB,CAAC;IAC5B,kFAAkF;IAClF,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;CAC7C;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAkBpE,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,OAAO,EAAE,kBAAkB,EAC3B,oBAAoB,CAAC,EAAE,oBAAoB,qBAU5C;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,0BAQlC,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,sCAAsC;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,kFAAkF;IAClF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,8EAA8E;IAC9E,WAAW,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"use-current-message.d.ts","sourceRoot":"","sources":["../../src/hooks/use-current-message.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,sCAAsC,CAAC;AAI9C,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,EAAE,kBAAkB,CAAC;IAC5B,kFAAkF;IAClF,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;CAC7C;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAkBpE,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,OAAO,EAAE,kBAAkB,EAC3B,oBAAoB,CAAC,EAAE,oBAAoB,qBAU5C;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,0BAQlC,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,sCAAsC;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,kFAAkF;IAClF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,8EAA8E;IAC9E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uFAAuF;IACvF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,wBAAwB,QAAO,qBAAqB,GAAG,IAiBnE,CAAC"}
|
|
@@ -116,6 +116,7 @@ const useTamboCurrentComponent = () => {
|
|
|
116
116
|
props: message.component?.props,
|
|
117
117
|
interactableId: message.interactableMetadata?.id ?? undefined,
|
|
118
118
|
description: message.interactableMetadata?.description ?? undefined,
|
|
119
|
+
threadId: message.threadId,
|
|
119
120
|
};
|
|
120
121
|
};
|
|
121
122
|
exports.useTamboCurrentComponent = useTamboCurrentComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-current-message.js","sourceRoot":"","sources":["../../src/hooks/use-current-message.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDb,oEAaC;AAjED,+CAAyD;AAMzD,MAAM,mBAAmB,GAAG,IAAA,qBAAa,EAA4B,IAAI,CAAC,CAAC;AAS3E;;;;;;;;GAQG;AACI,MAAM,oBAAoB,GAAwC,CAAC,EACxE,QAAQ,EACR,OAAO,EACP,oBAAoB,GACrB,EAAE,EAAE;IACH,uDAAuD;IACvD,MAAM,eAAe,GAAuB,oBAAoB;QAC9D,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,oBAAoB,EAAE;QACtC,CAAC,CAAC,OAAO,CAAC;IAEZ,8EAA8E;IAC9E,2EAA2E;IAC3E,6EAA6E;IAC7E,OAAO,CACL,8BAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,IAClE,QAAQ,CACoB,CAChC,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,oBAAoB,wBAkB/B;AAEF;;;;;;;GAOG;AACH,SAAgB,4BAA4B,CAC1C,QAAyB,EACzB,OAA2B,EAC3B,oBAA2C;IAE3C,OAAO,CACL,8BAAC,4BAAoB,IACnB,OAAO,EAAE,OAAO,EAChB,oBAAoB,EAAE,oBAAoB,IAEzC,QAAQ,CACY,CACxB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACI,MAAM,sBAAsB,GAAG,GAAG,EAAE;IACzC,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,mBAAmB,CAAC,CAAC;IAChD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AARW,QAAA,sBAAsB,0BAQjC;
|
|
1
|
+
{"version":3,"file":"use-current-message.js","sourceRoot":"","sources":["../../src/hooks/use-current-message.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDb,oEAaC;AAjED,+CAAyD;AAMzD,MAAM,mBAAmB,GAA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AO;QACL,aAAa,EACX,OAAO,CAAC,oBAAoB,EAAE,aAAa;YAC3C,OAAO,CAAC,SAAS,EAAE,aAAa;YAChC,SAAS;QACX,KAAK,EAAE,OAAO,CAAC,SAAS,EAAE,KAAwC;QAClE,cAAc,EAAE,OAAO,CAAC,oBAAoB,EAAE,EAAE,IAAI,SAAS;QAC7D,WAAW,EAAE,OAAO,CAAC,oBAAoB,EAAE,WAAW,IAAI,SAAS;QACnE,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,wBAAwB,4BAiBnC","sourcesContent":["\"use client\";\nimport React, { createContext, useContext } from \"react\";\nimport {\n InteractableMetadata,\n TamboThreadMessage,\n} from \"../model/generate-component-response\";\n\nconst TamboMessageContext = createContext<TamboThreadMessage | null>(null);\n\nexport interface TamboMessageProviderProps {\n children: React.ReactNode;\n message: TamboThreadMessage;\n /** Optional interactable metadata for components wrapped with withInteractable */\n interactableMetadata?: InteractableMetadata;\n}\n\n/**\n * Wraps all components, so that they can find what message they are in.\n * Also supports optional interactable metadata for components wrapped with withInteractable.\n * @param props - props for the TamboMessageProvider\n * @param props.children - The children to wrap\n * @param props.message - The message object\n * @param props.interactableMetadata - Optional interactable component metadata\n * @returns The wrapped component\n */\nexport const TamboMessageProvider: React.FC<TamboMessageProviderProps> = ({\n children,\n message,\n interactableMetadata,\n}) => {\n // Merge interactable metadata into message if provided\n const enhancedMessage: TamboThreadMessage = interactableMetadata\n ? { ...message, interactableMetadata }\n : message;\n\n // Use a unique key={...} to force a re-render when the message changes - this\n // make sure that if the rendered component is swapped into a tree (like if\n // you always show the last rendered component) then the state/etc is correct\n return (\n <TamboMessageContext.Provider value={enhancedMessage} key={message.id}>\n {children}\n </TamboMessageContext.Provider>\n );\n};\n\n/**\n * Wraps a component with a TamboMessageProvider - this allows the provider\n * to be used outside of a TSX file\n * @param children - The children to wrap\n * @param message - The message object\n * @param interactableMetadata - Optional interactable metadata\n * @returns The wrapped component\n */\nexport function wrapWithTamboMessageProvider(\n children: React.ReactNode,\n message: TamboThreadMessage,\n interactableMetadata?: InteractableMetadata,\n) {\n return (\n <TamboMessageProvider\n message={message}\n interactableMetadata={interactableMetadata}\n >\n {children}\n </TamboMessageProvider>\n );\n}\n\n/**\n * Hook used inside a component wrapped with TamboMessageProvider, to get\n * the current message.\n * @returns The current message that is used to render the component\n */\nexport const useTamboCurrentMessage = () => {\n const message = useContext(TamboMessageContext);\n if (!message) {\n throw new Error(\n \"useTamboCurrentMessage must be used within a TamboMessageProvider\",\n );\n }\n return message;\n};\n\n/**\n * Component info extracted from the current message and interactable context.\n * Provides a unified interface for accessing component metadata.\n */\nexport interface TamboCurrentComponent {\n /** Component name from the message */\n componentName?: string;\n /** Component props from the message */\n props?: Record<string, any>;\n /** Interactable ID (only present for components wrapped with withInteractable) */\n interactableId?: string;\n /** Description (only present for components wrapped with withInteractable) */\n description?: string;\n /** Thread ID from the message (only present when the component is part of a thread) */\n threadId?: string;\n}\n\n/**\n * Hook to access the current component information from the message context.\n * Provides a unified interface for both AI-generated and interactable components.\n *\n * **Use this hook when you need component metadata regardless of the context.**\n * @returns Component info including name, props, and interactable metadata if available, or null if used outside TamboMessageProvider\n * @example\n * ```tsx\n * function MyInlineEditor() {\n * const component = useTamboCurrentComponent();\n *\n * if (!component) return null; // Not inside a component\n *\n * return (\n * <div>\n * Editing: {component.componentName}\n * {component.interactableId && <span>ID: {component.interactableId}</span>}\n * </div>\n * );\n * }\n * ```\n */\nexport const useTamboCurrentComponent = (): TamboCurrentComponent | null => {\n const message = useContext(TamboMessageContext);\n\n if (!message) {\n return null;\n }\n\n return {\n componentName:\n message.interactableMetadata?.componentName ??\n message.component?.componentName ??\n undefined,\n props: message.component?.props as Record<string, any> | undefined,\n interactableId: message.interactableMetadata?.id ?? undefined,\n description: message.interactableMetadata?.description ?? undefined,\n threadId: message.threadId,\n };\n};\n"]}
|
|
@@ -152,6 +152,7 @@ describe("useTamboCurrentComponent", () => {
|
|
|
152
152
|
},
|
|
153
153
|
interactableId: undefined,
|
|
154
154
|
description: undefined,
|
|
155
|
+
threadId: "test-thread-id",
|
|
155
156
|
});
|
|
156
157
|
});
|
|
157
158
|
it("should return interactable metadata when provided", () => {
|
|
@@ -183,6 +184,7 @@ describe("useTamboCurrentComponent", () => {
|
|
|
183
184
|
},
|
|
184
185
|
interactableId: "interactable-456",
|
|
185
186
|
description: "Shows current weather",
|
|
187
|
+
threadId: "test-thread-id",
|
|
186
188
|
});
|
|
187
189
|
});
|
|
188
190
|
it("should prioritize interactableMetadata.componentName over message.component.componentName", () => {
|
|
@@ -221,6 +223,7 @@ describe("useTamboCurrentComponent", () => {
|
|
|
221
223
|
props: undefined,
|
|
222
224
|
interactableId: "interactable-only",
|
|
223
225
|
description: "Interactable only",
|
|
226
|
+
threadId: "test-thread-id",
|
|
224
227
|
});
|
|
225
228
|
});
|
|
226
229
|
it("should handle message with component but no interactable metadata", () => {
|
|
@@ -245,6 +248,7 @@ describe("useTamboCurrentComponent", () => {
|
|
|
245
248
|
},
|
|
246
249
|
interactableId: undefined,
|
|
247
250
|
description: undefined,
|
|
251
|
+
threadId: "test-thread-id",
|
|
248
252
|
});
|
|
249
253
|
});
|
|
250
254
|
it("should return undefined for all fields when message has neither component nor interactable metadata", () => {
|
|
@@ -258,6 +262,7 @@ describe("useTamboCurrentComponent", () => {
|
|
|
258
262
|
props: undefined,
|
|
259
263
|
interactableId: undefined,
|
|
260
264
|
description: undefined,
|
|
265
|
+
threadId: "test-thread-id",
|
|
261
266
|
});
|
|
262
267
|
});
|
|
263
268
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-current-message.test.js","sourceRoot":"","sources":["../../src/hooks/use-current-message.test.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAoE;AACpE,kDAA0B;AAK1B,+DAI+B;AAE/B,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,MAAM,iBAAiB,GAAG,CACxB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,EAAE,GAAG,EAAE;QAC7G,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC,CAAC,yDAAyD;QAE9F,MAAM,OAAO,GAAG,CAAC,EAAE,QAAQ,EAAiC,EAAE,EAAE,CAAC,CAC/D,8BAAC,0CAAoB,IAAC,OAAO,EAAE,OAAO,IAAG,QAAQ,CAAwB,CAC1E,CAAC;QAEF,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,kBAAU,EAAC,GAAG,EAAE,CAAC,IAAA,8CAAwB,GAAE,EAAE;YAC9D,OAAO;SACR,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;YAC7B,aAAa,EAAE,SAAS;YACxB,KAAK,EAAE,SAAS;YAChB,cAAc,EAAE,SAAS;YACzB,WAAW,EAAE,SAAS;SACvB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { render, renderHook, screen } from \"@testing-library/react\";\nimport React from \"react\";\nimport {\n InteractableMetadata,\n TamboThreadMessage,\n} from \"../model/generate-component-response\";\nimport {\n TamboMessageProvider,\n useTamboCurrentComponent,\n useTamboCurrentMessage,\n} from \"./use-current-message\";\n\ndescribe(\"TamboMessageProvider\", () => {\n const createMockMessage = (\n overrides: Partial<TamboThreadMessage> = {},\n ): TamboThreadMessage => ({\n id: \"test-message-id\",\n threadId: \"test-thread-id\",\n componentState: {},\n content: [{ type: \"text\", text: \"Test message\" }],\n createdAt: new Date().toISOString(),\n role: \"assistant\",\n ...overrides,\n });\n\n it(\"should provide message context to children\", () => {\n const message = createMockMessage();\n\n const TestComponent = () => {\n const currentMessage = useTamboCurrentMessage();\n return <div>{currentMessage.id}</div>;\n };\n\n render(\n <TamboMessageProvider message={message}>\n <TestComponent />\n </TamboMessageProvider>,\n );\n\n expect(screen.getByText(\"test-message-id\")).toBeInTheDocument();\n });\n\n it(\"should merge interactable metadata into message\", () => {\n const message = createMockMessage();\n const interactableMetadata: InteractableMetadata = {\n id: \"interactable-123\",\n componentName: \"TestComponent\",\n description: \"Test description\",\n };\n\n const TestComponent = () => {\n const currentMessage = useTamboCurrentMessage();\n return (\n <div>\n <span data-testid=\"message-id\">{currentMessage.id}</span>\n <span data-testid=\"interactable-id\">\n {currentMessage.interactableMetadata?.id}\n </span>\n </div>\n );\n };\n\n render(\n <TamboMessageProvider\n message={message}\n interactableMetadata={interactableMetadata}\n >\n <TestComponent />\n </TamboMessageProvider>,\n );\n\n expect(screen.getByTestId(\"message-id\")).toHaveTextContent(\n \"test-message-id\",\n );\n expect(screen.getByTestId(\"interactable-id\")).toHaveTextContent(\n \"interactable-123\",\n );\n });\n\n it(\"should work without interactable metadata\", () => {\n const message = createMockMessage();\n\n const TestComponent = () => {\n const currentMessage = useTamboCurrentMessage();\n return (\n <div>\n <span data-testid=\"has-metadata\">\n {currentMessage.interactableMetadata ? \"yes\" : \"no\"}\n </span>\n </div>\n );\n };\n\n render(\n <TamboMessageProvider message={message}>\n <TestComponent />\n </TamboMessageProvider>,\n );\n\n expect(screen.getByTestId(\"has-metadata\")).toHaveTextContent(\"no\");\n });\n\n it(\"should use message.id as key for re-renders\", () => {\n const message1 = createMockMessage({ id: \"message-1\" });\n const message2 = createMockMessage({ id: \"message-2\" });\n\n let renderCount = 0;\n const TestComponent = () => {\n renderCount++;\n const currentMessage = useTamboCurrentMessage();\n return <div>{currentMessage.id}</div>;\n };\n\n const { rerender } = render(\n <TamboMessageProvider message={message1}>\n <TestComponent />\n </TamboMessageProvider>,\n );\n\n expect(renderCount).toBe(1);\n expect(screen.getByText(\"message-1\")).toBeInTheDocument();\n\n // Change to new message - should force re-render due to key change\n rerender(\n <TamboMessageProvider message={message2}>\n <TestComponent />\n </TamboMessageProvider>,\n );\n\n expect(renderCount).toBe(2);\n expect(screen.getByText(\"message-2\")).toBeInTheDocument();\n });\n});\n\ndescribe(\"useTamboCurrentMessage\", () => {\n const createMockMessage = (\n overrides: Partial<TamboThreadMessage> = {},\n ): TamboThreadMessage => ({\n id: \"test-message-id\",\n threadId: \"test-thread-id\",\n componentState: {},\n content: [{ type: \"text\", text: \"Test message\" }],\n createdAt: new Date().toISOString(),\n role: \"assistant\",\n ...overrides,\n });\n\n it(\"should throw error when used outside TamboMessageProvider\", () => {\n // Suppress console.error for this test\n const consoleSpy = jest.spyOn(console, \"error\").mockImplementation();\n\n expect(() => {\n renderHook(() => useTamboCurrentMessage());\n }).toThrow(\n \"useTamboCurrentMessage must be used within a TamboMessageProvider\",\n );\n\n consoleSpy.mockRestore();\n });\n\n it(\"should return the current message\", () => {\n const message = createMockMessage();\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboMessageProvider message={message}>{children}</TamboMessageProvider>\n );\n\n const { result } = renderHook(() => useTamboCurrentMessage(), { wrapper });\n\n expect(result.current).toEqual(\n expect.objectContaining({\n id: \"test-message-id\",\n threadId: \"test-thread-id\",\n }),\n );\n });\n\n it(\"should return message with interactable metadata when provided\", () => {\n const message = createMockMessage();\n const interactableMetadata: InteractableMetadata = {\n id: \"interactable-123\",\n componentName: \"TestComponent\",\n description: \"Test description\",\n };\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboMessageProvider\n message={message}\n interactableMetadata={interactableMetadata}\n >\n {children}\n </TamboMessageProvider>\n );\n\n const { result } = renderHook(() => useTamboCurrentMessage(), { wrapper });\n\n expect(result.current.interactableMetadata).toEqual(interactableMetadata);\n });\n});\n\ndescribe(\"useTamboCurrentComponent\", () => {\n const createMockMessage = (\n overrides: Partial<TamboThreadMessage> = {},\n ): TamboThreadMessage => ({\n id: \"test-message-id\",\n threadId: \"test-thread-id\",\n componentState: {},\n content: [{ type: \"text\", text: \"Test message\" }],\n createdAt: new Date().toISOString(),\n role: \"assistant\",\n ...overrides,\n });\n\n it(\"should return null when used outside TamboMessageProvider\", () => {\n const { result } = renderHook(() => useTamboCurrentComponent());\n\n expect(result.current).toBeNull();\n });\n\n it(\"should return component info from message.component\", () => {\n const message = createMockMessage({\n component: {\n componentName: \"WeatherCard\",\n componentState: {},\n message: \"\",\n props: {\n city: \"San Francisco\",\n temperature: 72,\n },\n },\n });\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboMessageProvider message={message}>{children}</TamboMessageProvider>\n );\n\n const { result } = renderHook(() => useTamboCurrentComponent(), {\n wrapper,\n });\n\n expect(result.current).toEqual({\n componentName: \"WeatherCard\",\n props: {\n city: \"San Francisco\",\n temperature: 72,\n },\n interactableId: undefined,\n description: undefined,\n });\n });\n\n it(\"should return interactable metadata when provided\", () => {\n const message = createMockMessage({\n component: {\n componentName: \"WeatherCard\",\n componentState: {},\n message: \"\",\n props: {\n city: \"San Francisco\",\n temperature: 72,\n },\n },\n });\n\n const interactableMetadata: InteractableMetadata = {\n id: \"interactable-456\",\n componentName: \"WeatherCard\",\n description: \"Shows current weather\",\n };\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboMessageProvider\n message={message}\n interactableMetadata={interactableMetadata}\n >\n {children}\n </TamboMessageProvider>\n );\n\n const { result } = renderHook(() => useTamboCurrentComponent(), {\n wrapper,\n });\n\n expect(result.current).toEqual({\n componentName: \"WeatherCard\",\n props: {\n city: \"San Francisco\",\n temperature: 72,\n },\n interactableId: \"interactable-456\",\n description: \"Shows current weather\",\n });\n });\n\n it(\"should prioritize interactableMetadata.componentName over message.component.componentName\", () => {\n const message = createMockMessage({\n component: {\n componentName: \"OldComponentName\",\n componentState: {},\n message: \"\",\n props: {},\n },\n });\n\n const interactableMetadata: InteractableMetadata = {\n id: \"interactable-789\",\n componentName: \"NewComponentName\",\n description: \"New description\",\n };\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboMessageProvider\n message={message}\n interactableMetadata={interactableMetadata}\n >\n {children}\n </TamboMessageProvider>\n );\n\n const { result } = renderHook(() => useTamboCurrentComponent(), {\n wrapper,\n });\n\n expect(result.current?.componentName).toBe(\"NewComponentName\");\n });\n\n it(\"should handle message with only interactable metadata (no component)\", () => {\n const message = createMockMessage(); // No component field\n\n const interactableMetadata: InteractableMetadata = {\n id: \"interactable-only\",\n componentName: \"InteractableComponent\",\n description: \"Interactable only\",\n };\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboMessageProvider\n message={message}\n interactableMetadata={interactableMetadata}\n >\n {children}\n </TamboMessageProvider>\n );\n\n const { result } = renderHook(() => useTamboCurrentComponent(), {\n wrapper,\n });\n\n expect(result.current).toEqual({\n componentName: \"InteractableComponent\",\n props: undefined,\n interactableId: \"interactable-only\",\n description: \"Interactable only\",\n });\n });\n\n it(\"should handle message with component but no interactable metadata\", () => {\n const message = createMockMessage({\n component: {\n componentName: \"SimpleComponent\",\n componentState: {},\n message: \"\",\n props: {\n title: \"Hello\",\n },\n },\n });\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboMessageProvider message={message}>{children}</TamboMessageProvider>\n );\n\n const { result } = renderHook(() => useTamboCurrentComponent(), {\n wrapper,\n });\n\n expect(result.current).toEqual({\n componentName: \"SimpleComponent\",\n props: {\n title: \"Hello\",\n },\n interactableId: undefined,\n description: undefined,\n });\n });\n\n it(\"should return undefined for all fields when message has neither component nor interactable metadata\", () => {\n const message = createMockMessage(); // Minimal message with no component or interactable data\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboMessageProvider message={message}>{children}</TamboMessageProvider>\n );\n\n const { result } = renderHook(() => useTamboCurrentComponent(), {\n wrapper,\n });\n\n expect(result.current).toEqual({\n componentName: undefined,\n props: undefined,\n interactableId: undefined,\n description: undefined,\n });\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"use-current-message.test.js","sourceRoot":"","sources":["../../src/hooks/use-current-message.test.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAoE;AACpE,kDAA0B;AAK1B,+DAI+B;AAE/B,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,MAAM,iBAAiB,GAAG,CACxB,YAAyC,EAAE,EACvB,EAAE,C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AAQ,EAAE,gBAAgB;SAC3B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qGAAqG,EAAE,GAAG,EAAE;QAC7G,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC,CAAC,yDAAyD;QAE9F,MAAM,OAAO,GAAG,CAAC,EAAE,QAAQ,EAAiC,EAAE,EAAE,CAAC,CAC/D,8BAAC,0CAAoB,IAAC,OAAO,EAAE,OAAO,IAAG,QAAQ,CAAwB,CAC1E,CAAC;QAEF,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,kBAAU,EAAC,GAAG,EAAE,CAAC,IAAA,8CAAwB,GAAE,EAAE;YAC9D,OAAO;SACR,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;YAC7B,aAAa,EAAE,SAAS;YACxB,KAAK,EAAE,SAAS;YAChB,cAAc,EAAE,SAAS;YACzB,WAAW,EAAE,SAAS;YACtB,QAAQ,EAAE,gBAAgB;SAC3B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { render, renderHook, screen } from \"@testing-library/react\";\nimport React from \"react\";\nimport {\n InteractableMetadata,\n TamboThreadMessage,\n} from \"../model/generate-component-response\";\nimport {\n TamboMessageProvider,\n useTamboCurrentComponent,\n useTamboCurrentMessage,\n} from \"./use-current-message\";\n\ndescribe(\"TamboMessageProvider\", () => {\n const createMockMessage = (\n overrides: Partial<TamboThreadMessage> = {},\n ): TamboThreadMessage => ({\n id: \"test-message-id\",\n threadId: \"test-thread-id\",\n componentState: {},\n content: [{ type: \"text\", text: \"Test message\" }],\n createdAt: new Date().toISOString(),\n role: \"assistant\",\n ...overrides,\n });\n\n it(\"should provide message context to children\", () => {\n const message = createMockMessage();\n\n const TestComponent = () => {\n const currentMessage = useTamboCurrentMessage();\n return <div>{currentMessage.id}</div>;\n };\n\n render(\n <TamboMessageProvider message={message}>\n <TestComponent />\n </TamboMessageProvider>,\n );\n\n expect(screen.getByText(\"test-message-id\")).toBeInTheDocument();\n });\n\n it(\"should merge interactable metadata into message\", () => {\n const message = createMockMessage();\n const interactableMetadata: InteractableMetadata = {\n id: \"interactable-123\",\n componentName: \"TestComponent\",\n description: \"Test description\",\n };\n\n const TestComponent = () => {\n const currentMessage = useTamboCurrentMessage();\n return (\n <div>\n <span data-testid=\"message-id\">{currentMessage.id}</span>\n <span data-testid=\"interactable-id\">\n {currentMessage.interactableMetadata?.id}\n </span>\n </div>\n );\n };\n\n render(\n <TamboMessageProvider\n message={message}\n interactableMetadata={interactableMetadata}\n >\n <TestComponent />\n </TamboMessageProvider>,\n );\n\n expect(screen.getByTestId(\"message-id\")).toHaveTextContent(\n \"test-message-id\",\n );\n expect(screen.getByTestId(\"interactable-id\")).toHaveTextContent(\n \"interactable-123\",\n );\n });\n\n it(\"should work without interactable metadata\", () => {\n const message = createMockMessage();\n\n const TestComponent = () => {\n const currentMessage = useTamboCurrentMessage();\n return (\n <div>\n <span data-testid=\"has-metadata\">\n {currentMessage.interactableMetadata ? \"yes\" : \"no\"}\n </span>\n </div>\n );\n };\n\n render(\n <TamboMessageProvider message={message}>\n <TestComponent />\n </TamboMessageProvider>,\n );\n\n expect(screen.getByTestId(\"has-metadata\")).toHaveTextContent(\"no\");\n });\n\n it(\"should use message.id as key for re-renders\", () => {\n const message1 = createMockMessage({ id: \"message-1\" });\n const message2 = createMockMessage({ id: \"message-2\" });\n\n let renderCount = 0;\n const TestComponent = () => {\n renderCount++;\n const currentMessage = useTamboCurrentMessage();\n return <div>{currentMessage.id}</div>;\n };\n\n const { rerender } = render(\n <TamboMessageProvider message={message1}>\n <TestComponent />\n </TamboMessageProvider>,\n );\n\n expect(renderCount).toBe(1);\n expect(screen.getByText(\"message-1\")).toBeInTheDocument();\n\n // Change to new message - should force re-render due to key change\n rerender(\n <TamboMessageProvider message={message2}>\n <TestComponent />\n </TamboMessageProvider>,\n );\n\n expect(renderCount).toBe(2);\n expect(screen.getByText(\"message-2\")).toBeInTheDocument();\n });\n});\n\ndescribe(\"useTamboCurrentMessage\", () => {\n const createMockMessage = (\n overrides: Partial<TamboThreadMessage> = {},\n ): TamboThreadMessage => ({\n id: \"test-message-id\",\n threadId: \"test-thread-id\",\n componentState: {},\n content: [{ type: \"text\", text: \"Test message\" }],\n createdAt: new Date().toISOString(),\n role: \"assistant\",\n ...overrides,\n });\n\n it(\"should throw error when used outside TamboMessageProvider\", () => {\n // Suppress console.error for this test\n const consoleSpy = jest.spyOn(console, \"error\").mockImplementation();\n\n expect(() => {\n renderHook(() => useTamboCurrentMessage());\n }).toThrow(\n \"useTamboCurrentMessage must be used within a TamboMessageProvider\",\n );\n\n consoleSpy.mockRestore();\n });\n\n it(\"should return the current message\", () => {\n const message = createMockMessage();\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboMessageProvider message={message}>{children}</TamboMessageProvider>\n );\n\n const { result } = renderHook(() => useTamboCurrentMessage(), { wrapper });\n\n expect(result.current).toEqual(\n expect.objectContaining({\n id: \"test-message-id\",\n threadId: \"test-thread-id\",\n }),\n );\n });\n\n it(\"should return message with interactable metadata when provided\", () => {\n const message = createMockMessage();\n const interactableMetadata: InteractableMetadata = {\n id: \"interactable-123\",\n componentName: \"TestComponent\",\n description: \"Test description\",\n };\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboMessageProvider\n message={message}\n interactableMetadata={interactableMetadata}\n >\n {children}\n </TamboMessageProvider>\n );\n\n const { result } = renderHook(() => useTamboCurrentMessage(), { wrapper });\n\n expect(result.current.interactableMetadata).toEqual(interactableMetadata);\n });\n});\n\ndescribe(\"useTamboCurrentComponent\", () => {\n const createMockMessage = (\n overrides: Partial<TamboThreadMessage> = {},\n ): TamboThreadMessage => ({\n id: \"test-message-id\",\n threadId: \"test-thread-id\",\n componentState: {},\n content: [{ type: \"text\", text: \"Test message\" }],\n createdAt: new Date().toISOString(),\n role: \"assistant\",\n ...overrides,\n });\n\n it(\"should return null when used outside TamboMessageProvider\", () => {\n const { result } = renderHook(() => useTamboCurrentComponent());\n\n expect(result.current).toBeNull();\n });\n\n it(\"should return component info from message.component\", () => {\n const message = createMockMessage({\n component: {\n componentName: \"WeatherCard\",\n componentState: {},\n message: \"\",\n props: {\n city: \"San Francisco\",\n temperature: 72,\n },\n },\n });\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboMessageProvider message={message}>{children}</TamboMessageProvider>\n );\n\n const { result } = renderHook(() => useTamboCurrentComponent(), {\n wrapper,\n });\n\n expect(result.current).toEqual({\n componentName: \"WeatherCard\",\n props: {\n city: \"San Francisco\",\n temperature: 72,\n },\n interactableId: undefined,\n description: undefined,\n threadId: \"test-thread-id\",\n });\n });\n\n it(\"should return interactable metadata when provided\", () => {\n const message = createMockMessage({\n component: {\n componentName: \"WeatherCard\",\n componentState: {},\n message: \"\",\n props: {\n city: \"San Francisco\",\n temperature: 72,\n },\n },\n });\n\n const interactableMetadata: InteractableMetadata = {\n id: \"interactable-456\",\n componentName: \"WeatherCard\",\n description: \"Shows current weather\",\n };\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboMessageProvider\n message={message}\n interactableMetadata={interactableMetadata}\n >\n {children}\n </TamboMessageProvider>\n );\n\n const { result } = renderHook(() => useTamboCurrentComponent(), {\n wrapper,\n });\n\n expect(result.current).toEqual({\n componentName: \"WeatherCard\",\n props: {\n city: \"San Francisco\",\n temperature: 72,\n },\n interactableId: \"interactable-456\",\n description: \"Shows current weather\",\n threadId: \"test-thread-id\",\n });\n });\n\n it(\"should prioritize interactableMetadata.componentName over message.component.componentName\", () => {\n const message = createMockMessage({\n component: {\n componentName: \"OldComponentName\",\n componentState: {},\n message: \"\",\n props: {},\n },\n });\n\n const interactableMetadata: InteractableMetadata = {\n id: \"interactable-789\",\n componentName: \"NewComponentName\",\n description: \"New description\",\n };\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboMessageProvider\n message={message}\n interactableMetadata={interactableMetadata}\n >\n {children}\n </TamboMessageProvider>\n );\n\n const { result } = renderHook(() => useTamboCurrentComponent(), {\n wrapper,\n });\n\n expect(result.current?.componentName).toBe(\"NewComponentName\");\n });\n\n it(\"should handle message with only interactable metadata (no component)\", () => {\n const message = createMockMessage(); // No component field\n\n const interactableMetadata: InteractableMetadata = {\n id: \"interactable-only\",\n componentName: \"InteractableComponent\",\n description: \"Interactable only\",\n };\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboMessageProvider\n message={message}\n interactableMetadata={interactableMetadata}\n >\n {children}\n </TamboMessageProvider>\n );\n\n const { result } = renderHook(() => useTamboCurrentComponent(), {\n wrapper,\n });\n\n expect(result.current).toEqual({\n componentName: \"InteractableComponent\",\n props: undefined,\n interactableId: \"interactable-only\",\n description: \"Interactable only\",\n threadId: \"test-thread-id\",\n });\n });\n\n it(\"should handle message with component but no interactable metadata\", () => {\n const message = createMockMessage({\n component: {\n componentName: \"SimpleComponent\",\n componentState: {},\n message: \"\",\n props: {\n title: \"Hello\",\n },\n },\n });\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboMessageProvider message={message}>{children}</TamboMessageProvider>\n );\n\n const { result } = renderHook(() => useTamboCurrentComponent(), {\n wrapper,\n });\n\n expect(result.current).toEqual({\n componentName: \"SimpleComponent\",\n props: {\n title: \"Hello\",\n },\n interactableId: undefined,\n description: undefined,\n threadId: \"test-thread-id\",\n });\n });\n\n it(\"should return undefined for all fields when message has neither component nor interactable metadata\", () => {\n const message = createMockMessage(); // Minimal message with no component or interactable data\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboMessageProvider message={message}>{children}</TamboMessageProvider>\n );\n\n const { result } = renderHook(() => useTamboCurrentComponent(), {\n wrapper,\n });\n\n expect(result.current).toEqual({\n componentName: undefined,\n props: undefined,\n interactableId: undefined,\n description: undefined,\n threadId: \"test-thread-id\",\n });\n });\n});\n"]}
|
|
@@ -371,7 +371,7 @@ export interface RegisterToolFn {
|
|
|
371
371
|
*/
|
|
372
372
|
<Args extends Zod4FunctionArgs, Returns extends Zod4FunctionReturns>(tool: TamboToolZod4Function<Args, Returns>, warnOnOverwrite?: boolean): void;
|
|
373
373
|
(tool: TamboToolWithToolSchema, warnOnOverwrite?: boolean): void;
|
|
374
|
-
<Args extends StandardSchemaV1, Returns extends StandardSchemaV1>(tool:
|
|
374
|
+
<Args extends StandardSchemaV1, Returns extends StandardSchemaV1>(tool: TamboToolStandardSchema<Args, Returns>, warnOnOverwrite?: boolean): void;
|
|
375
375
|
<Args extends any[], Returns = any>(tool: TamboToolJSONSchema<Args, Returns>, warnOnOverwrite?: boolean): void;
|
|
376
376
|
(tool: TamboToolUnknown, warnOnOverwrite?: boolean): void;
|
|
377
377
|
(tool: TamboTool, warnOnOverwrite?: boolean): void;
|
|
@@ -404,7 +404,7 @@ export interface DefineToolFn {
|
|
|
404
404
|
* @param tool The tool definition to register
|
|
405
405
|
* @returns The registered tool definition
|
|
406
406
|
*/
|
|
407
|
-
<Input extends StandardSchemaV1, Output extends StandardSchemaV1>(tool: TamboToolStandardSchema<Input, Output>):
|
|
407
|
+
<Input extends StandardSchemaV1, Output extends StandardSchemaV1>(tool: TamboToolStandardSchema<Input, Output>): TamboToolStandardSchema<Input, Output>;
|
|
408
408
|
/**
|
|
409
409
|
* Provides type safety for defining a Tambo Tool.
|
|
410
410
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-metadata.d.ts","sourceRoot":"","sources":["../../src/model/component-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EACL,WAAW,IAAI,YAAY,EAC3B,QAAQ,IAAI,gBAAgB,EA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,CAAC,SAAS,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,EACvB,IAAI,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,GAC9B,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;CAC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-metadata.js","sourceRoot":"","sources":["../../src/model/component-metadata.ts"],"names":[],"mappings":"","sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { JSONSchema7 } from \"json-schema\";\nimport { ComponentType } from \"react\";\nimport {\n ZodFunction as Zod3Function,\n ZodTuple as Zod3FunctionArgs,\n ZodType as Zod3FunctionReturns,\n infer as Zod3Infer,\n} from \"zod/v3\";\nimport {\n $ZodFunction as Zod4Function,\n $ZodFunctionArgs as Zod4FunctionArgs,\n $ZodType as Zod4FunctionReturns,\n infer as Zod4Infer,\n} from \"zod/v4/core\";\n\n/**\n * A schema type that accepts either a Standard Schema compliant validator\n * (e.g., Zod, Valibot, ArkType) or a raw JSON Schema object.\n *\n * Standard Schema is a specification that provides a unified interface for\n * TypeScript validation libraries. Libraries like Zod implement this spec,\n * allowing us to accept any compliant validator without depending on a specific library.\n * @see https://standardschema.dev/\n */\nexport type SupportedSchema = StandardSchemaV1 | JSONSchema7;\n\n/** Extension of the ToolParameters interface from Tambo AI to include JSONSchema definition */\nexport type ParameterSpec = TamboAI.ToolParameters & {\n schema?: JSONSchema7;\n};\n\n/**\n * Extends the base ContextTool interface from Tambo AI to include schema information\n * for parameter validation.\n */\nexport interface ComponentContextToolMetadata\n extends TamboAI.ComponentContextToolMetadata {\n parameters: ParameterSpec[];\n}\n\nexport interface ComponentContextTool {\n getComponentContext: (...args: any[]) => Promise<any>;\n definition: ComponentContextToolMetadata;\n}\n\nexport interface RegisteredComponent extends TamboAI.AvailableComponent {\n component: ComponentType<any>;\n loadingComponent?: ComponentType<any>;\n}\n\nexport type ComponentRegistry = Record<string, RegisteredComponent>;\n\nexport type TamboToolRegistry = Record<\n string,\n TamboTool | TamboToolWithToolSchema\n>;\n\n/**\n * A JSON Schema that is compatible with the MCP.\n * This is a simplified JSON Schema that is compatible with the MCPClient and the tool's inputSchema.\n *\n * Do not export this type from the SDK.\n */\nexport type JSONSchemaLite = JSONSchema7 & {\n description?: string;\n};\n\ntype MaybeAsync<T> = T | Promise<T>;\n\n/**\n * TamboTool is a type that represents a tool that can be registered with Tambo.\n *\n * It is preferable to use the `defineTool` helper function to create tools, as\n * it provides better type inference and safety.\n * @example\n * ```ts\n * import { TamboTool, defineTool } from \"@tambo-ai/react\";\n * import { z } from \"zod\";\n *\n * const locationToLatLon = defineTool({\n * name: \"location_to_latlon\",\n * description:\n * \"Fetch latitude and longitude from a location string. Returns an object with 'lat' and 'lon' properties.\",\n * tool: async ({ location }) => getLatLonFromLocation(location),\n * inputSchema: z.object({\n * location: z.string(),\n * }),\n * outputSchema: z.object({\n * lat: z.number(),\n * lon: z.number(),\n * }),\n * });\n * ```\n * Alternatively, you manually construct a TamboTool with type safety by passing\n * the expected parameter and return types as generics:\n * ```ts\n * import { TamboTool } from \"@tambo-ai/react\";\n * import { z } from \"zod\";\n *\n * const locationToLatLon: TamboTool<{ location: string }, { lat: number; lon: number }> = {\n * name: \"location_to_latlon\",\n * description:\n * \"Fetch latitude and longitude from a location string. Returns an object with 'lat' and 'lon' properties.\",\n * tool: async ({ location }) => getLatLonFromLocation(location),\n * inputSchema: z.object({\n * location: z.string(),\n * }),\n * outputSchema: z.object({\n * lat: z.number(),\n * lon: z.number(),\n * }),\n * });\n * ```\n */\nexport interface TamboTool<\n Params = any,\n Returns = any,\n Rest extends any[] = [],\n> {\n /**\n * Unique identifier for the tool\n */\n name: string;\n /**\n * Description of what the tool does - used by AI to determine when to use it\n */\n description: string;\n /**\n * Optional human-readable name of the tool for display purposes.\n */\n title?: string;\n /**\n * Optional properties describing tool behavior\n */\n annotations?: {\n /**\n * An array indicating the intended audience(s) for this resource. Valid\n * values are \"user\" and \"assistant\". For example, [\"user\", \"assistant\"]\n * indicates content useful for both.\n */\n audience: (\"user\" | \"assistant\")[];\n /**\n * A number from 0.0 to 1.0 indicating the importance of this resource. A\n * value of 1 means \"most important\" (effectively required), while 0 means\n * \"least important\" (entirely optional).\n */\n priority: number;\n /**\n * An ISO 8601 formatted timestamp indicating when the resource was last\n * modified (e.g., \"2025-01-12T15:00:58Z\").\n */\n lastModified: string;\n };\n\n /**\n * The function that implements the tool's logic. This function will be called\n * by Tambo when the model decides to invoke the tool.\n * @param params - The input parameters for the tool. These are validated\n * against the inputSchema before being passed so are guaranteed to be correct\n * when called by the model.\n * @returns The result of the tool execution, which can be a value or a\n * Promise resolving to a value\n */\n tool: (params: Params, ...rest: Rest) => MaybeAsync<Returns>;\n\n /**\n * The schema for the tool's input parameters. This can be a validator from\n * any Standard Schema compliant library (Zod, Valibot, ArkType, etc.) or a\n * raw JSON Schema object.\n *\n * This schema is used to validate and parse the parameters before passing\n * them to the tool function.\n */\n inputSchema: SupportedSchema | unknown;\n\n /**\n * The schema for the tool's output/return value. This can be any Standard Schema\n * compliant validator (Zod, Valibot, ArkType, etc.) or a raw JSON Schema object.\n *\n * This is used to inform the model about the structure of the tool's return value\n * and is not used for runtime validation at this stage.\n */\n outputSchema: SupportedSchema | unknown;\n\n /**\n * Optional function to transform the tool's return value into an array of content parts.\n * If not provided, the return value will be converted to a string and wrapped in a text content part.\n * @param result - The result returned by the tool function\n * @returns An array of content parts to be sent back to the AI\n */\n transformToContent?: (\n result: any,\n ) =>\n | Promise<TamboAI.Beta.Threads.ChatCompletionContentPart[]>\n | TamboAI.Beta.Threads.ChatCompletionContentPart[];\n}\n\n/**\n * Simplified interface for tools using the deprecated toolSchema format.\n * This interface uses simple `any` types to avoid complex type instantiation.\n * Use `defineTamboTool()` for full type inference when creating tools.\n * @deprecated Use TamboTool with `inputSchema`/`outputSchema` instead.\n */\nexport type TamboToolWithToolSchema<\n Args extends any[] = any[],\n Returns = any,\n> = Omit<TamboTool, \"tool\" | \"inputSchema\" | \"outputSchema\"> & {\n tool: (...args: Args) => MaybeAsync<Returns>;\n /** @deprecated Use `inputSchema`/`outputSchema` properties instead. */\n toolSchema: unknown;\n};\n\n// NOTE(lachieh): this comment mirrors the one from `TamboTool` above\n/**\n * TamboTool is a type that represents a tool that can be registered with Tambo.\n *\n * It is preferable to use the `defineTool` helper function to create tools, as\n * it provides better type inference and safety.\n * @example\n * ```ts\n * import { TamboTool, defineTool } from \"@tambo-ai/react\";\n * import { z } from \"zod\";\n *\n * const locationToLatLon = defineTool({\n * name: \"location_to_latlon\",\n * description:\n * \"Fetch latitude and longitude from a location string. Returns an object with 'lat' and 'lon' properties.\",\n * tool: async ({ location }) => getLatLonFromLocation(location),\n * inputSchema: z.object({\n * location: z.string(),\n * }),\n * outputSchema: z.object({\n * lat: z.number(),\n * lon: z.number(),\n * }),\n * });\n * ```\n * Alternatively, you manually construct a TamboTool with type safety by passing\n * the expected parameter and return types as generics:\n * ```ts\n * import { TamboTool } from \"@tambo-ai/react\";\n * import { z } from \"zod\";\n *\n * const locationToLatLon: TamboTool<{ location: string }, { lat: number; lon: number }> = {\n * name: \"location_to_latlon\",\n * description:\n * \"Fetch latitude and longitude from a location string. Returns an object with 'lat' and 'lon' properties.\",\n * tool: async ({ location }) => getLatLonFromLocation(location),\n * inputSchema: z.object({\n * location: z.string(),\n * }),\n * outputSchema: z.object({\n * lat: z.number(),\n * lon: z.number(),\n * }),\n * });\n * ```\n */\nexport type TamboToolBase<Params = any, Returns = any> =\n | TamboToolWithToolSchema\n | TamboTool<Params, Returns>;\n\n/**\n * A tool that uses JSON Schema compliant input and output schemas.\n * This does not provide type safety for the tool's parameters and return value.\n * @internal\n */\nexport type TamboToolJSONSchema<\n Args extends unknown[] = unknown[],\n Returns = unknown,\n> = Omit<TamboTool<Args, Returns>, \"tool\" | \"inputSchema\" | \"outputSchema\"> & {\n tool: (...args: Args) => MaybeAsync<Returns>;\n inputSchema: JSONSchemaLite;\n outputSchema: JSONSchemaLite;\n};\n\n/**\n * A tool that could not be matched to any known schema types.\n * This means type safety cannot be guaranteed.\n * @internal\n */\nexport type TamboToolUnknown = Omit<\n TamboTool,\n \"tool\" | \"inputSchema\" | \"outputSchema\"\n> & {\n tool: (...args: unknown[]) => MaybeAsync<unknown>;\n inputSchema: unknown;\n outputSchema: unknown;\n};\n\n/**\n * A tool that uses Standard Schema compliant input and output schemas.\n * This provides full type safety for the tool's parameters and return value.\n * @internal\n */\nexport type TamboToolStandardSchema<\n Input extends StandardSchemaV1 = StandardSchemaV1,\n Output extends StandardSchemaV1 = StandardSchemaV1,\n> = Omit<\n TamboTool<\n StandardSchemaV1.InferOutput<Input>,\n StandardSchemaV1.InferOutput<Output>\n >,\n \"tool\" | \"inputSchema\" | \"outputSchema\"\n> & {\n tool: (\n ...args: [StandardSchemaV1.InferOutput<Input>]\n ) => MaybeAsync<StandardSchemaV1.InferOutput<Output>>;\n inputSchema: Input;\n outputSchema: Output;\n};\n\ntype TamboToolZod3Function<\n Args extends Zod3FunctionArgs,\n Returns extends Zod3FunctionReturns,\n> = Omit<\n TamboToolWithToolSchema<Zod3Infer<Args>, Zod3Infer<Returns>>,\n \"toolSchema\"\n> & {\n tool: (...args: Zod3Infer<Args>) => MaybeAsync<Zod3Infer<Returns>>;\n /** @deprecated Use `inputSchema`/`outputSchema` properties instead. */\n toolSchema: Zod3Function<Args, Returns>;\n};\n\ntype TamboToolZod4Function<\n Args extends Zod4FunctionArgs,\n Returns extends Zod4FunctionReturns,\n> = Omit<\n TamboToolWithToolSchema<Zod4Infer<Args>, Zod4Infer<Returns>>,\n \"toolSchema\"\n> & {\n tool: (...args: Zod4Infer<Args>) => MaybeAsync<Zod4Infer<Returns>>;\n /** @deprecated Use `inputSchema`/`outputSchema` properties instead. */\n toolSchema: Zod4Function<Args, Returns>;\n};\n\nexport type TamboToolAssociations = Record<string, string[]>;\n/**\n * A component that can be registered with the TamboRegistryProvider.\n */\n\nexport interface TamboComponent {\n /** The name of the component */\n name: string;\n /** The description of the component */\n description: string;\n /**\n * The React component to render.\n *\n * Make sure to pass the Component itself, not an instance of the component. For example,\n * if you have a component like this:\n *\n * ```tsx\n * const MyComponent = () => {\n * return <div>My Component</div>;\n * };\n * ```\n *\n * You should pass the `Component`:\n *\n * ```tsx\n * const components = [MyComponent];\n * <TamboRegistryProvider components={components} />\n * ```\n */\n component: ComponentType<any>;\n\n /**\n * Schema describing the component's props. Accepts any Standard Schema\n * compliant validator (Zod, Valibot, ArkType, etc.) or a raw JSON Schema\n * object.\n *\n * Either this or propsDefinition must be provided, but not both.\n * @example\n * ```typescript\n * import { z } from \"zod/v4\";\n *\n * const component: TamboComponent = {\n * name: \"MyComponent\",\n * description: \"A sample component\",\n * component: MyComponent,\n * propsSchema: z.object({\n * title: z.string(),\n * count: z.number().optional()\n * })\n * };\n * ```\n */\n propsSchema?: SupportedSchema;\n /**\n * The props definition of the component as a JSON object.\n * Either this or propsSchema must be provided, but not both.\n * @deprecated Use propsSchema instead.\n */\n propsDefinition?: any;\n /** The loading component to render while the component is loading */\n loadingComponent?: ComponentType<any>;\n /** The tools that are associated with the component */\n associatedTools?: (TamboTool | TamboToolWithToolSchema)[];\n}\n\nexport interface RegisterToolsFn {\n /**\n * Registers one or more Tambo tools.\n * @param tools - An array of Tambo tools to register\n */\n (tools: TamboTool[]): void;\n (tools: (TamboTool | TamboToolWithToolSchema)[]): void;\n}\n\n/**\n * Function interface for registering a Tambo tool with full type inference.\n * This function has multiple overloads to handle different schema types. This\n * is a utility function and does not perform any runtime logic.\n */\nexport interface RegisterToolFn {\n /**\n * @deprecated Use `inputSchema`/`outputSchema` instead. toolSchema is deprecated\n * and will be removed in future versions.\n * @example\n * ```diff\n * import { z } from \"zod/v3\";\n * const myTool = defineTamboTool({\n * ...\n * - toolSchema: z.function()\n * - .arguments(z.tuple([z.string()]))\n * - .returns(z.number()),\n * + inputSchema: z.object({\n * + input: z.string().describe(\"Input description\")\n * + }),\n * + outputSchema: z.number().describe(\"Result description\"),\n * });\n */\n <Args extends Zod3FunctionArgs, Returns extends Zod3FunctionReturns>(\n tool: TamboToolZod3Function<Args, Returns>,\n warnOnOverwrite?: boolean,\n ): void;\n /**\n * @deprecated Use `inputSchema`/`outputSchema` instead. toolSchema is deprecated\n * and will be removed in future versions.\n * @example\n * ```diff\n * import { z } from \"zod/v4\";\n * const myTool = defineTamboTool({\n * ...\n * - toolSchema: z.function({\n * - input: z.tuple([z.string()]),\n * - output: z.number(),\n * - }),\n * + inputSchema: z.object({\n * + input: z.string().describe(\"Input description\")\n * + }),\n * + outputSchema: z.number().describe(\"Result description\"),\n * });\n */\n <Args extends Zod4FunctionArgs, Returns extends Zod4FunctionReturns>(\n tool: TamboToolZod4Function<Args, Returns>,\n warnOnOverwrite?: boolean,\n ): void;\n (tool: TamboToolWithToolSchema, warnOnOverwrite?: boolean): void;\n <Args extends StandardSchemaV1, Returns extends StandardSchemaV1>(\n tool: TamboTool<\n StandardSchemaV1.InferOutput<Args>,\n StandardSchemaV1.InferOutput<Returns>\n >,\n warnOnOverwrite?: boolean,\n ): void;\n <Args extends any[], Returns = any>(\n tool: TamboToolJSONSchema<Args, Returns>,\n warnOnOverwrite?: boolean,\n ): void;\n (tool: TamboToolUnknown, warnOnOverwrite?: boolean): void;\n (tool: TamboTool, warnOnOverwrite?: boolean): void;\n}\n\n/**\n * Function interface for defining a Tambo tool with full type inference. This\n * function has multiple overloads to handle different schema types. This is a\n * utility function and does not perform any runtime logic.\n */\nexport interface DefineToolFn {\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * Tambo uses the [standard-schema.dev](https://standard-schema.dev) spec which means you can use any Standard Schema\n * compliant validator (Zod, Valibot, ArkType, etc.). This definition ensures the input and output types are correctly\n * inferred from the provided schemas.\n * @example\n * ```typescript\n * import { z } from \"zod/v4\";\n *\n * const myTool = defineTamboTool({\n * // ...\n * inputSchema: z.object({\n * input: z.string().describe(\"Input description\")\n * }),\n * outputSchema: z.number().describe(\"Result description\"),\n * });\n * ```\n * @see {@link https://standard-schema.dev/}\n * @param tool The tool definition to register\n * @returns The registered tool definition\n */\n <Input extends StandardSchemaV1, Output extends StandardSchemaV1>(\n tool: TamboToolStandardSchema<Input, Output>,\n ): TamboTool<\n StandardSchemaV1.InferOutput<Input>,\n StandardSchemaV1.InferOutput<Output>\n >;\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * This tool uses the deprecated `toolSchema` format which uses a zod function schema. If you are using a validation\n * library that implements StandardSchema.dev, please switch to using separate `inputSchema` and `outputSchema`\n * properties instead. See example below.\n * @example\n * ```diff\n * import { z } from \"zod/v4\";\n *\n * const myTool = defineTamboTool({\n * // ...\n * - toolSchema: z.function({\n * - input: z.tuple([z.string()]),\n * - output: z.number(),\n * - })\n * + inputSchema: z.object({\n * + input: z.string().describe(\"Input description\")\n * + }),\n * + outputSchema: z.number().describe(\"Result description\"),\n * });\n * @see {@link https://standard-schema.dev/}\n * @param tool The tool definition to register\n * @returns The registered tool definition\n * @deprecated Using `toolSchema` is deprecated. Please use separate `inputSchema` and `outputSchema` properties instead.\n * Note that use of `toolSchema` will be removed in a future release.\n * ```\n */\n <Args extends Zod3FunctionArgs, Returns extends Zod3FunctionReturns>(\n tool: TamboToolZod3Function<Args, Returns>,\n ): TamboToolZod3Function<Args, Returns>;\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * This tool uses the deprecated `toolSchema` format which uses a zod function schema. If you are using a validation\n * library that implements standard-schema.dev, please switch to using separate `inputSchema` and `outputSchema`\n * properties instead. See example below.\n * @param tool The tool definition to register\n * @returns The registered tool definition\n * @deprecated Using `toolSchema` is deprecated. Please use separate `inputSchema` and `outputSchema` properties instead.\n * Note that use of `toolSchema` will be removed in a future release.\n * @example\n * ```diff\n * import { z } from \"zod/v4\";\n *\n * const myTool = defineTamboTool({\n * // ...\n * - toolSchema: z.function({\n * - input: z.tuple([z.string()]),\n * - output: z.number(),\n * - })\n * + inputSchema: z.object({\n * + input: z.string().describe(\"Input description\")\n * + }),\n * + outputSchema: z.number().describe(\"Result description\"),\n * });\n * ```\n */\n <Args extends Zod4FunctionArgs, Returns extends Zod4FunctionReturns>(\n tool: TamboToolZod4Function<Args, Returns>,\n ): TamboToolZod4Function<Args, Returns>;\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * This tool uses the deprecated `toolSchema` property which uses a zod function schema. If you are using a validation\n * library that implements standard-schema.dev, please switch to using separate `inputSchema` and `outputSchema`\n * properties instead. See example below.\n * @param tool The tool definition to register\n * @returns The registered tool definition\n * @deprecated Using `toolSchema` is deprecated. Please use separate `inputSchema` and `outputSchema` properties instead.\n * Note that use of `toolSchema` will be removed in a future release.\n * @example\n * ```diff\n * import { z } from \"zod/v4\";\n *\n * const myTool = defineTamboTool({\n * // ...\n * - toolSchema: { ... }\n * + inputSchema: z.object({ ... }),\n * + outputSchema: z.number(),\n * });\n * ```\n */\n (tool: TamboToolWithToolSchema): TamboToolWithToolSchema;\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * This tool definition matched to JSON Schema input and output schemas which allows does not guarantee type\n * safety. If you are using a validation library that implements\n * [Standard Schema](https://standardschema.dev/#what-tools-frameworks-accept-speccompliant-schemas), please ensure\n * your schemas are correctly typed.\n * @see {@link https://standard-schema.dev/}\n * @param tool The tool definition to register\n * @returns The registered tool definition\n */\n <I extends any[], O = any>(\n tool: TamboToolJSONSchema<I, O>,\n ): TamboToolJSONSchema<I, O>;\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * This tool definition could not be matched to any known schema types which means type safety cannot be\n * guaranteed. If you are using a validation library that implements\n * [Standard Schema](https://standardschema.dev/#what-tools-frameworks-accept-speccompliant-schemas), please ensure\n * your schemas are correctly typed.\n * @example\n * ```typescript\n * const myTool = defineTamboTool({\n * name: \"myTool\",\n * description: \"An example tool\",\n * tool: (input) => { ... },\n * inputSchema: yourInputSchema,\n * outputSchema: yourOutputSchema,\n * });\n * @param tool The tool definition to register\n * @returns The registered tool definition\n * ```\n */\n (tool: TamboToolUnknown): TamboToolUnknown;\n (tool: TamboTool): TamboTool;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"component-metadata.js","sourceRoot":"","sources":["../../src/model/component-metadata.ts"],"names":[],"mappings":"","sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { JSONSchema7 } from \"json-schema\";\nimport { ComponentType } from \"react\";\nimport {\n ZodFunction as Zod3Function,\n ZodTuple as Zod3FunctionArgs,\n ZodType as Zod3FunctionReturns,\n infer as Zod3Infer,\n} from \"zod/v3\";\nimport {\n $ZodFunction as Zod4Function,\n $ZodFunctionArgs as Zod4FunctionArgs,\n $ZodType as Zod4FunctionReturns,\n infer as Zod4Infer,\n} from \"zod/v4/core\";\n\n/**\n * A schema type that accepts either a Standard Schema compliant validator\n * (e.g., Zod, Valibot, ArkType) or a raw JSON Schema object.\n *\n * Standard Schema is a specification that provides a unified interface for\n * TypeScript validation libraries. Libraries like Zod implement this spec,\n * allowing us to accept any compliant validator without depending on a specific library.\n * @see https://standardschema.dev/\n */\nexport type SupportedSchema = StandardSchemaV1 | JSONSchema7;\n\n/** Extension of the ToolParameters interface from Tambo AI to include JSONSchema definition */\nexport type ParameterSpec = TamboAI.ToolParameters & {\n schema?: JSONSchema7;\n};\n\n/**\n * Extends the base ContextTool interface from Tambo AI to include schema information\n * for parameter validation.\n */\nexport interface ComponentContextToolMetadata\n extends TamboAI.ComponentContextToolMetadata {\n parameters: ParameterSpec[];\n}\n\nexport interface ComponentContextTool {\n getComponentContext: (...args: any[]) => Promise<any>;\n definition: ComponentContextToolMetadata;\n}\n\nexport interface RegisteredComponent extends TamboAI.AvailableComponent {\n component: ComponentType<any>;\n loadingComponent?: ComponentType<any>;\n}\n\nexport type ComponentRegistry = Record<string, RegisteredComponent>;\n\nexport type TamboToolRegistry = Record<\n string,\n TamboTool | TamboToolWithToolSchema\n>;\n\n/**\n * A JSON Schema that is compatible with the MCP.\n * This is a simplified JSON Schema that is compatible with the MCPClient and the tool's inputSchema.\n *\n * Do not export this type from the SDK.\n */\nexport type JSONSchemaLite = JSONSchema7 & {\n description?: string;\n};\n\ntype MaybeAsync<T> = T | Promise<T>;\n\n/**\n * TamboTool is a type that represents a tool that can be registered with Tambo.\n *\n * It is preferable to use the `defineTool` helper function to create tools, as\n * it provides better type inference and safety.\n * @example\n * ```ts\n * import { TamboTool, defineTool } from \"@tambo-ai/react\";\n * import { z } from \"zod\";\n *\n * const locationToLatLon = defineTool({\n * name: \"location_to_latlon\",\n * description:\n * \"Fetch latitude and longitude from a location string. Returns an object with 'lat' and 'lon' properties.\",\n * tool: async ({ location }) => getLatLonFromLocation(location),\n * inputSchema: z.object({\n * location: z.string(),\n * }),\n * outputSchema: z.object({\n * lat: z.number(),\n * lon: z.number(),\n * }),\n * });\n * ```\n * Alternatively, you manually construct a TamboTool with type safety by passing\n * the expected parameter and return types as generics:\n * ```ts\n * import { TamboTool } from \"@tambo-ai/react\";\n * import { z } from \"zod\";\n *\n * const locationToLatLon: TamboTool<{ location: string }, { lat: number; lon: number }> = {\n * name: \"location_to_latlon\",\n * description:\n * \"Fetch latitude and longitude from a location string. Returns an object with 'lat' and 'lon' properties.\",\n * tool: async ({ location }) => getLatLonFromLocation(location),\n * inputSchema: z.object({\n * location: z.string(),\n * }),\n * outputSchema: z.object({\n * lat: z.number(),\n * lon: z.number(),\n * }),\n * });\n * ```\n */\nexport interface TamboTool<\n Params = any,\n Returns = any,\n Rest extends any[] = [],\n> {\n /**\n * Unique identifier for the tool\n */\n name: string;\n /**\n * Description of what the tool does - used by AI to determine when to use it\n */\n description: string;\n /**\n * Optional human-readable name of the tool for display purposes.\n */\n title?: string;\n /**\n * Optional properties describing tool behavior\n */\n annotations?: {\n /**\n * An array indicating the intended audience(s) for this resource. Valid\n * values are \"user\" and \"assistant\". For example, [\"user\", \"assistant\"]\n * indicates content useful for both.\n */\n audience: (\"user\" | \"assistant\")[];\n /**\n * A number from 0.0 to 1.0 indicating the importance of this resource. A\n * value of 1 means \"most important\" (effectively required), while 0 means\n * \"least important\" (entirely optional).\n */\n priority: number;\n /**\n * An ISO 8601 formatted timestamp indicating when the resource was last\n * modified (e.g., \"2025-01-12T15:00:58Z\").\n */\n lastModified: string;\n };\n\n /**\n * The function that implements the tool's logic. This function will be called\n * by Tambo when the model decides to invoke the tool.\n * @param params - The input parameters for the tool. These are validated\n * against the inputSchema before being passed so are guaranteed to be correct\n * when called by the model.\n * @returns The result of the tool execution, which can be a value or a\n * Promise resolving to a value\n */\n tool: (params: Params, ...rest: Rest) => MaybeAsync<Returns>;\n\n /**\n * The schema for the tool's input parameters. This can be a validator from\n * any Standard Schema compliant library (Zod, Valibot, ArkType, etc.) or a\n * raw JSON Schema object.\n *\n * This schema is used to validate and parse the parameters before passing\n * them to the tool function.\n */\n inputSchema: SupportedSchema | unknown;\n\n /**\n * The schema for the tool's output/return value. This can be any Standard Schema\n * compliant validator (Zod, Valibot, ArkType, etc.) or a raw JSON Schema object.\n *\n * This is used to inform the model about the structure of the tool's return value\n * and is not used for runtime validation at this stage.\n */\n outputSchema: SupportedSchema | unknown;\n\n /**\n * Optional function to transform the tool's return value into an array of content parts.\n * If not provided, the return value will be converted to a string and wrapped in a text content part.\n * @param result - The result returned by the tool function\n * @returns An array of content parts to be sent back to the AI\n */\n transformToContent?: (\n result: any,\n ) =>\n | Promise<TamboAI.Beta.Threads.ChatCompletionContentPart[]>\n | TamboAI.Beta.Threads.ChatCompletionContentPart[];\n}\n\n/**\n * Simplified interface for tools using the deprecated toolSchema format.\n * This interface uses simple `any` types to avoid complex type instantiation.\n * Use `defineTamboTool()` for full type inference when creating tools.\n * @deprecated Use TamboTool with `inputSchema`/`outputSchema` instead.\n */\nexport type TamboToolWithToolSchema<\n Args extends any[] = any[],\n Returns = any,\n> = Omit<TamboTool, \"tool\" | \"inputSchema\" | \"outputSchema\"> & {\n tool: (...args: Args) => MaybeAsync<Returns>;\n /** @deprecated Use `inputSchema`/`outputSchema` properties instead. */\n toolSchema: unknown;\n};\n\n// NOTE(lachieh): this comment mirrors the one from `TamboTool` above\n/**\n * TamboTool is a type that represents a tool that can be registered with Tambo.\n *\n * It is preferable to use the `defineTool` helper function to create tools, as\n * it provides better type inference and safety.\n * @example\n * ```ts\n * import { TamboTool, defineTool } from \"@tambo-ai/react\";\n * import { z } from \"zod\";\n *\n * const locationToLatLon = defineTool({\n * name: \"location_to_latlon\",\n * description:\n * \"Fetch latitude and longitude from a location string. Returns an object with 'lat' and 'lon' properties.\",\n * tool: async ({ location }) => getLatLonFromLocation(location),\n * inputSchema: z.object({\n * location: z.string(),\n * }),\n * outputSchema: z.object({\n * lat: z.number(),\n * lon: z.number(),\n * }),\n * });\n * ```\n * Alternatively, you manually construct a TamboTool with type safety by passing\n * the expected parameter and return types as generics:\n * ```ts\n * import { TamboTool } from \"@tambo-ai/react\";\n * import { z } from \"zod\";\n *\n * const locationToLatLon: TamboTool<{ location: string }, { lat: number; lon: number }> = {\n * name: \"location_to_latlon\",\n * description:\n * \"Fetch latitude and longitude from a location string. Returns an object with 'lat' and 'lon' properties.\",\n * tool: async ({ location }) => getLatLonFromLocation(location),\n * inputSchema: z.object({\n * location: z.string(),\n * }),\n * outputSchema: z.object({\n * lat: z.number(),\n * lon: z.number(),\n * }),\n * });\n * ```\n */\nexport type TamboToolBase<Params = any, Returns = any> =\n | TamboToolWithToolSchema\n | TamboTool<Params, Returns>;\n\n/**\n * A tool that uses JSON Schema compliant input and output schemas.\n * This does not provide type safety for the tool's parameters and return value.\n * @internal\n */\nexport type TamboToolJSONSchema<\n Args extends unknown[] = unknown[],\n Returns = unknown,\n> = Omit<TamboTool<Args, Returns>, \"tool\" | \"inputSchema\" | \"outputSchema\"> & {\n tool: (...args: Args) => MaybeAsync<Returns>;\n inputSchema: JSONSchemaLite;\n outputSchema: JSONSchemaLite;\n};\n\n/**\n * A tool that could not be matched to any known schema types.\n * This means type safety cannot be guaranteed.\n * @internal\n */\nexport type TamboToolUnknown = Omit<\n TamboTool,\n \"tool\" | \"inputSchema\" | \"outputSchema\"\n> & {\n tool: (...args: unknown[]) => MaybeAsync<unknown>;\n inputSchema: unknown;\n outputSchema: unknown;\n};\n\n/**\n * A tool that uses Standard Schema compliant input and output schemas.\n * This provides full type safety for the tool's parameters and return value.\n * @internal\n */\nexport type TamboToolStandardSchema<\n Input extends StandardSchemaV1 = StandardSchemaV1,\n Output extends StandardSchemaV1 = StandardSchemaV1,\n> = Omit<\n TamboTool<\n StandardSchemaV1.InferOutput<Input>,\n StandardSchemaV1.InferOutput<Output>\n >,\n \"tool\" | \"inputSchema\" | \"outputSchema\"\n> & {\n tool: (\n ...args: [StandardSchemaV1.InferOutput<Input>]\n ) => MaybeAsync<StandardSchemaV1.InferOutput<Output>>;\n inputSchema: Input;\n outputSchema: Output;\n};\n\ntype TamboToolZod3Function<\n Args extends Zod3FunctionArgs,\n Returns extends Zod3FunctionReturns,\n> = Omit<\n TamboToolWithToolSchema<Zod3Infer<Args>, Zod3Infer<Returns>>,\n \"toolSchema\"\n> & {\n tool: (...args: Zod3Infer<Args>) => MaybeAsync<Zod3Infer<Returns>>;\n /** @deprecated Use `inputSchema`/`outputSchema` properties instead. */\n toolSchema: Zod3Function<Args, Returns>;\n};\n\ntype TamboToolZod4Function<\n Args extends Zod4FunctionArgs,\n Returns extends Zod4FunctionReturns,\n> = Omit<\n TamboToolWithToolSchema<Zod4Infer<Args>, Zod4Infer<Returns>>,\n \"toolSchema\"\n> & {\n tool: (...args: Zod4Infer<Args>) => MaybeAsync<Zod4Infer<Returns>>;\n /** @deprecated Use `inputSchema`/`outputSchema` properties instead. */\n toolSchema: Zod4Function<Args, Returns>;\n};\n\nexport type TamboToolAssociations = Record<string, string[]>;\n/**\n * A component that can be registered with the TamboRegistryProvider.\n */\n\nexport interface TamboComponent {\n /** The name of the component */\n name: string;\n /** The description of the component */\n description: string;\n /**\n * The React component to render.\n *\n * Make sure to pass the Component itself, not an instance of the component. For example,\n * if you have a component like this:\n *\n * ```tsx\n * const MyComponent = () => {\n * return <div>My Component</div>;\n * };\n * ```\n *\n * You should pass the `Component`:\n *\n * ```tsx\n * const components = [MyComponent];\n * <TamboRegistryProvider components={components} />\n * ```\n */\n component: ComponentType<any>;\n\n /**\n * Schema describing the component's props. Accepts any Standard Schema\n * compliant validator (Zod, Valibot, ArkType, etc.) or a raw JSON Schema\n * object.\n *\n * Either this or propsDefinition must be provided, but not both.\n * @example\n * ```typescript\n * import { z } from \"zod/v4\";\n *\n * const component: TamboComponent = {\n * name: \"MyComponent\",\n * description: \"A sample component\",\n * component: MyComponent,\n * propsSchema: z.object({\n * title: z.string(),\n * count: z.number().optional()\n * })\n * };\n * ```\n */\n propsSchema?: SupportedSchema;\n /**\n * The props definition of the component as a JSON object.\n * Either this or propsSchema must be provided, but not both.\n * @deprecated Use propsSchema instead.\n */\n propsDefinition?: any;\n /** The loading component to render while the component is loading */\n loadingComponent?: ComponentType<any>;\n /** The tools that are associated with the component */\n associatedTools?: (TamboTool | TamboToolWithToolSchema)[];\n}\n\nexport interface RegisterToolsFn {\n /**\n * Registers one or more Tambo tools.\n * @param tools - An array of Tambo tools to register\n */\n (tools: TamboTool[]): void;\n (tools: (TamboTool | TamboToolWithToolSchema)[]): void;\n}\n\n/**\n * Function interface for registering a Tambo tool with full type inference.\n * This function has multiple overloads to handle different schema types. This\n * is a utility function and does not perform any runtime logic.\n */\nexport interface RegisterToolFn {\n /**\n * @deprecated Use `inputSchema`/`outputSchema` instead. toolSchema is deprecated\n * and will be removed in future versions.\n * @example\n * ```diff\n * import { z } from \"zod/v3\";\n * const myTool = defineTamboTool({\n * ...\n * - toolSchema: z.function()\n * - .arguments(z.tuple([z.string()]))\n * - .returns(z.number()),\n * + inputSchema: z.object({\n * + input: z.string().describe(\"Input description\")\n * + }),\n * + outputSchema: z.number().describe(\"Result description\"),\n * });\n */\n <Args extends Zod3FunctionArgs, Returns extends Zod3FunctionReturns>(\n tool: TamboToolZod3Function<Args, Returns>,\n warnOnOverwrite?: boolean,\n ): void;\n /**\n * @deprecated Use `inputSchema`/`outputSchema` instead. toolSchema is deprecated\n * and will be removed in future versions.\n * @example\n * ```diff\n * import { z } from \"zod/v4\";\n * const myTool = defineTamboTool({\n * ...\n * - toolSchema: z.function({\n * - input: z.tuple([z.string()]),\n * - output: z.number(),\n * - }),\n * + inputSchema: z.object({\n * + input: z.string().describe(\"Input description\")\n * + }),\n * + outputSchema: z.number().describe(\"Result description\"),\n * });\n */\n <Args extends Zod4FunctionArgs, Returns extends Zod4FunctionReturns>(\n tool: TamboToolZod4Function<Args, Returns>,\n warnOnOverwrite?: boolean,\n ): void;\n (tool: TamboToolWithToolSchema, warnOnOverwrite?: boolean): void;\n <Args extends StandardSchemaV1, Returns extends StandardSchemaV1>(\n tool: TamboToolStandardSchema<Args, Returns>,\n warnOnOverwrite?: boolean,\n ): void;\n <Args extends any[], Returns = any>(\n tool: TamboToolJSONSchema<Args, Returns>,\n warnOnOverwrite?: boolean,\n ): void;\n (tool: TamboToolUnknown, warnOnOverwrite?: boolean): void;\n (tool: TamboTool, warnOnOverwrite?: boolean): void;\n}\n\n/**\n * Function interface for defining a Tambo tool with full type inference. This\n * function has multiple overloads to handle different schema types. This is a\n * utility function and does not perform any runtime logic.\n */\nexport interface DefineToolFn {\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * Tambo uses the [standard-schema.dev](https://standard-schema.dev) spec which means you can use any Standard Schema\n * compliant validator (Zod, Valibot, ArkType, etc.). This definition ensures the input and output types are correctly\n * inferred from the provided schemas.\n * @example\n * ```typescript\n * import { z } from \"zod/v4\";\n *\n * const myTool = defineTamboTool({\n * // ...\n * inputSchema: z.object({\n * input: z.string().describe(\"Input description\")\n * }),\n * outputSchema: z.number().describe(\"Result description\"),\n * });\n * ```\n * @see {@link https://standard-schema.dev/}\n * @param tool The tool definition to register\n * @returns The registered tool definition\n */\n <Input extends StandardSchemaV1, Output extends StandardSchemaV1>(\n tool: TamboToolStandardSchema<Input, Output>,\n ): TamboToolStandardSchema<Input, Output>;\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * This tool uses the deprecated `toolSchema` format which uses a zod function schema. If you are using a validation\n * library that implements StandardSchema.dev, please switch to using separate `inputSchema` and `outputSchema`\n * properties instead. See example below.\n * @example\n * ```diff\n * import { z } from \"zod/v4\";\n *\n * const myTool = defineTamboTool({\n * // ...\n * - toolSchema: z.function({\n * - input: z.tuple([z.string()]),\n * - output: z.number(),\n * - })\n * + inputSchema: z.object({\n * + input: z.string().describe(\"Input description\")\n * + }),\n * + outputSchema: z.number().describe(\"Result description\"),\n * });\n * @see {@link https://standard-schema.dev/}\n * @param tool The tool definition to register\n * @returns The registered tool definition\n * @deprecated Using `toolSchema` is deprecated. Please use separate `inputSchema` and `outputSchema` properties instead.\n * Note that use of `toolSchema` will be removed in a future release.\n * ```\n */\n <Args extends Zod3FunctionArgs, Returns extends Zod3FunctionReturns>(\n tool: TamboToolZod3Function<Args, Returns>,\n ): TamboToolZod3Function<Args, Returns>;\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * This tool uses the deprecated `toolSchema` format which uses a zod function schema. If you are using a validation\n * library that implements standard-schema.dev, please switch to using separate `inputSchema` and `outputSchema`\n * properties instead. See example below.\n * @param tool The tool definition to register\n * @returns The registered tool definition\n * @deprecated Using `toolSchema` is deprecated. Please use separate `inputSchema` and `outputSchema` properties instead.\n * Note that use of `toolSchema` will be removed in a future release.\n * @example\n * ```diff\n * import { z } from \"zod/v4\";\n *\n * const myTool = defineTamboTool({\n * // ...\n * - toolSchema: z.function({\n * - input: z.tuple([z.string()]),\n * - output: z.number(),\n * - })\n * + inputSchema: z.object({\n * + input: z.string().describe(\"Input description\")\n * + }),\n * + outputSchema: z.number().describe(\"Result description\"),\n * });\n * ```\n */\n <Args extends Zod4FunctionArgs, Returns extends Zod4FunctionReturns>(\n tool: TamboToolZod4Function<Args, Returns>,\n ): TamboToolZod4Function<Args, Returns>;\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * This tool uses the deprecated `toolSchema` property which uses a zod function schema. If you are using a validation\n * library that implements standard-schema.dev, please switch to using separate `inputSchema` and `outputSchema`\n * properties instead. See example below.\n * @param tool The tool definition to register\n * @returns The registered tool definition\n * @deprecated Using `toolSchema` is deprecated. Please use separate `inputSchema` and `outputSchema` properties instead.\n * Note that use of `toolSchema` will be removed in a future release.\n * @example\n * ```diff\n * import { z } from \"zod/v4\";\n *\n * const myTool = defineTamboTool({\n * // ...\n * - toolSchema: { ... }\n * + inputSchema: z.object({ ... }),\n * + outputSchema: z.number(),\n * });\n * ```\n */\n (tool: TamboToolWithToolSchema): TamboToolWithToolSchema;\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * This tool definition matched to JSON Schema input and output schemas which allows does not guarantee type\n * safety. If you are using a validation library that implements\n * [Standard Schema](https://standardschema.dev/#what-tools-frameworks-accept-speccompliant-schemas), please ensure\n * your schemas are correctly typed.\n * @see {@link https://standard-schema.dev/}\n * @param tool The tool definition to register\n * @returns The registered tool definition\n */\n <I extends any[], O = any>(\n tool: TamboToolJSONSchema<I, O>,\n ): TamboToolJSONSchema<I, O>;\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * This tool definition could not be matched to any known schema types which means type safety cannot be\n * guaranteed. If you are using a validation library that implements\n * [Standard Schema](https://standardschema.dev/#what-tools-frameworks-accept-speccompliant-schemas), please ensure\n * your schemas are correctly typed.\n * @example\n * ```typescript\n * const myTool = defineTamboTool({\n * name: \"myTool\",\n * description: \"An example tool\",\n * tool: (input) => { ... },\n * inputSchema: yourInputSchema,\n * outputSchema: yourOutputSchema,\n * });\n * @param tool The tool definition to register\n * @returns The registered tool definition\n * ```\n */\n (tool: TamboToolUnknown): TamboToolUnknown;\n (tool: TamboTool): TamboTool;\n}\n"]}
|