@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,1203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
+
import { createSuperagentNativeClient } from "./apiClient.js";
|
|
5
|
+
import { DEFAULT_SANDBOX_FILE_PATHS, normalizeFilePaths } from "./fileTreeUtils.js";
|
|
6
|
+
import { createSuperagentSocketClient } from "./realtimeClient.js";
|
|
7
|
+
import { createSuperagentApiClient } from "./superagentApiClient.js";
|
|
8
|
+
export function useSuperagentRuntime({
|
|
9
|
+
config,
|
|
10
|
+
initialAgentId,
|
|
11
|
+
nativeAdapters = {}
|
|
12
|
+
}) {
|
|
13
|
+
const superagentService = useMemo(() => createSuperagentApiClient({
|
|
14
|
+
baseUrl: config.baseUrl,
|
|
15
|
+
currentUserId: config.currentUserId,
|
|
16
|
+
getAccessToken: config.getAccessToken,
|
|
17
|
+
getHeaders: config.getHeaders
|
|
18
|
+
}), [config.baseUrl, config.currentUserId, config.getAccessToken, config.getHeaders]);
|
|
19
|
+
const [agents, setAgents] = useState([]);
|
|
20
|
+
const [activeAgentId, setActiveAgentId] = useState(initialAgentId ?? null);
|
|
21
|
+
const [currentRoute, setCurrentRoute] = useState(initialAgentId ? {
|
|
22
|
+
name: 'agent',
|
|
23
|
+
agentId: initialAgentId
|
|
24
|
+
} : {
|
|
25
|
+
name: 'home'
|
|
26
|
+
});
|
|
27
|
+
const [availableConnectors, setAvailableConnectors] = useState([]);
|
|
28
|
+
const [automationCredits, setAutomationCredits] = useState({});
|
|
29
|
+
const [automations, setAutomations] = useState([]);
|
|
30
|
+
const [channelStatus, setChannelStatus] = useState({});
|
|
31
|
+
const [connectingChannelId, setConnectingChannelId] = useState(null);
|
|
32
|
+
const [collaborators, setCollaborators] = useState([]);
|
|
33
|
+
const [connectedConnectors, setConnectedConnectors] = useState([]);
|
|
34
|
+
const [connectingConnectorId, setConnectingConnectorId] = useState(null);
|
|
35
|
+
const [filePaths, setFilePaths] = useState([]);
|
|
36
|
+
const [fileLoadError, setFileLoadError] = useState(null);
|
|
37
|
+
const [fileLoadFailed, setFileLoadFailed] = useState(false);
|
|
38
|
+
const [isLoadingAgentSettings, setIsLoadingAgentSettings] = useState(false);
|
|
39
|
+
const [isLoadingChannels, setIsLoadingChannels] = useState(false);
|
|
40
|
+
const [isLoadingCollaborators, setIsLoadingCollaborators] = useState(false);
|
|
41
|
+
const [isLoadingFiles, setIsLoadingFiles] = useState(false);
|
|
42
|
+
const [isLoadingAutomations, setIsLoadingAutomations] = useState(false);
|
|
43
|
+
const [isLoadingConnectors, setIsLoadingConnectors] = useState(false);
|
|
44
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
45
|
+
const [loadError, setLoadError] = useState(null);
|
|
46
|
+
const [runtimeAuthToken, setRuntimeAuthToken] = useState(null);
|
|
47
|
+
const [realtimeClient, setRealtimeClient] = useState();
|
|
48
|
+
const [secrets, setSecrets] = useState([]);
|
|
49
|
+
const connectorFlowRef = useRef(null);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
let cancelled = false;
|
|
52
|
+
async function loadAgents() {
|
|
53
|
+
setIsLoading(true);
|
|
54
|
+
setLoadError(null);
|
|
55
|
+
try {
|
|
56
|
+
const loadedAgents = await superagentService.listAgents();
|
|
57
|
+
if (cancelled) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
setAgents(loadedAgents);
|
|
61
|
+
setActiveAgentId(current => current ?? initialAgentId ?? loadedAgents[0]?.id ?? null);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
if (!cancelled) {
|
|
64
|
+
setLoadError(getErrorMessage(error));
|
|
65
|
+
}
|
|
66
|
+
} finally {
|
|
67
|
+
if (!cancelled) {
|
|
68
|
+
setIsLoading(false);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
loadAgents();
|
|
73
|
+
return () => {
|
|
74
|
+
cancelled = true;
|
|
75
|
+
};
|
|
76
|
+
}, [initialAgentId, superagentService]);
|
|
77
|
+
const loadConnectors = useCallback(async agentId => {
|
|
78
|
+
setIsLoadingConnectors(true);
|
|
79
|
+
try {
|
|
80
|
+
const connectors = await superagentService.listConnectors(agentId);
|
|
81
|
+
setAvailableConnectors(connectors.availableConnectors);
|
|
82
|
+
setConnectedConnectors(connectors.connectedConnectors);
|
|
83
|
+
} catch {
|
|
84
|
+
setAvailableConnectors([]);
|
|
85
|
+
setConnectedConnectors([]);
|
|
86
|
+
} finally {
|
|
87
|
+
setIsLoadingConnectors(false);
|
|
88
|
+
}
|
|
89
|
+
}, [superagentService]);
|
|
90
|
+
const loadAutomations = useCallback(async agentId => {
|
|
91
|
+
setIsLoadingAutomations(true);
|
|
92
|
+
try {
|
|
93
|
+
const loadedAutomations = await superagentService.listAutomations(agentId);
|
|
94
|
+
setAutomations(loadedAutomations);
|
|
95
|
+
} catch {
|
|
96
|
+
setAutomations([]);
|
|
97
|
+
} finally {
|
|
98
|
+
setIsLoadingAutomations(false);
|
|
99
|
+
}
|
|
100
|
+
}, [superagentService]);
|
|
101
|
+
const loadAutomationCredits = useCallback(async agentId => {
|
|
102
|
+
try {
|
|
103
|
+
const loadedCredits = await superagentService.listAutomationCredits(agentId);
|
|
104
|
+
setAutomationCredits(loadedCredits);
|
|
105
|
+
} catch {
|
|
106
|
+
setAutomationCredits({});
|
|
107
|
+
}
|
|
108
|
+
}, [superagentService]);
|
|
109
|
+
const loadFiles = useCallback(async agentId => {
|
|
110
|
+
setIsLoadingFiles(true);
|
|
111
|
+
try {
|
|
112
|
+
const loadedFilePaths = await superagentService.listSandboxFiles(agentId);
|
|
113
|
+
const normalizedFilePaths = normalizeFilePaths(loadedFilePaths);
|
|
114
|
+
setFilePaths(normalizedFilePaths.length > 0 ? normalizedFilePaths : DEFAULT_SANDBOX_FILE_PATHS);
|
|
115
|
+
setFileLoadError(null);
|
|
116
|
+
setFileLoadFailed(false);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
setFilePaths(DEFAULT_SANDBOX_FILE_PATHS);
|
|
119
|
+
setFileLoadError(getErrorMessage(error));
|
|
120
|
+
setFileLoadFailed(true);
|
|
121
|
+
} finally {
|
|
122
|
+
setIsLoadingFiles(false);
|
|
123
|
+
}
|
|
124
|
+
}, [superagentService]);
|
|
125
|
+
const loadAgentSettings = useCallback(async agentId => {
|
|
126
|
+
setIsLoadingAgentSettings(true);
|
|
127
|
+
try {
|
|
128
|
+
const loadedSecrets = await superagentService.listSecrets(agentId);
|
|
129
|
+
setSecrets(loadedSecrets);
|
|
130
|
+
} catch {
|
|
131
|
+
setSecrets([]);
|
|
132
|
+
} finally {
|
|
133
|
+
setIsLoadingAgentSettings(false);
|
|
134
|
+
}
|
|
135
|
+
}, [superagentService]);
|
|
136
|
+
const loadCollaborators = useCallback(async agentId => {
|
|
137
|
+
setIsLoadingCollaborators(true);
|
|
138
|
+
try {
|
|
139
|
+
const loadedCollaborators = await superagentService.listCollaborators(agentId);
|
|
140
|
+
setCollaborators(loadedCollaborators);
|
|
141
|
+
} catch {
|
|
142
|
+
setCollaborators([]);
|
|
143
|
+
} finally {
|
|
144
|
+
setIsLoadingCollaborators(false);
|
|
145
|
+
}
|
|
146
|
+
}, [superagentService]);
|
|
147
|
+
const resolveRuntimeToken = useCallback(async agentId => {
|
|
148
|
+
if (agentId === activeAgentId && runtimeAuthToken) {
|
|
149
|
+
return runtimeAuthToken;
|
|
150
|
+
}
|
|
151
|
+
const token = await superagentService.getRuntimeAuthToken(agentId);
|
|
152
|
+
if (agentId === activeAgentId) {
|
|
153
|
+
setRuntimeAuthToken(token);
|
|
154
|
+
}
|
|
155
|
+
return token;
|
|
156
|
+
}, [activeAgentId, runtimeAuthToken, superagentService]);
|
|
157
|
+
const loadChannels = useCallback(async agentId => {
|
|
158
|
+
setIsLoadingChannels(true);
|
|
159
|
+
try {
|
|
160
|
+
const token = await resolveRuntimeToken(agentId);
|
|
161
|
+
const status = await superagentService.getChannelStatus(agentId, token);
|
|
162
|
+
setChannelStatus(current => ({
|
|
163
|
+
...status,
|
|
164
|
+
imessage: {
|
|
165
|
+
...status.imessage,
|
|
166
|
+
activation: current.imessage?.activation ?? status.imessage?.activation
|
|
167
|
+
},
|
|
168
|
+
line: {
|
|
169
|
+
...status.line,
|
|
170
|
+
activation: current.line?.activation ?? status.line?.activation
|
|
171
|
+
}
|
|
172
|
+
}));
|
|
173
|
+
} catch {
|
|
174
|
+
setChannelStatus({});
|
|
175
|
+
} finally {
|
|
176
|
+
setIsLoadingChannels(false);
|
|
177
|
+
}
|
|
178
|
+
}, [resolveRuntimeToken, superagentService]);
|
|
179
|
+
const refreshAutomations = useCallback(async agentId => {
|
|
180
|
+
await Promise.all([loadAutomations(agentId), loadAutomationCredits(agentId)]);
|
|
181
|
+
}, [loadAutomationCredits, loadAutomations]);
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
if (!activeAgentId) {
|
|
184
|
+
setAvailableConnectors([]);
|
|
185
|
+
setAutomationCredits({});
|
|
186
|
+
setAutomations([]);
|
|
187
|
+
setChannelStatus({});
|
|
188
|
+
setCollaborators([]);
|
|
189
|
+
setConnectingChannelId(null);
|
|
190
|
+
setConnectedConnectors([]);
|
|
191
|
+
setFilePaths([]);
|
|
192
|
+
setSecrets([]);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
loadAgentSettings(activeAgentId);
|
|
196
|
+
loadCollaborators(activeAgentId);
|
|
197
|
+
loadConnectors(activeAgentId);
|
|
198
|
+
loadFiles(activeAgentId);
|
|
199
|
+
refreshAutomations(activeAgentId);
|
|
200
|
+
}, [activeAgentId, loadAgentSettings, loadCollaborators, loadConnectors, loadFiles, refreshAutomations]);
|
|
201
|
+
useEffect(() => {
|
|
202
|
+
if (!activeAgentId || !runtimeAuthToken) {
|
|
203
|
+
setChannelStatus({});
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
loadChannels(activeAgentId);
|
|
207
|
+
}, [activeAgentId, loadChannels, runtimeAuthToken]);
|
|
208
|
+
const reloadPendingConnector = useCallback(() => {
|
|
209
|
+
const flow = connectorFlowRef.current;
|
|
210
|
+
if (!flow || flow.cancelled) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
setTimeout(() => {
|
|
214
|
+
loadConnectors(flow.agentId);
|
|
215
|
+
}, 1200);
|
|
216
|
+
}, [loadConnectors]);
|
|
217
|
+
const reloadChannelsOnResume = useCallback(() => {
|
|
218
|
+
if (!activeAgentId) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
setTimeout(() => {
|
|
222
|
+
loadChannels(activeAgentId);
|
|
223
|
+
}, 1200);
|
|
224
|
+
}, [activeAgentId, loadChannels]);
|
|
225
|
+
const completePendingConnectorFromCallback = useCallback(async event => {
|
|
226
|
+
const flow = connectorFlowRef.current;
|
|
227
|
+
if (!flow || flow.cancelled) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (event.status === 'success') {
|
|
231
|
+
flow.cancelled = true;
|
|
232
|
+
connectorFlowRef.current = null;
|
|
233
|
+
setConnectingConnectorId(null);
|
|
234
|
+
await loadConnectors(flow.agentId);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (event.status === 'error') {
|
|
238
|
+
flow.cancelled = true;
|
|
239
|
+
connectorFlowRef.current = null;
|
|
240
|
+
setConnectingConnectorId(null);
|
|
241
|
+
await loadConnectors(flow.agentId);
|
|
242
|
+
showAlert(nativeAdapters, 'Connector failed', 'OAuth authorization did not complete. Please try connecting again.');
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
await loadConnectors(flow.agentId);
|
|
246
|
+
}, [loadConnectors, nativeAdapters]);
|
|
247
|
+
useEffect(() => {
|
|
248
|
+
return nativeAdapters.subscribeToExternalAuthCallbacks?.(completePendingConnectorFromCallback);
|
|
249
|
+
}, [completePendingConnectorFromCallback, nativeAdapters]);
|
|
250
|
+
useEffect(() => {
|
|
251
|
+
const unsubscribeResume = nativeAdapters.subscribeToAppResume?.(() => {
|
|
252
|
+
reloadPendingConnector();
|
|
253
|
+
reloadChannelsOnResume();
|
|
254
|
+
});
|
|
255
|
+
const unsubscribeDeepLinks = nativeAdapters.subscribeToDeepLinks?.(url => {
|
|
256
|
+
if (nativeAdapters.isExternalAuthCallbackUrl?.(url)) {
|
|
257
|
+
nativeAdapters.completeExternalAuthCallback?.(url);
|
|
258
|
+
reloadPendingConnector();
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
return () => {
|
|
262
|
+
unsubscribeResume?.();
|
|
263
|
+
unsubscribeDeepLinks?.();
|
|
264
|
+
};
|
|
265
|
+
}, [nativeAdapters, reloadChannelsOnResume, reloadPendingConnector]);
|
|
266
|
+
useEffect(() => {
|
|
267
|
+
return () => {
|
|
268
|
+
if (connectorFlowRef.current) {
|
|
269
|
+
connectorFlowRef.current.cancelled = true;
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
}, []);
|
|
273
|
+
const apiClient = useMemo(() => {
|
|
274
|
+
if (!activeAgentId) {
|
|
275
|
+
return undefined;
|
|
276
|
+
}
|
|
277
|
+
return createSuperagentNativeClient({
|
|
278
|
+
apiBaseUrl: `${normalizeBaseUrl(config.baseUrl)}/api/apps`,
|
|
279
|
+
appId: activeAgentId,
|
|
280
|
+
getAuthToken: config.getAccessToken,
|
|
281
|
+
getHeaders: config.getHeaders
|
|
282
|
+
});
|
|
283
|
+
}, [activeAgentId, config.baseUrl, config.getAccessToken, config.getHeaders]);
|
|
284
|
+
useEffect(() => {
|
|
285
|
+
if (!activeAgentId) {
|
|
286
|
+
setRuntimeAuthToken(null);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
let cancelled = false;
|
|
290
|
+
setRuntimeAuthToken(null);
|
|
291
|
+
superagentService.getRuntimeAuthToken(activeAgentId).then(token => {
|
|
292
|
+
if (!cancelled) {
|
|
293
|
+
setRuntimeAuthToken(token);
|
|
294
|
+
}
|
|
295
|
+
}).catch(() => {
|
|
296
|
+
if (!cancelled) {
|
|
297
|
+
setRuntimeAuthToken(null);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
return () => {
|
|
301
|
+
cancelled = true;
|
|
302
|
+
};
|
|
303
|
+
}, [activeAgentId, superagentService]);
|
|
304
|
+
useEffect(() => {
|
|
305
|
+
if (!activeAgentId || !runtimeAuthToken) {
|
|
306
|
+
setRealtimeClient(undefined);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
const socket = nativeAdapters.createRealtimeSocket?.({
|
|
310
|
+
appId: activeAgentId,
|
|
311
|
+
baseUrl: config.baseUrl,
|
|
312
|
+
token: runtimeAuthToken
|
|
313
|
+
});
|
|
314
|
+
if (!socket) {
|
|
315
|
+
setRealtimeClient(undefined);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
setRealtimeClient(createSuperagentSocketClient({
|
|
319
|
+
socket
|
|
320
|
+
}));
|
|
321
|
+
return () => {
|
|
322
|
+
socket.disconnect?.();
|
|
323
|
+
};
|
|
324
|
+
}, [activeAgentId, config.baseUrl, nativeAdapters, runtimeAuthToken]);
|
|
325
|
+
const onCreateAgent = useCallback(async () => {
|
|
326
|
+
const createdAgent = await superagentService.createAgent();
|
|
327
|
+
setAgents(current => [createdAgent, ...current.filter(agent => agent.id !== createdAgent.id)]);
|
|
328
|
+
setActiveAgentId(createdAgent.id);
|
|
329
|
+
setLoadError(null);
|
|
330
|
+
return createdAgent;
|
|
331
|
+
}, [superagentService]);
|
|
332
|
+
const onOpenAgent = useCallback(agentId => {
|
|
333
|
+
setActiveAgentId(agentId);
|
|
334
|
+
}, [superagentService]);
|
|
335
|
+
const onRenameAgent = useCallback(async ({
|
|
336
|
+
agentId,
|
|
337
|
+
name
|
|
338
|
+
}) => {
|
|
339
|
+
const updatedAgent = await superagentService.renameAgent(agentId, name);
|
|
340
|
+
setAgents(current => current.map(agent => agent.id === agentId ? {
|
|
341
|
+
...agent,
|
|
342
|
+
...updatedAgent,
|
|
343
|
+
name: updatedAgent.name || name
|
|
344
|
+
} : agent));
|
|
345
|
+
return updatedAgent;
|
|
346
|
+
}, [superagentService]);
|
|
347
|
+
const onUpdateAgentModel = useCallback(async ({
|
|
348
|
+
agentId,
|
|
349
|
+
model
|
|
350
|
+
}) => {
|
|
351
|
+
try {
|
|
352
|
+
const updatedAgent = await superagentService.updateAgentModel(agentId, model);
|
|
353
|
+
setAgents(current => current.map(agent => agent.id === agentId ? {
|
|
354
|
+
...agent,
|
|
355
|
+
...updatedAgent
|
|
356
|
+
} : agent));
|
|
357
|
+
} catch (error) {
|
|
358
|
+
showAlert(nativeAdapters, 'Model update failed', getErrorMessage(error));
|
|
359
|
+
}
|
|
360
|
+
}, [nativeAdapters, superagentService]);
|
|
361
|
+
const onUpdateToolPermissions = useCallback(async ({
|
|
362
|
+
agentId,
|
|
363
|
+
config
|
|
364
|
+
}) => {
|
|
365
|
+
try {
|
|
366
|
+
const updatedAgent = await superagentService.updateToolPermissions(agentId, config);
|
|
367
|
+
setAgents(current => current.map(agent => agent.id === agentId ? {
|
|
368
|
+
...agent,
|
|
369
|
+
...updatedAgent
|
|
370
|
+
} : agent));
|
|
371
|
+
} catch (error) {
|
|
372
|
+
showAlert(nativeAdapters, 'Permissions update failed', getErrorMessage(error));
|
|
373
|
+
}
|
|
374
|
+
}, [nativeAdapters, superagentService]);
|
|
375
|
+
const onSaveSecret = useCallback(async ({
|
|
376
|
+
agentId,
|
|
377
|
+
name,
|
|
378
|
+
value
|
|
379
|
+
}) => {
|
|
380
|
+
try {
|
|
381
|
+
await superagentService.saveSecret(agentId, name, value);
|
|
382
|
+
await loadAgentSettings(agentId);
|
|
383
|
+
} catch (error) {
|
|
384
|
+
showAlert(nativeAdapters, 'Secret save failed', getErrorMessage(error));
|
|
385
|
+
}
|
|
386
|
+
}, [loadAgentSettings, nativeAdapters, superagentService]);
|
|
387
|
+
const onDeleteSecret = useCallback(async ({
|
|
388
|
+
agentId,
|
|
389
|
+
name
|
|
390
|
+
}) => {
|
|
391
|
+
const confirmed = await confirmAction(nativeAdapters, {
|
|
392
|
+
confirmText: 'Delete',
|
|
393
|
+
destructive: true,
|
|
394
|
+
message: `Delete "${name}" permanently?`,
|
|
395
|
+
title: 'Delete secret?'
|
|
396
|
+
});
|
|
397
|
+
if (!confirmed) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
try {
|
|
401
|
+
await superagentService.deleteSecret(agentId, name);
|
|
402
|
+
await loadAgentSettings(agentId);
|
|
403
|
+
} catch (error) {
|
|
404
|
+
showAlert(nativeAdapters, 'Secret delete failed', getErrorMessage(error));
|
|
405
|
+
}
|
|
406
|
+
}, [loadAgentSettings, nativeAdapters, superagentService]);
|
|
407
|
+
const onShareAgent = useCallback(async ({
|
|
408
|
+
agentId,
|
|
409
|
+
addAsGuest,
|
|
410
|
+
emails
|
|
411
|
+
}) => {
|
|
412
|
+
const result = await superagentService.inviteCollaborators(agentId, emails, addAsGuest);
|
|
413
|
+
await loadCollaborators(agentId);
|
|
414
|
+
return result;
|
|
415
|
+
}, [loadCollaborators, superagentService]);
|
|
416
|
+
const onShareAgentLink = useCallback(async ({
|
|
417
|
+
agentId
|
|
418
|
+
}) => {
|
|
419
|
+
const agent = agents.find(item => item.id === agentId);
|
|
420
|
+
const url = buildWebUrl(config.webUrl ?? config.baseUrl, `/superagent/${encodeURIComponent(agentId)}`);
|
|
421
|
+
if (nativeAdapters.share) {
|
|
422
|
+
await nativeAdapters.share({
|
|
423
|
+
message: `Open ${agent?.name || 'this Superagent'} in Base44:\n${url}`,
|
|
424
|
+
title: agent?.name || 'Superagent',
|
|
425
|
+
url
|
|
426
|
+
});
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
if (nativeAdapters.openWebUrl) {
|
|
430
|
+
await nativeAdapters.openWebUrl(url);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
showAlert(nativeAdapters, 'Share unavailable', url);
|
|
434
|
+
}, [agents, config.baseUrl, config.webUrl, nativeAdapters]);
|
|
435
|
+
const onOpenWorkspaceMembers = useCallback(({
|
|
436
|
+
organizationId
|
|
437
|
+
}) => {
|
|
438
|
+
if (!organizationId) {
|
|
439
|
+
showAlert(nativeAdapters, 'Workspace unavailable', 'Open workspace settings from the web to add this person as a workspace member.');
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
nativeAdapters.openWebUrl?.(buildWebUrl(config.webUrl ?? config.baseUrl, `/workspace/${encodeURIComponent(organizationId)}/settings/seats-members`));
|
|
443
|
+
}, [config.baseUrl, config.webUrl, nativeAdapters]);
|
|
444
|
+
const onCloneAgent = useCallback(({
|
|
445
|
+
agentId
|
|
446
|
+
}) => {
|
|
447
|
+
nativeAdapters.openWebUrl?.(buildWebUrl(config.webUrl ?? config.baseUrl, `/remix-app/${encodeURIComponent(agentId)}?clone_history=true`));
|
|
448
|
+
}, [config.baseUrl, config.webUrl, nativeAdapters]);
|
|
449
|
+
const onDeleteAgent = useCallback(async ({
|
|
450
|
+
agentId
|
|
451
|
+
}) => {
|
|
452
|
+
const agent = agents.find(item => item.id === agentId);
|
|
453
|
+
const confirmed = await confirmAction(nativeAdapters, {
|
|
454
|
+
confirmText: 'Delete',
|
|
455
|
+
destructive: true,
|
|
456
|
+
message: `Delete "${agent?.name || 'this Superagent'}" permanently?`,
|
|
457
|
+
title: 'Delete Superagent?'
|
|
458
|
+
});
|
|
459
|
+
if (!confirmed) {
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
try {
|
|
463
|
+
await superagentService.deleteAgent(agentId);
|
|
464
|
+
setAgents(current => current.filter(item => item.id !== agentId));
|
|
465
|
+
setSecrets([]);
|
|
466
|
+
setActiveAgentId(current => current === agentId ? null : current);
|
|
467
|
+
setCurrentRoute({
|
|
468
|
+
name: 'home'
|
|
469
|
+
});
|
|
470
|
+
} catch (error) {
|
|
471
|
+
showAlert(nativeAdapters, 'Delete failed', getErrorMessage(error));
|
|
472
|
+
}
|
|
473
|
+
}, [agents, nativeAdapters, superagentService]);
|
|
474
|
+
const onToggleAutomation = useCallback(async ({
|
|
475
|
+
agentId,
|
|
476
|
+
automation
|
|
477
|
+
}) => {
|
|
478
|
+
try {
|
|
479
|
+
const updatedAutomation = await superagentService.toggleAutomation(agentId, automation);
|
|
480
|
+
setAutomations(current => current.map(item => item.id === automation.id ? {
|
|
481
|
+
...item,
|
|
482
|
+
...updatedAutomation
|
|
483
|
+
} : item));
|
|
484
|
+
void loadAutomationCredits(agentId);
|
|
485
|
+
} catch (error) {
|
|
486
|
+
showAlert(nativeAdapters, 'Automation failed', getErrorMessage(error));
|
|
487
|
+
}
|
|
488
|
+
}, [loadAutomationCredits, nativeAdapters, superagentService]);
|
|
489
|
+
const onArchiveAutomation = useCallback(async ({
|
|
490
|
+
agentId,
|
|
491
|
+
automation
|
|
492
|
+
}) => {
|
|
493
|
+
try {
|
|
494
|
+
const updatedAutomation = await superagentService.archiveAutomation(agentId, automation);
|
|
495
|
+
setAutomations(current => current.map(item => item.id === automation.id ? {
|
|
496
|
+
...item,
|
|
497
|
+
...updatedAutomation,
|
|
498
|
+
is_active: false,
|
|
499
|
+
is_archived: true
|
|
500
|
+
} : item));
|
|
501
|
+
void loadAutomationCredits(agentId);
|
|
502
|
+
} catch (error) {
|
|
503
|
+
showAlert(nativeAdapters, 'Archive failed', getErrorMessage(error));
|
|
504
|
+
}
|
|
505
|
+
}, [loadAutomationCredits, nativeAdapters, superagentService]);
|
|
506
|
+
const onRestoreAutomation = useCallback(async ({
|
|
507
|
+
agentId,
|
|
508
|
+
automation
|
|
509
|
+
}) => {
|
|
510
|
+
try {
|
|
511
|
+
const updatedAutomation = await superagentService.restoreAutomation(agentId, automation);
|
|
512
|
+
setAutomations(current => current.map(item => item.id === automation.id ? {
|
|
513
|
+
...item,
|
|
514
|
+
...updatedAutomation,
|
|
515
|
+
is_active: true,
|
|
516
|
+
is_archived: false
|
|
517
|
+
} : item));
|
|
518
|
+
void loadAutomationCredits(agentId);
|
|
519
|
+
} catch (error) {
|
|
520
|
+
showAlert(nativeAdapters, 'Restore failed', getErrorMessage(error));
|
|
521
|
+
}
|
|
522
|
+
}, [loadAutomationCredits, nativeAdapters, superagentService]);
|
|
523
|
+
const onDeleteAutomation = useCallback(async ({
|
|
524
|
+
agentId,
|
|
525
|
+
automation
|
|
526
|
+
}) => {
|
|
527
|
+
const confirmed = await confirmAction(nativeAdapters, {
|
|
528
|
+
confirmText: 'Delete',
|
|
529
|
+
destructive: true,
|
|
530
|
+
message: `Delete "${automation.name}" permanently?`,
|
|
531
|
+
title: 'Delete automation?'
|
|
532
|
+
});
|
|
533
|
+
if (!confirmed) {
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
try {
|
|
537
|
+
await superagentService.deleteAutomation(agentId, automation);
|
|
538
|
+
setAutomations(current => current.filter(item => item.id !== automation.id));
|
|
539
|
+
setAutomationCredits(current => {
|
|
540
|
+
const next = {
|
|
541
|
+
...current
|
|
542
|
+
};
|
|
543
|
+
delete next[automation.id];
|
|
544
|
+
return next;
|
|
545
|
+
});
|
|
546
|
+
} catch (error) {
|
|
547
|
+
showAlert(nativeAdapters, 'Delete failed', getErrorMessage(error));
|
|
548
|
+
}
|
|
549
|
+
}, [nativeAdapters, superagentService]);
|
|
550
|
+
const onRunAutomationNow = useCallback(async ({
|
|
551
|
+
agentId,
|
|
552
|
+
automation
|
|
553
|
+
}) => {
|
|
554
|
+
try {
|
|
555
|
+
await superagentService.runAutomationNow(agentId, automation);
|
|
556
|
+
await refreshAutomations(agentId);
|
|
557
|
+
} catch (error) {
|
|
558
|
+
showAlert(nativeAdapters, 'Run failed', getErrorMessage(error));
|
|
559
|
+
}
|
|
560
|
+
}, [nativeAdapters, refreshAutomations, superagentService]);
|
|
561
|
+
const onEditAutomation = useCallback(({
|
|
562
|
+
agentId
|
|
563
|
+
}) => {
|
|
564
|
+
nativeAdapters.openWebUrl?.(buildWebUrl(config.webUrl ?? config.baseUrl, `/superagent/${encodeURIComponent(agentId)}`));
|
|
565
|
+
}, [config.baseUrl, config.webUrl, nativeAdapters]);
|
|
566
|
+
const onOpenSandboxFile = useCallback(async ({
|
|
567
|
+
agentId,
|
|
568
|
+
path
|
|
569
|
+
}) => {
|
|
570
|
+
return superagentService.readSandboxFile(agentId, path);
|
|
571
|
+
}, [superagentService]);
|
|
572
|
+
const onSaveSandboxFile = useCallback(async ({
|
|
573
|
+
agentId,
|
|
574
|
+
content,
|
|
575
|
+
path
|
|
576
|
+
}) => {
|
|
577
|
+
try {
|
|
578
|
+
await superagentService.writeSandboxFile(agentId, path, content);
|
|
579
|
+
await loadFiles(agentId);
|
|
580
|
+
} catch (error) {
|
|
581
|
+
showAlert(nativeAdapters, 'Save failed', getErrorMessage(error));
|
|
582
|
+
throw error;
|
|
583
|
+
}
|
|
584
|
+
}, [loadFiles, nativeAdapters, superagentService]);
|
|
585
|
+
const onUploadSandboxFiles = useCallback(async ({
|
|
586
|
+
agentId
|
|
587
|
+
}) => {
|
|
588
|
+
try {
|
|
589
|
+
const files = await nativeAdapters.pickSandboxFiles?.();
|
|
590
|
+
if (!files?.length) {
|
|
591
|
+
return [];
|
|
592
|
+
}
|
|
593
|
+
for (const file of files) {
|
|
594
|
+
await superagentService.writeSandboxFile(agentId, file.name, file.content);
|
|
595
|
+
}
|
|
596
|
+
await loadFiles(agentId);
|
|
597
|
+
return files.map(file => ({
|
|
598
|
+
path: file.name
|
|
599
|
+
}));
|
|
600
|
+
} catch (error) {
|
|
601
|
+
if (nativeAdapters.isAttachmentPickerCancel?.(error)) {
|
|
602
|
+
return [];
|
|
603
|
+
}
|
|
604
|
+
showAlert(nativeAdapters, 'Upload failed', getErrorMessage(error));
|
|
605
|
+
throw error;
|
|
606
|
+
}
|
|
607
|
+
}, [loadFiles, nativeAdapters, superagentService]);
|
|
608
|
+
const onRouteChange = useCallback(route => {
|
|
609
|
+
setCurrentRoute(route);
|
|
610
|
+
if (route.name === 'agent') {
|
|
611
|
+
setActiveAgentId(route.agentId);
|
|
612
|
+
}
|
|
613
|
+
}, []);
|
|
614
|
+
const onStartLiveVoice = useCallback(async context => {
|
|
615
|
+
const session = await superagentService.createVoiceLiveSession(context.agentId, context.conversationId);
|
|
616
|
+
try {
|
|
617
|
+
await startBackendVoiceLiveSession(session, nativeAdapters.liveVoiceAudio);
|
|
618
|
+
} finally {
|
|
619
|
+
await superagentService.deleteVoiceLiveSession(context.agentId, session.sessionId).catch(() => undefined);
|
|
620
|
+
}
|
|
621
|
+
}, [nativeAdapters, superagentService]);
|
|
622
|
+
const onOpenWhatsApp = useCallback(async ({
|
|
623
|
+
agentId
|
|
624
|
+
}) => {
|
|
625
|
+
setConnectingChannelId('whatsapp');
|
|
626
|
+
try {
|
|
627
|
+
const token = await resolveRuntimeToken(agentId);
|
|
628
|
+
const connectUrl = superagentService.getWhatsAppConnectUrl(agentId, token);
|
|
629
|
+
setChannelStatus(current => ({
|
|
630
|
+
...current,
|
|
631
|
+
whatsapp: {
|
|
632
|
+
...current.whatsapp,
|
|
633
|
+
connectUrl
|
|
634
|
+
}
|
|
635
|
+
}));
|
|
636
|
+
await nativeAdapters.openUrl?.(connectUrl);
|
|
637
|
+
} catch (error) {
|
|
638
|
+
showAlert(nativeAdapters, 'WhatsApp setup failed', getErrorMessage(error));
|
|
639
|
+
} finally {
|
|
640
|
+
setConnectingChannelId(null);
|
|
641
|
+
}
|
|
642
|
+
}, [nativeAdapters, resolveRuntimeToken, superagentService]);
|
|
643
|
+
const onSetupTelegram = useCallback(async ({
|
|
644
|
+
agentId,
|
|
645
|
+
token
|
|
646
|
+
}) => {
|
|
647
|
+
setConnectingChannelId('telegram');
|
|
648
|
+
try {
|
|
649
|
+
const runtimeToken = await resolveRuntimeToken(agentId);
|
|
650
|
+
const telegram = await superagentService.setupTelegram(agentId, runtimeToken, token);
|
|
651
|
+
setChannelStatus(current => ({
|
|
652
|
+
...current,
|
|
653
|
+
telegram
|
|
654
|
+
}));
|
|
655
|
+
} finally {
|
|
656
|
+
setConnectingChannelId(null);
|
|
657
|
+
}
|
|
658
|
+
}, [resolveRuntimeToken, superagentService]);
|
|
659
|
+
const onDisconnectTelegram = useCallback(async ({
|
|
660
|
+
agentId
|
|
661
|
+
}) => {
|
|
662
|
+
const confirmed = await confirmAction(nativeAdapters, {
|
|
663
|
+
confirmText: 'Disconnect',
|
|
664
|
+
destructive: true,
|
|
665
|
+
message: 'The Telegram bot webhook will be removed from this Superagent.',
|
|
666
|
+
title: 'Disconnect Telegram?'
|
|
667
|
+
});
|
|
668
|
+
if (!confirmed) {
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
setConnectingChannelId('telegram');
|
|
672
|
+
try {
|
|
673
|
+
const token = await resolveRuntimeToken(agentId);
|
|
674
|
+
await superagentService.disconnectTelegram(agentId, token);
|
|
675
|
+
setChannelStatus(current => ({
|
|
676
|
+
...current,
|
|
677
|
+
telegram: {
|
|
678
|
+
connected: false
|
|
679
|
+
}
|
|
680
|
+
}));
|
|
681
|
+
} catch (error) {
|
|
682
|
+
showAlert(nativeAdapters, 'Telegram disconnect failed', getErrorMessage(error));
|
|
683
|
+
} finally {
|
|
684
|
+
setConnectingChannelId(null);
|
|
685
|
+
}
|
|
686
|
+
}, [nativeAdapters, resolveRuntimeToken, superagentService]);
|
|
687
|
+
const onGenerateLineCode = useCallback(async ({
|
|
688
|
+
agentId
|
|
689
|
+
}) => {
|
|
690
|
+
setConnectingChannelId('line');
|
|
691
|
+
try {
|
|
692
|
+
const token = await resolveRuntimeToken(agentId);
|
|
693
|
+
const activation = await superagentService.generateLineCode(agentId, token);
|
|
694
|
+
setChannelStatus(current => ({
|
|
695
|
+
...current,
|
|
696
|
+
line: {
|
|
697
|
+
...current.line,
|
|
698
|
+
activation,
|
|
699
|
+
connected: false
|
|
700
|
+
}
|
|
701
|
+
}));
|
|
702
|
+
} catch (error) {
|
|
703
|
+
showAlert(nativeAdapters, 'LINE setup failed', getErrorMessage(error));
|
|
704
|
+
} finally {
|
|
705
|
+
setConnectingChannelId(null);
|
|
706
|
+
}
|
|
707
|
+
}, [nativeAdapters, resolveRuntimeToken, superagentService]);
|
|
708
|
+
const onGenerateIMessageCode = useCallback(async ({
|
|
709
|
+
agentId
|
|
710
|
+
}) => {
|
|
711
|
+
setConnectingChannelId('imessage');
|
|
712
|
+
try {
|
|
713
|
+
const token = await resolveRuntimeToken(agentId);
|
|
714
|
+
const activation = await superagentService.generateIMessageCode(agentId, token);
|
|
715
|
+
setChannelStatus(current => ({
|
|
716
|
+
...current,
|
|
717
|
+
imessage: {
|
|
718
|
+
...current.imessage,
|
|
719
|
+
activation,
|
|
720
|
+
connected: current.imessage?.connected ?? false
|
|
721
|
+
}
|
|
722
|
+
}));
|
|
723
|
+
return activation;
|
|
724
|
+
} catch (error) {
|
|
725
|
+
showAlert(nativeAdapters, 'iMessage setup failed', getErrorMessage(error));
|
|
726
|
+
throw error;
|
|
727
|
+
} finally {
|
|
728
|
+
setConnectingChannelId(null);
|
|
729
|
+
}
|
|
730
|
+
}, [nativeAdapters, resolveRuntimeToken, superagentService]);
|
|
731
|
+
const onDisconnectIMessage = useCallback(async ({
|
|
732
|
+
agentId
|
|
733
|
+
}) => {
|
|
734
|
+
const confirmed = await confirmAction(nativeAdapters, {
|
|
735
|
+
confirmText: 'Disconnect',
|
|
736
|
+
destructive: true,
|
|
737
|
+
message: 'Existing iMessage users will need to reconnect with a new activation code.',
|
|
738
|
+
title: 'Disconnect iMessage?'
|
|
739
|
+
});
|
|
740
|
+
if (!confirmed) {
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
setConnectingChannelId('imessage');
|
|
744
|
+
try {
|
|
745
|
+
const token = await resolveRuntimeToken(agentId);
|
|
746
|
+
const imessage = await superagentService.disconnectIMessage(agentId, token);
|
|
747
|
+
setChannelStatus(current => ({
|
|
748
|
+
...current,
|
|
749
|
+
imessage
|
|
750
|
+
}));
|
|
751
|
+
} catch (error) {
|
|
752
|
+
showAlert(nativeAdapters, 'iMessage disconnect failed', getErrorMessage(error));
|
|
753
|
+
} finally {
|
|
754
|
+
setConnectingChannelId(null);
|
|
755
|
+
}
|
|
756
|
+
}, [nativeAdapters, resolveRuntimeToken, superagentService]);
|
|
757
|
+
const onOpenIMessage = useCallback(async ({
|
|
758
|
+
code,
|
|
759
|
+
phoneNumber
|
|
760
|
+
}) => {
|
|
761
|
+
try {
|
|
762
|
+
await nativeAdapters.openUrl?.(buildIMessageUrl(phoneNumber, code));
|
|
763
|
+
} catch (error) {
|
|
764
|
+
showAlert(nativeAdapters, 'iMessage link unavailable', getErrorMessage(error));
|
|
765
|
+
}
|
|
766
|
+
}, [nativeAdapters]);
|
|
767
|
+
const onOpenTelegram = useCallback(async ({
|
|
768
|
+
url
|
|
769
|
+
}) => {
|
|
770
|
+
await openAllowedExternalUrl(nativeAdapters, url, ['t.me', 'telegram.me'], 'Telegram link unavailable');
|
|
771
|
+
}, [nativeAdapters]);
|
|
772
|
+
const onOpenLine = useCallback(async ({
|
|
773
|
+
url
|
|
774
|
+
}) => {
|
|
775
|
+
await openAllowedExternalUrl(nativeAdapters, url, ['line.me'], 'LINE link unavailable');
|
|
776
|
+
}, [nativeAdapters]);
|
|
777
|
+
const onShareLineCode = useCallback(async ({
|
|
778
|
+
addFriendUrl,
|
|
779
|
+
code
|
|
780
|
+
}) => {
|
|
781
|
+
await nativeAdapters.share?.({
|
|
782
|
+
message: `LINE activation code: ${code}\n${addFriendUrl}`,
|
|
783
|
+
title: 'LINE activation code',
|
|
784
|
+
url: addFriendUrl
|
|
785
|
+
});
|
|
786
|
+
}, [nativeAdapters]);
|
|
787
|
+
const onShareIMessageCode = useCallback(async ({
|
|
788
|
+
code,
|
|
789
|
+
phoneNumber
|
|
790
|
+
}) => {
|
|
791
|
+
await nativeAdapters.share?.({
|
|
792
|
+
message: `Text ${code} to ${phoneNumber} to connect this Superagent on iMessage.`,
|
|
793
|
+
title: 'iMessage activation code',
|
|
794
|
+
url: buildIMessageUrl(phoneNumber, code)
|
|
795
|
+
});
|
|
796
|
+
}, [nativeAdapters]);
|
|
797
|
+
const onConnectConnector = useCallback(async ({
|
|
798
|
+
accessMode,
|
|
799
|
+
agentId,
|
|
800
|
+
connectorId,
|
|
801
|
+
forceReconnect,
|
|
802
|
+
scopes
|
|
803
|
+
}) => {
|
|
804
|
+
if (connectorFlowRef.current) {
|
|
805
|
+
connectorFlowRef.current.cancelled = true;
|
|
806
|
+
}
|
|
807
|
+
const flow = {
|
|
808
|
+
agentId,
|
|
809
|
+
cancelled: false,
|
|
810
|
+
connectorId
|
|
811
|
+
};
|
|
812
|
+
connectorFlowRef.current = flow;
|
|
813
|
+
setConnectingConnectorId(connectorId);
|
|
814
|
+
try {
|
|
815
|
+
const connection = await superagentService.initiateConnectorConnection(agentId, connectorId, {
|
|
816
|
+
accessMode,
|
|
817
|
+
forceReconnect,
|
|
818
|
+
scopes
|
|
819
|
+
});
|
|
820
|
+
if (connection.error) {
|
|
821
|
+
throw new Error(connection.error_message || connection.error);
|
|
822
|
+
}
|
|
823
|
+
if (connection.already_authorized) {
|
|
824
|
+
connectorFlowRef.current = null;
|
|
825
|
+
setConnectingConnectorId(null);
|
|
826
|
+
await loadConnectors(agentId);
|
|
827
|
+
return true;
|
|
828
|
+
}
|
|
829
|
+
if (!connection.redirect_url || !connection.connection_id) {
|
|
830
|
+
throw new Error('The backend did not return an authorization URL for this connector.');
|
|
831
|
+
}
|
|
832
|
+
await nativeAdapters.openUrl?.(connection.redirect_url);
|
|
833
|
+
await waitForConnectorAuthorization(superagentService, agentId, connectorId, connection.connection_id, flow);
|
|
834
|
+
if (!flow.cancelled) {
|
|
835
|
+
connectorFlowRef.current = null;
|
|
836
|
+
setConnectingConnectorId(null);
|
|
837
|
+
await loadConnectors(agentId);
|
|
838
|
+
return true;
|
|
839
|
+
}
|
|
840
|
+
return false;
|
|
841
|
+
} catch (error) {
|
|
842
|
+
if (!flow.cancelled) {
|
|
843
|
+
connectorFlowRef.current = null;
|
|
844
|
+
setConnectingConnectorId(null);
|
|
845
|
+
showAlert(nativeAdapters, 'Connector failed', getErrorMessage(error));
|
|
846
|
+
await loadConnectors(agentId);
|
|
847
|
+
}
|
|
848
|
+
return false;
|
|
849
|
+
}
|
|
850
|
+
}, [loadConnectors, nativeAdapters, superagentService]);
|
|
851
|
+
const onCancelConnectorConnection = useCallback(({
|
|
852
|
+
agentId,
|
|
853
|
+
connectorId
|
|
854
|
+
}) => {
|
|
855
|
+
const flow = connectorFlowRef.current;
|
|
856
|
+
if (flow && flow.agentId === agentId && flow.connectorId === connectorId) {
|
|
857
|
+
flow.cancelled = true;
|
|
858
|
+
connectorFlowRef.current = null;
|
|
859
|
+
}
|
|
860
|
+
setConnectingConnectorId(null);
|
|
861
|
+
loadConnectors(agentId);
|
|
862
|
+
}, [loadConnectors]);
|
|
863
|
+
const onDisconnectConnector = useCallback(async ({
|
|
864
|
+
agentId,
|
|
865
|
+
connectorId
|
|
866
|
+
}) => {
|
|
867
|
+
const confirmed = await confirmAction(nativeAdapters, {
|
|
868
|
+
confirmText: 'Disconnect',
|
|
869
|
+
destructive: true,
|
|
870
|
+
message: 'The agent will stop using this connected account.',
|
|
871
|
+
title: 'Disconnect connector?'
|
|
872
|
+
});
|
|
873
|
+
if (!confirmed) {
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
try {
|
|
877
|
+
await superagentService.disconnectConnector(agentId, connectorId);
|
|
878
|
+
await loadConnectors(agentId);
|
|
879
|
+
} catch (error) {
|
|
880
|
+
showAlert(nativeAdapters, 'Disconnect failed', getErrorMessage(error));
|
|
881
|
+
}
|
|
882
|
+
}, [loadConnectors, nativeAdapters, superagentService]);
|
|
883
|
+
const onRemoveConnector = useCallback(async ({
|
|
884
|
+
agentId,
|
|
885
|
+
connectorId
|
|
886
|
+
}) => {
|
|
887
|
+
const confirmed = await confirmAction(nativeAdapters, {
|
|
888
|
+
confirmText: 'Remove',
|
|
889
|
+
destructive: true,
|
|
890
|
+
message: 'This removes the connector authorization from this agent.',
|
|
891
|
+
title: 'Remove connector?'
|
|
892
|
+
});
|
|
893
|
+
if (!confirmed) {
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
try {
|
|
897
|
+
await superagentService.removeConnector(agentId, connectorId);
|
|
898
|
+
await loadConnectors(agentId);
|
|
899
|
+
} catch (error) {
|
|
900
|
+
showAlert(nativeAdapters, 'Remove failed', getErrorMessage(error));
|
|
901
|
+
}
|
|
902
|
+
}, [loadConnectors, nativeAdapters, superagentService]);
|
|
903
|
+
return {
|
|
904
|
+
agents,
|
|
905
|
+
apiClient,
|
|
906
|
+
availableConnectors,
|
|
907
|
+
automationCredits,
|
|
908
|
+
automations,
|
|
909
|
+
channelStatus,
|
|
910
|
+
collaborators,
|
|
911
|
+
connectingChannelId,
|
|
912
|
+
connectingConnectorId,
|
|
913
|
+
connectedConnectors,
|
|
914
|
+
currentRoute,
|
|
915
|
+
currentUserAvatarUrl: config.currentUserAvatarUrl,
|
|
916
|
+
currentUserName: config.currentUserName,
|
|
917
|
+
fileLoadError,
|
|
918
|
+
fileLoadFailed,
|
|
919
|
+
filePaths,
|
|
920
|
+
isLoadingAgentSettings,
|
|
921
|
+
isLoadingChannels,
|
|
922
|
+
isLoadingCollaborators,
|
|
923
|
+
isLoadingConnectors,
|
|
924
|
+
isLoadingAutomations,
|
|
925
|
+
isLoadingFiles,
|
|
926
|
+
isLoading,
|
|
927
|
+
latestMessages: [],
|
|
928
|
+
loadError,
|
|
929
|
+
messagesByAgentId: {},
|
|
930
|
+
onAgentMessageDone: nativeAdapters.onAgentMessageDone,
|
|
931
|
+
onCancelConnectorConnection,
|
|
932
|
+
onArchiveAutomation,
|
|
933
|
+
onCloneAgent,
|
|
934
|
+
onConnectConnector,
|
|
935
|
+
onCreateAgent,
|
|
936
|
+
onDeleteAgent,
|
|
937
|
+
onDeleteAutomation,
|
|
938
|
+
onDeleteSecret,
|
|
939
|
+
onDisconnectConnector,
|
|
940
|
+
onDisconnectIMessage,
|
|
941
|
+
onDisconnectTelegram,
|
|
942
|
+
onEditAutomation,
|
|
943
|
+
onGenerateLineCode,
|
|
944
|
+
onGenerateIMessageCode,
|
|
945
|
+
onOpenIMessage,
|
|
946
|
+
onOpenLine,
|
|
947
|
+
onOpenAgent,
|
|
948
|
+
onOpenTelegram,
|
|
949
|
+
onOpenWhatsApp,
|
|
950
|
+
onOpenSandboxFile,
|
|
951
|
+
onOpenWorkspaceMembers,
|
|
952
|
+
onRemoveConnector,
|
|
953
|
+
onRenameAgent,
|
|
954
|
+
onRefreshAgentSettings: loadAgentSettings,
|
|
955
|
+
onRefreshAutomations: refreshAutomations,
|
|
956
|
+
onRefreshCollaborators: loadCollaborators,
|
|
957
|
+
onRefreshChannels: loadChannels,
|
|
958
|
+
onRefreshFiles: loadFiles,
|
|
959
|
+
onRestoreAutomation,
|
|
960
|
+
onRouteChange,
|
|
961
|
+
onRunAutomationNow,
|
|
962
|
+
onSaveSandboxFile,
|
|
963
|
+
onSaveSecret,
|
|
964
|
+
onShareAgent,
|
|
965
|
+
onShareAgentLink,
|
|
966
|
+
onShareIMessageCode,
|
|
967
|
+
onShareLineCode,
|
|
968
|
+
onStartLiveVoice,
|
|
969
|
+
onSetupTelegram,
|
|
970
|
+
onToggleAutomation,
|
|
971
|
+
onUpdateAgentModel,
|
|
972
|
+
onUpdateToolPermissions,
|
|
973
|
+
onUploadSandboxFiles,
|
|
974
|
+
realtimeClient,
|
|
975
|
+
secrets
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
async function waitForConnectorAuthorization(superagentService, agentId, connectorId, connectionId, flow) {
|
|
979
|
+
const maxAttempts = 40;
|
|
980
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
981
|
+
if (flow.cancelled) {
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
await delay(3000);
|
|
985
|
+
if (flow.cancelled) {
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
const status = await superagentService.getConnectorConnectionStatus(agentId, connectorId, connectionId);
|
|
989
|
+
if (status === 'ACTIVE') {
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
if (status === 'FAILED') {
|
|
993
|
+
throw new Error('OAuth connection failed.');
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
throw new Error('Connection timed out after 2 minutes.');
|
|
997
|
+
}
|
|
998
|
+
async function openAllowedExternalUrl(nativeAdapters, url, allowedHosts, fallbackMessage) {
|
|
999
|
+
if (!isAllowedExternalUrl(url, allowedHosts)) {
|
|
1000
|
+
showAlert(nativeAdapters, fallbackMessage, 'The backend returned a channel link that cannot be opened safely.');
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
try {
|
|
1004
|
+
await nativeAdapters.openUrl?.(url);
|
|
1005
|
+
} catch (error) {
|
|
1006
|
+
showAlert(nativeAdapters, fallbackMessage, getErrorMessage(error));
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
function showAlert(nativeAdapters, title, message) {
|
|
1010
|
+
nativeAdapters.alert?.(title, message);
|
|
1011
|
+
}
|
|
1012
|
+
async function confirmAction(nativeAdapters, input) {
|
|
1013
|
+
if (!nativeAdapters.confirm) {
|
|
1014
|
+
return true;
|
|
1015
|
+
}
|
|
1016
|
+
return nativeAdapters.confirm(input);
|
|
1017
|
+
}
|
|
1018
|
+
function buildWebUrl(baseUrl, path) {
|
|
1019
|
+
return `${normalizeBaseUrl(baseUrl)}${path.startsWith('/') ? path : `/${path}`}`;
|
|
1020
|
+
}
|
|
1021
|
+
function buildIMessageUrl(phoneNumber, code) {
|
|
1022
|
+
return `sms:${encodeURIComponent(phoneNumber)}?body=${encodeURIComponent(code)}`;
|
|
1023
|
+
}
|
|
1024
|
+
function normalizeBaseUrl(url) {
|
|
1025
|
+
return url.trim().replace(/\/+$/, '');
|
|
1026
|
+
}
|
|
1027
|
+
function isAllowedExternalUrl(url, allowedHosts) {
|
|
1028
|
+
try {
|
|
1029
|
+
const parsedUrl = new URL(url);
|
|
1030
|
+
if (parsedUrl.protocol !== 'https:') {
|
|
1031
|
+
return false;
|
|
1032
|
+
}
|
|
1033
|
+
return allowedHosts.some(host => parsedUrl.hostname === host || parsedUrl.hostname.endsWith(`.${host}`));
|
|
1034
|
+
} catch {
|
|
1035
|
+
return false;
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
function delay(ms) {
|
|
1039
|
+
return new Promise(resolve => {
|
|
1040
|
+
setTimeout(resolve, ms);
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
function getErrorMessage(error) {
|
|
1044
|
+
return error instanceof Error ? error.message : 'Failed to load Superagents';
|
|
1045
|
+
}
|
|
1046
|
+
const GEMINI_LIVE_INPUT_SAMPLE_RATE = 16000;
|
|
1047
|
+
const GEMINI_LIVE_INPUT_MIME_TYPE = `audio/pcm;rate=${GEMINI_LIVE_INPUT_SAMPLE_RATE}`;
|
|
1048
|
+
function startBackendVoiceLiveSession(session, audio) {
|
|
1049
|
+
if (!audio?.startAudioCapture) {
|
|
1050
|
+
throw new Error('Native Live Voice audio callbacks are not installed in this app build.');
|
|
1051
|
+
}
|
|
1052
|
+
return new Promise((resolve, reject) => {
|
|
1053
|
+
const socket = new WebSocket(session.websocketUrl, ['base44-voice']);
|
|
1054
|
+
let capture;
|
|
1055
|
+
let captureStarted = false;
|
|
1056
|
+
let setupComplete = false;
|
|
1057
|
+
let settled = false;
|
|
1058
|
+
const finish = async error => {
|
|
1059
|
+
if (settled) {
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
settled = true;
|
|
1063
|
+
clearTimeout(setupTimeout);
|
|
1064
|
+
try {
|
|
1065
|
+
if (!error && socket.readyState === WebSocket.OPEN) {
|
|
1066
|
+
socket.send(JSON.stringify({
|
|
1067
|
+
realtimeInput: {
|
|
1068
|
+
audioStreamEnd: true
|
|
1069
|
+
}
|
|
1070
|
+
}));
|
|
1071
|
+
}
|
|
1072
|
+
await capture?.stop?.();
|
|
1073
|
+
await audio.stopAudioCapture?.();
|
|
1074
|
+
await audio.stopAudioPlayback?.();
|
|
1075
|
+
} catch {
|
|
1076
|
+
// Cleanup should not hide the original Live Voice error.
|
|
1077
|
+
}
|
|
1078
|
+
if (socket.readyState === WebSocket.OPEN || socket.readyState === WebSocket.CONNECTING) {
|
|
1079
|
+
socket.close();
|
|
1080
|
+
}
|
|
1081
|
+
if (error) {
|
|
1082
|
+
reject(error);
|
|
1083
|
+
} else {
|
|
1084
|
+
resolve();
|
|
1085
|
+
}
|
|
1086
|
+
};
|
|
1087
|
+
const startCapture = async () => {
|
|
1088
|
+
if (captureStarted || settled) return;
|
|
1089
|
+
captureStarted = true;
|
|
1090
|
+
const canUseMicrophone = await audio.requestMicrophonePermission?.();
|
|
1091
|
+
if (canUseMicrophone === false) {
|
|
1092
|
+
await finish(new Error('Microphone access denied. Please allow microphone access to use Live Voice.'));
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1095
|
+
await audio.prepareAudioSession?.();
|
|
1096
|
+
capture = await audio.startAudioCapture({
|
|
1097
|
+
mimeType: GEMINI_LIVE_INPUT_MIME_TYPE,
|
|
1098
|
+
onAudioChunk(chunk) {
|
|
1099
|
+
if (settled || socket.readyState !== WebSocket.OPEN) return;
|
|
1100
|
+
socket.send(JSON.stringify({
|
|
1101
|
+
realtimeInput: {
|
|
1102
|
+
audio: {
|
|
1103
|
+
data: chunk.data,
|
|
1104
|
+
mimeType: chunk.mimeType ?? GEMINI_LIVE_INPUT_MIME_TYPE
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
}));
|
|
1108
|
+
},
|
|
1109
|
+
onError(error) {
|
|
1110
|
+
finish(error);
|
|
1111
|
+
},
|
|
1112
|
+
onStop() {
|
|
1113
|
+
finish();
|
|
1114
|
+
},
|
|
1115
|
+
sampleRate: GEMINI_LIVE_INPUT_SAMPLE_RATE
|
|
1116
|
+
});
|
|
1117
|
+
};
|
|
1118
|
+
const setupTimeout = setTimeout(() => {
|
|
1119
|
+
finish(new Error('Live Voice setup timed out.'));
|
|
1120
|
+
}, 60000);
|
|
1121
|
+
socket.onopen = () => {
|
|
1122
|
+
socket.send(JSON.stringify({
|
|
1123
|
+
base44Auth: {
|
|
1124
|
+
streamToken: session.streamToken
|
|
1125
|
+
}
|
|
1126
|
+
}));
|
|
1127
|
+
};
|
|
1128
|
+
socket.onmessage = event => {
|
|
1129
|
+
const payload = parseSocketPayload(event.data);
|
|
1130
|
+
if (payload && ('setupComplete' in payload || 'setup_complete' in payload)) {
|
|
1131
|
+
setupComplete = true;
|
|
1132
|
+
clearTimeout(setupTimeout);
|
|
1133
|
+
startCapture().catch(error => finish(error instanceof Error ? error : new Error('Failed to start Live Voice audio')));
|
|
1134
|
+
}
|
|
1135
|
+
if (payload && isGeminiLiveInterrupted(payload)) {
|
|
1136
|
+
audio.stopAudioPlayback?.();
|
|
1137
|
+
}
|
|
1138
|
+
for (const chunk of getGeminiLiveAudioChunks(payload)) {
|
|
1139
|
+
audio.playAudioChunk?.(chunk);
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
socket.onerror = () => {
|
|
1143
|
+
finish(new Error('Failed to connect to Live Voice'));
|
|
1144
|
+
};
|
|
1145
|
+
socket.onclose = event => {
|
|
1146
|
+
if (!setupComplete) {
|
|
1147
|
+
finish(new Error(getLiveVoiceCloseMessage(event)));
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
finish();
|
|
1151
|
+
};
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1154
|
+
function getLiveVoiceCloseMessage(event) {
|
|
1155
|
+
const reason = event.reason?.trim();
|
|
1156
|
+
if (reason) {
|
|
1157
|
+
return `Live Voice connection closed: ${event.code ?? 'unknown'} ${reason}`;
|
|
1158
|
+
}
|
|
1159
|
+
return `Live Voice connection closed: ${event.code ?? 'unknown'}`;
|
|
1160
|
+
}
|
|
1161
|
+
function parseSocketPayload(data) {
|
|
1162
|
+
if (typeof data !== 'string') {
|
|
1163
|
+
return null;
|
|
1164
|
+
}
|
|
1165
|
+
try {
|
|
1166
|
+
const payload = JSON.parse(data);
|
|
1167
|
+
return payload && typeof payload === 'object' ? payload : null;
|
|
1168
|
+
} catch {
|
|
1169
|
+
return null;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
function getGeminiLiveAudioChunks(payload) {
|
|
1173
|
+
const serverContent = getRecord(payload, 'serverContent') ?? getRecord(payload, 'server_content');
|
|
1174
|
+
const modelTurn = getRecord(serverContent, 'modelTurn') ?? getRecord(serverContent, 'model_turn');
|
|
1175
|
+
const parts = modelTurn?.parts;
|
|
1176
|
+
if (!Array.isArray(parts)) {
|
|
1177
|
+
return [];
|
|
1178
|
+
}
|
|
1179
|
+
return parts.flatMap(part => {
|
|
1180
|
+
const partRecord = asRecord(part);
|
|
1181
|
+
const inlineData = getRecord(partRecord, 'inlineData') ?? getRecord(partRecord, 'inline_data');
|
|
1182
|
+
const data = inlineData?.data;
|
|
1183
|
+
if (typeof data !== 'string' || data.length === 0) {
|
|
1184
|
+
return [];
|
|
1185
|
+
}
|
|
1186
|
+
const mimeType = inlineData?.mimeType;
|
|
1187
|
+
return [{
|
|
1188
|
+
data,
|
|
1189
|
+
mimeType: typeof mimeType === 'string' ? mimeType : undefined
|
|
1190
|
+
}];
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
function isGeminiLiveInterrupted(payload) {
|
|
1194
|
+
const serverContent = getRecord(payload, 'serverContent') ?? getRecord(payload, 'server_content');
|
|
1195
|
+
return serverContent?.interrupted === true;
|
|
1196
|
+
}
|
|
1197
|
+
function getRecord(value, key) {
|
|
1198
|
+
return asRecord(value?.[key]);
|
|
1199
|
+
}
|
|
1200
|
+
function asRecord(value) {
|
|
1201
|
+
return value && typeof value === 'object' ? value : null;
|
|
1202
|
+
}
|
|
1203
|
+
//# sourceMappingURL=useSuperagentRuntime.js.map
|