@tambo-ai/react 0.75.0 → 1.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hoc/with-tambo-interactable.d.ts.map +1 -1
- package/dist/hoc/with-tambo-interactable.js +13 -13
- package/dist/hoc/with-tambo-interactable.js.map +1 -1
- package/dist/hoc/with-tambo-interactable.test.js +3 -3
- package/dist/hoc/with-tambo-interactable.test.js.map +1 -1
- package/dist/index.d.ts +7 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -59
- package/dist/index.js.map +1 -1
- package/dist/mcp/mcp-hooks.js +5 -5
- package/dist/mcp/mcp-hooks.js.map +1 -1
- package/dist/model/component-metadata.d.ts +4 -4
- package/dist/model/component-metadata.js.map +1 -1
- package/dist/providers/tambo-client-provider.d.ts +6 -0
- package/dist/providers/tambo-client-provider.d.ts.map +1 -1
- package/dist/providers/tambo-client-provider.js +4 -2
- package/dist/providers/tambo-client-provider.js.map +1 -1
- package/dist/providers/tambo-interactable-provider.d.ts +1 -1
- package/dist/providers/tambo-interactables-additional-context-edge-cases.test.js +2 -10
- package/dist/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -1
- package/dist/providers/tambo-interactables-additional-context.test.js +3 -19
- package/dist/providers/tambo-interactables-additional-context.test.js.map +1 -1
- package/dist/providers/tambo-mcp-token-provider.d.ts +8 -17
- package/dist/providers/tambo-mcp-token-provider.d.ts.map +1 -1
- package/dist/providers/tambo-mcp-token-provider.js +20 -97
- package/dist/providers/tambo-mcp-token-provider.js.map +1 -1
- package/dist/testing/tools.d.ts +3 -3
- package/dist/testing/tools.d.ts.map +1 -1
- package/dist/testing/tools.js.map +1 -1
- package/dist/util/registry-validators.js +1 -1
- package/dist/util/registry-validators.js.map +1 -1
- package/dist/v1/__tests__/v1-interactables.test.js +1 -1
- package/dist/v1/__tests__/v1-interactables.test.js.map +1 -1
- package/dist/v1/components/v1-component-renderer.d.ts +9 -9
- package/dist/v1/components/v1-component-renderer.d.ts.map +1 -1
- package/dist/v1/components/v1-component-renderer.js +13 -13
- package/dist/v1/components/v1-component-renderer.js.map +1 -1
- package/dist/v1/components/v1-component-renderer.test.js +15 -15
- package/dist/v1/components/v1-component-renderer.test.js.map +1 -1
- package/{esm/hooks/use-current-message.d.ts → dist/v1/hooks/use-tambo-current-message.d.ts} +30 -9
- package/dist/v1/hooks/use-tambo-current-message.d.ts.map +1 -0
- package/dist/{hooks/use-current-message.js → v1/hooks/use-tambo-current-message.js} +13 -8
- package/dist/v1/hooks/use-tambo-current-message.js.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-auth-state.d.ts +5 -5
- package/dist/v1/hooks/use-tambo-v1-auth-state.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-auth-state.js +8 -8
- package/dist/v1/hooks/use-tambo-v1-auth-state.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-auth-state.test.js +12 -12
- package/dist/v1/hooks/use-tambo-v1-auth-state.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-component-state.d.ts +7 -6
- package/dist/v1/hooks/use-tambo-v1-component-state.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-component-state.js +50 -24
- package/dist/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-component-state.test.js +60 -35
- package/dist/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-messages.d.ts +9 -9
- package/dist/v1/hooks/use-tambo-v1-messages.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-messages.js +4 -4
- package/dist/v1/hooks/use-tambo-v1-messages.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-messages.test.js +7 -7
- package/dist/v1/hooks/use-tambo-v1-messages.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-send-message.d.ts +3 -3
- package/dist/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-send-message.js +20 -22
- package/dist/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-send-message.test.js +51 -51
- 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 +5 -5
- package/dist/v1/hooks/use-tambo-v1-stream-status.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-stream-status.js +12 -14
- package/dist/v1/hooks/use-tambo-v1-stream-status.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-stream-status.test.js +19 -19
- package/dist/v1/hooks/use-tambo-v1-stream-status.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-suggestions.d.ts +7 -7
- package/dist/v1/hooks/use-tambo-v1-suggestions.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-suggestions.js +9 -9
- package/dist/v1/hooks/use-tambo-v1-suggestions.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-suggestions.test.js +44 -44
- package/dist/v1/hooks/use-tambo-v1-suggestions.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-thread-input.d.ts +3 -3
- package/dist/v1/hooks/use-tambo-v1-thread-input.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-thread-input.js +4 -4
- package/dist/v1/hooks/use-tambo-v1-thread-input.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-thread-input.test.js +29 -29
- 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 +4 -4
- package/dist/v1/hooks/use-tambo-v1-thread-list.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-thread-list.js +5 -5
- package/dist/v1/hooks/use-tambo-v1-thread-list.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-thread-list.test.js +13 -17
- package/dist/v1/hooks/use-tambo-v1-thread-list.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-thread.d.ts +3 -3
- package/dist/v1/hooks/use-tambo-v1-thread.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-thread.js +4 -4
- package/dist/v1/hooks/use-tambo-v1-thread.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-thread.test.js +5 -5
- package/dist/v1/hooks/use-tambo-v1-thread.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1.d.ts +16 -7
- package/dist/v1/hooks/use-tambo-v1.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1.js +41 -10
- package/dist/v1/hooks/use-tambo-v1.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1.test.js +176 -48
- package/dist/v1/hooks/use-tambo-v1.test.js.map +1 -1
- package/dist/v1/index.d.ts +31 -27
- package/dist/v1/index.d.ts.map +1 -1
- package/dist/v1/index.js +45 -35
- package/dist/v1/index.js.map +1 -1
- package/dist/v1/providers/tambo-v1-provider.d.ts +20 -20
- package/dist/v1/providers/tambo-v1-provider.d.ts.map +1 -1
- package/dist/v1/providers/tambo-v1-provider.js +32 -32
- package/dist/v1/providers/tambo-v1-provider.js.map +1 -1
- package/dist/v1/providers/tambo-v1-provider.test.js +22 -22
- package/dist/v1/providers/tambo-v1-provider.test.js.map +1 -1
- package/dist/v1/providers/tambo-v1-stream-context.d.ts +15 -15
- package/dist/v1/providers/tambo-v1-stream-context.d.ts.map +1 -1
- package/dist/v1/providers/tambo-v1-stream-context.js +17 -17
- package/dist/v1/providers/tambo-v1-stream-context.js.map +1 -1
- package/dist/v1/providers/tambo-v1-stream-context.test.js +9 -9
- package/dist/v1/providers/tambo-v1-stream-context.test.js.map +1 -1
- package/dist/v1/providers/tambo-v1-stub-provider.d.ts +9 -9
- package/dist/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
- package/dist/v1/providers/tambo-v1-stub-provider.js +7 -7
- package/dist/v1/providers/tambo-v1-stub-provider.js.map +1 -1
- package/dist/v1/providers/tambo-v1-stub-provider.test.js +25 -25
- package/dist/v1/providers/tambo-v1-stub-provider.test.js.map +1 -1
- package/dist/v1/providers/tambo-v1-thread-input-provider.d.ts +9 -9
- package/dist/v1/providers/tambo-v1-thread-input-provider.d.ts.map +1 -1
- package/dist/v1/providers/tambo-v1-thread-input-provider.js +16 -16
- package/dist/v1/providers/tambo-v1-thread-input-provider.js.map +1 -1
- package/dist/v1/types/auth.d.ts +2 -2
- package/dist/v1/types/auth.d.ts.map +1 -1
- package/dist/v1/types/auth.js.map +1 -1
- package/dist/v1/types/component.d.ts +3 -3
- package/dist/v1/types/component.d.ts.map +1 -1
- package/dist/v1/types/component.js +2 -2
- package/dist/v1/types/component.js.map +1 -1
- package/dist/v1/types/event.d.ts +1 -1
- package/dist/v1/types/event.js +1 -1
- package/dist/v1/types/event.js.map +1 -1
- package/dist/v1/types/message.d.ts +17 -24
- package/dist/v1/types/message.d.ts.map +1 -1
- package/dist/v1/types/message.js +1 -1
- package/dist/v1/types/message.js.map +1 -1
- package/dist/v1/types/thread.d.ts +10 -8
- package/dist/v1/types/thread.d.ts.map +1 -1
- package/dist/v1/types/thread.js +1 -1
- package/dist/v1/types/thread.js.map +1 -1
- package/dist/v1/types/tool-choice.d.ts +1 -1
- package/dist/v1/types/tool-choice.js.map +1 -1
- package/dist/v1/utils/component-renderer.d.ts +11 -5
- package/dist/v1/utils/component-renderer.d.ts.map +1 -1
- package/dist/v1/utils/component-renderer.js +16 -7
- package/dist/v1/utils/component-renderer.js.map +1 -1
- package/dist/v1/utils/component-renderer.test.js +7 -7
- package/dist/v1/utils/component-renderer.test.js.map +1 -1
- package/dist/v1/utils/event-accumulator.d.ts +13 -13
- package/dist/v1/utils/event-accumulator.d.ts.map +1 -1
- package/dist/v1/utils/event-accumulator.js +26 -15
- package/dist/v1/utils/event-accumulator.js.map +1 -1
- package/dist/v1/utils/event-accumulator.test.js +54 -19
- package/dist/v1/utils/event-accumulator.test.js.map +1 -1
- package/dist/v1/utils/registry-conversion.d.ts +18 -18
- package/dist/v1/utils/registry-conversion.js +23 -23
- package/dist/v1/utils/registry-conversion.js.map +1 -1
- package/dist/v1/utils/stream-handler.d.ts +1 -1
- package/dist/v1/utils/stream-handler.js +1 -1
- package/dist/v1/utils/stream-handler.js.map +1 -1
- package/dist/v1/utils/thread-utils.d.ts +2 -2
- package/dist/v1/utils/thread-utils.d.ts.map +1 -1
- package/dist/v1/utils/thread-utils.js.map +1 -1
- package/dist/v1/utils/tool-call-tracker.d.ts +1 -1
- package/dist/v1/utils/tool-call-tracker.js +1 -1
- package/dist/v1/utils/tool-call-tracker.js.map +1 -1
- package/dist/v1/utils/tool-executor.d.ts +1 -1
- package/dist/v1/utils/tool-executor.js +2 -2
- package/dist/v1/utils/tool-executor.js.map +1 -1
- package/esm/hoc/with-tambo-interactable.d.ts.map +1 -1
- package/esm/hoc/with-tambo-interactable.js +13 -13
- package/esm/hoc/with-tambo-interactable.js.map +1 -1
- package/esm/hoc/with-tambo-interactable.test.js +1 -1
- package/esm/hoc/with-tambo-interactable.test.js.map +1 -1
- package/esm/index.d.ts +7 -25
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +7 -21
- package/esm/index.js.map +1 -1
- package/esm/mcp/mcp-hooks.js +1 -1
- package/esm/mcp/mcp-hooks.js.map +1 -1
- package/esm/model/component-metadata.d.ts +4 -4
- package/esm/model/component-metadata.js.map +1 -1
- package/esm/providers/tambo-client-provider.d.ts +6 -0
- package/esm/providers/tambo-client-provider.d.ts.map +1 -1
- package/esm/providers/tambo-client-provider.js +4 -2
- package/esm/providers/tambo-client-provider.js.map +1 -1
- package/esm/providers/tambo-interactable-provider.d.ts +1 -1
- package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js +2 -10
- package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -1
- package/esm/providers/tambo-interactables-additional-context.test.js +3 -19
- package/esm/providers/tambo-interactables-additional-context.test.js.map +1 -1
- package/esm/providers/tambo-mcp-token-provider.d.ts +8 -17
- package/esm/providers/tambo-mcp-token-provider.d.ts.map +1 -1
- package/esm/providers/tambo-mcp-token-provider.js +20 -97
- package/esm/providers/tambo-mcp-token-provider.js.map +1 -1
- package/esm/testing/tools.d.ts +3 -3
- package/esm/testing/tools.d.ts.map +1 -1
- package/esm/testing/tools.js.map +1 -1
- package/esm/util/registry-validators.js +1 -1
- package/esm/util/registry-validators.js.map +1 -1
- package/esm/v1/__tests__/v1-interactables.test.js +1 -1
- package/esm/v1/__tests__/v1-interactables.test.js.map +1 -1
- package/esm/v1/components/v1-component-renderer.d.ts +9 -9
- package/esm/v1/components/v1-component-renderer.d.ts.map +1 -1
- package/esm/v1/components/v1-component-renderer.js +12 -12
- package/esm/v1/components/v1-component-renderer.js.map +1 -1
- package/esm/v1/components/v1-component-renderer.test.js +16 -16
- package/esm/v1/components/v1-component-renderer.test.js.map +1 -1
- package/{dist/hooks/use-current-message.d.ts → esm/v1/hooks/use-tambo-current-message.d.ts} +30 -9
- package/esm/v1/hooks/use-tambo-current-message.d.ts.map +1 -0
- package/esm/{hooks/use-current-message.js → v1/hooks/use-tambo-current-message.js} +13 -8
- package/esm/v1/hooks/use-tambo-current-message.js.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-auth-state.d.ts +5 -5
- package/esm/v1/hooks/use-tambo-v1-auth-state.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-auth-state.js +8 -8
- package/esm/v1/hooks/use-tambo-v1-auth-state.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-auth-state.test.js +14 -14
- package/esm/v1/hooks/use-tambo-v1-auth-state.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-component-state.d.ts +7 -6
- package/esm/v1/hooks/use-tambo-v1-component-state.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-component-state.js +50 -24
- package/esm/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-component-state.test.js +62 -37
- package/esm/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-messages.d.ts +9 -9
- package/esm/v1/hooks/use-tambo-v1-messages.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-messages.js +3 -3
- package/esm/v1/hooks/use-tambo-v1-messages.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-messages.test.js +9 -9
- package/esm/v1/hooks/use-tambo-v1-messages.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-send-message.d.ts +3 -3
- package/esm/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-send-message.js +21 -23
- package/esm/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-send-message.test.js +54 -54
- 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 +5 -5
- package/esm/v1/hooks/use-tambo-v1-stream-status.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-stream-status.js +12 -14
- package/esm/v1/hooks/use-tambo-v1-stream-status.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-stream-status.test.js +21 -21
- package/esm/v1/hooks/use-tambo-v1-stream-status.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-suggestions.d.ts +7 -7
- package/esm/v1/hooks/use-tambo-v1-suggestions.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-suggestions.js +11 -11
- package/esm/v1/hooks/use-tambo-v1-suggestions.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-suggestions.test.js +48 -48
- package/esm/v1/hooks/use-tambo-v1-suggestions.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread-input.d.ts +3 -3
- package/esm/v1/hooks/use-tambo-v1-thread-input.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread-input.js +3 -3
- package/esm/v1/hooks/use-tambo-v1-thread-input.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread-input.test.js +32 -32
- 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 +4 -4
- package/esm/v1/hooks/use-tambo-v1-thread-list.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread-list.js +6 -6
- package/esm/v1/hooks/use-tambo-v1-thread-list.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread-list.test.js +15 -19
- package/esm/v1/hooks/use-tambo-v1-thread-list.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread.d.ts +3 -3
- package/esm/v1/hooks/use-tambo-v1-thread.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread.js +4 -4
- package/esm/v1/hooks/use-tambo-v1-thread.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread.test.js +6 -6
- package/esm/v1/hooks/use-tambo-v1-thread.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1.d.ts +16 -7
- package/esm/v1/hooks/use-tambo-v1.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1.js +43 -12
- package/esm/v1/hooks/use-tambo-v1.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1.test.js +178 -50
- package/esm/v1/hooks/use-tambo-v1.test.js.map +1 -1
- package/esm/v1/index.d.ts +31 -27
- package/esm/v1/index.d.ts.map +1 -1
- package/esm/v1/index.js +38 -33
- package/esm/v1/index.js.map +1 -1
- package/esm/v1/providers/tambo-v1-provider.d.ts +20 -20
- package/esm/v1/providers/tambo-v1-provider.d.ts.map +1 -1
- package/esm/v1/providers/tambo-v1-provider.js +32 -32
- package/esm/v1/providers/tambo-v1-provider.js.map +1 -1
- package/esm/v1/providers/tambo-v1-provider.test.js +23 -23
- package/esm/v1/providers/tambo-v1-provider.test.js.map +1 -1
- package/esm/v1/providers/tambo-v1-stream-context.d.ts +15 -15
- package/esm/v1/providers/tambo-v1-stream-context.d.ts.map +1 -1
- package/esm/v1/providers/tambo-v1-stream-context.js +17 -17
- package/esm/v1/providers/tambo-v1-stream-context.js.map +1 -1
- package/esm/v1/providers/tambo-v1-stream-context.test.js +10 -10
- package/esm/v1/providers/tambo-v1-stream-context.test.js.map +1 -1
- package/esm/v1/providers/tambo-v1-stub-provider.d.ts +9 -9
- package/esm/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
- package/esm/v1/providers/tambo-v1-stub-provider.js +9 -9
- package/esm/v1/providers/tambo-v1-stub-provider.js.map +1 -1
- package/esm/v1/providers/tambo-v1-stub-provider.test.js +28 -28
- package/esm/v1/providers/tambo-v1-stub-provider.test.js.map +1 -1
- package/esm/v1/providers/tambo-v1-thread-input-provider.d.ts +9 -9
- package/esm/v1/providers/tambo-v1-thread-input-provider.d.ts.map +1 -1
- package/esm/v1/providers/tambo-v1-thread-input-provider.js +15 -15
- package/esm/v1/providers/tambo-v1-thread-input-provider.js.map +1 -1
- package/esm/v1/types/auth.d.ts +2 -2
- package/esm/v1/types/auth.d.ts.map +1 -1
- package/esm/v1/types/auth.js.map +1 -1
- package/esm/v1/types/component.d.ts +3 -3
- package/esm/v1/types/component.d.ts.map +1 -1
- package/esm/v1/types/component.js +2 -2
- package/esm/v1/types/component.js.map +1 -1
- package/esm/v1/types/event.d.ts +1 -1
- package/esm/v1/types/event.js +1 -1
- package/esm/v1/types/event.js.map +1 -1
- package/esm/v1/types/message.d.ts +17 -24
- package/esm/v1/types/message.d.ts.map +1 -1
- package/esm/v1/types/message.js +1 -1
- package/esm/v1/types/message.js.map +1 -1
- package/esm/v1/types/thread.d.ts +10 -8
- package/esm/v1/types/thread.d.ts.map +1 -1
- package/esm/v1/types/thread.js +1 -1
- package/esm/v1/types/thread.js.map +1 -1
- package/esm/v1/types/tool-choice.d.ts +1 -1
- package/esm/v1/types/tool-choice.js.map +1 -1
- package/esm/v1/utils/component-renderer.d.ts +11 -5
- package/esm/v1/utils/component-renderer.d.ts.map +1 -1
- package/esm/v1/utils/component-renderer.js +13 -5
- package/esm/v1/utils/component-renderer.js.map +1 -1
- package/esm/v1/utils/component-renderer.test.js +8 -8
- package/esm/v1/utils/component-renderer.test.js.map +1 -1
- package/esm/v1/utils/event-accumulator.d.ts +13 -13
- package/esm/v1/utils/event-accumulator.d.ts.map +1 -1
- package/esm/v1/utils/event-accumulator.js +26 -15
- package/esm/v1/utils/event-accumulator.js.map +1 -1
- package/esm/v1/utils/event-accumulator.test.js +54 -19
- package/esm/v1/utils/event-accumulator.test.js.map +1 -1
- package/esm/v1/utils/registry-conversion.d.ts +18 -18
- package/esm/v1/utils/registry-conversion.js +23 -23
- package/esm/v1/utils/registry-conversion.js.map +1 -1
- package/esm/v1/utils/stream-handler.d.ts +1 -1
- package/esm/v1/utils/stream-handler.js +1 -1
- package/esm/v1/utils/stream-handler.js.map +1 -1
- package/esm/v1/utils/thread-utils.d.ts +2 -2
- package/esm/v1/utils/thread-utils.d.ts.map +1 -1
- package/esm/v1/utils/thread-utils.js.map +1 -1
- package/esm/v1/utils/tool-call-tracker.d.ts +1 -1
- package/esm/v1/utils/tool-call-tracker.js +1 -1
- package/esm/v1/utils/tool-call-tracker.js.map +1 -1
- package/esm/v1/utils/tool-executor.d.ts +1 -1
- package/esm/v1/utils/tool-executor.js +2 -2
- package/esm/v1/utils/tool-executor.js.map +1 -1
- package/package.json +4 -9
- package/dist/hooks/index.d.ts +0 -9
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/index.js +0 -34
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/use-component-state.d.ts +0 -30
- package/dist/hooks/use-component-state.d.ts.map +0 -1
- package/dist/hooks/use-component-state.js +0 -139
- package/dist/hooks/use-component-state.js.map +0 -1
- package/dist/hooks/use-component-state.test.d.ts +0 -2
- package/dist/hooks/use-component-state.test.d.ts.map +0 -1
- package/dist/hooks/use-component-state.test.js +0 -406
- package/dist/hooks/use-component-state.test.js.map +0 -1
- package/dist/hooks/use-current-message.d.ts.map +0 -1
- package/dist/hooks/use-current-message.js.map +0 -1
- package/dist/hooks/use-current-message.test.d.ts +0 -2
- package/dist/hooks/use-current-message.test.d.ts.map +0 -1
- package/dist/hooks/use-current-message.test.js +0 -269
- package/dist/hooks/use-current-message.test.js.map +0 -1
- package/dist/hooks/use-streaming-props.d.ts +0 -11
- package/dist/hooks/use-streaming-props.d.ts.map +0 -1
- package/dist/hooks/use-streaming-props.js +0 -37
- package/dist/hooks/use-streaming-props.js.map +0 -1
- package/dist/hooks/use-suggestions.d.ts +0 -46
- package/dist/hooks/use-suggestions.d.ts.map +0 -1
- package/dist/hooks/use-suggestions.js +0 -118
- package/dist/hooks/use-suggestions.js.map +0 -1
- package/dist/hooks/use-suggestions.test.d.ts +0 -2
- package/dist/hooks/use-suggestions.test.d.ts.map +0 -1
- package/dist/hooks/use-suggestions.test.js +0 -247
- package/dist/hooks/use-suggestions.test.js.map +0 -1
- package/dist/hooks/use-tambo-stream-status.d.ts +0 -90
- package/dist/hooks/use-tambo-stream-status.d.ts.map +0 -1
- package/dist/hooks/use-tambo-stream-status.js +0 -213
- package/dist/hooks/use-tambo-stream-status.js.map +0 -1
- package/dist/hooks/use-tambo-stream-status.test.d.ts +0 -2
- package/dist/hooks/use-tambo-stream-status.test.d.ts.map +0 -1
- package/dist/hooks/use-tambo-stream-status.test.js +0 -378
- package/dist/hooks/use-tambo-stream-status.test.js.map +0 -1
- package/dist/hooks/use-tambo-threads.d.ts +0 -158
- package/dist/hooks/use-tambo-threads.d.ts.map +0 -1
- package/dist/hooks/use-tambo-threads.js +0 -45
- package/dist/hooks/use-tambo-threads.js.map +0 -1
- package/dist/hooks/use-tambo-threads.test.d.ts +0 -2
- package/dist/hooks/use-tambo-threads.test.d.ts.map +0 -1
- package/dist/hooks/use-tambo-threads.test.js +0 -214
- package/dist/hooks/use-tambo-threads.test.js.map +0 -1
- package/dist/model/generate-component-response.d.ts +0 -37
- package/dist/model/generate-component-response.d.ts.map +0 -1
- package/dist/model/generate-component-response.js +0 -29
- package/dist/model/generate-component-response.js.map +0 -1
- package/dist/model/tambo-thread.d.ts +0 -15
- package/dist/model/tambo-thread.d.ts.map +0 -1
- package/dist/model/tambo-thread.js +0 -3
- package/dist/model/tambo-thread.js.map +0 -1
- package/dist/providers/__tests__/thread-input-resource-resolution.test.d.ts +0 -2
- package/dist/providers/__tests__/thread-input-resource-resolution.test.d.ts.map +0 -1
- package/dist/providers/__tests__/thread-input-resource-resolution.test.js +0 -592
- package/dist/providers/__tests__/thread-input-resource-resolution.test.js.map +0 -1
- package/dist/providers/index.d.ts +0 -13
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js +0 -41
- package/dist/providers/index.js.map +0 -1
- package/dist/providers/tambo-component-provider.d.ts +0 -23
- package/dist/providers/tambo-component-provider.d.ts.map +0 -1
- package/dist/providers/tambo-component-provider.js +0 -88
- package/dist/providers/tambo-component-provider.js.map +0 -1
- package/dist/providers/tambo-prop-stream-provider/index.d.ts +0 -19
- package/dist/providers/tambo-prop-stream-provider/index.d.ts.map +0 -1
- package/dist/providers/tambo-prop-stream-provider/index.js +0 -43
- package/dist/providers/tambo-prop-stream-provider/index.js.map +0 -1
- package/dist/providers/tambo-prop-stream-provider/pending.d.ts +0 -12
- package/dist/providers/tambo-prop-stream-provider/pending.d.ts.map +0 -1
- package/dist/providers/tambo-prop-stream-provider/pending.js +0 -31
- package/dist/providers/tambo-prop-stream-provider/pending.js.map +0 -1
- package/dist/providers/tambo-prop-stream-provider/provider.d.ts +0 -17
- package/dist/providers/tambo-prop-stream-provider/provider.d.ts.map +0 -1
- package/dist/providers/tambo-prop-stream-provider/provider.js +0 -107
- package/dist/providers/tambo-prop-stream-provider/provider.js.map +0 -1
- package/dist/providers/tambo-prop-stream-provider/streaming.d.ts +0 -12
- package/dist/providers/tambo-prop-stream-provider/streaming.d.ts.map +0 -1
- package/dist/providers/tambo-prop-stream-provider/streaming.js +0 -28
- package/dist/providers/tambo-prop-stream-provider/streaming.js.map +0 -1
- package/dist/providers/tambo-prop-stream-provider/success.d.ts +0 -12
- package/dist/providers/tambo-prop-stream-provider/success.d.ts.map +0 -1
- package/dist/providers/tambo-prop-stream-provider/success.js +0 -28
- package/dist/providers/tambo-prop-stream-provider/success.js.map +0 -1
- package/dist/providers/tambo-prop-stream-provider/types.d.ts +0 -25
- package/dist/providers/tambo-prop-stream-provider/types.d.ts.map +0 -1
- package/dist/providers/tambo-prop-stream-provider/types.js +0 -6
- package/dist/providers/tambo-prop-stream-provider/types.js.map +0 -1
- package/dist/providers/tambo-prop-stream-provider.test.d.ts +0 -2
- package/dist/providers/tambo-prop-stream-provider.test.d.ts.map +0 -1
- package/dist/providers/tambo-prop-stream-provider.test.js +0 -275
- package/dist/providers/tambo-prop-stream-provider.test.js.map +0 -1
- package/dist/providers/tambo-provider.d.ts +0 -53
- package/dist/providers/tambo-provider.d.ts.map +0 -1
- package/dist/providers/tambo-provider.js +0 -133
- package/dist/providers/tambo-provider.js.map +0 -1
- package/dist/providers/tambo-stubs.d.ts +0 -89
- package/dist/providers/tambo-stubs.d.ts.map +0 -1
- package/dist/providers/tambo-stubs.js +0 -279
- package/dist/providers/tambo-stubs.js.map +0 -1
- package/dist/providers/tambo-stubs.test.d.ts +0 -2
- package/dist/providers/tambo-stubs.test.d.ts.map +0 -1
- package/dist/providers/tambo-stubs.test.js +0 -97
- package/dist/providers/tambo-stubs.test.js.map +0 -1
- package/dist/providers/tambo-thread-input-provider.d.ts +0 -65
- package/dist/providers/tambo-thread-input-provider.d.ts.map +0 -1
- package/dist/providers/tambo-thread-input-provider.js +0 -179
- package/dist/providers/tambo-thread-input-provider.js.map +0 -1
- package/dist/providers/tambo-thread-provider-initial-messages.test.d.ts +0 -2
- package/dist/providers/tambo-thread-provider-initial-messages.test.d.ts.map +0 -1
- package/dist/providers/tambo-thread-provider-initial-messages.test.js +0 -278
- package/dist/providers/tambo-thread-provider-initial-messages.test.js.map +0 -1
- package/dist/providers/tambo-thread-provider.d.ts +0 -126
- package/dist/providers/tambo-thread-provider.d.ts.map +0 -1
- package/dist/providers/tambo-thread-provider.js +0 -931
- package/dist/providers/tambo-thread-provider.js.map +0 -1
- package/dist/providers/tambo-thread-provider.test.d.ts +0 -2
- package/dist/providers/tambo-thread-provider.test.d.ts.map +0 -1
- package/dist/providers/tambo-thread-provider.test.js +0 -1591
- package/dist/providers/tambo-thread-provider.test.js.map +0 -1
- package/dist/util/generate-component.d.ts +0 -12
- package/dist/util/generate-component.d.ts.map +0 -1
- package/dist/util/generate-component.js +0 -58
- package/dist/util/generate-component.js.map +0 -1
- package/dist/util/generate-component.test.d.ts +0 -2
- package/dist/util/generate-component.test.d.ts.map +0 -1
- package/dist/util/generate-component.test.js +0 -340
- package/dist/util/generate-component.test.js.map +0 -1
- package/esm/hooks/index.d.ts +0 -9
- package/esm/hooks/index.d.ts.map +0 -1
- package/esm/hooks/index.js +0 -10
- package/esm/hooks/index.js.map +0 -1
- package/esm/hooks/use-component-state.d.ts +0 -30
- package/esm/hooks/use-component-state.d.ts.map +0 -1
- package/esm/hooks/use-component-state.js +0 -136
- package/esm/hooks/use-component-state.js.map +0 -1
- package/esm/hooks/use-component-state.test.d.ts +0 -2
- package/esm/hooks/use-component-state.test.d.ts.map +0 -1
- package/esm/hooks/use-component-state.test.js +0 -401
- package/esm/hooks/use-component-state.test.js.map +0 -1
- package/esm/hooks/use-current-message.d.ts.map +0 -1
- package/esm/hooks/use-current-message.js.map +0 -1
- package/esm/hooks/use-current-message.test.d.ts +0 -2
- package/esm/hooks/use-current-message.test.d.ts.map +0 -1
- package/esm/hooks/use-current-message.test.js +0 -264
- package/esm/hooks/use-current-message.test.js.map +0 -1
- package/esm/hooks/use-streaming-props.d.ts +0 -11
- package/esm/hooks/use-streaming-props.d.ts.map +0 -1
- package/esm/hooks/use-streaming-props.js +0 -34
- package/esm/hooks/use-streaming-props.js.map +0 -1
- package/esm/hooks/use-suggestions.d.ts +0 -46
- package/esm/hooks/use-suggestions.d.ts.map +0 -1
- package/esm/hooks/use-suggestions.js +0 -115
- package/esm/hooks/use-suggestions.js.map +0 -1
- package/esm/hooks/use-suggestions.test.d.ts +0 -2
- package/esm/hooks/use-suggestions.test.d.ts.map +0 -1
- package/esm/hooks/use-suggestions.test.js +0 -245
- package/esm/hooks/use-suggestions.test.js.map +0 -1
- package/esm/hooks/use-tambo-stream-status.d.ts +0 -90
- package/esm/hooks/use-tambo-stream-status.d.ts.map +0 -1
- package/esm/hooks/use-tambo-stream-status.js +0 -210
- package/esm/hooks/use-tambo-stream-status.js.map +0 -1
- package/esm/hooks/use-tambo-stream-status.test.d.ts +0 -2
- package/esm/hooks/use-tambo-stream-status.test.d.ts.map +0 -1
- package/esm/hooks/use-tambo-stream-status.test.js +0 -376
- package/esm/hooks/use-tambo-stream-status.test.js.map +0 -1
- package/esm/hooks/use-tambo-threads.d.ts +0 -158
- package/esm/hooks/use-tambo-threads.d.ts.map +0 -1
- package/esm/hooks/use-tambo-threads.js +0 -42
- package/esm/hooks/use-tambo-threads.js.map +0 -1
- package/esm/hooks/use-tambo-threads.test.d.ts +0 -2
- package/esm/hooks/use-tambo-threads.test.d.ts.map +0 -1
- package/esm/hooks/use-tambo-threads.test.js +0 -212
- package/esm/hooks/use-tambo-threads.test.js.map +0 -1
- package/esm/model/generate-component-response.d.ts +0 -37
- package/esm/model/generate-component-response.d.ts.map +0 -1
- package/esm/model/generate-component-response.js +0 -25
- package/esm/model/generate-component-response.js.map +0 -1
- package/esm/model/tambo-thread.d.ts +0 -15
- package/esm/model/tambo-thread.d.ts.map +0 -1
- package/esm/model/tambo-thread.js +0 -2
- package/esm/model/tambo-thread.js.map +0 -1
- package/esm/providers/__tests__/thread-input-resource-resolution.test.d.ts +0 -2
- package/esm/providers/__tests__/thread-input-resource-resolution.test.d.ts.map +0 -1
- package/esm/providers/__tests__/thread-input-resource-resolution.test.js +0 -587
- package/esm/providers/__tests__/thread-input-resource-resolution.test.js.map +0 -1
- package/esm/providers/index.d.ts +0 -13
- package/esm/providers/index.d.ts.map +0 -1
- package/esm/providers/index.js +0 -11
- package/esm/providers/index.js.map +0 -1
- package/esm/providers/tambo-component-provider.d.ts +0 -23
- package/esm/providers/tambo-component-provider.d.ts.map +0 -1
- package/esm/providers/tambo-component-provider.js +0 -50
- package/esm/providers/tambo-component-provider.js.map +0 -1
- package/esm/providers/tambo-prop-stream-provider/index.d.ts +0 -19
- package/esm/providers/tambo-prop-stream-provider/index.d.ts.map +0 -1
- package/esm/providers/tambo-prop-stream-provider/index.js +0 -22
- package/esm/providers/tambo-prop-stream-provider/index.js.map +0 -1
- package/esm/providers/tambo-prop-stream-provider/pending.d.ts +0 -12
- package/esm/providers/tambo-prop-stream-provider/pending.d.ts.map +0 -1
- package/esm/providers/tambo-prop-stream-provider/pending.js +0 -24
- package/esm/providers/tambo-prop-stream-provider/pending.js.map +0 -1
- package/esm/providers/tambo-prop-stream-provider/provider.d.ts +0 -17
- package/esm/providers/tambo-prop-stream-provider/provider.d.ts.map +0 -1
- package/esm/providers/tambo-prop-stream-provider/provider.js +0 -70
- package/esm/providers/tambo-prop-stream-provider/provider.js.map +0 -1
- package/esm/providers/tambo-prop-stream-provider/streaming.d.ts +0 -12
- package/esm/providers/tambo-prop-stream-provider/streaming.d.ts.map +0 -1
- package/esm/providers/tambo-prop-stream-provider/streaming.js +0 -21
- package/esm/providers/tambo-prop-stream-provider/streaming.js.map +0 -1
- package/esm/providers/tambo-prop-stream-provider/success.d.ts +0 -12
- package/esm/providers/tambo-prop-stream-provider/success.d.ts.map +0 -1
- package/esm/providers/tambo-prop-stream-provider/success.js +0 -21
- package/esm/providers/tambo-prop-stream-provider/success.js.map +0 -1
- package/esm/providers/tambo-prop-stream-provider/types.d.ts +0 -25
- package/esm/providers/tambo-prop-stream-provider/types.d.ts.map +0 -1
- package/esm/providers/tambo-prop-stream-provider/types.js +0 -3
- package/esm/providers/tambo-prop-stream-provider/types.js.map +0 -1
- package/esm/providers/tambo-prop-stream-provider.test.d.ts +0 -2
- package/esm/providers/tambo-prop-stream-provider.test.d.ts.map +0 -1
- package/esm/providers/tambo-prop-stream-provider.test.js +0 -270
- package/esm/providers/tambo-prop-stream-provider.test.js.map +0 -1
- package/esm/providers/tambo-provider.d.ts +0 -53
- package/esm/providers/tambo-provider.d.ts.map +0 -1
- package/esm/providers/tambo-provider.js +0 -94
- package/esm/providers/tambo-provider.js.map +0 -1
- package/esm/providers/tambo-stubs.d.ts +0 -89
- package/esm/providers/tambo-stubs.d.ts.map +0 -1
- package/esm/providers/tambo-stubs.js +0 -242
- package/esm/providers/tambo-stubs.js.map +0 -1
- package/esm/providers/tambo-stubs.test.d.ts +0 -2
- package/esm/providers/tambo-stubs.test.d.ts.map +0 -1
- package/esm/providers/tambo-stubs.test.js +0 -62
- package/esm/providers/tambo-stubs.test.js.map +0 -1
- package/esm/providers/tambo-thread-input-provider.d.ts +0 -65
- package/esm/providers/tambo-thread-input-provider.d.ts.map +0 -1
- package/esm/providers/tambo-thread-input-provider.js +0 -141
- package/esm/providers/tambo-thread-input-provider.js.map +0 -1
- package/esm/providers/tambo-thread-provider-initial-messages.test.d.ts +0 -2
- package/esm/providers/tambo-thread-provider-initial-messages.test.d.ts.map +0 -1
- package/esm/providers/tambo-thread-provider-initial-messages.test.js +0 -273
- package/esm/providers/tambo-thread-provider-initial-messages.test.js.map +0 -1
- package/esm/providers/tambo-thread-provider.d.ts +0 -126
- package/esm/providers/tambo-thread-provider.d.ts.map +0 -1
- package/esm/providers/tambo-thread-provider.js +0 -891
- package/esm/providers/tambo-thread-provider.js.map +0 -1
- package/esm/providers/tambo-thread-provider.test.d.ts +0 -2
- package/esm/providers/tambo-thread-provider.test.d.ts.map +0 -1
- package/esm/providers/tambo-thread-provider.test.js +0 -1553
- package/esm/providers/tambo-thread-provider.test.js.map +0 -1
- package/esm/util/generate-component.d.ts +0 -12
- package/esm/util/generate-component.d.ts.map +0 -1
- package/esm/util/generate-component.js +0 -52
- package/esm/util/generate-component.js.map +0 -1
- package/esm/util/generate-component.test.d.ts +0 -2
- package/esm/util/generate-component.test.d.ts.map +0 -1
- package/esm/util/generate-component.test.js +0 -302
- package/esm/util/generate-component.test.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* TamboThreadInputProvider - Shared Thread Input Context
|
|
3
3
|
*
|
|
4
4
|
* Provides shared input state across all components, enabling features like
|
|
5
5
|
* suggestions to update the input field directly.
|
|
6
6
|
*
|
|
7
|
-
* This mirrors the beta SDK
|
|
7
|
+
* This mirrors the TamboThreadInputProvider pattern from the legacy beta SDK.
|
|
8
8
|
*/
|
|
9
9
|
import React, { type PropsWithChildren } from "react";
|
|
10
10
|
import { type StagedImage } from "../../hooks/use-message-images.js";
|
|
@@ -34,7 +34,7 @@ export interface SubmitOptions {
|
|
|
34
34
|
/**
|
|
35
35
|
* Context props for thread input state
|
|
36
36
|
*/
|
|
37
|
-
export interface
|
|
37
|
+
export interface TamboThreadInputContextProps extends Omit<UseTamboMutationResult<{
|
|
38
38
|
threadId: string | undefined;
|
|
39
39
|
}, Error, SubmitOptions | undefined>, "mutate" | "mutateAsync"> {
|
|
40
40
|
/** Current value of the input field */
|
|
@@ -71,28 +71,28 @@ export interface TamboV1ThreadInputContextProps extends Omit<UseTamboMutationRes
|
|
|
71
71
|
* Context for thread input state.
|
|
72
72
|
* @internal
|
|
73
73
|
*/
|
|
74
|
-
export declare const
|
|
74
|
+
export declare const TamboThreadInputContext: React.Context<TamboThreadInputContextProps | undefined>;
|
|
75
75
|
/**
|
|
76
76
|
* Provider that manages shared thread input state across all components.
|
|
77
77
|
*
|
|
78
|
-
* This ensures that
|
|
78
|
+
* This ensures that useTamboThreadInput, useTamboSuggestions, and other components
|
|
79
79
|
* all share the same input state.
|
|
80
80
|
* @param props - Provider props
|
|
81
81
|
* @param props.children - Child components
|
|
82
82
|
* @returns Thread input context provider
|
|
83
83
|
*/
|
|
84
|
-
export declare function
|
|
84
|
+
export declare function TamboThreadInputProvider({ children }: PropsWithChildren): React.JSX.Element;
|
|
85
85
|
/**
|
|
86
86
|
* Hook to access the shared thread input state.
|
|
87
87
|
*
|
|
88
88
|
* All components using this hook share the same input state, enabling
|
|
89
89
|
* features like suggestions to update the input field directly.
|
|
90
90
|
* @returns The shared thread input context
|
|
91
|
-
* @throws {Error} If used outside
|
|
91
|
+
* @throws {Error} If used outside TamboThreadInputProvider
|
|
92
92
|
* @example
|
|
93
93
|
* ```tsx
|
|
94
94
|
* function ChatInput() {
|
|
95
|
-
* const { value, setValue, submit, isPending } =
|
|
95
|
+
* const { value, setValue, submit, isPending } = useTamboThreadInput();
|
|
96
96
|
*
|
|
97
97
|
* return (
|
|
98
98
|
* <form onSubmit={(e) => { e.preventDefault(); submit(); }}>
|
|
@@ -107,5 +107,5 @@ export declare function TamboV1ThreadInputProvider({ children }: PropsWithChildr
|
|
|
107
107
|
* }
|
|
108
108
|
* ```
|
|
109
109
|
*/
|
|
110
|
-
export declare function
|
|
110
|
+
export declare function useTamboThreadInput(): TamboThreadInputContextProps;
|
|
111
111
|
//# sourceMappingURL=tambo-v1-thread-input-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-v1-thread-input-provider.d.ts","sourceRoot":"","sources":["../../../src/v1/providers/tambo-v1-thread-input-provider.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,EAKZ,KAAK,iBAAiB,EACvB,MAAM,OAAO,CAAC;AACf,OAAO,EAEL,KAAK,WAAW,EACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,+BAA+B,CAAC;AAGvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AASvD,eAAO,MAAM,oBAAoB;;;CAGvB,CAAC;AAkCX;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"tambo-v1-thread-input-provider.d.ts","sourceRoot":"","sources":["../../../src/v1/providers/tambo-v1-thread-input-provider.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,EAKZ,KAAK,iBAAiB,EACvB,MAAM,OAAO,CAAC;AACf,OAAO,EAEL,KAAK,WAAW,EACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,+BAA+B,CAAC;AAGvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AASvD,eAAO,MAAM,oBAAoB;;;CAGvB,CAAC;AAkCX;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CACxD,sBAAsB,CACpB;IAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,EAChC,KAAK,EACL,aAAa,GAAG,SAAS,CAC1B,EACD,QAAQ,GAAG,aAAa,CACzB;IACC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAEvD;;;;OAIG;IACH,MAAM,EAAE,CACN,OAAO,CAAC,EAAE,aAAa,KACpB,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC,CAAC;IAE/C,8BAA8B;IAC9B,MAAM,EAAE,WAAW,EAAE,CAAC;IAEtB,yBAAyB;IACzB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAExC,0BAA0B;IAC1B,SAAS,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5C,4BAA4B;IAC5B,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAElC,8BAA8B;IAC9B,WAAW,EAAE,MAAM,IAAI,CAAC;IAExB,iEAAiE;IACjE,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAE7B,qFAAqF;IACrF,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,yDAExB,CAAC;AAEb;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,QAAQ,EAAE,EAAE,iBAAiB,qBAgGvE;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,IAAI,4BAA4B,CAQlE"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* TamboThreadInputProvider - Shared Thread Input Context
|
|
4
4
|
*
|
|
5
5
|
* Provides shared input state across all components, enabling features like
|
|
6
6
|
* suggestions to update the input field directly.
|
|
7
7
|
*
|
|
8
|
-
* This mirrors the beta SDK
|
|
8
|
+
* This mirrors the TamboThreadInputProvider pattern from the legacy beta SDK.
|
|
9
9
|
*/
|
|
10
10
|
import React, { createContext, useCallback, useContext, useState, } from "react";
|
|
11
11
|
import { useMessageImages, } from "../../hooks/use-message-images.js";
|
|
12
12
|
import { useTamboMutation, } from "../../hooks/react-query-hooks.js";
|
|
13
|
-
import {
|
|
13
|
+
import { useTamboSendMessage } from "../hooks/use-tambo-v1-send-message.js";
|
|
14
14
|
import { isPlaceholderThreadId } from "../utils/event-accumulator.js";
|
|
15
|
-
import {
|
|
15
|
+
import { useTamboAuthState } from "../hooks/use-tambo-v1-auth-state.js";
|
|
16
16
|
import { useStreamDispatch, useStreamState } from "./tambo-v1-stream-context.js";
|
|
17
17
|
// Error messages for various input-related error scenarios.
|
|
18
18
|
// TODO: Reintroduce explicit `NETWORK` and `SERVER` keys once `submit()` maps
|
|
@@ -51,27 +51,27 @@ function stagedImageToResourceContent(image) {
|
|
|
51
51
|
* Context for thread input state.
|
|
52
52
|
* @internal
|
|
53
53
|
*/
|
|
54
|
-
export const
|
|
54
|
+
export const TamboThreadInputContext = createContext(undefined);
|
|
55
55
|
/**
|
|
56
56
|
* Provider that manages shared thread input state across all components.
|
|
57
57
|
*
|
|
58
|
-
* This ensures that
|
|
58
|
+
* This ensures that useTamboThreadInput, useTamboSuggestions, and other components
|
|
59
59
|
* all share the same input state.
|
|
60
60
|
* @param props - Provider props
|
|
61
61
|
* @param props.children - Child components
|
|
62
62
|
* @returns Thread input context provider
|
|
63
63
|
*/
|
|
64
|
-
export function
|
|
64
|
+
export function TamboThreadInputProvider({ children }) {
|
|
65
65
|
const [inputValue, setInputValue] = useState("");
|
|
66
66
|
const imageState = useMessageImages();
|
|
67
67
|
const streamState = useStreamState();
|
|
68
68
|
const dispatch = useStreamDispatch();
|
|
69
|
-
const authState =
|
|
69
|
+
const authState = useTamboAuthState();
|
|
70
70
|
// Use the current thread from stream state directly
|
|
71
71
|
// Placeholder ID indicates a new thread should be created
|
|
72
72
|
const currentThreadId = streamState.currentThreadId ?? undefined;
|
|
73
73
|
const isNewThread = isPlaceholderThreadId(currentThreadId);
|
|
74
|
-
const sendMessage =
|
|
74
|
+
const sendMessage = useTamboSendMessage(currentThreadId);
|
|
75
75
|
const isIdentified = authState.status === "identified";
|
|
76
76
|
const submitFn = useCallback(async (options) => {
|
|
77
77
|
if (!isIdentified) {
|
|
@@ -127,7 +127,7 @@ export function TamboV1ThreadInputProvider({ children }) {
|
|
|
127
127
|
threadId: currentThreadId,
|
|
128
128
|
isDisabled: mutationState.isPending || !isIdentified,
|
|
129
129
|
};
|
|
130
|
-
return (React.createElement(
|
|
130
|
+
return (React.createElement(TamboThreadInputContext.Provider, { value: contextValue }, children));
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
133
|
* Hook to access the shared thread input state.
|
|
@@ -135,11 +135,11 @@ export function TamboV1ThreadInputProvider({ children }) {
|
|
|
135
135
|
* All components using this hook share the same input state, enabling
|
|
136
136
|
* features like suggestions to update the input field directly.
|
|
137
137
|
* @returns The shared thread input context
|
|
138
|
-
* @throws {Error} If used outside
|
|
138
|
+
* @throws {Error} If used outside TamboThreadInputProvider
|
|
139
139
|
* @example
|
|
140
140
|
* ```tsx
|
|
141
141
|
* function ChatInput() {
|
|
142
|
-
* const { value, setValue, submit, isPending } =
|
|
142
|
+
* const { value, setValue, submit, isPending } = useTamboThreadInput();
|
|
143
143
|
*
|
|
144
144
|
* return (
|
|
145
145
|
* <form onSubmit={(e) => { e.preventDefault(); submit(); }}>
|
|
@@ -154,10 +154,10 @@ export function TamboV1ThreadInputProvider({ children }) {
|
|
|
154
154
|
* }
|
|
155
155
|
* ```
|
|
156
156
|
*/
|
|
157
|
-
export function
|
|
158
|
-
const context = useContext(
|
|
157
|
+
export function useTamboThreadInput() {
|
|
158
|
+
const context = useContext(TamboThreadInputContext);
|
|
159
159
|
if (!context) {
|
|
160
|
-
throw new Error("
|
|
160
|
+
throw new Error("useTamboThreadInput must be used within TamboThreadInputProvider");
|
|
161
161
|
}
|
|
162
162
|
return context;
|
|
163
163
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-v1-thread-input-provider.js","sourceRoot":"","sources":["../../../src/v1/providers/tambo-v1-thread-input-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,EACZ,aAAa,EACb,WAAW,EACX,UAAU,EACV,QAAQ,GAET,MAAM,OAAO,CAAC;AACf,OAAO,EACL,gBAAgB,GAEjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,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AC,iBAAiB,EAAE,eAAe,CAAC;QACjD,UAAU,EAAE,QAAQ;KACrB,CAAC,CAAC;IAEH,MAAM,YAAY,GAAmC;QACnD,GAAG,aAAa;QAChB,KAAK,EAAE,UAAU;QACjB,QAAQ,EAAE,aAAa;QACvB,MAAM,EAAE,WAAW;QACnB,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,QAAQ,EAAE,eAAe;QACzB,UAAU,EAAE,aAAa,CAAC,SAAS,IAAI,CAAC,YAAY;KACrD,CAAC;IAEF,OAAO,CACL,oBAAC,yBAAyB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,IACpD,QAAQ,CAC0B,CACtC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,OAAO,GAAG,UAAU,CAAC,yBAAyB,CAAC,CAAC;IACtD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,sEAAsE,CACvE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["\"use client\";\n\n/**\n * TamboV1ThreadInputProvider - Shared Thread Input Context for v1 API\n *\n * Provides shared input state across all components, enabling features like\n * suggestions to update the input field directly.\n *\n * This mirrors the beta SDK's TamboThreadInputProvider pattern.\n */\n\nimport React, {\n createContext,\n useCallback,\n useContext,\n useState,\n type PropsWithChildren,\n} from \"react\";\nimport {\n useMessageImages,\n type StagedImage,\n} from \"../../hooks/use-message-images\";\nimport {\n useTamboMutation,\n type UseTamboMutationResult,\n} from \"../../hooks/react-query-hooks\";\nimport { useTamboV1SendMessage } from \"../hooks/use-tambo-v1-send-message\";\nimport type { InputMessage } from \"../types/message\";\nimport type { ToolChoice } from \"../types/tool-choice\";\nimport { isPlaceholderThreadId } from \"../utils/event-accumulator\";\nimport { useTamboV1AuthState } from \"../hooks/use-tambo-v1-auth-state\";\nimport { useStreamDispatch, useStreamState } from \"./tambo-v1-stream-context\";\n\n// Error messages for various input-related error scenarios.\n// TODO: Reintroduce explicit `NETWORK` and `SERVER` keys once `submit()` maps\n// failures into a small, stable set of user-facing error codes (at minimum:\n// connectivity failures vs non-2xx responses).\nexport const INPUT_ERROR_MESSAGES = {\n EMPTY: \"Message cannot be empty\",\n VALIDATION: \"Invalid message format\",\n} as const;\n\nfunction stagedImageToResourceContent(\n image: StagedImage,\n): InputMessage[\"content\"][number] {\n if (!image.dataUrl.startsWith(\"data:\")) {\n throw new Error(INPUT_ERROR_MESSAGES.VALIDATION);\n }\n\n const commaIndex = image.dataUrl.indexOf(\",\");\n if (commaIndex === -1) {\n throw new Error(INPUT_ERROR_MESSAGES.VALIDATION);\n }\n\n const header = image.dataUrl.slice(\"data:\".length, commaIndex);\n const [mimeType, ...params] = header.split(\";\");\n const isBase64 = params.includes(\"base64\");\n\n if (mimeType !== image.type || !isBase64) {\n throw new Error(INPUT_ERROR_MESSAGES.VALIDATION);\n }\n\n return {\n type: \"resource\",\n resource: {\n name: image.name,\n mimeType: image.type,\n // Shared.Resource.blob expects base64-encoded data; this is the base64\n // payload from the `data:` URL.\n blob: image.dataUrl.slice(commaIndex + 1),\n },\n };\n}\n\n/**\n * Options for submitting a message\n */\nexport interface SubmitOptions {\n /**\n * Enable debug logging for the stream\n */\n debug?: boolean;\n\n /**\n * How the model should use tools. Defaults to \"auto\".\n * - \"auto\": Model decides whether to use tools\n * - \"required\": Model must use at least one tool\n * - \"none\": Model cannot use tools\n * - { name: \"toolName\" }: Model must use the specified tool\n */\n toolChoice?: ToolChoice;\n}\n\n/**\n * Context props for thread input state\n */\nexport interface TamboV1ThreadInputContextProps extends Omit<\n UseTamboMutationResult<\n { threadId: string | undefined },\n Error,\n SubmitOptions | undefined\n >,\n \"mutate\" | \"mutateAsync\"\n> {\n /** Current value of the input field */\n value: string;\n\n /**\n * Function to update the input value\n * @param value - New value for the input field\n */\n setValue: React.Dispatch<React.SetStateAction<string>>;\n\n /**\n * Function to submit the current input value\n * @param options - Submission options\n * @returns Promise with the threadId\n */\n submit: (\n options?: SubmitOptions,\n ) => Promise<{ threadId: string | undefined }>;\n\n /** Currently staged images */\n images: StagedImage[];\n\n /** Add a single image */\n addImage: (file: File) => Promise<void>;\n\n /** Add multiple images */\n addImages: (files: File[]) => Promise<void>;\n\n /** Remove an image by id */\n removeImage: (id: string) => void;\n\n /** Clear all staged images */\n clearImages: () => void;\n\n /** Current thread ID being used for input (from stream state) */\n threadId: string | undefined;\n\n /** Whether the input should be disabled (pending submission or not authenticated) */\n isDisabled: boolean;\n}\n\n/**\n * Context for thread input state.\n * @internal\n */\nexport const TamboV1ThreadInputContext = createContext<\n TamboV1ThreadInputContextProps | undefined\n>(undefined);\n\n/**\n * Provider that manages shared thread input state across all components.\n *\n * This ensures that useTamboV1ThreadInput, useTamboV1Suggestions, and other components\n * all share the same input state.\n * @param props - Provider props\n * @param props.children - Child components\n * @returns Thread input context provider\n */\nexport function TamboV1ThreadInputProvider({ children }: PropsWithChildren) {\n const [inputValue, setInputValue] = useState(\"\");\n const imageState = useMessageImages();\n const streamState = useStreamState();\n const dispatch = useStreamDispatch();\n const authState = useTamboV1AuthState();\n\n // Use the current thread from stream state directly\n // Placeholder ID indicates a new thread should be created\n const currentThreadId = streamState.currentThreadId ?? undefined;\n const isNewThread = isPlaceholderThreadId(currentThreadId);\n const sendMessage = useTamboV1SendMessage(currentThreadId);\n\n const isIdentified = authState.status === \"identified\";\n\n const submitFn = useCallback(\n async (\n options?: SubmitOptions,\n ): Promise<{ threadId: string | undefined }> => {\n if (!isIdentified) {\n throw new Error(\n \"Cannot submit: authentication is not ready. \" +\n \"Ensure a valid userKey or userToken is provided.\",\n );\n }\n\n const trimmedValue = inputValue.trim();\n\n // Check if we have content to send\n if (!trimmedValue && imageState.images.length === 0) {\n throw new Error(INPUT_ERROR_MESSAGES.EMPTY);\n }\n\n const content: InputMessage[\"content\"] = [];\n\n if (trimmedValue) {\n content.push({ type: \"text\", text: trimmedValue });\n }\n\n for (const image of imageState.images) {\n content.push(stagedImageToResourceContent(image));\n }\n\n const result = await sendMessage.mutateAsync({\n message: {\n role: \"user\",\n content,\n },\n userMessageText: trimmedValue, // Pass text for optimistic display\n debug: options?.debug,\n toolChoice: options?.toolChoice,\n });\n\n // Clear input and images after successful submission\n setInputValue(\"\");\n imageState.clearImages();\n\n // Update stream context's currentThreadId if a new thread was created\n if (result.threadId && isNewThread) {\n dispatch({ type: \"SET_CURRENT_THREAD\", threadId: result.threadId });\n }\n\n return result;\n },\n // `stagedImageToResourceContent` is a pure module-level helper (not a hook value).\n [inputValue, imageState, sendMessage, isNewThread, dispatch, isIdentified],\n );\n\n const {\n mutateAsync: submitAsync,\n mutate: _unusedSubmit,\n ...mutationState\n } = useTamboMutation({\n mutationKey: [\"v1-thread-input\", currentThreadId],\n mutationFn: submitFn,\n });\n\n const contextValue: TamboV1ThreadInputContextProps = {\n ...mutationState,\n value: inputValue,\n setValue: setInputValue,\n submit: submitAsync,\n images: imageState.images,\n addImage: imageState.addImage,\n addImages: imageState.addImages,\n removeImage: imageState.removeImage,\n clearImages: imageState.clearImages,\n threadId: currentThreadId,\n isDisabled: mutationState.isPending || !isIdentified,\n };\n\n return (\n <TamboV1ThreadInputContext.Provider value={contextValue}>\n {children}\n </TamboV1ThreadInputContext.Provider>\n );\n}\n\n/**\n * Hook to access the shared thread input state.\n *\n * All components using this hook share the same input state, enabling\n * features like suggestions to update the input field directly.\n * @returns The shared thread input context\n * @throws {Error} If used outside TamboV1ThreadInputProvider\n * @example\n * ```tsx\n * function ChatInput() {\n * const { value, setValue, submit, isPending } = useTamboV1ThreadInput();\n *\n * return (\n * <form onSubmit={(e) => { e.preventDefault(); submit(); }}>\n * <input\n * value={value}\n * onChange={(e) => setValue(e.target.value)}\n * disabled={isPending}\n * />\n * <button type=\"submit\" disabled={isPending}>Send</button>\n * </form>\n * );\n * }\n * ```\n */\nexport function useTamboV1ThreadInput(): TamboV1ThreadInputContextProps {\n const context = useContext(TamboV1ThreadInputContext);\n if (!context) {\n throw new Error(\n \"useTamboV1ThreadInput must be used within TamboV1ThreadInputProvider\",\n );\n }\n return context;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tambo-v1-thread-input-provider.js","sourceRoot":"","sources":["../../../src/v1/providers/tambo-v1-thread-input-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,EACZ,aAAa,EACb,WAAW,EACX,UAAU,EACV,QAAQ,GAET,MAAM,OAAO,CAAC;AACf,OAAO,EACL,gBAAgB,GAEjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,gBAAgB,GAEjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAGzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE9E,4DAA4D;AAC5D,8EAA8E;AAC9E,4EAA4E;AAC5E,+CAA+C;AAC/C,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,KAAK,EAAE,yBAAyB;IAChC,UAAU,EAAE,wBAAwB;CAC5B,CAAC;AAEX,SAAS,4BAA4B,CACnC,KAAkB;IAElB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAA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AC,uBAAuB,CAAC,CAAC;IACpD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,kEAAkE,CACnE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["\"use client\";\n\n/**\n * TamboThreadInputProvider - Shared Thread Input Context\n *\n * Provides shared input state across all components, enabling features like\n * suggestions to update the input field directly.\n *\n * This mirrors the TamboThreadInputProvider pattern from the legacy beta SDK.\n */\n\nimport React, {\n createContext,\n useCallback,\n useContext,\n useState,\n type PropsWithChildren,\n} from \"react\";\nimport {\n useMessageImages,\n type StagedImage,\n} from \"../../hooks/use-message-images\";\nimport {\n useTamboMutation,\n type UseTamboMutationResult,\n} from \"../../hooks/react-query-hooks\";\nimport { useTamboSendMessage } from \"../hooks/use-tambo-v1-send-message\";\nimport type { InputMessage } from \"../types/message\";\nimport type { ToolChoice } from \"../types/tool-choice\";\nimport { isPlaceholderThreadId } from \"../utils/event-accumulator\";\nimport { useTamboAuthState } from \"../hooks/use-tambo-v1-auth-state\";\nimport { useStreamDispatch, useStreamState } from \"./tambo-v1-stream-context\";\n\n// Error messages for various input-related error scenarios.\n// TODO: Reintroduce explicit `NETWORK` and `SERVER` keys once `submit()` maps\n// failures into a small, stable set of user-facing error codes (at minimum:\n// connectivity failures vs non-2xx responses).\nexport const INPUT_ERROR_MESSAGES = {\n EMPTY: \"Message cannot be empty\",\n VALIDATION: \"Invalid message format\",\n} as const;\n\nfunction stagedImageToResourceContent(\n image: StagedImage,\n): InputMessage[\"content\"][number] {\n if (!image.dataUrl.startsWith(\"data:\")) {\n throw new Error(INPUT_ERROR_MESSAGES.VALIDATION);\n }\n\n const commaIndex = image.dataUrl.indexOf(\",\");\n if (commaIndex === -1) {\n throw new Error(INPUT_ERROR_MESSAGES.VALIDATION);\n }\n\n const header = image.dataUrl.slice(\"data:\".length, commaIndex);\n const [mimeType, ...params] = header.split(\";\");\n const isBase64 = params.includes(\"base64\");\n\n if (mimeType !== image.type || !isBase64) {\n throw new Error(INPUT_ERROR_MESSAGES.VALIDATION);\n }\n\n return {\n type: \"resource\",\n resource: {\n name: image.name,\n mimeType: image.type,\n // Shared.Resource.blob expects base64-encoded data; this is the base64\n // payload from the `data:` URL.\n blob: image.dataUrl.slice(commaIndex + 1),\n },\n };\n}\n\n/**\n * Options for submitting a message\n */\nexport interface SubmitOptions {\n /**\n * Enable debug logging for the stream\n */\n debug?: boolean;\n\n /**\n * How the model should use tools. Defaults to \"auto\".\n * - \"auto\": Model decides whether to use tools\n * - \"required\": Model must use at least one tool\n * - \"none\": Model cannot use tools\n * - { name: \"toolName\" }: Model must use the specified tool\n */\n toolChoice?: ToolChoice;\n}\n\n/**\n * Context props for thread input state\n */\nexport interface TamboThreadInputContextProps extends Omit<\n UseTamboMutationResult<\n { threadId: string | undefined },\n Error,\n SubmitOptions | undefined\n >,\n \"mutate\" | \"mutateAsync\"\n> {\n /** Current value of the input field */\n value: string;\n\n /**\n * Function to update the input value\n * @param value - New value for the input field\n */\n setValue: React.Dispatch<React.SetStateAction<string>>;\n\n /**\n * Function to submit the current input value\n * @param options - Submission options\n * @returns Promise with the threadId\n */\n submit: (\n options?: SubmitOptions,\n ) => Promise<{ threadId: string | undefined }>;\n\n /** Currently staged images */\n images: StagedImage[];\n\n /** Add a single image */\n addImage: (file: File) => Promise<void>;\n\n /** Add multiple images */\n addImages: (files: File[]) => Promise<void>;\n\n /** Remove an image by id */\n removeImage: (id: string) => void;\n\n /** Clear all staged images */\n clearImages: () => void;\n\n /** Current thread ID being used for input (from stream state) */\n threadId: string | undefined;\n\n /** Whether the input should be disabled (pending submission or not authenticated) */\n isDisabled: boolean;\n}\n\n/**\n * Context for thread input state.\n * @internal\n */\nexport const TamboThreadInputContext = createContext<\n TamboThreadInputContextProps | undefined\n>(undefined);\n\n/**\n * Provider that manages shared thread input state across all components.\n *\n * This ensures that useTamboThreadInput, useTamboSuggestions, and other components\n * all share the same input state.\n * @param props - Provider props\n * @param props.children - Child components\n * @returns Thread input context provider\n */\nexport function TamboThreadInputProvider({ children }: PropsWithChildren) {\n const [inputValue, setInputValue] = useState(\"\");\n const imageState = useMessageImages();\n const streamState = useStreamState();\n const dispatch = useStreamDispatch();\n const authState = useTamboAuthState();\n\n // Use the current thread from stream state directly\n // Placeholder ID indicates a new thread should be created\n const currentThreadId = streamState.currentThreadId ?? undefined;\n const isNewThread = isPlaceholderThreadId(currentThreadId);\n const sendMessage = useTamboSendMessage(currentThreadId);\n\n const isIdentified = authState.status === \"identified\";\n\n const submitFn = useCallback(\n async (\n options?: SubmitOptions,\n ): Promise<{ threadId: string | undefined }> => {\n if (!isIdentified) {\n throw new Error(\n \"Cannot submit: authentication is not ready. \" +\n \"Ensure a valid userKey or userToken is provided.\",\n );\n }\n\n const trimmedValue = inputValue.trim();\n\n // Check if we have content to send\n if (!trimmedValue && imageState.images.length === 0) {\n throw new Error(INPUT_ERROR_MESSAGES.EMPTY);\n }\n\n const content: InputMessage[\"content\"] = [];\n\n if (trimmedValue) {\n content.push({ type: \"text\", text: trimmedValue });\n }\n\n for (const image of imageState.images) {\n content.push(stagedImageToResourceContent(image));\n }\n\n const result = await sendMessage.mutateAsync({\n message: {\n role: \"user\",\n content,\n },\n userMessageText: trimmedValue, // Pass text for optimistic display\n debug: options?.debug,\n toolChoice: options?.toolChoice,\n });\n\n // Clear input and images after successful submission\n setInputValue(\"\");\n imageState.clearImages();\n\n // Update stream context's currentThreadId if a new thread was created\n if (result.threadId && isNewThread) {\n dispatch({ type: \"SET_CURRENT_THREAD\", threadId: result.threadId });\n }\n\n return result;\n },\n // `stagedImageToResourceContent` is a pure module-level helper (not a hook value).\n [inputValue, imageState, sendMessage, isNewThread, dispatch, isIdentified],\n );\n\n const {\n mutateAsync: submitAsync,\n mutate: _unusedSubmit,\n ...mutationState\n } = useTamboMutation({\n mutationKey: [\"v1-thread-input\", currentThreadId],\n mutationFn: submitFn,\n });\n\n const contextValue: TamboThreadInputContextProps = {\n ...mutationState,\n value: inputValue,\n setValue: setInputValue,\n submit: submitAsync,\n images: imageState.images,\n addImage: imageState.addImage,\n addImages: imageState.addImages,\n removeImage: imageState.removeImage,\n clearImages: imageState.clearImages,\n threadId: currentThreadId,\n isDisabled: mutationState.isPending || !isIdentified,\n };\n\n return (\n <TamboThreadInputContext.Provider value={contextValue}>\n {children}\n </TamboThreadInputContext.Provider>\n );\n}\n\n/**\n * Hook to access the shared thread input state.\n *\n * All components using this hook share the same input state, enabling\n * features like suggestions to update the input field directly.\n * @returns The shared thread input context\n * @throws {Error} If used outside TamboThreadInputProvider\n * @example\n * ```tsx\n * function ChatInput() {\n * const { value, setValue, submit, isPending } = useTamboThreadInput();\n *\n * return (\n * <form onSubmit={(e) => { e.preventDefault(); submit(); }}>\n * <input\n * value={value}\n * onChange={(e) => setValue(e.target.value)}\n * disabled={isPending}\n * />\n * <button type=\"submit\" disabled={isPending}>Send</button>\n * </form>\n * );\n * }\n * ```\n */\nexport function useTamboThreadInput(): TamboThreadInputContextProps {\n const context = useContext(TamboThreadInputContext);\n if (!context) {\n throw new Error(\n \"useTamboThreadInput must be used within TamboThreadInputProvider\",\n );\n }\n return context;\n}\n"]}
|
package/esm/v1/types/auth.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Authentication state for the
|
|
2
|
+
* Authentication state for the SDK.
|
|
3
3
|
*
|
|
4
4
|
* Discriminated union tracking the current auth lifecycle:
|
|
5
5
|
* - `identified`: ready to make API calls (via userKey or successful token exchange)
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* - `invalid`: both userKey AND userToken provided (must choose one)
|
|
9
9
|
* - `unauthenticated`: neither userKey nor userToken provided
|
|
10
10
|
*/
|
|
11
|
-
export type
|
|
11
|
+
export type TamboAuthState = {
|
|
12
12
|
status: "identified";
|
|
13
13
|
source: "userKey" | "tokenExchange";
|
|
14
14
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/v1/types/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/v1/types/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,GACtB;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,SAAS,GAAG,eAAe,CAAA;CAAE,GAC7D;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GACxB;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GACjC;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,iBAAiB,CAAA;CAAE,CAAC"}
|
package/esm/v1/types/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/v1/types/auth.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Authentication state for the
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/v1/types/auth.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Authentication state for the SDK.\n *\n * Discriminated union tracking the current auth lifecycle:\n * - `identified`: ready to make API calls (via userKey or successful token exchange)\n * - `exchanging`: userToken provided, exchange in-flight\n * - `error`: token exchange failed\n * - `invalid`: both userKey AND userToken provided (must choose one)\n * - `unauthenticated`: neither userKey nor userToken provided\n */\nexport type TamboAuthState =\n | { status: \"identified\"; source: \"userKey\" | \"tokenExchange\" }\n | { status: \"exchanging\" }\n | { status: \"error\"; error: Error }\n | { status: \"invalid\" }\n | { status: \"unauthenticated\" };\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Component Types
|
|
2
|
+
* Component Types
|
|
3
3
|
*
|
|
4
4
|
* Defines how React components are registered and made available to the AI.
|
|
5
5
|
*
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* from the SDK. The SDK exports two different AvailableComponent types:
|
|
8
8
|
* - `shared.AvailableComponent` has `props` and `contextTools` fields
|
|
9
9
|
* - `RunCreateParams.AvailableComponent` has `propsSchema` and `stateSchema` fields
|
|
10
|
-
* We need the latter for
|
|
10
|
+
* We need the latter for API calls, so we define it locally to avoid confusion.
|
|
11
11
|
*/
|
|
12
12
|
import type { ComponentType } from "react";
|
|
13
13
|
/**
|
|
@@ -28,7 +28,7 @@ export interface AvailableComponent {
|
|
|
28
28
|
* Component registration for React SDK
|
|
29
29
|
* Extends AvailableComponent with the actual React component
|
|
30
30
|
*/
|
|
31
|
-
export interface
|
|
31
|
+
export interface TamboComponent extends AvailableComponent {
|
|
32
32
|
/** The React component to render */
|
|
33
33
|
component: ComponentType<any>;
|
|
34
34
|
/** Initial state factory (optional) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/v1/types/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IAEb,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;IAEpB,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAErC,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED;;;GAGG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/v1/types/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IAEb,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;IAEpB,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAErC,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED;;;GAGG;AACH,MAAM,WAAW,cAAe,SAAQ,kBAAkB;IACxD,oCAAoC;IACpC,SAAS,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAE9B,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAClC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAEhE,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IAEd,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,mCAAmC;IACnC,WAAW,EAAE,MAAM,CAAC;IAEpB,oDAAoD;IACpD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Component Types
|
|
2
|
+
* Component Types
|
|
3
3
|
*
|
|
4
4
|
* Defines how React components are registered and made available to the AI.
|
|
5
5
|
*
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* from the SDK. The SDK exports two different AvailableComponent types:
|
|
8
8
|
* - `shared.AvailableComponent` has `props` and `contextTools` fields
|
|
9
9
|
* - `RunCreateParams.AvailableComponent` has `propsSchema` and `stateSchema` fields
|
|
10
|
-
* We need the latter for
|
|
10
|
+
* We need the latter for API calls, so we define it locally to avoid confusion.
|
|
11
11
|
*/
|
|
12
12
|
export {};
|
|
13
13
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/v1/types/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG","sourcesContent":["/**\n * Component Types
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/v1/types/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG","sourcesContent":["/**\n * Component Types\n *\n * Defines how React components are registered and made available to the AI.\n *\n * Note: AvailableComponent is defined locally to match RunCreateParams.AvailableComponent\n * from the SDK. The SDK exports two different AvailableComponent types:\n * - `shared.AvailableComponent` has `props` and `contextTools` fields\n * - `RunCreateParams.AvailableComponent` has `propsSchema` and `stateSchema` fields\n * We need the latter for API calls, so we define it locally to avoid confusion.\n */\n\nimport type { ComponentType } from \"react\";\n\n/**\n * Component registration metadata for the AI\n * This is what gets sent to the API in the `available_components` field\n */\nexport interface AvailableComponent {\n /** Component name (must be unique) */\n name: string;\n\n /** Human-readable description for the AI */\n description: string;\n\n /** JSON Schema describing component props */\n propsSchema: Record<string, unknown>;\n\n /** JSON Schema describing component state (optional) */\n stateSchema?: Record<string, unknown>;\n}\n\n/**\n * Component registration for React SDK\n * Extends AvailableComponent with the actual React component\n */\nexport interface TamboComponent extends AvailableComponent {\n /** The React component to render */\n component: ComponentType<any>;\n\n /** Initial state factory (optional) */\n initialState?: () => Record<string, unknown>;\n}\n\n/**\n * Props passed to components when rendered\n */\nexport interface TamboComponentProps<\n TProps extends Record<string, unknown> = Record<string, unknown>,\n TState extends Record<string, unknown> = Record<string, unknown>,\n> {\n /** Component props from AI */\n props: TProps;\n\n /** Component state (can be updated by AI or client) */\n state?: TState;\n\n /** Unique component instance ID */\n componentId: string;\n\n /** Whether this component is currently streaming */\n isStreaming?: boolean;\n}\n"]}
|
package/esm/v1/types/event.d.ts
CHANGED
package/esm/v1/types/event.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../../src/v1/types/event.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyFH;;GAEG;AACH,MAAM,wBAAwB,GAAG;IAC/B,uBAAuB;IACvB,6BAA6B;IAC7B,6BAA6B;IAC7B,qBAAqB;IACrB,0BAA0B;CAClB,CAAC;AAEX;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAElC;IACC,OAAO,CACL,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC7B,wBAA8C,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CACrE,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAAkB;IAElB,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,uBAAuB;YAC1B,OAAO,KAA4B,CAAC;QACtC,KAAK,6BAA6B;YAChC,OAAO,KAAiC,CAAC;QAC3C,KAAK,6BAA6B;YAChC,OAAO,KAAiC,CAAC;QAC3C,KAAK,qBAAqB;YACxB,OAAO,KAA0B,CAAC;QACpC,KAAK,0BAA0B;YAC7B,OAAO,KAA8B,CAAC;QACxC;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC","sourcesContent":["/**\n * Tambo-specific Custom Event Types for
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../../src/v1/types/event.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyFH;;GAEG;AACH,MAAM,wBAAwB,GAAG;IAC/B,uBAAuB;IACvB,6BAA6B;IAC7B,6BAA6B;IAC7B,qBAAqB;IACrB,0BAA0B;CAClB,CAAC;AAEX;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAElC;IACC,OAAO,CACL,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC7B,wBAA8C,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CACrE,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAAkB;IAElB,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,uBAAuB;YAC1B,OAAO,KAA4B,CAAC;QACtC,KAAK,6BAA6B;YAChC,OAAO,KAAiC,CAAC;QAC3C,KAAK,6BAA6B;YAChC,OAAO,KAAiC,CAAC;QAC3C,KAAK,qBAAqB;YACxB,OAAO,KAA0B,CAAC;QACpC,KAAK,0BAA0B;YAC7B,OAAO,KAA8B,CAAC;QACxC;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC","sourcesContent":["/**\n * Tambo-specific Custom Event Types for Streaming API\n *\n * Defines custom events specific to Tambo functionality.\n * For standard AG-UI events, import directly from `@ag-ui/core`.\n */\n\nimport type { CustomEvent } from \"@ag-ui/core\";\nimport type { Operation } from \"fast-json-patch\";\n\ntype TamboCustomEventEnvelope<TName extends string, TValue> = Omit<\n CustomEvent,\n \"name\" | \"value\"\n> & {\n name: TName;\n value: TValue;\n};\n\n/**\n * Component start event (custom: tambo.component.start)\n */\nexport type ComponentStartEvent = TamboCustomEventEnvelope<\n \"tambo.component.start\",\n {\n messageId: string;\n componentId: string;\n componentName: string;\n }\n>;\n\n/**\n * Component props delta event (custom: tambo.component.props_delta)\n * Uses JSON Patch (RFC 6902) to update component props\n */\nexport type ComponentPropsDeltaEvent = TamboCustomEventEnvelope<\n \"tambo.component.props_delta\",\n {\n componentId: string;\n operations: Operation[];\n }\n>;\n\n/**\n * Component state delta event (custom: tambo.component.state_delta)\n * Uses JSON Patch (RFC 6902) to update component state\n */\nexport type ComponentStateDeltaEvent = TamboCustomEventEnvelope<\n \"tambo.component.state_delta\",\n {\n componentId: string;\n operations: Operation[];\n }\n>;\n\n/**\n * Component end event (custom: tambo.component.end)\n */\nexport type ComponentEndEvent = TamboCustomEventEnvelope<\n \"tambo.component.end\",\n {\n componentId: string;\n }\n>;\n\n/**\n * Pending tool call information from awaiting_input event\n */\nexport interface PendingToolCall {\n toolCallId: string;\n toolName: string;\n arguments: string;\n}\n\n/**\n * Run awaiting input event (custom: tambo.run.awaiting_input)\n * Signals that the run is paused waiting for client-side tool execution\n */\nexport type RunAwaitingInputEvent = TamboCustomEventEnvelope<\n \"tambo.run.awaiting_input\",\n {\n pendingToolCalls: PendingToolCall[];\n }\n>;\n\n/**\n * Union type of Tambo-specific custom events\n */\nexport type TamboCustomEvent =\n | ComponentStartEvent\n | ComponentPropsDeltaEvent\n | ComponentStateDeltaEvent\n | ComponentEndEvent\n | RunAwaitingInputEvent;\n\n/**\n * Known Tambo custom event names for type narrowing\n */\nconst TAMBO_CUSTOM_EVENT_NAMES = [\n \"tambo.component.start\",\n \"tambo.component.props_delta\",\n \"tambo.component.state_delta\",\n \"tambo.component.end\",\n \"tambo.run.awaiting_input\",\n] as const;\n\n/**\n * Type guard to check if an event is a Tambo custom event.\n * Validates that the event has a name matching known Tambo custom event types.\n * @param event - Event object to check\n * @param event.name - Event name to match against known Tambo event types\n * @returns True if event is a TamboCustomEvent\n */\nexport function isTamboCustomEvent(event: {\n name?: string;\n}): event is TamboCustomEvent {\n return (\n typeof event.name === \"string\" &&\n (TAMBO_CUSTOM_EVENT_NAMES as readonly string[]).includes(event.name)\n );\n}\n\n/**\n * Casts a CustomEvent to the specific TamboCustomEvent type based on its name.\n * Uses exhaustive type checking to ensure all event types are handled.\n * @param event - The CustomEvent to cast\n * @returns The properly typed TamboCustomEvent, or undefined if not a known Tambo event\n */\nexport function asTamboCustomEvent(\n event: CustomEvent,\n): TamboCustomEvent | undefined {\n switch (event.name) {\n case \"tambo.component.start\":\n return event as ComponentStartEvent;\n case \"tambo.component.props_delta\":\n return event as ComponentPropsDeltaEvent;\n case \"tambo.component.state_delta\":\n return event as ComponentStateDeltaEvent;\n case \"tambo.component.end\":\n return event as ComponentEndEvent;\n case \"tambo.run.awaiting_input\":\n return event as RunAwaitingInputEvent;\n default:\n return undefined;\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Message and Content Types
|
|
2
|
+
* Message and Content Types
|
|
3
3
|
*
|
|
4
4
|
* Re-exports message and content types from `@tambo-ai/typescript-sdk`.
|
|
5
5
|
* Messages use Anthropic-style content blocks pattern where a message
|
|
@@ -7,19 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { ReactElement } from "react";
|
|
9
9
|
export type { TextContent, ToolResultContent, ResourceContent, } from "@tambo-ai/typescript-sdk/resources/threads/threads";
|
|
10
|
-
import type { InputMessage } from "@tambo-ai/typescript-sdk/resources/threads/runs";
|
|
11
10
|
export type { InputMessage } from "@tambo-ai/typescript-sdk/resources/threads/runs";
|
|
11
|
+
import type { RunCreateParams } from "@tambo-ai/typescript-sdk/resources/threads/runs";
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* in addition to
|
|
15
|
-
*
|
|
16
|
-
* The TS SDK `InputMessage` type constrains `role` to `'user'`, but the V1 API
|
|
17
|
-
* accepts `'user' | 'system' | 'assistant'` for `initialMessages`. This type
|
|
18
|
-
* widens the role field until the TS SDK type is regenerated.
|
|
13
|
+
* Message type for initial messages that seed a new thread.
|
|
14
|
+
* Supports system and assistant roles in addition to user,
|
|
15
|
+
* and restricts content to text and resource blocks (no tool results).
|
|
19
16
|
*/
|
|
20
|
-
export type InitialInputMessage =
|
|
21
|
-
role: "user" | "system" | "assistant";
|
|
22
|
-
};
|
|
17
|
+
export type InitialInputMessage = RunCreateParams.Thread.InitialMessage;
|
|
23
18
|
export type { MessageListResponse, MessageGetResponse, } from "@tambo-ai/typescript-sdk/resources/threads/messages";
|
|
24
19
|
import type { TextContent, ToolUseContent, ToolResultContent, ComponentContent, ResourceContent } from "@tambo-ai/typescript-sdk/resources/threads/threads";
|
|
25
20
|
/**
|
|
@@ -29,9 +24,9 @@ import type { TextContent, ToolUseContent, ToolResultContent, ComponentContent,
|
|
|
29
24
|
export type ComponentStreamingState = "started" | "streaming" | "done";
|
|
30
25
|
/**
|
|
31
26
|
* Extended ComponentContent with streaming state and rendered element.
|
|
32
|
-
* Used by the
|
|
27
|
+
* Used by the SDK to track component rendering lifecycle.
|
|
33
28
|
*/
|
|
34
|
-
export interface
|
|
29
|
+
export interface TamboComponentContent extends ComponentContent {
|
|
35
30
|
/**
|
|
36
31
|
* Current streaming state of this component's props.
|
|
37
32
|
* - 'started': Component block created, awaiting props
|
|
@@ -52,8 +47,6 @@ export interface V1ComponentContent extends ComponentContent {
|
|
|
52
47
|
* These are used to customize tool status messages shown in the UI.
|
|
53
48
|
*/
|
|
54
49
|
export interface TamboToolDisplayProps {
|
|
55
|
-
/** Generic display message for the tool */
|
|
56
|
-
_tambo_displayMessage?: string;
|
|
57
50
|
/** Message shown while the tool is executing */
|
|
58
51
|
_tambo_statusMessage?: string;
|
|
59
52
|
/** Message shown after the tool completes */
|
|
@@ -61,12 +54,12 @@ export interface TamboToolDisplayProps {
|
|
|
61
54
|
}
|
|
62
55
|
/**
|
|
63
56
|
* Extended ToolUseContent with computed state properties.
|
|
64
|
-
* Used by the
|
|
57
|
+
* Used by the SDK to provide pre-computed tool state to consumers.
|
|
65
58
|
*
|
|
66
|
-
* Note: The computed properties are populated by `
|
|
59
|
+
* Note: The computed properties are populated by `useTambo()` hook.
|
|
67
60
|
* When accessed via lower-level APIs, they may be undefined.
|
|
68
61
|
*/
|
|
69
|
-
export interface
|
|
62
|
+
export interface TamboToolUseContent extends Omit<ToolUseContent, "input"> {
|
|
70
63
|
/**
|
|
71
64
|
* Tool input parameters with internal `_tambo_*` properties removed.
|
|
72
65
|
* Consumers see only the actual tool parameters.
|
|
@@ -74,19 +67,19 @@ export interface V1ToolUseContent extends Omit<ToolUseContent, "input"> {
|
|
|
74
67
|
input: Record<string, unknown>;
|
|
75
68
|
/**
|
|
76
69
|
* Whether this tool call has completed (has a matching tool_result).
|
|
77
|
-
* Computed by `
|
|
70
|
+
* Computed by `useTambo()` based on presence of matching tool_result.
|
|
78
71
|
*/
|
|
79
72
|
hasCompleted?: boolean;
|
|
80
73
|
/**
|
|
81
74
|
* The status message to display, resolved based on tool execution state.
|
|
82
75
|
* Automatically updates as tool progresses through execution lifecycle.
|
|
83
|
-
* Computed by `
|
|
76
|
+
* Computed by `useTambo()`.
|
|
84
77
|
*/
|
|
85
78
|
statusMessage?: string;
|
|
86
79
|
/**
|
|
87
80
|
* Extracted Tambo display properties from the tool input.
|
|
88
81
|
* Consumers can use these for custom rendering if needed.
|
|
89
|
-
* Computed by `
|
|
82
|
+
* Computed by `useTambo()`.
|
|
90
83
|
*/
|
|
91
84
|
tamboDisplayProps?: TamboToolDisplayProps;
|
|
92
85
|
}
|
|
@@ -97,13 +90,13 @@ export interface V1ToolUseContent extends Omit<ToolUseContent, "input"> {
|
|
|
97
90
|
export type MessageRole = "user" | "assistant" | "system";
|
|
98
91
|
/**
|
|
99
92
|
* Union type of all content block types.
|
|
100
|
-
* Uses
|
|
93
|
+
* Uses TamboComponentContent and TamboToolUseContent which include computed state.
|
|
101
94
|
*/
|
|
102
|
-
export type Content = TextContent |
|
|
95
|
+
export type Content = TextContent | TamboToolUseContent | ToolResultContent | TamboComponentContent | ResourceContent;
|
|
103
96
|
/**
|
|
104
97
|
* Message in a thread (simplified from SDK's MessageGetResponse)
|
|
105
98
|
*/
|
|
106
|
-
export interface
|
|
99
|
+
export interface TamboThreadMessage {
|
|
107
100
|
/** Unique message identifier */
|
|
108
101
|
id: string;
|
|
109
102
|
/** Message role (user or assistant) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/v1/types/message.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAK1C,YAAY,EACV,WAAW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AC;IAE/B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,qBAAqB,CAAC;CAC3C;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE1D;;;GAGG;AACH,MAAM,MAAM,OAAO,GACf,WAAW,GACX,mBAAmB,GACnB,iBAAiB,GACjB,qBAAqB,GACrB,eAAe,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;IAEX,uCAAuC;IACvC,IAAI,EAAE,WAAW,CAAC;IAElB,oCAAoC;IACpC,OAAO,EAAE,OAAO,EAAE,CAAC;IAEnB,sFAAsF;IACtF,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,uBAAuB;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEnC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAErB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B"}
|
package/esm/v1/types/message.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/v1/types/message.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * Message and Content Types
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/v1/types/message.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * Message and Content Types\n *\n * Re-exports message and content types from `@tambo-ai/typescript-sdk`.\n * Messages use Anthropic-style content blocks pattern where a message\n * contains an array of content blocks (text, tool calls, tool results, components).\n */\n\nimport type { ReactElement } from \"react\";\n\n// Re-export content block types from TypeScript SDK\n// Note: ToolUseContent and ComponentContent are NOT re-exported - use TamboToolUseContent\n// and TamboComponentContent instead, which include computed state properties.\nexport type {\n TextContent,\n ToolResultContent,\n ResourceContent,\n} from \"@tambo-ai/typescript-sdk/resources/threads/threads\";\n\n// Re-export message types from TypeScript SDK\nexport type { InputMessage } from \"@tambo-ai/typescript-sdk/resources/threads/runs\";\nimport type { RunCreateParams } from \"@tambo-ai/typescript-sdk/resources/threads/runs\";\n\n/**\n * Message type for initial messages that seed a new thread.\n * Supports system and assistant roles in addition to user,\n * and restricts content to text and resource blocks (no tool results).\n */\nexport type InitialInputMessage = RunCreateParams.Thread.InitialMessage;\n\nexport type {\n MessageListResponse,\n MessageGetResponse,\n} from \"@tambo-ai/typescript-sdk/resources/threads/messages\";\n\n// Import for Content union type\nimport type {\n TextContent,\n ToolUseContent,\n ToolResultContent,\n ComponentContent,\n ResourceContent,\n} from \"@tambo-ai/typescript-sdk/resources/threads/threads\";\n\n/**\n * Streaming state for component content blocks.\n * Tracks the lifecycle of component prop/state streaming.\n */\nexport type ComponentStreamingState = \"started\" | \"streaming\" | \"done\";\n\n/**\n * Extended ComponentContent with streaming state and rendered element.\n * Used by the SDK to track component rendering lifecycle.\n */\nexport interface TamboComponentContent extends ComponentContent {\n /**\n * Current streaming state of this component's props.\n * - 'started': Component block created, awaiting props\n * - 'streaming': Props are being streamed\n * - 'done': Props streaming complete\n *\n * Optional for historical messages loaded from API (defaults to \"done\").\n */\n streamingState?: ComponentStreamingState;\n\n /**\n * The rendered React element for this component.\n * undefined if not yet rendered, null if the component couldn't be found in the registry.\n */\n renderedComponent?: ReactElement | null;\n}\n\n/**\n * Special display properties that can be included in tool input.\n * These are used to customize tool status messages shown in the UI.\n */\nexport interface TamboToolDisplayProps {\n /** Message shown while the tool is executing */\n _tambo_statusMessage?: string;\n /** Message shown after the tool completes */\n _tambo_completionStatusMessage?: string;\n}\n\n/**\n * Extended ToolUseContent with computed state properties.\n * Used by the SDK to provide pre-computed tool state to consumers.\n *\n * Note: The computed properties are populated by `useTambo()` hook.\n * When accessed via lower-level APIs, they may be undefined.\n */\nexport interface TamboToolUseContent extends Omit<ToolUseContent, \"input\"> {\n /**\n * Tool input parameters with internal `_tambo_*` properties removed.\n * Consumers see only the actual tool parameters.\n */\n input: Record<string, unknown>;\n\n /**\n * Whether this tool call has completed (has a matching tool_result).\n * Computed by `useTambo()` based on presence of matching tool_result.\n */\n hasCompleted?: boolean;\n\n /**\n * The status message to display, resolved based on tool execution state.\n * Automatically updates as tool progresses through execution lifecycle.\n * Computed by `useTambo()`.\n */\n statusMessage?: string;\n\n /**\n * Extracted Tambo display properties from the tool input.\n * Consumers can use these for custom rendering if needed.\n * Computed by `useTambo()`.\n */\n tamboDisplayProps?: TamboToolDisplayProps;\n}\n\n/**\n * Message role (from SDK)\n * Includes 'system' to accommodate messages loaded from API.\n */\nexport type MessageRole = \"user\" | \"assistant\" | \"system\";\n\n/**\n * Union type of all content block types.\n * Uses TamboComponentContent and TamboToolUseContent which include computed state.\n */\nexport type Content =\n | TextContent\n | TamboToolUseContent\n | ToolResultContent\n | TamboComponentContent\n | ResourceContent;\n\n/**\n * Message in a thread (simplified from SDK's MessageGetResponse)\n */\nexport interface TamboThreadMessage {\n /** Unique message identifier */\n id: string;\n\n /** Message role (user or assistant) */\n role: MessageRole;\n\n /** Content blocks in the message */\n content: Content[];\n\n /** When the message was created (optional for historical messages loaded from API) */\n createdAt?: string;\n\n /** Message metadata */\n metadata?: Record<string, unknown>;\n\n /**\n * Reasoning content from the model (transient - only during streaming).\n * Each element is a reasoning \"chunk\" - models may emit multiple reasoning blocks.\n * This data is not persisted to the database and will not be present in\n * messages loaded from the API.\n */\n reasoning?: string[];\n\n /**\n * Duration of the reasoning phase in milliseconds (for display purposes).\n * Populated when reasoning completes.\n */\n reasoningDurationMS?: number;\n}\n"]}
|
package/esm/v1/types/thread.d.ts
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Thread Types
|
|
2
|
+
* Thread Types
|
|
3
3
|
*
|
|
4
4
|
* Re-exports thread types from `@tambo-ai/typescript-sdk` and defines
|
|
5
5
|
* React-specific extensions for streaming state management.
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { TamboThreadMessage } from "./message.js";
|
|
8
8
|
export type { ThreadCreateResponse, ThreadRetrieveResponse, ThreadListResponse, } from "@tambo-ai/typescript-sdk/resources/threads/threads";
|
|
9
9
|
/**
|
|
10
|
-
* Run status indicates the current state of the thread
|
|
10
|
+
* Run status indicates the current state of the thread's run lifecycle.
|
|
11
|
+
* Matches the API's RunStatus — no "complete" or "error" variants.
|
|
12
|
+
* Error information is tracked separately in StreamingState.error.
|
|
11
13
|
*/
|
|
12
|
-
export type RunStatus = "idle" | "waiting" | "streaming"
|
|
14
|
+
export type RunStatus = "idle" | "waiting" | "streaming";
|
|
13
15
|
/**
|
|
14
16
|
* Thread represents a conversation with the AI
|
|
15
17
|
* Extended from SDK's ThreadRetrieveResponse with additional fields for React state
|
|
16
18
|
*/
|
|
17
|
-
export interface
|
|
19
|
+
export interface TamboThread {
|
|
18
20
|
/** Unique thread identifier */
|
|
19
21
|
id: string;
|
|
20
|
-
/** Thread
|
|
21
|
-
|
|
22
|
+
/** Thread name */
|
|
23
|
+
name?: string;
|
|
22
24
|
/** Messages in the thread */
|
|
23
|
-
messages:
|
|
25
|
+
messages: TamboThreadMessage[];
|
|
24
26
|
/** Current run status */
|
|
25
27
|
status: RunStatus;
|
|
26
28
|
/** Thread metadata */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread.d.ts","sourceRoot":"","sources":["../../../src/v1/types/thread.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"thread.d.ts","sourceRoot":"","sources":["../../../src/v1/types/thread.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAGpD,YAAY,EACV,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,oDAAoD,CAAC;AAE5D;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,+BAA+B;IAC/B,EAAE,EAAE,MAAM,CAAC;IAEX,kBAAkB;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,6BAA6B;IAC7B,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAE/B,yBAAyB;IACzB,MAAM,EAAE,SAAS,CAAC;IAElB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEnC,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAC;IAElB,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;IAElB,iFAAiF;IACjF,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,+BAA+B;IAC/B,MAAM,EAAE,SAAS,CAAC;IAElB,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,mCAAmC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,wDAAwD;IACxD,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,6CAA6C;IAC7C,KAAK,CAAC,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH"}
|
package/esm/v1/types/thread.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread.js","sourceRoot":"","sources":["../../../src/v1/types/thread.ts"],"names":[],"mappings":"AAAA;;;;;GAKG","sourcesContent":["/**\n * Thread Types
|
|
1
|
+
{"version":3,"file":"thread.js","sourceRoot":"","sources":["../../../src/v1/types/thread.ts"],"names":[],"mappings":"AAAA;;;;;GAKG","sourcesContent":["/**\n * Thread Types\n *\n * Re-exports thread types from `@tambo-ai/typescript-sdk` and defines\n * React-specific extensions for streaming state management.\n */\n\nimport type { TamboThreadMessage } from \"./message\";\n\n// Re-export thread types from TypeScript SDK\nexport type {\n ThreadCreateResponse,\n ThreadRetrieveResponse,\n ThreadListResponse,\n} from \"@tambo-ai/typescript-sdk/resources/threads/threads\";\n\n/**\n * Run status indicates the current state of the thread's run lifecycle.\n * Matches the API's RunStatus — no \"complete\" or \"error\" variants.\n * Error information is tracked separately in StreamingState.error.\n */\nexport type RunStatus = \"idle\" | \"waiting\" | \"streaming\";\n\n/**\n * Thread represents a conversation with the AI\n * Extended from SDK's ThreadRetrieveResponse with additional fields for React state\n */\nexport interface TamboThread {\n /** Unique thread identifier */\n id: string;\n\n /** Thread name */\n name?: string;\n\n /** Messages in the thread */\n messages: TamboThreadMessage[];\n\n /** Current run status */\n status: RunStatus;\n\n /** Thread metadata */\n metadata?: Record<string, unknown>;\n\n /** When the thread was created */\n createdAt: string;\n\n /** When the thread was last updated */\n updatedAt: string;\n\n /** Whether the last run was cancelled (resets to false when a new run starts) */\n lastRunCancelled: boolean;\n}\n\n/**\n * Streaming state tracks the progress of an active run\n * This is React-specific and not part of the SDK\n */\nexport interface StreamingState {\n /** Current streaming status */\n status: RunStatus;\n\n /** Active run ID (if streaming) */\n runId?: string;\n\n /** Active message ID being streamed */\n messageId?: string;\n\n /** When the current run started */\n startTime?: number;\n\n /** When reasoning started (for duration calculation) */\n reasoningStartTime?: number;\n\n /** Error information if status is 'error' */\n error?: {\n message: string;\n code?: string;\n };\n}\n"]}
|