@base44/superagent-native 0.0.2 → 0.0.3
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/lib/commonjs/AgentSettingsPanel.js +123 -47
- package/lib/commonjs/AgentSettingsPanel.js.map +1 -1
- package/lib/commonjs/AgentSphereIcon.js +14 -118
- package/lib/commonjs/AgentSphereIcon.js.map +1 -1
- package/lib/commonjs/AttachmentPickerStatusModal.js +3 -2
- package/lib/commonjs/AttachmentPickerStatusModal.js.map +1 -1
- package/lib/commonjs/ChannelsPanel.js +66 -44
- package/lib/commonjs/ChannelsPanel.js.map +1 -1
- package/lib/commonjs/ConversationChat.js +11 -2
- package/lib/commonjs/ConversationChat.js.map +1 -1
- package/lib/commonjs/ConversationComposer.js +8 -7
- package/lib/commonjs/ConversationComposer.js.map +1 -1
- package/lib/commonjs/ConversationScreen.js +2 -0
- package/lib/commonjs/ConversationScreen.js.map +1 -1
- package/lib/commonjs/EditorDrawer.js +54 -24
- package/lib/commonjs/EditorDrawer.js.map +1 -1
- package/lib/commonjs/FilesPanel.js +56 -20
- package/lib/commonjs/FilesPanel.js.map +1 -1
- package/lib/commonjs/RenameAgentModal.js +2 -1
- package/lib/commonjs/RenameAgentModal.js.map +1 -1
- package/lib/commonjs/ShareAgentModal.js +11 -10
- package/lib/commonjs/ShareAgentModal.js.map +1 -1
- package/lib/commonjs/ShareAgentModal.styles.js +2 -2
- package/lib/commonjs/ShareAgentModal.styles.js.map +1 -1
- package/lib/commonjs/SuperagentHomeScreen.js +27 -9
- package/lib/commonjs/SuperagentHomeScreen.js.map +1 -1
- package/lib/commonjs/ToolApprovalCard.js +72 -14
- package/lib/commonjs/ToolApprovalCard.js.map +1 -1
- package/lib/commonjs/ToolCallSummary.js +14 -9
- package/lib/commonjs/ToolCallSummary.js.map +1 -1
- package/lib/commonjs/agentSphereAssets.js +327 -0
- package/lib/commonjs/agentSphereAssets.js.map +1 -0
- package/lib/commonjs/agentSphereStyles.js +3 -3
- package/lib/commonjs/agentSphereStyles.js.map +1 -1
- package/lib/commonjs/apiClient.js +7 -0
- package/lib/commonjs/apiClient.js.map +1 -1
- package/lib/commonjs/composerStyles.js +2 -2
- package/lib/commonjs/composerStyles.js.map +1 -1
- package/lib/commonjs/connectorBrandIcons.generated.js +625 -0
- package/lib/commonjs/connectorBrandIcons.generated.js.map +1 -0
- package/lib/commonjs/connectorBrandIcons.js +3 -55
- package/lib/commonjs/connectorBrandIcons.js.map +1 -1
- package/lib/commonjs/connectorCatalog.js +19 -1
- package/lib/commonjs/connectorCatalog.js.map +1 -1
- package/lib/commonjs/conversationParts.js +5 -4
- package/lib/commonjs/conversationParts.js.map +1 -1
- package/lib/commonjs/conversationRuntime.js +120 -12
- package/lib/commonjs/conversationRuntime.js.map +1 -1
- package/lib/commonjs/conversationStyles.js +2 -1
- package/lib/commonjs/conversationStyles.js.map +1 -1
- package/lib/commonjs/editorShellStyles.js +6 -2
- package/lib/commonjs/editorShellStyles.js.map +1 -1
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/markdownStyles.js +2 -2
- package/lib/commonjs/markdownStyles.js.map +1 -1
- package/lib/commonjs/messageActionStyles.js +2 -2
- package/lib/commonjs/messageActionStyles.js.map +1 -1
- package/lib/commonjs/realtimeClient.js +4 -1
- package/lib/commonjs/realtimeClient.js.map +1 -1
- package/lib/commonjs/renameAgentModalStyles.js +2 -2
- package/lib/commonjs/renameAgentModalStyles.js.map +1 -1
- package/lib/commonjs/screenParts.js +24 -41
- package/lib/commonjs/screenParts.js.map +1 -1
- package/lib/commonjs/styles.js +71 -60
- package/lib/commonjs/styles.js.map +1 -1
- package/lib/commonjs/superagentApiClient.js +63 -18
- package/lib/commonjs/superagentApiClient.js.map +1 -1
- package/lib/commonjs/theme.js +249 -0
- package/lib/commonjs/theme.js.map +1 -0
- package/lib/commonjs/useSuperagentConversation.js +133 -20
- package/lib/commonjs/useSuperagentConversation.js.map +1 -1
- package/lib/commonjs/useSuperagentRuntime.js +167 -82
- package/lib/commonjs/useSuperagentRuntime.js.map +1 -1
- package/lib/module/AgentSettingsPanel.js +125 -49
- package/lib/module/AgentSettingsPanel.js.map +1 -1
- package/lib/module/AgentSphereIcon.js +15 -118
- package/lib/module/AgentSphereIcon.js.map +1 -1
- package/lib/module/AttachmentPickerStatusModal.js +4 -3
- package/lib/module/AttachmentPickerStatusModal.js.map +1 -1
- package/lib/module/ChannelsPanel.js +67 -45
- package/lib/module/ChannelsPanel.js.map +1 -1
- package/lib/module/ConversationChat.js +11 -2
- package/lib/module/ConversationChat.js.map +1 -1
- package/lib/module/ConversationComposer.js +8 -7
- package/lib/module/ConversationComposer.js.map +1 -1
- package/lib/module/ConversationScreen.js +2 -0
- package/lib/module/ConversationScreen.js.map +1 -1
- package/lib/module/EditorDrawer.js +55 -25
- package/lib/module/EditorDrawer.js.map +1 -1
- package/lib/module/FilesPanel.js +56 -20
- package/lib/module/FilesPanel.js.map +1 -1
- package/lib/module/RenameAgentModal.js +2 -1
- package/lib/module/RenameAgentModal.js.map +1 -1
- package/lib/module/ShareAgentModal.js +11 -10
- package/lib/module/ShareAgentModal.js.map +1 -1
- package/lib/module/ShareAgentModal.styles.js +2 -2
- package/lib/module/ShareAgentModal.styles.js.map +1 -1
- package/lib/module/SuperagentHomeScreen.js +27 -9
- package/lib/module/SuperagentHomeScreen.js.map +1 -1
- package/lib/module/ToolApprovalCard.js +72 -14
- package/lib/module/ToolApprovalCard.js.map +1 -1
- package/lib/module/ToolCallSummary.js +14 -9
- package/lib/module/ToolCallSummary.js.map +1 -1
- package/lib/module/agentSphereAssets.js +323 -0
- package/lib/module/agentSphereAssets.js.map +1 -0
- package/lib/module/agentSphereStyles.js +3 -3
- package/lib/module/agentSphereStyles.js.map +1 -1
- package/lib/module/apiClient.js +7 -0
- package/lib/module/apiClient.js.map +1 -1
- package/lib/module/composerStyles.js +2 -2
- package/lib/module/composerStyles.js.map +1 -1
- package/lib/module/connectorBrandIcons.generated.js +621 -0
- package/lib/module/connectorBrandIcons.generated.js.map +1 -0
- package/lib/module/connectorBrandIcons.js +1 -53
- package/lib/module/connectorBrandIcons.js.map +1 -1
- package/lib/module/connectorCatalog.js +17 -0
- package/lib/module/connectorCatalog.js.map +1 -1
- package/lib/module/conversationParts.js +5 -4
- package/lib/module/conversationParts.js.map +1 -1
- package/lib/module/conversationRuntime.js +118 -12
- package/lib/module/conversationRuntime.js.map +1 -1
- package/lib/module/conversationStyles.js +3 -2
- package/lib/module/conversationStyles.js.map +1 -1
- package/lib/module/editorShellStyles.js +6 -2
- package/lib/module/editorShellStyles.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/markdownStyles.js +2 -2
- package/lib/module/markdownStyles.js.map +1 -1
- package/lib/module/messageActionStyles.js +2 -2
- package/lib/module/messageActionStyles.js.map +1 -1
- package/lib/module/realtimeClient.js +4 -1
- package/lib/module/realtimeClient.js.map +1 -1
- package/lib/module/renameAgentModalStyles.js +2 -2
- package/lib/module/renameAgentModalStyles.js.map +1 -1
- package/lib/module/screenParts.js +25 -42
- package/lib/module/screenParts.js.map +1 -1
- package/lib/module/styles.js +71 -60
- package/lib/module/styles.js.map +1 -1
- package/lib/module/superagentApiClient.js +63 -18
- package/lib/module/superagentApiClient.js.map +1 -1
- package/lib/module/theme.js +239 -0
- package/lib/module/theme.js.map +1 -0
- package/lib/module/useSuperagentConversation.js +135 -22
- package/lib/module/useSuperagentConversation.js.map +1 -1
- package/lib/module/useSuperagentRuntime.js +167 -82
- package/lib/module/useSuperagentRuntime.js.map +1 -1
- package/lib/typescript/commonjs/AgentSettingsPanel.d.ts.map +1 -1
- package/lib/typescript/commonjs/AgentSphereIcon.d.ts.map +1 -1
- package/lib/typescript/commonjs/AttachmentPickerStatusModal.d.ts.map +1 -1
- package/lib/typescript/commonjs/ChannelsPanel.d.ts.map +1 -1
- package/lib/typescript/commonjs/ConversationChat.d.ts +1 -1
- package/lib/typescript/commonjs/ConversationChat.d.ts.map +1 -1
- package/lib/typescript/commonjs/ConversationComposer.d.ts.map +1 -1
- package/lib/typescript/commonjs/ConversationMessageList.d.ts +1 -1
- package/lib/typescript/commonjs/ConversationMessageList.d.ts.map +1 -1
- package/lib/typescript/commonjs/ConversationScreen.d.ts +2 -1
- package/lib/typescript/commonjs/ConversationScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/EditorDrawer.d.ts +1 -1
- package/lib/typescript/commonjs/EditorDrawer.d.ts.map +1 -1
- package/lib/typescript/commonjs/FilesPanel.d.ts.map +1 -1
- package/lib/typescript/commonjs/RenameAgentModal.d.ts.map +1 -1
- package/lib/typescript/commonjs/ShareAgentModal.d.ts.map +1 -1
- package/lib/typescript/commonjs/ShareAgentModal.styles.d.ts.map +1 -1
- package/lib/typescript/commonjs/SuperagentHomeScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ToolApprovalCard.d.ts +3 -3
- package/lib/typescript/commonjs/ToolApprovalCard.d.ts.map +1 -1
- package/lib/typescript/commonjs/ToolCallSummary.d.ts +1 -1
- package/lib/typescript/commonjs/ToolCallSummary.d.ts.map +1 -1
- package/lib/typescript/commonjs/agentSphereAssets.d.ts +2 -0
- package/lib/typescript/commonjs/agentSphereAssets.d.ts.map +1 -0
- package/lib/typescript/commonjs/agentSphereStyles.d.ts.map +1 -1
- package/lib/typescript/commonjs/apiClient.d.ts.map +1 -1
- package/lib/typescript/commonjs/composerStyles.d.ts.map +1 -1
- package/lib/typescript/commonjs/connectorBrandIcons.d.ts.map +1 -1
- package/lib/typescript/commonjs/connectorBrandIcons.generated.d.ts +2 -0
- package/lib/typescript/commonjs/connectorBrandIcons.generated.d.ts.map +1 -0
- package/lib/typescript/commonjs/connectorCatalog.d.ts +2 -0
- package/lib/typescript/commonjs/connectorCatalog.d.ts.map +1 -1
- package/lib/typescript/commonjs/conversationParts.d.ts +1 -1
- package/lib/typescript/commonjs/conversationParts.d.ts.map +1 -1
- package/lib/typescript/commonjs/conversationRuntime.d.ts +6 -1
- package/lib/typescript/commonjs/conversationRuntime.d.ts.map +1 -1
- package/lib/typescript/commonjs/conversationStyles.d.ts.map +1 -1
- package/lib/typescript/commonjs/editorShellStyles.d.ts +4 -0
- package/lib/typescript/commonjs/editorShellStyles.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +2 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/markdownStyles.d.ts.map +1 -1
- package/lib/typescript/commonjs/messageActionStyles.d.ts.map +1 -1
- package/lib/typescript/commonjs/realtimeClient.d.ts.map +1 -1
- package/lib/typescript/commonjs/renameAgentModalStyles.d.ts.map +1 -1
- package/lib/typescript/commonjs/screenParts.d.ts +1 -1
- package/lib/typescript/commonjs/screenParts.d.ts.map +1 -1
- package/lib/typescript/commonjs/styles.d.ts +20 -11
- package/lib/typescript/commonjs/styles.d.ts.map +1 -1
- package/lib/typescript/commonjs/superagentApiClient.d.ts +2 -1
- package/lib/typescript/commonjs/superagentApiClient.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme.d.ts +36 -0
- package/lib/typescript/commonjs/theme.d.ts.map +1 -0
- package/lib/typescript/commonjs/types.d.ts +16 -2
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/useSuperagentConversation.d.ts +3 -2
- package/lib/typescript/commonjs/useSuperagentConversation.d.ts.map +1 -1
- package/lib/typescript/commonjs/useSuperagentRuntime.d.ts +2 -1
- package/lib/typescript/commonjs/useSuperagentRuntime.d.ts.map +1 -1
- package/lib/typescript/module/AgentSettingsPanel.d.ts.map +1 -1
- package/lib/typescript/module/AgentSphereIcon.d.ts.map +1 -1
- package/lib/typescript/module/AttachmentPickerStatusModal.d.ts.map +1 -1
- package/lib/typescript/module/ChannelsPanel.d.ts.map +1 -1
- package/lib/typescript/module/ConversationChat.d.ts +1 -1
- package/lib/typescript/module/ConversationChat.d.ts.map +1 -1
- package/lib/typescript/module/ConversationComposer.d.ts.map +1 -1
- package/lib/typescript/module/ConversationMessageList.d.ts +1 -1
- package/lib/typescript/module/ConversationMessageList.d.ts.map +1 -1
- package/lib/typescript/module/ConversationScreen.d.ts +2 -1
- package/lib/typescript/module/ConversationScreen.d.ts.map +1 -1
- package/lib/typescript/module/EditorDrawer.d.ts +1 -1
- package/lib/typescript/module/EditorDrawer.d.ts.map +1 -1
- package/lib/typescript/module/FilesPanel.d.ts.map +1 -1
- package/lib/typescript/module/RenameAgentModal.d.ts.map +1 -1
- package/lib/typescript/module/ShareAgentModal.d.ts.map +1 -1
- package/lib/typescript/module/ShareAgentModal.styles.d.ts.map +1 -1
- package/lib/typescript/module/SuperagentHomeScreen.d.ts.map +1 -1
- package/lib/typescript/module/ToolApprovalCard.d.ts +3 -3
- package/lib/typescript/module/ToolApprovalCard.d.ts.map +1 -1
- package/lib/typescript/module/ToolCallSummary.d.ts +1 -1
- package/lib/typescript/module/ToolCallSummary.d.ts.map +1 -1
- package/lib/typescript/module/agentSphereAssets.d.ts +2 -0
- package/lib/typescript/module/agentSphereAssets.d.ts.map +1 -0
- package/lib/typescript/module/agentSphereStyles.d.ts.map +1 -1
- package/lib/typescript/module/apiClient.d.ts.map +1 -1
- package/lib/typescript/module/composerStyles.d.ts.map +1 -1
- package/lib/typescript/module/connectorBrandIcons.d.ts.map +1 -1
- package/lib/typescript/module/connectorBrandIcons.generated.d.ts +2 -0
- package/lib/typescript/module/connectorBrandIcons.generated.d.ts.map +1 -0
- package/lib/typescript/module/connectorCatalog.d.ts +2 -0
- package/lib/typescript/module/connectorCatalog.d.ts.map +1 -1
- package/lib/typescript/module/conversationParts.d.ts +1 -1
- package/lib/typescript/module/conversationParts.d.ts.map +1 -1
- package/lib/typescript/module/conversationRuntime.d.ts +6 -1
- package/lib/typescript/module/conversationRuntime.d.ts.map +1 -1
- package/lib/typescript/module/conversationStyles.d.ts.map +1 -1
- package/lib/typescript/module/editorShellStyles.d.ts +4 -0
- package/lib/typescript/module/editorShellStyles.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +2 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/markdownStyles.d.ts.map +1 -1
- package/lib/typescript/module/messageActionStyles.d.ts.map +1 -1
- package/lib/typescript/module/realtimeClient.d.ts.map +1 -1
- package/lib/typescript/module/renameAgentModalStyles.d.ts.map +1 -1
- package/lib/typescript/module/screenParts.d.ts +1 -1
- package/lib/typescript/module/screenParts.d.ts.map +1 -1
- package/lib/typescript/module/styles.d.ts +20 -11
- package/lib/typescript/module/styles.d.ts.map +1 -1
- package/lib/typescript/module/superagentApiClient.d.ts +2 -1
- package/lib/typescript/module/superagentApiClient.d.ts.map +1 -1
- package/lib/typescript/module/theme.d.ts +36 -0
- package/lib/typescript/module/theme.d.ts.map +1 -0
- package/lib/typescript/module/types.d.ts +16 -2
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/lib/typescript/module/useSuperagentConversation.d.ts +3 -2
- package/lib/typescript/module/useSuperagentConversation.d.ts.map +1 -1
- package/lib/typescript/module/useSuperagentRuntime.d.ts +2 -1
- package/lib/typescript/module/useSuperagentRuntime.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/AgentSettingsPanel.tsx +118 -49
- package/src/AgentSphereIcon.tsx +11 -62
- package/src/AttachmentPickerStatusModal.tsx +4 -3
- package/src/ChannelsPanel.tsx +59 -39
- package/src/ConversationChat.tsx +12 -3
- package/src/ConversationComposer.tsx +7 -6
- package/src/ConversationMessageList.tsx +1 -1
- package/src/ConversationScreen.tsx +3 -0
- package/src/EditorDrawer.tsx +66 -41
- package/src/FilesPanel.tsx +48 -20
- package/src/RenameAgentModal.tsx +2 -1
- package/src/ShareAgentModal.styles.ts +2 -1
- package/src/ShareAgentModal.tsx +9 -8
- package/src/SuperagentHomeScreen.tsx +27 -7
- package/src/ToolApprovalCard.tsx +82 -14
- package/src/ToolCallSummary.tsx +18 -12
- package/src/agentSphereAssets.ts +325 -0
- package/src/agentSphereStyles.ts +3 -2
- package/src/apiClient.ts +7 -0
- package/src/composerStyles.ts +2 -1
- package/src/connectorBrandIcons.generated.ts +618 -0
- package/src/connectorBrandIcons.tsx +1 -53
- package/src/connectorCatalog.ts +24 -0
- package/src/conversationParts.tsx +6 -5
- package/src/conversationRuntime.ts +123 -12
- package/src/conversationStyles.ts +2 -1
- package/src/editorShellStyles.ts +6 -1
- package/src/index.ts +2 -0
- package/src/markdownStyles.ts +2 -1
- package/src/messageActionStyles.ts +2 -1
- package/src/realtimeClient.ts +7 -1
- package/src/renameAgentModalStyles.ts +2 -1
- package/src/screenParts.tsx +17 -29
- package/src/styles.ts +63 -54
- package/src/superagentApiClient.ts +68 -18
- package/src/theme.ts +254 -0
- package/src/types.ts +21 -2
- package/src/useSuperagentConversation.ts +141 -24
- package/src/useSuperagentRuntime.ts +165 -84
package/src/types.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ComponentType, ReactNode } from 'react';
|
|
2
2
|
import type { ProviderProps } from 'react-native-paper';
|
|
3
3
|
|
|
4
|
+
import type { SuperagentColorScheme } from './theme';
|
|
5
|
+
|
|
4
6
|
export type SuperagentToolCall = {
|
|
5
7
|
id?: string;
|
|
6
8
|
name: string;
|
|
@@ -144,10 +146,15 @@ export type SuperagentConversation = {
|
|
|
144
146
|
messages?: SuperagentMessage[];
|
|
145
147
|
};
|
|
146
148
|
|
|
149
|
+
export type SuperagentAgentDonePayload = {
|
|
150
|
+
sender_platform_user_id?: string;
|
|
151
|
+
bootstrap_intro?: boolean;
|
|
152
|
+
};
|
|
153
|
+
|
|
147
154
|
export type SuperagentRealtimeHandlers = {
|
|
148
155
|
onMessage?: (message: SuperagentMessage) => void;
|
|
149
156
|
onConversation?: (conversation: SuperagentConversation) => void;
|
|
150
|
-
onAgentDone?: () => void;
|
|
157
|
+
onAgentDone?: (payload?: SuperagentAgentDonePayload) => void;
|
|
151
158
|
onReconnect?: () => void;
|
|
152
159
|
onError?: (error: unknown) => void;
|
|
153
160
|
};
|
|
@@ -241,6 +248,7 @@ export type SuperagentTelegramChannelStatus = {
|
|
|
241
248
|
export type SuperagentWhatsAppChannelStatus = {
|
|
242
249
|
connected?: boolean;
|
|
243
250
|
connectUrl?: string | null;
|
|
251
|
+
userHandle?: string | null;
|
|
244
252
|
};
|
|
245
253
|
|
|
246
254
|
export type SuperagentLineActivation = {
|
|
@@ -380,6 +388,10 @@ export type SuperagentNativeClient = {
|
|
|
380
388
|
getConversation(conversationId: string): Promise<SuperagentConversation>;
|
|
381
389
|
getMessages(conversationId: string, params?: { limit?: number; before?: string }): Promise<SuperagentPaginatedMessages>;
|
|
382
390
|
createConversation(metadata?: Record<string, unknown>): Promise<SuperagentConversation>;
|
|
391
|
+
// Seeds a brand-new conversation with the lightweight intro turn. Unlike
|
|
392
|
+
// addMessage, the backend persists the seed hidden and skips sandbox acquisition,
|
|
393
|
+
// so opening an empty chat doesn't stall on a cold sandbox or burn a tool turn.
|
|
394
|
+
bootstrapIntro(conversationId: string, messageParams?: Record<string, unknown>): Promise<{ started: boolean }>;
|
|
383
395
|
addMessage(conversationId: string, message: Partial<SuperagentMessage>): Promise<unknown>;
|
|
384
396
|
stopConversation(conversationId: string): Promise<void>;
|
|
385
397
|
getQueuedMessages(conversationId: string): Promise<{ messages: QueuedSuperagentMessage[] }>;
|
|
@@ -422,6 +434,10 @@ export type SuperagentMarkdownRenderer = ComponentType<SuperagentMarkdownRendere
|
|
|
422
434
|
|
|
423
435
|
export type SuperagentHomeScreenProps = {
|
|
424
436
|
activeAgentId?: string | null;
|
|
437
|
+
/** Initial color scheme; the in-app settings toggle can change it. Defaults to 'light'. */
|
|
438
|
+
defaultColorScheme?: SuperagentColorScheme;
|
|
439
|
+
/** Called when the user changes the scheme from settings (e.g. to persist it). */
|
|
440
|
+
onColorSchemeChange?: (scheme: SuperagentColorScheme) => void;
|
|
425
441
|
agents?: SuperagentAgent[];
|
|
426
442
|
latestMessages?: SuperagentMessage[];
|
|
427
443
|
messagesByAgentId?: Record<string, SuperagentMessage[]>;
|
|
@@ -434,6 +450,9 @@ export type SuperagentHomeScreenProps = {
|
|
|
434
450
|
navigationMode?: 'internal' | 'external';
|
|
435
451
|
paperTheme?: ProviderProps['theme'];
|
|
436
452
|
currentUserAvatarUrl?: string | null;
|
|
453
|
+
// Platform user id of the signed-in user. Used to ignore agent_done events from
|
|
454
|
+
// other collaborators in shared conversations (sender_platform_user_id filter).
|
|
455
|
+
currentUserId?: string | null;
|
|
437
456
|
currentUserName?: string;
|
|
438
457
|
fileLoadError?: string | null;
|
|
439
458
|
fileLoadFailed?: boolean;
|
|
@@ -466,7 +485,7 @@ export type SuperagentHomeScreenProps = {
|
|
|
466
485
|
isLoadingChannels?: boolean;
|
|
467
486
|
isLoadingConnectors?: boolean;
|
|
468
487
|
onCancelConnectorConnection?: (input: { agentId: string; connectorId: string }) => void;
|
|
469
|
-
onConnectConnector?: (input: SuperagentConnectorActionInput) => Promise<boolean | void> | boolean | void;
|
|
488
|
+
onConnectConnector?: (input: SuperagentConnectorActionInput) => Promise<boolean | string | void> | boolean | string | void;
|
|
470
489
|
onDisconnectConnector?: (input: SuperagentConnectorActionInput) => Promise<void> | void;
|
|
471
490
|
onArchiveAutomation?: (input: SuperagentAutomationActionInput) => Promise<void> | void;
|
|
472
491
|
onCloneAgent?: (input: SuperagentAgentActionInput) => Promise<void> | void;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { MESSAGES_PAGE_SIZE } from './constants';
|
|
4
4
|
import {
|
|
5
5
|
countAssistantResponses,
|
|
6
6
|
createErrorMessage,
|
|
7
7
|
createUserMessage,
|
|
8
8
|
getMessageCursor,
|
|
9
9
|
hasNewAssistantResponse,
|
|
10
|
+
hasRunningToolCall,
|
|
10
11
|
isQueuedResponse,
|
|
11
12
|
isVisibleMessage,
|
|
12
13
|
mergeConversationSnapshot,
|
|
13
14
|
mergeMessage,
|
|
14
15
|
normalizeMessages,
|
|
15
16
|
pollConversation,
|
|
17
|
+
pollQueuedSend,
|
|
16
18
|
refreshConversation,
|
|
17
19
|
sendWithFallback,
|
|
18
20
|
} from './conversationRuntime';
|
|
@@ -24,6 +26,7 @@ type UseConversationParams = {
|
|
|
24
26
|
agentId: string;
|
|
25
27
|
apiClient?: SuperagentNativeClient;
|
|
26
28
|
realtimeClient?: SuperagentRealtimeClient;
|
|
29
|
+
currentUserId?: string | null;
|
|
27
30
|
fallbackMessages: SuperagentMessage[];
|
|
28
31
|
fallbackSending: boolean;
|
|
29
32
|
onAgentMessageDone?: () => Promise<void> | void;
|
|
@@ -35,6 +38,7 @@ export function useSuperagentConversation({
|
|
|
35
38
|
agentId,
|
|
36
39
|
apiClient,
|
|
37
40
|
realtimeClient,
|
|
41
|
+
currentUserId,
|
|
38
42
|
fallbackMessages,
|
|
39
43
|
fallbackSending,
|
|
40
44
|
onAgentMessageDone,
|
|
@@ -88,6 +92,13 @@ export function useSuperagentConversation({
|
|
|
88
92
|
const client = apiClient;
|
|
89
93
|
let cancelled = false;
|
|
90
94
|
|
|
95
|
+
// Clear the previous agent/client's conversation up front so a stale id or
|
|
96
|
+
// thread can't linger while the new one loads — or, if the reload fails, be
|
|
97
|
+
// shown or receive sends (conversationUnavailable only blocks with no id).
|
|
98
|
+
setConversationId(null);
|
|
99
|
+
setMessages([]);
|
|
100
|
+
setHasMoreMessages(false);
|
|
101
|
+
|
|
91
102
|
async function initConversation() {
|
|
92
103
|
setIsLoading(true);
|
|
93
104
|
setInitError(null);
|
|
@@ -104,7 +115,12 @@ export function useSuperagentConversation({
|
|
|
104
115
|
setHasMoreMessages(Boolean(page.has_more ?? page.hasMore));
|
|
105
116
|
|
|
106
117
|
if ((conversation.messages ?? []).length === 0) {
|
|
107
|
-
|
|
118
|
+
// Seed the intro via bootstrap-intro (hidden seed, no sandbox acquisition)
|
|
119
|
+
// instead of sending a visible "Hey!" through the full /messages path —
|
|
120
|
+
// opening an empty chat shouldn't stall on a cold sandbox or burn a
|
|
121
|
+
// tool-capable turn. The assistant intro arrives via realtime / a later
|
|
122
|
+
// refresh, so we don't block on it here.
|
|
123
|
+
await client.bootstrapIntro(conversation.id);
|
|
108
124
|
if (cancelled) return;
|
|
109
125
|
await refreshConversation(client, conversation.id, setMessages);
|
|
110
126
|
}
|
|
@@ -134,23 +150,64 @@ export function useSuperagentConversation({
|
|
|
134
150
|
const incoming = normalizeMessages(conversation.messages ?? []);
|
|
135
151
|
setMessages((current) => mergeConversationSnapshot(current, incoming));
|
|
136
152
|
},
|
|
137
|
-
onAgentDone() {
|
|
153
|
+
onAgentDone(payload) {
|
|
154
|
+
// Shared conversations: the backend tags agent_done with the sender's
|
|
155
|
+
// platform user id. Ignore completions from OTHER collaborators so a
|
|
156
|
+
// teammate's finishing run doesn't clear THIS user's sending state or fire
|
|
157
|
+
// their completion callbacks early (matches the web client).
|
|
158
|
+
if (payload?.sender_platform_user_id && currentUserId && payload.sender_platform_user_id !== currentUserId) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
138
161
|
// Agent finished via realtime — cancel the 5s settle fallback so
|
|
139
162
|
// onConversationSettled doesn't also fire when the timer elapses.
|
|
140
163
|
if (settleTimeoutRef.current) {
|
|
141
164
|
clearTimeout(settleTimeoutRef.current);
|
|
142
165
|
settleTimeoutRef.current = null;
|
|
143
166
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
167
|
+
// Guard the busy-state clear against a newer send superseding this turn
|
|
168
|
+
// while we refresh/poll: only clear if no later send has started since
|
|
169
|
+
// (mirrors setSendingForCurrentSend in sendMessage).
|
|
170
|
+
const sendGeneration = sendGenerationRef.current;
|
|
171
|
+
const setSendingIfCurrent = (value: boolean) => {
|
|
172
|
+
if (sendGenerationRef.current === sendGeneration) setIsSending(value);
|
|
173
|
+
};
|
|
174
|
+
const settle = () => {
|
|
175
|
+
setSendingIfCurrent(false);
|
|
176
|
+
setQueuedMessages([]);
|
|
177
|
+
onAgentMessageDoneRef.current?.();
|
|
152
178
|
onConversationSettledRef.current?.();
|
|
179
|
+
};
|
|
180
|
+
if (!apiClient) {
|
|
181
|
+
settle();
|
|
182
|
+
return;
|
|
153
183
|
}
|
|
184
|
+
const handOffToPoll = (assistantCountBefore: number) => {
|
|
185
|
+
// Keep the busy state and let the bounded poll finish the turn (it
|
|
186
|
+
// retries refreshes and settles once no tool is running or the cap is
|
|
187
|
+
// hit), matching the no-realtime poll and 5s settle paths.
|
|
188
|
+
if (pollIntervalRef.current) clearInterval(pollIntervalRef.current);
|
|
189
|
+
pollIntervalRef.current = pollConversation(
|
|
190
|
+
apiClient, conversationId, setMessages, setSendingIfCurrent, assistantCountBefore,
|
|
191
|
+
() => { setQueuedMessages([]); onConversationSettledRef.current?.(); },
|
|
192
|
+
() => onAgentMessageDoneRef.current?.(),
|
|
193
|
+
);
|
|
194
|
+
};
|
|
195
|
+
refreshConversation(apiClient, conversationId, setMessages)
|
|
196
|
+
.then((refreshed) => {
|
|
197
|
+
// agent_done arrived while a tool is still running in the snapshot —
|
|
198
|
+
// don't settle yet, let the poll loop finish it.
|
|
199
|
+
if (hasRunningToolCall(refreshed)) {
|
|
200
|
+
handOffToPoll(countAssistantResponses(refreshed));
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
settle();
|
|
204
|
+
})
|
|
205
|
+
.catch(() => {
|
|
206
|
+
// The final refresh failed, so we can't tell whether a tool is still
|
|
207
|
+
// running — hand off to the bounded poll instead of clearing the busy
|
|
208
|
+
// state blind (it will settle on completion or the hard cap).
|
|
209
|
+
handOffToPoll(countAssistantResponses(messagesRef.current));
|
|
210
|
+
});
|
|
154
211
|
},
|
|
155
212
|
onReconnect() {
|
|
156
213
|
// A reconnect means the transient socket error cleared — drop the
|
|
@@ -162,17 +219,19 @@ export function useSuperagentConversation({
|
|
|
162
219
|
setInitError(error instanceof Error ? error.message : 'Realtime connection failed');
|
|
163
220
|
},
|
|
164
221
|
});
|
|
165
|
-
}, [apiClient, conversationId, realtimeClient]);
|
|
222
|
+
}, [apiClient, conversationId, currentUserId, realtimeClient]);
|
|
166
223
|
|
|
167
224
|
const visibleMessages = useMemo(
|
|
168
225
|
() => messages.filter((message, index) => isVisibleMessage(message, index)),
|
|
169
226
|
[messages],
|
|
170
227
|
);
|
|
171
228
|
|
|
172
|
-
|
|
229
|
+
// Resolves true when the send was accepted (queued/sent), false when it failed
|
|
230
|
+
// before reaching the conversation — so the composer can restore the draft.
|
|
231
|
+
const sendMessage = useCallback(async (content: string, options: { fileUrls?: string[]; replyTo?: SuperagentReplyTo } = {}): Promise<boolean> => {
|
|
173
232
|
const trimmedContent = content.trim();
|
|
174
233
|
const fileUrls = options.fileUrls?.filter(Boolean) ?? [];
|
|
175
|
-
if (!trimmedContent && fileUrls.length === 0) return;
|
|
234
|
+
if (!trimmedContent && fileUrls.length === 0) return false;
|
|
176
235
|
|
|
177
236
|
// A new send supersedes any pending poll/settle timers from the previous one.
|
|
178
237
|
clearPendingSettlers();
|
|
@@ -186,7 +245,7 @@ export function useSuperagentConversation({
|
|
|
186
245
|
// No send path yet (no fallback handler, or the conversation is still
|
|
187
246
|
// loading) — drop the optimistic bubble so the turn doesn't look sent.
|
|
188
247
|
setMessages((current) => current.filter((message) => message.id !== userMessage.id));
|
|
189
|
-
return;
|
|
248
|
+
return false;
|
|
190
249
|
}
|
|
191
250
|
const sendGeneration = sendGenerationRef.current + 1;
|
|
192
251
|
sendGenerationRef.current = sendGeneration;
|
|
@@ -195,9 +254,11 @@ export function useSuperagentConversation({
|
|
|
195
254
|
};
|
|
196
255
|
|
|
197
256
|
setIsSending(true);
|
|
198
|
-
const hasAssistantResponse = await sendWithFallback(agentId, trimmedContent, fileUrls, options.replyTo, onSendMessage, setMessages, setSendingForCurrentSend);
|
|
257
|
+
const { delivered, hasAssistantResponse } = await sendWithFallback(agentId, trimmedContent, fileUrls, options.replyTo, onSendMessage, setMessages, setSendingForCurrentSend, userMessage.id);
|
|
199
258
|
if (hasAssistantResponse) onAgentMessageDoneRef.current?.();
|
|
200
|
-
|
|
259
|
+
// Report actual delivery so the composer restores the draft on a rejected
|
|
260
|
+
// fallback send instead of silently dropping the user's text/attachments.
|
|
261
|
+
return delivered;
|
|
201
262
|
}
|
|
202
263
|
|
|
203
264
|
const sendGeneration = sendGenerationRef.current + 1;
|
|
@@ -218,9 +279,32 @@ export function useSuperagentConversation({
|
|
|
218
279
|
() => onAgentMessageDoneRef.current?.(),
|
|
219
280
|
);
|
|
220
281
|
} else {
|
|
221
|
-
settleTimeoutRef.current = setTimeout(() => {
|
|
282
|
+
settleTimeoutRef.current = setTimeout(async () => {
|
|
222
283
|
settleTimeoutRef.current = null;
|
|
223
|
-
|
|
284
|
+
// agent_done is late — hand off to the bounded poll loop, which keeps
|
|
285
|
+
// "sending" until tools finish (or the hard cap), instead of clearing
|
|
286
|
+
// it mid-turn.
|
|
287
|
+
const handOffToPoll = () => {
|
|
288
|
+
if (pollIntervalRef.current) clearInterval(pollIntervalRef.current);
|
|
289
|
+
pollIntervalRef.current = pollConversation(
|
|
290
|
+
apiClient, conversationId, setMessages, setSendingForCurrentSend, assistantCountBefore,
|
|
291
|
+
() => { setQueuedMessages([]); onConversationSettledRef.current?.(); },
|
|
292
|
+
() => onAgentMessageDoneRef.current?.(),
|
|
293
|
+
);
|
|
294
|
+
};
|
|
295
|
+
try {
|
|
296
|
+
const refreshed = await refreshConversation(apiClient, conversationId, setMessages);
|
|
297
|
+
if (hasRunningToolCall(refreshed)) {
|
|
298
|
+
handOffToPoll();
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
} catch {
|
|
302
|
+
// Refresh failed — we can't tell whether a tool is still running, so
|
|
303
|
+
// hand off to the bounded poll rather than clearing the busy state
|
|
304
|
+
// blind (it retries and settles on completion or the hard cap).
|
|
305
|
+
handOffToPoll();
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
224
308
|
setSendingForCurrentSend(false);
|
|
225
309
|
setQueuedMessages([]);
|
|
226
310
|
onAgentMessageDoneRef.current?.();
|
|
@@ -232,11 +316,36 @@ export function useSuperagentConversation({
|
|
|
232
316
|
const response = await apiClient.addMessage(conversationId, userMessage);
|
|
233
317
|
if (isQueuedResponse(response)) {
|
|
234
318
|
setQueuedMessages((current) => [...current, { id: userMessage.id!, content: userMessage.content, position: current.length }]);
|
|
235
|
-
//
|
|
236
|
-
|
|
319
|
+
// Another turn holds the conversation lock. Wait for OUR message to drain
|
|
320
|
+
// from the backend queue before settling — otherwise the running turn's
|
|
321
|
+
// completion would clear isSending / the queued strip early and let another
|
|
322
|
+
// send start while this one is still pending. pollQueuedSend re-baselines and
|
|
323
|
+
// hands off to the normal response poll once our turn actually starts.
|
|
324
|
+
if (pollIntervalRef.current) clearInterval(pollIntervalRef.current);
|
|
325
|
+
pollIntervalRef.current = pollQueuedSend(
|
|
326
|
+
apiClient, conversationId, userMessage.id!, setMessages, setSendingForCurrentSend,
|
|
327
|
+
(interval) => { pollIntervalRef.current = interval; },
|
|
328
|
+
() => { setQueuedMessages([]); onConversationSettledRef.current?.(); },
|
|
329
|
+
() => onAgentMessageDoneRef.current?.(),
|
|
330
|
+
);
|
|
237
331
|
} else {
|
|
238
|
-
|
|
239
|
-
|
|
332
|
+
let refreshedMessages;
|
|
333
|
+
try {
|
|
334
|
+
refreshedMessages = await refreshConversation(apiClient, conversationId, setMessages);
|
|
335
|
+
} catch {
|
|
336
|
+
// addMessage already succeeded (a non-queued send returns only after the
|
|
337
|
+
// agent is invoked), so the turn IS delivered. A failed post-send refresh
|
|
338
|
+
// must NOT drop the optimistic row or report failure — that would make
|
|
339
|
+
// ConversationChat restore the draft and the user resend, duplicating the
|
|
340
|
+
// message. Hand off to the bounded poll/settle loop and report delivered.
|
|
341
|
+
armSettleFallback();
|
|
342
|
+
return true;
|
|
343
|
+
}
|
|
344
|
+
// Only complete immediately if a new assistant reply landed AND no tool is
|
|
345
|
+
// still running — otherwise hand off to armSettleFallback (pollConversation
|
|
346
|
+
// without realtime), which keeps "sending" until tools finish. Matches the
|
|
347
|
+
// poll/settle paths so tool-using turns don't drop the busy state early.
|
|
348
|
+
if (!realtimeClient && hasNewAssistantResponse(refreshedMessages, assistantCountBefore) && !hasRunningToolCall(refreshedMessages)) {
|
|
240
349
|
setSendingForCurrentSend(false);
|
|
241
350
|
setQueuedMessages([]);
|
|
242
351
|
onAgentMessageDoneRef.current?.();
|
|
@@ -245,10 +354,18 @@ export function useSuperagentConversation({
|
|
|
245
354
|
armSettleFallback();
|
|
246
355
|
}
|
|
247
356
|
}
|
|
357
|
+
return true;
|
|
248
358
|
} catch (error) {
|
|
359
|
+
// The optimistic bubble never reached the server (addMessage threw), so drop
|
|
360
|
+
// it and surface the error in its place — otherwise the turn looks sent and a
|
|
361
|
+
// later refresh/resend could duplicate it. Mirrors the no-send-path above.
|
|
249
362
|
const errorMessage = createErrorMessage(error);
|
|
250
|
-
setMessages((current) => [
|
|
363
|
+
setMessages((current) => [
|
|
364
|
+
...current.filter((message) => message.id !== userMessage.id),
|
|
365
|
+
errorMessage,
|
|
366
|
+
]);
|
|
251
367
|
setSendingForCurrentSend(false);
|
|
368
|
+
return false;
|
|
252
369
|
}
|
|
253
370
|
}, [agentId, apiClient, clearPendingSettlers, conversationId, onSendMessage, realtimeClient]);
|
|
254
371
|
|