@base44/superagent-native 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +132 -0
- package/lib/commonjs/AgentSettingsPanel.js +1067 -0
- package/lib/commonjs/AgentSettingsPanel.js.map +1 -0
- package/lib/commonjs/AgentSphereIcon.js +243 -0
- package/lib/commonjs/AgentSphereIcon.js.map +1 -0
- package/lib/commonjs/AttachmentPickerStatusModal.js +96 -0
- package/lib/commonjs/AttachmentPickerStatusModal.js.map +1 -0
- package/lib/commonjs/AttachmentPreviewStrip.js +49 -0
- package/lib/commonjs/AttachmentPreviewStrip.js.map +1 -0
- package/lib/commonjs/ChannelsPanel.js +733 -0
- package/lib/commonjs/ChannelsPanel.js.map +1 -0
- package/lib/commonjs/ConversationChat.js +219 -0
- package/lib/commonjs/ConversationChat.js.map +1 -0
- package/lib/commonjs/ConversationComposer.js +323 -0
- package/lib/commonjs/ConversationComposer.js.map +1 -0
- package/lib/commonjs/ConversationMessageList.js +105 -0
- package/lib/commonjs/ConversationMessageList.js.map +1 -0
- package/lib/commonjs/ConversationScreen.js +241 -0
- package/lib/commonjs/ConversationScreen.js.map +1 -0
- package/lib/commonjs/EditorDrawer.js +1127 -0
- package/lib/commonjs/EditorDrawer.js.map +1 -0
- package/lib/commonjs/EditorTabPanel.js +28 -0
- package/lib/commonjs/EditorTabPanel.js.map +1 -0
- package/lib/commonjs/FilesPanel.js +533 -0
- package/lib/commonjs/FilesPanel.js.map +1 -0
- package/lib/commonjs/MarkdownText.js +313 -0
- package/lib/commonjs/MarkdownText.js.map +1 -0
- package/lib/commonjs/MessageActionBar.js +90 -0
- package/lib/commonjs/MessageActionBar.js.map +1 -0
- package/lib/commonjs/RenameAgentModal.js +99 -0
- package/lib/commonjs/RenameAgentModal.js.map +1 -0
- package/lib/commonjs/ShareAgentModal.js +349 -0
- package/lib/commonjs/ShareAgentModal.js.map +1 -0
- package/lib/commonjs/ShareAgentModal.styles.js +236 -0
- package/lib/commonjs/ShareAgentModal.styles.js.map +1 -0
- package/lib/commonjs/SuperagentHomeScreen.js +316 -0
- package/lib/commonjs/SuperagentHomeScreen.js.map +1 -0
- package/lib/commonjs/ToolApprovalCard.js +542 -0
- package/lib/commonjs/ToolApprovalCard.js.map +1 -0
- package/lib/commonjs/ToolCallSummary.js +632 -0
- package/lib/commonjs/ToolCallSummary.js.map +1 -0
- package/lib/commonjs/agentSphereStyles.js +38 -0
- package/lib/commonjs/agentSphereStyles.js.map +1 -0
- package/lib/commonjs/apiClient.js +158 -0
- package/lib/commonjs/apiClient.js.map +1 -0
- package/lib/commonjs/attachmentFileHelpers.js +104 -0
- package/lib/commonjs/attachmentFileHelpers.js.map +1 -0
- package/lib/commonjs/attachmentUpload.js +87 -0
- package/lib/commonjs/attachmentUpload.js.map +1 -0
- package/lib/commonjs/composerStyles.js +248 -0
- package/lib/commonjs/composerStyles.js.map +1 -0
- package/lib/commonjs/connectorBrandIcons.js +82 -0
- package/lib/commonjs/connectorBrandIcons.js.map +1 -0
- package/lib/commonjs/connectorCatalog.js +377 -0
- package/lib/commonjs/connectorCatalog.js.map +1 -0
- package/lib/commonjs/constants.js +15 -0
- package/lib/commonjs/constants.js.map +1 -0
- package/lib/commonjs/conversationParts.js +273 -0
- package/lib/commonjs/conversationParts.js.map +1 -0
- package/lib/commonjs/conversationRuntime.js +144 -0
- package/lib/commonjs/conversationRuntime.js.map +1 -0
- package/lib/commonjs/conversationStyles.js +758 -0
- package/lib/commonjs/conversationStyles.js.map +1 -0
- package/lib/commonjs/editorShellStyles.js +1032 -0
- package/lib/commonjs/editorShellStyles.js.map +1 -0
- package/lib/commonjs/editorTabs.js +42 -0
- package/lib/commonjs/editorTabs.js.map +1 -0
- package/lib/commonjs/fileTreeUtils.js +133 -0
- package/lib/commonjs/fileTreeUtils.js.map +1 -0
- package/lib/commonjs/index.js +110 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/markdownStyles.js +157 -0
- package/lib/commonjs/markdownStyles.js.map +1 -0
- package/lib/commonjs/mediaUtils.js +61 -0
- package/lib/commonjs/mediaUtils.js.map +1 -0
- package/lib/commonjs/messageActionStyles.js +45 -0
- package/lib/commonjs/messageActionStyles.js.map +1 -0
- package/lib/commonjs/messageUtils.js +55 -0
- package/lib/commonjs/messageUtils.js.map +1 -0
- package/lib/commonjs/nativeActionSheet.js +21 -0
- package/lib/commonjs/nativeActionSheet.js.map +1 -0
- package/lib/commonjs/nativeActionSheet.web.js +10 -0
- package/lib/commonjs/nativeActionSheet.web.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/paperTheme.js +59 -0
- package/lib/commonjs/paperTheme.js.map +1 -0
- package/lib/commonjs/realtimeClient.js +99 -0
- package/lib/commonjs/realtimeClient.js.map +1 -0
- package/lib/commonjs/renameAgentModalStyles.js +83 -0
- package/lib/commonjs/renameAgentModalStyles.js.map +1 -0
- package/lib/commonjs/screenParts.js +220 -0
- package/lib/commonjs/screenParts.js.map +1 -0
- package/lib/commonjs/styles.js +343 -0
- package/lib/commonjs/styles.js.map +1 -0
- package/lib/commonjs/superagentApiClient.js +613 -0
- package/lib/commonjs/superagentApiClient.js.map +1 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/useSuperagentAttachmentPicker.js +80 -0
- package/lib/commonjs/useSuperagentAttachmentPicker.js.map +1 -0
- package/lib/commonjs/useSuperagentConversation.js +216 -0
- package/lib/commonjs/useSuperagentConversation.js.map +1 -0
- package/lib/commonjs/useSuperagentRuntime.js +1207 -0
- package/lib/commonjs/useSuperagentRuntime.js.map +1 -0
- package/lib/module/AgentSettingsPanel.js +1062 -0
- package/lib/module/AgentSettingsPanel.js.map +1 -0
- package/lib/module/AgentSphereIcon.js +237 -0
- package/lib/module/AgentSphereIcon.js.map +1 -0
- package/lib/module/AttachmentPickerStatusModal.js +91 -0
- package/lib/module/AttachmentPickerStatusModal.js.map +1 -0
- package/lib/module/AttachmentPreviewStrip.js +44 -0
- package/lib/module/AttachmentPreviewStrip.js.map +1 -0
- package/lib/module/ChannelsPanel.js +728 -0
- package/lib/module/ChannelsPanel.js.map +1 -0
- package/lib/module/ConversationChat.js +214 -0
- package/lib/module/ConversationChat.js.map +1 -0
- package/lib/module/ConversationComposer.js +318 -0
- package/lib/module/ConversationComposer.js.map +1 -0
- package/lib/module/ConversationMessageList.js +100 -0
- package/lib/module/ConversationMessageList.js.map +1 -0
- package/lib/module/ConversationScreen.js +236 -0
- package/lib/module/ConversationScreen.js.map +1 -0
- package/lib/module/EditorDrawer.js +1122 -0
- package/lib/module/EditorDrawer.js.map +1 -0
- package/lib/module/EditorTabPanel.js +23 -0
- package/lib/module/EditorTabPanel.js.map +1 -0
- package/lib/module/FilesPanel.js +528 -0
- package/lib/module/FilesPanel.js.map +1 -0
- package/lib/module/MarkdownText.js +308 -0
- package/lib/module/MarkdownText.js.map +1 -0
- package/lib/module/MessageActionBar.js +85 -0
- package/lib/module/MessageActionBar.js.map +1 -0
- package/lib/module/RenameAgentModal.js +94 -0
- package/lib/module/RenameAgentModal.js.map +1 -0
- package/lib/module/ShareAgentModal.js +344 -0
- package/lib/module/ShareAgentModal.js.map +1 -0
- package/lib/module/ShareAgentModal.styles.js +232 -0
- package/lib/module/ShareAgentModal.styles.js.map +1 -0
- package/lib/module/SuperagentHomeScreen.js +311 -0
- package/lib/module/SuperagentHomeScreen.js.map +1 -0
- package/lib/module/ToolApprovalCard.js +537 -0
- package/lib/module/ToolApprovalCard.js.map +1 -0
- package/lib/module/ToolCallSummary.js +627 -0
- package/lib/module/ToolCallSummary.js.map +1 -0
- package/lib/module/agentSphereStyles.js +34 -0
- package/lib/module/agentSphereStyles.js.map +1 -0
- package/lib/module/apiClient.js +154 -0
- package/lib/module/apiClient.js.map +1 -0
- package/lib/module/attachmentFileHelpers.js +97 -0
- package/lib/module/attachmentFileHelpers.js.map +1 -0
- package/lib/module/attachmentUpload.js +82 -0
- package/lib/module/attachmentUpload.js.map +1 -0
- package/lib/module/composerStyles.js +244 -0
- package/lib/module/composerStyles.js.map +1 -0
- package/lib/module/connectorBrandIcons.js +76 -0
- package/lib/module/connectorBrandIcons.js.map +1 -0
- package/lib/module/connectorCatalog.js +373 -0
- package/lib/module/connectorCatalog.js.map +1 -0
- package/lib/module/constants.js +10 -0
- package/lib/module/constants.js.map +1 -0
- package/lib/module/conversationParts.js +266 -0
- package/lib/module/conversationParts.js.map +1 -0
- package/lib/module/conversationRuntime.js +129 -0
- package/lib/module/conversationRuntime.js.map +1 -0
- package/lib/module/conversationStyles.js +754 -0
- package/lib/module/conversationStyles.js.map +1 -0
- package/lib/module/editorShellStyles.js +1028 -0
- package/lib/module/editorShellStyles.js.map +1 -0
- package/lib/module/editorTabs.js +37 -0
- package/lib/module/editorTabs.js.map +1 -0
- package/lib/module/fileTreeUtils.js +120 -0
- package/lib/module/fileTreeUtils.js.map +1 -0
- package/lib/module/index.js +17 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/markdownStyles.js +153 -0
- package/lib/module/markdownStyles.js.map +1 -0
- package/lib/module/mediaUtils.js +53 -0
- package/lib/module/mediaUtils.js.map +1 -0
- package/lib/module/messageActionStyles.js +41 -0
- package/lib/module/messageActionStyles.js.map +1 -0
- package/lib/module/messageUtils.js +46 -0
- package/lib/module/messageUtils.js.map +1 -0
- package/lib/module/nativeActionSheet.js +17 -0
- package/lib/module/nativeActionSheet.js.map +1 -0
- package/lib/module/nativeActionSheet.web.js +6 -0
- package/lib/module/nativeActionSheet.web.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/paperTheme.js +55 -0
- package/lib/module/paperTheme.js.map +1 -0
- package/lib/module/realtimeClient.js +95 -0
- package/lib/module/realtimeClient.js.map +1 -0
- package/lib/module/renameAgentModalStyles.js +79 -0
- package/lib/module/renameAgentModalStyles.js.map +1 -0
- package/lib/module/screenParts.js +210 -0
- package/lib/module/screenParts.js.map +1 -0
- package/lib/module/styles.js +339 -0
- package/lib/module/styles.js.map +1 -0
- package/lib/module/superagentApiClient.js +609 -0
- package/lib/module/superagentApiClient.js.map +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/useSuperagentAttachmentPicker.js +75 -0
- package/lib/module/useSuperagentAttachmentPicker.js.map +1 -0
- package/lib/module/useSuperagentConversation.js +212 -0
- package/lib/module/useSuperagentConversation.js.map +1 -0
- package/lib/module/useSuperagentRuntime.js +1203 -0
- package/lib/module/useSuperagentRuntime.js.map +1 -0
- package/lib/typescript/commonjs/AgentSettingsPanel.d.ts +19 -0
- package/lib/typescript/commonjs/AgentSettingsPanel.d.ts.map +1 -0
- package/lib/typescript/commonjs/AgentSphereIcon.d.ts +15 -0
- package/lib/typescript/commonjs/AgentSphereIcon.d.ts.map +1 -0
- package/lib/typescript/commonjs/AttachmentPickerStatusModal.d.ts +8 -0
- package/lib/typescript/commonjs/AttachmentPickerStatusModal.d.ts.map +1 -0
- package/lib/typescript/commonjs/AttachmentPreviewStrip.d.ts +7 -0
- package/lib/typescript/commonjs/AttachmentPreviewStrip.d.ts.map +1 -0
- package/lib/typescript/commonjs/ChannelsPanel.d.ts +21 -0
- package/lib/typescript/commonjs/ChannelsPanel.d.ts.map +1 -0
- package/lib/typescript/commonjs/ConversationChat.d.ts +22 -0
- package/lib/typescript/commonjs/ConversationChat.d.ts.map +1 -0
- package/lib/typescript/commonjs/ConversationComposer.d.ts +24 -0
- package/lib/typescript/commonjs/ConversationComposer.d.ts.map +1 -0
- package/lib/typescript/commonjs/ConversationMessageList.d.ts +17 -0
- package/lib/typescript/commonjs/ConversationMessageList.d.ts.map +1 -0
- package/lib/typescript/commonjs/ConversationScreen.d.ts +80 -0
- package/lib/typescript/commonjs/ConversationScreen.d.ts.map +1 -0
- package/lib/typescript/commonjs/EditorDrawer.d.ts +67 -0
- package/lib/typescript/commonjs/EditorDrawer.d.ts.map +1 -0
- package/lib/typescript/commonjs/EditorTabPanel.d.ts +6 -0
- package/lib/typescript/commonjs/EditorTabPanel.d.ts.map +1 -0
- package/lib/typescript/commonjs/FilesPanel.d.ts +14 -0
- package/lib/typescript/commonjs/FilesPanel.d.ts.map +1 -0
- package/lib/typescript/commonjs/MarkdownText.d.ts +10 -0
- package/lib/typescript/commonjs/MarkdownText.d.ts.map +1 -0
- package/lib/typescript/commonjs/MessageActionBar.d.ts +8 -0
- package/lib/typescript/commonjs/MessageActionBar.d.ts.map +1 -0
- package/lib/typescript/commonjs/RenameAgentModal.d.ts +10 -0
- package/lib/typescript/commonjs/RenameAgentModal.d.ts.map +1 -0
- package/lib/typescript/commonjs/ShareAgentModal.d.ts +15 -0
- package/lib/typescript/commonjs/ShareAgentModal.d.ts.map +1 -0
- package/lib/typescript/commonjs/ShareAgentModal.styles.d.ts +229 -0
- package/lib/typescript/commonjs/ShareAgentModal.styles.d.ts.map +1 -0
- package/lib/typescript/commonjs/SuperagentHomeScreen.d.ts +4 -0
- package/lib/typescript/commonjs/SuperagentHomeScreen.d.ts.map +1 -0
- package/lib/typescript/commonjs/ToolApprovalCard.d.ts +13 -0
- package/lib/typescript/commonjs/ToolApprovalCard.d.ts.map +1 -0
- package/lib/typescript/commonjs/ToolCallSummary.d.ts +16 -0
- package/lib/typescript/commonjs/ToolCallSummary.d.ts.map +1 -0
- package/lib/typescript/commonjs/agentSphereStyles.d.ts +31 -0
- package/lib/typescript/commonjs/agentSphereStyles.d.ts.map +1 -0
- package/lib/typescript/commonjs/apiClient.d.ts +4 -0
- package/lib/typescript/commonjs/apiClient.d.ts.map +1 -0
- package/lib/typescript/commonjs/attachmentFileHelpers.d.ts +6 -0
- package/lib/typescript/commonjs/attachmentFileHelpers.d.ts.map +1 -0
- package/lib/typescript/commonjs/attachmentUpload.d.ts +12 -0
- package/lib/typescript/commonjs/attachmentUpload.d.ts.map +1 -0
- package/lib/typescript/commonjs/composerStyles.d.ts +241 -0
- package/lib/typescript/commonjs/composerStyles.d.ts.map +1 -0
- package/lib/typescript/commonjs/connectorBrandIcons.d.ts +7 -0
- package/lib/typescript/commonjs/connectorBrandIcons.d.ts.map +1 -0
- package/lib/typescript/commonjs/connectorCatalog.d.ts +3 -0
- package/lib/typescript/commonjs/connectorCatalog.d.ts.map +1 -0
- package/lib/typescript/commonjs/constants.d.ts +4 -0
- package/lib/typescript/commonjs/constants.d.ts.map +1 -0
- package/lib/typescript/commonjs/conversationParts.d.ts +29 -0
- package/lib/typescript/commonjs/conversationParts.d.ts.map +1 -0
- package/lib/typescript/commonjs/conversationRuntime.d.ts +67 -0
- package/lib/typescript/commonjs/conversationRuntime.d.ts.map +1 -0
- package/lib/typescript/commonjs/conversationStyles.d.ts +742 -0
- package/lib/typescript/commonjs/conversationStyles.d.ts.map +1 -0
- package/lib/typescript/commonjs/editorShellStyles.d.ts +1025 -0
- package/lib/typescript/commonjs/editorShellStyles.d.ts.map +1 -0
- package/lib/typescript/commonjs/editorTabs.d.ts +11 -0
- package/lib/typescript/commonjs/editorTabs.d.ts.map +1 -0
- package/lib/typescript/commonjs/fileTreeUtils.d.ts +17 -0
- package/lib/typescript/commonjs/fileTreeUtils.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +20 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/markdownStyles.d.ts +150 -0
- package/lib/typescript/commonjs/markdownStyles.d.ts.map +1 -0
- package/lib/typescript/commonjs/mediaUtils.d.ts +9 -0
- package/lib/typescript/commonjs/mediaUtils.d.ts.map +1 -0
- package/lib/typescript/commonjs/messageActionStyles.d.ts +38 -0
- package/lib/typescript/commonjs/messageActionStyles.d.ts.map +1 -0
- package/lib/typescript/commonjs/messageUtils.d.ts +8 -0
- package/lib/typescript/commonjs/messageUtils.d.ts.map +1 -0
- package/lib/typescript/commonjs/nativeActionSheet.d.ts +6 -0
- package/lib/typescript/commonjs/nativeActionSheet.d.ts.map +1 -0
- package/lib/typescript/commonjs/nativeActionSheet.web.d.ts +3 -0
- package/lib/typescript/commonjs/nativeActionSheet.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/paperTheme.d.ts +3 -0
- package/lib/typescript/commonjs/paperTheme.d.ts.map +1 -0
- package/lib/typescript/commonjs/realtimeClient.d.ts +16 -0
- package/lib/typescript/commonjs/realtimeClient.d.ts.map +1 -0
- package/lib/typescript/commonjs/renameAgentModalStyles.d.ts +76 -0
- package/lib/typescript/commonjs/renameAgentModalStyles.d.ts.map +1 -0
- package/lib/typescript/commonjs/screenParts.d.ts +31 -0
- package/lib/typescript/commonjs/screenParts.d.ts.map +1 -0
- package/lib/typescript/commonjs/styles.d.ts +336 -0
- package/lib/typescript/commonjs/styles.d.ts.map +1 -0
- package/lib/typescript/commonjs/superagentApiClient.d.ts +66 -0
- package/lib/typescript/commonjs/superagentApiClient.d.ts.map +1 -0
- package/lib/typescript/commonjs/types.d.ts +437 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/useSuperagentAttachmentPicker.d.ts +30 -0
- package/lib/typescript/commonjs/useSuperagentAttachmentPicker.d.ts.map +1 -0
- package/lib/typescript/commonjs/useSuperagentConversation.d.ts +36 -0
- package/lib/typescript/commonjs/useSuperagentConversation.d.ts.map +1 -0
- package/lib/typescript/commonjs/useSuperagentRuntime.d.ts +163 -0
- package/lib/typescript/commonjs/useSuperagentRuntime.d.ts.map +1 -0
- package/lib/typescript/module/AgentSettingsPanel.d.ts +19 -0
- package/lib/typescript/module/AgentSettingsPanel.d.ts.map +1 -0
- package/lib/typescript/module/AgentSphereIcon.d.ts +15 -0
- package/lib/typescript/module/AgentSphereIcon.d.ts.map +1 -0
- package/lib/typescript/module/AttachmentPickerStatusModal.d.ts +8 -0
- package/lib/typescript/module/AttachmentPickerStatusModal.d.ts.map +1 -0
- package/lib/typescript/module/AttachmentPreviewStrip.d.ts +7 -0
- package/lib/typescript/module/AttachmentPreviewStrip.d.ts.map +1 -0
- package/lib/typescript/module/ChannelsPanel.d.ts +21 -0
- package/lib/typescript/module/ChannelsPanel.d.ts.map +1 -0
- package/lib/typescript/module/ConversationChat.d.ts +22 -0
- package/lib/typescript/module/ConversationChat.d.ts.map +1 -0
- package/lib/typescript/module/ConversationComposer.d.ts +24 -0
- package/lib/typescript/module/ConversationComposer.d.ts.map +1 -0
- package/lib/typescript/module/ConversationMessageList.d.ts +17 -0
- package/lib/typescript/module/ConversationMessageList.d.ts.map +1 -0
- package/lib/typescript/module/ConversationScreen.d.ts +80 -0
- package/lib/typescript/module/ConversationScreen.d.ts.map +1 -0
- package/lib/typescript/module/EditorDrawer.d.ts +67 -0
- package/lib/typescript/module/EditorDrawer.d.ts.map +1 -0
- package/lib/typescript/module/EditorTabPanel.d.ts +6 -0
- package/lib/typescript/module/EditorTabPanel.d.ts.map +1 -0
- package/lib/typescript/module/FilesPanel.d.ts +14 -0
- package/lib/typescript/module/FilesPanel.d.ts.map +1 -0
- package/lib/typescript/module/MarkdownText.d.ts +10 -0
- package/lib/typescript/module/MarkdownText.d.ts.map +1 -0
- package/lib/typescript/module/MessageActionBar.d.ts +8 -0
- package/lib/typescript/module/MessageActionBar.d.ts.map +1 -0
- package/lib/typescript/module/RenameAgentModal.d.ts +10 -0
- package/lib/typescript/module/RenameAgentModal.d.ts.map +1 -0
- package/lib/typescript/module/ShareAgentModal.d.ts +15 -0
- package/lib/typescript/module/ShareAgentModal.d.ts.map +1 -0
- package/lib/typescript/module/ShareAgentModal.styles.d.ts +229 -0
- package/lib/typescript/module/ShareAgentModal.styles.d.ts.map +1 -0
- package/lib/typescript/module/SuperagentHomeScreen.d.ts +4 -0
- package/lib/typescript/module/SuperagentHomeScreen.d.ts.map +1 -0
- package/lib/typescript/module/ToolApprovalCard.d.ts +13 -0
- package/lib/typescript/module/ToolApprovalCard.d.ts.map +1 -0
- package/lib/typescript/module/ToolCallSummary.d.ts +16 -0
- package/lib/typescript/module/ToolCallSummary.d.ts.map +1 -0
- package/lib/typescript/module/agentSphereStyles.d.ts +31 -0
- package/lib/typescript/module/agentSphereStyles.d.ts.map +1 -0
- package/lib/typescript/module/apiClient.d.ts +4 -0
- package/lib/typescript/module/apiClient.d.ts.map +1 -0
- package/lib/typescript/module/attachmentFileHelpers.d.ts +6 -0
- package/lib/typescript/module/attachmentFileHelpers.d.ts.map +1 -0
- package/lib/typescript/module/attachmentUpload.d.ts +12 -0
- package/lib/typescript/module/attachmentUpload.d.ts.map +1 -0
- package/lib/typescript/module/composerStyles.d.ts +241 -0
- package/lib/typescript/module/composerStyles.d.ts.map +1 -0
- package/lib/typescript/module/connectorBrandIcons.d.ts +7 -0
- package/lib/typescript/module/connectorBrandIcons.d.ts.map +1 -0
- package/lib/typescript/module/connectorCatalog.d.ts +3 -0
- package/lib/typescript/module/connectorCatalog.d.ts.map +1 -0
- package/lib/typescript/module/constants.d.ts +4 -0
- package/lib/typescript/module/constants.d.ts.map +1 -0
- package/lib/typescript/module/conversationParts.d.ts +29 -0
- package/lib/typescript/module/conversationParts.d.ts.map +1 -0
- package/lib/typescript/module/conversationRuntime.d.ts +67 -0
- package/lib/typescript/module/conversationRuntime.d.ts.map +1 -0
- package/lib/typescript/module/conversationStyles.d.ts +742 -0
- package/lib/typescript/module/conversationStyles.d.ts.map +1 -0
- package/lib/typescript/module/editorShellStyles.d.ts +1025 -0
- package/lib/typescript/module/editorShellStyles.d.ts.map +1 -0
- package/lib/typescript/module/editorTabs.d.ts +11 -0
- package/lib/typescript/module/editorTabs.d.ts.map +1 -0
- package/lib/typescript/module/fileTreeUtils.d.ts +17 -0
- package/lib/typescript/module/fileTreeUtils.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +20 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/markdownStyles.d.ts +150 -0
- package/lib/typescript/module/markdownStyles.d.ts.map +1 -0
- package/lib/typescript/module/mediaUtils.d.ts +9 -0
- package/lib/typescript/module/mediaUtils.d.ts.map +1 -0
- package/lib/typescript/module/messageActionStyles.d.ts +38 -0
- package/lib/typescript/module/messageActionStyles.d.ts.map +1 -0
- package/lib/typescript/module/messageUtils.d.ts +8 -0
- package/lib/typescript/module/messageUtils.d.ts.map +1 -0
- package/lib/typescript/module/nativeActionSheet.d.ts +6 -0
- package/lib/typescript/module/nativeActionSheet.d.ts.map +1 -0
- package/lib/typescript/module/nativeActionSheet.web.d.ts +3 -0
- package/lib/typescript/module/nativeActionSheet.web.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/paperTheme.d.ts +3 -0
- package/lib/typescript/module/paperTheme.d.ts.map +1 -0
- package/lib/typescript/module/realtimeClient.d.ts +16 -0
- package/lib/typescript/module/realtimeClient.d.ts.map +1 -0
- package/lib/typescript/module/renameAgentModalStyles.d.ts +76 -0
- package/lib/typescript/module/renameAgentModalStyles.d.ts.map +1 -0
- package/lib/typescript/module/screenParts.d.ts +31 -0
- package/lib/typescript/module/screenParts.d.ts.map +1 -0
- package/lib/typescript/module/styles.d.ts +336 -0
- package/lib/typescript/module/styles.d.ts.map +1 -0
- package/lib/typescript/module/superagentApiClient.d.ts +66 -0
- package/lib/typescript/module/superagentApiClient.d.ts.map +1 -0
- package/lib/typescript/module/types.d.ts +437 -0
- package/lib/typescript/module/types.d.ts.map +1 -0
- package/lib/typescript/module/useSuperagentAttachmentPicker.d.ts +30 -0
- package/lib/typescript/module/useSuperagentAttachmentPicker.d.ts.map +1 -0
- package/lib/typescript/module/useSuperagentConversation.d.ts +36 -0
- package/lib/typescript/module/useSuperagentConversation.d.ts.map +1 -0
- package/lib/typescript/module/useSuperagentRuntime.d.ts +163 -0
- package/lib/typescript/module/useSuperagentRuntime.d.ts.map +1 -0
- package/package.json +87 -0
- package/src/AgentSettingsPanel.tsx +1122 -0
- package/src/AgentSphereIcon.tsx +170 -0
- package/src/AttachmentPickerStatusModal.tsx +80 -0
- package/src/AttachmentPreviewStrip.tsx +38 -0
- package/src/ChannelsPanel.tsx +705 -0
- package/src/ConversationChat.tsx +245 -0
- package/src/ConversationComposer.tsx +368 -0
- package/src/ConversationMessageList.tsx +140 -0
- package/src/ConversationScreen.tsx +320 -0
- package/src/EditorDrawer.tsx +1297 -0
- package/src/EditorTabPanel.tsx +19 -0
- package/src/FilesPanel.tsx +577 -0
- package/src/MarkdownText.tsx +317 -0
- package/src/MessageActionBar.tsx +126 -0
- package/src/RenameAgentModal.tsx +107 -0
- package/src/ShareAgentModal.styles.ts +95 -0
- package/src/ShareAgentModal.tsx +320 -0
- package/src/SuperagentHomeScreen.tsx +318 -0
- package/src/ToolApprovalCard.tsx +592 -0
- package/src/ToolCallSummary.tsx +599 -0
- package/src/agentSphereStyles.ts +25 -0
- package/src/apiClient.ts +189 -0
- package/src/attachmentFileHelpers.ts +109 -0
- package/src/attachmentUpload.ts +112 -0
- package/src/composerStyles.ts +167 -0
- package/src/connectorBrandIcons.tsx +69 -0
- package/src/connectorCatalog.ts +414 -0
- package/src/constants.ts +9 -0
- package/src/conversationParts.tsx +307 -0
- package/src/conversationRuntime.ts +171 -0
- package/src/conversationStyles.ts +412 -0
- package/src/editorShellStyles.ts +1023 -0
- package/src/editorTabs.ts +26 -0
- package/src/fileTreeUtils.ts +165 -0
- package/src/index.ts +110 -0
- package/src/markdownStyles.ts +64 -0
- package/src/mediaUtils.ts +75 -0
- package/src/messageActionStyles.ts +26 -0
- package/src/messageUtils.ts +58 -0
- package/src/nativeActionSheet.ts +25 -0
- package/src/nativeActionSheet.web.ts +5 -0
- package/src/paperTheme.ts +52 -0
- package/src/realtimeClient.ts +149 -0
- package/src/renameAgentModalStyles.ts +77 -0
- package/src/screenParts.tsx +185 -0
- package/src/styles.ts +190 -0
- package/src/superagentApiClient.ts +895 -0
- package/src/types.ts +514 -0
- package/src/useSuperagentAttachmentPicker.tsx +117 -0
- package/src/useSuperagentConversation.ts +242 -0
- package/src/useSuperagentRuntime.ts +1371 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { Animated, Easing, Pressable, Text, View } from 'react-native';
|
|
3
|
+
import { ChevronLeft, MoreHorizontal, Share2, Sparkles } from 'lucide-react-native';
|
|
4
|
+
|
|
5
|
+
import { AgentSphereIcon } from './AgentSphereIcon';
|
|
6
|
+
import { conversationStyles } from './conversationStyles';
|
|
7
|
+
import { getEditorTabLabel } from './editorTabs';
|
|
8
|
+
import { MarkdownText } from './MarkdownText';
|
|
9
|
+
import { showMessageActions } from './MessageActionBar';
|
|
10
|
+
import { getFileName, getMessageFiles, getMessageToolCalls, getReplyTo } from './messageUtils';
|
|
11
|
+
import { ToolCallSummary } from './ToolCallSummary';
|
|
12
|
+
import type {
|
|
13
|
+
SuperagentAgent,
|
|
14
|
+
SuperagentConnector,
|
|
15
|
+
SuperagentConnectorActionInput,
|
|
16
|
+
SuperagentConversation,
|
|
17
|
+
SuperagentCopyMessageInput,
|
|
18
|
+
SuperagentEditorTab,
|
|
19
|
+
SuperagentMarkdownRenderer,
|
|
20
|
+
SuperagentMessage,
|
|
21
|
+
SuperagentToolRenderers,
|
|
22
|
+
} from './types';
|
|
23
|
+
|
|
24
|
+
export function ConversationHeader({
|
|
25
|
+
activeTab,
|
|
26
|
+
agent,
|
|
27
|
+
onBack,
|
|
28
|
+
onOpenMenu,
|
|
29
|
+
onOpenShare,
|
|
30
|
+
onRenameRequest,
|
|
31
|
+
}: {
|
|
32
|
+
activeTab: SuperagentEditorTab;
|
|
33
|
+
agent: SuperagentAgent;
|
|
34
|
+
onBack: () => void;
|
|
35
|
+
onOpenMenu: () => void;
|
|
36
|
+
onOpenShare?: () => void;
|
|
37
|
+
onRenameRequest?: () => void;
|
|
38
|
+
}) {
|
|
39
|
+
const subtitle = activeTab === 'chat' ? agent.description || 'Superagent' : getEditorTabLabel(activeTab);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<View style={conversationStyles.header}>
|
|
43
|
+
<Pressable accessibilityLabel="Back" accessibilityRole="button" onPress={onBack} style={conversationStyles.headerIconButton}>
|
|
44
|
+
<ChevronLeft color="#F4F4F5" size={34} strokeWidth={2.1} />
|
|
45
|
+
</Pressable>
|
|
46
|
+
<Pressable
|
|
47
|
+
accessibilityHint="Long press to rename this Superagent"
|
|
48
|
+
accessibilityLabel="Superagent name"
|
|
49
|
+
accessibilityRole="button"
|
|
50
|
+
delayLongPress={320}
|
|
51
|
+
disabled={!onRenameRequest}
|
|
52
|
+
onLongPress={onRenameRequest}
|
|
53
|
+
style={conversationStyles.headerTitleWrap}
|
|
54
|
+
>
|
|
55
|
+
<AgentSphereIcon agent={agent} size="header" />
|
|
56
|
+
<View style={conversationStyles.headerTitleTextWrap}>
|
|
57
|
+
<Text numberOfLines={1} style={conversationStyles.headerTitle}>{agent.name || 'Superagent'}</Text>
|
|
58
|
+
<Text numberOfLines={1} style={conversationStyles.headerSubtitle}>{subtitle}</Text>
|
|
59
|
+
</View>
|
|
60
|
+
</Pressable>
|
|
61
|
+
<View style={conversationStyles.headerActions}>
|
|
62
|
+
{onOpenShare ? (
|
|
63
|
+
<Pressable accessibilityLabel="Share Superagent chat" accessibilityRole="button" onPress={onOpenShare} style={conversationStyles.headerShareButton}>
|
|
64
|
+
<Share2 color="#F4F4F5" size={22} strokeWidth={2.4} />
|
|
65
|
+
</Pressable>
|
|
66
|
+
) : null}
|
|
67
|
+
<Pressable accessibilityLabel="Open Superagent menu" accessibilityRole="button" onPress={onOpenMenu} style={conversationStyles.headerMenuButton}>
|
|
68
|
+
<MoreHorizontal color="#F4F4F5" size={28} strokeWidth={2.4} />
|
|
69
|
+
</Pressable>
|
|
70
|
+
</View>
|
|
71
|
+
</View>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function MessageBubble({
|
|
76
|
+
agent,
|
|
77
|
+
availableConnectors,
|
|
78
|
+
conversationId,
|
|
79
|
+
currentUserAvatarUrl,
|
|
80
|
+
isLastAssistantMessage,
|
|
81
|
+
message,
|
|
82
|
+
onConnectConnector,
|
|
83
|
+
onCopyMessage,
|
|
84
|
+
onDeleteMessage,
|
|
85
|
+
onReplyMessage,
|
|
86
|
+
renderMarkdown,
|
|
87
|
+
showAvatar,
|
|
88
|
+
showTimestamp,
|
|
89
|
+
submitToolCallInput,
|
|
90
|
+
toolRenderers,
|
|
91
|
+
}: {
|
|
92
|
+
agent: SuperagentAgent;
|
|
93
|
+
availableConnectors?: SuperagentConnector[];
|
|
94
|
+
conversationId: string | null;
|
|
95
|
+
currentUserAvatarUrl?: string | null;
|
|
96
|
+
isLastAssistantMessage: boolean;
|
|
97
|
+
message: SuperagentMessage;
|
|
98
|
+
onConnectConnector?: (input: SuperagentConnectorActionInput) => Promise<boolean | void> | boolean | void;
|
|
99
|
+
onCopyMessage?: SuperagentCopyMessageInput;
|
|
100
|
+
onDeleteMessage?: (messageId: string) => Promise<boolean> | boolean;
|
|
101
|
+
onReplyMessage?: (message: SuperagentMessage) => void;
|
|
102
|
+
renderMarkdown?: SuperagentMarkdownRenderer;
|
|
103
|
+
showAvatar: boolean;
|
|
104
|
+
showTimestamp: boolean;
|
|
105
|
+
submitToolCallInput?: (
|
|
106
|
+
toolCallId: string,
|
|
107
|
+
approve: boolean,
|
|
108
|
+
extraUserInput?: unknown,
|
|
109
|
+
originRequestId?: string,
|
|
110
|
+
) => Promise<SuperagentConversation | null>;
|
|
111
|
+
toolRenderers?: SuperagentToolRenderers;
|
|
112
|
+
}) {
|
|
113
|
+
const isUser = message.role === 'user';
|
|
114
|
+
const files = getMessageFiles(message);
|
|
115
|
+
const replyTo = getReplyTo(message);
|
|
116
|
+
const toolCalls = getMessageToolCalls(message);
|
|
117
|
+
const senderName = isUser ? 'You' : agent.name || 'Superagent';
|
|
118
|
+
const usesScrollableMarkdown = hasScrollableMarkdown(message.content);
|
|
119
|
+
const bubbleStyle = [
|
|
120
|
+
conversationStyles.messageBubble,
|
|
121
|
+
isUser ? conversationStyles.userBubble : conversationStyles.assistantBubble,
|
|
122
|
+
!showTimestamp && (isUser ? conversationStyles.userBubbleStacked : conversationStyles.assistantBubbleStacked),
|
|
123
|
+
];
|
|
124
|
+
const openMessageActions = () => showMessageActions({
|
|
125
|
+
message,
|
|
126
|
+
onCopyMessage,
|
|
127
|
+
onDeleteMessage,
|
|
128
|
+
onReplyMessage,
|
|
129
|
+
});
|
|
130
|
+
const bubbleContent = (
|
|
131
|
+
<>
|
|
132
|
+
{replyTo ? <ReplyQuote content={replyTo.content} /> : null}
|
|
133
|
+
{message.content ? (
|
|
134
|
+
<MarkdownText
|
|
135
|
+
content={message.content}
|
|
136
|
+
isUser={isUser}
|
|
137
|
+
message={message}
|
|
138
|
+
onLongPress={usesScrollableMarkdown ? openMessageActions : undefined}
|
|
139
|
+
renderMarkdown={renderMarkdown}
|
|
140
|
+
/>
|
|
141
|
+
) : null}
|
|
142
|
+
{files.length > 0 ? <FileChips files={files} /> : null}
|
|
143
|
+
{toolCalls.length > 0 ? (
|
|
144
|
+
<ToolCallSummary
|
|
145
|
+
agent={agent}
|
|
146
|
+
availableConnectors={availableConnectors}
|
|
147
|
+
conversationId={conversationId}
|
|
148
|
+
isLastAssistantMessage={isLastAssistantMessage}
|
|
149
|
+
message={message}
|
|
150
|
+
onConnectConnector={onConnectConnector}
|
|
151
|
+
submitToolCallInput={submitToolCallInput}
|
|
152
|
+
toolCalls={toolCalls}
|
|
153
|
+
toolRenderers={toolRenderers}
|
|
154
|
+
/>
|
|
155
|
+
) : null}
|
|
156
|
+
{showTimestamp && message.createdAt ? (
|
|
157
|
+
<Text style={conversationStyles.messageTime}>{formatTime(message.createdAt)}</Text>
|
|
158
|
+
) : null}
|
|
159
|
+
</>
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<View style={[
|
|
164
|
+
conversationStyles.messageGroup,
|
|
165
|
+
isUser ? conversationStyles.userMessageGroup : conversationStyles.assistantMessageGroup,
|
|
166
|
+
showAvatar && conversationStyles.messageGroupWithAvatar,
|
|
167
|
+
]}>
|
|
168
|
+
{showAvatar ? (
|
|
169
|
+
<View style={[
|
|
170
|
+
conversationStyles.identityRow,
|
|
171
|
+
isUser ? conversationStyles.userIdentityRow : conversationStyles.assistantIdentityRow,
|
|
172
|
+
]}>
|
|
173
|
+
<AgentSphereIcon agent={agent} isUser={isUser} userAvatarUrl={isUser ? currentUserAvatarUrl : undefined} />
|
|
174
|
+
<Text numberOfLines={1} style={[
|
|
175
|
+
conversationStyles.identityName,
|
|
176
|
+
isUser ? conversationStyles.userIdentityName : conversationStyles.assistantIdentityName,
|
|
177
|
+
]}>
|
|
178
|
+
{senderName}
|
|
179
|
+
</Text>
|
|
180
|
+
</View>
|
|
181
|
+
) : null}
|
|
182
|
+
<View style={[
|
|
183
|
+
conversationStyles.messageBubbleWrap,
|
|
184
|
+
usesScrollableMarkdown && conversationStyles.scrollableMessageBubbleWrap,
|
|
185
|
+
isUser ? conversationStyles.userMessageBubbleWrap : conversationStyles.assistantMessageBubbleWrap,
|
|
186
|
+
]}>
|
|
187
|
+
{usesScrollableMarkdown ? (
|
|
188
|
+
<View style={bubbleStyle}>
|
|
189
|
+
{bubbleContent}
|
|
190
|
+
</View>
|
|
191
|
+
) : (
|
|
192
|
+
<Pressable
|
|
193
|
+
accessibilityRole="button"
|
|
194
|
+
delayLongPress={280}
|
|
195
|
+
onLongPress={openMessageActions}
|
|
196
|
+
style={bubbleStyle}
|
|
197
|
+
>
|
|
198
|
+
{bubbleContent}
|
|
199
|
+
</Pressable>
|
|
200
|
+
)}
|
|
201
|
+
</View>
|
|
202
|
+
</View>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function hasScrollableMarkdown(content?: string) {
|
|
207
|
+
if (!content) return false;
|
|
208
|
+
if (/```/.test(content)) return true;
|
|
209
|
+
|
|
210
|
+
const lines = content.replace(/\r\n/g, '\n').split('\n');
|
|
211
|
+
return lines.some((line, index) => (
|
|
212
|
+
line.includes('|') &&
|
|
213
|
+
Boolean(lines[index + 1]?.match(/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/))
|
|
214
|
+
));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function ReplyQuote({ content }: { content: string }) {
|
|
218
|
+
return (
|
|
219
|
+
<View style={conversationStyles.replyQuote}>
|
|
220
|
+
<Text style={conversationStyles.replyQuoteText} numberOfLines={2}>{content}</Text>
|
|
221
|
+
</View>
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function FileChips({ files }: { files: string[] }) {
|
|
226
|
+
return (
|
|
227
|
+
<View style={conversationStyles.fileChipsWrap}>
|
|
228
|
+
{files.map((file) => (
|
|
229
|
+
<View key={file} style={conversationStyles.fileChip}>
|
|
230
|
+
<Text style={conversationStyles.fileChipText} numberOfLines={1}>{getFileName(file)}</Text>
|
|
231
|
+
</View>
|
|
232
|
+
))}
|
|
233
|
+
</View>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export function TypingIndicator() {
|
|
238
|
+
const spin = useRef(new Animated.Value(0)).current;
|
|
239
|
+
const pulse = useRef(new Animated.Value(0)).current;
|
|
240
|
+
|
|
241
|
+
useEffect(() => {
|
|
242
|
+
const animation = Animated.parallel([
|
|
243
|
+
Animated.loop(
|
|
244
|
+
Animated.timing(spin, {
|
|
245
|
+
duration: 1600,
|
|
246
|
+
easing: Easing.linear,
|
|
247
|
+
toValue: 1,
|
|
248
|
+
useNativeDriver: true,
|
|
249
|
+
}),
|
|
250
|
+
),
|
|
251
|
+
Animated.loop(
|
|
252
|
+
Animated.sequence([
|
|
253
|
+
Animated.timing(pulse, {
|
|
254
|
+
duration: 620,
|
|
255
|
+
easing: Easing.out(Easing.quad),
|
|
256
|
+
toValue: 1,
|
|
257
|
+
useNativeDriver: true,
|
|
258
|
+
}),
|
|
259
|
+
Animated.timing(pulse, {
|
|
260
|
+
duration: 620,
|
|
261
|
+
easing: Easing.in(Easing.quad),
|
|
262
|
+
toValue: 0,
|
|
263
|
+
useNativeDriver: true,
|
|
264
|
+
}),
|
|
265
|
+
]),
|
|
266
|
+
),
|
|
267
|
+
]);
|
|
268
|
+
|
|
269
|
+
animation.start();
|
|
270
|
+
return () => animation.stop();
|
|
271
|
+
}, [pulse, spin]);
|
|
272
|
+
|
|
273
|
+
const rotate = spin.interpolate({
|
|
274
|
+
inputRange: [0, 1],
|
|
275
|
+
outputRange: ['0deg', '360deg'],
|
|
276
|
+
});
|
|
277
|
+
const scale = pulse.interpolate({
|
|
278
|
+
inputRange: [0, 1],
|
|
279
|
+
outputRange: [0.94, 1.08],
|
|
280
|
+
});
|
|
281
|
+
const opacity = pulse.interpolate({
|
|
282
|
+
inputRange: [0, 1],
|
|
283
|
+
outputRange: [0.72, 1],
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
return (
|
|
287
|
+
<View style={conversationStyles.typingWrap}>
|
|
288
|
+
<Animated.View style={[
|
|
289
|
+
conversationStyles.thinkingIcon,
|
|
290
|
+
{ opacity, transform: [{ rotate }, { scale }] },
|
|
291
|
+
]}>
|
|
292
|
+
<Sparkles color="#FF8A4C" size={16} strokeWidth={2.3} />
|
|
293
|
+
</Animated.View>
|
|
294
|
+
<Text style={[conversationStyles.typingText, conversationStyles.typingTextWrap]}>Thinking</Text>
|
|
295
|
+
</View>
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function formatTime(value: string) {
|
|
300
|
+
const date = new Date(value);
|
|
301
|
+
if (Number.isNaN(date.getTime())) return '';
|
|
302
|
+
|
|
303
|
+
return date.toLocaleTimeString([], {
|
|
304
|
+
hour: '2-digit',
|
|
305
|
+
minute: '2-digit',
|
|
306
|
+
});
|
|
307
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
|
|
3
|
+
import { AUTO_GREET_MESSAGE, nextMessageId } from './constants';
|
|
4
|
+
import type { SuperagentMessage, SuperagentNativeClient, SuperagentReplyTo } from './types';
|
|
5
|
+
|
|
6
|
+
export function normalizeMessages(messages: SuperagentMessage[]) {
|
|
7
|
+
return messages.map((message) => ({
|
|
8
|
+
...message,
|
|
9
|
+
content: normalizeContent(message.content),
|
|
10
|
+
createdAt: getMessageCursor(message),
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function mergeMessage(messages: SuperagentMessage[], nextMessage: SuperagentMessage) {
|
|
15
|
+
const normalized = normalizeMessages([{
|
|
16
|
+
...nextMessage,
|
|
17
|
+
created_at: nextMessage.created_at ?? Date.now(),
|
|
18
|
+
}])[0];
|
|
19
|
+
|
|
20
|
+
if (!normalized.id) return [...messages, normalized];
|
|
21
|
+
|
|
22
|
+
const existingIndex = messages.findIndex((message) => message.id === normalized.id);
|
|
23
|
+
if (existingIndex < 0) return [...messages, normalized];
|
|
24
|
+
|
|
25
|
+
return messages.map((message, index) => (index === existingIndex ? normalized : message));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function isVisibleMessage(message: SuperagentMessage, index: number) {
|
|
29
|
+
if (message.hidden) return false;
|
|
30
|
+
if (message.role === 'system') return false;
|
|
31
|
+
return !(index === 0 && message.role === 'user' && message.content === AUTO_GREET_MESSAGE);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function createUserMessage(content: string, options: { fileUrls?: string[]; replyTo?: SuperagentReplyTo } = {}): SuperagentMessage {
|
|
35
|
+
const fileUrls = options.fileUrls?.filter(Boolean) ?? [];
|
|
36
|
+
const replyTo = options.replyTo;
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
id: nextMessageId(),
|
|
40
|
+
role: 'user',
|
|
41
|
+
content,
|
|
42
|
+
createdAt: new Date().toISOString(),
|
|
43
|
+
...(fileUrls.length > 0 ? { fileUrls, file_urls: fileUrls } : {}),
|
|
44
|
+
...(replyTo ? {
|
|
45
|
+
additional_message_params: { reply_to: { content: replyTo.content, message_id: replyTo.messageId } },
|
|
46
|
+
replyTo,
|
|
47
|
+
} : {}),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function createErrorMessage(error: unknown): SuperagentMessage {
|
|
52
|
+
return {
|
|
53
|
+
id: nextMessageId(),
|
|
54
|
+
role: 'assistant',
|
|
55
|
+
content: error instanceof Error ? error.message : 'Something went wrong. Please try again.',
|
|
56
|
+
createdAt: new Date().toISOString(),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function isQueuedResponse(response: unknown) {
|
|
61
|
+
return Boolean(
|
|
62
|
+
response &&
|
|
63
|
+
typeof response === 'object' &&
|
|
64
|
+
'queued' in response &&
|
|
65
|
+
(response as { queued?: unknown }).queued,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function countAssistantResponses(messages: SuperagentMessage[]) {
|
|
70
|
+
return messages.filter((message) => (
|
|
71
|
+
message.role === 'assistant' &&
|
|
72
|
+
!message.hidden &&
|
|
73
|
+
normalizeContent(message.content).trim().length > 0
|
|
74
|
+
)).length;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function hasNewAssistantResponse(messages: SuperagentMessage[], assistantCountBefore: number) {
|
|
78
|
+
return countAssistantResponses(messages) > assistantCountBefore;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export async function refreshConversation(
|
|
82
|
+
apiClient: SuperagentNativeClient,
|
|
83
|
+
conversationId: string,
|
|
84
|
+
setMessages: (messages: SuperagentMessage[]) => void,
|
|
85
|
+
) {
|
|
86
|
+
const refreshed = await apiClient.getConversation(conversationId);
|
|
87
|
+
const normalizedMessages = normalizeMessages(refreshed.messages ?? []);
|
|
88
|
+
setMessages(normalizedMessages);
|
|
89
|
+
return normalizedMessages;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export async function sendWithFallback(
|
|
93
|
+
agentId: string,
|
|
94
|
+
content: string,
|
|
95
|
+
fileUrls: string[],
|
|
96
|
+
replyTo: SuperagentReplyTo | undefined,
|
|
97
|
+
onSendMessage: (params: { agentId: string; fileUrls?: string[]; message: string; replyTo?: SuperagentReplyTo }) =>
|
|
98
|
+
Promise<SuperagentMessage | SuperagentMessage[] | void> | SuperagentMessage | SuperagentMessage[] | void,
|
|
99
|
+
setMessages: Dispatch<SetStateAction<SuperagentMessage[]>>,
|
|
100
|
+
setIsSending: (value: boolean) => void,
|
|
101
|
+
): Promise<boolean> {
|
|
102
|
+
try {
|
|
103
|
+
const response = await onSendMessage({ agentId, fileUrls, message: content, replyTo });
|
|
104
|
+
const responseMessages = Array.isArray(response) ? response : response ? [response] : [];
|
|
105
|
+
setMessages((current) => [...current, ...responseMessages]);
|
|
106
|
+
return responseMessages.some((message) => message.role === 'assistant');
|
|
107
|
+
} catch (error) {
|
|
108
|
+
const errorMessage = createErrorMessage(error);
|
|
109
|
+
setMessages((current) => [...current, errorMessage]);
|
|
110
|
+
return false;
|
|
111
|
+
} finally {
|
|
112
|
+
setIsSending(false);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function pollConversation(
|
|
117
|
+
apiClient: SuperagentNativeClient,
|
|
118
|
+
conversationId: string,
|
|
119
|
+
setMessages: (messages: SuperagentMessage[]) => void,
|
|
120
|
+
setIsSending: (value: boolean) => void,
|
|
121
|
+
assistantCountBefore: number,
|
|
122
|
+
onComplete?: () => Promise<void> | void,
|
|
123
|
+
onAgentMessageDone?: () => Promise<void> | void,
|
|
124
|
+
) {
|
|
125
|
+
let attempts = 0;
|
|
126
|
+
const interval = setInterval(async () => {
|
|
127
|
+
attempts += 1;
|
|
128
|
+
let shouldStop = attempts >= 10;
|
|
129
|
+
let foundAssistantResponse = false;
|
|
130
|
+
|
|
131
|
+
try {
|
|
132
|
+
const refreshedMessages = await refreshConversation(apiClient, conversationId, setMessages);
|
|
133
|
+
foundAssistantResponse = hasNewAssistantResponse(refreshedMessages, assistantCountBefore);
|
|
134
|
+
shouldStop = shouldStop || foundAssistantResponse;
|
|
135
|
+
} finally {
|
|
136
|
+
if (shouldStop) {
|
|
137
|
+
clearInterval(interval);
|
|
138
|
+
setIsSending(false);
|
|
139
|
+
if (foundAssistantResponse) onAgentMessageDone?.();
|
|
140
|
+
onComplete?.();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}, 2000);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function getMessageCursor(message?: SuperagentMessage) {
|
|
147
|
+
if (!message) return undefined;
|
|
148
|
+
|
|
149
|
+
return normalizeDate(
|
|
150
|
+
message.createdAt ??
|
|
151
|
+
message.metadata?.created_date ??
|
|
152
|
+
message.created_at,
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function normalizeDate(value: number | string | Date | undefined) {
|
|
157
|
+
if (!value) return undefined;
|
|
158
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
159
|
+
return Number.isNaN(date.getTime()) ? undefined : date.toISOString();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function normalizeContent(content: unknown) {
|
|
163
|
+
if (typeof content === 'string') return content;
|
|
164
|
+
if (content == null) return '';
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
return JSON.stringify(content, null, 2);
|
|
168
|
+
} catch {
|
|
169
|
+
return String(content);
|
|
170
|
+
}
|
|
171
|
+
}
|