@tambo-ai/react 0.65.2 → 0.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +174 -81
- package/dist/context-helpers/context-helpers-provider.test.d.ts.map +1 -0
- package/dist/context-helpers/{__tests__/context-helpers-provider.test.js → context-helpers-provider.test.js} +2 -2
- package/dist/context-helpers/context-helpers-provider.test.js.map +1 -0
- package/dist/context-helpers/context-helpers.test.d.ts.map +1 -0
- package/dist/context-helpers/{__tests__/context-helpers.test.js → context-helpers.test.js} +1 -1
- package/dist/context-helpers/context-helpers.test.js.map +1 -0
- package/{esm/providers → dist}/hoc/with-tambo-interactable.d.ts +2 -2
- package/dist/hoc/with-tambo-interactable.d.ts.map +1 -0
- package/dist/{providers/hoc → hoc}/with-tambo-interactable.js +29 -2
- package/dist/hoc/with-tambo-interactable.js.map +1 -0
- package/dist/hoc/with-tambo-interactable.test.d.ts +2 -0
- package/dist/hoc/with-tambo-interactable.test.d.ts.map +1 -0
- package/dist/hoc/with-tambo-interactable.test.js +192 -0
- package/dist/hoc/with-tambo-interactable.test.js.map +1 -0
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +2 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/use-component-state.d.ts +11 -24
- package/dist/hooks/use-component-state.d.ts.map +1 -1
- package/dist/hooks/use-component-state.js +14 -5
- package/dist/hooks/use-component-state.js.map +1 -1
- package/dist/hooks/use-component-state.test.d.ts.map +1 -0
- package/dist/hooks/{__tests__/use-component-state.test.js → use-component-state.test.js} +7 -7
- package/dist/hooks/use-component-state.test.js.map +1 -0
- package/dist/hooks/use-current-message.d.ts +51 -7
- package/dist/hooks/use-current-message.d.ts.map +1 -1
- package/dist/hooks/use-current-message.js +50 -6
- package/dist/hooks/use-current-message.js.map +1 -1
- package/dist/hooks/use-current-message.test.d.ts +2 -0
- package/dist/hooks/use-current-message.test.d.ts.map +1 -0
- package/dist/hooks/use-current-message.test.js +264 -0
- package/dist/hooks/use-current-message.test.js.map +1 -0
- package/dist/hooks/use-message-images.test.d.ts.map +1 -0
- package/dist/hooks/{__tests__/use-message-images.test.js → use-message-images.test.js} +1 -1
- package/dist/hooks/use-message-images.test.js.map +1 -0
- package/dist/hooks/use-streaming-props.d.ts +7 -19
- package/dist/hooks/use-streaming-props.d.ts.map +1 -1
- package/dist/hooks/use-streaming-props.js +7 -19
- package/dist/hooks/use-streaming-props.js.map +1 -1
- package/dist/hooks/use-suggestions.d.ts +1 -1
- package/dist/hooks/use-suggestions.d.ts.map +1 -1
- package/dist/hooks/use-suggestions.js.map +1 -1
- package/dist/hooks/use-suggestions.test.d.ts.map +1 -0
- package/dist/hooks/{__tests__/use-suggestions.test.js → use-suggestions.test.js} +36 -29
- package/dist/hooks/use-suggestions.test.js.map +1 -0
- package/dist/hooks/use-tambo-stream-status.d.ts +9 -8
- package/dist/hooks/use-tambo-stream-status.d.ts.map +1 -1
- package/dist/hooks/use-tambo-stream-status.js +9 -8
- package/dist/hooks/use-tambo-stream-status.js.map +1 -1
- package/dist/hooks/use-tambo-stream-status.test.d.ts.map +1 -0
- package/dist/hooks/{__tests__/use-tambo-stream-status.test.js → use-tambo-stream-status.test.js} +6 -6
- package/dist/hooks/use-tambo-stream-status.test.js.map +1 -0
- package/dist/hooks/use-tambo-threads.test.d.ts.map +1 -0
- package/dist/hooks/{__tests__/use-tambo-threads.test.js → use-tambo-threads.test.js} +3 -3
- package/dist/hooks/use-tambo-threads.test.js.map +1 -0
- package/dist/index.d.ts +10 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp/elicitation.d.ts +10 -2
- package/dist/mcp/elicitation.d.ts.map +1 -1
- package/dist/mcp/elicitation.js +19 -1
- package/dist/mcp/elicitation.js.map +1 -1
- package/dist/mcp/elicitation.test.d.ts.map +1 -0
- package/dist/mcp/{__tests__/elicitation.test.js → elicitation.test.js} +1 -1
- package/dist/mcp/elicitation.test.js.map +1 -0
- package/dist/mcp/index.d.ts +11 -2
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +11 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/mcp-client.d.ts +29 -10
- package/dist/mcp/mcp-client.d.ts.map +1 -1
- package/dist/mcp/mcp-client.test.d.ts.map +1 -0
- package/dist/mcp/{__tests__/mcp-client.test.js → mcp-client.test.js} +1 -1
- package/dist/mcp/mcp-client.test.js.map +1 -0
- package/dist/mcp/mcp-hooks.d.ts +129 -25
- package/dist/mcp/mcp-hooks.d.ts.map +1 -1
- package/dist/mcp/mcp-hooks.js +104 -40
- package/dist/mcp/mcp-hooks.js.map +1 -1
- package/dist/mcp/mcp-hooks.test.d.ts.map +1 -0
- package/dist/mcp/{__tests__/mcp-hooks.test.js → mcp-hooks.test.js} +90 -51
- package/dist/mcp/mcp-hooks.test.js.map +1 -0
- package/dist/mcp/tambo-mcp-provider.d.ts +2 -0
- package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
- package/dist/mcp/tambo-mcp-provider.js +60 -13
- package/dist/mcp/tambo-mcp-provider.js.map +1 -1
- package/dist/mcp/tambo-mcp-provider.test.d.ts.map +1 -0
- package/dist/mcp/{__tests__/tambo-mcp-provider.test.js → tambo-mcp-provider.test.js} +9 -25
- package/dist/mcp/tambo-mcp-provider.test.js.map +1 -0
- package/dist/mcp/use-mcp-servers.test.d.ts.map +1 -0
- package/dist/mcp/{__tests__/use-mcp-servers.test.js → use-mcp-servers.test.js} +5 -11
- package/dist/mcp/use-mcp-servers.test.js.map +1 -0
- package/dist/model/component-metadata.d.ts +444 -14
- package/dist/model/component-metadata.d.ts.map +1 -1
- package/dist/model/component-metadata.js.map +1 -1
- package/dist/model/generate-component-response.d.ts +12 -1
- package/dist/model/generate-component-response.d.ts.map +1 -1
- package/dist/model/generate-component-response.js.map +1 -1
- package/dist/model/mcp-server-info.d.ts +3 -1
- package/dist/model/mcp-server-info.d.ts.map +1 -1
- package/dist/model/mcp-server-info.js.map +1 -1
- package/dist/model/resource-info.d.ts +55 -0
- package/dist/model/resource-info.d.ts.map +1 -0
- package/dist/model/resource-info.js +3 -0
- package/dist/model/resource-info.js.map +1 -0
- package/dist/model/tambo-thread.d.ts +6 -1
- package/dist/model/tambo-thread.d.ts.map +1 -1
- package/dist/model/tambo-thread.js.map +1 -1
- package/dist/providers/hooks/use-tambo-session-token.test.d.ts.map +1 -0
- package/dist/providers/hooks/{__tests__/use-tambo-session-token.test.js → use-tambo-session-token.test.js} +1 -1
- package/dist/providers/hooks/use-tambo-session-token.test.js.map +1 -0
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/tambo-client-provider.d.ts +0 -4
- package/dist/providers/tambo-client-provider.d.ts.map +1 -1
- package/dist/providers/tambo-client-provider.js +0 -3
- package/dist/providers/tambo-client-provider.js.map +1 -1
- package/dist/providers/tambo-component-provider.d.ts +4 -4
- package/dist/providers/tambo-component-provider.d.ts.map +1 -1
- package/dist/providers/tambo-component-provider.js.map +1 -1
- package/dist/providers/tambo-context-attachment-provider.test.d.ts.map +1 -0
- package/dist/providers/{__tests__/tambo-context-attachment-provider.test.js → tambo-context-attachment-provider.test.js} +2 -2
- package/dist/providers/tambo-context-attachment-provider.test.js.map +1 -0
- package/dist/providers/tambo-context-helpers-provider.test.d.ts.map +1 -0
- package/dist/providers/{__tests__/tambo-context-helpers-provider.test.js → tambo-context-helpers-provider.test.js} +2 -2
- package/dist/providers/tambo-context-helpers-provider.test.js.map +1 -0
- package/dist/providers/tambo-interactable-provider-partial-updates.test.d.ts.map +1 -0
- package/dist/providers/{__tests__/tambo-interactable-provider-partial-updates.test.js → tambo-interactable-provider-partial-updates.test.js} +91 -91
- package/dist/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -0
- package/dist/providers/tambo-interactable-provider.d.ts +2 -3
- package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
- package/dist/providers/tambo-interactable-provider.js +47 -41
- package/dist/providers/tambo-interactable-provider.js.map +1 -1
- package/dist/providers/tambo-interactables-additional-context-edge-cases.test.d.ts.map +1 -0
- package/dist/providers/{__tests__/tambo-interactables-additional-context-edge-cases.test.js → tambo-interactables-additional-context-edge-cases.test.js} +17 -17
- package/dist/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -0
- package/dist/providers/tambo-interactables-additional-context.test.d.ts.map +1 -0
- package/dist/providers/{__tests__/tambo-interactables-additional-context.test.js → tambo-interactables-additional-context.test.js} +19 -19
- package/dist/providers/tambo-interactables-additional-context.test.js.map +1 -0
- package/dist/providers/tambo-mcp-token-provider.d.ts +20 -13
- package/dist/providers/tambo-mcp-token-provider.d.ts.map +1 -1
- package/dist/providers/tambo-mcp-token-provider.js +122 -10
- package/dist/providers/tambo-mcp-token-provider.js.map +1 -1
- package/dist/providers/tambo-prop-stream-provider.test.d.ts.map +1 -0
- package/dist/providers/{__tests__/tambo-prop-stream-provider.test.js → tambo-prop-stream-provider.test.js} +32 -25
- package/dist/providers/tambo-prop-stream-provider.test.js.map +1 -0
- package/dist/providers/tambo-provider.d.ts +2 -2
- package/dist/providers/tambo-provider.d.ts.map +1 -1
- package/dist/providers/tambo-provider.js +5 -7
- package/dist/providers/tambo-provider.js.map +1 -1
- package/dist/providers/tambo-registry-provider.d.ts +28 -7
- package/dist/providers/tambo-registry-provider.d.ts.map +1 -1
- package/dist/providers/tambo-registry-provider.js +70 -181
- package/dist/providers/tambo-registry-provider.js.map +1 -1
- package/dist/providers/tambo-registry-provider.test.d.ts.map +1 -0
- package/dist/providers/{__tests__/tambo-registry-provider.test.js → tambo-registry-provider.test.js} +153 -31
- package/dist/providers/tambo-registry-provider.test.js.map +1 -0
- package/dist/providers/tambo-registry-schema-compat.test.d.ts +2 -0
- package/dist/providers/tambo-registry-schema-compat.test.d.ts.map +1 -0
- package/dist/providers/tambo-registry-schema-compat.test.js +616 -0
- package/dist/providers/tambo-registry-schema-compat.test.js.map +1 -0
- package/dist/providers/tambo-stubs.d.ts +2 -2
- package/dist/providers/tambo-stubs.d.ts.map +1 -1
- package/dist/providers/tambo-stubs.js +9 -2
- package/dist/providers/tambo-stubs.js.map +1 -1
- package/dist/providers/tambo-stubs.test.d.ts.map +1 -0
- package/dist/providers/{__tests__/tambo-stubs.test.js → tambo-stubs.test.js} +2 -2
- package/dist/providers/tambo-stubs.test.js.map +1 -0
- package/dist/providers/tambo-thread-input-provider.d.ts +2 -1
- package/dist/providers/tambo-thread-input-provider.d.ts.map +1 -1
- package/dist/providers/tambo-thread-input-provider.js +3 -3
- package/dist/providers/tambo-thread-input-provider.js.map +1 -1
- package/dist/providers/tambo-thread-provider-initial-messages.test.d.ts.map +1 -0
- package/dist/providers/{__tests__/tambo-thread-provider-initial-messages.test.js → tambo-thread-provider-initial-messages.test.js} +7 -9
- package/dist/providers/tambo-thread-provider-initial-messages.test.js.map +1 -0
- package/dist/providers/tambo-thread-provider.d.ts +8 -0
- package/dist/providers/tambo-thread-provider.d.ts.map +1 -1
- package/dist/providers/tambo-thread-provider.js +82 -19
- package/dist/providers/tambo-thread-provider.js.map +1 -1
- package/dist/providers/tambo-thread-provider.test.d.ts.map +1 -0
- package/dist/providers/{__tests__/tambo-thread-provider.test.js → tambo-thread-provider.test.js} +42 -78
- package/dist/providers/tambo-thread-provider.test.js.map +1 -0
- package/dist/schema/index.d.ts +6 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +18 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/json-schema.d.ts +35 -0
- package/dist/schema/json-schema.d.ts.map +1 -0
- package/dist/schema/json-schema.js +103 -0
- package/dist/schema/json-schema.js.map +1 -0
- package/dist/schema/schema.d.ts +66 -0
- package/dist/schema/schema.d.ts.map +1 -0
- package/dist/schema/schema.js +192 -0
- package/dist/schema/schema.js.map +1 -0
- package/dist/schema/schema.test.d.ts +2 -0
- package/dist/schema/schema.test.d.ts.map +1 -0
- package/dist/schema/schema.test.js +41 -0
- package/dist/schema/schema.test.js.map +1 -0
- package/dist/schema/standard-schema.d.ts +21 -0
- package/dist/schema/standard-schema.d.ts.map +1 -0
- package/dist/schema/standard-schema.js +37 -0
- package/dist/schema/standard-schema.js.map +1 -0
- package/dist/schema/validate.d.ts +14 -0
- package/dist/schema/validate.d.ts.map +1 -0
- package/dist/schema/validate.js +148 -0
- package/dist/schema/validate.js.map +1 -0
- package/dist/schema/validate.test.d.ts +2 -0
- package/dist/schema/validate.test.d.ts.map +1 -0
- package/dist/schema/validate.test.js +128 -0
- package/dist/schema/validate.test.js.map +1 -0
- package/dist/schema/zod.d.ts +54 -0
- package/dist/schema/zod.d.ts.map +1 -0
- package/dist/schema/zod.js +135 -0
- package/dist/schema/zod.js.map +1 -0
- package/dist/testing/tools.d.ts +29 -15
- package/dist/testing/tools.d.ts.map +1 -1
- package/dist/testing/tools.js +64 -19
- package/dist/testing/tools.js.map +1 -1
- package/dist/util/content-parts.test.d.ts.map +1 -0
- package/dist/util/{__tests__/content-parts.test.js → content-parts.test.js} +1 -1
- package/dist/util/content-parts.test.js.map +1 -0
- package/dist/util/generate-component.d.ts.map +1 -1
- package/dist/util/generate-component.js +3 -3
- package/dist/util/generate-component.js.map +1 -1
- package/dist/util/mcp-server-utils.d.ts +23 -0
- package/dist/util/mcp-server-utils.d.ts.map +1 -0
- package/dist/util/mcp-server-utils.js +107 -0
- package/dist/util/mcp-server-utils.js.map +1 -0
- package/dist/util/mcp-server-utils.test.d.ts +2 -0
- package/dist/util/mcp-server-utils.test.d.ts.map +1 -0
- package/dist/util/mcp-server-utils.test.js +287 -0
- package/dist/util/mcp-server-utils.test.js.map +1 -0
- package/dist/util/message-builder.d.ts +4 -3
- package/dist/util/message-builder.d.ts.map +1 -1
- package/dist/util/message-builder.js +83 -8
- package/dist/util/message-builder.js.map +1 -1
- package/dist/util/message-builder.test.d.ts.map +1 -0
- package/dist/util/message-builder.test.js +678 -0
- package/dist/util/message-builder.test.js.map +1 -0
- package/dist/util/query-utils.d.ts.map +1 -1
- package/dist/util/query-utils.js +49 -31
- package/dist/util/query-utils.js.map +1 -1
- package/dist/util/registry-validators.d.ts +26 -0
- package/dist/util/registry-validators.d.ts.map +1 -0
- package/dist/util/registry-validators.js +105 -0
- package/dist/util/registry-validators.js.map +1 -0
- package/dist/util/registry-validators.test.d.ts +2 -0
- package/dist/util/registry-validators.test.d.ts.map +1 -0
- package/dist/util/registry-validators.test.js +235 -0
- package/dist/util/registry-validators.test.js.map +1 -0
- package/dist/util/registry.d.ts +35 -7
- package/dist/util/registry.d.ts.map +1 -1
- package/dist/util/registry.js +60 -77
- package/dist/util/registry.js.map +1 -1
- package/dist/util/registry.test.d.ts +2 -0
- package/dist/util/registry.test.d.ts.map +1 -0
- package/dist/util/registry.test.js +204 -0
- package/dist/util/registry.test.js.map +1 -0
- package/dist/util/resource-validators.d.ts +16 -0
- package/dist/util/resource-validators.d.ts.map +1 -0
- package/dist/util/resource-validators.js +34 -0
- package/dist/util/resource-validators.js.map +1 -0
- package/dist/util/tool-caller.d.ts +2 -2
- package/dist/util/tool-caller.d.ts.map +1 -1
- package/dist/util/tool-caller.js +12 -4
- package/dist/util/tool-caller.js.map +1 -1
- package/esm/context-helpers/context-helpers-provider.test.d.ts.map +1 -0
- package/esm/context-helpers/{__tests__/context-helpers-provider.test.js → context-helpers-provider.test.js} +2 -2
- package/esm/context-helpers/context-helpers-provider.test.js.map +1 -0
- package/esm/context-helpers/context-helpers.test.d.ts.map +1 -0
- package/esm/context-helpers/{__tests__/context-helpers.test.js → context-helpers.test.js} +1 -1
- package/esm/context-helpers/context-helpers.test.js.map +1 -0
- package/{dist/providers → esm}/hoc/with-tambo-interactable.d.ts +2 -2
- package/esm/hoc/with-tambo-interactable.d.ts.map +1 -0
- package/esm/{providers/hoc → hoc}/with-tambo-interactable.js +29 -2
- package/esm/hoc/with-tambo-interactable.js.map +1 -0
- package/esm/hoc/with-tambo-interactable.test.d.ts +2 -0
- package/esm/hoc/with-tambo-interactable.test.d.ts.map +1 -0
- package/esm/hoc/with-tambo-interactable.test.js +187 -0
- package/esm/hoc/with-tambo-interactable.test.js.map +1 -0
- package/esm/hooks/index.d.ts +1 -1
- package/esm/hooks/index.d.ts.map +1 -1
- package/esm/hooks/index.js +1 -1
- package/esm/hooks/index.js.map +1 -1
- package/esm/hooks/use-component-state.d.ts +11 -24
- package/esm/hooks/use-component-state.d.ts.map +1 -1
- package/esm/hooks/use-component-state.js +14 -5
- package/esm/hooks/use-component-state.js.map +1 -1
- package/esm/hooks/use-component-state.test.d.ts.map +1 -0
- package/esm/hooks/{__tests__/use-component-state.test.js → use-component-state.test.js} +7 -7
- package/esm/hooks/use-component-state.test.js.map +1 -0
- package/esm/hooks/use-current-message.d.ts +51 -7
- package/esm/hooks/use-current-message.d.ts.map +1 -1
- package/esm/hooks/use-current-message.js +48 -5
- package/esm/hooks/use-current-message.js.map +1 -1
- package/esm/hooks/use-current-message.test.d.ts +2 -0
- package/esm/hooks/use-current-message.test.d.ts.map +1 -0
- package/esm/hooks/use-current-message.test.js +259 -0
- package/esm/hooks/use-current-message.test.js.map +1 -0
- package/esm/hooks/use-message-images.test.d.ts.map +1 -0
- package/esm/hooks/{__tests__/use-message-images.test.js → use-message-images.test.js} +1 -1
- package/esm/hooks/use-message-images.test.js.map +1 -0
- package/esm/hooks/use-streaming-props.d.ts +7 -19
- package/esm/hooks/use-streaming-props.d.ts.map +1 -1
- package/esm/hooks/use-streaming-props.js +7 -19
- package/esm/hooks/use-streaming-props.js.map +1 -1
- package/esm/hooks/use-suggestions.d.ts +1 -1
- package/esm/hooks/use-suggestions.d.ts.map +1 -1
- package/esm/hooks/use-suggestions.js.map +1 -1
- package/esm/hooks/use-suggestions.test.d.ts.map +1 -0
- package/esm/hooks/{__tests__/use-suggestions.test.js → use-suggestions.test.js} +36 -29
- package/esm/hooks/use-suggestions.test.js.map +1 -0
- package/esm/hooks/use-tambo-stream-status.d.ts +9 -8
- package/esm/hooks/use-tambo-stream-status.d.ts.map +1 -1
- package/esm/hooks/use-tambo-stream-status.js +9 -8
- package/esm/hooks/use-tambo-stream-status.js.map +1 -1
- package/esm/hooks/use-tambo-stream-status.test.d.ts.map +1 -0
- package/esm/hooks/{__tests__/use-tambo-stream-status.test.js → use-tambo-stream-status.test.js} +6 -6
- package/esm/hooks/use-tambo-stream-status.test.js.map +1 -0
- package/esm/hooks/use-tambo-threads.test.d.ts.map +1 -0
- package/esm/hooks/{__tests__/use-tambo-threads.test.js → use-tambo-threads.test.js} +3 -3
- package/esm/hooks/use-tambo-threads.test.js.map +1 -0
- package/esm/index.d.ts +10 -8
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +4 -2
- package/esm/index.js.map +1 -1
- package/esm/mcp/elicitation.d.ts +10 -2
- package/esm/mcp/elicitation.d.ts.map +1 -1
- package/esm/mcp/elicitation.js +19 -1
- package/esm/mcp/elicitation.js.map +1 -1
- package/esm/mcp/elicitation.test.d.ts.map +1 -0
- package/esm/mcp/{__tests__/elicitation.test.js → elicitation.test.js} +1 -1
- package/esm/mcp/elicitation.test.js.map +1 -0
- package/esm/mcp/index.d.ts +11 -2
- package/esm/mcp/index.d.ts.map +1 -1
- package/esm/mcp/index.js +10 -1
- package/esm/mcp/index.js.map +1 -1
- package/esm/mcp/mcp-client.d.ts +29 -10
- package/esm/mcp/mcp-client.d.ts.map +1 -1
- package/esm/mcp/mcp-client.test.d.ts.map +1 -0
- package/esm/mcp/{__tests__/mcp-client.test.js → mcp-client.test.js} +1 -1
- package/esm/mcp/mcp-client.test.js.map +1 -0
- package/esm/mcp/mcp-hooks.d.ts +129 -25
- package/esm/mcp/mcp-hooks.d.ts.map +1 -1
- package/esm/mcp/mcp-hooks.js +103 -40
- package/esm/mcp/mcp-hooks.js.map +1 -1
- package/esm/mcp/mcp-hooks.test.d.ts.map +1 -0
- package/esm/mcp/{__tests__/mcp-hooks.test.js → mcp-hooks.test.js} +90 -51
- package/esm/mcp/mcp-hooks.test.js.map +1 -0
- package/esm/mcp/tambo-mcp-provider.d.ts +2 -0
- package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
- package/esm/mcp/tambo-mcp-provider.js +60 -13
- package/esm/mcp/tambo-mcp-provider.js.map +1 -1
- package/esm/mcp/tambo-mcp-provider.test.d.ts.map +1 -0
- package/esm/mcp/{__tests__/tambo-mcp-provider.test.js → tambo-mcp-provider.test.js} +9 -25
- package/esm/mcp/tambo-mcp-provider.test.js.map +1 -0
- package/esm/mcp/use-mcp-servers.test.d.ts.map +1 -0
- package/esm/mcp/{__tests__/use-mcp-servers.test.js → use-mcp-servers.test.js} +5 -11
- package/esm/mcp/use-mcp-servers.test.js.map +1 -0
- package/esm/model/component-metadata.d.ts +444 -14
- package/esm/model/component-metadata.d.ts.map +1 -1
- package/esm/model/component-metadata.js.map +1 -1
- package/esm/model/generate-component-response.d.ts +12 -1
- package/esm/model/generate-component-response.d.ts.map +1 -1
- package/esm/model/generate-component-response.js.map +1 -1
- package/esm/model/mcp-server-info.d.ts +3 -1
- package/esm/model/mcp-server-info.d.ts.map +1 -1
- package/esm/model/mcp-server-info.js.map +1 -1
- package/esm/model/resource-info.d.ts +55 -0
- package/esm/model/resource-info.d.ts.map +1 -0
- package/esm/model/resource-info.js +2 -0
- package/esm/model/resource-info.js.map +1 -0
- package/esm/model/tambo-thread.d.ts +6 -1
- package/esm/model/tambo-thread.d.ts.map +1 -1
- package/esm/model/tambo-thread.js.map +1 -1
- package/esm/providers/hooks/use-tambo-session-token.test.d.ts.map +1 -0
- package/esm/providers/hooks/{__tests__/use-tambo-session-token.test.js → use-tambo-session-token.test.js} +1 -1
- package/esm/providers/hooks/use-tambo-session-token.test.js.map +1 -0
- package/esm/providers/index.d.ts +1 -1
- package/esm/providers/index.d.ts.map +1 -1
- package/esm/providers/index.js.map +1 -1
- package/esm/providers/tambo-client-provider.d.ts +0 -4
- package/esm/providers/tambo-client-provider.d.ts.map +1 -1
- package/esm/providers/tambo-client-provider.js +0 -3
- package/esm/providers/tambo-client-provider.js.map +1 -1
- package/esm/providers/tambo-component-provider.d.ts +4 -4
- package/esm/providers/tambo-component-provider.d.ts.map +1 -1
- package/esm/providers/tambo-component-provider.js.map +1 -1
- package/esm/providers/tambo-context-attachment-provider.test.d.ts.map +1 -0
- package/esm/providers/{__tests__/tambo-context-attachment-provider.test.js → tambo-context-attachment-provider.test.js} +2 -2
- package/esm/providers/tambo-context-attachment-provider.test.js.map +1 -0
- package/esm/providers/tambo-context-helpers-provider.test.d.ts.map +1 -0
- package/esm/providers/{__tests__/tambo-context-helpers-provider.test.js → tambo-context-helpers-provider.test.js} +2 -2
- package/esm/providers/tambo-context-helpers-provider.test.js.map +1 -0
- package/esm/providers/tambo-interactable-provider-partial-updates.test.d.ts.map +1 -0
- package/esm/providers/{__tests__/tambo-interactable-provider-partial-updates.test.js → tambo-interactable-provider-partial-updates.test.js} +5 -5
- package/esm/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -0
- package/esm/providers/tambo-interactable-provider.d.ts +2 -3
- package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
- package/esm/providers/tambo-interactable-provider.js +44 -38
- package/esm/providers/tambo-interactable-provider.js.map +1 -1
- package/esm/providers/tambo-interactables-additional-context-edge-cases.test.d.ts.map +1 -0
- package/esm/providers/{__tests__/tambo-interactables-additional-context-edge-cases.test.js → tambo-interactables-additional-context-edge-cases.test.js} +10 -10
- package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -0
- package/esm/providers/tambo-interactables-additional-context.test.d.ts.map +1 -0
- package/esm/providers/{__tests__/tambo-interactables-additional-context.test.js → tambo-interactables-additional-context.test.js} +10 -10
- package/esm/providers/tambo-interactables-additional-context.test.js.map +1 -0
- package/esm/providers/tambo-mcp-token-provider.d.ts +20 -13
- package/esm/providers/tambo-mcp-token-provider.d.ts.map +1 -1
- package/esm/providers/tambo-mcp-token-provider.js +123 -11
- package/esm/providers/tambo-mcp-token-provider.js.map +1 -1
- package/esm/providers/tambo-prop-stream-provider.test.d.ts.map +1 -0
- package/esm/providers/{__tests__/tambo-prop-stream-provider.test.js → tambo-prop-stream-provider.test.js} +32 -25
- package/esm/providers/tambo-prop-stream-provider.test.js.map +1 -0
- package/esm/providers/tambo-provider.d.ts +2 -2
- package/esm/providers/tambo-provider.d.ts.map +1 -1
- package/esm/providers/tambo-provider.js +5 -7
- package/esm/providers/tambo-provider.js.map +1 -1
- package/esm/providers/tambo-registry-provider.d.ts +28 -7
- package/esm/providers/tambo-registry-provider.d.ts.map +1 -1
- package/esm/providers/tambo-registry-provider.js +67 -175
- package/esm/providers/tambo-registry-provider.js.map +1 -1
- package/esm/providers/tambo-registry-provider.test.d.ts.map +1 -0
- package/esm/providers/{__tests__/tambo-registry-provider.test.js → tambo-registry-provider.test.js} +149 -27
- package/esm/providers/tambo-registry-provider.test.js.map +1 -0
- package/esm/providers/tambo-registry-schema-compat.test.d.ts +2 -0
- package/esm/providers/tambo-registry-schema-compat.test.d.ts.map +1 -0
- package/esm/providers/tambo-registry-schema-compat.test.js +578 -0
- package/esm/providers/tambo-registry-schema-compat.test.js.map +1 -0
- package/esm/providers/tambo-stubs.d.ts +2 -2
- package/esm/providers/tambo-stubs.d.ts.map +1 -1
- package/esm/providers/tambo-stubs.js +9 -2
- package/esm/providers/tambo-stubs.js.map +1 -1
- package/esm/providers/tambo-stubs.test.d.ts.map +1 -0
- package/esm/providers/{__tests__/tambo-stubs.test.js → tambo-stubs.test.js} +2 -2
- package/esm/providers/tambo-stubs.test.js.map +1 -0
- package/esm/providers/tambo-thread-input-provider.d.ts +2 -1
- package/esm/providers/tambo-thread-input-provider.d.ts.map +1 -1
- package/esm/providers/tambo-thread-input-provider.js +3 -3
- package/esm/providers/tambo-thread-input-provider.js.map +1 -1
- package/esm/providers/tambo-thread-provider-initial-messages.test.d.ts.map +1 -0
- package/esm/providers/{__tests__/tambo-thread-provider-initial-messages.test.js → tambo-thread-provider-initial-messages.test.js} +7 -9
- package/esm/providers/tambo-thread-provider-initial-messages.test.js.map +1 -0
- package/esm/providers/tambo-thread-provider.d.ts +8 -0
- package/esm/providers/tambo-thread-provider.d.ts.map +1 -1
- package/esm/providers/tambo-thread-provider.js +82 -19
- package/esm/providers/tambo-thread-provider.js.map +1 -1
- package/esm/providers/tambo-thread-provider.test.d.ts.map +1 -0
- package/esm/providers/{__tests__/tambo-thread-provider.test.js → tambo-thread-provider.test.js} +34 -70
- package/esm/providers/tambo-thread-provider.test.js.map +1 -0
- package/esm/schema/index.d.ts +6 -0
- package/esm/schema/index.d.ts.map +1 -0
- package/esm/schema/index.js +6 -0
- package/esm/schema/index.js.map +1 -0
- package/esm/schema/json-schema.d.ts +35 -0
- package/esm/schema/json-schema.d.ts.map +1 -0
- package/esm/schema/json-schema.js +98 -0
- package/esm/schema/json-schema.js.map +1 -0
- package/esm/schema/schema.d.ts +66 -0
- package/esm/schema/schema.d.ts.map +1 -0
- package/esm/schema/schema.js +185 -0
- package/esm/schema/schema.js.map +1 -0
- package/esm/schema/schema.test.d.ts +2 -0
- package/esm/schema/schema.test.d.ts.map +1 -0
- package/esm/schema/schema.test.js +39 -0
- package/esm/schema/schema.test.js.map +1 -0
- package/esm/schema/standard-schema.d.ts +21 -0
- package/esm/schema/standard-schema.d.ts.map +1 -0
- package/esm/schema/standard-schema.js +34 -0
- package/esm/schema/standard-schema.js.map +1 -0
- package/esm/schema/validate.d.ts +14 -0
- package/esm/schema/validate.d.ts.map +1 -0
- package/esm/schema/validate.js +145 -0
- package/esm/schema/validate.js.map +1 -0
- package/esm/schema/validate.test.d.ts +2 -0
- package/esm/schema/validate.test.d.ts.map +1 -0
- package/esm/schema/validate.test.js +126 -0
- package/esm/schema/validate.test.js.map +1 -0
- package/esm/schema/zod.d.ts +54 -0
- package/esm/schema/zod.d.ts.map +1 -0
- package/esm/schema/zod.js +124 -0
- package/esm/schema/zod.js.map +1 -0
- package/esm/testing/tools.d.ts +29 -15
- package/esm/testing/tools.d.ts.map +1 -1
- package/esm/testing/tools.js +62 -16
- package/esm/testing/tools.js.map +1 -1
- package/esm/util/content-parts.test.d.ts.map +1 -0
- package/esm/util/{__tests__/content-parts.test.js → content-parts.test.js} +1 -1
- package/esm/util/content-parts.test.js.map +1 -0
- package/esm/util/generate-component.d.ts.map +1 -1
- package/esm/util/generate-component.js +3 -3
- package/esm/util/generate-component.js.map +1 -1
- package/esm/util/mcp-server-utils.d.ts +23 -0
- package/esm/util/mcp-server-utils.d.ts.map +1 -0
- package/esm/util/mcp-server-utils.js +102 -0
- package/esm/util/mcp-server-utils.js.map +1 -0
- package/esm/util/mcp-server-utils.test.d.ts +2 -0
- package/esm/util/mcp-server-utils.test.d.ts.map +1 -0
- package/esm/util/mcp-server-utils.test.js +285 -0
- package/esm/util/mcp-server-utils.test.js.map +1 -0
- package/esm/util/message-builder.d.ts +4 -3
- package/esm/util/message-builder.d.ts.map +1 -1
- package/esm/util/message-builder.js +83 -8
- package/esm/util/message-builder.js.map +1 -1
- package/esm/util/message-builder.test.d.ts.map +1 -0
- package/esm/util/message-builder.test.js +676 -0
- package/esm/util/message-builder.test.js.map +1 -0
- package/esm/util/query-utils.d.ts.map +1 -1
- package/esm/util/query-utils.js +49 -31
- package/esm/util/query-utils.js.map +1 -1
- package/esm/util/registry-validators.d.ts +26 -0
- package/esm/util/registry-validators.d.ts.map +1 -0
- package/esm/util/registry-validators.js +100 -0
- package/esm/util/registry-validators.js.map +1 -0
- package/esm/util/registry-validators.test.d.ts +2 -0
- package/esm/util/registry-validators.test.d.ts.map +1 -0
- package/esm/util/registry-validators.test.js +233 -0
- package/esm/util/registry-validators.test.js.map +1 -0
- package/esm/util/registry.d.ts +35 -7
- package/esm/util/registry.d.ts.map +1 -1
- package/esm/util/registry.js +57 -73
- package/esm/util/registry.js.map +1 -1
- package/esm/util/registry.test.d.ts +2 -0
- package/esm/util/registry.test.d.ts.map +1 -0
- package/esm/util/registry.test.js +169 -0
- package/esm/util/registry.test.js.map +1 -0
- package/esm/util/resource-validators.d.ts +16 -0
- package/esm/util/resource-validators.d.ts.map +1 -0
- package/esm/util/resource-validators.js +30 -0
- package/esm/util/resource-validators.js.map +1 -0
- package/esm/util/tool-caller.d.ts +2 -2
- package/esm/util/tool-caller.d.ts.map +1 -1
- package/esm/util/tool-caller.js +12 -4
- package/esm/util/tool-caller.js.map +1 -1
- package/package.json +30 -11
- package/dist/__tests__/util/validate-zod-schema.test.d.ts +0 -2
- package/dist/__tests__/util/validate-zod-schema.test.d.ts.map +0 -1
- package/dist/__tests__/util/validate-zod-schema.test.js +0 -96
- package/dist/__tests__/util/validate-zod-schema.test.js.map +0 -1
- package/dist/context-helpers/__tests__/context-helpers-provider.test.d.ts.map +0 -1
- package/dist/context-helpers/__tests__/context-helpers-provider.test.js.map +0 -1
- package/dist/context-helpers/__tests__/context-helpers.test.d.ts.map +0 -1
- package/dist/context-helpers/__tests__/context-helpers.test.js.map +0 -1
- package/dist/hooks/__tests__/use-component-state.test.d.ts.map +0 -1
- package/dist/hooks/__tests__/use-component-state.test.js.map +0 -1
- package/dist/hooks/__tests__/use-message-images.test.d.ts.map +0 -1
- package/dist/hooks/__tests__/use-message-images.test.js.map +0 -1
- package/dist/hooks/__tests__/use-suggestions.test.d.ts.map +0 -1
- package/dist/hooks/__tests__/use-suggestions.test.js.map +0 -1
- package/dist/hooks/__tests__/use-tambo-stream-status.test.d.ts.map +0 -1
- package/dist/hooks/__tests__/use-tambo-stream-status.test.js.map +0 -1
- package/dist/hooks/__tests__/use-tambo-threads.test.d.ts.map +0 -1
- package/dist/hooks/__tests__/use-tambo-threads.test.js.map +0 -1
- package/dist/mcp/__tests__/elicitation.test.d.ts.map +0 -1
- package/dist/mcp/__tests__/elicitation.test.js.map +0 -1
- package/dist/mcp/__tests__/mcp-client.test.d.ts.map +0 -1
- package/dist/mcp/__tests__/mcp-client.test.js.map +0 -1
- package/dist/mcp/__tests__/mcp-hooks.test.d.ts.map +0 -1
- package/dist/mcp/__tests__/mcp-hooks.test.js.map +0 -1
- package/dist/mcp/__tests__/tambo-mcp-provider.test.d.ts.map +0 -1
- package/dist/mcp/__tests__/tambo-mcp-provider.test.js.map +0 -1
- package/dist/mcp/__tests__/use-mcp-servers.test.d.ts.map +0 -1
- package/dist/mcp/__tests__/use-mcp-servers.test.js.map +0 -1
- package/dist/providers/__tests__/tambo-context-attachment-provider.test.d.ts.map +0 -1
- package/dist/providers/__tests__/tambo-context-attachment-provider.test.js.map +0 -1
- package/dist/providers/__tests__/tambo-context-helpers-provider.test.d.ts.map +0 -1
- package/dist/providers/__tests__/tambo-context-helpers-provider.test.js.map +0 -1
- package/dist/providers/__tests__/tambo-interactable-provider-partial-updates.test.d.ts.map +0 -1
- package/dist/providers/__tests__/tambo-interactable-provider-partial-updates.test.js.map +0 -1
- package/dist/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.d.ts.map +0 -1
- package/dist/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.js.map +0 -1
- package/dist/providers/__tests__/tambo-interactables-additional-context.test.d.ts.map +0 -1
- package/dist/providers/__tests__/tambo-interactables-additional-context.test.js.map +0 -1
- package/dist/providers/__tests__/tambo-prop-stream-provider.test.d.ts.map +0 -1
- package/dist/providers/__tests__/tambo-prop-stream-provider.test.js.map +0 -1
- package/dist/providers/__tests__/tambo-registry-provider.test.d.ts.map +0 -1
- package/dist/providers/__tests__/tambo-registry-provider.test.js.map +0 -1
- package/dist/providers/__tests__/tambo-stubs.test.d.ts.map +0 -1
- package/dist/providers/__tests__/tambo-stubs.test.js.map +0 -1
- package/dist/providers/__tests__/tambo-thread-provider-initial-messages.test.d.ts.map +0 -1
- package/dist/providers/__tests__/tambo-thread-provider-initial-messages.test.js.map +0 -1
- package/dist/providers/__tests__/tambo-thread-provider.test.d.ts.map +0 -1
- package/dist/providers/__tests__/tambo-thread-provider.test.js.map +0 -1
- package/dist/providers/hoc/with-tambo-interactable.d.ts.map +0 -1
- package/dist/providers/hoc/with-tambo-interactable.js.map +0 -1
- package/dist/providers/hooks/__tests__/use-tambo-session-token.test.d.ts.map +0 -1
- package/dist/providers/hooks/__tests__/use-tambo-session-token.test.js.map +0 -1
- package/dist/util/__tests__/content-parts.test.d.ts.map +0 -1
- package/dist/util/__tests__/content-parts.test.js.map +0 -1
- package/dist/util/__tests__/message-builder.test.d.ts.map +0 -1
- package/dist/util/__tests__/message-builder.test.js +0 -191
- package/dist/util/__tests__/message-builder.test.js.map +0 -1
- package/dist/util/validate-zod-schema.d.ts +0 -10
- package/dist/util/validate-zod-schema.d.ts.map +0 -1
- package/dist/util/validate-zod-schema.js +0 -100
- package/dist/util/validate-zod-schema.js.map +0 -1
- package/esm/__tests__/util/validate-zod-schema.test.d.ts +0 -2
- package/esm/__tests__/util/validate-zod-schema.test.d.ts.map +0 -1
- package/esm/__tests__/util/validate-zod-schema.test.js +0 -94
- package/esm/__tests__/util/validate-zod-schema.test.js.map +0 -1
- package/esm/context-helpers/__tests__/context-helpers-provider.test.d.ts.map +0 -1
- package/esm/context-helpers/__tests__/context-helpers-provider.test.js.map +0 -1
- package/esm/context-helpers/__tests__/context-helpers.test.d.ts.map +0 -1
- package/esm/context-helpers/__tests__/context-helpers.test.js.map +0 -1
- package/esm/hooks/__tests__/use-component-state.test.d.ts.map +0 -1
- package/esm/hooks/__tests__/use-component-state.test.js.map +0 -1
- package/esm/hooks/__tests__/use-message-images.test.d.ts.map +0 -1
- package/esm/hooks/__tests__/use-message-images.test.js.map +0 -1
- package/esm/hooks/__tests__/use-suggestions.test.d.ts.map +0 -1
- package/esm/hooks/__tests__/use-suggestions.test.js.map +0 -1
- package/esm/hooks/__tests__/use-tambo-stream-status.test.d.ts.map +0 -1
- package/esm/hooks/__tests__/use-tambo-stream-status.test.js.map +0 -1
- package/esm/hooks/__tests__/use-tambo-threads.test.d.ts.map +0 -1
- package/esm/hooks/__tests__/use-tambo-threads.test.js.map +0 -1
- package/esm/mcp/__tests__/elicitation.test.d.ts.map +0 -1
- package/esm/mcp/__tests__/elicitation.test.js.map +0 -1
- package/esm/mcp/__tests__/mcp-client.test.d.ts.map +0 -1
- package/esm/mcp/__tests__/mcp-client.test.js.map +0 -1
- package/esm/mcp/__tests__/mcp-hooks.test.d.ts.map +0 -1
- package/esm/mcp/__tests__/mcp-hooks.test.js.map +0 -1
- package/esm/mcp/__tests__/tambo-mcp-provider.test.d.ts.map +0 -1
- package/esm/mcp/__tests__/tambo-mcp-provider.test.js.map +0 -1
- package/esm/mcp/__tests__/use-mcp-servers.test.d.ts.map +0 -1
- package/esm/mcp/__tests__/use-mcp-servers.test.js.map +0 -1
- package/esm/providers/__tests__/tambo-context-attachment-provider.test.d.ts.map +0 -1
- package/esm/providers/__tests__/tambo-context-attachment-provider.test.js.map +0 -1
- package/esm/providers/__tests__/tambo-context-helpers-provider.test.d.ts.map +0 -1
- package/esm/providers/__tests__/tambo-context-helpers-provider.test.js.map +0 -1
- package/esm/providers/__tests__/tambo-interactable-provider-partial-updates.test.d.ts.map +0 -1
- package/esm/providers/__tests__/tambo-interactable-provider-partial-updates.test.js.map +0 -1
- package/esm/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.d.ts.map +0 -1
- package/esm/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.js.map +0 -1
- package/esm/providers/__tests__/tambo-interactables-additional-context.test.d.ts.map +0 -1
- package/esm/providers/__tests__/tambo-interactables-additional-context.test.js.map +0 -1
- package/esm/providers/__tests__/tambo-prop-stream-provider.test.d.ts.map +0 -1
- package/esm/providers/__tests__/tambo-prop-stream-provider.test.js.map +0 -1
- package/esm/providers/__tests__/tambo-registry-provider.test.d.ts.map +0 -1
- package/esm/providers/__tests__/tambo-registry-provider.test.js.map +0 -1
- package/esm/providers/__tests__/tambo-stubs.test.d.ts.map +0 -1
- package/esm/providers/__tests__/tambo-stubs.test.js.map +0 -1
- package/esm/providers/__tests__/tambo-thread-provider-initial-messages.test.d.ts.map +0 -1
- package/esm/providers/__tests__/tambo-thread-provider-initial-messages.test.js.map +0 -1
- package/esm/providers/__tests__/tambo-thread-provider.test.d.ts.map +0 -1
- package/esm/providers/__tests__/tambo-thread-provider.test.js.map +0 -1
- package/esm/providers/hoc/with-tambo-interactable.d.ts.map +0 -1
- package/esm/providers/hoc/with-tambo-interactable.js.map +0 -1
- package/esm/providers/hooks/__tests__/use-tambo-session-token.test.d.ts.map +0 -1
- package/esm/providers/hooks/__tests__/use-tambo-session-token.test.js.map +0 -1
- package/esm/util/__tests__/content-parts.test.d.ts.map +0 -1
- package/esm/util/__tests__/content-parts.test.js.map +0 -1
- package/esm/util/__tests__/message-builder.test.d.ts.map +0 -1
- package/esm/util/__tests__/message-builder.test.js +0 -189
- package/esm/util/__tests__/message-builder.test.js.map +0 -1
- package/esm/util/validate-zod-schema.d.ts +0 -10
- package/esm/util/validate-zod-schema.d.ts.map +0 -1
- package/esm/util/validate-zod-schema.js +0 -97
- package/esm/util/validate-zod-schema.js.map +0 -1
- /package/dist/context-helpers/{__tests__/context-helpers-provider.test.d.ts → context-helpers-provider.test.d.ts} +0 -0
- /package/dist/context-helpers/{__tests__/context-helpers.test.d.ts → context-helpers.test.d.ts} +0 -0
- /package/dist/hooks/{__tests__/use-component-state.test.d.ts → use-component-state.test.d.ts} +0 -0
- /package/dist/hooks/{__tests__/use-message-images.test.d.ts → use-message-images.test.d.ts} +0 -0
- /package/dist/hooks/{__tests__/use-suggestions.test.d.ts → use-suggestions.test.d.ts} +0 -0
- /package/dist/hooks/{__tests__/use-tambo-stream-status.test.d.ts → use-tambo-stream-status.test.d.ts} +0 -0
- /package/dist/hooks/{__tests__/use-tambo-threads.test.d.ts → use-tambo-threads.test.d.ts} +0 -0
- /package/dist/mcp/{__tests__/elicitation.test.d.ts → elicitation.test.d.ts} +0 -0
- /package/dist/mcp/{__tests__/mcp-client.test.d.ts → mcp-client.test.d.ts} +0 -0
- /package/dist/mcp/{__tests__/mcp-hooks.test.d.ts → mcp-hooks.test.d.ts} +0 -0
- /package/dist/mcp/{__tests__/tambo-mcp-provider.test.d.ts → tambo-mcp-provider.test.d.ts} +0 -0
- /package/dist/mcp/{__tests__/use-mcp-servers.test.d.ts → use-mcp-servers.test.d.ts} +0 -0
- /package/dist/providers/hooks/{__tests__/use-tambo-session-token.test.d.ts → use-tambo-session-token.test.d.ts} +0 -0
- /package/dist/providers/{__tests__/tambo-context-attachment-provider.test.d.ts → tambo-context-attachment-provider.test.d.ts} +0 -0
- /package/dist/providers/{__tests__/tambo-context-helpers-provider.test.d.ts → tambo-context-helpers-provider.test.d.ts} +0 -0
- /package/dist/providers/{__tests__/tambo-interactable-provider-partial-updates.test.d.ts → tambo-interactable-provider-partial-updates.test.d.ts} +0 -0
- /package/dist/providers/{__tests__/tambo-interactables-additional-context-edge-cases.test.d.ts → tambo-interactables-additional-context-edge-cases.test.d.ts} +0 -0
- /package/dist/providers/{__tests__/tambo-interactables-additional-context.test.d.ts → tambo-interactables-additional-context.test.d.ts} +0 -0
- /package/dist/providers/{__tests__/tambo-prop-stream-provider.test.d.ts → tambo-prop-stream-provider.test.d.ts} +0 -0
- /package/dist/providers/{__tests__/tambo-registry-provider.test.d.ts → tambo-registry-provider.test.d.ts} +0 -0
- /package/dist/providers/{__tests__/tambo-stubs.test.d.ts → tambo-stubs.test.d.ts} +0 -0
- /package/dist/providers/{__tests__/tambo-thread-provider-initial-messages.test.d.ts → tambo-thread-provider-initial-messages.test.d.ts} +0 -0
- /package/dist/providers/{__tests__/tambo-thread-provider.test.d.ts → tambo-thread-provider.test.d.ts} +0 -0
- /package/dist/util/{__tests__/content-parts.test.d.ts → content-parts.test.d.ts} +0 -0
- /package/dist/util/{__tests__/message-builder.test.d.ts → message-builder.test.d.ts} +0 -0
- /package/esm/context-helpers/{__tests__/context-helpers-provider.test.d.ts → context-helpers-provider.test.d.ts} +0 -0
- /package/esm/context-helpers/{__tests__/context-helpers.test.d.ts → context-helpers.test.d.ts} +0 -0
- /package/esm/hooks/{__tests__/use-component-state.test.d.ts → use-component-state.test.d.ts} +0 -0
- /package/esm/hooks/{__tests__/use-message-images.test.d.ts → use-message-images.test.d.ts} +0 -0
- /package/esm/hooks/{__tests__/use-suggestions.test.d.ts → use-suggestions.test.d.ts} +0 -0
- /package/esm/hooks/{__tests__/use-tambo-stream-status.test.d.ts → use-tambo-stream-status.test.d.ts} +0 -0
- /package/esm/hooks/{__tests__/use-tambo-threads.test.d.ts → use-tambo-threads.test.d.ts} +0 -0
- /package/esm/mcp/{__tests__/elicitation.test.d.ts → elicitation.test.d.ts} +0 -0
- /package/esm/mcp/{__tests__/mcp-client.test.d.ts → mcp-client.test.d.ts} +0 -0
- /package/esm/mcp/{__tests__/mcp-hooks.test.d.ts → mcp-hooks.test.d.ts} +0 -0
- /package/esm/mcp/{__tests__/tambo-mcp-provider.test.d.ts → tambo-mcp-provider.test.d.ts} +0 -0
- /package/esm/mcp/{__tests__/use-mcp-servers.test.d.ts → use-mcp-servers.test.d.ts} +0 -0
- /package/esm/providers/hooks/{__tests__/use-tambo-session-token.test.d.ts → use-tambo-session-token.test.d.ts} +0 -0
- /package/esm/providers/{__tests__/tambo-context-attachment-provider.test.d.ts → tambo-context-attachment-provider.test.d.ts} +0 -0
- /package/esm/providers/{__tests__/tambo-context-helpers-provider.test.d.ts → tambo-context-helpers-provider.test.d.ts} +0 -0
- /package/esm/providers/{__tests__/tambo-interactable-provider-partial-updates.test.d.ts → tambo-interactable-provider-partial-updates.test.d.ts} +0 -0
- /package/esm/providers/{__tests__/tambo-interactables-additional-context-edge-cases.test.d.ts → tambo-interactables-additional-context-edge-cases.test.d.ts} +0 -0
- /package/esm/providers/{__tests__/tambo-interactables-additional-context.test.d.ts → tambo-interactables-additional-context.test.d.ts} +0 -0
- /package/esm/providers/{__tests__/tambo-prop-stream-provider.test.d.ts → tambo-prop-stream-provider.test.d.ts} +0 -0
- /package/esm/providers/{__tests__/tambo-registry-provider.test.d.ts → tambo-registry-provider.test.d.ts} +0 -0
- /package/esm/providers/{__tests__/tambo-stubs.test.d.ts → tambo-stubs.test.d.ts} +0 -0
- /package/esm/providers/{__tests__/tambo-thread-provider-initial-messages.test.d.ts → tambo-thread-provider-initial-messages.test.d.ts} +0 -0
- /package/esm/providers/{__tests__/tambo-thread-provider.test.d.ts → tambo-thread-provider.test.d.ts} +0 -0
- /package/esm/util/{__tests__/content-parts.test.d.ts → content-parts.test.d.ts} +0 -0
- /package/esm/util/{__tests__/message-builder.test.d.ts → message-builder.test.d.ts} +0 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = require("@testing-library/react");
|
|
7
|
+
const react_2 = __importDefault(require("react"));
|
|
8
|
+
const v3_1 = require("zod/v3");
|
|
9
|
+
const use_current_message_1 = require("../hooks/use-current-message");
|
|
10
|
+
const tambo_interactable_provider_1 = require("../providers/tambo-interactable-provider");
|
|
11
|
+
const with_tambo_interactable_1 = require("./with-tambo-interactable");
|
|
12
|
+
// Create a consistent mock implementation
|
|
13
|
+
const mockAddInteractableComponent = jest.fn(() => "mock-id-123");
|
|
14
|
+
const mockUpdateInteractableComponentProps = jest.fn();
|
|
15
|
+
const mockGetInteractableComponent = jest.fn(() => null);
|
|
16
|
+
const mockRemoveInteractableComponent = jest.fn();
|
|
17
|
+
const mockGetInteractableComponentsByName = jest.fn(() => []);
|
|
18
|
+
const mockClearAllInteractableComponents = jest.fn();
|
|
19
|
+
// Mock the interactable provider
|
|
20
|
+
jest.mock("../providers/tambo-interactable-provider", () => ({
|
|
21
|
+
TamboInteractableProvider: ({ children }) => (react_2.default.createElement("div", { "data-testid": "interactable-provider" }, children)),
|
|
22
|
+
useTamboInteractable: () => ({
|
|
23
|
+
addInteractableComponent: mockAddInteractableComponent,
|
|
24
|
+
updateInteractableComponentProps: mockUpdateInteractableComponentProps,
|
|
25
|
+
getInteractableComponent: mockGetInteractableComponent,
|
|
26
|
+
removeInteractableComponent: mockRemoveInteractableComponent,
|
|
27
|
+
getInteractableComponentsByName: mockGetInteractableComponentsByName,
|
|
28
|
+
clearAllInteractableComponents: mockClearAllInteractableComponents,
|
|
29
|
+
interactableComponents: [],
|
|
30
|
+
}),
|
|
31
|
+
}));
|
|
32
|
+
describe("withTamboInteractable", () => {
|
|
33
|
+
const TestComponent = ({ title, count }) => (react_2.default.createElement("div", null,
|
|
34
|
+
react_2.default.createElement("h1", { "data-testid": "title" }, title),
|
|
35
|
+
count !== undefined && react_2.default.createElement("span", { "data-testid": "count" }, count)));
|
|
36
|
+
const testSchema = v3_1.z.object({
|
|
37
|
+
title: v3_1.z.string(),
|
|
38
|
+
count: v3_1.z.number().optional(),
|
|
39
|
+
});
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
jest.clearAllMocks();
|
|
42
|
+
// Reset mock implementations
|
|
43
|
+
mockAddInteractableComponent.mockReturnValue("mock-id-123");
|
|
44
|
+
mockGetInteractableComponent.mockReturnValue(null);
|
|
45
|
+
mockGetInteractableComponentsByName.mockReturnValue([]);
|
|
46
|
+
});
|
|
47
|
+
it("should render the wrapped component with provided props", () => {
|
|
48
|
+
const InteractableComponent = (0, with_tambo_interactable_1.withTamboInteractable)(TestComponent, {
|
|
49
|
+
componentName: "TestComponent",
|
|
50
|
+
description: "A test component",
|
|
51
|
+
propsSchema: testSchema,
|
|
52
|
+
});
|
|
53
|
+
(0, react_1.render)(react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
|
|
54
|
+
react_2.default.createElement(InteractableComponent, { title: "Hello", count: 42 })));
|
|
55
|
+
expect(react_1.screen.getByTestId("title")).toHaveTextContent("Hello");
|
|
56
|
+
expect(react_1.screen.getByTestId("count")).toHaveTextContent("42");
|
|
57
|
+
});
|
|
58
|
+
it("should set displayName correctly", () => {
|
|
59
|
+
const InteractableComponent = (0, with_tambo_interactable_1.withTamboInteractable)(TestComponent, {
|
|
60
|
+
componentName: "TestComponent",
|
|
61
|
+
description: "A test component",
|
|
62
|
+
});
|
|
63
|
+
expect(InteractableComponent.displayName).toBe("withTamboInteractable(TestComponent)");
|
|
64
|
+
});
|
|
65
|
+
it("should handle components without displayName", () => {
|
|
66
|
+
const AnonymousComponent = () => react_2.default.createElement("div", null, "Anonymous");
|
|
67
|
+
const InteractableComponent = (0, with_tambo_interactable_1.withTamboInteractable)(AnonymousComponent, {
|
|
68
|
+
componentName: "AnonymousComponent",
|
|
69
|
+
description: "An anonymous component",
|
|
70
|
+
});
|
|
71
|
+
// Anonymous components get their name from the function name
|
|
72
|
+
expect(InteractableComponent.displayName).toBe("withTamboInteractable(AnonymousComponent)");
|
|
73
|
+
});
|
|
74
|
+
it("should provide TamboMessageProvider with interactable metadata", async () => {
|
|
75
|
+
// Child component that uses the context
|
|
76
|
+
const ContextConsumer = () => {
|
|
77
|
+
const component = (0, use_current_message_1.useTamboCurrentComponent)();
|
|
78
|
+
return (react_2.default.createElement("div", null,
|
|
79
|
+
react_2.default.createElement("span", { "data-testid": "interactable-id" }, component?.interactableId),
|
|
80
|
+
react_2.default.createElement("span", { "data-testid": "component-name" }, component?.componentName),
|
|
81
|
+
react_2.default.createElement("span", { "data-testid": "description" }, component?.description)));
|
|
82
|
+
};
|
|
83
|
+
// Wrap TestComponent to include ContextConsumer
|
|
84
|
+
const TestComponentWithConsumer = (props) => (react_2.default.createElement("div", null,
|
|
85
|
+
react_2.default.createElement(TestComponent, { ...props }),
|
|
86
|
+
react_2.default.createElement(ContextConsumer, null)));
|
|
87
|
+
const InteractableWithConsumer = (0, with_tambo_interactable_1.withTamboInteractable)(TestComponentWithConsumer, {
|
|
88
|
+
componentName: "TestComponent",
|
|
89
|
+
description: "A test component",
|
|
90
|
+
propsSchema: testSchema,
|
|
91
|
+
});
|
|
92
|
+
(0, react_1.render)(react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
|
|
93
|
+
react_2.default.createElement(InteractableWithConsumer, { title: "Hello" })));
|
|
94
|
+
// Wait for the component to register and render
|
|
95
|
+
await (0, react_1.waitFor)(() => {
|
|
96
|
+
expect(react_1.screen.getByTestId("interactable-id")).toHaveTextContent("mock-id-123");
|
|
97
|
+
});
|
|
98
|
+
expect(react_1.screen.getByTestId("component-name")).toHaveTextContent("TestComponent");
|
|
99
|
+
expect(react_1.screen.getByTestId("description")).toHaveTextContent("A test component");
|
|
100
|
+
});
|
|
101
|
+
it("should create minimal message with correct structure", async () => {
|
|
102
|
+
// Child component that checks the message structure
|
|
103
|
+
const MessageChecker = () => {
|
|
104
|
+
const component = (0, use_current_message_1.useTamboCurrentComponent)();
|
|
105
|
+
return (react_2.default.createElement("div", null,
|
|
106
|
+
react_2.default.createElement("span", { "data-testid": "has-component-name" }, component?.componentName ? "yes" : "no"),
|
|
107
|
+
react_2.default.createElement("span", { "data-testid": "has-props" }, component?.props ? "yes" : "no"),
|
|
108
|
+
react_2.default.createElement("span", { "data-testid": "has-interactable-id" }, component?.interactableId ? "yes" : "no"),
|
|
109
|
+
react_2.default.createElement("span", { "data-testid": "has-description" }, component?.description ? "yes" : "no")));
|
|
110
|
+
};
|
|
111
|
+
const TestComponentWithChecker = (props) => (react_2.default.createElement("div", null,
|
|
112
|
+
react_2.default.createElement(TestComponent, { ...props }),
|
|
113
|
+
react_2.default.createElement(MessageChecker, null)));
|
|
114
|
+
const InteractableWithChecker = (0, with_tambo_interactable_1.withTamboInteractable)(TestComponentWithChecker, {
|
|
115
|
+
componentName: "TestComponent",
|
|
116
|
+
description: "A test component",
|
|
117
|
+
propsSchema: testSchema,
|
|
118
|
+
});
|
|
119
|
+
(0, react_1.render)(react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
|
|
120
|
+
react_2.default.createElement(InteractableWithChecker, { title: "Hello", count: 42 })));
|
|
121
|
+
await (0, react_1.waitFor)(() => {
|
|
122
|
+
expect(react_1.screen.getByTestId("has-component-name")).toHaveTextContent("yes");
|
|
123
|
+
});
|
|
124
|
+
expect(react_1.screen.getByTestId("has-props")).toHaveTextContent("yes");
|
|
125
|
+
expect(react_1.screen.getByTestId("has-interactable-id")).toHaveTextContent("yes");
|
|
126
|
+
expect(react_1.screen.getByTestId("has-description")).toHaveTextContent("yes");
|
|
127
|
+
});
|
|
128
|
+
it("should pass through all component props correctly", () => {
|
|
129
|
+
const InteractableComponent = (0, with_tambo_interactable_1.withTamboInteractable)(TestComponent, {
|
|
130
|
+
componentName: "TestComponent",
|
|
131
|
+
description: "A test component",
|
|
132
|
+
propsSchema: testSchema,
|
|
133
|
+
});
|
|
134
|
+
(0, react_1.render)(react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
|
|
135
|
+
react_2.default.createElement(InteractableComponent, { title: "Test Title", count: 100 })));
|
|
136
|
+
expect(react_1.screen.getByTestId("title")).toHaveTextContent("Test Title");
|
|
137
|
+
expect(react_1.screen.getByTestId("count")).toHaveTextContent("100");
|
|
138
|
+
});
|
|
139
|
+
it("should filter out interactable-specific props from component props", () => {
|
|
140
|
+
const ExtendedComponent = ({ title, onInteractableReady, onPropsUpdate, }) => (react_2.default.createElement("div", null,
|
|
141
|
+
react_2.default.createElement("span", { "data-testid": "title" }, title),
|
|
142
|
+
react_2.default.createElement("span", { "data-testid": "has-ready" }, onInteractableReady ? "yes" : "no"),
|
|
143
|
+
react_2.default.createElement("span", { "data-testid": "has-update" }, onPropsUpdate ? "yes" : "no")));
|
|
144
|
+
const InteractableComponent = (0, with_tambo_interactable_1.withTamboInteractable)(ExtendedComponent, {
|
|
145
|
+
componentName: "ExtendedComponent",
|
|
146
|
+
description: "An extended component",
|
|
147
|
+
});
|
|
148
|
+
const mockReady = jest.fn();
|
|
149
|
+
const mockUpdate = jest.fn();
|
|
150
|
+
(0, react_1.render)(react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
|
|
151
|
+
react_2.default.createElement(InteractableComponent, { title: "Test", onInteractableReady: mockReady, onPropsUpdate: mockUpdate })));
|
|
152
|
+
expect(react_1.screen.getByTestId("title")).toHaveTextContent("Test");
|
|
153
|
+
// These props should be filtered out
|
|
154
|
+
expect(react_1.screen.getByTestId("has-ready")).toHaveTextContent("no");
|
|
155
|
+
expect(react_1.screen.getByTestId("has-update")).toHaveTextContent("no");
|
|
156
|
+
});
|
|
157
|
+
it("should work without propsSchema", () => {
|
|
158
|
+
const InteractableComponent = (0, with_tambo_interactable_1.withTamboInteractable)(TestComponent, {
|
|
159
|
+
componentName: "TestComponent",
|
|
160
|
+
description: "A test component",
|
|
161
|
+
});
|
|
162
|
+
(0, react_1.render)(react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
|
|
163
|
+
react_2.default.createElement(InteractableComponent, { title: "No Schema" })));
|
|
164
|
+
expect(react_1.screen.getByTestId("title")).toHaveTextContent("No Schema");
|
|
165
|
+
});
|
|
166
|
+
it("should render before interactable ID is set", () => {
|
|
167
|
+
const InteractableComponent = (0, with_tambo_interactable_1.withTamboInteractable)(TestComponent, {
|
|
168
|
+
componentName: "TestComponent",
|
|
169
|
+
description: "A test component",
|
|
170
|
+
});
|
|
171
|
+
const { container } = (0, react_1.render)(react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
|
|
172
|
+
react_2.default.createElement(InteractableComponent, { title: "Early Render" })));
|
|
173
|
+
// Component should render even before ID is available
|
|
174
|
+
expect(container.querySelector('[data-testid="title"]')).toBeInTheDocument();
|
|
175
|
+
});
|
|
176
|
+
it("should handle null/undefined values in props", () => {
|
|
177
|
+
const NullableComponent = ({ title, optional, nullable, }) => (react_2.default.createElement("div", null,
|
|
178
|
+
react_2.default.createElement("span", { "data-testid": "title" }, title),
|
|
179
|
+
react_2.default.createElement("span", { "data-testid": "optional" }, optional ?? "undefined"),
|
|
180
|
+
react_2.default.createElement("span", { "data-testid": "nullable" }, nullable ?? "null")));
|
|
181
|
+
const InteractableComponent = (0, with_tambo_interactable_1.withTamboInteractable)(NullableComponent, {
|
|
182
|
+
componentName: "NullableComponent",
|
|
183
|
+
description: "A component with nullable props",
|
|
184
|
+
});
|
|
185
|
+
(0, react_1.render)(react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
|
|
186
|
+
react_2.default.createElement(InteractableComponent, { title: "Test", nullable: null })));
|
|
187
|
+
expect(react_1.screen.getByTestId("title")).toHaveTextContent("Test");
|
|
188
|
+
expect(react_1.screen.getByTestId("optional")).toHaveTextContent("undefined");
|
|
189
|
+
expect(react_1.screen.getByTestId("nullable")).toHaveTextContent("null");
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
//# sourceMappingURL=with-tambo-interactable.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-tambo-interactable.test.js","sourceRoot":"","sources":["../../src/hoc/with-tambo-interactable.test.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAiE;AACjE,kDAA0B;AAC1B,+BAA2B;AAC3B,sEAAwE;AACxE,0FAAqF;AACrF,uEAAkE;AAElE,0CAA0C;AAC1C,MAAM,4BAA4B,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC;AAClE,MAAM,oCAAoC,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACvD,MAAM,4BAA4B,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;AACzD,MAAM,+BAA+B,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAClD,MAAM,mCAAmC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;AAC9D,MAAM,kCAAkC,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAErD,iCAAiC;AACjC,IAAI,CAAC,IAAI,CAAC,0CAA0C,EAAE,GAAG,EAAE,CAAC,CAAC;IAC3D,yBAAyB,EAAE,CAAC,EAAE,QAAQ,EAAiC,EAAE,EAAE,C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AS,CAAC,aAAa,CAAC,uBAAuB,CAAC,CACjD,CAAC,iBAAiB,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QAOtD,MAAM,iBAAiB,GAA4B,CAAC,EAClD,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,EAAE,EAAE,CAAC,CACJ;YACE,uDAAkB,OAAO,IAAE,KAAK,CAAQ;YACxC,uDAAkB,UAAU,IAAE,QAAQ,IAAI,WAAW,CAAQ;YAC7D,uDAAkB,UAAU,IAAE,QAAQ,IAAI,MAAM,CAAQ,CACpD,CACP,CAAC;QAEF,MAAM,qBAAqB,GAAG,IAAA,+CAAqB,EAAC,iBAAiB,EAAE;YACrE,aAAa,EAAE,mBAAmB;YAClC,WAAW,EAAE,iCAAiC;SAC/C,CAAC,CAAC;QAEH,IAAA,cAAM,EACJ,8BAAC,uDAAyB;YACxB,8BAAC,qBAAqB,IAAC,KAAK,EAAC,MAAM,EAAC,QAAQ,EAAE,IAAI,GAAI,CAC5B,CAC7B,CAAC;QAEF,MAAM,CAAC,cAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC9D,MAAM,CAAC,cAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;QACtE,MAAM,CAAC,cAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { render, screen, waitFor } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zod/v3\";\nimport { useTamboCurrentComponent } from \"../hooks/use-current-message\";\nimport { TamboInteractableProvider } from \"../providers/tambo-interactable-provider\";\nimport { withTamboInteractable } from \"./with-tambo-interactable\";\n\n// Create a consistent mock implementation\nconst mockAddInteractableComponent = jest.fn(() => \"mock-id-123\");\nconst mockUpdateInteractableComponentProps = jest.fn();\nconst mockGetInteractableComponent = jest.fn(() => null);\nconst mockRemoveInteractableComponent = jest.fn();\nconst mockGetInteractableComponentsByName = jest.fn(() => []);\nconst mockClearAllInteractableComponents = jest.fn();\n\n// Mock the interactable provider\njest.mock(\"../providers/tambo-interactable-provider\", () => ({\n TamboInteractableProvider: ({ children }: { children: React.ReactNode }) => (\n <div data-testid=\"interactable-provider\">{children}</div>\n ),\n useTamboInteractable: () => ({\n addInteractableComponent: mockAddInteractableComponent,\n updateInteractableComponentProps: mockUpdateInteractableComponentProps,\n getInteractableComponent: mockGetInteractableComponent,\n removeInteractableComponent: mockRemoveInteractableComponent,\n getInteractableComponentsByName: mockGetInteractableComponentsByName,\n clearAllInteractableComponents: mockClearAllInteractableComponents,\n interactableComponents: [],\n }),\n}));\n\ndescribe(\"withTamboInteractable\", () => {\n // Simple test component\n interface TestComponentProps {\n title: string;\n count?: number;\n }\n\n const TestComponent: React.FC<TestComponentProps> = ({ title, count }) => (\n <div>\n <h1 data-testid=\"title\">{title}</h1>\n {count !== undefined && <span data-testid=\"count\">{count}</span>}\n </div>\n );\n\n const testSchema = z.object({\n title: z.string(),\n count: z.number().optional(),\n });\n\n beforeEach(() => {\n jest.clearAllMocks();\n // Reset mock implementations\n mockAddInteractableComponent.mockReturnValue(\"mock-id-123\");\n mockGetInteractableComponent.mockReturnValue(null);\n mockGetInteractableComponentsByName.mockReturnValue([]);\n });\n\n it(\"should render the wrapped component with provided props\", () => {\n const InteractableComponent = withTamboInteractable(TestComponent, {\n componentName: \"TestComponent\",\n description: \"A test component\",\n propsSchema: testSchema,\n });\n\n render(\n <TamboInteractableProvider>\n <InteractableComponent title=\"Hello\" count={42} />\n </TamboInteractableProvider>,\n );\n\n expect(screen.getByTestId(\"title\")).toHaveTextContent(\"Hello\");\n expect(screen.getByTestId(\"count\")).toHaveTextContent(\"42\");\n });\n\n it(\"should set displayName correctly\", () => {\n const InteractableComponent = withTamboInteractable(TestComponent, {\n componentName: \"TestComponent\",\n description: \"A test component\",\n });\n\n expect(InteractableComponent.displayName).toBe(\n \"withTamboInteractable(TestComponent)\",\n );\n });\n\n it(\"should handle components without displayName\", () => {\n const AnonymousComponent = () => <div>Anonymous</div>;\n\n const InteractableComponent = withTamboInteractable(AnonymousComponent, {\n componentName: \"AnonymousComponent\",\n description: \"An anonymous component\",\n });\n\n // Anonymous components get their name from the function name\n expect(InteractableComponent.displayName).toBe(\n \"withTamboInteractable(AnonymousComponent)\",\n );\n });\n\n it(\"should provide TamboMessageProvider with interactable metadata\", async () => {\n // Child component that uses the context\n const ContextConsumer = () => {\n const component = useTamboCurrentComponent();\n return (\n <div>\n <span data-testid=\"interactable-id\">{component?.interactableId}</span>\n <span data-testid=\"component-name\">{component?.componentName}</span>\n <span data-testid=\"description\">{component?.description}</span>\n </div>\n );\n };\n\n // Wrap TestComponent to include ContextConsumer\n const TestComponentWithConsumer: React.FC<TestComponentProps> = (props) => (\n <div>\n <TestComponent {...props} />\n <ContextConsumer />\n </div>\n );\n\n const InteractableWithConsumer = withTamboInteractable(\n TestComponentWithConsumer,\n {\n componentName: \"TestComponent\",\n description: \"A test component\",\n propsSchema: testSchema,\n },\n );\n\n render(\n <TamboInteractableProvider>\n <InteractableWithConsumer title=\"Hello\" />\n </TamboInteractableProvider>,\n );\n\n // Wait for the component to register and render\n await waitFor(() => {\n expect(screen.getByTestId(\"interactable-id\")).toHaveTextContent(\n \"mock-id-123\",\n );\n });\n\n expect(screen.getByTestId(\"component-name\")).toHaveTextContent(\n \"TestComponent\",\n );\n expect(screen.getByTestId(\"description\")).toHaveTextContent(\n \"A test component\",\n );\n });\n\n it(\"should create minimal message with correct structure\", async () => {\n // Child component that checks the message structure\n const MessageChecker = () => {\n const component = useTamboCurrentComponent();\n return (\n <div>\n <span data-testid=\"has-component-name\">\n {component?.componentName ? \"yes\" : \"no\"}\n </span>\n <span data-testid=\"has-props\">{component?.props ? \"yes\" : \"no\"}</span>\n <span data-testid=\"has-interactable-id\">\n {component?.interactableId ? \"yes\" : \"no\"}\n </span>\n <span data-testid=\"has-description\">\n {component?.description ? \"yes\" : \"no\"}\n </span>\n </div>\n );\n };\n\n const TestComponentWithChecker: React.FC<TestComponentProps> = (props) => (\n <div>\n <TestComponent {...props} />\n <MessageChecker />\n </div>\n );\n\n const InteractableWithChecker = withTamboInteractable(\n TestComponentWithChecker,\n {\n componentName: \"TestComponent\",\n description: \"A test component\",\n propsSchema: testSchema,\n },\n );\n\n render(\n <TamboInteractableProvider>\n <InteractableWithChecker title=\"Hello\" count={42} />\n </TamboInteractableProvider>,\n );\n\n await waitFor(() => {\n expect(screen.getByTestId(\"has-component-name\")).toHaveTextContent(\"yes\");\n });\n\n expect(screen.getByTestId(\"has-props\")).toHaveTextContent(\"yes\");\n expect(screen.getByTestId(\"has-interactable-id\")).toHaveTextContent(\"yes\");\n expect(screen.getByTestId(\"has-description\")).toHaveTextContent(\"yes\");\n });\n\n it(\"should pass through all component props correctly\", () => {\n const InteractableComponent = withTamboInteractable(TestComponent, {\n componentName: \"TestComponent\",\n description: \"A test component\",\n propsSchema: testSchema,\n });\n\n render(\n <TamboInteractableProvider>\n <InteractableComponent title=\"Test Title\" count={100} />\n </TamboInteractableProvider>,\n );\n\n expect(screen.getByTestId(\"title\")).toHaveTextContent(\"Test Title\");\n expect(screen.getByTestId(\"count\")).toHaveTextContent(\"100\");\n });\n\n it(\"should filter out interactable-specific props from component props\", () => {\n interface ExtendedProps extends TestComponentProps {\n onInteractableReady?: (id: string) => void;\n onPropsUpdate?: (props: Record<string, any>) => void;\n }\n\n const ExtendedComponent: React.FC<ExtendedProps> = ({\n title,\n onInteractableReady,\n onPropsUpdate,\n }) => (\n <div>\n <span data-testid=\"title\">{title}</span>\n <span data-testid=\"has-ready\">\n {onInteractableReady ? \"yes\" : \"no\"}\n </span>\n <span data-testid=\"has-update\">{onPropsUpdate ? \"yes\" : \"no\"}</span>\n </div>\n );\n\n const InteractableComponent = withTamboInteractable(ExtendedComponent, {\n componentName: \"ExtendedComponent\",\n description: \"An extended component\",\n });\n\n const mockReady = jest.fn();\n const mockUpdate = jest.fn();\n\n render(\n <TamboInteractableProvider>\n <InteractableComponent\n title=\"Test\"\n onInteractableReady={mockReady}\n onPropsUpdate={mockUpdate}\n />\n </TamboInteractableProvider>,\n );\n\n expect(screen.getByTestId(\"title\")).toHaveTextContent(\"Test\");\n // These props should be filtered out\n expect(screen.getByTestId(\"has-ready\")).toHaveTextContent(\"no\");\n expect(screen.getByTestId(\"has-update\")).toHaveTextContent(\"no\");\n });\n\n it(\"should work without propsSchema\", () => {\n const InteractableComponent = withTamboInteractable(TestComponent, {\n componentName: \"TestComponent\",\n description: \"A test component\",\n });\n\n render(\n <TamboInteractableProvider>\n <InteractableComponent title=\"No Schema\" />\n </TamboInteractableProvider>,\n );\n\n expect(screen.getByTestId(\"title\")).toHaveTextContent(\"No Schema\");\n });\n\n it(\"should render before interactable ID is set\", () => {\n const InteractableComponent = withTamboInteractable(TestComponent, {\n componentName: \"TestComponent\",\n description: \"A test component\",\n });\n\n const { container } = render(\n <TamboInteractableProvider>\n <InteractableComponent title=\"Early Render\" />\n </TamboInteractableProvider>,\n );\n\n // Component should render even before ID is available\n expect(\n container.querySelector('[data-testid=\"title\"]'),\n ).toBeInTheDocument();\n });\n\n it(\"should handle null/undefined values in props\", () => {\n interface NullableProps {\n title: string;\n optional?: string;\n nullable: string | null;\n }\n\n const NullableComponent: React.FC<NullableProps> = ({\n title,\n optional,\n nullable,\n }) => (\n <div>\n <span data-testid=\"title\">{title}</span>\n <span data-testid=\"optional\">{optional ?? \"undefined\"}</span>\n <span data-testid=\"nullable\">{nullable ?? \"null\"}</span>\n </div>\n );\n\n const InteractableComponent = withTamboInteractable(NullableComponent, {\n componentName: \"NullableComponent\",\n description: \"A component with nullable props\",\n });\n\n render(\n <TamboInteractableProvider>\n <InteractableComponent title=\"Test\" nullable={null} />\n </TamboInteractableProvider>,\n );\n\n expect(screen.getByTestId(\"title\")).toHaveTextContent(\"Test\");\n expect(screen.getByTestId(\"optional\")).toHaveTextContent(\"undefined\");\n expect(screen.getByTestId(\"nullable\")).toHaveTextContent(\"null\");\n });\n});\n"]}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./react-query-hooks";
|
|
2
2
|
export { useTamboComponentState } from "./use-component-state";
|
|
3
|
-
export { useTamboCurrentMessage } from "./use-current-message";
|
|
3
|
+
export { useTamboCurrentComponent, useTamboCurrentMessage, type TamboCurrentComponent, } from "./use-current-message";
|
|
4
4
|
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";
|
|
@@ -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,
|
|
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,EACL,wBAAwB,EACxB,sBAAsB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,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/dist/hooks/index.js
CHANGED
|
@@ -14,12 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.useTamboVoice = exports.useTamboThreadList = exports.useTamboStreamStatus = exports.useTamboStreamingProps = exports.useTamboCurrentMessage = exports.useTamboComponentState = void 0;
|
|
17
|
+
exports.useTamboVoice = exports.useTamboThreadList = exports.useTamboStreamStatus = exports.useTamboStreamingProps = exports.useTamboCurrentMessage = exports.useTamboCurrentComponent = exports.useTamboComponentState = void 0;
|
|
18
18
|
// Export all hooks from this directory
|
|
19
19
|
__exportStar(require("./react-query-hooks"), exports);
|
|
20
20
|
var use_component_state_1 = require("./use-component-state");
|
|
21
21
|
Object.defineProperty(exports, "useTamboComponentState", { enumerable: true, get: function () { return use_component_state_1.useTamboComponentState; } });
|
|
22
22
|
var use_current_message_1 = require("./use-current-message");
|
|
23
|
+
Object.defineProperty(exports, "useTamboCurrentComponent", { enumerable: true, get: function () { return use_current_message_1.useTamboCurrentComponent; } });
|
|
23
24
|
Object.defineProperty(exports, "useTamboCurrentMessage", { enumerable: true, get: function () { return use_current_message_1.useTamboCurrentMessage; } });
|
|
24
25
|
var use_streaming_props_1 = require("./use-streaming-props");
|
|
25
26
|
Object.defineProperty(exports, "useTamboStreamingProps", { enumerable: true, get: function () { return use_streaming_props_1.useTamboStreamingProps; } });
|
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,sDAAoC;AACpC,6DAA+D;AAAtD,6HAAA,sBAAsB,OAAA;AAC/B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,sDAAoC;AACpC,6DAA+D;AAAtD,6HAAA,sBAAsB,OAAA;AAC/B,6DAI+B;AAH7B,+HAAA,wBAAwB,OAAA;AACxB,6HAAA,sBAAsB,OAAA;AAGxB,6DAA+D;AAAtD,6HAAA,sBAAsB,OAAA;AAC/B,oDAAkC;AAClC,qEAImC;AAHjC,+HAAA,oBAAoB,OAAA;AAItB,yDAAyD;AAAhD,uHAAA,kBAAkB,OAAA;AAC3B,qDAAkD;AAAzC,gHAAA,aAAa,OAAA","sourcesContent":["// Export all hooks from this directory\nexport * from \"./react-query-hooks\";\nexport { useTamboComponentState } from \"./use-component-state\";\nexport {\n useTamboCurrentComponent,\n useTamboCurrentMessage,\n type TamboCurrentComponent,\n} 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"]}
|
|
@@ -1,31 +1,18 @@
|
|
|
1
1
|
type StateUpdateResult<T> = [currentState: T, setState: (newState: T) => void];
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* Benefits: Passes user changes to AI, and when threads are returned, state is preserved.
|
|
5
|
-
* @param keyName - The unique key to identify this state value within the message's componentState object
|
|
6
|
-
* @param initialValue - Optional initial value for the state, used if no componentState value exists in the Tambo message containing this hook usage.
|
|
7
|
-
* @param setFromProp - Optional value used to set the state value, only while no componentState value exists in the Tambo message containing this hook usage. Use this to allow streaming updates from a prop to the state value.
|
|
8
|
-
* @param debounceTime - Optional debounce time in milliseconds (default: 500ms) to limit API calls.
|
|
9
|
-
* @returns A tuple containing:
|
|
10
|
-
* - The current state value
|
|
11
|
-
* - A setter function to update the state (updates UI immediately, debounces server sync)
|
|
12
|
-
* @example
|
|
13
|
-
* const [count, setCount] = useTamboComponentState("counter", 0);
|
|
3
|
+
* Like useState, but syncs to the thread message's `componentState`.
|
|
14
4
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* email: "",
|
|
19
|
-
* message: ""
|
|
20
|
-
* });
|
|
5
|
+
* Use `setFromProp` to seed state from streamed props. During streaming,
|
|
6
|
+
* state updates as new prop values arrive. Once streaming completes,
|
|
7
|
+
* user edits take precedence over the original prop value.
|
|
21
8
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
9
|
+
* Pair with `useTamboStreamStatus` to disable inputs while streaming.
|
|
10
|
+
* @see {@link https://docs.tambo.co/concepts/streaming/streaming-best-practices}
|
|
11
|
+
* @param keyName - Unique key within the message's componentState
|
|
12
|
+
* @param initialValue - Default value if no componentState exists
|
|
13
|
+
* @param setFromProp - Seeds state from props (updates during streaming, then user edits take over)
|
|
14
|
+
* @param debounceTime - Server sync debounce in ms (default: 500)
|
|
15
|
+
* @returns A tuple of [currentState, setState] similar to React's useState
|
|
29
16
|
*/
|
|
30
17
|
export declare function useTamboComponentState<S = undefined>(keyName: string, initialValue?: S, setFromProp?: S, debounceTime?: number): StateUpdateResult<S | undefined>;
|
|
31
18
|
export declare function useTamboComponentState<S>(keyName: string, initialValue: S, setFromProp?: S, debounceTime?: number): StateUpdateResult<S>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-component-state.d.ts","sourceRoot":"","sources":["../../src/hooks/use-component-state.tsx"],"names":[],"mappings":"AAMA,KAAK,iBAAiB,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC;AAE/E
|
|
1
|
+
{"version":3,"file":"use-component-state.d.ts","sourceRoot":"","sources":["../../src/hooks/use-component-state.tsx"],"names":[],"mappings":"AAMA,KAAK,iBAAiB,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,GAAG,SAAS,EAClD,OAAO,EAAE,MAAM,EACf,YAAY,CAAC,EAAE,CAAC,EAChB,WAAW,CAAC,EAAE,CAAC,EACf,YAAY,CAAC,EAAE,MAAM,GACpB,iBAAiB,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;AACpC,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,CAAC,EACf,WAAW,CAAC,EAAE,CAAC,EACf,YAAY,CAAC,EAAE,MAAM,GACpB,iBAAiB,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -14,7 +14,7 @@ function useTamboComponentState(keyName, initialValue, setFromProp, debounceTime
|
|
|
14
14
|
const [localState, setLocalState] = (0, react_1.useState)(messageState ?? initialValue);
|
|
15
15
|
const [initializedFromThreadMessage, setInitializedFromThreadMessage] = (0, react_1.useState)(messageState ? true : false);
|
|
16
16
|
// Optimistically update the local thread message's componentState
|
|
17
|
-
const updateLocalThreadMessage = (0, react_1.useCallback)((newState, existingMessage) => {
|
|
17
|
+
const updateLocalThreadMessage = (0, react_1.useCallback)(async (newState, existingMessage) => {
|
|
18
18
|
const updatedMessage = {
|
|
19
19
|
threadId: existingMessage.threadId,
|
|
20
20
|
componentState: {
|
|
@@ -22,7 +22,7 @@ function useTamboComponentState(keyName, initialValue, setFromProp, debounceTime
|
|
|
22
22
|
[keyName]: newState,
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
|
-
updateThreadMessage(existingMessage.id, updatedMessage, false);
|
|
25
|
+
await updateThreadMessage(existingMessage.id, updatedMessage, false);
|
|
26
26
|
}, [updateThreadMessage, keyName]);
|
|
27
27
|
// Debounced callback to update the remote thread message's componentState
|
|
28
28
|
const updateRemoteThreadMessage = (0, use_debounce_1.useDebouncedCallback)(async (newState, existingMessage) => {
|
|
@@ -33,8 +33,8 @@ function useTamboComponentState(keyName, initialValue, setFromProp, debounceTime
|
|
|
33
33
|
}, debounceTime);
|
|
34
34
|
const setValue = (0, react_1.useCallback)((newState) => {
|
|
35
35
|
setLocalState(newState);
|
|
36
|
-
updateLocalThreadMessage(newState, message);
|
|
37
|
-
updateRemoteThreadMessage(newState, message);
|
|
36
|
+
void updateLocalThreadMessage(newState, message);
|
|
37
|
+
void updateRemoteThreadMessage(newState, message);
|
|
38
38
|
}, [message, updateLocalThreadMessage, updateRemoteThreadMessage]);
|
|
39
39
|
// Mirror the thread message's componentState value to the local state
|
|
40
40
|
(0, react_1.useEffect)(() => {
|
|
@@ -54,7 +54,16 @@ function useTamboComponentState(keyName, initialValue, setFromProp, debounceTime
|
|
|
54
54
|
// Ensure pending changes are flushed on unmount
|
|
55
55
|
(0, react_1.useEffect)(() => {
|
|
56
56
|
return () => {
|
|
57
|
-
|
|
57
|
+
async function flushUpdates() {
|
|
58
|
+
try {
|
|
59
|
+
await updateRemoteThreadMessage.flush();
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
console.error("Failed to flush pending thread message updates:", error);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Fire-and-forget cleanup (errors handled inside)
|
|
66
|
+
void flushUpdates();
|
|
58
67
|
};
|
|
59
68
|
}, [updateRemoteThreadMessage]);
|
|
60
69
|
return [localState, setValue];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-component-state.js","sourceRoot":"","sources":["../../src/hooks/use-component-state.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;
|
|
1
|
+
{"version":3,"file":"use-component-state.js","sourceRoot":"","sources":["../../src/hooks/use-component-state.tsx"],"names":[],"mappings":";AAAA,Y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AM,yBAAyB,CAAC,KAAK,EAAE,CAAC;gBAC1C,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CACX,iDAAiD,EACjD,KAAK,CACN,CAAC;gBACJ,CAAC;YACH,CAAC;YACD,kDAAkD;YAClD,KAAK,YAAY,EAAE,CAAC;QACtB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,yBAAyB,CAAC,CAAC,CAAC;IAEhC,OAAO,CAAC,UAAe,EAAE,QAAQ,CAAC,CAAC;AACrC,CAAC","sourcesContent":["\"use client\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport { useDebouncedCallback } from \"use-debounce\";\nimport { TamboThreadMessage, useTamboClient, useTamboThread } from \"..\";\nimport { useTamboCurrentMessage } from \"./use-current-message\";\n\ntype StateUpdateResult<T> = [currentState: T, setState: (newState: T) => void];\n\n/**\n * Like useState, but syncs to the thread message's `componentState`.\n *\n * Use `setFromProp` to seed state from streamed props. During streaming,\n * state updates as new prop values arrive. Once streaming completes,\n * user edits take precedence over the original prop value.\n *\n * Pair with `useTamboStreamStatus` to disable inputs while streaming.\n * @see {@link https://docs.tambo.co/concepts/streaming/streaming-best-practices}\n * @param keyName - Unique key within the message's componentState\n * @param initialValue - Default value if no componentState exists\n * @param setFromProp - Seeds state from props (updates during streaming, then user edits take over)\n * @param debounceTime - Server sync debounce in ms (default: 500)\n * @returns A tuple of [currentState, setState] similar to React's useState\n */\nexport function useTamboComponentState<S = undefined>(\n keyName: string,\n initialValue?: S,\n setFromProp?: S,\n debounceTime?: number,\n): StateUpdateResult<S | undefined>;\nexport function useTamboComponentState<S>(\n keyName: string,\n initialValue: S,\n setFromProp?: S,\n debounceTime?: number,\n): StateUpdateResult<S>;\nexport function useTamboComponentState<S>(\n keyName: string,\n initialValue?: S,\n setFromProp?: S,\n debounceTime = 500,\n): StateUpdateResult<S> {\n const message = useTamboCurrentMessage();\n const { updateThreadMessage } = useTamboThread();\n const client = useTamboClient();\n const messageState = message?.componentState?.[keyName];\n const [localState, setLocalState] = useState<S | undefined>(\n (messageState as S) ?? initialValue,\n );\n const [initializedFromThreadMessage, setInitializedFromThreadMessage] =\n useState(messageState ? true : false);\n\n // Optimistically update the local thread message's componentState\n const updateLocalThreadMessage = useCallback(\n async (newState: S, existingMessage: TamboThreadMessage) => {\n const updatedMessage = {\n threadId: existingMessage.threadId,\n componentState: {\n ...existingMessage.componentState,\n [keyName]: newState,\n },\n };\n await updateThreadMessage(existingMessage.id, updatedMessage, false);\n },\n [updateThreadMessage, keyName],\n );\n\n // Debounced callback to update the remote thread message's componentState\n const updateRemoteThreadMessage = useDebouncedCallback(\n async (newState: S, existingMessage: TamboThreadMessage) => {\n await client.beta.threads.messages.updateComponentState(\n existingMessage.id,\n {\n id: existingMessage.threadId,\n state: { [keyName]: newState },\n },\n );\n },\n debounceTime,\n );\n\n const setValue = useCallback(\n (newState: S) => {\n setLocalState(newState);\n void updateLocalThreadMessage(newState, message);\n void updateRemoteThreadMessage(newState, message);\n },\n [message, updateLocalThreadMessage, updateRemoteThreadMessage],\n );\n\n // Mirror the thread message's componentState value to the local state\n useEffect(() => {\n const messageState = message?.componentState?.[keyName];\n if (!messageState) {\n return;\n }\n setInitializedFromThreadMessage(true);\n setLocalState(message.componentState?.[keyName] as S);\n }, [message?.componentState?.[keyName], message, keyName]);\n\n // For editable fields that are set from a prop to allow streaming updates, don't overwrite a fetched state value set from the thread message with prop value on initial load.\n useEffect(() => {\n if (setFromProp !== undefined && !initializedFromThreadMessage) {\n setLocalState(setFromProp as S);\n }\n }, [setFromProp, initializedFromThreadMessage]);\n\n // Ensure pending changes are flushed on unmount\n useEffect(() => {\n return () => {\n async function flushUpdates() {\n try {\n await updateRemoteThreadMessage.flush();\n } catch (error) {\n console.error(\n \"Failed to flush pending thread message updates:\",\n error,\n );\n }\n }\n // Fire-and-forget cleanup (errors handled inside)\n void flushUpdates();\n };\n }, [updateRemoteThreadMessage]);\n\n return [localState as S, setValue];\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-component-state.test.d.ts","sourceRoot":"","sources":["../../src/hooks/use-component-state.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const react_1 = require("@testing-library/react");
|
|
4
|
-
const tambo_client_provider_1 = require("
|
|
5
|
-
const tambo_thread_provider_1 = require("
|
|
6
|
-
const use_component_state_1 = require("
|
|
7
|
-
const use_current_message_1 = require("
|
|
4
|
+
const tambo_client_provider_1 = require("../providers/tambo-client-provider");
|
|
5
|
+
const tambo_thread_provider_1 = require("../providers/tambo-thread-provider");
|
|
6
|
+
const use_component_state_1 = require("./use-component-state");
|
|
7
|
+
const use_current_message_1 = require("./use-current-message");
|
|
8
8
|
// Mock the required providers
|
|
9
|
-
jest.mock("
|
|
9
|
+
jest.mock("../providers/tambo-client-provider", () => ({
|
|
10
10
|
useTamboClient: jest.fn(),
|
|
11
11
|
}));
|
|
12
|
-
jest.mock("
|
|
12
|
+
jest.mock("../providers/tambo-thread-provider", () => ({
|
|
13
13
|
useTamboThread: jest.fn(),
|
|
14
14
|
}));
|
|
15
|
-
jest.mock("
|
|
15
|
+
jest.mock("./use-current-message", () => ({
|
|
16
16
|
useTamboCurrentMessage: jest.fn(),
|
|
17
17
|
}));
|
|
18
18
|
// Create a mock debounced function with flush method
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-component-state.test.js","sourceRoot":"","sources":["../../src/hooks/use-component-state.test.tsx"],"names":[],"mappings":";;AAAA,kDAAyD;AAEzD,8EAAoE;AACpE,8EAAoE;AAEpE,+DAA+D;AAC/D,+DAA+D;AAE/D,8BAA8B;AAC9B,IAAI,CAAC,IAAI,CAAC,oCAAoC,EAAE,GAAG,EAAE,CAAC,CAAC;IACrD,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;CAC1B,CAAC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,GAAG,iBAAiB,CAAC;gBACjC,EAAE,EAAE,UAAU;gBACd,cAAc,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE;aACzC,CAAC,CAAC;YAEH,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAA,kBAAU,EACrC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;gBACd,IAAI,CAAC,MAAM,CAAC,4CAAsB,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;gBAC7D,OAAO,IAAA,4CAAsB,EAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YACtD,CAAC,EACD,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,CACxC,CAAC;YAEF,uBAAuB;YACvB,uBAAuB,CAAC,SAAS,EAAE,CAAC;YAEpC,oDAAoD;YACpD,QAAQ,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;YAEhC,wCAAwC;YACxC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { act, renderHook } from \"@testing-library/react\";\nimport { TamboThreadMessage } from \"../model/generate-component-response\";\nimport { useTamboClient } from \"../providers/tambo-client-provider\";\nimport { useTamboThread } from \"../providers/tambo-thread-provider\";\nimport { PartialTamboAI } from \"../testing/types\";\nimport { useTamboComponentState } from \"./use-component-state\";\nimport { useTamboCurrentMessage } from \"./use-current-message\";\n\n// Mock the required providers\njest.mock(\"../providers/tambo-client-provider\", () => ({\n useTamboClient: jest.fn(),\n}));\n\njest.mock(\"../providers/tambo-thread-provider\", () => ({\n useTamboThread: jest.fn(),\n}));\n\njest.mock(\"./use-current-message\", () => ({\n useTamboCurrentMessage: jest.fn(),\n}));\n\n// Create a mock debounced function with flush method\nconst createMockDebouncedFunction = (fn: any) => {\n const debouncedFn = jest.fn((...args: any[]) => fn(...args)) as jest.Mock & {\n flush: jest.Mock;\n cancel: jest.Mock;\n isPending: () => boolean;\n };\n debouncedFn.flush = jest.fn();\n debouncedFn.cancel = jest.fn();\n debouncedFn.isPending = jest.fn(() => false);\n return debouncedFn;\n};\n\n// Mock use-debounce\njest.mock(\"use-debounce\", () => ({\n useDebouncedCallback: jest.fn(),\n}));\n\n// Import the mocked useDebouncedCallback\nimport { useDebouncedCallback } from \"use-debounce\";\n\ndescribe(\"useTamboComponentState\", () => {\n // Helper function to create mock TamboThreadMessage\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 const mockUpdateThreadMessage = jest.fn();\n const mockUpdateComponentState = jest.fn();\n\n beforeEach(() => {\n jest.clearAllMocks();\n\n // Setup default mock for useDebouncedCallback\n jest\n .mocked(useDebouncedCallback)\n .mockImplementation((fn) => createMockDebouncedFunction(fn));\n\n // Setup default mocks\n jest.mocked(useTamboClient).mockReturnValue({\n beta: {\n threads: {\n messages: {\n updateComponentState: mockUpdateComponentState,\n },\n },\n },\n } satisfies PartialTamboAI as any);\n\n jest.mocked(useTamboThread).mockReturnValue({\n updateThreadMessage: mockUpdateThreadMessage,\n } as any);\n\n jest.mocked(useTamboCurrentMessage).mockReturnValue(createMockMessage());\n });\n\n describe(\"Initial State Management\", () => {\n it(\"should initialize with initialValue when no componentState exists\", () => {\n const initialValue = \"test-initial\";\n jest\n .mocked(useTamboCurrentMessage)\n .mockReturnValue(createMockMessage({ componentState: {} }));\n\n const { result } = renderHook(() =>\n useTamboComponentState(\"testKey\", initialValue),\n );\n\n expect(result.current[0]).toBe(initialValue);\n });\n\n it(\"should use existing componentState value over initialValue\", () => {\n const initialValue = \"initial\";\n const existingValue = \"existing\";\n jest.mocked(useTamboCurrentMessage).mockReturnValue(\n createMockMessage({\n componentState: { testKey: existingValue },\n }),\n );\n\n const { result } = renderHook(() =>\n useTamboComponentState(\"testKey\", initialValue),\n );\n\n expect(result.current[0]).toBe(existingValue);\n });\n\n it(\"should handle undefined initialValue gracefully\", () => {\n jest\n .mocked(useTamboCurrentMessage)\n .mockReturnValue(createMockMessage({ componentState: {} }));\n\n const { result } = renderHook(() => useTamboComponentState(\"testKey\"));\n\n expect(result.current[0]).toBeUndefined();\n });\n\n it(\"should handle different data types correctly\", () => {\n const testCases = [\n { value: \"string\" },\n { value: 42 },\n { value: true },\n { value: { name: \"test\" } },\n { value: [1, 2, 3] },\n ];\n\n testCases.forEach(({ value }) => {\n jest.mocked(useTamboCurrentMessage).mockReturnValue(\n createMockMessage({\n componentState: { testKey: value },\n }),\n );\n\n const { result } = renderHook(() =>\n useTamboComponentState(\"testKey\", value),\n );\n\n expect(result.current[0]).toEqual(value);\n });\n });\n });\n\n describe(\"State Updates\", () => {\n it(\"should update local state immediately when setValue is called\", () => {\n const initialValue = \"initial\";\n jest\n .mocked(useTamboCurrentMessage)\n .mockReturnValue(\n createMockMessage({ componentState: { testKey: initialValue } }),\n );\n\n const { result } = renderHook(() =>\n useTamboComponentState(\"testKey\", initialValue),\n );\n\n const newValue = \"updated\";\n act(() => {\n result.current[1](newValue);\n });\n\n expect(result.current[0]).toBe(newValue);\n });\n\n it(\"should trigger local thread message update when setValue is called\", () => {\n const message = createMockMessage({\n componentState: { testKey: \"initial\" },\n });\n jest.mocked(useTamboCurrentMessage).mockReturnValue(message);\n\n const { result } = renderHook(() =>\n useTamboComponentState(\"testKey\", \"initial\"),\n );\n\n const newValue = \"updated\";\n act(() => {\n result.current[1](newValue);\n });\n\n expect(mockUpdateThreadMessage).toHaveBeenCalledWith(\n message.id,\n {\n threadId: message.threadId,\n componentState: {\n testKey: newValue,\n },\n },\n false,\n );\n });\n\n it(\"should trigger debounced remote API call when setValue is called\", () => {\n const message = createMockMessage({\n componentState: { testKey: \"initial\" },\n });\n jest.mocked(useTamboCurrentMessage).mockReturnValue(message);\n\n const { result } = renderHook(() =>\n useTamboComponentState(\"testKey\", \"initial\"),\n );\n\n const newValue = \"updated\";\n act(() => {\n result.current[1](newValue);\n });\n\n // The debounced function should be called\n expect(mockUpdateComponentState).toHaveBeenCalledWith(message.id, {\n id: message.threadId,\n state: { testKey: newValue },\n });\n });\n\n it(\"should work with complex objects and arrays\", () => {\n const initialValue = { name: \"test\", items: [1, 2, 3] };\n jest\n .mocked(useTamboCurrentMessage)\n .mockReturnValue(\n createMockMessage({ componentState: { testKey: initialValue } }),\n );\n\n const { result } = renderHook(() =>\n useTamboComponentState(\"testKey\", initialValue),\n );\n\n const newValue = { name: \"updated\", items: [4, 5, 6] };\n act(() => {\n result.current[1](newValue);\n });\n\n expect(result.current[0]).toEqual(newValue);\n expect(mockUpdateThreadMessage).toHaveBeenCalledWith(\n expect.any(String),\n expect.objectContaining({\n componentState: {\n testKey: newValue,\n },\n }),\n false,\n );\n });\n });\n\n describe(\"Debouncing Behavior\", () => {\n it(\"should use default debounce time of 500ms\", () => {\n renderHook(() => useTamboComponentState(\"testKey\", \"initial\"));\n\n expect(useDebouncedCallback).toHaveBeenCalledWith(\n expect.any(Function),\n 500,\n );\n });\n\n it(\"should use custom debounce time when provided\", () => {\n const customDebounceTime = 1000;\n\n renderHook(() =>\n useTamboComponentState(\n \"testKey\",\n \"initial\",\n undefined,\n customDebounceTime,\n ),\n );\n\n expect(useDebouncedCallback).toHaveBeenCalledWith(\n expect.any(Function),\n customDebounceTime,\n );\n });\n\n it(\"should flush debounced callback on unmount\", () => {\n const mockFlush = jest.fn();\n const mockDebouncedFn = createMockDebouncedFunction(jest.fn());\n mockDebouncedFn.flush = mockFlush;\n\n // Mock the debounced callback to return our specific mock\n jest.mocked(useDebouncedCallback).mockReturnValue(mockDebouncedFn);\n\n const { unmount } = renderHook(() =>\n useTamboComponentState(\"testKey\", \"initial\"),\n );\n\n unmount();\n\n expect(mockFlush).toHaveBeenCalled();\n });\n });\n\n describe(\"Multi-Hook Scenarios\", () => {\n it(\"should handle multiple hooks with different keyNames independently\", () => {\n const message = createMockMessage({\n componentState: {\n key1: \"value1\",\n key2: \"value2\",\n },\n });\n jest.mocked(useTamboCurrentMessage).mockReturnValue(message);\n\n const { result: result1 } = renderHook(() =>\n useTamboComponentState(\"key1\", \"default1\"),\n );\n const { result: result2 } = renderHook(() =>\n useTamboComponentState(\"key2\", \"default2\"),\n );\n\n expect(result1.current[0]).toBe(\"value1\");\n expect(result2.current[0]).toBe(\"value2\");\n\n // Update first hook\n act(() => {\n result1.current[1](\"updated1\");\n });\n\n expect(result1.current[0]).toBe(\"updated1\");\n expect(result2.current[0]).toBe(\"value2\"); // Should remain unchanged\n });\n\n it(\"should preserve existing componentState when updating another key\", () => {\n const message = createMockMessage({\n componentState: {\n existingKey: \"existing\",\n testKey: \"initial\",\n },\n });\n jest.mocked(useTamboCurrentMessage).mockReturnValue(message);\n\n const { result } = renderHook(() =>\n useTamboComponentState(\"testKey\", \"initial\"),\n );\n\n act(() => {\n result.current[1](\"updated\");\n });\n\n expect(mockUpdateThreadMessage).toHaveBeenCalledWith(\n message.id,\n {\n threadId: message.threadId,\n componentState: {\n existingKey: \"existing\", // Should preserve existing keys\n testKey: \"updated\",\n },\n },\n false,\n );\n });\n });\n\n describe(\"SetFromProp Feature\", () => {\n it(\"should set value from prop when hasSetFromMessage is false\", () => {\n jest\n .mocked(useTamboCurrentMessage)\n .mockReturnValue(createMockMessage({ componentState: {} }));\n\n const propValue = \"from-prop\";\n const { result } = renderHook(() =>\n useTamboComponentState(\"testKey\", \"initial\", propValue),\n );\n\n // Initially, hasSetFromMessage should be false, so prop value should be used\n expect(result.current[0]).toBe(propValue);\n });\n\n it(\"should ignore setFromProp when initialized from message state\", async () => {\n const existingValue = \"existing\";\n jest.mocked(useTamboCurrentMessage).mockReturnValue(\n createMockMessage({\n componentState: { testKey: existingValue },\n }),\n );\n\n const propValue = \"from-prop\";\n const { result } = renderHook(() =>\n useTamboComponentState(\"testKey\", \"initial\", propValue),\n );\n\n // Should use existing value from message, not prop value\n await act(async () => {\n await new Promise((resolve) => setTimeout(resolve, 0));\n });\n\n expect(result.current[0]).toBe(existingValue);\n });\n\n it(\"should update state from setFromProp changes when no message state exists\", () => {\n jest\n .mocked(useTamboCurrentMessage)\n .mockReturnValue(createMockMessage({ componentState: {} }));\n\n const { result, rerender } = renderHook(\n ({ propValue }) =>\n useTamboComponentState(\"testKey\", \"initial\", propValue),\n { initialProps: { propValue: \"prop1\" } },\n );\n\n expect(result.current[0]).toBe(\"prop1\");\n\n // Change prop value\n rerender({ propValue: \"prop2\" });\n\n // Since hasSetFromMessage is still false (no message state),\n // it should update to new prop value\n expect(result.current[0]).toBe(\"prop2\");\n });\n\n it(\"should handle undefined setFromProp gracefully\", () => {\n jest\n .mocked(useTamboCurrentMessage)\n .mockReturnValue(createMockMessage({ componentState: {} }));\n\n const { result } = renderHook(() =>\n useTamboComponentState(\"testKey\", \"initial\", undefined),\n );\n\n expect(result.current[0]).toBe(\"initial\");\n });\n });\n\n describe(\"Message State Sync\", () => {\n it(\"should sync with message.componentState changes\", () => {\n const { result, rerender } = renderHook(\n ({ message }) => {\n jest.mocked(useTamboCurrentMessage).mockReturnValue(message);\n return useTamboComponentState(\"testKey\", \"initial\");\n },\n {\n initialProps: {\n message: createMockMessage({\n componentState: { testKey: \"value1\" },\n }),\n },\n },\n );\n\n // Change the message\n const newMessage = createMockMessage({\n componentState: { testKey: \"value2\" },\n });\n\n rerender({ message: newMessage });\n\n // The hook should sync with the new message state\n expect(result.current[0]).toBe(\"value2\");\n expect(mockUpdateThreadMessage).not.toHaveBeenCalled();\n });\n\n it(\"should handle message without componentState gracefully\", () => {\n jest\n .mocked(useTamboCurrentMessage)\n .mockReturnValue(\n createMockMessage({ componentState: undefined as any }),\n );\n\n const { result } = renderHook(() =>\n useTamboComponentState(\"testKey\", \"initial\"),\n );\n\n expect(result.current[0]).toBe(\"initial\");\n });\n\n it(\"should preserve state when message updates but componentState[keyName] unchanged\", () => {\n const message1 = createMockMessage({\n id: \"message1\",\n componentState: { testKey: \"unchanged\" },\n });\n const message2 = createMockMessage({\n id: \"message2\",\n componentState: { testKey: \"unchanged\" },\n });\n\n const { result, rerender } = renderHook(\n ({ message }) => {\n jest.mocked(useTamboCurrentMessage).mockReturnValue(message);\n return useTamboComponentState(\"testKey\", \"initial\");\n },\n { initialProps: { message: message1 } },\n );\n\n // Clear previous calls\n mockUpdateThreadMessage.mockClear();\n\n // Change message but keep same componentState value\n rerender({ message: message2 });\n\n // Should preserve the \"unchanged\" value\n expect(result.current[0]).toBe(\"unchanged\");\n });\n });\n});\n"]}
|
|
@@ -1,27 +1,71 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { TamboThreadMessage } from "../model/generate-component-response";
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { InteractableMetadata, TamboThreadMessage } from "../model/generate-component-response";
|
|
3
|
+
export interface TamboMessageProviderProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
message: TamboThreadMessage;
|
|
6
|
+
/** Optional interactable metadata for components wrapped with withInteractable */
|
|
7
|
+
interactableMetadata?: InteractableMetadata;
|
|
8
|
+
}
|
|
3
9
|
/**
|
|
4
|
-
* Wraps all components, so that they can find what message they are in
|
|
10
|
+
* Wraps all components, so that they can find what message they are in.
|
|
11
|
+
* Also supports optional interactable metadata for components wrapped with withInteractable.
|
|
5
12
|
* @param props - props for the TamboMessageProvider
|
|
6
13
|
* @param props.children - The children to wrap
|
|
7
14
|
* @param props.message - The message object
|
|
15
|
+
* @param props.interactableMetadata - Optional interactable component metadata
|
|
8
16
|
* @returns The wrapped component
|
|
9
17
|
*/
|
|
10
|
-
export declare const TamboMessageProvider: React.FC<
|
|
11
|
-
message: TamboThreadMessage;
|
|
12
|
-
}>>;
|
|
18
|
+
export declare const TamboMessageProvider: React.FC<TamboMessageProviderProps>;
|
|
13
19
|
/**
|
|
14
20
|
* Wraps a component with a TamboMessageProvider - this allows the provider
|
|
15
21
|
* to be used outside of a TSX file
|
|
16
22
|
* @param children - The children to wrap
|
|
17
23
|
* @param message - The message object
|
|
24
|
+
* @param interactableMetadata - Optional interactable metadata
|
|
18
25
|
* @returns The wrapped component
|
|
19
26
|
*/
|
|
20
|
-
export declare function wrapWithTamboMessageProvider(children: React.ReactNode, message: TamboThreadMessage): React.JSX.Element;
|
|
27
|
+
export declare function wrapWithTamboMessageProvider(children: React.ReactNode, message: TamboThreadMessage, interactableMetadata?: InteractableMetadata): React.JSX.Element;
|
|
21
28
|
/**
|
|
22
29
|
* Hook used inside a component wrapped with TamboMessageProvider, to get
|
|
23
30
|
* the current message.
|
|
24
31
|
* @returns The current message that is used to render the component
|
|
25
32
|
*/
|
|
26
33
|
export declare const useTamboCurrentMessage: () => TamboThreadMessage;
|
|
34
|
+
/**
|
|
35
|
+
* Component info extracted from the current message and interactable context.
|
|
36
|
+
* Provides a unified interface for accessing component metadata.
|
|
37
|
+
*/
|
|
38
|
+
export interface TamboCurrentComponent {
|
|
39
|
+
/** Component name from the message */
|
|
40
|
+
componentName?: string;
|
|
41
|
+
/** Component props from the message */
|
|
42
|
+
props?: Record<string, any>;
|
|
43
|
+
/** Interactable ID (only present for components wrapped with withInteractable) */
|
|
44
|
+
interactableId?: string;
|
|
45
|
+
/** Description (only present for components wrapped with withInteractable) */
|
|
46
|
+
description?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Hook to access the current component information from the message context.
|
|
50
|
+
* Provides a unified interface for both AI-generated and interactable components.
|
|
51
|
+
*
|
|
52
|
+
* **Use this hook when you need component metadata regardless of the context.**
|
|
53
|
+
* @returns Component info including name, props, and interactable metadata if available, or null if used outside TamboMessageProvider
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* function MyInlineEditor() {
|
|
57
|
+
* const component = useTamboCurrentComponent();
|
|
58
|
+
*
|
|
59
|
+
* if (!component) return null; // Not inside a component
|
|
60
|
+
*
|
|
61
|
+
* return (
|
|
62
|
+
* <div>
|
|
63
|
+
* Editing: {component.componentName}
|
|
64
|
+
* {component.interactableId && <span>ID: {component.interactableId}</span>}
|
|
65
|
+
* </div>
|
|
66
|
+
* );
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare const useTamboCurrentComponent: () => TamboCurrentComponent | null;
|
|
27
71
|
//# sourceMappingURL=use-current-message.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-current-message.d.ts","sourceRoot":"","sources":["../../src/hooks/use-current-message.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
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;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,wBAAwB,QAAO,qBAAqB,GAAG,IAgBnE,CAAC"}
|