@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.
Files changed (306) hide show
  1. package/lib/commonjs/AgentSettingsPanel.js +123 -47
  2. package/lib/commonjs/AgentSettingsPanel.js.map +1 -1
  3. package/lib/commonjs/AgentSphereIcon.js +14 -118
  4. package/lib/commonjs/AgentSphereIcon.js.map +1 -1
  5. package/lib/commonjs/AttachmentPickerStatusModal.js +3 -2
  6. package/lib/commonjs/AttachmentPickerStatusModal.js.map +1 -1
  7. package/lib/commonjs/ChannelsPanel.js +66 -44
  8. package/lib/commonjs/ChannelsPanel.js.map +1 -1
  9. package/lib/commonjs/ConversationChat.js +11 -2
  10. package/lib/commonjs/ConversationChat.js.map +1 -1
  11. package/lib/commonjs/ConversationComposer.js +8 -7
  12. package/lib/commonjs/ConversationComposer.js.map +1 -1
  13. package/lib/commonjs/ConversationScreen.js +2 -0
  14. package/lib/commonjs/ConversationScreen.js.map +1 -1
  15. package/lib/commonjs/EditorDrawer.js +54 -24
  16. package/lib/commonjs/EditorDrawer.js.map +1 -1
  17. package/lib/commonjs/FilesPanel.js +56 -20
  18. package/lib/commonjs/FilesPanel.js.map +1 -1
  19. package/lib/commonjs/RenameAgentModal.js +2 -1
  20. package/lib/commonjs/RenameAgentModal.js.map +1 -1
  21. package/lib/commonjs/ShareAgentModal.js +11 -10
  22. package/lib/commonjs/ShareAgentModal.js.map +1 -1
  23. package/lib/commonjs/ShareAgentModal.styles.js +2 -2
  24. package/lib/commonjs/ShareAgentModal.styles.js.map +1 -1
  25. package/lib/commonjs/SuperagentHomeScreen.js +27 -9
  26. package/lib/commonjs/SuperagentHomeScreen.js.map +1 -1
  27. package/lib/commonjs/ToolApprovalCard.js +72 -14
  28. package/lib/commonjs/ToolApprovalCard.js.map +1 -1
  29. package/lib/commonjs/ToolCallSummary.js +14 -9
  30. package/lib/commonjs/ToolCallSummary.js.map +1 -1
  31. package/lib/commonjs/agentSphereAssets.js +327 -0
  32. package/lib/commonjs/agentSphereAssets.js.map +1 -0
  33. package/lib/commonjs/agentSphereStyles.js +3 -3
  34. package/lib/commonjs/agentSphereStyles.js.map +1 -1
  35. package/lib/commonjs/apiClient.js +7 -0
  36. package/lib/commonjs/apiClient.js.map +1 -1
  37. package/lib/commonjs/composerStyles.js +2 -2
  38. package/lib/commonjs/composerStyles.js.map +1 -1
  39. package/lib/commonjs/connectorBrandIcons.generated.js +625 -0
  40. package/lib/commonjs/connectorBrandIcons.generated.js.map +1 -0
  41. package/lib/commonjs/connectorBrandIcons.js +3 -55
  42. package/lib/commonjs/connectorBrandIcons.js.map +1 -1
  43. package/lib/commonjs/connectorCatalog.js +19 -1
  44. package/lib/commonjs/connectorCatalog.js.map +1 -1
  45. package/lib/commonjs/conversationParts.js +5 -4
  46. package/lib/commonjs/conversationParts.js.map +1 -1
  47. package/lib/commonjs/conversationRuntime.js +120 -12
  48. package/lib/commonjs/conversationRuntime.js.map +1 -1
  49. package/lib/commonjs/conversationStyles.js +2 -1
  50. package/lib/commonjs/conversationStyles.js.map +1 -1
  51. package/lib/commonjs/editorShellStyles.js +6 -2
  52. package/lib/commonjs/editorShellStyles.js.map +1 -1
  53. package/lib/commonjs/index.js +7 -0
  54. package/lib/commonjs/index.js.map +1 -1
  55. package/lib/commonjs/markdownStyles.js +2 -2
  56. package/lib/commonjs/markdownStyles.js.map +1 -1
  57. package/lib/commonjs/messageActionStyles.js +2 -2
  58. package/lib/commonjs/messageActionStyles.js.map +1 -1
  59. package/lib/commonjs/realtimeClient.js +4 -1
  60. package/lib/commonjs/realtimeClient.js.map +1 -1
  61. package/lib/commonjs/renameAgentModalStyles.js +2 -2
  62. package/lib/commonjs/renameAgentModalStyles.js.map +1 -1
  63. package/lib/commonjs/screenParts.js +24 -41
  64. package/lib/commonjs/screenParts.js.map +1 -1
  65. package/lib/commonjs/styles.js +71 -60
  66. package/lib/commonjs/styles.js.map +1 -1
  67. package/lib/commonjs/superagentApiClient.js +63 -18
  68. package/lib/commonjs/superagentApiClient.js.map +1 -1
  69. package/lib/commonjs/theme.js +249 -0
  70. package/lib/commonjs/theme.js.map +1 -0
  71. package/lib/commonjs/useSuperagentConversation.js +133 -20
  72. package/lib/commonjs/useSuperagentConversation.js.map +1 -1
  73. package/lib/commonjs/useSuperagentRuntime.js +167 -82
  74. package/lib/commonjs/useSuperagentRuntime.js.map +1 -1
  75. package/lib/module/AgentSettingsPanel.js +125 -49
  76. package/lib/module/AgentSettingsPanel.js.map +1 -1
  77. package/lib/module/AgentSphereIcon.js +15 -118
  78. package/lib/module/AgentSphereIcon.js.map +1 -1
  79. package/lib/module/AttachmentPickerStatusModal.js +4 -3
  80. package/lib/module/AttachmentPickerStatusModal.js.map +1 -1
  81. package/lib/module/ChannelsPanel.js +67 -45
  82. package/lib/module/ChannelsPanel.js.map +1 -1
  83. package/lib/module/ConversationChat.js +11 -2
  84. package/lib/module/ConversationChat.js.map +1 -1
  85. package/lib/module/ConversationComposer.js +8 -7
  86. package/lib/module/ConversationComposer.js.map +1 -1
  87. package/lib/module/ConversationScreen.js +2 -0
  88. package/lib/module/ConversationScreen.js.map +1 -1
  89. package/lib/module/EditorDrawer.js +55 -25
  90. package/lib/module/EditorDrawer.js.map +1 -1
  91. package/lib/module/FilesPanel.js +56 -20
  92. package/lib/module/FilesPanel.js.map +1 -1
  93. package/lib/module/RenameAgentModal.js +2 -1
  94. package/lib/module/RenameAgentModal.js.map +1 -1
  95. package/lib/module/ShareAgentModal.js +11 -10
  96. package/lib/module/ShareAgentModal.js.map +1 -1
  97. package/lib/module/ShareAgentModal.styles.js +2 -2
  98. package/lib/module/ShareAgentModal.styles.js.map +1 -1
  99. package/lib/module/SuperagentHomeScreen.js +27 -9
  100. package/lib/module/SuperagentHomeScreen.js.map +1 -1
  101. package/lib/module/ToolApprovalCard.js +72 -14
  102. package/lib/module/ToolApprovalCard.js.map +1 -1
  103. package/lib/module/ToolCallSummary.js +14 -9
  104. package/lib/module/ToolCallSummary.js.map +1 -1
  105. package/lib/module/agentSphereAssets.js +323 -0
  106. package/lib/module/agentSphereAssets.js.map +1 -0
  107. package/lib/module/agentSphereStyles.js +3 -3
  108. package/lib/module/agentSphereStyles.js.map +1 -1
  109. package/lib/module/apiClient.js +7 -0
  110. package/lib/module/apiClient.js.map +1 -1
  111. package/lib/module/composerStyles.js +2 -2
  112. package/lib/module/composerStyles.js.map +1 -1
  113. package/lib/module/connectorBrandIcons.generated.js +621 -0
  114. package/lib/module/connectorBrandIcons.generated.js.map +1 -0
  115. package/lib/module/connectorBrandIcons.js +1 -53
  116. package/lib/module/connectorBrandIcons.js.map +1 -1
  117. package/lib/module/connectorCatalog.js +17 -0
  118. package/lib/module/connectorCatalog.js.map +1 -1
  119. package/lib/module/conversationParts.js +5 -4
  120. package/lib/module/conversationParts.js.map +1 -1
  121. package/lib/module/conversationRuntime.js +118 -12
  122. package/lib/module/conversationRuntime.js.map +1 -1
  123. package/lib/module/conversationStyles.js +3 -2
  124. package/lib/module/conversationStyles.js.map +1 -1
  125. package/lib/module/editorShellStyles.js +6 -2
  126. package/lib/module/editorShellStyles.js.map +1 -1
  127. package/lib/module/index.js +1 -0
  128. package/lib/module/index.js.map +1 -1
  129. package/lib/module/markdownStyles.js +2 -2
  130. package/lib/module/markdownStyles.js.map +1 -1
  131. package/lib/module/messageActionStyles.js +2 -2
  132. package/lib/module/messageActionStyles.js.map +1 -1
  133. package/lib/module/realtimeClient.js +4 -1
  134. package/lib/module/realtimeClient.js.map +1 -1
  135. package/lib/module/renameAgentModalStyles.js +2 -2
  136. package/lib/module/renameAgentModalStyles.js.map +1 -1
  137. package/lib/module/screenParts.js +25 -42
  138. package/lib/module/screenParts.js.map +1 -1
  139. package/lib/module/styles.js +71 -60
  140. package/lib/module/styles.js.map +1 -1
  141. package/lib/module/superagentApiClient.js +63 -18
  142. package/lib/module/superagentApiClient.js.map +1 -1
  143. package/lib/module/theme.js +239 -0
  144. package/lib/module/theme.js.map +1 -0
  145. package/lib/module/useSuperagentConversation.js +135 -22
  146. package/lib/module/useSuperagentConversation.js.map +1 -1
  147. package/lib/module/useSuperagentRuntime.js +167 -82
  148. package/lib/module/useSuperagentRuntime.js.map +1 -1
  149. package/lib/typescript/commonjs/AgentSettingsPanel.d.ts.map +1 -1
  150. package/lib/typescript/commonjs/AgentSphereIcon.d.ts.map +1 -1
  151. package/lib/typescript/commonjs/AttachmentPickerStatusModal.d.ts.map +1 -1
  152. package/lib/typescript/commonjs/ChannelsPanel.d.ts.map +1 -1
  153. package/lib/typescript/commonjs/ConversationChat.d.ts +1 -1
  154. package/lib/typescript/commonjs/ConversationChat.d.ts.map +1 -1
  155. package/lib/typescript/commonjs/ConversationComposer.d.ts.map +1 -1
  156. package/lib/typescript/commonjs/ConversationMessageList.d.ts +1 -1
  157. package/lib/typescript/commonjs/ConversationMessageList.d.ts.map +1 -1
  158. package/lib/typescript/commonjs/ConversationScreen.d.ts +2 -1
  159. package/lib/typescript/commonjs/ConversationScreen.d.ts.map +1 -1
  160. package/lib/typescript/commonjs/EditorDrawer.d.ts +1 -1
  161. package/lib/typescript/commonjs/EditorDrawer.d.ts.map +1 -1
  162. package/lib/typescript/commonjs/FilesPanel.d.ts.map +1 -1
  163. package/lib/typescript/commonjs/RenameAgentModal.d.ts.map +1 -1
  164. package/lib/typescript/commonjs/ShareAgentModal.d.ts.map +1 -1
  165. package/lib/typescript/commonjs/ShareAgentModal.styles.d.ts.map +1 -1
  166. package/lib/typescript/commonjs/SuperagentHomeScreen.d.ts.map +1 -1
  167. package/lib/typescript/commonjs/ToolApprovalCard.d.ts +3 -3
  168. package/lib/typescript/commonjs/ToolApprovalCard.d.ts.map +1 -1
  169. package/lib/typescript/commonjs/ToolCallSummary.d.ts +1 -1
  170. package/lib/typescript/commonjs/ToolCallSummary.d.ts.map +1 -1
  171. package/lib/typescript/commonjs/agentSphereAssets.d.ts +2 -0
  172. package/lib/typescript/commonjs/agentSphereAssets.d.ts.map +1 -0
  173. package/lib/typescript/commonjs/agentSphereStyles.d.ts.map +1 -1
  174. package/lib/typescript/commonjs/apiClient.d.ts.map +1 -1
  175. package/lib/typescript/commonjs/composerStyles.d.ts.map +1 -1
  176. package/lib/typescript/commonjs/connectorBrandIcons.d.ts.map +1 -1
  177. package/lib/typescript/commonjs/connectorBrandIcons.generated.d.ts +2 -0
  178. package/lib/typescript/commonjs/connectorBrandIcons.generated.d.ts.map +1 -0
  179. package/lib/typescript/commonjs/connectorCatalog.d.ts +2 -0
  180. package/lib/typescript/commonjs/connectorCatalog.d.ts.map +1 -1
  181. package/lib/typescript/commonjs/conversationParts.d.ts +1 -1
  182. package/lib/typescript/commonjs/conversationParts.d.ts.map +1 -1
  183. package/lib/typescript/commonjs/conversationRuntime.d.ts +6 -1
  184. package/lib/typescript/commonjs/conversationRuntime.d.ts.map +1 -1
  185. package/lib/typescript/commonjs/conversationStyles.d.ts.map +1 -1
  186. package/lib/typescript/commonjs/editorShellStyles.d.ts +4 -0
  187. package/lib/typescript/commonjs/editorShellStyles.d.ts.map +1 -1
  188. package/lib/typescript/commonjs/index.d.ts +2 -0
  189. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  190. package/lib/typescript/commonjs/markdownStyles.d.ts.map +1 -1
  191. package/lib/typescript/commonjs/messageActionStyles.d.ts.map +1 -1
  192. package/lib/typescript/commonjs/realtimeClient.d.ts.map +1 -1
  193. package/lib/typescript/commonjs/renameAgentModalStyles.d.ts.map +1 -1
  194. package/lib/typescript/commonjs/screenParts.d.ts +1 -1
  195. package/lib/typescript/commonjs/screenParts.d.ts.map +1 -1
  196. package/lib/typescript/commonjs/styles.d.ts +20 -11
  197. package/lib/typescript/commonjs/styles.d.ts.map +1 -1
  198. package/lib/typescript/commonjs/superagentApiClient.d.ts +2 -1
  199. package/lib/typescript/commonjs/superagentApiClient.d.ts.map +1 -1
  200. package/lib/typescript/commonjs/theme.d.ts +36 -0
  201. package/lib/typescript/commonjs/theme.d.ts.map +1 -0
  202. package/lib/typescript/commonjs/types.d.ts +16 -2
  203. package/lib/typescript/commonjs/types.d.ts.map +1 -1
  204. package/lib/typescript/commonjs/useSuperagentConversation.d.ts +3 -2
  205. package/lib/typescript/commonjs/useSuperagentConversation.d.ts.map +1 -1
  206. package/lib/typescript/commonjs/useSuperagentRuntime.d.ts +2 -1
  207. package/lib/typescript/commonjs/useSuperagentRuntime.d.ts.map +1 -1
  208. package/lib/typescript/module/AgentSettingsPanel.d.ts.map +1 -1
  209. package/lib/typescript/module/AgentSphereIcon.d.ts.map +1 -1
  210. package/lib/typescript/module/AttachmentPickerStatusModal.d.ts.map +1 -1
  211. package/lib/typescript/module/ChannelsPanel.d.ts.map +1 -1
  212. package/lib/typescript/module/ConversationChat.d.ts +1 -1
  213. package/lib/typescript/module/ConversationChat.d.ts.map +1 -1
  214. package/lib/typescript/module/ConversationComposer.d.ts.map +1 -1
  215. package/lib/typescript/module/ConversationMessageList.d.ts +1 -1
  216. package/lib/typescript/module/ConversationMessageList.d.ts.map +1 -1
  217. package/lib/typescript/module/ConversationScreen.d.ts +2 -1
  218. package/lib/typescript/module/ConversationScreen.d.ts.map +1 -1
  219. package/lib/typescript/module/EditorDrawer.d.ts +1 -1
  220. package/lib/typescript/module/EditorDrawer.d.ts.map +1 -1
  221. package/lib/typescript/module/FilesPanel.d.ts.map +1 -1
  222. package/lib/typescript/module/RenameAgentModal.d.ts.map +1 -1
  223. package/lib/typescript/module/ShareAgentModal.d.ts.map +1 -1
  224. package/lib/typescript/module/ShareAgentModal.styles.d.ts.map +1 -1
  225. package/lib/typescript/module/SuperagentHomeScreen.d.ts.map +1 -1
  226. package/lib/typescript/module/ToolApprovalCard.d.ts +3 -3
  227. package/lib/typescript/module/ToolApprovalCard.d.ts.map +1 -1
  228. package/lib/typescript/module/ToolCallSummary.d.ts +1 -1
  229. package/lib/typescript/module/ToolCallSummary.d.ts.map +1 -1
  230. package/lib/typescript/module/agentSphereAssets.d.ts +2 -0
  231. package/lib/typescript/module/agentSphereAssets.d.ts.map +1 -0
  232. package/lib/typescript/module/agentSphereStyles.d.ts.map +1 -1
  233. package/lib/typescript/module/apiClient.d.ts.map +1 -1
  234. package/lib/typescript/module/composerStyles.d.ts.map +1 -1
  235. package/lib/typescript/module/connectorBrandIcons.d.ts.map +1 -1
  236. package/lib/typescript/module/connectorBrandIcons.generated.d.ts +2 -0
  237. package/lib/typescript/module/connectorBrandIcons.generated.d.ts.map +1 -0
  238. package/lib/typescript/module/connectorCatalog.d.ts +2 -0
  239. package/lib/typescript/module/connectorCatalog.d.ts.map +1 -1
  240. package/lib/typescript/module/conversationParts.d.ts +1 -1
  241. package/lib/typescript/module/conversationParts.d.ts.map +1 -1
  242. package/lib/typescript/module/conversationRuntime.d.ts +6 -1
  243. package/lib/typescript/module/conversationRuntime.d.ts.map +1 -1
  244. package/lib/typescript/module/conversationStyles.d.ts.map +1 -1
  245. package/lib/typescript/module/editorShellStyles.d.ts +4 -0
  246. package/lib/typescript/module/editorShellStyles.d.ts.map +1 -1
  247. package/lib/typescript/module/index.d.ts +2 -0
  248. package/lib/typescript/module/index.d.ts.map +1 -1
  249. package/lib/typescript/module/markdownStyles.d.ts.map +1 -1
  250. package/lib/typescript/module/messageActionStyles.d.ts.map +1 -1
  251. package/lib/typescript/module/realtimeClient.d.ts.map +1 -1
  252. package/lib/typescript/module/renameAgentModalStyles.d.ts.map +1 -1
  253. package/lib/typescript/module/screenParts.d.ts +1 -1
  254. package/lib/typescript/module/screenParts.d.ts.map +1 -1
  255. package/lib/typescript/module/styles.d.ts +20 -11
  256. package/lib/typescript/module/styles.d.ts.map +1 -1
  257. package/lib/typescript/module/superagentApiClient.d.ts +2 -1
  258. package/lib/typescript/module/superagentApiClient.d.ts.map +1 -1
  259. package/lib/typescript/module/theme.d.ts +36 -0
  260. package/lib/typescript/module/theme.d.ts.map +1 -0
  261. package/lib/typescript/module/types.d.ts +16 -2
  262. package/lib/typescript/module/types.d.ts.map +1 -1
  263. package/lib/typescript/module/useSuperagentConversation.d.ts +3 -2
  264. package/lib/typescript/module/useSuperagentConversation.d.ts.map +1 -1
  265. package/lib/typescript/module/useSuperagentRuntime.d.ts +2 -1
  266. package/lib/typescript/module/useSuperagentRuntime.d.ts.map +1 -1
  267. package/package.json +1 -1
  268. package/src/AgentSettingsPanel.tsx +118 -49
  269. package/src/AgentSphereIcon.tsx +11 -62
  270. package/src/AttachmentPickerStatusModal.tsx +4 -3
  271. package/src/ChannelsPanel.tsx +59 -39
  272. package/src/ConversationChat.tsx +12 -3
  273. package/src/ConversationComposer.tsx +7 -6
  274. package/src/ConversationMessageList.tsx +1 -1
  275. package/src/ConversationScreen.tsx +3 -0
  276. package/src/EditorDrawer.tsx +66 -41
  277. package/src/FilesPanel.tsx +48 -20
  278. package/src/RenameAgentModal.tsx +2 -1
  279. package/src/ShareAgentModal.styles.ts +2 -1
  280. package/src/ShareAgentModal.tsx +9 -8
  281. package/src/SuperagentHomeScreen.tsx +27 -7
  282. package/src/ToolApprovalCard.tsx +82 -14
  283. package/src/ToolCallSummary.tsx +18 -12
  284. package/src/agentSphereAssets.ts +325 -0
  285. package/src/agentSphereStyles.ts +3 -2
  286. package/src/apiClient.ts +7 -0
  287. package/src/composerStyles.ts +2 -1
  288. package/src/connectorBrandIcons.generated.ts +618 -0
  289. package/src/connectorBrandIcons.tsx +1 -53
  290. package/src/connectorCatalog.ts +24 -0
  291. package/src/conversationParts.tsx +6 -5
  292. package/src/conversationRuntime.ts +123 -12
  293. package/src/conversationStyles.ts +2 -1
  294. package/src/editorShellStyles.ts +6 -1
  295. package/src/index.ts +2 -0
  296. package/src/markdownStyles.ts +2 -1
  297. package/src/messageActionStyles.ts +2 -1
  298. package/src/realtimeClient.ts +7 -1
  299. package/src/renameAgentModalStyles.ts +2 -1
  300. package/src/screenParts.tsx +17 -29
  301. package/src/styles.ts +63 -54
  302. package/src/superagentApiClient.ts +68 -18
  303. package/src/theme.ts +254 -0
  304. package/src/types.ts +21 -2
  305. package/src/useSuperagentConversation.ts +141 -24
  306. 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 { AUTO_GREET_MESSAGE, MESSAGES_PAGE_SIZE } from './constants';
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
- await client.addMessage(conversation.id, createUserMessage(AUTO_GREET_MESSAGE));
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
- setIsSending(false);
145
- setQueuedMessages([]);
146
- onAgentMessageDoneRef.current?.();
147
- if (apiClient) {
148
- refreshConversation(apiClient, conversationId, setMessages)
149
- .then(() => onConversationSettledRef.current?.())
150
- .catch(() => {});
151
- } else {
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
- const sendMessage = useCallback(async (content: string, options: { fileUrls?: string[]; replyTo?: SuperagentReplyTo } = {}) => {
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
- return;
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
- refreshConversation(apiClient, conversationId, setMessages).catch(() => {});
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
- // A queued send still needs a settle path, or isSending / the queued strip stick.
236
- armSettleFallback();
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
- const refreshedMessages = await refreshConversation(apiClient, conversationId, setMessages);
239
- if (!realtimeClient && hasNewAssistantResponse(refreshedMessages, assistantCountBefore)) {
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) => [...current, errorMessage]);
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