stream-chat-react-native-core 9.12.1 → 9.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/a2ui/package.json +6 -0
- package/lib/commonjs/a11y/a11yUtils.js.map +1 -1
- package/lib/commonjs/a11y/hooks/useResolvedModalAccessibilityProps.js.map +1 -1
- package/lib/commonjs/a2ui/A2UIContexts.js +8 -0
- package/lib/commonjs/a2ui/A2UIContexts.js.map +1 -0
- package/lib/commonjs/a2ui/A2UIInstructions.js +49 -0
- package/lib/commonjs/a2ui/A2UIInstructions.js.map +1 -0
- package/lib/commonjs/a2ui/A2UIPlaceholder.js +37 -0
- package/lib/commonjs/a2ui/A2UIPlaceholder.js.map +1 -0
- package/lib/commonjs/a2ui/A2UIRenderer.js +363 -0
- package/lib/commonjs/a2ui/A2UIRenderer.js.map +1 -0
- package/lib/commonjs/a2ui/A2UIStream.js +91 -0
- package/lib/commonjs/a2ui/A2UIStream.js.map +1 -0
- package/lib/commonjs/a2ui/A2UISurface.js +212 -0
- package/lib/commonjs/a2ui/A2UISurface.js.map +1 -0
- package/lib/commonjs/a2ui/basicCatalog.json +1206 -0
- package/lib/commonjs/a2ui/basicFunctions.js +398 -0
- package/lib/commonjs/a2ui/basicFunctions.js.map +1 -0
- package/lib/commonjs/a2ui/catalogDocument.js +80 -0
- package/lib/commonjs/a2ui/catalogDocument.js.map +1 -0
- package/lib/commonjs/a2ui/catalogs.js +105 -0
- package/lib/commonjs/a2ui/catalogs.js.map +1 -0
- package/lib/commonjs/a2ui/components/DateTimeInput.js +445 -0
- package/lib/commonjs/a2ui/components/DateTimeInput.js.map +1 -0
- package/lib/commonjs/a2ui/components/Media.js +316 -0
- package/lib/commonjs/a2ui/components/Media.js.map +1 -0
- package/lib/commonjs/a2ui/components/basicComponents.js +975 -0
- package/lib/commonjs/a2ui/components/basicComponents.js.map +1 -0
- package/lib/commonjs/a2ui/components/iconPaths.js +66 -0
- package/lib/commonjs/a2ui/components/iconPaths.js.map +1 -0
- package/lib/commonjs/a2ui/components/types.js +4 -0
- package/lib/commonjs/a2ui/components/types.js.map +1 -0
- package/lib/commonjs/a2ui/index.js +70 -0
- package/lib/commonjs/a2ui/index.js.map +1 -0
- package/lib/commonjs/a2ui/instructions.js +268 -0
- package/lib/commonjs/a2ui/instructions.js.map +1 -0
- package/lib/commonjs/a2ui/secrets.js +169 -0
- package/lib/commonjs/a2ui/secrets.js.map +1 -0
- package/lib/commonjs/a2ui/useReplyState.js +35 -0
- package/lib/commonjs/a2ui/useReplyState.js.map +1 -0
- package/lib/commonjs/ai-components/AITypingIndicatorView.js +8 -18
- package/lib/commonjs/ai-components/AITypingIndicatorView.js.map +1 -1
- package/lib/commonjs/ai-components/README.md +55 -3
- package/lib/commonjs/ai-components/StreamingMessageView.js +26 -0
- package/lib/commonjs/ai-components/StreamingMessageView.js.map +1 -1
- package/lib/commonjs/ai-components/charts/components/PieLegend.js +2 -1
- package/lib/commonjs/ai-components/charts/components/PieLegend.js.map +1 -1
- package/lib/commonjs/ai-components/charts/components/VictoryChart.js +7 -2
- package/lib/commonjs/ai-components/charts/components/VictoryChart.js.map +1 -1
- package/lib/commonjs/ai-components/charts/utils/format-time-label.js +15 -0
- package/lib/commonjs/ai-components/charts/utils/format-time-label.js.map +1 -0
- package/lib/commonjs/ai-components/charts/vega-lite/schema.js +17 -2
- package/lib/commonjs/ai-components/charts/vega-lite/schema.js.map +1 -1
- package/lib/commonjs/ai-components/contexts/composer-context.js +13 -6
- package/lib/commonjs/ai-components/contexts/composer-context.js.map +1 -1
- package/lib/commonjs/ai-components/contexts/index.js +11 -0
- package/lib/commonjs/ai-components/contexts/index.js.map +1 -1
- package/lib/commonjs/ai-components/contexts/theme-context.js +33 -2
- package/lib/commonjs/ai-components/contexts/theme-context.js.map +1 -1
- package/lib/commonjs/ai-components/contexts/translation-context.js +29 -0
- package/lib/commonjs/ai-components/contexts/translation-context.js.map +1 -0
- package/lib/commonjs/ai-components/conversation/AIConversation.js +366 -0
- package/lib/commonjs/ai-components/conversation/AIConversation.js.map +1 -0
- package/lib/commonjs/ai-components/conversation/controller/AIAgentError.js +13 -0
- package/lib/commonjs/ai-components/conversation/controller/AIAgentError.js.map +1 -0
- package/lib/commonjs/ai-components/conversation/controller/AIConversationController.js +425 -0
- package/lib/commonjs/ai-components/conversation/controller/AIConversationController.js.map +1 -0
- package/lib/commonjs/ai-components/conversation/controller/AIConversationExchange.js +89 -0
- package/lib/commonjs/ai-components/conversation/controller/AIConversationExchange.js.map +1 -0
- package/lib/commonjs/ai-components/conversation/controller/index.js +48 -0
- package/lib/commonjs/ai-components/conversation/controller/index.js.map +1 -0
- package/lib/commonjs/ai-components/conversation/controller/offers.js +29 -0
- package/lib/commonjs/ai-components/conversation/controller/offers.js.map +1 -0
- package/lib/commonjs/ai-components/conversation/controller/types.js +13 -0
- package/lib/commonjs/ai-components/conversation/controller/types.js.map +1 -0
- package/lib/commonjs/ai-components/conversation/controller/useAIConversationState.js +8 -0
- package/lib/commonjs/ai-components/conversation/controller/useAIConversationState.js.map +1 -0
- package/lib/commonjs/ai-components/conversation/entries.js +98 -0
- package/lib/commonjs/ai-components/conversation/entries.js.map +1 -0
- package/lib/commonjs/ai-components/conversation/fromStreamMessage.js +66 -0
- package/lib/commonjs/ai-components/conversation/fromStreamMessage.js.map +1 -0
- package/lib/commonjs/ai-components/conversation/index.js +48 -0
- package/lib/commonjs/ai-components/conversation/index.js.map +1 -0
- package/lib/commonjs/ai-components/conversation/list/AIChatList.js +224 -0
- package/lib/commonjs/ai-components/conversation/list/AIChatList.js.map +1 -0
- package/lib/commonjs/ai-components/conversation/list/useChatListController.js +78 -0
- package/lib/commonjs/ai-components/conversation/list/useChatListController.js.map +1 -0
- package/lib/commonjs/ai-components/conversation/list/useEndInView.js +51 -0
- package/lib/commonjs/ai-components/conversation/list/useEndInView.js.map +1 -0
- package/lib/commonjs/ai-components/conversation/list/useKeyboardOverlap.js +54 -0
- package/lib/commonjs/ai-components/conversation/list/useKeyboardOverlap.js.map +1 -0
- package/lib/commonjs/ai-components/conversation/list/useLoadOlder.js +73 -0
- package/lib/commonjs/ai-components/conversation/list/useLoadOlder.js.map +1 -0
- package/lib/commonjs/ai-components/conversation/list/usePinnedAnchor.js +84 -0
- package/lib/commonjs/ai-components/conversation/list/usePinnedAnchor.js.map +1 -0
- package/lib/commonjs/ai-components/conversation/types.js +4 -0
- package/lib/commonjs/ai-components/conversation/types.js.map +1 -0
- package/lib/commonjs/ai-components/conversation/useConversationRows.js +117 -0
- package/lib/commonjs/ai-components/conversation/useConversationRows.js.map +1 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIAction.js +30 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIAction.js.map +1 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIArguments.js +128 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIArguments.js.map +1 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIComponent.js +50 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIComponent.js.map +1 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIComponentDefinition.js +134 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIComponentDefinition.js.map +1 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIDocument.js +32 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIDocument.js.map +1 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIEntrance.js +193 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIEntrance.js.map +1 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIErrorBoundary.js +30 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIErrorBoundary.js.map +1 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIHelpers.js +54 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIHelpers.js.map +1 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIHost.js +259 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIHost.js.map +1 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIMedia.js +24 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIMedia.js.map +1 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIRenderer.js +10 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIRenderer.js.map +1 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIView.js +57 -0
- package/lib/commonjs/ai-components/generative-ui/AIUIView.js.map +1 -0
- package/lib/commonjs/ai-components/generative-ui/index.js +181 -0
- package/lib/commonjs/ai-components/generative-ui/index.js.map +1 -0
- package/lib/commonjs/ai-components/icons.js +44 -0
- package/lib/commonjs/ai-components/icons.js.map +1 -0
- package/lib/commonjs/ai-components/index.js +96 -0
- package/lib/commonjs/ai-components/index.js.map +1 -1
- package/lib/commonjs/ai-components/internal/Shimmer.js +36 -0
- package/lib/commonjs/ai-components/internal/Shimmer.js.map +1 -0
- package/lib/commonjs/ai-components/internal/format.js +66 -0
- package/lib/commonjs/ai-components/internal/format.js.map +1 -0
- package/lib/commonjs/ai-components/internal/hooks/useBottomSafeArea.js +12 -0
- package/lib/commonjs/ai-components/internal/hooks/useBottomSafeArea.js.map +1 -0
- package/lib/commonjs/ai-components/internal/icons/AgentIcons.js +74 -0
- package/lib/commonjs/ai-components/internal/icons/AgentIcons.js.map +1 -0
- package/lib/commonjs/ai-components/internal/tokens.js +11 -0
- package/lib/commonjs/ai-components/internal/tokens.js.map +1 -0
- package/lib/commonjs/ai-components/internal/uuid.js +21 -0
- package/lib/commonjs/ai-components/internal/uuid.js.map +1 -0
- package/lib/commonjs/ai-components/markdown/components/CodeBlock.js +4 -2
- package/lib/commonjs/ai-components/markdown/components/CodeBlock.js.map +1 -1
- package/lib/commonjs/ai-components/markdown/components/InlineCode.js +1 -0
- package/lib/commonjs/ai-components/markdown/components/InlineCode.js.map +1 -1
- package/lib/commonjs/ai-components/markdown/components/Text.js +11 -2
- package/lib/commonjs/ai-components/markdown/components/Text.js.map +1 -1
- package/lib/commonjs/ai-components/markdown/styles.js +27 -29
- package/lib/commonjs/ai-components/markdown/styles.js.map +1 -1
- package/lib/commonjs/ai-components/message/AIAssistantMessage.js +63 -0
- package/lib/commonjs/ai-components/message/AIAssistantMessage.js.map +1 -0
- package/lib/commonjs/ai-components/message/AIMessageAttachment.js +189 -0
- package/lib/commonjs/ai-components/message/AIMessageAttachment.js.map +1 -0
- package/lib/commonjs/ai-components/message/AIReplyActions.js +132 -0
- package/lib/commonjs/ai-components/message/AIReplyActions.js.map +1 -0
- package/lib/commonjs/ai-components/message/AIUserMessage.js +104 -0
- package/lib/commonjs/ai-components/message/AIUserMessage.js.map +1 -0
- package/lib/commonjs/ai-components/message/UserMessageMenu.js +150 -0
- package/lib/commonjs/ai-components/message/UserMessageMenu.js.map +1 -0
- package/lib/commonjs/ai-components/message/index.js +48 -0
- package/lib/commonjs/ai-components/message/index.js.map +1 -0
- package/lib/commonjs/ai-components/message-composer/ActionButton.js +2 -1
- package/lib/commonjs/ai-components/message-composer/ActionButton.js.map +1 -1
- package/lib/commonjs/ai-components/message-composer/ActionSheet.js +22 -6
- package/lib/commonjs/ai-components/message-composer/ActionSheet.js.map +1 -1
- package/lib/commonjs/ai-components/message-composer/AttachmentButton.js +5 -1
- package/lib/commonjs/ai-components/message-composer/AttachmentButton.js.map +1 -1
- package/lib/commonjs/ai-components/message-composer/ChatOptions.js +147 -0
- package/lib/commonjs/ai-components/message-composer/ChatOptions.js.map +1 -0
- package/lib/commonjs/ai-components/message-composer/ComposerView.js +136 -20
- package/lib/commonjs/ai-components/message-composer/ComposerView.js.map +1 -1
- package/lib/commonjs/ai-components/message-composer/EditingMessageChip.js +80 -0
- package/lib/commonjs/ai-components/message-composer/EditingMessageChip.js.map +1 -0
- package/lib/commonjs/ai-components/message-composer/MediaPreviewList.js +26 -1
- package/lib/commonjs/ai-components/message-composer/MediaPreviewList.js.map +1 -1
- package/lib/commonjs/ai-components/message-composer/index.js +11 -0
- package/lib/commonjs/ai-components/message-composer/index.js.map +1 -1
- package/lib/commonjs/ai-components/message-parts/AIMessageParts.js +110 -0
- package/lib/commonjs/ai-components/message-parts/AIMessageParts.js.map +1 -0
- package/lib/commonjs/ai-components/message-parts/AIToolApproval.js +197 -0
- package/lib/commonjs/ai-components/message-parts/AIToolApproval.js.map +1 -0
- package/lib/commonjs/ai-components/message-parts/AIToolAuthorization.js +250 -0
- package/lib/commonjs/ai-components/message-parts/AIToolAuthorization.js.map +1 -0
- package/lib/commonjs/ai-components/message-parts/AIToolCall.js +159 -0
- package/lib/commonjs/ai-components/message-parts/AIToolCall.js.map +1 -0
- package/lib/commonjs/ai-components/message-parts/callStates.js +54 -0
- package/lib/commonjs/ai-components/message-parts/callStates.js.map +1 -0
- package/lib/commonjs/ai-components/message-parts/index.js +70 -0
- package/lib/commonjs/ai-components/message-parts/index.js.map +1 -0
- package/lib/commonjs/ai-components/message-parts/parseMessageParts.js +126 -0
- package/lib/commonjs/ai-components/message-parts/parseMessageParts.js.map +1 -0
- package/lib/commonjs/ai-components/message-parts/types.js +2 -0
- package/lib/commonjs/ai-components/message-parts/types.js.map +1 -0
- package/lib/commonjs/ai-components/native-specs/NativeAIAgent.js +7 -0
- package/lib/commonjs/ai-components/native-specs/NativeAIAgent.js.map +1 -0
- package/lib/commonjs/ai-components/reasoning/AIReasoning.js +401 -0
- package/lib/commonjs/ai-components/reasoning/AIReasoning.js.map +1 -0
- package/lib/commonjs/ai-components/reasoning/index.js +26 -0
- package/lib/commonjs/ai-components/reasoning/index.js.map +1 -0
- package/lib/commonjs/ai-components/reasoning/thinkingClock.js +63 -0
- package/lib/commonjs/ai-components/reasoning/thinkingClock.js.map +1 -0
- package/lib/commonjs/ai-components/services/clipboard-service/expo.js +7 -2
- package/lib/commonjs/ai-components/services/clipboard-service/expo.js.map +1 -1
- package/lib/commonjs/ai-components/store/composer/store.js.map +1 -1
- package/lib/commonjs/ai-components/store/composer/useComposerChatOption.js +18 -0
- package/lib/commonjs/ai-components/store/composer/useComposerChatOption.js.map +1 -0
- package/lib/commonjs/ai-components/store/composer/useComposerIsEditing.js +18 -0
- package/lib/commonjs/ai-components/store/composer/useComposerIsEditing.js.map +1 -0
- package/lib/commonjs/ai-components/store/index.js +22 -0
- package/lib/commonjs/ai-components/store/index.js.map +1 -1
- package/lib/commonjs/ai-components/suggestions/AISuggestions.js +66 -0
- package/lib/commonjs/ai-components/suggestions/AISuggestions.js.map +1 -0
- package/lib/commonjs/ai-components/suggestions/index.js +15 -0
- package/lib/commonjs/ai-components/suggestions/index.js.map +1 -0
- package/lib/commonjs/ai-components/syntax-highlighting/utils/flatten-nodes.js +2 -1
- package/lib/commonjs/ai-components/syntax-highlighting/utils/flatten-nodes.js.map +1 -1
- package/lib/commonjs/ai-components/syntax-highlighting/utils/renderer.js +3 -2
- package/lib/commonjs/ai-components/syntax-highlighting/utils/renderer.js.map +1 -1
- package/lib/commonjs/ai-components/theme.js +137 -1
- package/lib/commonjs/ai-components/theme.js.map +1 -1
- package/lib/commonjs/ai-components/tool-calls/AIClientIdentity.js +22 -0
- package/lib/commonjs/ai-components/tool-calls/AIClientIdentity.js.map +1 -0
- package/lib/commonjs/ai-components/tool-calls/AIClientToolRunner.js +109 -0
- package/lib/commonjs/ai-components/tool-calls/AIClientToolRunner.js.map +1 -0
- package/lib/commonjs/ai-components/tool-calls/AIToolApprover.js +23 -0
- package/lib/commonjs/ai-components/tool-calls/AIToolApprover.js.map +1 -0
- package/lib/commonjs/ai-components/tool-calls/authSessionAuthorizer.js +88 -0
- package/lib/commonjs/ai-components/tool-calls/authSessionAuthorizer.js.map +1 -0
- package/lib/commonjs/ai-components/tool-calls/index.js +48 -0
- package/lib/commonjs/ai-components/tool-calls/index.js.map +1 -0
- package/lib/commonjs/ai-components/voice-visualization/glowShader.js.map +1 -1
- package/lib/commonjs/components/Accessibility/useAccessibilityAnnouncer.js.map +1 -1
- package/lib/commonjs/components/Message/MessageItemView/utils/renderText.js.map +1 -1
- package/lib/commonjs/contexts/translationContext/TranslationContext.js +2 -2
- package/lib/commonjs/contexts/translationContext/TranslationContext.js.map +1 -1
- package/lib/commonjs/i18n/ar.json +39 -1
- package/lib/commonjs/i18n/en.json +39 -1
- package/lib/commonjs/i18n/es.json +39 -1
- package/lib/commonjs/i18n/fr.json +39 -1
- package/lib/commonjs/i18n/he.json +39 -1
- package/lib/commonjs/i18n/hi.json +39 -1
- package/lib/commonjs/i18n/it.json +39 -1
- package/lib/commonjs/i18n/ja.json +39 -1
- package/lib/commonjs/i18n/ko.json +39 -1
- package/lib/commonjs/i18n/nl.json +39 -1
- package/lib/commonjs/i18n/pt-br.json +39 -1
- package/lib/commonjs/i18n/ru.json +39 -1
- package/lib/commonjs/i18n/tr.json +39 -1
- package/lib/commonjs/mock-builders/a2ui/ohrid.js +84 -0
- package/lib/commonjs/mock-builders/a2ui/ohrid.js.map +1 -0
- package/lib/commonjs/utils/i18n/Streami18n.js +9 -4
- package/lib/commonjs/utils/i18n/Streami18n.js.map +1 -1
- package/lib/commonjs/utils/i18n/utils.js +7 -0
- package/lib/commonjs/utils/i18n/utils.js.map +1 -0
- package/lib/commonjs/version.json +1 -1
- package/lib/module/a11y/a11yUtils.js.map +1 -1
- package/lib/module/a11y/hooks/useResolvedModalAccessibilityProps.js.map +1 -1
- package/lib/module/a2ui/A2UIContexts.js +8 -0
- package/lib/module/a2ui/A2UIContexts.js.map +1 -0
- package/lib/module/a2ui/A2UIInstructions.js +49 -0
- package/lib/module/a2ui/A2UIInstructions.js.map +1 -0
- package/lib/module/a2ui/A2UIPlaceholder.js +37 -0
- package/lib/module/a2ui/A2UIPlaceholder.js.map +1 -0
- package/lib/module/a2ui/A2UIRenderer.js +363 -0
- package/lib/module/a2ui/A2UIRenderer.js.map +1 -0
- package/lib/module/a2ui/A2UIStream.js +91 -0
- package/lib/module/a2ui/A2UIStream.js.map +1 -0
- package/lib/module/a2ui/A2UISurface.js +212 -0
- package/lib/module/a2ui/A2UISurface.js.map +1 -0
- package/lib/module/a2ui/basicCatalog.json +1206 -0
- package/lib/module/a2ui/basicFunctions.js +398 -0
- package/lib/module/a2ui/basicFunctions.js.map +1 -0
- package/lib/module/a2ui/catalogDocument.js +80 -0
- package/lib/module/a2ui/catalogDocument.js.map +1 -0
- package/lib/module/a2ui/catalogs.js +105 -0
- package/lib/module/a2ui/catalogs.js.map +1 -0
- package/lib/module/a2ui/components/DateTimeInput.js +445 -0
- package/lib/module/a2ui/components/DateTimeInput.js.map +1 -0
- package/lib/module/a2ui/components/Media.js +316 -0
- package/lib/module/a2ui/components/Media.js.map +1 -0
- package/lib/module/a2ui/components/basicComponents.js +975 -0
- package/lib/module/a2ui/components/basicComponents.js.map +1 -0
- package/lib/module/a2ui/components/iconPaths.js +66 -0
- package/lib/module/a2ui/components/iconPaths.js.map +1 -0
- package/lib/module/a2ui/components/types.js +4 -0
- package/lib/module/a2ui/components/types.js.map +1 -0
- package/lib/module/a2ui/index.js +70 -0
- package/lib/module/a2ui/index.js.map +1 -0
- package/lib/module/a2ui/instructions.js +268 -0
- package/lib/module/a2ui/instructions.js.map +1 -0
- package/lib/module/a2ui/secrets.js +169 -0
- package/lib/module/a2ui/secrets.js.map +1 -0
- package/lib/module/a2ui/useReplyState.js +35 -0
- package/lib/module/a2ui/useReplyState.js.map +1 -0
- package/lib/module/ai-components/AITypingIndicatorView.js +8 -18
- package/lib/module/ai-components/AITypingIndicatorView.js.map +1 -1
- package/lib/module/ai-components/README.md +55 -3
- package/lib/module/ai-components/StreamingMessageView.js +26 -0
- package/lib/module/ai-components/StreamingMessageView.js.map +1 -1
- package/lib/module/ai-components/charts/components/PieLegend.js +2 -1
- package/lib/module/ai-components/charts/components/PieLegend.js.map +1 -1
- package/lib/module/ai-components/charts/components/VictoryChart.js +7 -2
- package/lib/module/ai-components/charts/components/VictoryChart.js.map +1 -1
- package/lib/module/ai-components/charts/utils/format-time-label.js +15 -0
- package/lib/module/ai-components/charts/utils/format-time-label.js.map +1 -0
- package/lib/module/ai-components/charts/vega-lite/schema.js +17 -2
- package/lib/module/ai-components/charts/vega-lite/schema.js.map +1 -1
- package/lib/module/ai-components/contexts/composer-context.js +13 -6
- package/lib/module/ai-components/contexts/composer-context.js.map +1 -1
- package/lib/module/ai-components/contexts/index.js +11 -0
- package/lib/module/ai-components/contexts/index.js.map +1 -1
- package/lib/module/ai-components/contexts/theme-context.js +33 -2
- package/lib/module/ai-components/contexts/theme-context.js.map +1 -1
- package/lib/module/ai-components/contexts/translation-context.js +29 -0
- package/lib/module/ai-components/contexts/translation-context.js.map +1 -0
- package/lib/module/ai-components/conversation/AIConversation.js +366 -0
- package/lib/module/ai-components/conversation/AIConversation.js.map +1 -0
- package/lib/module/ai-components/conversation/controller/AIAgentError.js +13 -0
- package/lib/module/ai-components/conversation/controller/AIAgentError.js.map +1 -0
- package/lib/module/ai-components/conversation/controller/AIConversationController.js +425 -0
- package/lib/module/ai-components/conversation/controller/AIConversationController.js.map +1 -0
- package/lib/module/ai-components/conversation/controller/AIConversationExchange.js +89 -0
- package/lib/module/ai-components/conversation/controller/AIConversationExchange.js.map +1 -0
- package/lib/module/ai-components/conversation/controller/index.js +48 -0
- package/lib/module/ai-components/conversation/controller/index.js.map +1 -0
- package/lib/module/ai-components/conversation/controller/offers.js +29 -0
- package/lib/module/ai-components/conversation/controller/offers.js.map +1 -0
- package/lib/module/ai-components/conversation/controller/types.js +13 -0
- package/lib/module/ai-components/conversation/controller/types.js.map +1 -0
- package/lib/module/ai-components/conversation/controller/useAIConversationState.js +8 -0
- package/lib/module/ai-components/conversation/controller/useAIConversationState.js.map +1 -0
- package/lib/module/ai-components/conversation/entries.js +98 -0
- package/lib/module/ai-components/conversation/entries.js.map +1 -0
- package/lib/module/ai-components/conversation/fromStreamMessage.js +66 -0
- package/lib/module/ai-components/conversation/fromStreamMessage.js.map +1 -0
- package/lib/module/ai-components/conversation/index.js +48 -0
- package/lib/module/ai-components/conversation/index.js.map +1 -0
- package/lib/module/ai-components/conversation/list/AIChatList.js +224 -0
- package/lib/module/ai-components/conversation/list/AIChatList.js.map +1 -0
- package/lib/module/ai-components/conversation/list/useChatListController.js +78 -0
- package/lib/module/ai-components/conversation/list/useChatListController.js.map +1 -0
- package/lib/module/ai-components/conversation/list/useEndInView.js +51 -0
- package/lib/module/ai-components/conversation/list/useEndInView.js.map +1 -0
- package/lib/module/ai-components/conversation/list/useKeyboardOverlap.js +54 -0
- package/lib/module/ai-components/conversation/list/useKeyboardOverlap.js.map +1 -0
- package/lib/module/ai-components/conversation/list/useLoadOlder.js +73 -0
- package/lib/module/ai-components/conversation/list/useLoadOlder.js.map +1 -0
- package/lib/module/ai-components/conversation/list/usePinnedAnchor.js +84 -0
- package/lib/module/ai-components/conversation/list/usePinnedAnchor.js.map +1 -0
- package/lib/module/ai-components/conversation/types.js +4 -0
- package/lib/module/ai-components/conversation/types.js.map +1 -0
- package/lib/module/ai-components/conversation/useConversationRows.js +117 -0
- package/lib/module/ai-components/conversation/useConversationRows.js.map +1 -0
- package/lib/module/ai-components/generative-ui/AIUIAction.js +30 -0
- package/lib/module/ai-components/generative-ui/AIUIAction.js.map +1 -0
- package/lib/module/ai-components/generative-ui/AIUIArguments.js +128 -0
- package/lib/module/ai-components/generative-ui/AIUIArguments.js.map +1 -0
- package/lib/module/ai-components/generative-ui/AIUIComponent.js +50 -0
- package/lib/module/ai-components/generative-ui/AIUIComponent.js.map +1 -0
- package/lib/module/ai-components/generative-ui/AIUIComponentDefinition.js +134 -0
- package/lib/module/ai-components/generative-ui/AIUIComponentDefinition.js.map +1 -0
- package/lib/module/ai-components/generative-ui/AIUIDocument.js +32 -0
- package/lib/module/ai-components/generative-ui/AIUIDocument.js.map +1 -0
- package/lib/module/ai-components/generative-ui/AIUIEntrance.js +193 -0
- package/lib/module/ai-components/generative-ui/AIUIEntrance.js.map +1 -0
- package/lib/module/ai-components/generative-ui/AIUIErrorBoundary.js +30 -0
- package/lib/module/ai-components/generative-ui/AIUIErrorBoundary.js.map +1 -0
- package/lib/module/ai-components/generative-ui/AIUIHelpers.js +54 -0
- package/lib/module/ai-components/generative-ui/AIUIHelpers.js.map +1 -0
- package/lib/module/ai-components/generative-ui/AIUIHost.js +259 -0
- package/lib/module/ai-components/generative-ui/AIUIHost.js.map +1 -0
- package/lib/module/ai-components/generative-ui/AIUIMedia.js +24 -0
- package/lib/module/ai-components/generative-ui/AIUIMedia.js.map +1 -0
- package/lib/module/ai-components/generative-ui/AIUIRenderer.js +10 -0
- package/lib/module/ai-components/generative-ui/AIUIRenderer.js.map +1 -0
- package/lib/module/ai-components/generative-ui/AIUIView.js +57 -0
- package/lib/module/ai-components/generative-ui/AIUIView.js.map +1 -0
- package/lib/module/ai-components/generative-ui/index.js +181 -0
- package/lib/module/ai-components/generative-ui/index.js.map +1 -0
- package/lib/module/ai-components/icons.js +44 -0
- package/lib/module/ai-components/icons.js.map +1 -0
- package/lib/module/ai-components/index.js +96 -0
- package/lib/module/ai-components/index.js.map +1 -1
- package/lib/module/ai-components/internal/Shimmer.js +36 -0
- package/lib/module/ai-components/internal/Shimmer.js.map +1 -0
- package/lib/module/ai-components/internal/format.js +66 -0
- package/lib/module/ai-components/internal/format.js.map +1 -0
- package/lib/module/ai-components/internal/hooks/useBottomSafeArea.js +12 -0
- package/lib/module/ai-components/internal/hooks/useBottomSafeArea.js.map +1 -0
- package/lib/module/ai-components/internal/icons/AgentIcons.js +74 -0
- package/lib/module/ai-components/internal/icons/AgentIcons.js.map +1 -0
- package/lib/module/ai-components/internal/tokens.js +11 -0
- package/lib/module/ai-components/internal/tokens.js.map +1 -0
- package/lib/module/ai-components/internal/uuid.js +21 -0
- package/lib/module/ai-components/internal/uuid.js.map +1 -0
- package/lib/module/ai-components/markdown/components/CodeBlock.js +4 -2
- package/lib/module/ai-components/markdown/components/CodeBlock.js.map +1 -1
- package/lib/module/ai-components/markdown/components/InlineCode.js +1 -0
- package/lib/module/ai-components/markdown/components/InlineCode.js.map +1 -1
- package/lib/module/ai-components/markdown/components/Text.js +11 -2
- package/lib/module/ai-components/markdown/components/Text.js.map +1 -1
- package/lib/module/ai-components/markdown/styles.js +27 -29
- package/lib/module/ai-components/markdown/styles.js.map +1 -1
- package/lib/module/ai-components/message/AIAssistantMessage.js +63 -0
- package/lib/module/ai-components/message/AIAssistantMessage.js.map +1 -0
- package/lib/module/ai-components/message/AIMessageAttachment.js +189 -0
- package/lib/module/ai-components/message/AIMessageAttachment.js.map +1 -0
- package/lib/module/ai-components/message/AIReplyActions.js +132 -0
- package/lib/module/ai-components/message/AIReplyActions.js.map +1 -0
- package/lib/module/ai-components/message/AIUserMessage.js +104 -0
- package/lib/module/ai-components/message/AIUserMessage.js.map +1 -0
- package/lib/module/ai-components/message/UserMessageMenu.js +150 -0
- package/lib/module/ai-components/message/UserMessageMenu.js.map +1 -0
- package/lib/module/ai-components/message/index.js +48 -0
- package/lib/module/ai-components/message/index.js.map +1 -0
- package/lib/module/ai-components/message-composer/ActionButton.js +2 -1
- package/lib/module/ai-components/message-composer/ActionButton.js.map +1 -1
- package/lib/module/ai-components/message-composer/ActionSheet.js +22 -6
- package/lib/module/ai-components/message-composer/ActionSheet.js.map +1 -1
- package/lib/module/ai-components/message-composer/AttachmentButton.js +5 -1
- package/lib/module/ai-components/message-composer/AttachmentButton.js.map +1 -1
- package/lib/module/ai-components/message-composer/ChatOptions.js +147 -0
- package/lib/module/ai-components/message-composer/ChatOptions.js.map +1 -0
- package/lib/module/ai-components/message-composer/ComposerView.js +136 -20
- package/lib/module/ai-components/message-composer/ComposerView.js.map +1 -1
- package/lib/module/ai-components/message-composer/EditingMessageChip.js +80 -0
- package/lib/module/ai-components/message-composer/EditingMessageChip.js.map +1 -0
- package/lib/module/ai-components/message-composer/MediaPreviewList.js +26 -1
- package/lib/module/ai-components/message-composer/MediaPreviewList.js.map +1 -1
- package/lib/module/ai-components/message-composer/index.js +11 -0
- package/lib/module/ai-components/message-composer/index.js.map +1 -1
- package/lib/module/ai-components/message-parts/AIMessageParts.js +110 -0
- package/lib/module/ai-components/message-parts/AIMessageParts.js.map +1 -0
- package/lib/module/ai-components/message-parts/AIToolApproval.js +197 -0
- package/lib/module/ai-components/message-parts/AIToolApproval.js.map +1 -0
- package/lib/module/ai-components/message-parts/AIToolAuthorization.js +250 -0
- package/lib/module/ai-components/message-parts/AIToolAuthorization.js.map +1 -0
- package/lib/module/ai-components/message-parts/AIToolCall.js +159 -0
- package/lib/module/ai-components/message-parts/AIToolCall.js.map +1 -0
- package/lib/module/ai-components/message-parts/callStates.js +54 -0
- package/lib/module/ai-components/message-parts/callStates.js.map +1 -0
- package/lib/module/ai-components/message-parts/index.js +70 -0
- package/lib/module/ai-components/message-parts/index.js.map +1 -0
- package/lib/module/ai-components/message-parts/parseMessageParts.js +126 -0
- package/lib/module/ai-components/message-parts/parseMessageParts.js.map +1 -0
- package/lib/module/ai-components/message-parts/types.js +2 -0
- package/lib/module/ai-components/message-parts/types.js.map +1 -0
- package/lib/module/ai-components/native-specs/NativeAIAgent.js +7 -0
- package/lib/module/ai-components/native-specs/NativeAIAgent.js.map +1 -0
- package/lib/module/ai-components/reasoning/AIReasoning.js +401 -0
- package/lib/module/ai-components/reasoning/AIReasoning.js.map +1 -0
- package/lib/module/ai-components/reasoning/index.js +26 -0
- package/lib/module/ai-components/reasoning/index.js.map +1 -0
- package/lib/module/ai-components/reasoning/thinkingClock.js +63 -0
- package/lib/module/ai-components/reasoning/thinkingClock.js.map +1 -0
- package/lib/module/ai-components/services/clipboard-service/expo.js +7 -2
- package/lib/module/ai-components/services/clipboard-service/expo.js.map +1 -1
- package/lib/module/ai-components/store/composer/store.js.map +1 -1
- package/lib/module/ai-components/store/composer/useComposerChatOption.js +18 -0
- package/lib/module/ai-components/store/composer/useComposerChatOption.js.map +1 -0
- package/lib/module/ai-components/store/composer/useComposerIsEditing.js +18 -0
- package/lib/module/ai-components/store/composer/useComposerIsEditing.js.map +1 -0
- package/lib/module/ai-components/store/index.js +22 -0
- package/lib/module/ai-components/store/index.js.map +1 -1
- package/lib/module/ai-components/suggestions/AISuggestions.js +66 -0
- package/lib/module/ai-components/suggestions/AISuggestions.js.map +1 -0
- package/lib/module/ai-components/suggestions/index.js +15 -0
- package/lib/module/ai-components/suggestions/index.js.map +1 -0
- package/lib/module/ai-components/syntax-highlighting/utils/flatten-nodes.js +2 -1
- package/lib/module/ai-components/syntax-highlighting/utils/flatten-nodes.js.map +1 -1
- package/lib/module/ai-components/syntax-highlighting/utils/renderer.js +3 -2
- package/lib/module/ai-components/syntax-highlighting/utils/renderer.js.map +1 -1
- package/lib/module/ai-components/theme.js +137 -1
- package/lib/module/ai-components/theme.js.map +1 -1
- package/lib/module/ai-components/tool-calls/AIClientIdentity.js +22 -0
- package/lib/module/ai-components/tool-calls/AIClientIdentity.js.map +1 -0
- package/lib/module/ai-components/tool-calls/AIClientToolRunner.js +109 -0
- package/lib/module/ai-components/tool-calls/AIClientToolRunner.js.map +1 -0
- package/lib/module/ai-components/tool-calls/AIToolApprover.js +23 -0
- package/lib/module/ai-components/tool-calls/AIToolApprover.js.map +1 -0
- package/lib/module/ai-components/tool-calls/authSessionAuthorizer.js +88 -0
- package/lib/module/ai-components/tool-calls/authSessionAuthorizer.js.map +1 -0
- package/lib/module/ai-components/tool-calls/index.js +48 -0
- package/lib/module/ai-components/tool-calls/index.js.map +1 -0
- package/lib/module/ai-components/voice-visualization/glowShader.js.map +1 -1
- package/lib/module/components/Accessibility/useAccessibilityAnnouncer.js.map +1 -1
- package/lib/module/components/Message/MessageItemView/utils/renderText.js.map +1 -1
- package/lib/module/contexts/translationContext/TranslationContext.js +2 -2
- package/lib/module/contexts/translationContext/TranslationContext.js.map +1 -1
- package/lib/module/i18n/ar.json +39 -1
- package/lib/module/i18n/en.json +39 -1
- package/lib/module/i18n/es.json +39 -1
- package/lib/module/i18n/fr.json +39 -1
- package/lib/module/i18n/he.json +39 -1
- package/lib/module/i18n/hi.json +39 -1
- package/lib/module/i18n/it.json +39 -1
- package/lib/module/i18n/ja.json +39 -1
- package/lib/module/i18n/ko.json +39 -1
- package/lib/module/i18n/nl.json +39 -1
- package/lib/module/i18n/pt-br.json +39 -1
- package/lib/module/i18n/ru.json +39 -1
- package/lib/module/i18n/tr.json +39 -1
- package/lib/module/mock-builders/a2ui/ohrid.js +84 -0
- package/lib/module/mock-builders/a2ui/ohrid.js.map +1 -0
- package/lib/module/utils/i18n/Streami18n.js +9 -4
- package/lib/module/utils/i18n/Streami18n.js.map +1 -1
- package/lib/module/utils/i18n/utils.js +7 -0
- package/lib/module/utils/i18n/utils.js.map +1 -0
- package/lib/module/version.json +1 -1
- package/lib/typescript/a11y/a11yUtils.d.ts +0 -1
- package/lib/typescript/a11y/a11yUtils.d.ts.map +1 -1
- package/lib/typescript/a11y/hooks/useResolvedModalAccessibilityProps.d.ts +2 -3
- package/lib/typescript/a11y/hooks/useResolvedModalAccessibilityProps.d.ts.map +1 -1
- package/lib/typescript/a2ui/A2UIContexts.d.ts +9 -0
- package/lib/typescript/a2ui/A2UIContexts.d.ts.map +1 -0
- package/lib/typescript/a2ui/A2UIInstructions.d.ts +47 -0
- package/lib/typescript/a2ui/A2UIInstructions.d.ts.map +1 -0
- package/lib/typescript/a2ui/A2UIPlaceholder.d.ts +4 -0
- package/lib/typescript/a2ui/A2UIPlaceholder.d.ts.map +1 -0
- package/lib/typescript/a2ui/A2UIRenderer.d.ts +130 -0
- package/lib/typescript/a2ui/A2UIRenderer.d.ts.map +1 -0
- package/lib/typescript/a2ui/A2UIStream.d.ts +23 -0
- package/lib/typescript/a2ui/A2UIStream.d.ts.map +1 -0
- package/lib/typescript/a2ui/A2UISurface.d.ts +19 -0
- package/lib/typescript/a2ui/A2UISurface.d.ts.map +1 -0
- package/lib/typescript/a2ui/basicFunctions.d.ts +10 -0
- package/lib/typescript/a2ui/basicFunctions.d.ts.map +1 -0
- package/lib/typescript/a2ui/catalogDocument.d.ts +56 -0
- package/lib/typescript/a2ui/catalogDocument.d.ts.map +1 -0
- package/lib/typescript/a2ui/catalogs.d.ts +42 -0
- package/lib/typescript/a2ui/catalogs.d.ts.map +1 -0
- package/lib/typescript/a2ui/components/DateTimeInput.d.ts +44 -0
- package/lib/typescript/a2ui/components/DateTimeInput.d.ts.map +1 -0
- package/lib/typescript/a2ui/components/Media.d.ts +27 -0
- package/lib/typescript/a2ui/components/Media.d.ts.map +1 -0
- package/lib/typescript/a2ui/components/basicComponents.d.ts +4 -0
- package/lib/typescript/a2ui/components/basicComponents.d.ts.map +1 -0
- package/lib/typescript/a2ui/components/iconPaths.d.ts +2 -0
- package/lib/typescript/a2ui/components/iconPaths.d.ts.map +1 -0
- package/lib/typescript/a2ui/components/types.d.ts +23 -0
- package/lib/typescript/a2ui/components/types.d.ts.map +1 -0
- package/lib/typescript/a2ui/index.d.ts +8 -0
- package/lib/typescript/a2ui/index.d.ts.map +1 -0
- package/lib/typescript/a2ui/instructions.d.ts +39 -0
- package/lib/typescript/a2ui/instructions.d.ts.map +1 -0
- package/lib/typescript/a2ui/secrets.d.ts +20 -0
- package/lib/typescript/a2ui/secrets.d.ts.map +1 -0
- package/lib/typescript/a2ui/useReplyState.d.ts +4 -0
- package/lib/typescript/a2ui/useReplyState.d.ts.map +1 -0
- package/lib/typescript/ai-components/AITypingIndicatorView.d.ts.map +1 -1
- package/lib/typescript/ai-components/StreamingMessageView.d.ts +4 -1
- package/lib/typescript/ai-components/StreamingMessageView.d.ts.map +1 -1
- package/lib/typescript/ai-components/charts/components/PieLegend.d.ts.map +1 -1
- package/lib/typescript/ai-components/charts/components/VictoryChart.d.ts.map +1 -1
- package/lib/typescript/ai-components/charts/utils/format-time-label.d.ts +7 -0
- package/lib/typescript/ai-components/charts/utils/format-time-label.d.ts.map +1 -0
- package/lib/typescript/ai-components/charts/vega-lite/schema.d.ts +8 -8
- package/lib/typescript/ai-components/charts/vega-lite/schema.d.ts.map +1 -1
- package/lib/typescript/ai-components/contexts/composer-context.d.ts +3 -0
- package/lib/typescript/ai-components/contexts/composer-context.d.ts.map +1 -1
- package/lib/typescript/ai-components/contexts/index.d.ts +1 -0
- package/lib/typescript/ai-components/contexts/index.d.ts.map +1 -1
- package/lib/typescript/ai-components/contexts/theme-context.d.ts.map +1 -1
- package/lib/typescript/ai-components/contexts/translation-context.d.ts +19 -0
- package/lib/typescript/ai-components/contexts/translation-context.d.ts.map +1 -0
- package/lib/typescript/ai-components/conversation/AIConversation.d.ts +130 -0
- package/lib/typescript/ai-components/conversation/AIConversation.d.ts.map +1 -0
- package/lib/typescript/ai-components/conversation/controller/AIAgentError.d.ts +10 -0
- package/lib/typescript/ai-components/conversation/controller/AIAgentError.d.ts.map +1 -0
- package/lib/typescript/ai-components/conversation/controller/AIConversationController.d.ts +173 -0
- package/lib/typescript/ai-components/conversation/controller/AIConversationController.d.ts.map +1 -0
- package/lib/typescript/ai-components/conversation/controller/AIConversationExchange.d.ts +23 -0
- package/lib/typescript/ai-components/conversation/controller/AIConversationExchange.d.ts.map +1 -0
- package/lib/typescript/ai-components/conversation/controller/index.d.ts +5 -0
- package/lib/typescript/ai-components/conversation/controller/index.d.ts.map +1 -0
- package/lib/typescript/ai-components/conversation/controller/offers.d.ts +23 -0
- package/lib/typescript/ai-components/conversation/controller/offers.d.ts.map +1 -0
- package/lib/typescript/ai-components/conversation/controller/types.d.ts +142 -0
- package/lib/typescript/ai-components/conversation/controller/types.d.ts.map +1 -0
- package/lib/typescript/ai-components/conversation/controller/useAIConversationState.d.ts +9 -0
- package/lib/typescript/ai-components/conversation/controller/useAIConversationState.d.ts.map +1 -0
- package/lib/typescript/ai-components/conversation/entries.d.ts +47 -0
- package/lib/typescript/ai-components/conversation/entries.d.ts.map +1 -0
- package/lib/typescript/ai-components/conversation/fromStreamMessage.d.ts +25 -0
- package/lib/typescript/ai-components/conversation/fromStreamMessage.d.ts.map +1 -0
- package/lib/typescript/ai-components/conversation/index.d.ts +6 -0
- package/lib/typescript/ai-components/conversation/index.d.ts.map +1 -0
- package/lib/typescript/ai-components/conversation/list/AIChatList.d.ts +30 -0
- package/lib/typescript/ai-components/conversation/list/AIChatList.d.ts.map +1 -0
- package/lib/typescript/ai-components/conversation/list/useChatListController.d.ts +45 -0
- package/lib/typescript/ai-components/conversation/list/useChatListController.d.ts.map +1 -0
- package/lib/typescript/ai-components/conversation/list/useEndInView.d.ts +26 -0
- package/lib/typescript/ai-components/conversation/list/useEndInView.d.ts.map +1 -0
- package/lib/typescript/ai-components/conversation/list/useKeyboardOverlap.d.ts +17 -0
- package/lib/typescript/ai-components/conversation/list/useKeyboardOverlap.d.ts.map +1 -0
- package/lib/typescript/ai-components/conversation/list/useLoadOlder.d.ts +24 -0
- package/lib/typescript/ai-components/conversation/list/useLoadOlder.d.ts.map +1 -0
- package/lib/typescript/ai-components/conversation/list/usePinnedAnchor.d.ts +26 -0
- package/lib/typescript/ai-components/conversation/list/usePinnedAnchor.d.ts.map +1 -0
- package/lib/typescript/ai-components/conversation/types.d.ts +55 -0
- package/lib/typescript/ai-components/conversation/types.d.ts.map +1 -0
- package/lib/typescript/ai-components/conversation/useConversationRows.d.ts +66 -0
- package/lib/typescript/ai-components/conversation/useConversationRows.d.ts.map +1 -0
- package/lib/typescript/ai-components/generative-ui/AIUIAction.d.ts +48 -0
- package/lib/typescript/ai-components/generative-ui/AIUIAction.d.ts.map +1 -0
- package/lib/typescript/ai-components/generative-ui/AIUIArguments.d.ts +15 -0
- package/lib/typescript/ai-components/generative-ui/AIUIArguments.d.ts.map +1 -0
- package/lib/typescript/ai-components/generative-ui/AIUIComponent.d.ts +51 -0
- package/lib/typescript/ai-components/generative-ui/AIUIComponent.d.ts.map +1 -0
- package/lib/typescript/ai-components/generative-ui/AIUIComponentDefinition.d.ts +84 -0
- package/lib/typescript/ai-components/generative-ui/AIUIComponentDefinition.d.ts.map +1 -0
- package/lib/typescript/ai-components/generative-ui/AIUIDocument.d.ts +50 -0
- package/lib/typescript/ai-components/generative-ui/AIUIDocument.d.ts.map +1 -0
- package/lib/typescript/ai-components/generative-ui/AIUIEntrance.d.ts +75 -0
- package/lib/typescript/ai-components/generative-ui/AIUIEntrance.d.ts.map +1 -0
- package/lib/typescript/ai-components/generative-ui/AIUIErrorBoundary.d.ts +26 -0
- package/lib/typescript/ai-components/generative-ui/AIUIErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/ai-components/generative-ui/AIUIHelpers.d.ts +23 -0
- package/lib/typescript/ai-components/generative-ui/AIUIHelpers.d.ts.map +1 -0
- package/lib/typescript/ai-components/generative-ui/AIUIHost.d.ts +160 -0
- package/lib/typescript/ai-components/generative-ui/AIUIHost.d.ts.map +1 -0
- package/lib/typescript/ai-components/generative-ui/AIUIMedia.d.ts +22 -0
- package/lib/typescript/ai-components/generative-ui/AIUIMedia.d.ts.map +1 -0
- package/lib/typescript/ai-components/generative-ui/AIUIRenderer.d.ts +53 -0
- package/lib/typescript/ai-components/generative-ui/AIUIRenderer.d.ts.map +1 -0
- package/lib/typescript/ai-components/generative-ui/AIUIView.d.ts +35 -0
- package/lib/typescript/ai-components/generative-ui/AIUIView.d.ts.map +1 -0
- package/lib/typescript/ai-components/generative-ui/index.d.ts +11 -0
- package/lib/typescript/ai-components/generative-ui/index.d.ts.map +1 -0
- package/lib/typescript/ai-components/icons.d.ts +66 -0
- package/lib/typescript/ai-components/icons.d.ts.map +1 -0
- package/lib/typescript/ai-components/index.d.ts +8 -0
- package/lib/typescript/ai-components/index.d.ts.map +1 -1
- package/lib/typescript/ai-components/internal/Shimmer.d.ts +14 -0
- package/lib/typescript/ai-components/internal/Shimmer.d.ts.map +1 -0
- package/lib/typescript/ai-components/internal/format.d.ts +7 -0
- package/lib/typescript/ai-components/internal/format.d.ts.map +1 -0
- package/lib/typescript/ai-components/internal/hooks/useBottomSafeArea.d.ts +3 -0
- package/lib/typescript/ai-components/internal/hooks/useBottomSafeArea.d.ts.map +1 -0
- package/lib/typescript/ai-components/internal/icons/AgentIcons.d.ts +31 -0
- package/lib/typescript/ai-components/internal/icons/AgentIcons.d.ts.map +1 -0
- package/lib/typescript/ai-components/internal/tokens.d.ts +2 -0
- package/lib/typescript/ai-components/internal/tokens.d.ts.map +1 -0
- package/lib/typescript/ai-components/internal/uuid.d.ts +2 -0
- package/lib/typescript/ai-components/internal/uuid.d.ts.map +1 -0
- package/lib/typescript/ai-components/markdown/components/CodeBlock.d.ts.map +1 -1
- package/lib/typescript/ai-components/markdown/components/InlineCode.d.ts.map +1 -1
- package/lib/typescript/ai-components/markdown/components/Text.d.ts.map +1 -1
- package/lib/typescript/ai-components/markdown/styles.d.ts +23 -4
- package/lib/typescript/ai-components/markdown/styles.d.ts.map +1 -1
- package/lib/typescript/ai-components/markdown/types.d.ts +1 -0
- package/lib/typescript/ai-components/markdown/types.d.ts.map +1 -1
- package/lib/typescript/ai-components/message/AIAssistantMessage.d.ts +40 -0
- package/lib/typescript/ai-components/message/AIAssistantMessage.d.ts.map +1 -0
- package/lib/typescript/ai-components/message/AIMessageAttachment.d.ts +33 -0
- package/lib/typescript/ai-components/message/AIMessageAttachment.d.ts.map +1 -0
- package/lib/typescript/ai-components/message/AIReplyActions.d.ts +19 -0
- package/lib/typescript/ai-components/message/AIReplyActions.d.ts.map +1 -0
- package/lib/typescript/ai-components/message/AIUserMessage.d.ts +17 -0
- package/lib/typescript/ai-components/message/AIUserMessage.d.ts.map +1 -0
- package/lib/typescript/ai-components/message/UserMessageMenu.d.ts +31 -0
- package/lib/typescript/ai-components/message/UserMessageMenu.d.ts.map +1 -0
- package/lib/typescript/ai-components/message/index.d.ts +5 -0
- package/lib/typescript/ai-components/message/index.d.ts.map +1 -0
- package/lib/typescript/ai-components/message-composer/ActionButton.d.ts.map +1 -1
- package/lib/typescript/ai-components/message-composer/ActionSheet.d.ts +2 -2
- package/lib/typescript/ai-components/message-composer/ActionSheet.d.ts.map +1 -1
- package/lib/typescript/ai-components/message-composer/AttachmentButton.d.ts.map +1 -1
- package/lib/typescript/ai-components/message-composer/ChatOptions.d.ts +35 -0
- package/lib/typescript/ai-components/message-composer/ChatOptions.d.ts.map +1 -0
- package/lib/typescript/ai-components/message-composer/ComposerView.d.ts +34 -3
- package/lib/typescript/ai-components/message-composer/ComposerView.d.ts.map +1 -1
- package/lib/typescript/ai-components/message-composer/EditingMessageChip.d.ts +7 -0
- package/lib/typescript/ai-components/message-composer/EditingMessageChip.d.ts.map +1 -0
- package/lib/typescript/ai-components/message-composer/MediaPreviewList.d.ts.map +1 -1
- package/lib/typescript/ai-components/message-composer/index.d.ts +1 -0
- package/lib/typescript/ai-components/message-composer/index.d.ts.map +1 -1
- package/lib/typescript/ai-components/message-parts/AIMessageParts.d.ts +38 -0
- package/lib/typescript/ai-components/message-parts/AIMessageParts.d.ts.map +1 -0
- package/lib/typescript/ai-components/message-parts/AIToolApproval.d.ts +38 -0
- package/lib/typescript/ai-components/message-parts/AIToolApproval.d.ts.map +1 -0
- package/lib/typescript/ai-components/message-parts/AIToolAuthorization.d.ts +48 -0
- package/lib/typescript/ai-components/message-parts/AIToolAuthorization.d.ts.map +1 -0
- package/lib/typescript/ai-components/message-parts/AIToolCall.d.ts +11 -0
- package/lib/typescript/ai-components/message-parts/AIToolCall.d.ts.map +1 -0
- package/lib/typescript/ai-components/message-parts/callStates.d.ts +9 -0
- package/lib/typescript/ai-components/message-parts/callStates.d.ts.map +1 -0
- package/lib/typescript/ai-components/message-parts/index.d.ts +7 -0
- package/lib/typescript/ai-components/message-parts/index.d.ts.map +1 -0
- package/lib/typescript/ai-components/message-parts/parseMessageParts.d.ts +47 -0
- package/lib/typescript/ai-components/message-parts/parseMessageParts.d.ts.map +1 -0
- package/lib/typescript/ai-components/message-parts/types.d.ts +137 -0
- package/lib/typescript/ai-components/message-parts/types.d.ts.map +1 -0
- package/lib/typescript/ai-components/native-specs/NativeAIAgent.d.ts +22 -0
- package/lib/typescript/ai-components/native-specs/NativeAIAgent.d.ts.map +1 -0
- package/lib/typescript/ai-components/reasoning/AIReasoning.d.ts +63 -0
- package/lib/typescript/ai-components/reasoning/AIReasoning.d.ts.map +1 -0
- package/lib/typescript/ai-components/reasoning/index.d.ts +3 -0
- package/lib/typescript/ai-components/reasoning/index.d.ts.map +1 -0
- package/lib/typescript/ai-components/reasoning/thinkingClock.d.ts +29 -0
- package/lib/typescript/ai-components/reasoning/thinkingClock.d.ts.map +1 -0
- package/lib/typescript/ai-components/services/clipboard-service/expo.d.ts.map +1 -1
- package/lib/typescript/ai-components/store/composer/store.d.ts +8 -0
- package/lib/typescript/ai-components/store/composer/store.d.ts.map +1 -1
- package/lib/typescript/ai-components/store/composer/useComposerChatOption.d.ts +5 -0
- package/lib/typescript/ai-components/store/composer/useComposerChatOption.d.ts.map +1 -0
- package/lib/typescript/ai-components/store/composer/useComposerIsEditing.d.ts +5 -0
- package/lib/typescript/ai-components/store/composer/useComposerIsEditing.d.ts.map +1 -0
- package/lib/typescript/ai-components/store/index.d.ts +2 -0
- package/lib/typescript/ai-components/store/index.d.ts.map +1 -1
- package/lib/typescript/ai-components/suggestions/AISuggestions.d.ts +13 -0
- package/lib/typescript/ai-components/suggestions/AISuggestions.d.ts.map +1 -0
- package/lib/typescript/ai-components/suggestions/index.d.ts +2 -0
- package/lib/typescript/ai-components/suggestions/index.d.ts.map +1 -0
- package/lib/typescript/ai-components/syntax-highlighting/utils/flatten-nodes.d.ts.map +1 -1
- package/lib/typescript/ai-components/syntax-highlighting/utils/renderer.d.ts +1 -1
- package/lib/typescript/ai-components/syntax-highlighting/utils/renderer.d.ts.map +1 -1
- package/lib/typescript/ai-components/theme.d.ts +200 -0
- package/lib/typescript/ai-components/theme.d.ts.map +1 -1
- package/lib/typescript/ai-components/tool-calls/AIClientIdentity.d.ts +14 -0
- package/lib/typescript/ai-components/tool-calls/AIClientIdentity.d.ts.map +1 -0
- package/lib/typescript/ai-components/tool-calls/AIClientToolRunner.d.ts +109 -0
- package/lib/typescript/ai-components/tool-calls/AIClientToolRunner.d.ts.map +1 -0
- package/lib/typescript/ai-components/tool-calls/AIToolApprover.d.ts +48 -0
- package/lib/typescript/ai-components/tool-calls/AIToolApprover.d.ts.map +1 -0
- package/lib/typescript/ai-components/tool-calls/authSessionAuthorizer.d.ts +57 -0
- package/lib/typescript/ai-components/tool-calls/authSessionAuthorizer.d.ts.map +1 -0
- package/lib/typescript/ai-components/tool-calls/index.d.ts +5 -0
- package/lib/typescript/ai-components/tool-calls/index.d.ts.map +1 -0
- package/lib/typescript/ai-components/voice-visualization/glowShader.d.ts.map +1 -1
- package/lib/typescript/ai-components/voice-visualization/simplex.d.ts +1 -1
- package/lib/typescript/components/Accessibility/NotificationAnnouncer.d.ts +5 -5
- package/lib/typescript/components/Accessibility/hooks/useIncomingMessageAnnouncements.d.ts +1 -1
- package/lib/typescript/components/Accessibility/useAccessibilityAnnouncer.d.ts +0 -2
- package/lib/typescript/components/Accessibility/useAccessibilityAnnouncer.d.ts.map +1 -1
- package/lib/typescript/components/Message/MessageItemView/utils/renderText.d.ts.map +1 -1
- package/lib/typescript/contexts/translationContext/TranslationContext.d.ts +1 -1
- package/lib/typescript/contexts/translationContext/TranslationContext.d.ts.map +1 -1
- package/lib/typescript/i18n/ar.json +39 -1
- package/lib/typescript/i18n/en.json +39 -1
- package/lib/typescript/i18n/es.json +39 -1
- package/lib/typescript/i18n/fr.json +39 -1
- package/lib/typescript/i18n/he.json +39 -1
- package/lib/typescript/i18n/hi.json +39 -1
- package/lib/typescript/i18n/it.json +39 -1
- package/lib/typescript/i18n/ja.json +39 -1
- package/lib/typescript/i18n/ko.json +39 -1
- package/lib/typescript/i18n/nl.json +39 -1
- package/lib/typescript/i18n/pt-br.json +39 -1
- package/lib/typescript/i18n/ru.json +39 -1
- package/lib/typescript/i18n/tr.json +39 -1
- package/lib/typescript/utils/i18n/Streami18n.d.ts +40 -2
- package/lib/typescript/utils/i18n/Streami18n.d.ts.map +1 -1
- package/lib/typescript/utils/i18n/utils.d.ts +3 -0
- package/lib/typescript/utils/i18n/utils.d.ts.map +1 -0
- package/package.json +10 -2
- package/src/a11y/a11yUtils.ts +0 -1
- package/src/a11y/hooks/useResolvedModalAccessibilityProps.ts +2 -3
- package/src/a2ui/A2UIContexts.ts +15 -0
- package/src/a2ui/A2UIInstructions.ts +102 -0
- package/src/a2ui/A2UIPlaceholder.tsx +24 -0
- package/src/a2ui/A2UIRenderer.tsx +504 -0
- package/src/a2ui/A2UIStream.ts +105 -0
- package/src/a2ui/A2UISurface.tsx +241 -0
- package/src/a2ui/__tests__/A2UIInstructions.test.ts +233 -0
- package/src/a2ui/__tests__/A2UIRenderer.test.tsx +1514 -0
- package/src/a2ui/__tests__/conformance.test.ts +579 -0
- package/src/a2ui/basicCatalog.json +1206 -0
- package/src/a2ui/basicFunctions.ts +429 -0
- package/src/a2ui/catalogDocument.ts +119 -0
- package/src/a2ui/catalogs.ts +185 -0
- package/src/a2ui/components/DateTimeInput.tsx +381 -0
- package/src/a2ui/components/Media.tsx +278 -0
- package/src/a2ui/components/basicComponents.tsx +832 -0
- package/src/a2ui/components/iconPaths.ts +116 -0
- package/src/a2ui/components/types.ts +24 -0
- package/src/a2ui/index.ts +18 -0
- package/src/a2ui/instructions.ts +341 -0
- package/src/a2ui/secrets.ts +154 -0
- package/src/a2ui/useReplyState.ts +26 -0
- package/src/ai-components/AITypingIndicatorView.tsx +6 -22
- package/src/ai-components/README.md +55 -3
- package/src/ai-components/StreamingMessageView.tsx +27 -3
- package/src/ai-components/__tests__/ComposerView.test.tsx +227 -2
- package/src/ai-components/__tests__/Markdown.test.tsx +13 -0
- package/src/ai-components/__tests__/StreamingMessageView.test.tsx +69 -0
- package/src/ai-components/__tests__/charts.test.ts +75 -0
- package/src/ai-components/__tests__/clientToolRunner.test.ts +239 -0
- package/src/ai-components/__tests__/conversation.test.tsx +705 -0
- package/src/ai-components/__tests__/conversationController.test.ts +1561 -0
- package/src/ai-components/__tests__/conversationExchange.test.ts +187 -0
- package/src/ai-components/__tests__/conversationRows.test.ts +207 -0
- package/src/ai-components/__tests__/conversationUI.test.tsx +586 -0
- package/src/ai-components/__tests__/format.test.ts +32 -0
- package/src/ai-components/__tests__/generativeUI.test.ts +634 -0
- package/src/ai-components/__tests__/keyboard.test.ts +14 -0
- package/src/ai-components/__tests__/messagePartViews.test.tsx +343 -0
- package/src/ai-components/__tests__/messageParts.test.ts +336 -0
- package/src/ai-components/__tests__/messageViews.test.tsx +321 -0
- package/src/ai-components/__tests__/signIn.test.tsx +324 -0
- package/src/ai-components/__tests__/theme.test.tsx +18 -0
- package/src/ai-components/__tests__/translation.test.tsx +85 -0
- package/src/ai-components/__tests__/voiceDriver.test.ts +0 -3
- package/src/ai-components/__tests__/voicePalette.test.ts +1 -1
- package/src/ai-components/charts/components/PieLegend.tsx +2 -1
- package/src/ai-components/charts/components/VictoryChart.tsx +10 -2
- package/src/ai-components/charts/utils/format-time-label.ts +18 -0
- package/src/ai-components/charts/vega-lite/schema.ts +19 -2
- package/src/ai-components/contexts/composer-context.tsx +13 -5
- package/src/ai-components/contexts/index.ts +1 -0
- package/src/ai-components/contexts/theme-context.tsx +19 -4
- package/src/ai-components/contexts/translation-context.tsx +44 -0
- package/src/ai-components/conversation/AIConversation.tsx +590 -0
- package/src/ai-components/conversation/controller/AIAgentError.ts +14 -0
- package/src/ai-components/conversation/controller/AIConversationController.ts +623 -0
- package/src/ai-components/conversation/controller/AIConversationExchange.ts +132 -0
- package/src/ai-components/conversation/controller/index.ts +4 -0
- package/src/ai-components/conversation/controller/offers.ts +43 -0
- package/src/ai-components/conversation/controller/types.ts +154 -0
- package/src/ai-components/conversation/controller/useAIConversationState.ts +21 -0
- package/src/ai-components/conversation/entries.ts +177 -0
- package/src/ai-components/conversation/fromStreamMessage.ts +87 -0
- package/src/ai-components/conversation/index.ts +5 -0
- package/src/ai-components/conversation/list/AIChatList.tsx +227 -0
- package/src/ai-components/conversation/list/useChatListController.ts +91 -0
- package/src/ai-components/conversation/list/useEndInView.ts +61 -0
- package/src/ai-components/conversation/list/useKeyboardOverlap.ts +51 -0
- package/src/ai-components/conversation/list/useLoadOlder.ts +97 -0
- package/src/ai-components/conversation/list/usePinnedAnchor.ts +113 -0
- package/src/ai-components/conversation/types.ts +57 -0
- package/src/ai-components/conversation/useConversationRows.ts +230 -0
- package/src/ai-components/generative-ui/AIUIAction.ts +73 -0
- package/src/ai-components/generative-ui/AIUIArguments.ts +117 -0
- package/src/ai-components/generative-ui/AIUIComponent.tsx +106 -0
- package/src/ai-components/generative-ui/AIUIComponentDefinition.ts +163 -0
- package/src/ai-components/generative-ui/AIUIDocument.ts +77 -0
- package/src/ai-components/generative-ui/AIUIEntrance.tsx +223 -0
- package/src/ai-components/generative-ui/AIUIErrorBoundary.tsx +39 -0
- package/src/ai-components/generative-ui/AIUIHelpers.ts +86 -0
- package/src/ai-components/generative-ui/AIUIHost.ts +358 -0
- package/src/ai-components/generative-ui/AIUIMedia.ts +45 -0
- package/src/ai-components/generative-ui/AIUIRenderer.ts +60 -0
- package/src/ai-components/generative-ui/AIUIView.tsx +87 -0
- package/src/ai-components/generative-ui/index.ts +48 -0
- package/src/ai-components/icons.ts +101 -0
- package/src/ai-components/index.ts +10 -0
- package/src/ai-components/internal/Shimmer.tsx +40 -0
- package/src/ai-components/internal/format.ts +69 -0
- package/src/ai-components/internal/hooks/useBottomSafeArea.ts +6 -0
- package/src/ai-components/internal/icons/AgentIcons.tsx +138 -0
- package/src/ai-components/internal/tokens.ts +4 -0
- package/src/ai-components/internal/uuid.ts +17 -0
- package/src/ai-components/markdown/components/CodeBlock.tsx +13 -2
- package/src/ai-components/markdown/components/InlineCode.tsx +1 -0
- package/src/ai-components/markdown/components/Text.tsx +7 -2
- package/src/ai-components/markdown/styles.ts +29 -27
- package/src/ai-components/markdown/types.ts +1 -0
- package/src/ai-components/message/AIAssistantMessage.tsx +99 -0
- package/src/ai-components/message/AIMessageAttachment.tsx +245 -0
- package/src/ai-components/message/AIReplyActions.tsx +139 -0
- package/src/ai-components/message/AIUserMessage.tsx +121 -0
- package/src/ai-components/message/UserMessageMenu.tsx +149 -0
- package/src/ai-components/message/index.ts +4 -0
- package/src/ai-components/message-composer/ActionButton.tsx +5 -1
- package/src/ai-components/message-composer/ActionSheet.tsx +28 -6
- package/src/ai-components/message-composer/AttachmentButton.tsx +9 -1
- package/src/ai-components/message-composer/ChatOptions.tsx +144 -0
- package/src/ai-components/message-composer/ComposerView.tsx +179 -29
- package/src/ai-components/message-composer/EditingMessageChip.tsx +61 -0
- package/src/ai-components/message-composer/MediaPreviewList.tsx +34 -8
- package/src/ai-components/message-composer/index.ts +1 -0
- package/src/ai-components/message-parts/AIMessageParts.tsx +120 -0
- package/src/ai-components/message-parts/AIToolApproval.tsx +196 -0
- package/src/ai-components/message-parts/AIToolAuthorization.tsx +279 -0
- package/src/ai-components/message-parts/AIToolCall.tsx +117 -0
- package/src/ai-components/message-parts/callStates.ts +44 -0
- package/src/ai-components/message-parts/index.ts +6 -0
- package/src/ai-components/message-parts/parseMessageParts.ts +195 -0
- package/src/ai-components/message-parts/types.ts +157 -0
- package/src/ai-components/native-specs/NativeAIAgent.ts +25 -0
- package/src/ai-components/reasoning/AIReasoning.tsx +509 -0
- package/src/ai-components/reasoning/index.ts +2 -0
- package/src/ai-components/reasoning/thinkingClock.ts +109 -0
- package/src/ai-components/services/clipboard-service/expo.ts +18 -4
- package/src/ai-components/store/composer/store.ts +9 -0
- package/src/ai-components/store/composer/useComposerChatOption.ts +15 -0
- package/src/ai-components/store/composer/useComposerIsEditing.ts +15 -0
- package/src/ai-components/store/index.ts +2 -0
- package/src/ai-components/suggestions/AISuggestions.tsx +73 -0
- package/src/ai-components/suggestions/index.ts +1 -0
- package/src/ai-components/syntax-highlighting/utils/flatten-nodes.ts +2 -1
- package/src/ai-components/syntax-highlighting/utils/renderer.tsx +4 -2
- package/src/ai-components/theme.ts +334 -0
- package/src/ai-components/tool-calls/AIClientIdentity.ts +33 -0
- package/src/ai-components/tool-calls/AIClientToolRunner.ts +200 -0
- package/src/ai-components/tool-calls/AIToolApprover.tsx +60 -0
- package/src/ai-components/tool-calls/authSessionAuthorizer.ts +137 -0
- package/src/ai-components/tool-calls/index.ts +4 -0
- package/src/ai-components/voice-visualization/glowShader.ts +1 -3
- package/src/ai-components/voice-visualization/simplex.ts +1 -1
- package/src/components/Accessibility/NotificationAnnouncer.tsx +5 -5
- package/src/components/Accessibility/hooks/useIncomingMessageAnnouncements.ts +1 -1
- package/src/components/Accessibility/useAccessibilityAnnouncer.ts +0 -2
- package/src/components/Message/MessageItemView/utils/renderText.tsx +1 -2
- package/src/contexts/translationContext/TranslationContext.tsx +2 -2
- package/src/i18n/ar.json +39 -1
- package/src/i18n/en.json +39 -1
- package/src/i18n/es.json +39 -1
- package/src/i18n/fr.json +39 -1
- package/src/i18n/he.json +39 -1
- package/src/i18n/hi.json +39 -1
- package/src/i18n/it.json +39 -1
- package/src/i18n/ja.json +39 -1
- package/src/i18n/ko.json +39 -1
- package/src/i18n/nl.json +39 -1
- package/src/i18n/pt-br.json +39 -1
- package/src/i18n/ru.json +39 -1
- package/src/i18n/tr.json +39 -1
- package/src/mock-builders/a2ui/ohrid.ts +106 -0
- package/src/utils/i18n/Streami18n.ts +4 -1
- package/src/utils/i18n/utils.ts +3 -0
- package/src/version.json +1 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import isEqual from 'lodash/isEqual';
|
|
2
|
+
|
|
3
|
+
import type { AIConversationRequest } from './types';
|
|
4
|
+
|
|
5
|
+
import { generateUUIDv4 } from '../../internal/uuid';
|
|
6
|
+
import type { AIMessageAttachmentData } from '../../message/AIMessageAttachment';
|
|
7
|
+
import type { MediaAsset } from '../../services/media-picker-service/AbstractMediaPickerService';
|
|
8
|
+
import type { AIMessage, AIPendingMessage } from '../types';
|
|
9
|
+
|
|
10
|
+
// Where the request is: waiting for its reply, stopped by the person before it started, not
|
|
11
|
+
// sent because the transport failed, or not answered by the agent.
|
|
12
|
+
export type AIConversationExchangeState = 'waiting' | 'stopped' | 'failed' | 'unanswered';
|
|
13
|
+
|
|
14
|
+
// A reply the agent has started with no text, steps or attachments yet. Its generated UI can
|
|
15
|
+
// still show, when the conversation's host reads it.
|
|
16
|
+
export const hasEmptyContent = (message: AIMessage) =>
|
|
17
|
+
message.role !== 'user' &&
|
|
18
|
+
message.text === '' &&
|
|
19
|
+
!message.parts?.length &&
|
|
20
|
+
!message.attachments?.length;
|
|
21
|
+
|
|
22
|
+
// Whether a reply is written again since it was `original`: it started anew, or it shows
|
|
23
|
+
// something else.
|
|
24
|
+
const isRewritten = (message: AIMessage, original: AIMessage) =>
|
|
25
|
+
(!!message.isGenerating && !original.isGenerating) ||
|
|
26
|
+
message.text !== original.text ||
|
|
27
|
+
!isEqual(message.parts ?? [], original.parts ?? []) ||
|
|
28
|
+
!isEqual(message.attachments ?? [], original.attachments ?? []) ||
|
|
29
|
+
!isEqual(message.uiDocument, original.uiDocument);
|
|
30
|
+
|
|
31
|
+
export const attachmentOfAsset = (asset: MediaAsset): AIMessageAttachmentData => ({
|
|
32
|
+
kind: !asset.type || asset.type.startsWith('image') ? 'image' : 'file',
|
|
33
|
+
mimeType: asset.type?.includes('/') ? asset.type : undefined,
|
|
34
|
+
name: asset.name,
|
|
35
|
+
size: asset.size,
|
|
36
|
+
url: asset.uri,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// The latest request, until its reply starts or another request takes its place.
|
|
40
|
+
export class AIConversationExchange<Message extends AIMessage> {
|
|
41
|
+
state: AIConversationExchangeState = 'waiting';
|
|
42
|
+
// The messages there were when it was made, none of which is its reply.
|
|
43
|
+
readonly known: Set<string>;
|
|
44
|
+
// The messages it replaces, as they were, which the conversation leaves out while it waits:
|
|
45
|
+
// the reply written again, or the message edited, and those after it.
|
|
46
|
+
readonly replaced: Map<string, Message>;
|
|
47
|
+
// The person's message on its way.
|
|
48
|
+
readonly pending: AIPendingMessage | undefined;
|
|
49
|
+
|
|
50
|
+
constructor(
|
|
51
|
+
// Tells it apart from the requests before and after it.
|
|
52
|
+
readonly id: number,
|
|
53
|
+
readonly request: AIConversationRequest<Message>,
|
|
54
|
+
conversation: readonly Message[],
|
|
55
|
+
) {
|
|
56
|
+
this.known = new Set(conversation.map((message) => message.id));
|
|
57
|
+
const target = request.message
|
|
58
|
+
? conversation.findIndex((message) => message.id === request.message?.id)
|
|
59
|
+
: -1;
|
|
60
|
+
this.replaced = new Map(
|
|
61
|
+
target >= 0 && (request.kind === 'regenerate' || request.kind === 'edit')
|
|
62
|
+
? conversation.slice(target).map((message) => [message.id, message])
|
|
63
|
+
: [],
|
|
64
|
+
);
|
|
65
|
+
if (request.kind === 'regenerate') {
|
|
66
|
+
this.pending = undefined;
|
|
67
|
+
} else {
|
|
68
|
+
const edited = request.kind === 'edit' ? (request.message?.attachments ?? []) : [];
|
|
69
|
+
this.pending = {
|
|
70
|
+
attachments: [...edited, ...request.attachments.map(attachmentOfAsset)],
|
|
71
|
+
id: request.messageId,
|
|
72
|
+
text: request.text,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
get hasFailed() {
|
|
78
|
+
return this.state === 'failed' || this.state === 'unanswered';
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// The person's message while the conversation shows it: until its reply starts, and for a
|
|
82
|
+
// new message also once it is stopped or failed, since the agent may have it, or `retry()`
|
|
83
|
+
// sends it again. The messages an edit replaces come back instead.
|
|
84
|
+
get shownPending() {
|
|
85
|
+
return this.state === 'waiting' || this.request.kind === 'message' ? this.pending : undefined;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// The latest message when it is the request's reply: a reply that wasn't there, or one the
|
|
89
|
+
// request replaces, once it is written again.
|
|
90
|
+
reply(conversation: readonly Message[]) {
|
|
91
|
+
const last = conversation[conversation.length - 1];
|
|
92
|
+
if (!last || last.role === 'user') return undefined;
|
|
93
|
+
const original = this.replaced.get(last.id);
|
|
94
|
+
const rewritten = original ? isRewritten(last, original) : false;
|
|
95
|
+
return !this.known.has(last.id) || rewritten ? last : undefined;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Whether its reply has started: it shows something, or it is already finished.
|
|
99
|
+
hasReplyStarted(conversation: readonly Message[]) {
|
|
100
|
+
const reply = this.reply(conversation);
|
|
101
|
+
return !!reply && (!hasEmptyContent(reply) || !reply.isGenerating);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Whether the person's message is in the conversation: one with its id, or one of theirs
|
|
105
|
+
// after the messages there were.
|
|
106
|
+
hasMessageArrived(conversation: readonly Message[]) {
|
|
107
|
+
if (conversation.some((message) => message.id === this.request.messageId)) return true;
|
|
108
|
+
let lastKnown = -1;
|
|
109
|
+
conversation.forEach((message, index) => {
|
|
110
|
+
if (this.known.has(message.id)) lastKnown = index;
|
|
111
|
+
});
|
|
112
|
+
return conversation.slice(lastKnown + 1).some((message) => message.role === 'user');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// What `retry()` sends: the request again, or, when the agent had the person's message but
|
|
116
|
+
// couldn't answer it, a request for its reply, since sending it again would add it twice.
|
|
117
|
+
retryRequest(conversation: readonly Message[]): AIConversationRequest<Message> {
|
|
118
|
+
if (
|
|
119
|
+
this.state !== 'unanswered' ||
|
|
120
|
+
this.request.kind !== 'message' ||
|
|
121
|
+
!this.hasMessageArrived(conversation)
|
|
122
|
+
) {
|
|
123
|
+
return this.request;
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
attachments: [],
|
|
127
|
+
kind: 'regenerate',
|
|
128
|
+
messageId: generateUUIDv4(),
|
|
129
|
+
text: this.request.text,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type AIConversationStatus, isAIConversationAnswering } from './types';
|
|
2
|
+
|
|
3
|
+
import type { AIMessageRating, AIReplyActionsProps } from '../../message/AIReplyActions';
|
|
4
|
+
import type { AIMessage } from '../types';
|
|
5
|
+
|
|
6
|
+
type Offerer<Message extends AIMessage> = {
|
|
7
|
+
actions: { edit: boolean; rate: boolean; regenerate: boolean };
|
|
8
|
+
edit: (message: Message) => void;
|
|
9
|
+
rate: (reply: Message, rating: AIMessageRating | null) => void;
|
|
10
|
+
regenerate: (reply: Message) => void;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// What the person can do with a finished reply: rate it, and write it again while it is the
|
|
14
|
+
// latest and the agent isn't answering.
|
|
15
|
+
export const replyActionsOf = <Message extends AIMessage>(
|
|
16
|
+
offerer: Offerer<Message>,
|
|
17
|
+
{
|
|
18
|
+
ratings,
|
|
19
|
+
status,
|
|
20
|
+
}: { ratings: Readonly<Record<string, AIMessageRating>>; status: AIConversationStatus },
|
|
21
|
+
reply: Message,
|
|
22
|
+
isLatestReply: boolean,
|
|
23
|
+
): Omit<AIReplyActionsProps, 'text'> => ({
|
|
24
|
+
onRate: offerer.actions.rate ? (rating) => offerer.rate(reply, rating) : undefined,
|
|
25
|
+
onRegenerate:
|
|
26
|
+
offerer.actions.regenerate && isLatestReply && !isAIConversationAnswering(status)
|
|
27
|
+
? () => offerer.regenerate(reply)
|
|
28
|
+
: undefined,
|
|
29
|
+
rating: ratings[reply.id] ?? null,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Edits a message of the person's, when it is their latest and the agent isn't answering.
|
|
33
|
+
export const editActionOf = <Message extends AIMessage>(
|
|
34
|
+
offerer: Offerer<Message>,
|
|
35
|
+
{ messages, status }: { messages: readonly Message[]; status: AIConversationStatus },
|
|
36
|
+
message: Message,
|
|
37
|
+
): (() => void) | undefined => {
|
|
38
|
+
if (!offerer.actions.edit || message.role !== 'user' || isAIConversationAnswering(status)) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
const latest = [...messages].reverse().find((item) => item.role === 'user');
|
|
42
|
+
return latest?.id === message.id ? () => offerer.edit(message) : undefined;
|
|
43
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { AIMessageRating } from '../../message/AIReplyActions';
|
|
2
|
+
import type { AIChatOption } from '../../message-composer/ChatOptions';
|
|
3
|
+
import type { MediaAsset } from '../../services/media-picker-service/AbstractMediaPickerService';
|
|
4
|
+
import type { AIMessage } from '../types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Where the latest exchange with the agent is:
|
|
8
|
+
* - `ready`: nothing is on its way: the agent answered, or the person stopped it.
|
|
9
|
+
* - `submitted`: the person's request is on its way, or the agent is working on it and its reply
|
|
10
|
+
* shows nothing yet.
|
|
11
|
+
* - `streaming`: the agent is writing its reply.
|
|
12
|
+
* - `error`: the latest request failed, or the agent couldn't answer it. `retry()` tries again.
|
|
13
|
+
*/
|
|
14
|
+
export type AIConversationStatus = 'ready' | 'submitted' | 'streaming' | 'error';
|
|
15
|
+
|
|
16
|
+
/** Whether the agent is answering: the request is submitted, or its reply streaming. */
|
|
17
|
+
export const isAIConversationAnswering = (status: AIConversationStatus) =>
|
|
18
|
+
status === 'submitted' || status === 'streaming';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* What the person asks for:
|
|
22
|
+
* - `message`: a new message from the person.
|
|
23
|
+
* - `regenerate`: a new reply in place of the request's `message`, which is a reply, and of those
|
|
24
|
+
* after it. Without `message`, a reply to the latest message, which has none, such as after the
|
|
25
|
+
* agent couldn't answer it.
|
|
26
|
+
* - `edit`: the person changed the request's `message`, one of theirs, to say its `text`: it is
|
|
27
|
+
* answered again, in place of the replies after it.
|
|
28
|
+
*
|
|
29
|
+
* An open set: a kind of your own is on its way like a message.
|
|
30
|
+
*/
|
|
31
|
+
export type AIConversationRequestKind = 'message' | 'regenerate' | 'edit' | (string & {});
|
|
32
|
+
|
|
33
|
+
/** What the person asks the agent, as an `AIConversationTransport` sends it. */
|
|
34
|
+
export type AIConversationRequest<Message extends AIMessage = AIMessage> = {
|
|
35
|
+
/** What the person asks for. */
|
|
36
|
+
kind: AIConversationRequestKind;
|
|
37
|
+
/**
|
|
38
|
+
* An id for the person's message. A transport that creates the message with it lets the
|
|
39
|
+
* conversation find its copy by it. A retry of the request keeps it.
|
|
40
|
+
*/
|
|
41
|
+
messageId: string;
|
|
42
|
+
/** What the person wrote. When a reply is written again, the message it answers says it. */
|
|
43
|
+
text: string;
|
|
44
|
+
/** The files the person picked, on this device, to upload with their message. */
|
|
45
|
+
attachments: MediaAsset[];
|
|
46
|
+
/** The option the person picked in the composer, such as thinking harder. */
|
|
47
|
+
chatOption?: AIChatOption;
|
|
48
|
+
/** What the composer held besides, as `ComposerState.custom`. */
|
|
49
|
+
custom?: Record<string, unknown>;
|
|
50
|
+
/** The message it is about: the reply to write again, or the person's message they edited. */
|
|
51
|
+
message?: Message;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/** The ids of the states Stream Chat's AI indicator reports. */
|
|
55
|
+
export const AIAgentActivityStates = {
|
|
56
|
+
checkingExternalSources: 'AI_STATE_EXTERNAL_SOURCES',
|
|
57
|
+
error: 'AI_STATE_ERROR',
|
|
58
|
+
generating: 'AI_STATE_GENERATING',
|
|
59
|
+
thinking: 'AI_STATE_THINKING',
|
|
60
|
+
} as const;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* What the agent is doing. An open set: compare against the states you know. Those of
|
|
64
|
+
* `AIAgentActivityStates` are Stream Chat's AI indicator's.
|
|
65
|
+
*/
|
|
66
|
+
export type AIAgentActivityState =
|
|
67
|
+
| (typeof AIAgentActivityStates)[keyof typeof AIAgentActivityStates]
|
|
68
|
+
| (string & {});
|
|
69
|
+
|
|
70
|
+
/** What the agent says it is doing besides what its reply shows, such as checking sources. */
|
|
71
|
+
export type AIAgentActivity = {
|
|
72
|
+
state: AIAgentActivityState;
|
|
73
|
+
/** What it says about it, such as "Searching the web", or why it couldn't answer. */
|
|
74
|
+
text?: string;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/** What the conversation's views offer the person to do with its messages. All by default. */
|
|
78
|
+
export type AIConversationActions = {
|
|
79
|
+
/** Editing the person's latest message, which is then answered again. */
|
|
80
|
+
edit?: boolean;
|
|
81
|
+
/** Rating replies. */
|
|
82
|
+
rate?: boolean;
|
|
83
|
+
/** Asking for a new reply in place of the latest. */
|
|
84
|
+
regenerate?: boolean;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Where an `AIConversationTransport` tells its `AIConversationController` what the conversation
|
|
89
|
+
* holds. Once the controller is disposed, its updates go nowhere.
|
|
90
|
+
*/
|
|
91
|
+
export type AIConversationFeed<Message extends AIMessage = AIMessage> = {
|
|
92
|
+
/** Whether the controller it updates is still there. Stop following what it holds once it isn't. */
|
|
93
|
+
readonly isConnected: boolean;
|
|
94
|
+
/** The conversation's messages, oldest first, each time they change. */
|
|
95
|
+
updateMessages: (messages: readonly Message[]) => void;
|
|
96
|
+
/** Whether there are messages before the first one, which `loadOlderMessages` loads. */
|
|
97
|
+
updateHasOlderMessages: (hasOlderMessages: boolean) => void;
|
|
98
|
+
/** What the agent says it is doing, or `undefined` once it stops saying. */
|
|
99
|
+
updateActivity: (activity: AIAgentActivity | undefined) => void;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* How an `AIConversationController` reaches the agent and learns what it holds: it sends what the
|
|
104
|
+
* person asks, stops the agent, and tells the controller its messages as they change.
|
|
105
|
+
*
|
|
106
|
+
* With Stream Chat, the conversation is a channel: the transport follows its messages and AI
|
|
107
|
+
* indicator events, and sends each request through the channel or your agent's own API.
|
|
108
|
+
*
|
|
109
|
+
* ```ts
|
|
110
|
+
* const transport: AIConversationTransport = {
|
|
111
|
+
* connect: (feed) => {
|
|
112
|
+
* const update = () => feed.updateMessages(channel.state.messages.map(fromStreamMessage));
|
|
113
|
+
* update();
|
|
114
|
+
* return channel.on(update).unsubscribe;
|
|
115
|
+
* },
|
|
116
|
+
* send: (request) => agent.respond(request.text, request.attachments),
|
|
117
|
+
* stop: () => agent.interrupt(),
|
|
118
|
+
* };
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export type AIConversationTransport<Message extends AIMessage = AIMessage> = {
|
|
122
|
+
/**
|
|
123
|
+
* Starts telling `feed` what the conversation holds: its messages each time they change,
|
|
124
|
+
* whether there are older ones to load, and what the agent says it is doing. The controller
|
|
125
|
+
* calls it once, as it is made, and calls what it returns once it is disposed.
|
|
126
|
+
*/
|
|
127
|
+
connect: (feed: AIConversationFeed<Message>) => void | (() => void);
|
|
128
|
+
/**
|
|
129
|
+
* Sends what the person asks. Resolve once the agent has the request: its reply arrives
|
|
130
|
+
* through the feed. A rejection shows as the conversation's error, and the person can retry,
|
|
131
|
+
* which sends the same request again with the same `messageId`: if the first attempt reached
|
|
132
|
+
* your backend, or you keep a copy of the failed message, use the id so the message isn't added
|
|
133
|
+
* twice. A rejection with an `AbortError` ends the request without an error.
|
|
134
|
+
*
|
|
135
|
+
* The controller leaves out the messages a `regenerate` or an `edit` replaces only until the
|
|
136
|
+
* new reply starts. From then on it shows the messages as the feed has them, so update the
|
|
137
|
+
* conversation before the new reply arrives:
|
|
138
|
+
* - For a regenerate, remove the request's `message` and the messages after it, or write the
|
|
139
|
+
* new reply in place of `message`, under its id.
|
|
140
|
+
* - For an edit, change the person's `message` to say the request's `text`, under its id, and
|
|
141
|
+
* remove the messages after it.
|
|
142
|
+
*/
|
|
143
|
+
send: (request: AIConversationRequest<Message>) => Promise<void>;
|
|
144
|
+
/** Stops the reply the agent is writing. What it wrote so far stays. */
|
|
145
|
+
stop: () => Promise<void>;
|
|
146
|
+
/** Loads the messages before the first one, which arrive through the feed. */
|
|
147
|
+
loadOlderMessages?: () => Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* Tells your backend how the person rated a reply, or that they took their rating back with
|
|
150
|
+
* `null`. Without it, the controller keeps the ratings on this device. Ratings your backend has
|
|
151
|
+
* show through each message's `rating`.
|
|
152
|
+
*/
|
|
153
|
+
rate?: (reply: Message, rating: AIMessageRating | null) => Promise<void>;
|
|
154
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useStateStore } from '@stream-io/state-store/react-bindings';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
AIConversationController,
|
|
5
|
+
AIConversationControllerState,
|
|
6
|
+
} from './AIConversationController';
|
|
7
|
+
|
|
8
|
+
import type { AIMessage } from '../types';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Follows what `selector` picks of a conversation's state, such as its `status` or `error`: the
|
|
12
|
+
* component renders again when it changes. Keep `selector` outside the component, so it stays the
|
|
13
|
+
* same between renders.
|
|
14
|
+
*/
|
|
15
|
+
export const useAIConversationState = <
|
|
16
|
+
Message extends AIMessage,
|
|
17
|
+
Selected extends Readonly<Record<string, unknown>>,
|
|
18
|
+
>(
|
|
19
|
+
conversation: AIConversationController<Message>,
|
|
20
|
+
selector: (state: AIConversationControllerState<Message>) => Selected,
|
|
21
|
+
) => useStateStore(conversation.state, selector);
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { AIMessage, AIPendingMessage } from './types';
|
|
2
|
+
|
|
3
|
+
import type { AIUIDocument } from '../generative-ui/AIUIDocument';
|
|
4
|
+
import type { AIMessageAttachmentData } from '../message/AIMessageAttachment';
|
|
5
|
+
import { isToolCallFinished } from '../message-parts/parseMessageParts';
|
|
6
|
+
|
|
7
|
+
/** A row of the conversation: a message, or a message the person sent that is on its way. */
|
|
8
|
+
export type AIConversationEntry = {
|
|
9
|
+
/** The message's id, or, for the copy of a message that was on its way, that message's. */
|
|
10
|
+
id: string;
|
|
11
|
+
isFromUser: boolean;
|
|
12
|
+
/** Whether it is a reply that ends the conversation. */
|
|
13
|
+
isLatestReply: boolean;
|
|
14
|
+
/** The message, or `undefined` for one on its way. */
|
|
15
|
+
message?: AIMessage;
|
|
16
|
+
/** The message on its way, until its copy arrives. */
|
|
17
|
+
pending?: AIPendingMessage;
|
|
18
|
+
/** What the person sent with a message on its way, which its copy shows rather than load it again. */
|
|
19
|
+
sentAttachments: AIMessageAttachmentData[];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** The person's message and the replies to it. */
|
|
23
|
+
export type AIConversationTurn = { entries: AIConversationEntry[]; id: string };
|
|
24
|
+
|
|
25
|
+
/** Whether a reply's generated UI shows, such as `AIUIHost.canShow`. */
|
|
26
|
+
export type AIConversationCanShowUI = (document: AIUIDocument) => boolean;
|
|
27
|
+
|
|
28
|
+
const showsNoUI: AIConversationCanShowUI = () => false;
|
|
29
|
+
|
|
30
|
+
// A reply the agent has started but that has nothing to show yet: no text, steps or attachments,
|
|
31
|
+
// and no UI that `canShowUI` says shows.
|
|
32
|
+
const showsNothing = (message: AIMessage, canShowUI: AIConversationCanShowUI) =>
|
|
33
|
+
message.role !== 'user' &&
|
|
34
|
+
message.text === '' &&
|
|
35
|
+
!message.parts?.length &&
|
|
36
|
+
!message.attachments?.length &&
|
|
37
|
+
!(message.uiDocument && canShowUI(message.uiDocument));
|
|
38
|
+
|
|
39
|
+
// Whether a step is over: a round of reasoning that stopped streaming, or a call that finished.
|
|
40
|
+
// A step of a kind this SDK doesn't know counts as over, since it can't say otherwise.
|
|
41
|
+
const isStepOver = ({ reasoning, toolCall }: NonNullable<AIMessage['parts']>[number]) =>
|
|
42
|
+
reasoning
|
|
43
|
+
? reasoning.status !== 'streaming'
|
|
44
|
+
: toolCall
|
|
45
|
+
? isToolCallFinished(toolCall.status)
|
|
46
|
+
: true;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Whether the reply is being written, took steps that are all over, and shows no UI: once its
|
|
50
|
+
* answer stops growing, the agent is thinking again, between its steps. An agent's backend can
|
|
51
|
+
* write a round of reasoning as a step only once it is done, so nothing would show meanwhile. A
|
|
52
|
+
* step still going, such as a call waiting for the person, shows itself instead.
|
|
53
|
+
*/
|
|
54
|
+
export const hasFinishedSteps = (
|
|
55
|
+
message: AIMessage | undefined,
|
|
56
|
+
canShowUI: AIConversationCanShowUI = showsNoUI,
|
|
57
|
+
): message is AIMessage =>
|
|
58
|
+
!!message &&
|
|
59
|
+
message.role !== 'user' &&
|
|
60
|
+
!!message.isGenerating &&
|
|
61
|
+
!!message.parts?.length &&
|
|
62
|
+
message.parts.every(isStepOver) &&
|
|
63
|
+
!(message.uiDocument && canShowUI(message.uiDocument));
|
|
64
|
+
|
|
65
|
+
/** Groups the rows into turns, each starting with one of the person's messages. */
|
|
66
|
+
export const turnsOf = (entries: AIConversationEntry[]) =>
|
|
67
|
+
entries.reduce<AIConversationTurn[]>((turns, entry) => {
|
|
68
|
+
const last = turns[turns.length - 1];
|
|
69
|
+
if (!last || entry.isFromUser) turns.push({ entries: [entry], id: entry.id });
|
|
70
|
+
else last.entries.push(entry);
|
|
71
|
+
return turns;
|
|
72
|
+
}, []);
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Follows a message the person sent until its copy arrives in the messages, so the copy takes
|
|
76
|
+
* over its row (and its key) without a flicker, and tells whether the agent is surely about to
|
|
77
|
+
* answer.
|
|
78
|
+
*/
|
|
79
|
+
export class AIPendingMessageTracker {
|
|
80
|
+
// The person's messages each pending message's copy cannot be: those there were when it was
|
|
81
|
+
// first seen, and those that arrived since without being its copy, such as older ones.
|
|
82
|
+
private seen = new Map<string, Set<string>>();
|
|
83
|
+
// The pending message each copy took over, by the copy's id.
|
|
84
|
+
private copies = new Map<string, AIPendingMessage>();
|
|
85
|
+
// The pending message of the last update, whose copy can arrive in the update that stops
|
|
86
|
+
// passing it.
|
|
87
|
+
private lastPending?: AIPendingMessage;
|
|
88
|
+
|
|
89
|
+
// The rows of a conversation: its messages, apart from replies with nothing to show yet, and
|
|
90
|
+
// a message on its way until its copy arrives. A reply's UI shows when `canShowUI` says.
|
|
91
|
+
entries(
|
|
92
|
+
messages: AIMessage[],
|
|
93
|
+
pending?: AIPendingMessage | null,
|
|
94
|
+
canShowUI: AIConversationCanShowUI = showsNoUI,
|
|
95
|
+
): AIConversationEntry[] {
|
|
96
|
+
let showsPending = !!pending;
|
|
97
|
+
// A copy that arrives in the update that stops passing its pending message still takes over
|
|
98
|
+
// its row. Only then: a message sent later is not the copy of one that failed.
|
|
99
|
+
const awaited = pending ?? this.lastPending;
|
|
100
|
+
if (awaited) {
|
|
101
|
+
const sent = messages.filter((message) => message.role === 'user');
|
|
102
|
+
const ids = new Set(sent.map((message) => message.id));
|
|
103
|
+
const known = this.seen.get(awaited.id) ?? ids;
|
|
104
|
+
const matched = [...this.copies].find(
|
|
105
|
+
([copyId, original]) => original.id === awaited.id && ids.has(copyId),
|
|
106
|
+
)?.[0];
|
|
107
|
+
const copy = matched ?? this.copyOf(awaited, sent, known);
|
|
108
|
+
if (copy !== undefined) {
|
|
109
|
+
if (!this.copies.has(copy)) this.copies.set(copy, awaited);
|
|
110
|
+
showsPending = false;
|
|
111
|
+
} else {
|
|
112
|
+
this.seen.set(awaited.id, new Set([...known, ...ids]));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
this.lastPending = pending ?? undefined;
|
|
116
|
+
|
|
117
|
+
const entries: AIConversationEntry[] = messages
|
|
118
|
+
.filter((message) => !showsNothing(message, canShowUI))
|
|
119
|
+
.map((message) => {
|
|
120
|
+
const taken = this.copies.get(message.id);
|
|
121
|
+
return {
|
|
122
|
+
id: taken?.id ?? message.id,
|
|
123
|
+
isFromUser: message.role === 'user',
|
|
124
|
+
isLatestReply: false,
|
|
125
|
+
message,
|
|
126
|
+
sentAttachments: taken?.attachments ?? [],
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
if (showsPending && pending) {
|
|
130
|
+
entries.push({
|
|
131
|
+
id: pending.id,
|
|
132
|
+
isFromUser: true,
|
|
133
|
+
isLatestReply: false,
|
|
134
|
+
pending,
|
|
135
|
+
sentAttachments: [],
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
const last = entries[entries.length - 1];
|
|
139
|
+
if (last && !last.isFromUser) last.isLatestReply = true;
|
|
140
|
+
return entries;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// The copy of a message that was on its way: the person's message with its id, when the app
|
|
144
|
+
// knew it. Otherwise their first after those known, which older messages loading above cannot
|
|
145
|
+
// be. With none of theirs known, it is their latest, when that is the only new one or says the
|
|
146
|
+
// same.
|
|
147
|
+
private copyOf(pending: AIPendingMessage, sent: AIMessage[], known: Set<string>) {
|
|
148
|
+
const ids = sent.map((message) => message.id);
|
|
149
|
+
if (ids.includes(pending.id)) return pending.id;
|
|
150
|
+
let lastKnown = -1;
|
|
151
|
+
ids.forEach((id, index) => {
|
|
152
|
+
if (known.has(id)) lastKnown = index;
|
|
153
|
+
});
|
|
154
|
+
if (lastKnown >= 0) return ids[lastKnown + 1];
|
|
155
|
+
const fresh = sent.filter((message) => !known.has(message.id));
|
|
156
|
+
const latest = fresh[fresh.length - 1];
|
|
157
|
+
if (!latest || (fresh.length !== 1 && latest.text !== pending.text)) return undefined;
|
|
158
|
+
return latest.id;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Whether the latest message is surely waiting for a reply that shows nothing yet: it is on its
|
|
162
|
+
// way, it is the copy of the one on its way, or its reply is being written but shows nothing.
|
|
163
|
+
// Call it after `entries`, which matches the copies.
|
|
164
|
+
isAwaitingReply(
|
|
165
|
+
messages: AIMessage[],
|
|
166
|
+
pending?: AIPendingMessage | null,
|
|
167
|
+
canShowUI: AIConversationCanShowUI = showsNoUI,
|
|
168
|
+
) {
|
|
169
|
+
const last = messages[messages.length - 1];
|
|
170
|
+
if (last && last.role !== 'user' && last.isGenerating && showsNothing(last, canShowUI))
|
|
171
|
+
return true;
|
|
172
|
+
if (!pending) return false;
|
|
173
|
+
const copy = [...this.copies].find(([, original]) => original.id === pending.id)?.[0];
|
|
174
|
+
if (copy === undefined) return true;
|
|
175
|
+
return last?.id === copy;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { Attachment, LocalMessage, MessageResponse } from 'stream-chat';
|
|
2
|
+
|
|
3
|
+
import type { AIMessage } from './types';
|
|
4
|
+
|
|
5
|
+
import { AI_UI_CUSTOM_DATA_KEY, parseAIUIDocument } from '../generative-ui/AIUIDocument';
|
|
6
|
+
import type { AIMessageAttachmentData } from '../message/AIMessageAttachment';
|
|
7
|
+
import { parseMessageParts } from '../message-parts/parseMessageParts';
|
|
8
|
+
|
|
9
|
+
/** A Stream message, as the channel's state or an event has it. */
|
|
10
|
+
export type AIStreamMessage = Pick<LocalMessage | MessageResponse, 'attachments' | 'id' | 'text'> &
|
|
11
|
+
Record<string, unknown>;
|
|
12
|
+
|
|
13
|
+
export type FromStreamMessageOptions = {
|
|
14
|
+
/** Whether the agent wrote it. Defaults to the message's `ai_generated` field. */
|
|
15
|
+
isAssistant?: (message: AIStreamMessage) => boolean;
|
|
16
|
+
/** The whole of a reasoning step's thinking, when the app has it, such as from live updates. */
|
|
17
|
+
reasoningText?: (messageId: string, stepId: string) => string | undefined;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// Images and files only: the steps (`ai_*`) are read as parts, and other kinds are the app's.
|
|
21
|
+
const attachmentOf = (attachment: Attachment): AIMessageAttachmentData | undefined => {
|
|
22
|
+
const name = attachment.title ?? attachment.fallback ?? undefined;
|
|
23
|
+
if (attachment.type === 'image') {
|
|
24
|
+
const url = attachment.image_url ?? attachment.asset_url ?? attachment.thumb_url;
|
|
25
|
+
return url ? { kind: 'image', mimeType: attachment.mime_type, name, url } : undefined;
|
|
26
|
+
}
|
|
27
|
+
if (attachment.type === 'file') {
|
|
28
|
+
const size = Number(attachment.file_size);
|
|
29
|
+
return attachment.asset_url
|
|
30
|
+
? {
|
|
31
|
+
kind: 'file',
|
|
32
|
+
mimeType: attachment.mime_type,
|
|
33
|
+
name,
|
|
34
|
+
size: Number.isFinite(size) && size > 0 ? size : undefined,
|
|
35
|
+
url: attachment.asset_url,
|
|
36
|
+
}
|
|
37
|
+
: undefined;
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Adapts a Stream message for `AIConversation`: a reply is one with `ai_generated: true`, it is
|
|
44
|
+
* being written while `generating: true`, its steps are its `ai_reasoning` and `ai_tool_call`
|
|
45
|
+
* attachments, its images and files are its other attachments, and the UI the agent wrote for
|
|
46
|
+
* it is its `ai_ui` field. A person's message has no UI, whatever its fields say.
|
|
47
|
+
*/
|
|
48
|
+
export const fromStreamMessage = (
|
|
49
|
+
message: AIStreamMessage,
|
|
50
|
+
{ isAssistant, reasoningText }: FromStreamMessageOptions = {},
|
|
51
|
+
): AIMessage => {
|
|
52
|
+
const attachments = message.attachments ?? [];
|
|
53
|
+
const assistant = isAssistant ? isAssistant(message) : message.ai_generated === true;
|
|
54
|
+
const uiDocument = assistant ? parseAIUIDocument(message[AI_UI_CUSTOM_DATA_KEY]) : undefined;
|
|
55
|
+
return {
|
|
56
|
+
attachments: attachments
|
|
57
|
+
.map(attachmentOf)
|
|
58
|
+
.filter((attachment): attachment is AIMessageAttachmentData => !!attachment),
|
|
59
|
+
id: message.id,
|
|
60
|
+
isGenerating: message.generating === true,
|
|
61
|
+
parts: parseMessageParts(attachments),
|
|
62
|
+
reasoningText: reasoningText
|
|
63
|
+
? (stepId: string) => reasoningText(message.id, stepId)
|
|
64
|
+
: undefined,
|
|
65
|
+
role: assistant ? 'assistant' : 'user',
|
|
66
|
+
text: message.text ?? '',
|
|
67
|
+
...(uiDocument ? { uiDocument } : {}),
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* A `fromStreamMessage` that gives back the same `AIMessage` for the same Stream message object.
|
|
73
|
+
* The channel's state replaces only the messages that change, so mapping its messages through it
|
|
74
|
+
* on every update leaves the others as they were, and `AIConversation` renders only the changed
|
|
75
|
+
* ones again. Make one per conversation, such as with `useState(() => createFromStreamMessage())`.
|
|
76
|
+
*/
|
|
77
|
+
export const createFromStreamMessage = (options?: FromStreamMessageOptions) => {
|
|
78
|
+
const cache = new WeakMap<AIStreamMessage, AIMessage>();
|
|
79
|
+
return (message: AIStreamMessage) => {
|
|
80
|
+
let adapted = cache.get(message);
|
|
81
|
+
if (!adapted) {
|
|
82
|
+
adapted = fromStreamMessage(message, options);
|
|
83
|
+
cache.set(message, adapted);
|
|
84
|
+
}
|
|
85
|
+
return adapted;
|
|
86
|
+
};
|
|
87
|
+
};
|