@tambo-ai/react 0.67.1 → 0.69.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 +3 -5
- package/dist/context-helpers/context-helpers.test.js +16 -4
- package/dist/context-helpers/context-helpers.test.js.map +1 -1
- package/dist/context-helpers/current-interactables-context-helper.d.ts +2 -2
- package/dist/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
- package/dist/context-helpers/current-interactables-context-helper.js +31 -12
- package/dist/context-helpers/current-interactables-context-helper.js.map +1 -1
- package/dist/context-helpers/registry.d.ts +2 -2
- package/dist/context-helpers/registry.d.ts.map +1 -1
- package/dist/context-helpers/registry.js.map +1 -1
- package/dist/context-helpers/types.d.ts +2 -2
- package/dist/context-helpers/types.d.ts.map +1 -1
- package/dist/context-helpers/types.js.map +1 -1
- package/dist/hoc/with-tambo-interactable.d.ts +50 -4
- package/dist/hoc/with-tambo-interactable.d.ts.map +1 -1
- package/dist/hoc/with-tambo-interactable.js +20 -5
- package/dist/hoc/with-tambo-interactable.js.map +1 -1
- package/dist/hooks/use-component-state.d.ts +3 -8
- package/dist/hooks/use-component-state.d.ts.map +1 -1
- package/dist/hooks/use-component-state.js +8 -0
- package/dist/hooks/use-component-state.js.map +1 -1
- package/dist/hooks/use-component-state.test.js +37 -0
- package/dist/hooks/use-component-state.test.js.map +1 -1
- package/dist/hooks/use-message-images.test.js +174 -37
- package/dist/hooks/use-message-images.test.js.map +1 -1
- package/dist/hooks/use-tambo-threads.js +1 -1
- package/dist/hooks/use-tambo-threads.js.map +1 -1
- package/dist/hooks/use-tambo-voice.d.ts +1 -1
- package/dist/hooks/use-tambo-voice.js +1 -1
- package/dist/hooks/use-tambo-voice.js.map +1 -1
- package/dist/hooks/use-tambo-voice.test.d.ts +2 -0
- package/dist/hooks/use-tambo-voice.test.d.ts.map +1 -0
- package/dist/hooks/use-tambo-voice.test.js +239 -0
- package/dist/hooks/use-tambo-voice.test.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/elicitation.d.ts.map +1 -1
- package/dist/mcp/elicitation.js +12 -0
- package/dist/mcp/elicitation.js.map +1 -1
- package/dist/mcp/elicitation.test.js +8 -1
- package/dist/mcp/elicitation.test.js.map +1 -1
- package/dist/mcp/mcp-client.d.ts +6 -10
- package/dist/mcp/mcp-client.d.ts.map +1 -1
- package/dist/mcp/mcp-client.js.map +1 -1
- package/dist/mcp/mcp-constants.d.ts +19 -0
- package/dist/mcp/mcp-constants.d.ts.map +1 -0
- package/dist/mcp/mcp-constants.js +21 -0
- package/dist/mcp/mcp-constants.js.map +1 -0
- package/dist/mcp/mcp-hooks.d.ts +21 -40
- package/dist/mcp/mcp-hooks.d.ts.map +1 -1
- package/dist/mcp/mcp-hooks.js +130 -39
- package/dist/mcp/mcp-hooks.js.map +1 -1
- package/dist/mcp/mcp-hooks.test.js +431 -5
- package/dist/mcp/mcp-hooks.test.js.map +1 -1
- package/dist/mcp/tambo-mcp-provider.d.ts +7 -0
- package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
- package/dist/mcp/tambo-mcp-provider.js +205 -155
- package/dist/mcp/tambo-mcp-provider.js.map +1 -1
- package/dist/mcp/tambo-mcp-provider.test.js +37 -0
- package/dist/mcp/tambo-mcp-provider.test.js.map +1 -1
- package/dist/model/component-metadata.d.ts +54 -21
- package/dist/model/component-metadata.d.ts.map +1 -1
- package/dist/model/component-metadata.js.map +1 -1
- package/dist/model/tambo-interactable.d.ts +13 -5
- package/dist/model/tambo-interactable.d.ts.map +1 -1
- package/dist/model/tambo-interactable.js.map +1 -1
- package/dist/providers/__tests__/thread-input-resource-resolution.test.d.ts +2 -0
- package/dist/providers/__tests__/thread-input-resource-resolution.test.d.ts.map +1 -0
- package/dist/providers/__tests__/thread-input-resource-resolution.test.js +592 -0
- package/dist/providers/__tests__/thread-input-resource-resolution.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 +8 -0
- package/dist/providers/tambo-client-provider.d.ts.map +1 -1
- package/dist/providers/tambo-client-provider.js +10 -11
- package/dist/providers/tambo-client-provider.js.map +1 -1
- package/dist/providers/tambo-client-provider.test.d.ts +2 -0
- package/dist/providers/tambo-client-provider.test.d.ts.map +1 -0
- package/dist/providers/tambo-client-provider.test.js +208 -0
- package/dist/providers/tambo-client-provider.test.js.map +1 -0
- package/dist/providers/tambo-context-attachment-provider.d.ts +34 -92
- package/dist/providers/tambo-context-attachment-provider.d.ts.map +1 -1
- package/dist/providers/tambo-context-attachment-provider.js +62 -105
- package/dist/providers/tambo-context-attachment-provider.js.map +1 -1
- package/dist/providers/tambo-context-attachment-provider.test.js +229 -463
- package/dist/providers/tambo-context-attachment-provider.test.js.map +1 -1
- package/dist/providers/tambo-interactable-provider-partial-updates.test.js +22 -21
- package/dist/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
- package/dist/providers/tambo-interactable-provider.d.ts +5 -2
- package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
- package/dist/providers/tambo-interactable-provider.js +126 -17
- package/dist/providers/tambo-interactable-provider.js.map +1 -1
- package/dist/providers/tambo-interactable-provider.test.js +242 -0
- package/dist/providers/tambo-interactable-provider.test.js.map +1 -1
- package/dist/providers/tambo-interactables-additional-context.test.js +2 -5
- package/dist/providers/tambo-interactables-additional-context.test.js.map +1 -1
- package/dist/providers/tambo-provider.d.ts +2 -3
- package/dist/providers/tambo-provider.d.ts.map +1 -1
- package/dist/providers/tambo-provider.js +6 -5
- package/dist/providers/tambo-provider.js.map +1 -1
- package/dist/providers/tambo-registry-provider.test.js +16 -0
- package/dist/providers/tambo-registry-provider.test.js.map +1 -1
- package/dist/providers/tambo-registry-schema-compat.test.js +31 -0
- package/dist/providers/tambo-registry-schema-compat.test.js.map +1 -1
- package/dist/providers/tambo-thread-input-provider.d.ts +1 -1
- package/dist/providers/tambo-thread-input-provider.d.ts.map +1 -1
- package/dist/providers/tambo-thread-input-provider.js +26 -4
- package/dist/providers/tambo-thread-input-provider.js.map +1 -1
- package/dist/providers/tambo-thread-provider-initial-messages.test.js +84 -2
- package/dist/providers/tambo-thread-provider-initial-messages.test.js.map +1 -1
- package/dist/providers/tambo-thread-provider.d.ts.map +1 -1
- package/dist/providers/tambo-thread-provider.js +53 -42
- package/dist/providers/tambo-thread-provider.js.map +1 -1
- package/dist/providers/tambo-thread-provider.test.js +368 -262
- package/dist/providers/tambo-thread-provider.test.js.map +1 -1
- package/dist/schema/index.d.ts +1 -1
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +2 -1
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/json-schema.d.ts +7 -0
- package/dist/schema/json-schema.d.ts.map +1 -1
- package/dist/schema/json-schema.js +40 -29
- package/dist/schema/json-schema.js.map +1 -1
- package/dist/schema/json-schema.test.d.ts +2 -0
- package/dist/schema/json-schema.test.d.ts.map +1 -0
- package/dist/schema/json-schema.test.js +204 -0
- package/dist/schema/json-schema.test.js.map +1 -0
- package/dist/schema/schema.test.js +237 -0
- package/dist/schema/schema.test.js.map +1 -1
- package/dist/schema/standard-schema.d.ts +1 -0
- package/dist/schema/standard-schema.d.ts.map +1 -1
- package/dist/schema/standard-schema.js +18 -13
- package/dist/schema/standard-schema.js.map +1 -1
- package/dist/schema/standard-schema.test.d.ts +2 -0
- package/dist/schema/standard-schema.test.d.ts.map +1 -0
- package/dist/schema/standard-schema.test.js +165 -0
- package/dist/schema/standard-schema.test.js.map +1 -0
- package/dist/schema/validate.test.js +149 -0
- package/dist/schema/validate.test.js.map +1 -1
- package/dist/schema/zod.d.ts +7 -4
- package/dist/schema/zod.d.ts.map +1 -1
- package/dist/schema/zod.js +65 -22
- package/dist/schema/zod.js.map +1 -1
- package/dist/schema/zod.test.js +112 -0
- package/dist/schema/zod.test.js.map +1 -1
- package/dist/setupTests.js +3 -0
- package/dist/setupTests.js.map +1 -1
- package/dist/testing/tools.d.ts +4 -1
- package/dist/testing/tools.d.ts.map +1 -1
- package/dist/testing/tools.js +6 -1
- package/dist/testing/tools.js.map +1 -1
- package/dist/util/generate-component.d.ts.map +1 -1
- package/dist/util/generate-component.js +18 -3
- package/dist/util/generate-component.js.map +1 -1
- package/dist/util/generate-component.test.d.ts +2 -0
- package/dist/util/generate-component.test.d.ts.map +1 -0
- package/dist/util/generate-component.test.js +340 -0
- package/dist/util/generate-component.test.js.map +1 -0
- package/dist/util/is-promise.d.ts +9 -0
- package/dist/util/is-promise.d.ts.map +1 -0
- package/dist/util/is-promise.js +20 -0
- package/dist/util/is-promise.js.map +1 -0
- package/dist/util/is-promise.test.d.ts +2 -0
- package/dist/util/is-promise.test.d.ts.map +1 -0
- package/dist/util/is-promise.test.js +48 -0
- package/dist/util/is-promise.test.js.map +1 -0
- package/dist/util/message-builder.d.ts +3 -1
- package/dist/util/message-builder.d.ts.map +1 -1
- package/dist/util/message-builder.js +20 -3
- package/dist/util/message-builder.js.map +1 -1
- package/dist/util/message-builder.test.js +269 -0
- package/dist/util/message-builder.test.js.map +1 -1
- package/dist/util/query-utils.test.d.ts +2 -0
- package/dist/util/query-utils.test.d.ts.map +1 -0
- package/dist/util/query-utils.test.js +382 -0
- package/dist/util/query-utils.test.js.map +1 -0
- package/dist/util/registry-validators.d.ts.map +1 -1
- package/dist/util/registry-validators.js +7 -0
- package/dist/util/registry-validators.js.map +1 -1
- package/dist/util/registry-validators.test.js +57 -0
- package/dist/util/registry-validators.test.js.map +1 -1
- package/dist/util/registry.d.ts.map +1 -1
- package/dist/util/registry.js +9 -0
- package/dist/util/registry.js.map +1 -1
- package/dist/util/registry.test.js +323 -1
- package/dist/util/registry.test.js.map +1 -1
- package/dist/util/resource-content-resolver.d.ts +20 -0
- package/dist/util/resource-content-resolver.d.ts.map +1 -0
- package/dist/util/resource-content-resolver.js +93 -0
- package/dist/util/resource-content-resolver.js.map +1 -0
- package/dist/util/resource-content-resolver.test.d.ts +2 -0
- package/dist/util/resource-content-resolver.test.d.ts.map +1 -0
- package/dist/util/resource-content-resolver.test.js +254 -0
- package/dist/util/resource-content-resolver.test.js.map +1 -0
- package/dist/util/resource-validators.test.d.ts +2 -0
- package/dist/util/resource-validators.test.d.ts.map +1 -0
- package/dist/util/resource-validators.test.js +90 -0
- package/dist/util/resource-validators.test.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 +8 -8
- package/dist/util/tool-caller.js.map +1 -1
- package/dist/util/validate-component-name.test.d.ts +2 -0
- package/dist/util/validate-component-name.test.d.ts.map +1 -0
- package/dist/util/validate-component-name.test.js +35 -0
- package/dist/util/validate-component-name.test.js.map +1 -0
- package/esm/context-helpers/context-helpers.test.js +16 -4
- package/esm/context-helpers/context-helpers.test.js.map +1 -1
- package/esm/context-helpers/current-interactables-context-helper.d.ts +2 -2
- package/esm/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
- package/esm/context-helpers/current-interactables-context-helper.js +31 -12
- package/esm/context-helpers/current-interactables-context-helper.js.map +1 -1
- package/esm/context-helpers/registry.d.ts +2 -2
- package/esm/context-helpers/registry.d.ts.map +1 -1
- package/esm/context-helpers/registry.js.map +1 -1
- package/esm/context-helpers/types.d.ts +2 -2
- package/esm/context-helpers/types.d.ts.map +1 -1
- package/esm/context-helpers/types.js.map +1 -1
- package/esm/hoc/with-tambo-interactable.d.ts +50 -4
- package/esm/hoc/with-tambo-interactable.d.ts.map +1 -1
- package/esm/hoc/with-tambo-interactable.js +20 -5
- package/esm/hoc/with-tambo-interactable.js.map +1 -1
- package/esm/hooks/use-component-state.d.ts +3 -8
- package/esm/hooks/use-component-state.d.ts.map +1 -1
- package/esm/hooks/use-component-state.js +8 -0
- package/esm/hooks/use-component-state.js.map +1 -1
- package/esm/hooks/use-component-state.test.js +37 -0
- package/esm/hooks/use-component-state.test.js.map +1 -1
- package/esm/hooks/use-message-images.test.js +174 -37
- package/esm/hooks/use-message-images.test.js.map +1 -1
- package/esm/hooks/use-tambo-threads.js +1 -1
- package/esm/hooks/use-tambo-threads.js.map +1 -1
- package/esm/hooks/use-tambo-voice.d.ts +1 -1
- package/esm/hooks/use-tambo-voice.js +1 -1
- package/esm/hooks/use-tambo-voice.js.map +1 -1
- package/esm/hooks/use-tambo-voice.test.d.ts +2 -0
- package/esm/hooks/use-tambo-voice.test.d.ts.map +1 -0
- package/esm/hooks/use-tambo-voice.test.js +234 -0
- package/esm/hooks/use-tambo-voice.test.js.map +1 -0
- package/esm/index.d.ts +2 -2
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js.map +1 -1
- package/esm/mcp/elicitation.d.ts.map +1 -1
- package/esm/mcp/elicitation.js +12 -0
- package/esm/mcp/elicitation.js.map +1 -1
- package/esm/mcp/elicitation.test.js +8 -1
- package/esm/mcp/elicitation.test.js.map +1 -1
- package/esm/mcp/mcp-client.d.ts +6 -10
- package/esm/mcp/mcp-client.d.ts.map +1 -1
- package/esm/mcp/mcp-client.js.map +1 -1
- package/esm/mcp/mcp-constants.d.ts +19 -0
- package/esm/mcp/mcp-constants.d.ts.map +1 -0
- package/esm/mcp/mcp-constants.js +18 -0
- package/esm/mcp/mcp-constants.js.map +1 -0
- package/esm/mcp/mcp-hooks.d.ts +21 -40
- package/esm/mcp/mcp-hooks.d.ts.map +1 -1
- package/esm/mcp/mcp-hooks.js +97 -40
- package/esm/mcp/mcp-hooks.js.map +1 -1
- package/esm/mcp/mcp-hooks.test.js +431 -5
- package/esm/mcp/mcp-hooks.test.js.map +1 -1
- package/esm/mcp/tambo-mcp-provider.d.ts +7 -0
- package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
- package/esm/mcp/tambo-mcp-provider.js +204 -154
- package/esm/mcp/tambo-mcp-provider.js.map +1 -1
- package/esm/mcp/tambo-mcp-provider.test.js +37 -0
- package/esm/mcp/tambo-mcp-provider.test.js.map +1 -1
- package/esm/model/component-metadata.d.ts +54 -21
- package/esm/model/component-metadata.d.ts.map +1 -1
- package/esm/model/component-metadata.js.map +1 -1
- package/esm/model/tambo-interactable.d.ts +13 -5
- package/esm/model/tambo-interactable.d.ts.map +1 -1
- package/esm/model/tambo-interactable.js.map +1 -1
- package/esm/providers/__tests__/thread-input-resource-resolution.test.d.ts +2 -0
- package/esm/providers/__tests__/thread-input-resource-resolution.test.d.ts.map +1 -0
- package/esm/providers/__tests__/thread-input-resource-resolution.test.js +587 -0
- package/esm/providers/__tests__/thread-input-resource-resolution.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 +8 -0
- package/esm/providers/tambo-client-provider.d.ts.map +1 -1
- package/esm/providers/tambo-client-provider.js +11 -12
- package/esm/providers/tambo-client-provider.js.map +1 -1
- package/esm/providers/tambo-client-provider.test.d.ts +2 -0
- package/esm/providers/tambo-client-provider.test.d.ts.map +1 -0
- package/esm/providers/tambo-client-provider.test.js +203 -0
- package/esm/providers/tambo-client-provider.test.js.map +1 -0
- package/esm/providers/tambo-context-attachment-provider.d.ts +34 -92
- package/esm/providers/tambo-context-attachment-provider.d.ts.map +1 -1
- package/esm/providers/tambo-context-attachment-provider.js +63 -106
- package/esm/providers/tambo-context-attachment-provider.js.map +1 -1
- package/esm/providers/tambo-context-attachment-provider.test.js +230 -464
- package/esm/providers/tambo-context-attachment-provider.test.js.map +1 -1
- package/esm/providers/tambo-interactable-provider-partial-updates.test.js +22 -21
- package/esm/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
- package/esm/providers/tambo-interactable-provider.d.ts +5 -2
- package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
- package/esm/providers/tambo-interactable-provider.js +126 -17
- package/esm/providers/tambo-interactable-provider.js.map +1 -1
- package/esm/providers/tambo-interactable-provider.test.js +242 -0
- package/esm/providers/tambo-interactable-provider.test.js.map +1 -1
- package/esm/providers/tambo-interactables-additional-context.test.js +2 -5
- package/esm/providers/tambo-interactables-additional-context.test.js.map +1 -1
- package/esm/providers/tambo-provider.d.ts +2 -3
- package/esm/providers/tambo-provider.d.ts.map +1 -1
- package/esm/providers/tambo-provider.js +6 -5
- package/esm/providers/tambo-provider.js.map +1 -1
- package/esm/providers/tambo-registry-provider.test.js +16 -0
- package/esm/providers/tambo-registry-provider.test.js.map +1 -1
- package/esm/providers/tambo-registry-schema-compat.test.js +31 -0
- package/esm/providers/tambo-registry-schema-compat.test.js.map +1 -1
- package/esm/providers/tambo-thread-input-provider.d.ts +1 -1
- package/esm/providers/tambo-thread-input-provider.d.ts.map +1 -1
- package/esm/providers/tambo-thread-input-provider.js +26 -4
- package/esm/providers/tambo-thread-input-provider.js.map +1 -1
- package/esm/providers/tambo-thread-provider-initial-messages.test.js +84 -2
- package/esm/providers/tambo-thread-provider-initial-messages.test.js.map +1 -1
- package/esm/providers/tambo-thread-provider.d.ts.map +1 -1
- package/esm/providers/tambo-thread-provider.js +53 -42
- package/esm/providers/tambo-thread-provider.js.map +1 -1
- package/esm/providers/tambo-thread-provider.test.js +368 -262
- package/esm/providers/tambo-thread-provider.test.js.map +1 -1
- package/esm/schema/index.d.ts +1 -1
- package/esm/schema/index.d.ts.map +1 -1
- package/esm/schema/index.js +1 -1
- package/esm/schema/index.js.map +1 -1
- package/esm/schema/json-schema.d.ts +7 -0
- package/esm/schema/json-schema.d.ts.map +1 -1
- package/esm/schema/json-schema.js +11 -1
- package/esm/schema/json-schema.js.map +1 -1
- package/esm/schema/json-schema.test.d.ts +2 -0
- package/esm/schema/json-schema.test.d.ts.map +1 -0
- package/esm/schema/json-schema.test.js +202 -0
- package/esm/schema/json-schema.test.js.map +1 -0
- package/esm/schema/schema.test.js +238 -1
- package/esm/schema/schema.test.js.map +1 -1
- package/esm/schema/standard-schema.d.ts +1 -0
- package/esm/schema/standard-schema.d.ts.map +1 -1
- package/esm/schema/standard-schema.js +18 -13
- package/esm/schema/standard-schema.js.map +1 -1
- package/esm/schema/standard-schema.test.d.ts +2 -0
- package/esm/schema/standard-schema.test.d.ts.map +1 -0
- package/esm/schema/standard-schema.test.js +130 -0
- package/esm/schema/standard-schema.test.js.map +1 -0
- package/esm/schema/validate.test.js +149 -0
- package/esm/schema/validate.test.js.map +1 -1
- package/esm/schema/zod.d.ts +7 -4
- package/esm/schema/zod.d.ts.map +1 -1
- package/esm/schema/zod.js +65 -22
- package/esm/schema/zod.js.map +1 -1
- package/esm/schema/zod.test.js +113 -1
- package/esm/schema/zod.test.js.map +1 -1
- package/esm/setupTests.js +3 -0
- package/esm/setupTests.js.map +1 -1
- package/esm/testing/tools.d.ts +4 -1
- package/esm/testing/tools.d.ts.map +1 -1
- package/esm/testing/tools.js +6 -1
- package/esm/testing/tools.js.map +1 -1
- package/esm/util/generate-component.d.ts.map +1 -1
- package/esm/util/generate-component.js +18 -3
- package/esm/util/generate-component.js.map +1 -1
- package/esm/util/generate-component.test.d.ts +2 -0
- package/esm/util/generate-component.test.d.ts.map +1 -0
- package/esm/util/generate-component.test.js +302 -0
- package/esm/util/generate-component.test.js.map +1 -0
- package/esm/util/is-promise.d.ts +9 -0
- package/esm/util/is-promise.d.ts.map +1 -0
- package/esm/util/is-promise.js +17 -0
- package/esm/util/is-promise.js.map +1 -0
- package/esm/util/is-promise.test.d.ts +2 -0
- package/esm/util/is-promise.test.d.ts.map +1 -0
- package/esm/util/is-promise.test.js +46 -0
- package/esm/util/is-promise.test.js.map +1 -0
- package/esm/util/message-builder.d.ts +3 -1
- package/esm/util/message-builder.d.ts.map +1 -1
- package/esm/util/message-builder.js +20 -3
- package/esm/util/message-builder.js.map +1 -1
- package/esm/util/message-builder.test.js +269 -0
- package/esm/util/message-builder.test.js.map +1 -1
- package/esm/util/query-utils.test.d.ts +2 -0
- package/esm/util/query-utils.test.d.ts.map +1 -0
- package/esm/util/query-utils.test.js +380 -0
- package/esm/util/query-utils.test.js.map +1 -0
- package/esm/util/registry-validators.d.ts.map +1 -1
- package/esm/util/registry-validators.js +7 -0
- package/esm/util/registry-validators.js.map +1 -1
- package/esm/util/registry-validators.test.js +57 -0
- package/esm/util/registry-validators.test.js.map +1 -1
- package/esm/util/registry.d.ts.map +1 -1
- package/esm/util/registry.js +9 -0
- package/esm/util/registry.js.map +1 -1
- package/esm/util/registry.test.js +324 -2
- package/esm/util/registry.test.js.map +1 -1
- package/esm/util/resource-content-resolver.d.ts +20 -0
- package/esm/util/resource-content-resolver.d.ts.map +1 -0
- package/esm/util/resource-content-resolver.js +89 -0
- package/esm/util/resource-content-resolver.js.map +1 -0
- package/esm/util/resource-content-resolver.test.d.ts +2 -0
- package/esm/util/resource-content-resolver.test.d.ts.map +1 -0
- package/esm/util/resource-content-resolver.test.js +252 -0
- package/esm/util/resource-content-resolver.test.js.map +1 -0
- package/esm/util/resource-validators.test.d.ts +2 -0
- package/esm/util/resource-validators.test.d.ts.map +1 -0
- package/esm/util/resource-validators.test.js +88 -0
- package/esm/util/resource-validators.test.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 +8 -8
- package/esm/util/tool-caller.js.map +1 -1
- package/esm/util/validate-component-name.test.d.ts +2 -0
- package/esm/util/validate-component-name.test.d.ts.map +1 -0
- package/esm/util/validate-component-name.test.js +33 -0
- package/esm/util/validate-component-name.test.js.map +1 -0
- package/package.json +15 -23
- package/dist/schema/alias.d.ts +0 -3
- package/dist/schema/alias.d.ts.map +0 -1
- package/dist/schema/alias.js +0 -6
- package/dist/schema/alias.js.map +0 -1
- package/esm/schema/alias.d.ts +0 -3
- package/esm/schema/alias.d.ts.map +0 -1
- package/esm/schema/alias.js +0 -13
- package/esm/schema/alias.js.map +0 -1
|
@@ -36,9 +36,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
})();
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.useCurrentInteractablesSnapshot = exports.useTamboInteractable = exports.TamboInteractableProvider = void 0;
|
|
39
|
+
const fast_equals_1 = require("fast-equals");
|
|
39
40
|
const react_1 = __importStar(require("react"));
|
|
40
41
|
const v3_1 = require("zod/v3");
|
|
41
42
|
const current_interactables_context_helper_1 = require("../context-helpers/current-interactables-context-helper");
|
|
43
|
+
const schema_1 = require("../schema");
|
|
42
44
|
const validate_component_name_1 = require("../util/validate-component-name");
|
|
43
45
|
const tambo_component_provider_1 = require("./tambo-component-provider");
|
|
44
46
|
const tambo_context_helpers_provider_1 = require("./tambo-context-helpers-provider");
|
|
@@ -52,6 +54,8 @@ const TamboInteractableContext = (0, react_1.createContext)({
|
|
|
52
54
|
clearAllInteractableComponents: () => { },
|
|
53
55
|
setInteractableState: () => { },
|
|
54
56
|
getInteractableComponentState: () => undefined,
|
|
57
|
+
setInteractableSelected: () => { },
|
|
58
|
+
clearInteractableSelections: () => { },
|
|
55
59
|
});
|
|
56
60
|
/**
|
|
57
61
|
* The TamboInteractableProvider manages a list of components that are currently
|
|
@@ -205,32 +209,110 @@ const TamboInteractableProvider = ({ children, }) => {
|
|
|
205
209
|
});
|
|
206
210
|
return "Updated successfully";
|
|
207
211
|
}, []);
|
|
208
|
-
const
|
|
209
|
-
|
|
212
|
+
const updateInteractableComponentState = (0, react_1.useCallback)((componentId, newState) => {
|
|
213
|
+
if (!newState || Object.keys(newState).length === 0) {
|
|
214
|
+
return `Warning: No state values provided for component with ID ${componentId}.`;
|
|
215
|
+
}
|
|
216
|
+
setInteractableComponents((components = []) => {
|
|
217
|
+
const component = components.find((c) => c.id === componentId);
|
|
218
|
+
if (!component)
|
|
219
|
+
return components;
|
|
220
|
+
const prevState = component.state ?? {};
|
|
221
|
+
const updatedState = { ...prevState, ...newState };
|
|
222
|
+
if ((0, fast_equals_1.deepEqual)(prevState, updatedState))
|
|
223
|
+
return components;
|
|
224
|
+
// TODO(lachieh): validate state against schema?
|
|
225
|
+
const updated = {
|
|
226
|
+
...component,
|
|
227
|
+
state: updatedState,
|
|
228
|
+
};
|
|
229
|
+
return components.map((c) => (c.id === componentId ? updated : c));
|
|
230
|
+
});
|
|
231
|
+
return "Updated successfully";
|
|
232
|
+
}, []);
|
|
233
|
+
const registerInteractableComponentPropsUpdateTool = (0, react_1.useCallback)((component, maxNameLength = 60) => {
|
|
234
|
+
const tamboToolNamePart = `update_component_props_`;
|
|
210
235
|
const availableLength = maxNameLength - tamboToolNamePart.length;
|
|
211
236
|
if (component.id.length > availableLength) {
|
|
212
237
|
throw new Error(`Interactable component id ${component.id} is too long. It must be less than ${availableLength} characters.`);
|
|
213
238
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
239
|
+
// Build newProps schema as JSON Schema
|
|
240
|
+
let newPropsSchema;
|
|
241
|
+
if (component.propsSchema) {
|
|
242
|
+
// Convert any supported schema to JSON Schema, then make partial
|
|
243
|
+
const fullSchema = (0, schema_1.schemaToJsonSchema)(component.propsSchema);
|
|
244
|
+
newPropsSchema = (0, schema_1.makeJsonSchemaPartial)(fullSchema);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
// No schema - allow any properties
|
|
248
|
+
newPropsSchema = { type: "object", additionalProperties: true };
|
|
249
|
+
}
|
|
250
|
+
// Build the full input schema as JSON Schema
|
|
251
|
+
const inputSchema = {
|
|
252
|
+
type: "object",
|
|
253
|
+
properties: {
|
|
254
|
+
componentId: {
|
|
255
|
+
type: "string",
|
|
256
|
+
description: "The ID of the interactable component to update",
|
|
257
|
+
},
|
|
258
|
+
newProps: {
|
|
259
|
+
...newPropsSchema,
|
|
260
|
+
description: "The props to update. Provide only the props you want to change.",
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
required: ["componentId", "newProps"],
|
|
264
|
+
};
|
|
219
265
|
registerTool({
|
|
220
266
|
name: `${tamboToolNamePart}${component.id}`,
|
|
221
|
-
description: `Update the props of interactable component ${component.id} (${component.name}).
|
|
267
|
+
description: `Update the props of interactable component ${component.id} (${component.name}). Provide partial props (only props to change).`,
|
|
222
268
|
tool: ({ componentId, newProps }) => {
|
|
223
269
|
return updateInteractableComponentProps(componentId, newProps);
|
|
224
270
|
},
|
|
225
|
-
inputSchema
|
|
226
|
-
componentId: v3_1.z
|
|
227
|
-
.string()
|
|
228
|
-
.describe("The ID of the interactable component to update"),
|
|
229
|
-
newProps: schemaForArgs.describe("The props to update the component with. You can provide partial props (only the props you want to change) or complete props (all props). Only the props you specify will be updated."),
|
|
230
|
-
}),
|
|
271
|
+
inputSchema,
|
|
231
272
|
outputSchema: v3_1.z.string(),
|
|
232
273
|
});
|
|
233
274
|
}, [registerTool, updateInteractableComponentProps]);
|
|
275
|
+
const registerInteractableComponentStateUpdateTool = (0, react_1.useCallback)((component, maxNameLength = 60) => {
|
|
276
|
+
const tamboToolNamePart = `update_component_state_`;
|
|
277
|
+
const availableLength = maxNameLength - tamboToolNamePart.length;
|
|
278
|
+
if (component.id.length > availableLength) {
|
|
279
|
+
throw new Error(`Interactable component id ${component.id} is too long. It must be less than ${availableLength} characters.`);
|
|
280
|
+
}
|
|
281
|
+
// Build newState schema as JSON Schema
|
|
282
|
+
let newStateSchema = {
|
|
283
|
+
type: "object",
|
|
284
|
+
additionalProperties: true,
|
|
285
|
+
};
|
|
286
|
+
if (component.stateSchema) {
|
|
287
|
+
// Convert any supported schema to JSON Schema, then make partial
|
|
288
|
+
const fullSchema = (0, schema_1.schemaToJsonSchema)(component.stateSchema);
|
|
289
|
+
newStateSchema = (0, schema_1.makeJsonSchemaPartial)(fullSchema);
|
|
290
|
+
}
|
|
291
|
+
// Build the full input schema as JSON Schema
|
|
292
|
+
const inputSchema = {
|
|
293
|
+
type: "object",
|
|
294
|
+
properties: {
|
|
295
|
+
componentId: {
|
|
296
|
+
type: "string",
|
|
297
|
+
description: "The ID of the interactable component to update",
|
|
298
|
+
},
|
|
299
|
+
newState: {
|
|
300
|
+
...newStateSchema,
|
|
301
|
+
description: "The state values to update. Provide only the keys you want to change.",
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
required: ["componentId", "newState"],
|
|
305
|
+
};
|
|
306
|
+
registerTool({
|
|
307
|
+
name: `${tamboToolNamePart}${component.id}`,
|
|
308
|
+
description: `Update the state of interactable component ${component.id} (${component.name}). You may provide partial state (only keys to change).`,
|
|
309
|
+
tool: ({ componentId, newState }) => {
|
|
310
|
+
return updateInteractableComponentState(componentId, newState);
|
|
311
|
+
},
|
|
312
|
+
inputSchema,
|
|
313
|
+
outputSchema: v3_1.z.string(),
|
|
314
|
+
});
|
|
315
|
+
}, [registerTool, updateInteractableComponentState]);
|
|
234
316
|
const addInteractableComponent = (0, react_1.useCallback)((component) => {
|
|
235
317
|
// Validate component name
|
|
236
318
|
(0, validate_component_name_1.assertValidName)(component.name, "component");
|
|
@@ -242,12 +324,16 @@ const TamboInteractableProvider = ({ children, }) => {
|
|
|
242
324
|
id,
|
|
243
325
|
state: component.state ?? {},
|
|
244
326
|
};
|
|
245
|
-
|
|
327
|
+
registerInteractableComponentPropsUpdateTool(newComponent);
|
|
328
|
+
registerInteractableComponentStateUpdateTool(newComponent);
|
|
246
329
|
setInteractableComponents((prev) => {
|
|
247
330
|
return [...prev, newComponent];
|
|
248
331
|
});
|
|
249
332
|
return id;
|
|
250
|
-
}, [
|
|
333
|
+
}, [
|
|
334
|
+
registerInteractableComponentPropsUpdateTool,
|
|
335
|
+
registerInteractableComponentStateUpdateTool,
|
|
336
|
+
]);
|
|
251
337
|
const removeInteractableComponent = (0, react_1.useCallback)((id) => {
|
|
252
338
|
setInteractableComponents((prev) => prev.filter((c) => c.id !== id));
|
|
253
339
|
}, []);
|
|
@@ -270,7 +356,7 @@ const TamboInteractableProvider = ({ children, }) => {
|
|
|
270
356
|
const updated = {
|
|
271
357
|
...component,
|
|
272
358
|
state: {
|
|
273
|
-
...
|
|
359
|
+
...component.state,
|
|
274
360
|
[key]: value,
|
|
275
361
|
},
|
|
276
362
|
};
|
|
@@ -287,6 +373,27 @@ const TamboInteractableProvider = ({ children, }) => {
|
|
|
287
373
|
const component = interactableComponents.find((c) => c.id === componentId);
|
|
288
374
|
return component?.state;
|
|
289
375
|
}, [interactableComponents]);
|
|
376
|
+
const setInteractableSelected = (0, react_1.useCallback)((componentId, isSelected) => {
|
|
377
|
+
setInteractableComponents((prev) => {
|
|
378
|
+
let found = false;
|
|
379
|
+
const next = prev.map((component) => {
|
|
380
|
+
if (component.id !== componentId)
|
|
381
|
+
return component;
|
|
382
|
+
found = true;
|
|
383
|
+
return component.isSelected === isSelected
|
|
384
|
+
? component
|
|
385
|
+
: { ...component, isSelected: isSelected };
|
|
386
|
+
});
|
|
387
|
+
return found ? next : prev;
|
|
388
|
+
});
|
|
389
|
+
}, []);
|
|
390
|
+
const clearInteractableSelections = (0, react_1.useCallback)(() => {
|
|
391
|
+
setInteractableComponents((prev) => {
|
|
392
|
+
if (!prev.some((c) => c.isSelected))
|
|
393
|
+
return prev;
|
|
394
|
+
return prev.map((c) => (c.isSelected ? { ...c, isSelected: false } : c));
|
|
395
|
+
});
|
|
396
|
+
}, []);
|
|
290
397
|
const value = {
|
|
291
398
|
interactableComponents,
|
|
292
399
|
addInteractableComponent,
|
|
@@ -297,6 +404,8 @@ const TamboInteractableProvider = ({ children, }) => {
|
|
|
297
404
|
clearAllInteractableComponents,
|
|
298
405
|
setInteractableState: setInteractableStateValue,
|
|
299
406
|
getInteractableComponentState,
|
|
407
|
+
setInteractableSelected,
|
|
408
|
+
clearInteractableSelections,
|
|
300
409
|
};
|
|
301
410
|
return (react_1.default.createElement(TamboInteractableContext.Provider, { value: value }, children));
|
|
302
411
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-interactable-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.tsx"],"names":[],"mappings":";AAAA,0DAA0D;AAC1D,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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","sourcesContent":["// react-sdk/src/providers/tambo-interactable-provider.tsx\n\"use client\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport { z } from \"zod/v3\";\nimport { createInteractablesContextHelper } from \"../context-helpers/current-interactables-context-helper\";\nimport {\n TamboInteractableComponent,\n type TamboInteractableContext,\n} from \"../model/tambo-interactable\";\nimport { assertValidName } from \"../util/validate-component-name\";\nimport { useTamboComponent } from \"./tambo-component-provider\";\nimport { useTamboContextHelpers } from \"./tambo-context-helpers-provider\";\n\nconst TamboInteractableContext = createContext<TamboInteractableContext>({\n interactableComponents: [],\n addInteractableComponent: () => \"\",\n removeInteractableComponent: () => {},\n updateInteractableComponentProps: () => \"\",\n getInteractableComponent: () => undefined,\n getInteractableComponentsByName: () => [],\n clearAllInteractableComponents: () => {},\n setInteractableState: () => {},\n getInteractableComponentState: () => undefined,\n});\n\n/**\n * The TamboInteractableProvider manages a list of components that are currently\n * interactable, allowing tambo to interact with them by updating their props. It also registers tools\n * for Tambo to perform CRUD operations on the components list.\n * @param props - The props for the TamboInteractableProvider\n * @param props.children - The children to wrap\n * @returns The TamboInteractableProvider component\n */\nexport const TamboInteractableProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const [interactableComponents, setInteractableComponents] = useState<\n TamboInteractableComponent[]\n >([]);\n const { registerTool } = useTamboComponent();\n const { addContextHelper, removeContextHelper } = useTamboContextHelpers();\n\n // Create a stable context helper function for interactable components\n const interactablesContextHelper = useMemo(\n () => createInteractablesContextHelper(interactableComponents),\n [interactableComponents],\n );\n\n // Register the interactables context helper\n useEffect(() => {\n addContextHelper(\"interactables\", interactablesContextHelper);\n\n return () => {\n removeContextHelper(\"interactables\");\n };\n }, [interactablesContextHelper, addContextHelper, removeContextHelper]);\n\n useEffect(() => {\n if (interactableComponents.length > 0) {\n registerTool({\n name: \"get_all_interactable_components\",\n description:\n \"Only use this tool if the user is asking about interactable components.Get all currently interactable components with their details including their current props. These are components that you can interact with on behalf of the user.\",\n tool: () => {\n return {\n components: interactableComponents,\n };\n },\n inputSchema: z.object({}),\n outputSchema: z.object({\n components: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n props: z.record(z.string(), z.any()),\n propsSchema: z.record(z.string(), z.any()).optional(),\n }),\n ),\n }),\n });\n\n registerTool({\n name: \"get_interactable_component_by_id\",\n description: \"Get a specific interactable component by its ID\",\n tool: ({ componentId }) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n } as const;\n }\n\n return {\n success: true,\n component: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n } as const;\n },\n inputSchema: z.object({\n componentId: z.string().describe(\"The ID of the component\"),\n }),\n outputSchema: z.discriminatedUnion(\"success\", [\n z.object({\n success: z.literal(true),\n component: z\n .object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.string(), z.any()),\n })\n .optional(),\n }),\n z.object({\n success: z.literal(false),\n error: z.string(),\n }),\n ]),\n });\n\n registerTool({\n name: \"remove_interactable_component\",\n description: \"Remove an interactable component from the system\",\n tool: ({ componentId }) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n } as const;\n }\n\n setInteractableComponents((prev) =>\n prev.filter((c) => c.id !== componentId),\n );\n\n return {\n success: true,\n componentId,\n removedComponent: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n } as const;\n },\n inputSchema: z.object({\n componentId: z.string().describe(\"The ID of the component\"),\n }),\n outputSchema: z.discriminatedUnion(\"success\", [\n z.object({\n success: z.literal(true),\n componentId: z.string(),\n removedComponent: z.object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.string(), z.any()),\n }),\n }),\n z.object({\n success: z.literal(false),\n error: z.string(),\n }),\n ]),\n });\n }\n }, [interactableComponents, registerTool]);\n\n const updateInteractableComponentProps = useCallback(\n (id: string, newProps: Record<string, any>): string => {\n if (!newProps || Object.keys(newProps).length === 0) {\n return `Warning: No props provided for component with ID ${id}.`;\n }\n\n setInteractableComponents((prev) => {\n const component = prev.find((c) => c.id === id);\n if (!component) {\n return prev;\n }\n\n // Compare props shallowly\n const propsChanged = Object.entries(newProps).some(([key, value]) => {\n return component.props[key] !== value;\n });\n\n if (!propsChanged) {\n return prev; // unchanged\n }\n\n // Apply partial update\n const updated = {\n ...component,\n props: { ...component.props, ...newProps },\n };\n\n const updatedComponents = [...prev];\n const idx = prev.findIndex((c) => c.id === id);\n updatedComponents[idx] = updated;\n\n return updatedComponents;\n });\n\n return \"Updated successfully\";\n },\n [],\n );\n\n const registerInteractableComponentUpdateTool = useCallback(\n (component: TamboInteractableComponent, maxNameLength = 60) => {\n const tamboToolNamePart = `update_component_`;\n const availableLength = maxNameLength - tamboToolNamePart.length;\n if (component.id.length > availableLength) {\n throw new Error(\n `Interactable component id ${component.id} is too long. It must be less than ${availableLength} characters.`,\n );\n }\n\n const schemaForArgs =\n typeof component.propsSchema === \"object\" &&\n \"describe\" in component.propsSchema &&\n \"partial\" in component.propsSchema\n ? (component.propsSchema as any).partial()\n : z.object({});\n\n registerTool({\n name: `${tamboToolNamePart}${component.id}`,\n description: `Update the props of interactable component ${component.id} (${component.name}). You can provide partial props (only the props you want to change) or complete props (all props). Only the props you specify will be updated.`,\n tool: ({ componentId, newProps }) => {\n return updateInteractableComponentProps(componentId, newProps);\n },\n inputSchema: z.object({\n componentId: z\n .string()\n .describe(\"The ID of the interactable component to update\"),\n newProps: schemaForArgs.describe(\n \"The props to update the component with. You can provide partial props (only the props you want to change) or complete props (all props). Only the props you specify will be updated.\",\n ),\n }),\n outputSchema: z.string(),\n });\n },\n [registerTool, updateInteractableComponentProps],\n );\n\n const addInteractableComponent = useCallback(\n (\n component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\">,\n ): string => {\n // Validate component name\n assertValidName(component.name, \"component\");\n\n // Add a random part to the component name to make it unique when using multiple instances of the same component.\n const tamboGeneratedNamePart = `-${Math.random().toString(36).slice(2, 5)}`;\n const id = `${component.name}${tamboGeneratedNamePart}`;\n const newComponent: TamboInteractableComponent = {\n ...component,\n id,\n state: component.state ?? {},\n };\n\n registerInteractableComponentUpdateTool(newComponent);\n\n setInteractableComponents((prev) => {\n return [...prev, newComponent];\n });\n\n return id;\n },\n [registerInteractableComponentUpdateTool],\n );\n\n const removeInteractableComponent = useCallback((id: string) => {\n setInteractableComponents((prev) => prev.filter((c) => c.id !== id));\n }, []);\n\n const getInteractableComponent = useCallback(\n (id: string) => {\n return interactableComponents.find((c) => c.id === id);\n },\n [interactableComponents],\n );\n\n const getInteractableComponentsByName = useCallback(\n (componentName: string) => {\n return interactableComponents.filter((c) => c.name === componentName);\n },\n [interactableComponents],\n );\n\n const clearAllInteractableComponents = useCallback(() => {\n setInteractableComponents([]);\n }, []);\n\n const setInteractableStateValue = useCallback(\n (componentId: string, key: string, value: unknown) => {\n setInteractableComponents((prev) => {\n const component = prev.find((c) => c.id === componentId);\n if (!component) {\n console.warn(\n `Tried to update state for component ${componentId} but it was not found.`,\n );\n return prev;\n }\n\n const updated = {\n ...component,\n state: {\n ...(component.state ?? {}),\n [key]: value,\n },\n };\n\n const updatedComponents = prev.map((component) => {\n if (component.id === componentId) {\n return updated;\n }\n return component;\n });\n\n return updatedComponents;\n });\n },\n [],\n );\n\n const getInteractableComponentState = useCallback(\n (componentId: string) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n return component?.state;\n },\n [interactableComponents],\n );\n\n const value: TamboInteractableContext = {\n interactableComponents,\n addInteractableComponent,\n removeInteractableComponent,\n updateInteractableComponentProps,\n getInteractableComponent,\n getInteractableComponentsByName,\n clearAllInteractableComponents,\n setInteractableState: setInteractableStateValue,\n getInteractableComponentState,\n };\n\n return (\n <TamboInteractableContext.Provider value={value}>\n {children}\n </TamboInteractableContext.Provider>\n );\n};\n\n/**\n * The useTamboInteractable hook provides access to the interactable component\n * management functions.\n * @returns The interactable component management functions\n */\nexport const useTamboInteractable = () => {\n return useContext(TamboInteractableContext);\n};\n\n/**\n * Hook to get a cloned snapshot of the current interactables.\n * Returns a shallow copy of the array with cloned items and props to prevent\n * external mutation from affecting internal state.\n * @returns The current interactables snapshot (cloned).\n */\nexport const useCurrentInteractablesSnapshot = () => {\n const { interactableComponents } = useTamboInteractable();\n // Clone the array and each item/props to prevent mutation\n const copy = interactableComponents.map((c) => ({\n ...c,\n props: { ...c.props },\n }));\n\n return copy;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"tambo-interactable-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.tsx"],"names":[],"mappings":";AAAA,0DAA0D;AAC1D,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,6CAAwC;AAExC,+CAQe;AACf,+BAA2B;AAC3B,kHAA2G;AAK3G,sCAAsE;AACtE,6EAAkE;AAClE,yEAA+D;AAC/D,qFAA0E;AAE1E,MAAM,wBAAwB,GAAG,IAAA,qBAAa,EAA2B;IACvE,sBAAsB,EAAE,EAAE;IAC1B,wBAAwB,EAAE,GAAG,EAAE,CAAC,EAAE;IAClC,2BAA2B,EAAE,GAAG,EAAE,GAAE,CAAC;IACrC,gCAAgC,EAAE,GAAG,EAAE,CAAC,EAAE;IAC1C,wBAAwB,EAAE,GAAG,EAAE,CAAC,SAAS;IACzC,+BAA+B,EAAE,GAAG,EAAE,CAAC,EAAE;IACzC,8BAA8B,EAAE,GAAG,EAAE,GAAE,CAAC;IACxC,oBAAoB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC9B,6BAA6B,EAAE,GAAG,EAAE,CAAC,SAAS;IAC9C,uBAAuB,EAAE,GAAG,EAAE,GAAE,CAAC;IACjC,2BAA2B,EAAE,GAAG,EAAE,GAAE,CAAC;CACtC,CAAC,CAAC;AAEH;;;;;;;GAOG;AACI,MAAM,yBAAyB,GAAgC,CAAC,EACrE,Q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AAyB;QAC/C,6BAA6B;QAC7B,uBAAuB;QACvB,2BAA2B;KAC5B,CAAC;IAEF,OAAO,CACL,8BAAC,wBAAwB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAC5C,QAAQ,CACyB,CACrC,CAAC;AACJ,CAAC,CAAC;AAtcW,QAAA,yBAAyB,6BAscpC;AAEF;;;;GAIG;AACI,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,OAAO,IAAA,kBAAU,EAAC,wBAAwB,CAAC,CAAC;AAC9C,CAAC,CAAC;AAFW,QAAA,oBAAoB,wBAE/B;AAEF;;;;;GAKG;AACI,MAAM,+BAA+B,GAAG,GAAG,EAAE;IAClD,MAAM,EAAE,sBAAsB,EAAE,GAAG,IAAA,4BAAoB,GAAE,CAAC;IAC1D,0DAA0D;IAC1D,MAAM,IAAI,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9C,GAAG,CAAC;QACJ,KAAK,EAAE,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE;KACtB,CAAC,CAAC,CAAC;IAEJ,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AATW,QAAA,+BAA+B,mCAS1C","sourcesContent":["// react-sdk/src/providers/tambo-interactable-provider.tsx\n\"use client\";\nimport { deepEqual } from \"fast-equals\";\nimport { JSONSchema7 } from \"json-schema\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport { z } from \"zod/v3\";\nimport { createInteractablesContextHelper } from \"../context-helpers/current-interactables-context-helper\";\nimport {\n TamboInteractableComponent,\n type TamboInteractableContext,\n} from \"../model/tambo-interactable\";\nimport { makeJsonSchemaPartial, schemaToJsonSchema } from \"../schema\";\nimport { assertValidName } from \"../util/validate-component-name\";\nimport { useTamboComponent } from \"./tambo-component-provider\";\nimport { useTamboContextHelpers } from \"./tambo-context-helpers-provider\";\n\nconst TamboInteractableContext = createContext<TamboInteractableContext>({\n interactableComponents: [],\n addInteractableComponent: () => \"\",\n removeInteractableComponent: () => {},\n updateInteractableComponentProps: () => \"\",\n getInteractableComponent: () => undefined,\n getInteractableComponentsByName: () => [],\n clearAllInteractableComponents: () => {},\n setInteractableState: () => {},\n getInteractableComponentState: () => undefined,\n setInteractableSelected: () => {},\n clearInteractableSelections: () => {},\n});\n\n/**\n * The TamboInteractableProvider manages a list of components that are currently\n * interactable, allowing tambo to interact with them by updating their props. It also registers tools\n * for Tambo to perform CRUD operations on the components list.\n * @param props - The props for the TamboInteractableProvider\n * @param props.children - The children to wrap\n * @returns The TamboInteractableProvider component\n */\nexport const TamboInteractableProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const [interactableComponents, setInteractableComponents] = useState<\n TamboInteractableComponent[]\n >([]);\n const { registerTool } = useTamboComponent();\n const { addContextHelper, removeContextHelper } = useTamboContextHelpers();\n\n // Create a stable context helper function for interactable components\n const interactablesContextHelper = useMemo(\n () => createInteractablesContextHelper(interactableComponents),\n [interactableComponents],\n );\n\n // Register the interactables context helper\n useEffect(() => {\n addContextHelper(\"interactables\", interactablesContextHelper);\n\n return () => {\n removeContextHelper(\"interactables\");\n };\n }, [interactablesContextHelper, addContextHelper, removeContextHelper]);\n\n useEffect(() => {\n if (interactableComponents.length > 0) {\n registerTool({\n name: \"get_all_interactable_components\",\n description:\n \"Only use this tool if the user is asking about interactable components.Get all currently interactable components with their details including their current props. These are components that you can interact with on behalf of the user.\",\n tool: () => {\n return {\n components: interactableComponents,\n };\n },\n inputSchema: z.object({}),\n outputSchema: z.object({\n components: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n props: z.record(z.string(), z.any()),\n propsSchema: z.record(z.string(), z.any()).optional(),\n }),\n ),\n }),\n });\n\n registerTool({\n name: \"get_interactable_component_by_id\",\n description: \"Get a specific interactable component by its ID\",\n tool: ({ componentId }) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n } as const;\n }\n\n return {\n success: true,\n component: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n } as const;\n },\n inputSchema: z.object({\n componentId: z.string().describe(\"The ID of the component\"),\n }),\n outputSchema: z.discriminatedUnion(\"success\", [\n z.object({\n success: z.literal(true),\n component: z\n .object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.string(), z.any()),\n })\n .optional(),\n }),\n z.object({\n success: z.literal(false),\n error: z.string(),\n }),\n ]),\n });\n\n registerTool({\n name: \"remove_interactable_component\",\n description: \"Remove an interactable component from the system\",\n tool: ({ componentId }) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n } as const;\n }\n\n setInteractableComponents((prev) =>\n prev.filter((c) => c.id !== componentId),\n );\n\n return {\n success: true,\n componentId,\n removedComponent: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n } as const;\n },\n inputSchema: z.object({\n componentId: z.string().describe(\"The ID of the component\"),\n }),\n outputSchema: z.discriminatedUnion(\"success\", [\n z.object({\n success: z.literal(true),\n componentId: z.string(),\n removedComponent: z.object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.string(), z.any()),\n }),\n }),\n z.object({\n success: z.literal(false),\n error: z.string(),\n }),\n ]),\n });\n }\n }, [interactableComponents, registerTool]);\n\n const updateInteractableComponentProps = useCallback(\n (id: string, newProps: Record<string, any>): string => {\n if (!newProps || Object.keys(newProps).length === 0) {\n return `Warning: No props provided for component with ID ${id}.`;\n }\n\n setInteractableComponents((prev) => {\n const component = prev.find((c) => c.id === id);\n if (!component) {\n return prev;\n }\n\n // Compare props shallowly\n const propsChanged = Object.entries(newProps).some(([key, value]) => {\n return component.props[key] !== value;\n });\n\n if (!propsChanged) {\n return prev; // unchanged\n }\n\n // Apply partial update\n const updated = {\n ...component,\n props: { ...component.props, ...newProps },\n };\n\n const updatedComponents = [...prev];\n const idx = prev.findIndex((c) => c.id === id);\n updatedComponents[idx] = updated;\n\n return updatedComponents;\n });\n\n return \"Updated successfully\";\n },\n [],\n );\n\n const updateInteractableComponentState = useCallback(\n (componentId: string, newState: Record<string, unknown>): string => {\n if (!newState || Object.keys(newState).length === 0) {\n return `Warning: No state values provided for component with ID ${componentId}.`;\n }\n\n setInteractableComponents((components = []) => {\n const component = components.find((c) => c.id === componentId);\n if (!component) return components;\n\n const prevState = component.state ?? {};\n const updatedState = { ...prevState, ...newState };\n if (deepEqual(prevState, updatedState)) return components;\n\n // TODO(lachieh): validate state against schema?\n\n const updated = {\n ...component,\n state: updatedState,\n };\n\n return components.map((c) => (c.id === componentId ? updated : c));\n });\n\n return \"Updated successfully\";\n },\n [],\n );\n\n const registerInteractableComponentPropsUpdateTool = useCallback(\n (component: TamboInteractableComponent, maxNameLength = 60) => {\n const tamboToolNamePart = `update_component_props_`;\n const availableLength = maxNameLength - tamboToolNamePart.length;\n if (component.id.length > availableLength) {\n throw new Error(\n `Interactable component id ${component.id} is too long. It must be less than ${availableLength} characters.`,\n );\n }\n\n // Build newProps schema as JSON Schema\n let newPropsSchema: JSONSchema7;\n if (component.propsSchema) {\n // Convert any supported schema to JSON Schema, then make partial\n const fullSchema = schemaToJsonSchema(component.propsSchema);\n newPropsSchema = makeJsonSchemaPartial(fullSchema);\n } else {\n // No schema - allow any properties\n newPropsSchema = { type: \"object\", additionalProperties: true };\n }\n\n // Build the full input schema as JSON Schema\n const inputSchema: JSONSchema7 = {\n type: \"object\",\n properties: {\n componentId: {\n type: \"string\",\n description: \"The ID of the interactable component to update\",\n },\n newProps: {\n ...newPropsSchema,\n description:\n \"The props to update. Provide only the props you want to change.\",\n },\n },\n required: [\"componentId\", \"newProps\"],\n };\n\n registerTool({\n name: `${tamboToolNamePart}${component.id}`,\n description: `Update the props of interactable component ${component.id} (${component.name}). Provide partial props (only props to change).`,\n tool: ({ componentId, newProps }) => {\n return updateInteractableComponentProps(componentId, newProps);\n },\n inputSchema,\n outputSchema: z.string(),\n });\n },\n [registerTool, updateInteractableComponentProps],\n );\n\n const registerInteractableComponentStateUpdateTool = useCallback(\n (component: TamboInteractableComponent, maxNameLength = 60) => {\n const tamboToolNamePart = `update_component_state_`;\n const availableLength = maxNameLength - tamboToolNamePart.length;\n if (component.id.length > availableLength) {\n throw new Error(\n `Interactable component id ${component.id} is too long. It must be less than ${availableLength} characters.`,\n );\n }\n\n // Build newState schema as JSON Schema\n let newStateSchema: JSONSchema7 = {\n type: \"object\",\n additionalProperties: true,\n };\n if (component.stateSchema) {\n // Convert any supported schema to JSON Schema, then make partial\n const fullSchema = schemaToJsonSchema(component.stateSchema);\n newStateSchema = makeJsonSchemaPartial(fullSchema);\n }\n\n // Build the full input schema as JSON Schema\n const inputSchema: JSONSchema7 = {\n type: \"object\",\n properties: {\n componentId: {\n type: \"string\",\n description: \"The ID of the interactable component to update\",\n },\n newState: {\n ...newStateSchema,\n description:\n \"The state values to update. Provide only the keys you want to change.\",\n },\n },\n required: [\"componentId\", \"newState\"],\n };\n\n registerTool({\n name: `${tamboToolNamePart}${component.id}`,\n description: `Update the state of interactable component ${component.id} (${component.name}). You may provide partial state (only keys to change).`,\n tool: ({ componentId, newState }) => {\n return updateInteractableComponentState(componentId, newState);\n },\n inputSchema,\n outputSchema: z.string(),\n });\n },\n [registerTool, updateInteractableComponentState],\n );\n\n const addInteractableComponent = useCallback(\n (\n component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\">,\n ): string => {\n // Validate component name\n assertValidName(component.name, \"component\");\n\n // Add a random part to the component name to make it unique when using multiple instances of the same component.\n const tamboGeneratedNamePart = `-${Math.random().toString(36).slice(2, 5)}`;\n const id = `${component.name}${tamboGeneratedNamePart}`;\n const newComponent: TamboInteractableComponent = {\n ...component,\n id,\n state: component.state ?? {},\n };\n\n registerInteractableComponentPropsUpdateTool(newComponent);\n registerInteractableComponentStateUpdateTool(newComponent);\n\n setInteractableComponents((prev) => {\n return [...prev, newComponent];\n });\n\n return id;\n },\n [\n registerInteractableComponentPropsUpdateTool,\n registerInteractableComponentStateUpdateTool,\n ],\n );\n\n const removeInteractableComponent = useCallback((id: string) => {\n setInteractableComponents((prev) => prev.filter((c) => c.id !== id));\n }, []);\n\n const getInteractableComponent = useCallback(\n <P, S>(id: string): TamboInteractableComponent<P, S> | undefined => {\n return interactableComponents.find((c) => c.id === id) as\n | TamboInteractableComponent<P, S>\n | undefined;\n },\n [interactableComponents],\n );\n\n const getInteractableComponentsByName = useCallback(\n (componentName: string) => {\n return interactableComponents.filter((c) => c.name === componentName);\n },\n [interactableComponents],\n );\n\n const clearAllInteractableComponents = useCallback(() => {\n setInteractableComponents([]);\n }, []);\n\n const setInteractableStateValue = useCallback(\n (componentId: string, key: string, value: unknown) => {\n setInteractableComponents((prev) => {\n const component = prev.find((c) => c.id === componentId);\n if (!component) {\n console.warn(\n `Tried to update state for component ${componentId} but it was not found.`,\n );\n return prev;\n }\n\n const updated = {\n ...component,\n state: {\n ...component.state,\n [key]: value,\n },\n };\n\n const updatedComponents = prev.map((component) => {\n if (component.id === componentId) {\n return updated;\n }\n return component;\n });\n\n return updatedComponents;\n });\n },\n [],\n );\n\n const getInteractableComponentState = useCallback(\n (componentId: string) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n return component?.state;\n },\n [interactableComponents],\n );\n\n const setInteractableSelected = useCallback(\n (componentId: string, isSelected: boolean) => {\n setInteractableComponents((prev) => {\n let found = false;\n const next = prev.map((component) => {\n if (component.id !== componentId) return component;\n found = true;\n return component.isSelected === isSelected\n ? component\n : { ...component, isSelected: isSelected };\n });\n return found ? next : prev;\n });\n },\n [],\n );\n\n const clearInteractableSelections = useCallback(() => {\n setInteractableComponents((prev) => {\n if (!prev.some((c) => c.isSelected)) return prev;\n return prev.map((c) => (c.isSelected ? { ...c, isSelected: false } : c));\n });\n }, []);\n\n const value: TamboInteractableContext = {\n interactableComponents,\n addInteractableComponent,\n removeInteractableComponent,\n updateInteractableComponentProps,\n getInteractableComponent,\n getInteractableComponentsByName,\n clearAllInteractableComponents,\n setInteractableState: setInteractableStateValue,\n getInteractableComponentState,\n setInteractableSelected,\n clearInteractableSelections,\n };\n\n return (\n <TamboInteractableContext.Provider value={value}>\n {children}\n </TamboInteractableContext.Provider>\n );\n};\n\n/**\n * The useTamboInteractable hook provides access to the interactable component\n * management functions.\n * @returns The interactable component management functions\n */\nexport const useTamboInteractable = () => {\n return useContext(TamboInteractableContext);\n};\n\n/**\n * Hook to get a cloned snapshot of the current interactables.\n * Returns a shallow copy of the array with cloned items and props to prevent\n * external mutation from affecting internal state.\n * @returns The current interactables snapshot (cloned).\n */\nexport const useCurrentInteractablesSnapshot = () => {\n const { interactableComponents } = useTamboInteractable();\n // Clone the array and each item/props to prevent mutation\n const copy = interactableComponents.map((c) => ({\n ...c,\n props: { ...c.props },\n }));\n\n return copy;\n};\n"]}
|
|
@@ -59,4 +59,246 @@ describe("TamboInteractableProvider - State Tracking", () => {
|
|
|
59
59
|
expect(state).toEqual({ count: 10 });
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
|
+
describe("TamboInteractableProvider - State Update Tool Registration", () => {
|
|
63
|
+
beforeEach(() => {
|
|
64
|
+
jest.clearAllMocks();
|
|
65
|
+
});
|
|
66
|
+
const wrapper = ({ children }) => (react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null, children));
|
|
67
|
+
it("should register both prop and state update tools when component is added", () => {
|
|
68
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_interactable_provider_1.useTamboInteractable)(), { wrapper });
|
|
69
|
+
const component = {
|
|
70
|
+
name: "TestComponent",
|
|
71
|
+
description: "A test component",
|
|
72
|
+
component: () => react_2.default.createElement("div", null, "Test"),
|
|
73
|
+
props: { title: "Test" },
|
|
74
|
+
propsSchema: zod_1.z.object({ title: zod_1.z.string() }),
|
|
75
|
+
};
|
|
76
|
+
let componentId = "";
|
|
77
|
+
(0, react_1.act)(() => {
|
|
78
|
+
componentId = result.current.addInteractableComponent(component);
|
|
79
|
+
});
|
|
80
|
+
// Should register both update_component_ and update_component_state_ tools
|
|
81
|
+
const registeredToolNames = mockRegisterTool.mock.calls.map((call) => call[0].name);
|
|
82
|
+
expect(registeredToolNames).toContain(`update_component_props_${componentId}`);
|
|
83
|
+
expect(registeredToolNames).toContain(`update_component_state_${componentId}`);
|
|
84
|
+
});
|
|
85
|
+
it("should register state update tool with correct description", () => {
|
|
86
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_interactable_provider_1.useTamboInteractable)(), { wrapper });
|
|
87
|
+
const component = {
|
|
88
|
+
name: "MyComponent",
|
|
89
|
+
description: "A test component",
|
|
90
|
+
component: () => react_2.default.createElement("div", null, "Test"),
|
|
91
|
+
props: {},
|
|
92
|
+
};
|
|
93
|
+
let componentId = "";
|
|
94
|
+
(0, react_1.act)(() => {
|
|
95
|
+
componentId = result.current.addInteractableComponent(component);
|
|
96
|
+
});
|
|
97
|
+
const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
|
|
98
|
+
expect(stateToolCall).toBeDefined();
|
|
99
|
+
expect(stateToolCall[0].description).toContain(componentId);
|
|
100
|
+
expect(stateToolCall[0].description).toContain("MyComponent");
|
|
101
|
+
});
|
|
102
|
+
it("should allow state update tool to update multiple state values", () => {
|
|
103
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_interactable_provider_1.useTamboInteractable)(), { wrapper });
|
|
104
|
+
const component = {
|
|
105
|
+
name: "TestComponent",
|
|
106
|
+
description: "A test component",
|
|
107
|
+
component: () => react_2.default.createElement("div", null, "Test"),
|
|
108
|
+
props: {},
|
|
109
|
+
};
|
|
110
|
+
let componentId = "";
|
|
111
|
+
(0, react_1.act)(() => {
|
|
112
|
+
componentId = result.current.addInteractableComponent(component);
|
|
113
|
+
});
|
|
114
|
+
// Find the state update tool and call it
|
|
115
|
+
const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
|
|
116
|
+
const toolFn = stateToolCall[0].tool;
|
|
117
|
+
(0, react_1.act)(() => {
|
|
118
|
+
toolFn({ componentId, newState: { count: 5, name: "test" } });
|
|
119
|
+
});
|
|
120
|
+
const state = result.current.getInteractableComponentState(componentId);
|
|
121
|
+
expect(state).toEqual({ count: 5, name: "test" });
|
|
122
|
+
});
|
|
123
|
+
it("should preserve existing state when updating partial state", () => {
|
|
124
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_interactable_provider_1.useTamboInteractable)(), { wrapper });
|
|
125
|
+
const component = {
|
|
126
|
+
name: "TestComponent",
|
|
127
|
+
description: "A test component",
|
|
128
|
+
component: () => react_2.default.createElement("div", null, "Test"),
|
|
129
|
+
props: {},
|
|
130
|
+
};
|
|
131
|
+
let componentId = "";
|
|
132
|
+
(0, react_1.act)(() => {
|
|
133
|
+
componentId = result.current.addInteractableComponent(component);
|
|
134
|
+
});
|
|
135
|
+
// Set initial state
|
|
136
|
+
(0, react_1.act)(() => {
|
|
137
|
+
result.current.setInteractableState(componentId, "existingKey", "value1");
|
|
138
|
+
});
|
|
139
|
+
// Find the state update tool and call it with a new key
|
|
140
|
+
const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
|
|
141
|
+
const toolFn = stateToolCall[0].tool;
|
|
142
|
+
(0, react_1.act)(() => {
|
|
143
|
+
toolFn({ componentId, newState: { newKey: "value2" } });
|
|
144
|
+
});
|
|
145
|
+
const state = result.current.getInteractableComponentState(componentId);
|
|
146
|
+
expect(state).toEqual({ existingKey: "value1", newKey: "value2" });
|
|
147
|
+
});
|
|
148
|
+
it("should use stateSchema when provided for tool registration", () => {
|
|
149
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_interactable_provider_1.useTamboInteractable)(), { wrapper });
|
|
150
|
+
const stateSchema = zod_1.z.object({
|
|
151
|
+
count: zod_1.z.number(),
|
|
152
|
+
name: zod_1.z.string(),
|
|
153
|
+
});
|
|
154
|
+
const component = {
|
|
155
|
+
name: "TestComponent",
|
|
156
|
+
description: "A test component",
|
|
157
|
+
component: () => react_2.default.createElement("div", null, "Test"),
|
|
158
|
+
props: {},
|
|
159
|
+
stateSchema,
|
|
160
|
+
};
|
|
161
|
+
(0, react_1.act)(() => {
|
|
162
|
+
result.current.addInteractableComponent(component);
|
|
163
|
+
});
|
|
164
|
+
// Find the state update tool
|
|
165
|
+
const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
|
|
166
|
+
expect(stateToolCall).toBeDefined();
|
|
167
|
+
// The inputSchema should contain the partial stateSchema
|
|
168
|
+
expect(stateToolCall[0].inputSchema).toBeDefined();
|
|
169
|
+
});
|
|
170
|
+
it("should return warning when updating state with empty object", () => {
|
|
171
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_interactable_provider_1.useTamboInteractable)(), { wrapper });
|
|
172
|
+
const component = {
|
|
173
|
+
name: "TestComponent",
|
|
174
|
+
description: "A test component",
|
|
175
|
+
component: () => react_2.default.createElement("div", null, "Test"),
|
|
176
|
+
props: {},
|
|
177
|
+
};
|
|
178
|
+
let componentId = "";
|
|
179
|
+
(0, react_1.act)(() => {
|
|
180
|
+
componentId = result.current.addInteractableComponent(component);
|
|
181
|
+
});
|
|
182
|
+
// Find the state update tool and call it with empty state
|
|
183
|
+
const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
|
|
184
|
+
const toolFn = stateToolCall[0].tool;
|
|
185
|
+
let updateResult = "";
|
|
186
|
+
(0, react_1.act)(() => {
|
|
187
|
+
updateResult = toolFn({ componentId, newState: {} });
|
|
188
|
+
});
|
|
189
|
+
expect(updateResult).toContain("Warning");
|
|
190
|
+
expect(updateResult).toContain("No state values provided");
|
|
191
|
+
});
|
|
192
|
+
it("should preserve stateSchema in interactable component", () => {
|
|
193
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_interactable_provider_1.useTamboInteractable)(), { wrapper });
|
|
194
|
+
const stateSchema = zod_1.z.object({
|
|
195
|
+
count: zod_1.z.number(),
|
|
196
|
+
});
|
|
197
|
+
const component = {
|
|
198
|
+
name: "TestComponent",
|
|
199
|
+
description: "A test component",
|
|
200
|
+
component: () => react_2.default.createElement("div", null, "Test"),
|
|
201
|
+
props: {},
|
|
202
|
+
stateSchema,
|
|
203
|
+
};
|
|
204
|
+
let componentId = "";
|
|
205
|
+
(0, react_1.act)(() => {
|
|
206
|
+
componentId = result.current.addInteractableComponent(component);
|
|
207
|
+
});
|
|
208
|
+
const interactable = result.current.getInteractableComponent(componentId);
|
|
209
|
+
expect(interactable?.stateSchema).toBe(stateSchema);
|
|
210
|
+
});
|
|
211
|
+
it("should convert stateSchema to partial JSON Schema (no required fields)", () => {
|
|
212
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_interactable_provider_1.useTamboInteractable)(), { wrapper });
|
|
213
|
+
const stateSchema = zod_1.z.object({
|
|
214
|
+
count: zod_1.z.number(),
|
|
215
|
+
name: zod_1.z.string(),
|
|
216
|
+
});
|
|
217
|
+
const component = {
|
|
218
|
+
name: "TestComponent",
|
|
219
|
+
description: "A test component",
|
|
220
|
+
component: () => react_2.default.createElement("div", null, "Test"),
|
|
221
|
+
props: {},
|
|
222
|
+
stateSchema,
|
|
223
|
+
};
|
|
224
|
+
(0, react_1.act)(() => {
|
|
225
|
+
result.current.addInteractableComponent(component);
|
|
226
|
+
});
|
|
227
|
+
// Find the state update tool
|
|
228
|
+
const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
|
|
229
|
+
expect(stateToolCall).toBeDefined();
|
|
230
|
+
const inputSchema = stateToolCall[0].inputSchema;
|
|
231
|
+
// The newState property should not have required fields (partial schema)
|
|
232
|
+
expect(inputSchema.properties.newState).toBeDefined();
|
|
233
|
+
expect(inputSchema.properties.newState.required).toBeUndefined();
|
|
234
|
+
// But it should have the properties from the schema
|
|
235
|
+
expect(inputSchema.properties.newState.properties).toBeDefined();
|
|
236
|
+
});
|
|
237
|
+
it("should use additionalProperties when no stateSchema provided", () => {
|
|
238
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_interactable_provider_1.useTamboInteractable)(), { wrapper });
|
|
239
|
+
const component = {
|
|
240
|
+
name: "TestComponent",
|
|
241
|
+
description: "A test component",
|
|
242
|
+
component: () => react_2.default.createElement("div", null, "Test"),
|
|
243
|
+
props: {},
|
|
244
|
+
// No stateSchema
|
|
245
|
+
};
|
|
246
|
+
(0, react_1.act)(() => {
|
|
247
|
+
result.current.addInteractableComponent(component);
|
|
248
|
+
});
|
|
249
|
+
// Find the state update tool
|
|
250
|
+
const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
|
|
251
|
+
expect(stateToolCall).toBeDefined();
|
|
252
|
+
const inputSchema = stateToolCall[0].inputSchema;
|
|
253
|
+
// The newState property should allow additional properties
|
|
254
|
+
expect(inputSchema.properties.newState.additionalProperties).toBe(true);
|
|
255
|
+
});
|
|
256
|
+
it("should convert propsSchema to partial JSON Schema for props update tool", () => {
|
|
257
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_interactable_provider_1.useTamboInteractable)(), { wrapper });
|
|
258
|
+
const propsSchema = zod_1.z.object({
|
|
259
|
+
title: zod_1.z.string(),
|
|
260
|
+
count: zod_1.z.number(),
|
|
261
|
+
});
|
|
262
|
+
const component = {
|
|
263
|
+
name: "TestComponent",
|
|
264
|
+
description: "A test component",
|
|
265
|
+
component: () => react_2.default.createElement("div", null, "Test"),
|
|
266
|
+
props: { title: "test", count: 0 },
|
|
267
|
+
propsSchema,
|
|
268
|
+
};
|
|
269
|
+
(0, react_1.act)(() => {
|
|
270
|
+
result.current.addInteractableComponent(component);
|
|
271
|
+
});
|
|
272
|
+
// Find the props update tool (not the state one)
|
|
273
|
+
const propsToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_") &&
|
|
274
|
+
!call[0].name.includes("state"));
|
|
275
|
+
expect(propsToolCall).toBeDefined();
|
|
276
|
+
const inputSchema = propsToolCall[0].inputSchema;
|
|
277
|
+
// The newProps property should not have required fields (partial schema)
|
|
278
|
+
expect(inputSchema.properties.newProps).toBeDefined();
|
|
279
|
+
expect(inputSchema.properties.newProps.required).toBeUndefined();
|
|
280
|
+
// But it should have the properties from the schema
|
|
281
|
+
expect(inputSchema.properties.newProps.properties).toBeDefined();
|
|
282
|
+
});
|
|
283
|
+
it("should use additionalProperties when no propsSchema provided", () => {
|
|
284
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_interactable_provider_1.useTamboInteractable)(), { wrapper });
|
|
285
|
+
const component = {
|
|
286
|
+
name: "TestComponent",
|
|
287
|
+
description: "A test component",
|
|
288
|
+
component: () => react_2.default.createElement("div", null, "Test"),
|
|
289
|
+
props: { title: "test" },
|
|
290
|
+
// No propsSchema
|
|
291
|
+
};
|
|
292
|
+
(0, react_1.act)(() => {
|
|
293
|
+
result.current.addInteractableComponent(component);
|
|
294
|
+
});
|
|
295
|
+
// Find the props update tool
|
|
296
|
+
const propsToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_") &&
|
|
297
|
+
!call[0].name.includes("state"));
|
|
298
|
+
expect(propsToolCall).toBeDefined();
|
|
299
|
+
const inputSchema = propsToolCall[0].inputSchema;
|
|
300
|
+
// The newProps property should allow additional properties
|
|
301
|
+
expect(inputSchema.properties.newProps.additionalProperties).toBe(true);
|
|
302
|
+
});
|
|
303
|
+
});
|
|
62
304
|
//# sourceMappingURL=tambo-interactable-provider.test.js.map
|