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