@tambo-ai/react 0.73.0 → 0.74.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 +12 -12
- package/dist/hooks/use-component-state.d.ts +1 -1
- package/dist/hooks/use-component-state.js.map +1 -1
- package/dist/hooks/use-streaming-props.d.ts +1 -1
- package/dist/hooks/use-streaming-props.js +1 -1
- package/dist/hooks/use-streaming-props.js.map +1 -1
- package/dist/hooks/use-tambo-stream-status.d.ts +1 -1
- package/dist/hooks/use-tambo-stream-status.js +1 -1
- package/dist/hooks/use-tambo-stream-status.js.map +1 -1
- package/dist/mcp/mcp-hooks.d.ts +4 -0
- package/dist/mcp/mcp-hooks.d.ts.map +1 -1
- package/dist/mcp/mcp-hooks.js +4 -0
- package/dist/mcp/mcp-hooks.js.map +1 -1
- package/dist/providers/tambo-interactable-provider-partial-updates.test.js +3 -3
- package/dist/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
- package/dist/providers/tambo-interactable-provider.js +2 -2
- package/dist/providers/tambo-interactable-provider.js.map +1 -1
- package/dist/providers/tambo-interactable-provider.test.js +3 -3
- package/dist/providers/tambo-interactable-provider.test.js.map +1 -1
- package/dist/providers/tambo-provider.d.ts +3 -0
- package/dist/providers/tambo-provider.d.ts.map +1 -1
- package/dist/providers/tambo-provider.js +3 -0
- package/dist/providers/tambo-provider.js.map +1 -1
- package/dist/providers/tambo-thread-input-provider.d.ts.map +1 -1
- package/dist/providers/tambo-thread-input-provider.js +1 -0
- package/dist/providers/tambo-thread-input-provider.js.map +1 -1
- package/dist/util/resource-content-resolver.d.ts.map +1 -1
- package/dist/util/resource-content-resolver.js +2 -0
- package/dist/util/resource-content-resolver.js.map +1 -1
- package/dist/v1/__tests__/v1-interactables.test.d.ts +2 -0
- package/dist/v1/__tests__/v1-interactables.test.d.ts.map +1 -0
- package/dist/v1/__tests__/v1-interactables.test.js +135 -0
- package/dist/v1/__tests__/v1-interactables.test.js.map +1 -0
- package/dist/v1/components/v1-component-renderer.d.ts +48 -0
- package/dist/v1/components/v1-component-renderer.d.ts.map +1 -0
- package/dist/v1/components/v1-component-renderer.js +137 -0
- package/dist/v1/components/v1-component-renderer.js.map +1 -0
- package/dist/v1/components/v1-component-renderer.test.d.ts +2 -0
- package/dist/v1/components/v1-component-renderer.test.d.ts.map +1 -0
- package/dist/v1/components/v1-component-renderer.test.js +270 -0
- package/dist/v1/components/v1-component-renderer.test.js.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-component-state.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-component-state.js +2 -25
- package/dist/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-component-state.test.js +2 -1
- package/dist/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-messages.test.js +25 -1
- package/dist/v1/hooks/use-tambo-v1-messages.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-send-message.d.ts +18 -0
- package/dist/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-send-message.js +204 -17
- package/dist/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-send-message.test.js +261 -7
- package/dist/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-stream-status.d.ts +90 -0
- package/dist/v1/hooks/use-tambo-v1-stream-status.d.ts.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-stream-status.js +179 -0
- package/dist/v1/hooks/use-tambo-v1-stream-status.js.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-stream-status.test.d.ts +2 -0
- package/dist/v1/hooks/use-tambo-v1-stream-status.test.d.ts.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-stream-status.test.js +371 -0
- package/dist/v1/hooks/use-tambo-v1-stream-status.test.js.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-suggestions.d.ts +78 -54
- package/dist/v1/hooks/use-tambo-v1-suggestions.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-suggestions.js +153 -87
- package/dist/v1/hooks/use-tambo-v1-suggestions.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-suggestions.test.js +213 -134
- package/dist/v1/hooks/use-tambo-v1-suggestions.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-thread-input.test.js +148 -13
- package/dist/v1/hooks/use-tambo-v1-thread-input.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-thread-list.d.ts +8 -21
- package/dist/v1/hooks/use-tambo-v1-thread-list.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-thread-list.js +11 -10
- package/dist/v1/hooks/use-tambo-v1-thread-list.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-thread-list.test.js +37 -2
- package/dist/v1/hooks/use-tambo-v1-thread-list.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-thread.d.ts +1 -1
- package/dist/v1/hooks/use-tambo-v1-thread.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-thread.js +2 -7
- package/dist/v1/hooks/use-tambo-v1-thread.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-thread.test.js +2 -0
- package/dist/v1/hooks/use-tambo-v1-thread.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1.d.ts +12 -28
- package/dist/v1/hooks/use-tambo-v1.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1.js +164 -31
- package/dist/v1/hooks/use-tambo-v1.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1.test.js +891 -18
- package/dist/v1/hooks/use-tambo-v1.test.js.map +1 -1
- package/dist/v1/index.d.ts +7 -1
- package/dist/v1/index.d.ts.map +1 -1
- package/dist/v1/index.js +18 -1
- package/dist/v1/index.js.map +1 -1
- package/dist/v1/providers/tambo-v1-provider.d.ts +16 -6
- package/dist/v1/providers/tambo-v1-provider.d.ts.map +1 -1
- package/dist/v1/providers/tambo-v1-provider.js +14 -19
- package/dist/v1/providers/tambo-v1-provider.js.map +1 -1
- package/dist/v1/providers/tambo-v1-provider.test.js +34 -20
- package/dist/v1/providers/tambo-v1-provider.test.js.map +1 -1
- package/dist/v1/providers/tambo-v1-stream-context.d.ts +3 -3
- package/dist/v1/providers/tambo-v1-stream-context.d.ts.map +1 -1
- package/dist/v1/providers/tambo-v1-stream-context.js +60 -12
- package/dist/v1/providers/tambo-v1-stream-context.js.map +1 -1
- package/dist/v1/providers/tambo-v1-stream-context.test.js +49 -20
- package/dist/v1/providers/tambo-v1-stream-context.test.js.map +1 -1
- package/dist/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
- package/dist/v1/providers/tambo-v1-stub-provider.js +2 -0
- package/dist/v1/providers/tambo-v1-stub-provider.js.map +1 -1
- package/dist/v1/providers/tambo-v1-stub-provider.test.js +7 -6
- package/dist/v1/providers/tambo-v1-stub-provider.test.js.map +1 -1
- package/dist/v1/providers/tambo-v1-thread-input-provider.d.ts +1 -6
- package/dist/v1/providers/tambo-v1-thread-input-provider.d.ts.map +1 -1
- package/dist/v1/providers/tambo-v1-thread-input-provider.js +14 -12
- package/dist/v1/providers/tambo-v1-thread-input-provider.js.map +1 -1
- package/dist/v1/types/event.d.ts +9 -1
- package/dist/v1/types/event.d.ts.map +1 -1
- package/dist/v1/types/event.js.map +1 -1
- package/dist/v1/types/event.test.js +5 -1
- package/dist/v1/types/event.test.js.map +1 -1
- package/dist/v1/types/message.d.ts +65 -7
- package/dist/v1/types/message.d.ts.map +1 -1
- package/dist/v1/types/message.js.map +1 -1
- package/dist/v1/types/thread.d.ts +4 -0
- package/dist/v1/types/thread.d.ts.map +1 -1
- package/dist/v1/types/thread.js.map +1 -1
- package/dist/v1/utils/event-accumulator.d.ts +40 -4
- package/dist/v1/utils/event-accumulator.d.ts.map +1 -1
- package/dist/v1/utils/event-accumulator.js +444 -35
- package/dist/v1/utils/event-accumulator.js.map +1 -1
- package/dist/v1/utils/event-accumulator.test.js +1041 -28
- package/dist/v1/utils/event-accumulator.test.js.map +1 -1
- package/dist/v1/utils/registry-conversion.d.ts +9 -9
- package/dist/v1/utils/registry-conversion.d.ts.map +1 -1
- package/dist/v1/utils/registry-conversion.js +10 -11
- package/dist/v1/utils/registry-conversion.js.map +1 -1
- package/dist/v1/utils/registry-conversion.test.js +39 -11
- package/dist/v1/utils/registry-conversion.test.js.map +1 -1
- package/dist/v1/utils/thread-utils.d.ts +16 -0
- package/dist/v1/utils/thread-utils.d.ts.map +1 -0
- package/dist/v1/utils/thread-utils.js +34 -0
- package/dist/v1/utils/thread-utils.js.map +1 -0
- package/dist/v1/utils/tool-executor.d.ts.map +1 -1
- package/dist/v1/utils/tool-executor.js +2 -0
- package/dist/v1/utils/tool-executor.js.map +1 -1
- package/dist/v1/utils/tool-executor.test.js +5 -0
- package/dist/v1/utils/tool-executor.test.js.map +1 -1
- package/esm/context-helpers/context-helpers-provider.test.js +2 -2
- package/esm/context-helpers/context-helpers.test.js +1 -1
- package/esm/context-helpers/current-interactables-context-helper.d.ts +1 -1
- package/esm/context-helpers/current-page-context-helper.d.ts +1 -1
- package/esm/context-helpers/current-time-context-helper.d.ts +1 -1
- package/esm/context-helpers/index.d.ts +4 -4
- package/esm/context-helpers/index.js +4 -4
- package/esm/hoc/with-tambo-interactable.d.ts +1 -1
- package/esm/hoc/with-tambo-interactable.js +2 -2
- package/esm/hoc/with-tambo-interactable.test.js +3 -3
- package/esm/hooks/index.d.ts +8 -8
- package/esm/hooks/index.js +8 -8
- package/esm/hooks/react-query-hooks.js +1 -1
- package/esm/hooks/use-component-state.d.ts +1 -1
- package/esm/hooks/use-component-state.js +3 -3
- package/esm/hooks/use-component-state.js.map +1 -1
- package/esm/hooks/use-component-state.test.js +5 -5
- package/esm/hooks/use-current-message.d.ts +1 -1
- package/esm/hooks/use-current-message.test.js +1 -1
- package/esm/hooks/use-message-images.test.js +1 -1
- package/esm/hooks/use-streaming-props.d.ts +1 -1
- package/esm/hooks/use-streaming-props.js +1 -1
- package/esm/hooks/use-streaming-props.js.map +1 -1
- package/esm/hooks/use-suggestions.d.ts +2 -2
- package/esm/hooks/use-suggestions.js +10 -10
- package/esm/hooks/use-suggestions.test.js +7 -7
- package/esm/hooks/use-tambo-stream-status.d.ts +1 -1
- package/esm/hooks/use-tambo-stream-status.js +4 -4
- package/esm/hooks/use-tambo-stream-status.js.map +1 -1
- package/esm/hooks/use-tambo-stream-status.test.js +4 -4
- package/esm/hooks/use-tambo-threads.js +3 -3
- package/esm/hooks/use-tambo-threads.test.js +3 -3
- package/esm/hooks/use-tambo-voice.js +2 -2
- package/esm/hooks/use-tambo-voice.test.js +3 -3
- package/esm/index.d.ts +22 -22
- package/esm/index.js +15 -15
- package/esm/mcp/elicitation.d.ts +1 -1
- package/esm/mcp/elicitation.test.js +1 -1
- package/esm/mcp/index.d.ts +7 -7
- package/esm/mcp/index.js +3 -3
- package/esm/mcp/mcp-client.d.ts +1 -1
- package/esm/mcp/mcp-client.js +1 -1
- package/esm/mcp/mcp-client.test.js +1 -1
- package/esm/mcp/mcp-hooks.d.ts +5 -1
- package/esm/mcp/mcp-hooks.d.ts.map +1 -1
- package/esm/mcp/mcp-hooks.js +8 -4
- package/esm/mcp/mcp-hooks.js.map +1 -1
- package/esm/mcp/mcp-hooks.test.js +6 -6
- package/esm/mcp/tambo-mcp-provider.d.ts +4 -4
- package/esm/mcp/tambo-mcp-provider.js +7 -7
- package/esm/mcp/tambo-mcp-provider.test.js +5 -5
- package/esm/mcp/use-mcp-servers.test.js +4 -4
- package/esm/model/generate-component-response.d.ts +1 -1
- package/esm/model/tambo-interactable.d.ts +1 -1
- package/esm/model/tambo-thread.d.ts +1 -1
- package/esm/providers/__tests__/thread-input-resource-resolution.test.js +3 -3
- package/esm/providers/hooks/use-tambo-session-token.test.js +1 -1
- package/esm/providers/index.d.ts +12 -12
- package/esm/providers/index.js +10 -10
- package/esm/providers/tambo-client-provider.js +1 -1
- package/esm/providers/tambo-client-provider.test.js +2 -2
- package/esm/providers/tambo-component-provider.d.ts +1 -1
- package/esm/providers/tambo-component-provider.js +2 -2
- package/esm/providers/tambo-context-attachment-provider.js +1 -1
- package/esm/providers/tambo-context-attachment-provider.test.js +2 -2
- package/esm/providers/tambo-context-helpers-provider.d.ts +1 -1
- package/esm/providers/tambo-context-helpers-provider.js +1 -1
- package/esm/providers/tambo-context-helpers-provider.test.js +2 -2
- package/esm/providers/tambo-interactable-provider-partial-updates.test.js +4 -4
- package/esm/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
- package/esm/providers/tambo-interactable-provider.d.ts +5 -5
- package/esm/providers/tambo-interactable-provider.js +6 -6
- package/esm/providers/tambo-interactable-provider.js.map +1 -1
- package/esm/providers/tambo-interactable-provider.test.js +4 -4
- package/esm/providers/tambo-interactable-provider.test.js.map +1 -1
- package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js +4 -4
- package/esm/providers/tambo-interactables-additional-context.test.js +4 -4
- package/esm/providers/tambo-mcp-token-provider.js +2 -2
- package/esm/providers/tambo-prop-stream-provider/index.d.ts +8 -8
- package/esm/providers/tambo-prop-stream-provider/index.js +9 -9
- package/esm/providers/tambo-prop-stream-provider/pending.d.ts +1 -1
- package/esm/providers/tambo-prop-stream-provider/pending.js +2 -2
- package/esm/providers/tambo-prop-stream-provider/provider.d.ts +1 -1
- package/esm/providers/tambo-prop-stream-provider/provider.js +2 -2
- package/esm/providers/tambo-prop-stream-provider/streaming.d.ts +1 -1
- package/esm/providers/tambo-prop-stream-provider/streaming.js +2 -2
- package/esm/providers/tambo-prop-stream-provider/success.d.ts +1 -1
- package/esm/providers/tambo-prop-stream-provider/success.js +2 -2
- package/esm/providers/tambo-prop-stream-provider/types.d.ts +1 -1
- package/esm/providers/tambo-prop-stream-provider.test.js +4 -4
- package/esm/providers/tambo-provider.d.ts +10 -7
- package/esm/providers/tambo-provider.d.ts.map +1 -1
- package/esm/providers/tambo-provider.js +13 -10
- package/esm/providers/tambo-provider.js.map +1 -1
- package/esm/providers/tambo-registry-provider.d.ts +3 -3
- package/esm/providers/tambo-registry-provider.js +3 -3
- package/esm/providers/tambo-registry-provider.test.js +2 -2
- package/esm/providers/tambo-registry-schema-compat.test.js +2 -2
- package/esm/providers/tambo-stubs.d.ts +4 -4
- package/esm/providers/tambo-stubs.js +9 -9
- package/esm/providers/tambo-stubs.test.js +2 -2
- package/esm/providers/tambo-thread-input-provider.d.ts +2 -2
- package/esm/providers/tambo-thread-input-provider.d.ts.map +1 -1
- package/esm/providers/tambo-thread-input-provider.js +11 -10
- package/esm/providers/tambo-thread-input-provider.js.map +1 -1
- package/esm/providers/tambo-thread-provider-initial-messages.test.js +6 -6
- package/esm/providers/tambo-thread-provider.d.ts +2 -2
- package/esm/providers/tambo-thread-provider.js +8 -8
- package/esm/providers/tambo-thread-provider.test.js +7 -7
- package/esm/schema/index.d.ts +4 -4
- package/esm/schema/index.js +4 -4
- package/esm/schema/json-schema.test.js +1 -1
- package/esm/schema/schema.d.ts +1 -1
- package/esm/schema/schema.js +2 -2
- package/esm/schema/schema.test.js +3 -3
- package/esm/schema/standard-schema.test.js +1 -1
- package/esm/schema/validate.js +2 -2
- package/esm/schema/validate.test.js +1 -1
- package/esm/testing/tools.d.ts +3 -3
- package/esm/testing/tools.js +2 -2
- package/esm/util/content-parts.test.js +1 -1
- package/esm/util/generate-component.d.ts +2 -2
- package/esm/util/generate-component.js +4 -4
- package/esm/util/generate-component.test.js +2 -2
- package/esm/util/is-promise.test.js +1 -1
- package/esm/util/mcp-server-utils.d.ts +1 -1
- package/esm/util/mcp-server-utils.js +1 -1
- package/esm/util/mcp-server-utils.test.js +2 -2
- package/esm/util/message-builder.d.ts +1 -1
- package/esm/util/message-builder.test.js +1 -1
- package/esm/util/query-utils.test.js +1 -1
- package/esm/util/registry-validators.d.ts +1 -1
- package/esm/util/registry-validators.js +2 -2
- package/esm/util/registry-validators.test.js +1 -1
- package/esm/util/registry.d.ts +1 -1
- package/esm/util/registry.js +1 -1
- package/esm/util/registry.test.js +2 -2
- package/esm/util/resource-content-resolver.d.ts +2 -2
- package/esm/util/resource-content-resolver.d.ts.map +1 -1
- package/esm/util/resource-content-resolver.js +3 -1
- package/esm/util/resource-content-resolver.js.map +1 -1
- package/esm/util/resource-content-resolver.test.js +3 -3
- package/esm/util/resource-validators.d.ts +1 -1
- package/esm/util/resource-validators.test.js +1 -1
- package/esm/util/tool-caller.d.ts +1 -1
- package/esm/util/tool-caller.js +1 -1
- package/esm/util/validate-component-name.test.js +1 -1
- package/esm/v1/__tests__/v1-interactables.test.d.ts +2 -0
- package/esm/v1/__tests__/v1-interactables.test.d.ts.map +1 -0
- package/esm/v1/__tests__/v1-interactables.test.js +130 -0
- package/esm/v1/__tests__/v1-interactables.test.js.map +1 -0
- package/esm/v1/components/v1-component-renderer.d.ts +48 -0
- package/esm/v1/components/v1-component-renderer.d.ts.map +1 -0
- package/esm/v1/components/v1-component-renderer.js +100 -0
- package/esm/v1/components/v1-component-renderer.js.map +1 -0
- package/esm/v1/components/v1-component-renderer.test.d.ts +2 -0
- package/esm/v1/components/v1-component-renderer.test.d.ts.map +1 -0
- package/esm/v1/components/v1-component-renderer.test.js +265 -0
- package/esm/v1/components/v1-component-renderer.test.js.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-component-state.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-component-state.js +4 -27
- package/esm/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-component-state.test.js +6 -5
- package/esm/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-messages.d.ts +1 -1
- package/esm/v1/hooks/use-tambo-v1-messages.js +1 -1
- package/esm/v1/hooks/use-tambo-v1-messages.test.js +27 -3
- package/esm/v1/hooks/use-tambo-v1-messages.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-send-message.d.ts +20 -2
- package/esm/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-send-message.js +213 -26
- package/esm/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-send-message.test.js +266 -12
- package/esm/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-stream-status.d.ts +90 -0
- package/esm/v1/hooks/use-tambo-v1-stream-status.d.ts.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-stream-status.js +176 -0
- package/esm/v1/hooks/use-tambo-v1-stream-status.js.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-stream-status.test.d.ts +2 -0
- package/esm/v1/hooks/use-tambo-v1-stream-status.test.d.ts.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-stream-status.test.js +369 -0
- package/esm/v1/hooks/use-tambo-v1-stream-status.test.js.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-suggestions.d.ts +78 -54
- package/esm/v1/hooks/use-tambo-v1-suggestions.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-suggestions.js +157 -91
- package/esm/v1/hooks/use-tambo-v1-suggestions.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-suggestions.test.js +218 -139
- package/esm/v1/hooks/use-tambo-v1-suggestions.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread-input.d.ts +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread-input.js +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread-input.test.js +151 -16
- package/esm/v1/hooks/use-tambo-v1-thread-input.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread-list.d.ts +8 -21
- package/esm/v1/hooks/use-tambo-v1-thread-list.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread-list.js +12 -11
- package/esm/v1/hooks/use-tambo-v1-thread-list.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread-list.test.js +39 -4
- package/esm/v1/hooks/use-tambo-v1-thread-list.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread.d.ts +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread.js +3 -8
- package/esm/v1/hooks/use-tambo-v1-thread.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread.test.js +4 -2
- package/esm/v1/hooks/use-tambo-v1-thread.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1.d.ts +15 -31
- package/esm/v1/hooks/use-tambo-v1.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1.js +134 -34
- package/esm/v1/hooks/use-tambo-v1.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1.test.js +862 -19
- package/esm/v1/hooks/use-tambo-v1.test.js.map +1 -1
- package/esm/v1/index.d.ts +28 -22
- package/esm/v1/index.d.ts.map +1 -1
- package/esm/v1/index.js +30 -18
- package/esm/v1/index.js.map +1 -1
- package/esm/v1/providers/tambo-v1-provider.d.ts +21 -11
- package/esm/v1/providers/tambo-v1-provider.d.ts.map +1 -1
- package/esm/v1/providers/tambo-v1-provider.js +20 -25
- package/esm/v1/providers/tambo-v1-provider.js.map +1 -1
- package/esm/v1/providers/tambo-v1-provider.test.js +40 -26
- package/esm/v1/providers/tambo-v1-provider.test.js.map +1 -1
- package/esm/v1/providers/tambo-v1-stream-context.d.ts +4 -4
- package/esm/v1/providers/tambo-v1-stream-context.d.ts.map +1 -1
- package/esm/v1/providers/tambo-v1-stream-context.js +62 -14
- package/esm/v1/providers/tambo-v1-stream-context.js.map +1 -1
- package/esm/v1/providers/tambo-v1-stream-context.test.js +50 -21
- package/esm/v1/providers/tambo-v1-stream-context.test.js.map +1 -1
- package/esm/v1/providers/tambo-v1-stub-provider.d.ts +3 -3
- package/esm/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
- package/esm/v1/providers/tambo-v1-stub-provider.js +7 -5
- package/esm/v1/providers/tambo-v1-stub-provider.js.map +1 -1
- package/esm/v1/providers/tambo-v1-stub-provider.test.js +12 -11
- package/esm/v1/providers/tambo-v1-stub-provider.test.js.map +1 -1
- package/esm/v1/providers/tambo-v1-thread-input-provider.d.ts +3 -8
- package/esm/v1/providers/tambo-v1-thread-input-provider.d.ts.map +1 -1
- package/esm/v1/providers/tambo-v1-thread-input-provider.js +18 -16
- package/esm/v1/providers/tambo-v1-thread-input-provider.js.map +1 -1
- package/esm/v1/types/event.d.ts +9 -1
- package/esm/v1/types/event.d.ts.map +1 -1
- package/esm/v1/types/event.js.map +1 -1
- package/esm/v1/types/event.test.js +6 -2
- package/esm/v1/types/event.test.js.map +1 -1
- package/esm/v1/types/message.d.ts +65 -7
- package/esm/v1/types/message.d.ts.map +1 -1
- package/esm/v1/types/message.js.map +1 -1
- package/esm/v1/types/thread.d.ts +5 -1
- package/esm/v1/types/thread.d.ts.map +1 -1
- package/esm/v1/types/thread.js.map +1 -1
- package/esm/v1/utils/component-renderer.test.js +1 -1
- package/esm/v1/utils/event-accumulator.d.ts +41 -5
- package/esm/v1/utils/event-accumulator.d.ts.map +1 -1
- package/esm/v1/utils/event-accumulator.js +444 -36
- package/esm/v1/utils/event-accumulator.js.map +1 -1
- package/esm/v1/utils/event-accumulator.test.js +1042 -29
- package/esm/v1/utils/event-accumulator.test.js.map +1 -1
- package/esm/v1/utils/json-patch.test.js +1 -1
- package/esm/v1/utils/registry-conversion.d.ts +9 -9
- package/esm/v1/utils/registry-conversion.d.ts.map +1 -1
- package/esm/v1/utils/registry-conversion.js +11 -12
- package/esm/v1/utils/registry-conversion.js.map +1 -1
- package/esm/v1/utils/registry-conversion.test.js +40 -12
- package/esm/v1/utils/registry-conversion.test.js.map +1 -1
- package/esm/v1/utils/stream-handler.test.js +1 -1
- package/esm/v1/utils/thread-utils.d.ts +16 -0
- package/esm/v1/utils/thread-utils.d.ts.map +1 -0
- package/esm/v1/utils/thread-utils.js +31 -0
- package/esm/v1/utils/thread-utils.js.map +1 -0
- package/esm/v1/utils/tool-call-tracker.d.ts +1 -1
- package/esm/v1/utils/tool-executor.d.ts +1 -1
- package/esm/v1/utils/tool-executor.d.ts.map +1 -1
- package/esm/v1/utils/tool-executor.js +2 -0
- package/esm/v1/utils/tool-executor.js.map +1 -1
- package/esm/v1/utils/tool-executor.test.js +6 -1
- package/esm/v1/utils/tool-executor.test.js.map +1 -1
- package/package.json +11 -10
|
@@ -11,6 +11,7 @@ const use_tambo_v1_thread_input_1 = require("./use-tambo-v1-thread-input");
|
|
|
11
11
|
const use_tambo_v1_1 = require("./use-tambo-v1");
|
|
12
12
|
const tambo_client_provider_1 = require("../../providers/tambo-client-provider");
|
|
13
13
|
const tambo_registry_provider_1 = require("../../providers/tambo-registry-provider");
|
|
14
|
+
const tambo_v1_provider_1 = require("../providers/tambo-v1-provider");
|
|
14
15
|
// Mock dependencies
|
|
15
16
|
jest.mock("./use-tambo-v1-thread-input", () => ({
|
|
16
17
|
useTamboV1ThreadInput: jest.fn(),
|
|
@@ -25,11 +26,34 @@ jest.mock("../../providers/tambo-client-provider", () => ({
|
|
|
25
26
|
jest.mock("../../providers/tambo-registry-provider", () => ({
|
|
26
27
|
useTamboRegistry: jest.fn(),
|
|
27
28
|
}));
|
|
29
|
+
jest.mock("../providers/tambo-v1-provider", () => ({
|
|
30
|
+
useTamboV1Config: jest.fn(),
|
|
31
|
+
}));
|
|
28
32
|
describe("useTamboV1Suggestions", () => {
|
|
29
33
|
let queryClient;
|
|
30
34
|
const mockSetValue = jest.fn();
|
|
31
35
|
const mockSubmit = jest.fn();
|
|
32
|
-
const
|
|
36
|
+
const mockListSuggestions = jest.fn();
|
|
37
|
+
const mockCreateSuggestions = jest.fn();
|
|
38
|
+
const mockSuggestions = [
|
|
39
|
+
{
|
|
40
|
+
id: "suggestion_1",
|
|
41
|
+
messageId: "msg_1",
|
|
42
|
+
title: "What's the weather?",
|
|
43
|
+
detailedSuggestion: "What's the weather like today?",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "suggestion_2",
|
|
47
|
+
messageId: "msg_1",
|
|
48
|
+
title: "Tell me a joke",
|
|
49
|
+
detailedSuggestion: "Can you tell me a funny joke?",
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
const mockSuggestionsResponse = {
|
|
53
|
+
suggestions: mockSuggestions,
|
|
54
|
+
hasMore: false,
|
|
55
|
+
nextCursor: undefined,
|
|
56
|
+
};
|
|
33
57
|
function createWrapper() {
|
|
34
58
|
return function Wrapper({ children }) {
|
|
35
59
|
return (react_2.default.createElement(react_query_1.QueryClientProvider, { client: queryClient }, children));
|
|
@@ -43,21 +67,20 @@ describe("useTamboV1Suggestions", () => {
|
|
|
43
67
|
mutations: { retry: false },
|
|
44
68
|
},
|
|
45
69
|
});
|
|
70
|
+
// Mock useTamboQueryClient to return the test's queryClient
|
|
71
|
+
jest.mocked(tambo_client_provider_1.useTamboQueryClient).mockReturnValue(queryClient);
|
|
72
|
+
// Default mock for v1 config
|
|
73
|
+
jest.mocked(tambo_v1_provider_1.useTamboV1Config).mockReturnValue({ userKey: "user_123" });
|
|
46
74
|
// Default mock for thread input
|
|
47
75
|
jest.mocked(use_tambo_v1_thread_input_1.useTamboV1ThreadInput).mockReturnValue({
|
|
48
76
|
value: "",
|
|
49
77
|
setValue: mockSetValue,
|
|
50
78
|
submit: mockSubmit,
|
|
51
|
-
threadId: "thread_123",
|
|
52
|
-
setThreadId: jest.fn(),
|
|
53
|
-
images: [],
|
|
54
|
-
addImage: jest.fn(),
|
|
55
|
-
addImages: jest.fn(),
|
|
56
|
-
removeImage: jest.fn(),
|
|
57
|
-
clearImages: jest.fn(),
|
|
58
79
|
isPending: false,
|
|
59
80
|
isError: false,
|
|
60
|
-
error:
|
|
81
|
+
error: null,
|
|
82
|
+
isSuccess: false,
|
|
83
|
+
reset: jest.fn(),
|
|
61
84
|
});
|
|
62
85
|
// Default mock for useTamboV1
|
|
63
86
|
jest.mocked(use_tambo_v1_1.useTamboV1).mockReturnValue({
|
|
@@ -65,6 +88,7 @@ describe("useTamboV1Suggestions", () => {
|
|
|
65
88
|
thread: undefined,
|
|
66
89
|
isIdle: true,
|
|
67
90
|
isStreaming: false,
|
|
91
|
+
currentThreadId: "thread_123",
|
|
68
92
|
startNewThread: jest.fn(),
|
|
69
93
|
switchThread: jest.fn(),
|
|
70
94
|
initThread: jest.fn(),
|
|
@@ -91,30 +115,39 @@ describe("useTamboV1Suggestions", () => {
|
|
|
91
115
|
unregisterResource: jest.fn(),
|
|
92
116
|
setResourceSource: jest.fn(),
|
|
93
117
|
});
|
|
94
|
-
// Default mock for client
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
id: "suggestion_1",
|
|
98
|
-
suggestion: "What's the weather?",
|
|
99
|
-
detailedSuggestion: "What's the weather like today?",
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
id: "suggestion_2",
|
|
103
|
-
suggestion: "Tell me a joke",
|
|
104
|
-
detailedSuggestion: "Can you tell me a funny joke?",
|
|
105
|
-
},
|
|
106
|
-
]);
|
|
118
|
+
// Default mock for client - using v1 API structure
|
|
119
|
+
mockListSuggestions.mockResolvedValue({ suggestions: [], hasMore: false });
|
|
120
|
+
mockCreateSuggestions.mockResolvedValue(mockSuggestionsResponse);
|
|
107
121
|
jest.mocked(tambo_client_provider_1.useTamboClient).mockReturnValue({
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
},
|
|
122
|
+
threads: {
|
|
123
|
+
suggestions: {
|
|
124
|
+
list: mockListSuggestions,
|
|
125
|
+
create: mockCreateSuggestions,
|
|
113
126
|
},
|
|
114
127
|
},
|
|
115
128
|
});
|
|
116
129
|
});
|
|
117
130
|
describe("Initial State", () => {
|
|
131
|
+
it("returns empty suggestions when thread has placeholder ID", () => {
|
|
132
|
+
// Mock useTamboV1 to return placeholder thread ID
|
|
133
|
+
jest.mocked(use_tambo_v1_1.useTamboV1).mockReturnValue({
|
|
134
|
+
messages: [],
|
|
135
|
+
thread: undefined,
|
|
136
|
+
isIdle: true,
|
|
137
|
+
isStreaming: false,
|
|
138
|
+
currentThreadId: "placeholder",
|
|
139
|
+
startNewThread: jest.fn(),
|
|
140
|
+
switchThread: jest.fn(),
|
|
141
|
+
initThread: jest.fn(),
|
|
142
|
+
streamingState: { status: "idle" },
|
|
143
|
+
});
|
|
144
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_suggestions_1.useTamboV1Suggestions)(), {
|
|
145
|
+
wrapper: createWrapper(),
|
|
146
|
+
});
|
|
147
|
+
expect(result.current.suggestions).toEqual([]);
|
|
148
|
+
expect(result.current.selectedSuggestionId).toBeNull();
|
|
149
|
+
expect(result.current.isLoading).toBe(false);
|
|
150
|
+
});
|
|
118
151
|
it("returns empty suggestions when no messages", () => {
|
|
119
152
|
const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_suggestions_1.useTamboV1Suggestions)(), {
|
|
120
153
|
wrapper: createWrapper(),
|
|
@@ -135,12 +168,11 @@ describe("useTamboV1Suggestions", () => {
|
|
|
135
168
|
thread: undefined,
|
|
136
169
|
isIdle: true,
|
|
137
170
|
isStreaming: false,
|
|
171
|
+
currentThreadId: "thread_123",
|
|
138
172
|
startNewThread: jest.fn(),
|
|
139
173
|
switchThread: jest.fn(),
|
|
140
174
|
initThread: jest.fn(),
|
|
141
|
-
streamingState: {
|
|
142
|
-
status: "idle",
|
|
143
|
-
},
|
|
175
|
+
streamingState: { status: "idle" },
|
|
144
176
|
});
|
|
145
177
|
const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_suggestions_1.useTamboV1Suggestions)(), {
|
|
146
178
|
wrapper: createWrapper(),
|
|
@@ -162,12 +194,11 @@ describe("useTamboV1Suggestions", () => {
|
|
|
162
194
|
thread: undefined,
|
|
163
195
|
isIdle: true,
|
|
164
196
|
isStreaming: false,
|
|
197
|
+
currentThreadId: "thread_123",
|
|
165
198
|
startNewThread: jest.fn(),
|
|
166
199
|
switchThread: jest.fn(),
|
|
167
200
|
initThread: jest.fn(),
|
|
168
|
-
streamingState: {
|
|
169
|
-
status: "idle",
|
|
170
|
-
},
|
|
201
|
+
streamingState: { status: "idle" },
|
|
171
202
|
});
|
|
172
203
|
const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_suggestions_1.useTamboV1Suggestions)(), {
|
|
173
204
|
wrapper: createWrapper(),
|
|
@@ -175,11 +206,46 @@ describe("useTamboV1Suggestions", () => {
|
|
|
175
206
|
await (0, react_1.waitFor)(() => {
|
|
176
207
|
expect(result.current.suggestions).toHaveLength(2);
|
|
177
208
|
});
|
|
178
|
-
|
|
179
|
-
|
|
209
|
+
// Should first call list, then create since list returns empty
|
|
210
|
+
expect(mockListSuggestions).toHaveBeenCalledWith("msg_1", {
|
|
211
|
+
threadId: "thread_123",
|
|
212
|
+
userKey: "user_123",
|
|
213
|
+
});
|
|
214
|
+
expect(mockCreateSuggestions).toHaveBeenCalledWith("msg_1", expect.objectContaining({
|
|
215
|
+
threadId: "thread_123",
|
|
180
216
|
maxSuggestions: 3,
|
|
217
|
+
userKey: "user_123",
|
|
181
218
|
}));
|
|
182
219
|
});
|
|
220
|
+
it("returns existing suggestions from list without calling create", async () => {
|
|
221
|
+
mockListSuggestions.mockResolvedValue(mockSuggestionsResponse);
|
|
222
|
+
jest.mocked(use_tambo_v1_1.useTamboV1).mockReturnValue({
|
|
223
|
+
messages: [
|
|
224
|
+
{
|
|
225
|
+
id: "msg_1",
|
|
226
|
+
role: "assistant",
|
|
227
|
+
content: [],
|
|
228
|
+
createdAt: "2024-01-01T00:00:00Z",
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
thread: undefined,
|
|
232
|
+
isIdle: true,
|
|
233
|
+
isStreaming: false,
|
|
234
|
+
currentThreadId: "thread_123",
|
|
235
|
+
startNewThread: jest.fn(),
|
|
236
|
+
switchThread: jest.fn(),
|
|
237
|
+
initThread: jest.fn(),
|
|
238
|
+
streamingState: { status: "idle" },
|
|
239
|
+
});
|
|
240
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_suggestions_1.useTamboV1Suggestions)(), {
|
|
241
|
+
wrapper: createWrapper(),
|
|
242
|
+
});
|
|
243
|
+
await (0, react_1.waitFor)(() => {
|
|
244
|
+
expect(result.current.suggestions).toHaveLength(2);
|
|
245
|
+
});
|
|
246
|
+
expect(mockListSuggestions).toHaveBeenCalled();
|
|
247
|
+
expect(mockCreateSuggestions).not.toHaveBeenCalled();
|
|
248
|
+
});
|
|
183
249
|
it("does not generate suggestions when thread is streaming", () => {
|
|
184
250
|
jest.mocked(use_tambo_v1_1.useTamboV1).mockReturnValue({
|
|
185
251
|
messages: [
|
|
@@ -193,35 +259,19 @@ describe("useTamboV1Suggestions", () => {
|
|
|
193
259
|
thread: undefined,
|
|
194
260
|
isIdle: false,
|
|
195
261
|
isStreaming: true,
|
|
262
|
+
currentThreadId: "thread_123",
|
|
196
263
|
startNewThread: jest.fn(),
|
|
197
264
|
switchThread: jest.fn(),
|
|
198
265
|
initThread: jest.fn(),
|
|
199
|
-
streamingState: {
|
|
200
|
-
status: "streaming",
|
|
201
|
-
runId: "run_1",
|
|
202
|
-
},
|
|
266
|
+
streamingState: { status: "streaming", runId: "run_1" },
|
|
203
267
|
});
|
|
204
268
|
(0, react_1.renderHook)(() => (0, use_tambo_v1_suggestions_1.useTamboV1Suggestions)(), {
|
|
205
269
|
wrapper: createWrapper(),
|
|
206
270
|
});
|
|
207
|
-
expect(
|
|
271
|
+
expect(mockListSuggestions).not.toHaveBeenCalled();
|
|
272
|
+
expect(mockCreateSuggestions).not.toHaveBeenCalled();
|
|
208
273
|
});
|
|
209
|
-
it("does not generate suggestions when
|
|
210
|
-
jest.mocked(use_tambo_v1_thread_input_1.useTamboV1ThreadInput).mockReturnValue({
|
|
211
|
-
value: "",
|
|
212
|
-
setValue: mockSetValue,
|
|
213
|
-
submit: mockSubmit,
|
|
214
|
-
threadId: undefined,
|
|
215
|
-
setThreadId: jest.fn(),
|
|
216
|
-
images: [],
|
|
217
|
-
addImage: jest.fn(),
|
|
218
|
-
addImages: jest.fn(),
|
|
219
|
-
removeImage: jest.fn(),
|
|
220
|
-
clearImages: jest.fn(),
|
|
221
|
-
isPending: false,
|
|
222
|
-
isError: false,
|
|
223
|
-
error: undefined,
|
|
224
|
-
});
|
|
274
|
+
it("does not generate suggestions when autoGenerate is false", () => {
|
|
225
275
|
jest.mocked(use_tambo_v1_1.useTamboV1).mockReturnValue({
|
|
226
276
|
messages: [
|
|
227
277
|
{
|
|
@@ -234,17 +284,17 @@ describe("useTamboV1Suggestions", () => {
|
|
|
234
284
|
thread: undefined,
|
|
235
285
|
isIdle: true,
|
|
236
286
|
isStreaming: false,
|
|
287
|
+
currentThreadId: "thread_123",
|
|
237
288
|
startNewThread: jest.fn(),
|
|
238
289
|
switchThread: jest.fn(),
|
|
239
290
|
initThread: jest.fn(),
|
|
240
|
-
streamingState: {
|
|
241
|
-
status: "idle",
|
|
242
|
-
},
|
|
291
|
+
streamingState: { status: "idle" },
|
|
243
292
|
});
|
|
244
|
-
(0, react_1.renderHook)(() => (0, use_tambo_v1_suggestions_1.useTamboV1Suggestions)(), {
|
|
293
|
+
(0, react_1.renderHook)(() => (0, use_tambo_v1_suggestions_1.useTamboV1Suggestions)({ autoGenerate: false }), {
|
|
245
294
|
wrapper: createWrapper(),
|
|
246
295
|
});
|
|
247
|
-
expect(
|
|
296
|
+
expect(mockListSuggestions).not.toHaveBeenCalled();
|
|
297
|
+
expect(mockCreateSuggestions).not.toHaveBeenCalled();
|
|
248
298
|
});
|
|
249
299
|
it("uses custom maxSuggestions option", async () => {
|
|
250
300
|
jest.mocked(use_tambo_v1_1.useTamboV1).mockReturnValue({
|
|
@@ -259,24 +309,21 @@ describe("useTamboV1Suggestions", () => {
|
|
|
259
309
|
thread: undefined,
|
|
260
310
|
isIdle: true,
|
|
261
311
|
isStreaming: false,
|
|
312
|
+
currentThreadId: "thread_123",
|
|
262
313
|
startNewThread: jest.fn(),
|
|
263
314
|
switchThread: jest.fn(),
|
|
264
315
|
initThread: jest.fn(),
|
|
265
|
-
streamingState: {
|
|
266
|
-
status: "idle",
|
|
267
|
-
},
|
|
316
|
+
streamingState: { status: "idle" },
|
|
268
317
|
});
|
|
269
318
|
const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_suggestions_1.useTamboV1Suggestions)({ maxSuggestions: 5 }), { wrapper: createWrapper() });
|
|
270
319
|
await (0, react_1.waitFor)(() => {
|
|
271
320
|
expect(result.current.suggestions).toHaveLength(2);
|
|
272
321
|
});
|
|
273
|
-
expect(
|
|
274
|
-
maxSuggestions: 5,
|
|
275
|
-
}));
|
|
322
|
+
expect(mockCreateSuggestions).toHaveBeenCalledWith("msg_1", expect.objectContaining({ maxSuggestions: 5 }));
|
|
276
323
|
});
|
|
277
324
|
});
|
|
278
325
|
describe("Accepting Suggestions", () => {
|
|
279
|
-
it("updates
|
|
326
|
+
it("updates input value when accepting without submit", async () => {
|
|
280
327
|
jest.mocked(use_tambo_v1_1.useTamboV1).mockReturnValue({
|
|
281
328
|
messages: [
|
|
282
329
|
{
|
|
@@ -289,12 +336,11 @@ describe("useTamboV1Suggestions", () => {
|
|
|
289
336
|
thread: undefined,
|
|
290
337
|
isIdle: true,
|
|
291
338
|
isStreaming: false,
|
|
339
|
+
currentThreadId: "thread_123",
|
|
292
340
|
startNewThread: jest.fn(),
|
|
293
341
|
switchThread: jest.fn(),
|
|
294
342
|
initThread: jest.fn(),
|
|
295
|
-
streamingState: {
|
|
296
|
-
status: "idle",
|
|
297
|
-
},
|
|
343
|
+
streamingState: { status: "idle" },
|
|
298
344
|
});
|
|
299
345
|
const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_suggestions_1.useTamboV1Suggestions)(), {
|
|
300
346
|
wrapper: createWrapper(),
|
|
@@ -324,12 +370,11 @@ describe("useTamboV1Suggestions", () => {
|
|
|
324
370
|
thread: undefined,
|
|
325
371
|
isIdle: true,
|
|
326
372
|
isStreaming: false,
|
|
373
|
+
currentThreadId: "thread_123",
|
|
327
374
|
startNewThread: jest.fn(),
|
|
328
375
|
switchThread: jest.fn(),
|
|
329
376
|
initThread: jest.fn(),
|
|
330
|
-
streamingState: {
|
|
331
|
-
status: "idle",
|
|
332
|
-
},
|
|
377
|
+
streamingState: { status: "idle" },
|
|
333
378
|
});
|
|
334
379
|
const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_suggestions_1.useTamboV1Suggestions)(), {
|
|
335
380
|
wrapper: createWrapper(),
|
|
@@ -344,65 +389,40 @@ describe("useTamboV1Suggestions", () => {
|
|
|
344
389
|
expect(mockSetValue).toHaveBeenCalledWith("What's the weather like today?");
|
|
345
390
|
expect(mockSubmit).toHaveBeenCalled();
|
|
346
391
|
});
|
|
347
|
-
it("throws error when suggestion has no
|
|
348
|
-
jest.mocked(use_tambo_v1_1.useTamboV1).mockReturnValue({
|
|
349
|
-
messages: [
|
|
350
|
-
{
|
|
351
|
-
id: "msg_1",
|
|
352
|
-
role: "assistant",
|
|
353
|
-
content: [],
|
|
354
|
-
createdAt: "2024-01-01T00:00:00Z",
|
|
355
|
-
},
|
|
356
|
-
],
|
|
357
|
-
thread: undefined,
|
|
358
|
-
isIdle: true,
|
|
359
|
-
isStreaming: false,
|
|
360
|
-
startNewThread: jest.fn(),
|
|
361
|
-
switchThread: jest.fn(),
|
|
362
|
-
initThread: jest.fn(),
|
|
363
|
-
streamingState: {
|
|
364
|
-
status: "idle",
|
|
365
|
-
},
|
|
366
|
-
});
|
|
392
|
+
it("throws error when suggestion has no content", async () => {
|
|
367
393
|
const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_suggestions_1.useTamboV1Suggestions)(), {
|
|
368
394
|
wrapper: createWrapper(),
|
|
369
395
|
});
|
|
370
396
|
const emptySuggestion = {
|
|
371
397
|
id: "empty_suggestion",
|
|
372
|
-
|
|
398
|
+
messageId: "msg_1",
|
|
399
|
+
title: "Empty",
|
|
373
400
|
detailedSuggestion: "",
|
|
374
401
|
};
|
|
375
|
-
await expect(result.current.accept({ suggestion: emptySuggestion })).rejects.toThrow("Suggestion has no
|
|
402
|
+
await expect(result.current.accept({ suggestion: emptySuggestion })).rejects.toThrow("Suggestion has no content");
|
|
376
403
|
});
|
|
377
404
|
it("throws error when detailedSuggestion is only whitespace", async () => {
|
|
378
|
-
jest.mocked(use_tambo_v1_1.useTamboV1).mockReturnValue({
|
|
379
|
-
messages: [
|
|
380
|
-
{
|
|
381
|
-
id: "msg_1",
|
|
382
|
-
role: "assistant",
|
|
383
|
-
content: [],
|
|
384
|
-
createdAt: "2024-01-01T00:00:00Z",
|
|
385
|
-
},
|
|
386
|
-
],
|
|
387
|
-
thread: undefined,
|
|
388
|
-
isIdle: true,
|
|
389
|
-
isStreaming: false,
|
|
390
|
-
startNewThread: jest.fn(),
|
|
391
|
-
switchThread: jest.fn(),
|
|
392
|
-
initThread: jest.fn(),
|
|
393
|
-
streamingState: {
|
|
394
|
-
status: "idle",
|
|
395
|
-
},
|
|
396
|
-
});
|
|
397
405
|
const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_suggestions_1.useTamboV1Suggestions)(), {
|
|
398
406
|
wrapper: createWrapper(),
|
|
399
407
|
});
|
|
400
408
|
const whitespaceSuggestion = {
|
|
401
409
|
id: "whitespace_suggestion",
|
|
402
|
-
|
|
410
|
+
messageId: "msg_1",
|
|
411
|
+
title: "Whitespace",
|
|
403
412
|
detailedSuggestion: " ",
|
|
404
413
|
};
|
|
405
|
-
await expect(result.current.accept({ suggestion: whitespaceSuggestion })).rejects.toThrow("Suggestion has no
|
|
414
|
+
await expect(result.current.accept({ suggestion: whitespaceSuggestion })).rejects.toThrow("Suggestion has no content");
|
|
415
|
+
});
|
|
416
|
+
it("throws error when detailedSuggestion is undefined", async () => {
|
|
417
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_suggestions_1.useTamboV1Suggestions)(), {
|
|
418
|
+
wrapper: createWrapper(),
|
|
419
|
+
});
|
|
420
|
+
const undefinedSuggestion = {
|
|
421
|
+
id: "undefined_suggestion",
|
|
422
|
+
messageId: "msg_1",
|
|
423
|
+
title: "Undefined",
|
|
424
|
+
};
|
|
425
|
+
await expect(result.current.accept({ suggestion: undefinedSuggestion })).rejects.toThrow("Suggestion has no content");
|
|
406
426
|
});
|
|
407
427
|
});
|
|
408
428
|
describe("State Management", () => {
|
|
@@ -420,12 +440,11 @@ describe("useTamboV1Suggestions", () => {
|
|
|
420
440
|
thread: undefined,
|
|
421
441
|
isIdle: true,
|
|
422
442
|
isStreaming: false,
|
|
443
|
+
currentThreadId: "thread_123",
|
|
423
444
|
startNewThread: jest.fn(),
|
|
424
445
|
switchThread: jest.fn(),
|
|
425
446
|
initThread: jest.fn(),
|
|
426
|
-
streamingState: {
|
|
427
|
-
status: "idle",
|
|
428
|
-
},
|
|
447
|
+
streamingState: { status: "idle" },
|
|
429
448
|
});
|
|
430
449
|
const { result, rerender } = (0, react_1.renderHook)(() => (0, use_tambo_v1_suggestions_1.useTamboV1Suggestions)(), {
|
|
431
450
|
wrapper: createWrapper(),
|
|
@@ -459,19 +478,23 @@ describe("useTamboV1Suggestions", () => {
|
|
|
459
478
|
thread: undefined,
|
|
460
479
|
isIdle: true,
|
|
461
480
|
isStreaming: false,
|
|
481
|
+
currentThreadId: "thread_123",
|
|
462
482
|
startNewThread: jest.fn(),
|
|
463
483
|
switchThread: jest.fn(),
|
|
464
484
|
initThread: jest.fn(),
|
|
465
|
-
streamingState: {
|
|
466
|
-
status: "idle",
|
|
467
|
-
},
|
|
485
|
+
streamingState: { status: "idle" },
|
|
468
486
|
});
|
|
469
487
|
rerender();
|
|
470
488
|
await (0, react_1.waitFor)(() => {
|
|
471
489
|
expect(result.current.selectedSuggestionId).toBeNull();
|
|
472
490
|
});
|
|
473
491
|
});
|
|
474
|
-
it("
|
|
492
|
+
it("includes pagination info on raw data", async () => {
|
|
493
|
+
mockListSuggestions.mockResolvedValue({
|
|
494
|
+
suggestions: mockSuggestions,
|
|
495
|
+
hasMore: true,
|
|
496
|
+
nextCursor: "cursor_abc",
|
|
497
|
+
});
|
|
475
498
|
jest.mocked(use_tambo_v1_1.useTamboV1).mockReturnValue({
|
|
476
499
|
messages: [
|
|
477
500
|
{
|
|
@@ -484,27 +507,83 @@ describe("useTamboV1Suggestions", () => {
|
|
|
484
507
|
thread: undefined,
|
|
485
508
|
isIdle: true,
|
|
486
509
|
isStreaming: false,
|
|
510
|
+
currentThreadId: "thread_123",
|
|
487
511
|
startNewThread: jest.fn(),
|
|
488
512
|
switchThread: jest.fn(),
|
|
489
513
|
initThread: jest.fn(),
|
|
490
|
-
streamingState: {
|
|
491
|
-
|
|
492
|
-
|
|
514
|
+
streamingState: { status: "idle" },
|
|
515
|
+
});
|
|
516
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_suggestions_1.useTamboV1Suggestions)(), {
|
|
517
|
+
wrapper: createWrapper(),
|
|
518
|
+
});
|
|
519
|
+
await (0, react_1.waitFor)(() => {
|
|
520
|
+
expect(result.current.data?.hasMore).toBe(true);
|
|
521
|
+
expect(result.current.data?.nextCursor).toBe("cursor_abc");
|
|
493
522
|
});
|
|
523
|
+
});
|
|
524
|
+
it("exposes loading and error states", () => {
|
|
494
525
|
const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_suggestions_1.useTamboV1Suggestions)(), {
|
|
495
526
|
wrapper: createWrapper(),
|
|
496
527
|
});
|
|
497
|
-
expect(result.current.
|
|
498
|
-
expect(result.current.
|
|
499
|
-
expect(result.current.
|
|
528
|
+
expect(result.current.isLoading).toBeDefined();
|
|
529
|
+
expect(result.current.isSuccess).toBeDefined();
|
|
530
|
+
expect(result.current.isError).toBeDefined();
|
|
531
|
+
expect(result.current.error).toBeDefined();
|
|
532
|
+
expect(result.current.isAccepting).toBe(false);
|
|
533
|
+
expect(result.current.isGenerating).toBe(false);
|
|
500
534
|
});
|
|
501
|
-
|
|
535
|
+
});
|
|
536
|
+
describe("Manual Generation", () => {
|
|
537
|
+
it("allows manual generation via generate function", async () => {
|
|
538
|
+
jest.mocked(use_tambo_v1_1.useTamboV1).mockReturnValue({
|
|
539
|
+
messages: [
|
|
540
|
+
{
|
|
541
|
+
id: "msg_1",
|
|
542
|
+
role: "assistant",
|
|
543
|
+
content: [],
|
|
544
|
+
createdAt: "2024-01-01T00:00:00Z",
|
|
545
|
+
},
|
|
546
|
+
],
|
|
547
|
+
thread: undefined,
|
|
548
|
+
isIdle: true,
|
|
549
|
+
isStreaming: false,
|
|
550
|
+
currentThreadId: "thread_123",
|
|
551
|
+
startNewThread: jest.fn(),
|
|
552
|
+
switchThread: jest.fn(),
|
|
553
|
+
initThread: jest.fn(),
|
|
554
|
+
streamingState: { status: "idle" },
|
|
555
|
+
});
|
|
556
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_suggestions_1.useTamboV1Suggestions)({ autoGenerate: false }), { wrapper: createWrapper() });
|
|
557
|
+
// No auto-generation
|
|
558
|
+
expect(mockCreateSuggestions).not.toHaveBeenCalled();
|
|
559
|
+
// Manual generation
|
|
560
|
+
await (0, react_1.act)(async () => {
|
|
561
|
+
await result.current.generate();
|
|
562
|
+
});
|
|
563
|
+
expect(mockCreateSuggestions).toHaveBeenCalledWith("msg_1", expect.objectContaining({
|
|
564
|
+
threadId: "thread_123",
|
|
565
|
+
}));
|
|
566
|
+
});
|
|
567
|
+
it("returns undefined from generate when no assistant message", async () => {
|
|
568
|
+
jest.mocked(use_tambo_v1_1.useTamboV1).mockReturnValue({
|
|
569
|
+
messages: [],
|
|
570
|
+
thread: undefined,
|
|
571
|
+
isIdle: true,
|
|
572
|
+
isStreaming: false,
|
|
573
|
+
currentThreadId: "thread_123",
|
|
574
|
+
startNewThread: jest.fn(),
|
|
575
|
+
switchThread: jest.fn(),
|
|
576
|
+
initThread: jest.fn(),
|
|
577
|
+
streamingState: { status: "idle" },
|
|
578
|
+
});
|
|
502
579
|
const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_suggestions_1.useTamboV1Suggestions)(), {
|
|
503
580
|
wrapper: createWrapper(),
|
|
504
581
|
});
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
582
|
+
let generateResult;
|
|
583
|
+
await (0, react_1.act)(async () => {
|
|
584
|
+
generateResult = await result.current.generate();
|
|
585
|
+
});
|
|
586
|
+
expect(generateResult).toBeUndefined();
|
|
508
587
|
});
|
|
509
588
|
});
|
|
510
589
|
});
|