@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry-conversion.d.ts","sourceRoot":"","sources":["../../../src/v1/utils/registry-conversion.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"registry-conversion.d.ts","sourceRoot":"","sources":["../../../src/v1/utils/registry-conversion.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EACV,mBAAmB,EACnB,SAAS,EACT,0BAA0B,EAC3B,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAGvF,KAAK,kBAAkB,GAAG,eAAe,CAAC,kBAAkB,CAAC;AAC7D,KAAK,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC;AAEjC;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,mBAAmB,GAC7B,kBAAkB,CAepB;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EACN,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,GACnC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,GACnC,kBAAkB,EAAE,CAmBtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,SAAS,GAAG,0BAA0B,GAC3C,IAAI,CAwBN;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EACD,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,0BAA0B,CAAC,GACtD,GAAG,CAAC,MAAM,EAAE,SAAS,GAAG,0BAA0B,CAAC,GACtD,IAAI,EAAE,CAiBR"}
|
|
@@ -15,22 +15,21 @@ const schema_1 = require("../../schema/schema");
|
|
|
15
15
|
/**
|
|
16
16
|
* Convert a registered component to v1 API format.
|
|
17
17
|
*
|
|
18
|
-
* Transforms
|
|
19
|
-
* to AvailableComponent (v1 API format
|
|
20
|
-
* @param component - Component from beta SDK registry
|
|
18
|
+
* Transforms RegisteredComponent (from the registry, with props already converted
|
|
19
|
+
* to JSON Schema) to AvailableComponent (v1 API format).
|
|
20
|
+
* @param component - Component from beta SDK registry (already has props as JSON Schema)
|
|
21
21
|
* @returns Component metadata in v1 API format
|
|
22
|
-
* @throws {Error} if
|
|
22
|
+
* @throws {Error} if props is missing
|
|
23
23
|
*/
|
|
24
24
|
function toAvailableComponent(component) {
|
|
25
|
-
//
|
|
26
|
-
if (!component.
|
|
27
|
-
throw new Error(`Component "${component.name}" missing
|
|
25
|
+
// props is the JSON Schema that was converted from propsSchema during registration
|
|
26
|
+
if (!component.props) {
|
|
27
|
+
throw new Error(`Component "${component.name}" missing props - required for v1 API`);
|
|
28
28
|
}
|
|
29
|
-
const propsSchema = (0, schema_1.schemaToJsonSchema)(component.propsSchema);
|
|
30
29
|
return {
|
|
31
30
|
name: component.name,
|
|
32
31
|
description: component.description,
|
|
33
|
-
propsSchema:
|
|
32
|
+
propsSchema: component.props,
|
|
34
33
|
// stateSchema is v1-specific and not available in beta SDK components
|
|
35
34
|
// Components can still have state, but schema must be defined separately
|
|
36
35
|
};
|
|
@@ -38,8 +37,8 @@ function toAvailableComponent(component) {
|
|
|
38
37
|
/**
|
|
39
38
|
* Convert multiple registered components to v1 API format.
|
|
40
39
|
*
|
|
41
|
-
* Transforms a Record/Map of
|
|
42
|
-
* Components without
|
|
40
|
+
* Transforms a Record/Map of RegisteredComponents to an array of AvailableComponents.
|
|
41
|
+
* Components without props will be logged as warnings and skipped.
|
|
43
42
|
* @param components - Record or Map of components from beta SDK registry
|
|
44
43
|
* @returns Array of component metadata in v1 API format
|
|
45
44
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry-conversion.js","sourceRoot":"","sources":["../../../src/v1/utils/registry-conversion.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAwBH,
|
|
1
|
+
{"version":3,"file":"registry-conversion.js","sourceRoot":"","sources":["../../../src/v1/utils/registry-conversion.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAwBH,oDAiBC;AAUD,sDAuBC;AAYD,0CA0BC;AAWD,4CAqBC;AAxID,gDAAyD;AAOzD;;;;;;;;GAQG;AACH,SAAgB,oBAAoB,CAClC,SAA8B;IAE9B,mFAAmF;IACnF,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,cAAc,SAAS,CAAC,IAAI,uCAAuC,CACpE,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,WAAW,EAAE,SAAS,CAAC,WAAW;QAClC,WAAW,EAAE,SAAS,CAAC,KAAgC;QACvD,sEAAsE;QACtE,yEAAyE;KAC1E,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,UAEoC;IAEpC,MAAM,OAAO,GAAyB,EAAE,CAAC;IAEzC,MAAM,OAAO,GACX,UAAU,YAAY,GAAG;QACvB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAEjC,KAAK,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,OAAO,EAAE,CAAC;QACxC,IAAI,CAAC;YACH,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,KAAK,EA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AM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC;YACH,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CACV,kBAAkB,IAAI,uBAAuB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACtG,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/**\n * Registry Conversion Utilities\n *\n * Converts beta SDK component/tool types to v1 API format.\n * Reuses the beta SDK's TamboRegistryProvider but provides conversion\n * utilities for sending component/tool metadata to the v1 API.\n */\n\nimport type { JSONSchema7 } from \"json-schema\";\nimport type {\n RegisteredComponent,\n TamboTool,\n UnsupportedSchemaTamboTool,\n} from \"../../model/component-metadata\";\nimport { schemaToJsonSchema } from \"../../schema/schema\";\nimport type { RunCreateParams } from \"@tambo-ai/typescript-sdk/resources/threads/runs\";\n\n// Use the SDK's types for API requests\ntype AvailableComponent = RunCreateParams.AvailableComponent;\ntype Tool = RunCreateParams.Tool;\n\n/**\n * Convert a registered component to v1 API format.\n *\n * Transforms RegisteredComponent (from the registry, with props already converted\n * to JSON Schema) to AvailableComponent (v1 API format).\n * @param component - Component from beta SDK registry (already has props as JSON Schema)\n * @returns Component metadata in v1 API format\n * @throws {Error} if props is missing\n */\nexport function toAvailableComponent(\n component: RegisteredComponent,\n): AvailableComponent {\n // props is the JSON Schema that was converted from propsSchema during registration\n if (!component.props) {\n throw new Error(\n `Component \"${component.name}\" missing props - required for v1 API`,\n );\n }\n\n return {\n name: component.name,\n description: component.description,\n propsSchema: component.props as Record<string, unknown>,\n // stateSchema is v1-specific and not available in beta SDK components\n // Components can still have state, but schema must be defined separately\n };\n}\n\n/**\n * Convert multiple registered components to v1 API format.\n *\n * Transforms a Record/Map of RegisteredComponents to an array of AvailableComponents.\n * Components without props will be logged as warnings and skipped.\n * @param components - Record or Map of components from beta SDK registry\n * @returns Array of component metadata in v1 API format\n */\nexport function toAvailableComponents(\n components:\n | Record<string, RegisteredComponent>\n | Map<string, RegisteredComponent>,\n): AvailableComponent[] {\n const results: AvailableComponent[] = [];\n\n const entries =\n components instanceof Map\n ? Array.from(components.entries())\n : Object.entries(components);\n\n for (const [name, component] of entries) {\n try {\n results.push(toAvailableComponent(component));\n } catch (error) {\n console.warn(\n `Skipping component \"${name}\" in v1 conversion: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n return results;\n}\n\n/**\n * Convert a registered tool to v1 API format.\n *\n * Transforms TamboTool or UnsupportedSchemaTamboTool (beta SDK format with\n * Standard Schema support) to Tool (v1 API format requiring JSON Schema).\n * Handles both new inputSchema and deprecated toolSchema formats.\n * @param tool - Tool from beta SDK registry\n * @returns Tool metadata in v1 API format\n * @throws {Error} if schema conversion fails or schema is missing\n */\nexport function toAvailableTool(\n tool: TamboTool | UnsupportedSchemaTamboTool,\n): Tool {\n // Check for inputSchema (modern format - required in TamboTool)\n if (\"inputSchema\" in tool && tool.inputSchema) {\n const inputSchema: JSONSchema7 = schemaToJsonSchema(tool.inputSchema);\n return {\n name: tool.name,\n description: tool.description,\n inputSchema: inputSchema as Record<string, unknown>,\n };\n }\n\n // Check for deprecated toolSchema format (UnsupportedSchemaTamboTool)\n if (\"toolSchema\" in tool && tool.toolSchema) {\n const inputSchema: JSONSchema7 = schemaToJsonSchema(tool.toolSchema);\n return {\n name: tool.name,\n description: tool.description,\n inputSchema: inputSchema as Record<string, unknown>,\n };\n }\n\n throw new Error(\n `Tool \"${tool.name}\" missing inputSchema or toolSchema - required for v1 API`,\n );\n}\n\n/**\n * Convert multiple registered tools to v1 API format.\n *\n * Transforms a Record/Map of TamboTools or UnsupportedSchemaTamboTool to an array\n * of Tools. Tools without inputSchema/toolSchema will be logged as warnings\n * and skipped.\n * @param tools - Record or Map of tools from beta SDK registry\n * @returns Array of tool metadata in v1 API format\n */\nexport function toAvailableTools(\n tools:\n | Record<string, TamboTool | UnsupportedSchemaTamboTool>\n | Map<string, TamboTool | UnsupportedSchemaTamboTool>,\n): Tool[] {\n const results: Tool[] = [];\n\n const entries =\n tools instanceof Map ? Array.from(tools.entries()) : Object.entries(tools);\n\n for (const [name, tool] of entries) {\n try {\n results.push(toAvailableTool(tool));\n } catch (error) {\n console.warn(\n `Skipping tool \"${name}\" in v1 conversion: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n return results;\n}\n"]}
|
|
@@ -4,15 +4,21 @@ const zod_1 = require("zod");
|
|
|
4
4
|
const registry_conversion_1 = require("./registry-conversion");
|
|
5
5
|
describe("registry-conversion", () => {
|
|
6
6
|
describe("toAvailableComponent", () => {
|
|
7
|
-
it("converts a component with
|
|
7
|
+
it("converts a component with props (JSON Schema)", () => {
|
|
8
|
+
// RegisteredComponent has props already converted to JSON Schema
|
|
8
9
|
const component = {
|
|
9
10
|
name: "WeatherCard",
|
|
10
11
|
description: "Displays weather information",
|
|
11
12
|
component: () => null,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
props: {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {
|
|
16
|
+
city: { type: "string" },
|
|
17
|
+
temperature: { type: "number" },
|
|
18
|
+
},
|
|
19
|
+
required: ["city", "temperature"],
|
|
20
|
+
},
|
|
21
|
+
contextTools: [],
|
|
16
22
|
};
|
|
17
23
|
const result = (0, registry_conversion_1.toAvailableComponent)(component);
|
|
18
24
|
expect(result.name).toBe("WeatherCard");
|
|
@@ -20,13 +26,14 @@ describe("registry-conversion", () => {
|
|
|
20
26
|
expect(result.propsSchema).toBeDefined();
|
|
21
27
|
expect(result.propsSchema.type).toBe("object");
|
|
22
28
|
});
|
|
23
|
-
it("throws when
|
|
29
|
+
it("throws when props is missing", () => {
|
|
24
30
|
const component = {
|
|
25
31
|
name: "BadComponent",
|
|
26
32
|
description: "Missing schema",
|
|
27
33
|
component: () => null,
|
|
34
|
+
contextTools: [],
|
|
28
35
|
};
|
|
29
|
-
expect(() => (0, registry_conversion_1.toAvailableComponent)(component)).toThrow('Component "BadComponent" missing
|
|
36
|
+
expect(() => (0, registry_conversion_1.toAvailableComponent)(component)).toThrow('Component "BadComponent" missing props');
|
|
30
37
|
});
|
|
31
38
|
});
|
|
32
39
|
describe("toAvailableComponents", () => {
|
|
@@ -36,13 +43,23 @@ describe("registry-conversion", () => {
|
|
|
36
43
|
name: "Card",
|
|
37
44
|
description: "A card component",
|
|
38
45
|
component: () => null,
|
|
39
|
-
|
|
46
|
+
props: {
|
|
47
|
+
type: "object",
|
|
48
|
+
properties: { title: { type: "string" } },
|
|
49
|
+
required: ["title"],
|
|
50
|
+
},
|
|
51
|
+
contextTools: [],
|
|
40
52
|
},
|
|
41
53
|
Button: {
|
|
42
54
|
name: "Button",
|
|
43
55
|
description: "A button component",
|
|
44
56
|
component: () => null,
|
|
45
|
-
|
|
57
|
+
props: {
|
|
58
|
+
type: "object",
|
|
59
|
+
properties: { label: { type: "string" } },
|
|
60
|
+
required: ["label"],
|
|
61
|
+
},
|
|
62
|
+
contextTools: [],
|
|
46
63
|
},
|
|
47
64
|
};
|
|
48
65
|
const result = (0, registry_conversion_1.toAvailableComponents)(components);
|
|
@@ -58,7 +75,12 @@ describe("registry-conversion", () => {
|
|
|
58
75
|
name: "Card",
|
|
59
76
|
description: "A card",
|
|
60
77
|
component: () => null,
|
|
61
|
-
|
|
78
|
+
props: {
|
|
79
|
+
type: "object",
|
|
80
|
+
properties: { title: { type: "string" } },
|
|
81
|
+
required: ["title"],
|
|
82
|
+
},
|
|
83
|
+
contextTools: [],
|
|
62
84
|
},
|
|
63
85
|
],
|
|
64
86
|
]);
|
|
@@ -73,12 +95,18 @@ describe("registry-conversion", () => {
|
|
|
73
95
|
name: "Valid",
|
|
74
96
|
description: "Valid component",
|
|
75
97
|
component: () => null,
|
|
76
|
-
|
|
98
|
+
props: {
|
|
99
|
+
type: "object",
|
|
100
|
+
properties: { x: { type: "string" } },
|
|
101
|
+
required: ["x"],
|
|
102
|
+
},
|
|
103
|
+
contextTools: [],
|
|
77
104
|
},
|
|
78
105
|
Invalid: {
|
|
79
106
|
name: "Invalid",
|
|
80
107
|
description: "Missing schema",
|
|
81
108
|
component: () => null,
|
|
109
|
+
contextTools: [],
|
|
82
110
|
},
|
|
83
111
|
};
|
|
84
112
|
const result = (0, registry_conversion_1.toAvailableComponents)(components);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry-conversion.test.js","sourceRoot":"","sources":["../../../src/v1/utils/registry-conversion.test.ts"],"names":[],"mappings":";;AAAA,6BAAwB;AAExB,+DAK+B;AAE/B,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;QACpC,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;YAC/C,MAAM,SAAS,GAAmB;gBAChC,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,8BAA8B;gBAC3C,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI;gBACrB,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC;oBACpB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;oBAChB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE;iBACxB,CAAC;aACH,CAAC;YAEF,MAAM,MAAM,GAAG,IAAA,0CAAoB,EAAC,SAAS,CAAC,CAAC;YAE/C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACxC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;YAChE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,WAAW,EAAE,CAAC;YACzC,MAAM,CAA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AAY;oBACzB,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;oBACtB,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC;oBACxC,YAAY,EAAE,OAAC,CAAC,GAAG,EAAE;iBACtB;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,gBAAgB;oBAC7B,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;iBACC;aAC1B,CAAC;YAEF,MAAM,MAAM,GAAG,IAAA,sCAAgB,EAAC,KAAK,CAAC,CAAC;YAEvC,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC/B,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACrC,MAAM,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAClC,MAAM,CAAC,gBAAgB,CAAC,yBAAyB,CAAC,CACnD,CAAC;YAEF,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type { TamboComponent, TamboTool } from \"../../model/component-metadata\";\nimport {\n toAvailableComponent,\n toAvailableComponents,\n toAvailableTool,\n toAvailableTools,\n} from \"./registry-conversion\";\n\ndescribe(\"registry-conversion\", () => {\n describe(\"toAvailableComponent\", () => {\n it(\"converts a component with propsSchema\", () => {\n const component: TamboComponent = {\n name: \"WeatherCard\",\n description: \"Displays weather information\",\n component: () => null,\n propsSchema: z.object({\n city: z.string(),\n temperature: z.number(),\n }),\n };\n\n const result = toAvailableComponent(component);\n\n expect(result.name).toBe(\"WeatherCard\");\n expect(result.description).toBe(\"Displays weather information\");\n expect(result.propsSchema).toBeDefined();\n expect((result.propsSchema as Record<string, unknown>).type).toBe(\n \"object\",\n );\n });\n\n it(\"throws when propsSchema is missing\", () => {\n const component = {\n name: \"BadComponent\",\n description: \"Missing schema\",\n component: () => null,\n } as TamboComponent;\n\n expect(() => toAvailableComponent(component)).toThrow(\n 'Component \"BadComponent\" missing propsSchema',\n );\n });\n });\n\n describe(\"toAvailableComponents\", () => {\n it(\"converts a Record of components\", () => {\n const components: Record<string, TamboComponent> = {\n Card: {\n name: \"Card\",\n description: \"A card component\",\n component: () => null,\n propsSchema: z.object({ title: z.string() }),\n },\n Button: {\n name: \"Button\",\n description: \"A button component\",\n component: () => null,\n propsSchema: z.object({ label: z.string() }),\n },\n };\n\n const result = toAvailableComponents(components);\n\n expect(result).toHaveLength(2);\n expect(result.map((c) => c.name)).toContain(\"Card\");\n expect(result.map((c) => c.name)).toContain(\"Button\");\n });\n\n it(\"converts a Map of components\", () => {\n const components = new Map<string, TamboComponent>([\n [\n \"Card\",\n {\n name: \"Card\",\n description: \"A card\",\n component: () => null,\n propsSchema: z.object({ title: z.string() }),\n },\n ],\n ]);\n\n const result = toAvailableComponents(components);\n\n expect(result).toHaveLength(1);\n expect(result[0].name).toBe(\"Card\");\n });\n\n it(\"skips invalid components and logs warning\", () => {\n const warnSpy = jest.spyOn(console, \"warn\").mockImplementation(() => {});\n\n const components: Record<string, TamboComponent> = {\n Valid: {\n name: \"Valid\",\n description: \"Valid component\",\n component: () => null,\n propsSchema: z.object({ x: z.string() }),\n },\n Invalid: {\n name: \"Invalid\",\n description: \"Missing schema\",\n component: () => null,\n } as TamboComponent,\n };\n\n const result = toAvailableComponents(components);\n\n expect(result).toHaveLength(1);\n expect(result[0].name).toBe(\"Valid\");\n expect(warnSpy).toHaveBeenCalledWith(\n expect.stringContaining('Skipping component \"Invalid\"'),\n );\n\n warnSpy.mockRestore();\n });\n });\n\n describe(\"toAvailableTool\", () => {\n it(\"converts a tool with inputSchema\", () => {\n const tool: TamboTool = {\n name: \"get_weather\",\n description: \"Gets weather for a city\",\n tool: async () => ({ temp: 72 }),\n inputSchema: z.object({ city: z.string() }),\n outputSchema: z.any(),\n };\n\n const result = toAvailableTool(tool);\n\n expect(result.name).toBe(\"get_weather\");\n expect(result.description).toBe(\"Gets weather for a city\");\n expect(result.inputSchema).toBeDefined();\n expect((result.inputSchema as Record<string, unknown>).type).toBe(\n \"object\",\n );\n });\n\n it(\"throws when schema is missing\", () => {\n const tool = {\n name: \"bad_tool\",\n description: \"Missing schema\",\n tool: async () => ({}),\n } as unknown as TamboTool;\n\n expect(() => toAvailableTool(tool)).toThrow(\n 'Tool \"bad_tool\" missing inputSchema or toolSchema',\n );\n });\n });\n\n describe(\"toAvailableTools\", () => {\n it(\"converts a Record of tools\", () => {\n const tools: Record<string, TamboTool> = {\n search: {\n name: \"search\",\n description: \"Search the web\",\n tool: async () => [],\n inputSchema: z.object({ query: z.string() }),\n outputSchema: z.any(),\n },\n calculate: {\n name: \"calculate\",\n description: \"Calculate expression\",\n tool: async () => 0,\n inputSchema: z.object({ expr: z.string() }),\n outputSchema: z.any(),\n },\n };\n\n const result = toAvailableTools(tools);\n\n expect(result).toHaveLength(2);\n expect(result.map((t) => t.name)).toContain(\"search\");\n expect(result.map((t) => t.name)).toContain(\"calculate\");\n });\n\n it(\"converts a Map of tools\", () => {\n const tools = new Map<string, TamboTool>([\n [\n \"fetch\",\n {\n name: \"fetch\",\n description: \"Fetch data\",\n tool: async () => null,\n inputSchema: z.object({ url: z.string() }),\n outputSchema: z.any(),\n },\n ],\n ]);\n\n const result = toAvailableTools(tools);\n\n expect(result).toHaveLength(1);\n expect(result[0].name).toBe(\"fetch\");\n });\n\n it(\"skips invalid tools and logs warning\", () => {\n const warnSpy = jest.spyOn(console, \"warn\").mockImplementation(() => {});\n\n const tools: Record<string, TamboTool> = {\n valid: {\n name: \"valid\",\n description: \"Valid tool\",\n tool: async () => null,\n inputSchema: z.object({ x: z.number() }),\n outputSchema: z.any(),\n },\n invalid: {\n name: \"invalid\",\n description: \"Missing schema\",\n tool: async () => null,\n } as unknown as TamboTool,\n };\n\n const result = toAvailableTools(tools);\n\n expect(result).toHaveLength(1);\n expect(result[0].name).toBe(\"valid\");\n expect(warnSpy).toHaveBeenCalledWith(\n expect.stringContaining('Skipping tool \"invalid\"'),\n );\n\n warnSpy.mockRestore();\n });\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"registry-conversion.test.js","sourceRoot":"","sources":["../../../src/v1/utils/registry-conversion.test.ts"],"names":[],"mappings":";;AAAA,6BAAwB;AAKxB,+DAK+B;AAE/B,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;QACpC,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;YACvD,iEAAiE;YACjE,MAAM,SAAS,GAAwB;gBACrC,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,8BAA8B;gBAC3C,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI;gBACrB,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBACxB,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;qBAChC;oBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC;iBAClC;gBACD,YAAY,EAAE,EAAE;aACjB,CAAC;YAEF,MAAM,MAAM,GAAG,IAAA,0CAAoB,EAAC,SAAS,CAAC,CAAC;YAE/C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACxC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;YAChE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,WAAW,EAAE,CAAC;YACzC,MAAM,CAAE,MAAM,CAAC,WAAuC,CAAC,IAAI,CAAC,CAAC,IAAI,CAC/D,QAAQ,CACT,CAAC;QACJ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,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;YAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YAEzE,MAAM,KAAK,GAA8B;gBACvC,KAAK,EAAE;oBACL,IAAI,EAAE,OAAO;oBACb,WAAW,EAAE,YAAY;oBACzB,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;oBACtB,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC;oBACxC,YAAY,EAAE,OAAC,CAAC,GAAG,EAAE;iBACtB;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,gBAAgB;oBAC7B,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;iBACC;aAC1B,CAAC;YAEF,MAAM,MAAM,GAAG,IAAA,sCAAgB,EAAC,KAAK,CAAC,CAAC;YAEvC,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC/B,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACrC,MAAM,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAClC,MAAM,CAAC,gBAAgB,CAAC,yBAAyB,CAAC,CACnD,CAAC;YAEF,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type {\n RegisteredComponent,\n TamboTool,\n} from \"../../model/component-metadata\";\nimport {\n toAvailableComponent,\n toAvailableComponents,\n toAvailableTool,\n toAvailableTools,\n} from \"./registry-conversion\";\n\ndescribe(\"registry-conversion\", () => {\n describe(\"toAvailableComponent\", () => {\n it(\"converts a component with props (JSON Schema)\", () => {\n // RegisteredComponent has props already converted to JSON Schema\n const component: RegisteredComponent = {\n name: \"WeatherCard\",\n description: \"Displays weather information\",\n component: () => null,\n props: {\n type: \"object\",\n properties: {\n city: { type: \"string\" },\n temperature: { type: \"number\" },\n },\n required: [\"city\", \"temperature\"],\n },\n contextTools: [],\n };\n\n const result = toAvailableComponent(component);\n\n expect(result.name).toBe(\"WeatherCard\");\n expect(result.description).toBe(\"Displays weather information\");\n expect(result.propsSchema).toBeDefined();\n expect((result.propsSchema as Record<string, unknown>).type).toBe(\n \"object\",\n );\n });\n\n it(\"throws when props is missing\", () => {\n const component = {\n name: \"BadComponent\",\n description: \"Missing schema\",\n component: () => null,\n contextTools: [],\n } as unknown as RegisteredComponent;\n\n expect(() => toAvailableComponent(component)).toThrow(\n 'Component \"BadComponent\" missing props',\n );\n });\n });\n\n describe(\"toAvailableComponents\", () => {\n it(\"converts a Record of components\", () => {\n const components: Record<string, RegisteredComponent> = {\n Card: {\n name: \"Card\",\n description: \"A card component\",\n component: () => null,\n props: {\n type: \"object\",\n properties: { title: { type: \"string\" } },\n required: [\"title\"],\n },\n contextTools: [],\n },\n Button: {\n name: \"Button\",\n description: \"A button component\",\n component: () => null,\n props: {\n type: \"object\",\n properties: { label: { type: \"string\" } },\n required: [\"label\"],\n },\n contextTools: [],\n },\n };\n\n const result = toAvailableComponents(components);\n\n expect(result).toHaveLength(2);\n expect(result.map((c) => c.name)).toContain(\"Card\");\n expect(result.map((c) => c.name)).toContain(\"Button\");\n });\n\n it(\"converts a Map of components\", () => {\n const components = new Map<string, RegisteredComponent>([\n [\n \"Card\",\n {\n name: \"Card\",\n description: \"A card\",\n component: () => null,\n props: {\n type: \"object\",\n properties: { title: { type: \"string\" } },\n required: [\"title\"],\n },\n contextTools: [],\n },\n ],\n ]);\n\n const result = toAvailableComponents(components);\n\n expect(result).toHaveLength(1);\n expect(result[0].name).toBe(\"Card\");\n });\n\n it(\"skips invalid components and logs warning\", () => {\n const warnSpy = jest.spyOn(console, \"warn\").mockImplementation(() => {});\n\n const components: Record<string, RegisteredComponent> = {\n Valid: {\n name: \"Valid\",\n description: \"Valid component\",\n component: () => null,\n props: {\n type: \"object\",\n properties: { x: { type: \"string\" } },\n required: [\"x\"],\n },\n contextTools: [],\n },\n Invalid: {\n name: \"Invalid\",\n description: \"Missing schema\",\n component: () => null,\n contextTools: [],\n } as unknown as RegisteredComponent,\n };\n\n const result = toAvailableComponents(components);\n\n expect(result).toHaveLength(1);\n expect(result[0].name).toBe(\"Valid\");\n expect(warnSpy).toHaveBeenCalledWith(\n expect.stringContaining('Skipping component \"Invalid\"'),\n );\n\n warnSpy.mockRestore();\n });\n });\n\n describe(\"toAvailableTool\", () => {\n it(\"converts a tool with inputSchema\", () => {\n const tool: TamboTool = {\n name: \"get_weather\",\n description: \"Gets weather for a city\",\n tool: async () => ({ temp: 72 }),\n inputSchema: z.object({ city: z.string() }),\n outputSchema: z.any(),\n };\n\n const result = toAvailableTool(tool);\n\n expect(result.name).toBe(\"get_weather\");\n expect(result.description).toBe(\"Gets weather for a city\");\n expect(result.inputSchema).toBeDefined();\n expect((result.inputSchema as Record<string, unknown>).type).toBe(\n \"object\",\n );\n });\n\n it(\"throws when schema is missing\", () => {\n const tool = {\n name: \"bad_tool\",\n description: \"Missing schema\",\n tool: async () => ({}),\n } as unknown as TamboTool;\n\n expect(() => toAvailableTool(tool)).toThrow(\n 'Tool \"bad_tool\" missing inputSchema or toolSchema',\n );\n });\n });\n\n describe(\"toAvailableTools\", () => {\n it(\"converts a Record of tools\", () => {\n const tools: Record<string, TamboTool> = {\n search: {\n name: \"search\",\n description: \"Search the web\",\n tool: async () => [],\n inputSchema: z.object({ query: z.string() }),\n outputSchema: z.any(),\n },\n calculate: {\n name: \"calculate\",\n description: \"Calculate expression\",\n tool: async () => 0,\n inputSchema: z.object({ expr: z.string() }),\n outputSchema: z.any(),\n },\n };\n\n const result = toAvailableTools(tools);\n\n expect(result).toHaveLength(2);\n expect(result.map((t) => t.name)).toContain(\"search\");\n expect(result.map((t) => t.name)).toContain(\"calculate\");\n });\n\n it(\"converts a Map of tools\", () => {\n const tools = new Map<string, TamboTool>([\n [\n \"fetch\",\n {\n name: \"fetch\",\n description: \"Fetch data\",\n tool: async () => null,\n inputSchema: z.object({ url: z.string() }),\n outputSchema: z.any(),\n },\n ],\n ]);\n\n const result = toAvailableTools(tools);\n\n expect(result).toHaveLength(1);\n expect(result[0].name).toBe(\"fetch\");\n });\n\n it(\"skips invalid tools and logs warning\", () => {\n const warnSpy = jest.spyOn(console, \"warn\").mockImplementation(() => {});\n\n const tools: Record<string, TamboTool> = {\n valid: {\n name: \"valid\",\n description: \"Valid tool\",\n tool: async () => null,\n inputSchema: z.object({ x: z.number() }),\n outputSchema: z.any(),\n },\n invalid: {\n name: \"invalid\",\n description: \"Missing schema\",\n tool: async () => null,\n } as unknown as TamboTool,\n };\n\n const result = toAvailableTools(tools);\n\n expect(result).toHaveLength(1);\n expect(result[0].name).toBe(\"valid\");\n expect(warnSpy).toHaveBeenCalledWith(\n expect.stringContaining('Skipping tool \"invalid\"'),\n );\n\n warnSpy.mockRestore();\n });\n });\n});\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thread utility functions for searching and accessing thread content.
|
|
3
|
+
*/
|
|
4
|
+
import type { StreamState } from "./event-accumulator";
|
|
5
|
+
import type { V1ComponentContent } from "../types/message";
|
|
6
|
+
/**
|
|
7
|
+
* Find a component content block by ID in a specific thread.
|
|
8
|
+
* Searches from most recent messages first since active components are likely near the tail.
|
|
9
|
+
* Only searches the specified thread to prevent cross-thread data access.
|
|
10
|
+
* @param streamState - The current stream state containing thread data
|
|
11
|
+
* @param threadId - The thread ID to search in
|
|
12
|
+
* @param componentId - The component ID to find
|
|
13
|
+
* @returns The component content block, or undefined if not found
|
|
14
|
+
*/
|
|
15
|
+
export declare function findComponentContent(streamState: StreamState, threadId: string, componentId: string): V1ComponentContent | undefined;
|
|
16
|
+
//# sourceMappingURL=thread-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thread-utils.d.ts","sourceRoot":"","sources":["../../../src/v1/utils/thread-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,kBAAkB,GAAG,SAAS,CAkBhC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Thread utility functions for searching and accessing thread content.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.findComponentContent = findComponentContent;
|
|
7
|
+
/**
|
|
8
|
+
* Find a component content block by ID in a specific thread.
|
|
9
|
+
* Searches from most recent messages first since active components are likely near the tail.
|
|
10
|
+
* Only searches the specified thread to prevent cross-thread data access.
|
|
11
|
+
* @param streamState - The current stream state containing thread data
|
|
12
|
+
* @param threadId - The thread ID to search in
|
|
13
|
+
* @param componentId - The component ID to find
|
|
14
|
+
* @returns The component content block, or undefined if not found
|
|
15
|
+
*/
|
|
16
|
+
function findComponentContent(streamState, threadId, componentId) {
|
|
17
|
+
const threadState = streamState.threadMap[threadId];
|
|
18
|
+
if (!threadState) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
// Search from most recent messages first for better performance
|
|
22
|
+
const messages = threadState.thread.messages;
|
|
23
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
24
|
+
const content = messages[i].content;
|
|
25
|
+
for (let j = content.length - 1; j >= 0; j--) {
|
|
26
|
+
const block = content[j];
|
|
27
|
+
if (block.type === "component" && block.id === componentId) {
|
|
28
|
+
return block;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=thread-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thread-utils.js","sourceRoot":"","sources":["../../../src/v1/utils/thread-utils.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAcH,oDAsBC;AA/BD;;;;;;;;GAQG;AACH,SAAgB,oBAAoB,CAClC,WAAwB,EACxB,QAAgB,EAChB,WAAmB;IAEnB,MAAM,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACpD,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,gEAAgE;IAChE,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC7C,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACpC,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YACzB,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,IAAI,KAAK,CAAC,EAAE,KAAK,WAAW,EAAE,CAAC;gBAC3D,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["/**\n * Thread utility functions for searching and accessing thread content.\n */\n\nimport type { StreamState } from \"./event-accumulator\";\nimport type { V1ComponentContent } from \"../types/message\";\n\n/**\n * Find a component content block by ID in a specific thread.\n * Searches from most recent messages first since active components are likely near the tail.\n * Only searches the specified thread to prevent cross-thread data access.\n * @param streamState - The current stream state containing thread data\n * @param threadId - The thread ID to search in\n * @param componentId - The component ID to find\n * @returns The component content block, or undefined if not found\n */\nexport function findComponentContent(\n streamState: StreamState,\n threadId: string,\n componentId: string,\n): V1ComponentContent | undefined {\n const threadState = streamState.threadMap[threadId];\n if (!threadState) {\n return undefined;\n }\n\n // Search from most recent messages first for better performance\n const messages = threadState.thread.messages;\n for (let i = messages.length - 1; i >= 0; i--) {\n const content = messages[i].content;\n for (let j = content.length - 1; j >= 0; j--) {\n const block = content[j];\n if (block.type === \"component\" && block.id === componentId) {\n return block;\n }\n }\n }\n return undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-executor.d.ts","sourceRoot":"","sources":["../../../src/v1/utils/tool-executor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,KAAK,EACV,iBAAiB,EAGlB,MAAM,oDAAoD,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,SAAS,EACf,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"tool-executor.d.ts","sourceRoot":"","sources":["../../../src/v1/utils/tool-executor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,KAAK,EACV,iBAAiB,EAGlB,MAAM,oDAAoD,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,SAAS,EACf,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,iBAAiB,CAAC,CAiD5B;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EACvC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAC3D,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAiC9B"}
|
|
@@ -54,6 +54,7 @@ async function executeClientTool(tool, toolCallId, args) {
|
|
|
54
54
|
return {
|
|
55
55
|
type: "tool_result",
|
|
56
56
|
toolUseId: toolCallId,
|
|
57
|
+
isError: true,
|
|
57
58
|
content: [
|
|
58
59
|
{
|
|
59
60
|
type: "text",
|
|
@@ -86,6 +87,7 @@ async function executeAllPendingTools(toolCalls, registry) {
|
|
|
86
87
|
results.push({
|
|
87
88
|
type: "tool_result",
|
|
88
89
|
toolUseId: toolCallId,
|
|
90
|
+
isError: true,
|
|
89
91
|
content: [
|
|
90
92
|
{
|
|
91
93
|
type: "text",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-executor.js","sourceRoot":"","sources":["../../../src/v1/utils/tool-executor.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAwBH,
|
|
1
|
+
{"version":3,"file":"tool-executor.js","sourceRoot":"","sources":["../../../src/v1/ut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ool Executor for v1 API\n *\n * Handles automatic execution of client-side tools when the model\n * requests them via `tambo.run.awaiting_input` events.\n */\n\nimport type { TamboTool } from \"../../model/component-metadata\";\nimport type {\n ToolResultContent,\n TextContent,\n ResourceContent,\n} from \"@tambo-ai/typescript-sdk/resources/threads/threads\";\n\n/**\n * Pending tool call from the stream accumulator\n */\nexport interface PendingToolCall {\n name: string;\n input: Record<string, unknown>;\n}\n\n/**\n * Execute a single client-side tool and return the result.\n * @param tool - The tool definition from the registry\n * @param toolCallId - The ID of the tool call to respond to\n * @param args - The parsed arguments for the tool\n * @returns ToolResultContent with the execution result or error\n */\nexport async function executeClientTool(\n tool: TamboTool,\n toolCallId: string,\n args: Record<string, unknown>,\n): Promise<ToolResultContent> {\n try {\n const result = await tool.tool(args);\n\n // Transform result to content if transformer provided\n let content: (TextContent | ResourceContent)[];\n if (tool.transformToContent) {\n // transformToContent may return content parts in beta format\n // Convert to v1 format (TextContent | ResourceContent)\n const transformed = await tool.transformToContent(result);\n content = transformed.map((part) => {\n if (part.type === \"text\" && \"text\" in part && part.text) {\n return { type: \"text\" as const, text: part.text };\n }\n // For other types, stringify as text\n return {\n type: \"text\" as const,\n text: JSON.stringify(part),\n };\n });\n } else {\n // Default: stringify result as text\n content = [\n {\n type: \"text\" as const,\n text: typeof result === \"string\" ? result : JSON.stringify(result),\n },\n ];\n }\n\n return {\n type: \"tool_result\",\n toolUseId: toolCallId,\n content,\n };\n } catch (error) {\n return {\n type: \"tool_result\",\n toolUseId: toolCallId,\n isError: true,\n content: [\n {\n type: \"text\" as const,\n text:\n error instanceof Error ? error.message : \"Tool execution failed\",\n },\n ],\n };\n }\n}\n\n/**\n * Execute all pending tool calls and return their results.\n * Tools are executed sequentially to avoid race conditions when\n * tools may have side effects that depend on each other.\n * @param toolCalls - Map of tool call IDs to their call details\n * @param registry - Registry of tool names to their definitions (Map or Record)\n * @returns Array of ToolResultContent for all executed tools\n */\nexport async function executeAllPendingTools(\n toolCalls: Map<string, PendingToolCall>,\n registry: Map<string, TamboTool> | Record<string, TamboTool>,\n): Promise<ToolResultContent[]> {\n const results: ToolResultContent[] = [];\n\n // Normalize registry to allow lookup regardless of Map or Record\n const getTool = (name: string): TamboTool | undefined => {\n if (registry instanceof Map) {\n return registry.get(name);\n }\n return registry[name];\n };\n\n for (const [toolCallId, { name, input }] of toolCalls) {\n const tool = getTool(name);\n if (!tool) {\n results.push({\n type: \"tool_result\",\n toolUseId: toolCallId,\n isError: true,\n content: [\n {\n type: \"text\" as const,\n text: `Tool \"${name}\" not found in registry`,\n },\n ],\n });\n continue;\n }\n\n const result = await executeClientTool(tool, toolCallId, input);\n results.push(result);\n }\n\n return results;\n}\n"]}
|
|
@@ -94,6 +94,7 @@ describe("tool-executor", () => {
|
|
|
94
94
|
expect(result).toEqual({
|
|
95
95
|
type: "tool_result",
|
|
96
96
|
toolUseId: "call-5",
|
|
97
|
+
isError: true,
|
|
97
98
|
content: [{ type: "text", text: "Tool failed!" }],
|
|
98
99
|
});
|
|
99
100
|
});
|
|
@@ -111,6 +112,7 @@ describe("tool-executor", () => {
|
|
|
111
112
|
expect(result).toEqual({
|
|
112
113
|
type: "tool_result",
|
|
113
114
|
toolUseId: "call-6",
|
|
115
|
+
isError: true,
|
|
114
116
|
content: [{ type: "text", text: "Tool execution failed" }],
|
|
115
117
|
});
|
|
116
118
|
});
|
|
@@ -187,6 +189,7 @@ describe("tool-executor", () => {
|
|
|
187
189
|
expect(results[0]).toEqual({
|
|
188
190
|
type: "tool_result",
|
|
189
191
|
toolUseId: "call-1",
|
|
192
|
+
isError: true,
|
|
190
193
|
content: [
|
|
191
194
|
{ type: "text", text: 'Tool "unknown_tool" not found in registry' },
|
|
192
195
|
],
|
|
@@ -211,7 +214,9 @@ describe("tool-executor", () => {
|
|
|
211
214
|
]);
|
|
212
215
|
const results = await (0, tool_executor_1.executeAllPendingTools)(toolCalls, registry);
|
|
213
216
|
expect(results).toHaveLength(2);
|
|
217
|
+
expect(results[0].isError).toBeUndefined();
|
|
214
218
|
expect(results[0].content[0]).toEqual({ type: "text", text: "success" });
|
|
219
|
+
expect(results[1].isError).toBe(true);
|
|
215
220
|
expect(results[1].content[0]).toEqual({
|
|
216
221
|
type: "text",
|
|
217
222
|
text: 'Tool "unknown" not found in registry',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-executor.test.js","sourceRoot":"","sources":["../../../src/v1/utils/tool-executor.test.ts"],"names":[],"mappings":";;AAAA,6BAAwB;AAExB,mDAIyB;AAEzB,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;QACjC,EAAE,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;YACvD,MAAM,IAAI,GAAc;gBACtB,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,cAAc;gBAC3B,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAoB,EAAE,EAAE,CACzC,cAAc,IAAI,WAAW;gBAC/B,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC3C,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE;aACzB,CAAC;YAEF,MAAM,MAAM,GAAG,MAAM,IAAA,iCAAiB,EAAC,IAAI,EAAE,QAAQ,EAAE;gBACrD,IAAI,EAAE,SAAS;aAChB,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;gBACrB,IAAI,EAAE,aAAa;gBACnB,SAAS,EAAE,QAAQ;gBACnB,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,6BAA6B,EAAE,CAAC;aACjE,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,gCAAgC,EAAE,KAAK,IAAI,EAAE;YAC9C,MAAM,IAAI,GAAc;gBACtB,IAAI,EAAE,UAAU;gBAChB,WA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AAE,EAAE,CAAC;aAC3C,CAAC,CAAC;YAEH,MAAM,OAAO,GAAG,MAAM,IAAA,sCAAsB,EAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YAElE,MAAM,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAChC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;YACzE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;gBACpC,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,sCAAsC;aAC7C,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type { TamboTool } from \"../../model/component-metadata\";\nimport {\n executeClientTool,\n executeAllPendingTools,\n type PendingToolCall,\n} from \"./tool-executor\";\n\ndescribe(\"tool-executor\", () => {\n describe(\"executeClientTool\", () => {\n it(\"executes a tool and returns text result\", async () => {\n const tool: TamboTool = {\n name: \"get_weather\",\n description: \"Gets weather\",\n tool: async ({ city }: { city: string }) =>\n `Weather in ${city} is sunny`,\n inputSchema: z.object({ city: z.string() }),\n outputSchema: z.string(),\n };\n\n const result = await executeClientTool(tool, \"call-1\", {\n city: \"Seattle\",\n });\n\n expect(result).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-1\",\n content: [{ type: \"text\", text: \"Weather in Seattle is sunny\" }],\n });\n });\n\n it(\"stringifies non-string results\", async () => {\n const tool: TamboTool = {\n name: \"get_data\",\n description: \"Gets data\",\n tool: async () => ({ value: 42 }),\n inputSchema: z.object({}),\n outputSchema: z.object({ value: z.number() }),\n };\n\n const result = await executeClientTool(tool, \"call-2\", {});\n\n expect(result).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-2\",\n content: [{ type: \"text\", text: '{\"value\":42}' }],\n });\n });\n\n it(\"uses transformToContent when provided\", async () => {\n const tool: TamboTool = {\n name: \"custom_tool\",\n description: \"Custom tool\",\n tool: async () => \"custom result\",\n inputSchema: z.object({}),\n outputSchema: z.string(),\n transformToContent: (result) => [\n { type: \"text\", text: `Transformed: ${result}` },\n ],\n };\n\n const result = await executeClientTool(tool, \"call-3\", {});\n\n expect(result).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-3\",\n content: [{ type: \"text\", text: \"Transformed: custom result\" }],\n });\n });\n\n it(\"handles transformToContent with non-text types by stringifying\", async () => {\n const tool: TamboTool = {\n name: \"image_tool\",\n description: \"Image tool\",\n tool: async () => \"image data\",\n inputSchema: z.object({}),\n outputSchema: z.string(),\n transformToContent: () => [\n {\n type: \"image_url\",\n image_url: { url: \"https://example.com/image.png\" },\n },\n ],\n };\n\n const result = await executeClientTool(tool, \"call-4\", {});\n\n expect(result).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-4\",\n content: [\n {\n type: \"text\",\n text: '{\"type\":\"image_url\",\"image_url\":{\"url\":\"https://example.com/image.png\"}}',\n },\n ],\n });\n });\n\n it(\"handles tool execution errors gracefully\", async () => {\n const tool: TamboTool = {\n name: \"failing_tool\",\n description: \"A tool that fails\",\n tool: async () => {\n throw new Error(\"Tool failed!\");\n },\n inputSchema: z.object({}),\n outputSchema: z.void(),\n };\n\n const result = await executeClientTool(tool, \"call-5\", {});\n\n expect(result).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-5\",\n content: [{ type: \"text\", text: \"Tool failed!\" }],\n });\n });\n\n it(\"handles non-Error throws gracefully\", async () => {\n const tool: TamboTool = {\n name: \"throwing_tool\",\n description: \"A tool that throws a string\",\n tool: async () => {\n throw \"string error\";\n },\n inputSchema: z.object({}),\n outputSchema: z.void(),\n };\n\n const result = await executeClientTool(tool, \"call-6\", {});\n\n expect(result).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-6\",\n content: [{ type: \"text\", text: \"Tool execution failed\" }],\n });\n });\n });\n\n describe(\"executeAllPendingTools\", () => {\n it(\"executes multiple tools with Map registry\", async () => {\n const registry = new Map<string, TamboTool>([\n [\n \"add\",\n {\n name: \"add\",\n description: \"Adds numbers\",\n tool: async ({ a, b }: { a: number; b: number }) => a + b,\n inputSchema: z.object({ a: z.number(), b: z.number() }),\n outputSchema: z.number(),\n },\n ],\n [\n \"multiply\",\n {\n name: \"multiply\",\n description: \"Multiplies numbers\",\n tool: async ({ a, b }: { a: number; b: number }) => a * b,\n inputSchema: z.object({ a: z.number(), b: z.number() }),\n outputSchema: z.number(),\n },\n ],\n ]);\n\n const toolCalls = new Map<string, PendingToolCall>([\n [\"call-1\", { name: \"add\", input: { a: 2, b: 3 } }],\n [\"call-2\", { name: \"multiply\", input: { a: 4, b: 5 } }],\n ]);\n\n const results = await executeAllPendingTools(toolCalls, registry);\n\n expect(results).toHaveLength(2);\n expect(results[0]).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-1\",\n content: [{ type: \"text\", text: \"5\" }],\n });\n expect(results[1]).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-2\",\n content: [{ type: \"text\", text: \"20\" }],\n });\n });\n\n it(\"executes tools with Record registry\", async () => {\n const registry: Record<string, TamboTool> = {\n greet: {\n name: \"greet\",\n description: \"Greets user\",\n tool: async ({ name }: { name: string }) => `Hello, ${name}!`,\n inputSchema: z.object({ name: z.string() }),\n outputSchema: z.string(),\n },\n };\n\n const toolCalls = new Map<string, PendingToolCall>([\n [\"call-1\", { name: \"greet\", input: { name: \"World\" } }],\n ]);\n\n const results = await executeAllPendingTools(toolCalls, registry);\n\n expect(results).toHaveLength(1);\n expect(results[0]).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-1\",\n content: [{ type: \"text\", text: \"Hello, World!\" }],\n });\n });\n\n it(\"returns error result for unknown tools\", async () => {\n const registry = new Map<string, TamboTool>();\n\n const toolCalls = new Map<string, PendingToolCall>([\n [\"call-1\", { name: \"unknown_tool\", input: {} }],\n ]);\n\n const results = await executeAllPendingTools(toolCalls, registry);\n\n expect(results).toHaveLength(1);\n expect(results[0]).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-1\",\n content: [\n { type: \"text\", text: 'Tool \"unknown_tool\" not found in registry' },\n ],\n });\n });\n\n it(\"handles mixed known and unknown tools\", async () => {\n const registry = new Map<string, TamboTool>([\n [\n \"known\",\n {\n name: \"known\",\n description: \"Known tool\",\n tool: async () => \"success\",\n inputSchema: z.object({}),\n outputSchema: z.string(),\n },\n ],\n ]);\n\n const toolCalls = new Map<string, PendingToolCall>([\n [\"call-1\", { name: \"known\", input: {} }],\n [\"call-2\", { name: \"unknown\", input: {} }],\n ]);\n\n const results = await executeAllPendingTools(toolCalls, registry);\n\n expect(results).toHaveLength(2);\n expect(results[0].content[0]).toEqual({ type: \"text\", text: \"success\" });\n expect(results[1].content[0]).toEqual({\n type: \"text\",\n text: 'Tool \"unknown\" not found in registry',\n });\n });\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"tool-executor.test.js","sourceRoot":"","sources":["../../../src/v1/utils/tool-executor.test.ts"],"names":[],"mappings":";;AAAA,6BAAwB;AAExB,mDAIyB;AAEzB,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;QACjC,EAAE,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;YACvD,MAAM,IAAI,GAAc;gBACtB,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,cAAc;gBAC3B,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAoB,EAAE,EAAE,CACzC,cAAc,IAAI,WAAW;gBAC/B,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC3C,YAAY,EAAE,OAAC,CAAC,MAAM,EAA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AC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type { TamboTool } from \"../../model/component-metadata\";\nimport {\n executeClientTool,\n executeAllPendingTools,\n type PendingToolCall,\n} from \"./tool-executor\";\n\ndescribe(\"tool-executor\", () => {\n describe(\"executeClientTool\", () => {\n it(\"executes a tool and returns text result\", async () => {\n const tool: TamboTool = {\n name: \"get_weather\",\n description: \"Gets weather\",\n tool: async ({ city }: { city: string }) =>\n `Weather in ${city} is sunny`,\n inputSchema: z.object({ city: z.string() }),\n outputSchema: z.string(),\n };\n\n const result = await executeClientTool(tool, \"call-1\", {\n city: \"Seattle\",\n });\n\n expect(result).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-1\",\n content: [{ type: \"text\", text: \"Weather in Seattle is sunny\" }],\n });\n });\n\n it(\"stringifies non-string results\", async () => {\n const tool: TamboTool = {\n name: \"get_data\",\n description: \"Gets data\",\n tool: async () => ({ value: 42 }),\n inputSchema: z.object({}),\n outputSchema: z.object({ value: z.number() }),\n };\n\n const result = await executeClientTool(tool, \"call-2\", {});\n\n expect(result).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-2\",\n content: [{ type: \"text\", text: '{\"value\":42}' }],\n });\n });\n\n it(\"uses transformToContent when provided\", async () => {\n const tool: TamboTool = {\n name: \"custom_tool\",\n description: \"Custom tool\",\n tool: async () => \"custom result\",\n inputSchema: z.object({}),\n outputSchema: z.string(),\n transformToContent: (result) => [\n { type: \"text\", text: `Transformed: ${result}` },\n ],\n };\n\n const result = await executeClientTool(tool, \"call-3\", {});\n\n expect(result).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-3\",\n content: [{ type: \"text\", text: \"Transformed: custom result\" }],\n });\n });\n\n it(\"handles transformToContent with non-text types by stringifying\", async () => {\n const tool: TamboTool = {\n name: \"image_tool\",\n description: \"Image tool\",\n tool: async () => \"image data\",\n inputSchema: z.object({}),\n outputSchema: z.string(),\n transformToContent: () => [\n {\n type: \"image_url\",\n image_url: { url: \"https://example.com/image.png\" },\n },\n ],\n };\n\n const result = await executeClientTool(tool, \"call-4\", {});\n\n expect(result).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-4\",\n content: [\n {\n type: \"text\",\n text: '{\"type\":\"image_url\",\"image_url\":{\"url\":\"https://example.com/image.png\"}}',\n },\n ],\n });\n });\n\n it(\"handles tool execution errors gracefully\", async () => {\n const tool: TamboTool = {\n name: \"failing_tool\",\n description: \"A tool that fails\",\n tool: async () => {\n throw new Error(\"Tool failed!\");\n },\n inputSchema: z.object({}),\n outputSchema: z.void(),\n };\n\n const result = await executeClientTool(tool, \"call-5\", {});\n\n expect(result).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-5\",\n isError: true,\n content: [{ type: \"text\", text: \"Tool failed!\" }],\n });\n });\n\n it(\"handles non-Error throws gracefully\", async () => {\n const tool: TamboTool = {\n name: \"throwing_tool\",\n description: \"A tool that throws a string\",\n tool: async () => {\n throw \"string error\";\n },\n inputSchema: z.object({}),\n outputSchema: z.void(),\n };\n\n const result = await executeClientTool(tool, \"call-6\", {});\n\n expect(result).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-6\",\n isError: true,\n content: [{ type: \"text\", text: \"Tool execution failed\" }],\n });\n });\n });\n\n describe(\"executeAllPendingTools\", () => {\n it(\"executes multiple tools with Map registry\", async () => {\n const registry = new Map<string, TamboTool>([\n [\n \"add\",\n {\n name: \"add\",\n description: \"Adds numbers\",\n tool: async ({ a, b }: { a: number; b: number }) => a + b,\n inputSchema: z.object({ a: z.number(), b: z.number() }),\n outputSchema: z.number(),\n },\n ],\n [\n \"multiply\",\n {\n name: \"multiply\",\n description: \"Multiplies numbers\",\n tool: async ({ a, b }: { a: number; b: number }) => a * b,\n inputSchema: z.object({ a: z.number(), b: z.number() }),\n outputSchema: z.number(),\n },\n ],\n ]);\n\n const toolCalls = new Map<string, PendingToolCall>([\n [\"call-1\", { name: \"add\", input: { a: 2, b: 3 } }],\n [\"call-2\", { name: \"multiply\", input: { a: 4, b: 5 } }],\n ]);\n\n const results = await executeAllPendingTools(toolCalls, registry);\n\n expect(results).toHaveLength(2);\n expect(results[0]).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-1\",\n content: [{ type: \"text\", text: \"5\" }],\n });\n expect(results[1]).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-2\",\n content: [{ type: \"text\", text: \"20\" }],\n });\n });\n\n it(\"executes tools with Record registry\", async () => {\n const registry: Record<string, TamboTool> = {\n greet: {\n name: \"greet\",\n description: \"Greets user\",\n tool: async ({ name }: { name: string }) => `Hello, ${name}!`,\n inputSchema: z.object({ name: z.string() }),\n outputSchema: z.string(),\n },\n };\n\n const toolCalls = new Map<string, PendingToolCall>([\n [\"call-1\", { name: \"greet\", input: { name: \"World\" } }],\n ]);\n\n const results = await executeAllPendingTools(toolCalls, registry);\n\n expect(results).toHaveLength(1);\n expect(results[0]).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-1\",\n content: [{ type: \"text\", text: \"Hello, World!\" }],\n });\n });\n\n it(\"returns error result for unknown tools\", async () => {\n const registry = new Map<string, TamboTool>();\n\n const toolCalls = new Map<string, PendingToolCall>([\n [\"call-1\", { name: \"unknown_tool\", input: {} }],\n ]);\n\n const results = await executeAllPendingTools(toolCalls, registry);\n\n expect(results).toHaveLength(1);\n expect(results[0]).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-1\",\n isError: true,\n content: [\n { type: \"text\", text: 'Tool \"unknown_tool\" not found in registry' },\n ],\n });\n });\n\n it(\"handles mixed known and unknown tools\", async () => {\n const registry = new Map<string, TamboTool>([\n [\n \"known\",\n {\n name: \"known\",\n description: \"Known tool\",\n tool: async () => \"success\",\n inputSchema: z.object({}),\n outputSchema: z.string(),\n },\n ],\n ]);\n\n const toolCalls = new Map<string, PendingToolCall>([\n [\"call-1\", { name: \"known\", input: {} }],\n [\"call-2\", { name: \"unknown\", input: {} }],\n ]);\n\n const results = await executeAllPendingTools(toolCalls, registry);\n\n expect(results).toHaveLength(2);\n expect(results[0].isError).toBeUndefined();\n expect(results[0].content[0]).toEqual({ type: \"text\", text: \"success\" });\n expect(results[1].isError).toBe(true);\n expect(results[1].content[0]).toEqual({\n type: \"text\",\n text: 'Tool \"unknown\" not found in registry',\n });\n });\n });\n});\n"]}
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { act, renderHook } from "@testing-library/react";
|
|
15
15
|
import React from "react";
|
|
16
|
-
import { TamboContextHelpersProvider, useTamboContextHelpers, } from "../providers/tambo-context-helpers-provider";
|
|
17
|
-
import { currentPageContextHelper, currentTimeContextHelper, } from "./index";
|
|
16
|
+
import { TamboContextHelpersProvider, useTamboContextHelpers, } from "../providers/tambo-context-helpers-provider.js";
|
|
17
|
+
import { currentPageContextHelper, currentTimeContextHelper, } from "./index.js";
|
|
18
18
|
/**
|
|
19
19
|
* Test wrapper to provide the TamboContextHelpersProvider for hooks.
|
|
20
20
|
* @param helpers - A dictionary of context helper functions.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContextHelperFn } from "./types";
|
|
1
|
+
import { ContextHelperFn } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Prebuilt context helper that provides information about all interactable components currently on the page.
|
|
4
4
|
* This gives the AI awareness of what components it can interact with and their current state.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from "./current-page-context-helper";
|
|
2
|
-
export * from "./current-time-context-helper";
|
|
3
|
-
export * from "./current-interactables-context-helper";
|
|
4
|
-
export * from "./types";
|
|
1
|
+
export * from "./current-page-context-helper.js";
|
|
2
|
+
export * from "./current-time-context-helper.js";
|
|
3
|
+
export * from "./current-interactables-context-helper.js";
|
|
4
|
+
export * from "./types.js";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from "./current-page-context-helper";
|
|
2
|
-
export * from "./current-time-context-helper";
|
|
3
|
-
export * from "./current-interactables-context-helper";
|
|
4
|
-
export * from "./types";
|
|
1
|
+
export * from "./current-page-context-helper.js";
|
|
2
|
+
export * from "./current-time-context-helper.js";
|
|
3
|
+
export * from "./current-interactables-context-helper.js";
|
|
4
|
+
export * from "./types.js";
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { SupportedSchema } from "../schema";
|
|
2
|
+
import { SupportedSchema } from "../schema/index.js";
|
|
3
3
|
export interface InteractableConfig<Props = Record<string, unknown>, State = Record<string, unknown>> {
|
|
4
4
|
/**
|
|
5
5
|
* The name of the component, used for identification in Tambo.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
-
import { TamboMessageProvider } from "../hooks/use-current-message";
|
|
4
|
-
import { useTamboInteractable } from "../providers/tambo-interactable-provider";
|
|
3
|
+
import { TamboMessageProvider } from "../hooks/use-current-message.js";
|
|
4
|
+
import { useTamboInteractable } from "../providers/tambo-interactable-provider.js";
|
|
5
5
|
/**
|
|
6
6
|
* Higher-Order Component that makes any component interactable by tambo.
|
|
7
7
|
* @param WrappedComponent - The component to make interactable
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { render, screen, waitFor } from "@testing-library/react";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { z } from "zod/v3";
|
|
4
|
-
import { useTamboCurrentComponent } from "../hooks/use-current-message";
|
|
5
|
-
import { TamboInteractableProvider } from "../providers/tambo-interactable-provider";
|
|
6
|
-
import { withTamboInteractable } from "./with-tambo-interactable";
|
|
4
|
+
import { useTamboCurrentComponent } from "../hooks/use-current-message.js";
|
|
5
|
+
import { TamboInteractableProvider } from "../providers/tambo-interactable-provider.js";
|
|
6
|
+
import { withTamboInteractable } from "./with-tambo-interactable.js";
|
|
7
7
|
// Create a consistent mock implementation
|
|
8
8
|
const mockAddInteractableComponent = jest.fn(() => "mock-id-123");
|
|
9
9
|
const mockUpdateInteractableComponentProps = jest.fn();
|