@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,895 @@
1
+ import type {
2
+ SuperagentAgent,
3
+ SuperagentAutomation,
4
+ SuperagentAutomationCreditsSummary,
5
+ SuperagentChannelStatus,
6
+ SuperagentCollaborator,
7
+ SuperagentConnector,
8
+ SuperagentConnectorAccessMode,
9
+ SuperagentConnectorActionInput,
10
+ SuperagentIMessageActivation,
11
+ SuperagentIMessageChannelStatus,
12
+ SuperagentInviteCollaboratorsResult,
13
+ SuperagentLineActivation,
14
+ SuperagentModelChoice,
15
+ SuperagentSandboxFileContent,
16
+ SuperagentSecret,
17
+ SuperagentTelegramChannelStatus,
18
+ SuperagentToolPermissionConfig,
19
+ } from './types';
20
+ import { SUPERAGENT_CONNECTOR_CATALOG } from './connectorCatalog';
21
+ import { DEFAULT_SANDBOX_FILE_PATHS, normalizeFilePaths } from './fileTreeUtils';
22
+
23
+ const AGENT_FIELDS = [
24
+ 'id',
25
+ 'name',
26
+ 'user_description',
27
+ 'status',
28
+ 'updated_date',
29
+ 'logo_url',
30
+ 'created_date',
31
+ 'app_type',
32
+ 'avatar_index',
33
+ 'model',
34
+ 'organization_id',
35
+ 'tools_permission_config',
36
+ ].join(',');
37
+
38
+ const USER_AGENT_AGENT_NAME = 'your_agent';
39
+ const USER_AGENT_SANDBOX_LIST_PATHS = [
40
+ '.agents',
41
+ '.agents/rules',
42
+ '.agents/skills',
43
+ '.agents/mcps',
44
+ '.agents/hooks',
45
+ '.agents/cron',
46
+ '.agents/memory',
47
+ 'incoming_files',
48
+ ];
49
+
50
+ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
51
+
52
+ type HttpRequestOptions = {
53
+ authRequired?: boolean;
54
+ body?: unknown;
55
+ headers?: Record<string, string>;
56
+ method: HttpMethod;
57
+ };
58
+
59
+ export type SuperagentApiClientConfig = {
60
+ baseUrl: string;
61
+ currentUserId?: string | null;
62
+ getAccessToken: () => Promise<string | null | undefined> | string | null | undefined;
63
+ getHeaders?: () => Promise<Record<string, string> | undefined> | Record<string, string> | undefined;
64
+ };
65
+
66
+ type UserAgentApp = {
67
+ id: string;
68
+ name?: string;
69
+ user_description?: string;
70
+ logo_url?: string;
71
+ model?: SuperagentModelChoice | string | null;
72
+ organization_id?: string | null;
73
+ avatar_index?: number | null;
74
+ tools_permission_config?: SuperagentToolPermissionConfig | null;
75
+ updated_date?: string;
76
+ created_date?: string;
77
+ app_type?: string;
78
+ };
79
+
80
+ type AppIntegration = {
81
+ integration_type: string;
82
+ integration_account_identifier?: string | null;
83
+ scopes?: string[];
84
+ status?: string;
85
+ };
86
+
87
+ type HttpResult<T> = {
88
+ success: boolean;
89
+ data?: T;
90
+ error?: {
91
+ message: string;
92
+ status?: number;
93
+ };
94
+ };
95
+
96
+ type SuperagentHttpClient = ReturnType<typeof createHttpClient>;
97
+
98
+ export type SuperagentVoiceLiveSession = {
99
+ sessionId: string;
100
+ streamToken: string;
101
+ websocketUrl: string;
102
+ };
103
+
104
+ type VoiceLiveSessionResponse = {
105
+ session_id?: string;
106
+ stream_token?: string;
107
+ };
108
+
109
+ type RuntimeAuthTokenResponse = {
110
+ token?: string;
111
+ };
112
+
113
+ type TelegramStatusResponse = {
114
+ connected: boolean;
115
+ bot_link?: string | null;
116
+ bot_name?: string | null;
117
+ bot_username?: string | null;
118
+ };
119
+
120
+ type LineActivationResponse = {
121
+ add_friend_url?: string;
122
+ code?: string;
123
+ };
124
+
125
+ type IMessageStatusResponse = {
126
+ connected: boolean;
127
+ phone_number?: string | null;
128
+ };
129
+
130
+ type IMessageActivationResponse = {
131
+ code?: string;
132
+ phone_number?: string;
133
+ };
134
+
135
+ type SandboxFileListResponse = {
136
+ files?: string[];
137
+ };
138
+
139
+ export type SuperagentConnectorsResult = {
140
+ availableConnectors: SuperagentConnector[];
141
+ connectedConnectors: SuperagentConnector[];
142
+ };
143
+
144
+ export type InitiateConnectorConnectionResult = {
145
+ already_authorized?: boolean;
146
+ connection_id?: string | null;
147
+ error?: string | null;
148
+ error_message?: string | null;
149
+ other_user_email?: string | null;
150
+ redirect_url?: string | null;
151
+ };
152
+
153
+ export type ConnectorConnectionStatus = 'ACTIVE' | 'FAILED' | 'PENDING';
154
+
155
+ const OAUTH_INJECTED_SCOPES = new Set(['email', 'openid', 'profile', 'User.Read', 'offline_access']);
156
+
157
+ export function createSuperagentApiClient(config: SuperagentApiClientConfig) {
158
+ const appsEndpoint = `${normalizeBaseUrl(config.baseUrl)}/api/apps`;
159
+ const httpClient = createHttpClient(config);
160
+
161
+ return {
162
+ async listAgents(): Promise<SuperagentAgent[]> {
163
+ const query = {
164
+ app_type: 'user_agent',
165
+ ...(config.currentUserId ? {owner_id: config.currentUserId} : {}),
166
+ };
167
+ const endpoint = buildUrl(appsEndpoint, {
168
+ fields: AGENT_FIELDS,
169
+ filter_mode: 'owned_by_me',
170
+ limit: '9',
171
+ q: JSON.stringify(query),
172
+ skip: '0',
173
+ sort: '-updated_date',
174
+ });
175
+
176
+ const response = await httpClient.get<UserAgentApp[]>(endpoint, true);
177
+ assertSuccess(response, 'Failed to load Superagents');
178
+ return (response.data ?? []).map(toAgent);
179
+ },
180
+
181
+ async createAgent(): Promise<SuperagentAgent> {
182
+ const response = await httpClient.post<UserAgentApp>(appsEndpoint, {app_type: 'user_agent'}, true);
183
+ assertSuccess(response, 'Failed to create Superagent');
184
+ if (!response.data?.id) {
185
+ throw new Error('Superagent creation returned no app id');
186
+ }
187
+ return toAgent(response.data);
188
+ },
189
+
190
+ async renameAgent(agentId: string, name: string): Promise<SuperagentAgent> {
191
+ return updateAgent(httpClient, appsEndpoint, agentId, {name});
192
+ },
193
+
194
+ async updateAgentModel(agentId: string, model: SuperagentModelChoice | string): Promise<SuperagentAgent> {
195
+ return updateAgent(httpClient, appsEndpoint, agentId, {model});
196
+ },
197
+
198
+ async updateToolPermissions(agentId: string, config: SuperagentToolPermissionConfig): Promise<SuperagentAgent> {
199
+ return updateAgent(httpClient, appsEndpoint, agentId, {tools_permission_config: config});
200
+ },
201
+
202
+ async deleteAgent(agentId: string): Promise<void> {
203
+ const response = await httpClient.delete(`${appsEndpoint}/${encodeURIComponent(agentId)}`, true);
204
+ assertSuccess(response, 'Failed to delete Superagent');
205
+ },
206
+
207
+ async listCollaborators(agentId: string): Promise<SuperagentCollaborator[]> {
208
+ const endpoint = `${appsEndpoint}/${encodeURIComponent(agentId)}/users/collaborators`;
209
+ const response = await httpClient.get<SuperagentCollaborator[]>(endpoint, true);
210
+ assertSuccess(response, 'Failed to load shared chat members');
211
+ return response.data ?? [];
212
+ },
213
+
214
+ async inviteCollaborators(
215
+ agentId: string,
216
+ emails: string[],
217
+ addAsGuest = false,
218
+ ): Promise<SuperagentInviteCollaboratorsResult> {
219
+ const endpoint = `${appsEndpoint}/${encodeURIComponent(agentId)}/users/invite-users`;
220
+ const response = await httpClient.post<SuperagentInviteCollaboratorsResult>(
221
+ endpoint,
222
+ {
223
+ add_as_guest: addAsGuest,
224
+ collaborator_role: 'editor',
225
+ role: 'admin',
226
+ user_emails: emails,
227
+ },
228
+ true,
229
+ );
230
+ assertSuccess(response, 'Failed to invite collaborators');
231
+ return response.data ?? {results: []};
232
+ },
233
+
234
+ async listSecrets(agentId: string): Promise<SuperagentSecret[]> {
235
+ const response = await httpClient.get<Record<string, string>>(`${appsEndpoint}/${encodeURIComponent(agentId)}/secrets`, true);
236
+ assertSuccess(response, 'Failed to load Superagent secrets');
237
+ return Object.entries(response.data ?? {}).map(([name, value]) => ({name, value: String(value)}));
238
+ },
239
+
240
+ async saveSecret(agentId: string, name: string, value: string): Promise<void> {
241
+ const response = await httpClient.post(
242
+ `${appsEndpoint}/${encodeURIComponent(agentId)}/secrets`,
243
+ {[name.trim().toUpperCase()]: value.trim()},
244
+ true,
245
+ );
246
+ assertSuccess(response, 'Failed to save Superagent secret');
247
+ },
248
+
249
+ async deleteSecret(agentId: string, name: string): Promise<void> {
250
+ const endpoint = buildUrl(`${appsEndpoint}/${encodeURIComponent(agentId)}/secrets`, {
251
+ secret_name: name,
252
+ });
253
+ const response = await httpClient.delete(endpoint, true);
254
+ assertSuccess(response, 'Failed to delete Superagent secret');
255
+ },
256
+
257
+ async listConnectors(agentId: string): Promise<SuperagentConnectorsResult> {
258
+ const endpoint = `${appsEndpoint}/${encodeURIComponent(agentId)}/external-auth/list`;
259
+ const response = await httpClient.get<{integrations?: AppIntegration[]}>(endpoint, true);
260
+ assertSuccess(response, 'Failed to load Superagent connectors');
261
+
262
+ const connectedConnectors = (response.data?.integrations ?? [])
263
+ .filter((integration) => !isPaymentIntegration(integration.integration_type))
264
+ .map(toConnector);
265
+ const connectedIds = new Set(connectedConnectors.map((connector) => connector.id));
266
+ const availableConnectors = SUPERAGENT_CONNECTOR_CATALOG.filter((connector) => !connectedIds.has(connector.id));
267
+
268
+ return {
269
+ availableConnectors,
270
+ connectedConnectors,
271
+ };
272
+ },
273
+
274
+ async listAutomations(agentId: string): Promise<SuperagentAutomation[]> {
275
+ const endpoint = `${appsEndpoint}/${encodeURIComponent(agentId)}/automations`;
276
+ const response = await httpClient.get<SuperagentAutomation[]>(endpoint, true);
277
+ assertSuccess(response, 'Failed to load Superagent automations');
278
+ return (response.data ?? []).sort((a, b) => getAutomationTime(b) - getAutomationTime(a));
279
+ },
280
+
281
+ async listAutomationCredits(agentId: string): Promise<Record<string, SuperagentAutomationCreditsSummary>> {
282
+ const endpoint = `${appsEndpoint}/${encodeURIComponent(agentId)}/automations/credits-summary`;
283
+ const response = await httpClient.get<Record<string, SuperagentAutomationCreditsSummary>>(endpoint, true);
284
+ assertSuccess(response, 'Failed to load Superagent automation credits');
285
+ return response.data ?? {};
286
+ },
287
+
288
+ async listSandboxFiles(agentId: string): Promise<string[]> {
289
+ const rootFiles = await listSandboxFilesAt(httpClient, appsEndpoint, agentId, '.');
290
+ const agentFiles = await listUserAgentSandboxFilePaths(httpClient, appsEndpoint, agentId);
291
+
292
+ if (normalizeFilePaths(rootFiles).length === 0) {
293
+ return agentFiles;
294
+ }
295
+
296
+ return mergeSandboxFilePaths(rootFiles, agentFiles);
297
+ },
298
+
299
+ async readSandboxFile(agentId: string, path: string): Promise<SuperagentSandboxFileContent> {
300
+ const endpoint = buildUrl(`${appsEndpoint}/${encodeURIComponent(agentId)}/sandbox/files/content`, {
301
+ path,
302
+ });
303
+ const response = await httpClient.get<SuperagentSandboxFileContent>(endpoint, true);
304
+ assertSuccess(response, 'Failed to open Superagent file');
305
+ if (typeof response.data?.content !== 'string') {
306
+ throw new Error('The backend returned no file content.');
307
+ }
308
+ return {
309
+ content: response.data.content,
310
+ path: response.data.path || path,
311
+ };
312
+ },
313
+
314
+ async writeSandboxFile(agentId: string, path: string, content: string): Promise<void> {
315
+ const endpoint = `${appsEndpoint}/${encodeURIComponent(agentId)}/sandbox/files/content`;
316
+ const response = await httpClient.request(endpoint, {
317
+ authRequired: true,
318
+ body: {content, path},
319
+ method: 'PUT',
320
+ });
321
+ assertSuccess(response, 'Failed to save Superagent file');
322
+ },
323
+
324
+ async initiateConnectorConnection(
325
+ agentId: string,
326
+ connectorId: string,
327
+ options: Pick<SuperagentConnectorActionInput, 'accessMode' | 'forceReconnect' | 'scopes'> = {},
328
+ ): Promise<InitiateConnectorConnectionResult> {
329
+ const endpoint = `${appsEndpoint}/${encodeURIComponent(agentId)}/external-auth/initiate`;
330
+ const scopes = options.scopes ?? getConnectorScopes(connectorId, options.accessMode);
331
+ const response = await httpClient.post<InitiateConnectorConnectionResult>(
332
+ endpoint,
333
+ {
334
+ force_reconnect: options.forceReconnect ?? false,
335
+ integration_type: connectorId,
336
+ scopes,
337
+ },
338
+ true,
339
+ );
340
+ assertSuccess(response, 'Failed to start connector authorization');
341
+ return response.data ?? {};
342
+ },
343
+
344
+ async getConnectorConnectionStatus(
345
+ agentId: string,
346
+ connectorId: string,
347
+ connectionId: string,
348
+ ): Promise<ConnectorConnectionStatus> {
349
+ const endpoint = buildUrl(`${appsEndpoint}/${encodeURIComponent(agentId)}/external-auth/status`, {
350
+ connection_id: connectionId,
351
+ integration_type: connectorId,
352
+ });
353
+ const response = await httpClient.get<{status?: ConnectorConnectionStatus}>(endpoint, true);
354
+ assertSuccess(response, 'Failed to check connector authorization status');
355
+ return response.data?.status ?? 'PENDING';
356
+ },
357
+
358
+ async getRuntimeAuthToken(agentId: string): Promise<string> {
359
+ const endpoint = `${appsEndpoint}/${encodeURIComponent(agentId)}/auth/token`;
360
+ const response = await httpClient.get<RuntimeAuthTokenResponse>(endpoint, true);
361
+ assertSuccess(response, 'Failed to start Superagent realtime');
362
+ if (!response.data?.token) {
363
+ throw new Error('Superagent realtime returned no auth token');
364
+ }
365
+ return response.data.token;
366
+ },
367
+
368
+ getWhatsAppConnectUrl(agentId: string, runtimeAuthToken: string): string {
369
+ return buildUrl(`${appsEndpoint}/${encodeURIComponent(agentId)}/agents/${USER_AGENT_AGENT_NAME}/whatsapp`, {
370
+ token: runtimeAuthToken,
371
+ });
372
+ },
373
+
374
+ async getChannelStatus(agentId: string, runtimeAuthToken: string): Promise<SuperagentChannelStatus> {
375
+ const [telegram, imessage] = await Promise.all([
376
+ this.getTelegramStatus(agentId, runtimeAuthToken).catch(() => ({connected: false})),
377
+ this.getIMessageStatus(agentId, runtimeAuthToken).catch(() => ({connected: false})),
378
+ ]);
379
+
380
+ return {
381
+ imessage,
382
+ line: {connected: false},
383
+ telegram,
384
+ whatsapp: {
385
+ connected: false,
386
+ connectUrl: this.getWhatsAppConnectUrl(agentId, runtimeAuthToken),
387
+ },
388
+ };
389
+ },
390
+
391
+ async getTelegramStatus(agentId: string, runtimeAuthToken: string): Promise<SuperagentTelegramChannelStatus> {
392
+ const response = await runtimeRequest<TelegramStatusResponse>(httpClient, appsEndpoint, agentId, runtimeAuthToken, '/telegram/status', {
393
+ method: 'GET',
394
+ });
395
+ assertSuccess(response, 'Failed to load Telegram status');
396
+ return normalizeTelegramStatus(response.data);
397
+ },
398
+
399
+ async getIMessageStatus(agentId: string, runtimeAuthToken: string): Promise<SuperagentIMessageChannelStatus> {
400
+ const response = await runtimeRequest<IMessageStatusResponse>(httpClient, appsEndpoint, agentId, runtimeAuthToken, '/imessage/status', {
401
+ method: 'GET',
402
+ });
403
+ assertSuccess(response, 'Failed to load iMessage status');
404
+ return normalizeIMessageStatus(response.data);
405
+ },
406
+
407
+ async generateIMessageCode(agentId: string, runtimeAuthToken: string): Promise<SuperagentIMessageActivation> {
408
+ const response = await runtimeRequest<IMessageActivationResponse>(httpClient, appsEndpoint, agentId, runtimeAuthToken, '/imessage/generate-code', {
409
+ method: 'POST',
410
+ });
411
+ assertSuccess(response, 'Failed to generate iMessage code');
412
+ if (!response.data?.code || !response.data.phone_number) {
413
+ throw new Error('iMessage setup returned no activation code.');
414
+ }
415
+
416
+ return {
417
+ code: response.data.code,
418
+ phoneNumber: response.data.phone_number,
419
+ };
420
+ },
421
+
422
+ async disconnectIMessage(agentId: string, runtimeAuthToken: string): Promise<SuperagentIMessageChannelStatus> {
423
+ const response = await runtimeRequest<IMessageStatusResponse>(httpClient, appsEndpoint, agentId, runtimeAuthToken, '/imessage/disconnect', {
424
+ method: 'DELETE',
425
+ });
426
+ assertSuccess(response, 'Failed to disconnect iMessage');
427
+ return normalizeIMessageStatus(response.data);
428
+ },
429
+
430
+ async setupTelegram(agentId: string, runtimeAuthToken: string, token: string): Promise<SuperagentTelegramChannelStatus> {
431
+ const response = await runtimeRequest<TelegramStatusResponse>(httpClient, appsEndpoint, agentId, runtimeAuthToken, '/telegram/setup', {
432
+ body: {bot_token: token},
433
+ method: 'POST',
434
+ });
435
+ assertSuccess(response, 'Failed to connect Telegram');
436
+ return normalizeTelegramStatus(response.data);
437
+ },
438
+
439
+ async disconnectTelegram(agentId: string, runtimeAuthToken: string): Promise<void> {
440
+ const response = await runtimeRequest(httpClient, appsEndpoint, agentId, runtimeAuthToken, '/telegram/disconnect', {
441
+ method: 'DELETE',
442
+ });
443
+ assertSuccess(response, 'Failed to disconnect Telegram');
444
+ },
445
+
446
+ async generateLineCode(agentId: string, runtimeAuthToken: string): Promise<SuperagentLineActivation> {
447
+ const response = await runtimeRequest<LineActivationResponse>(httpClient, appsEndpoint, agentId, runtimeAuthToken, '/line/generate-code', {
448
+ method: 'POST',
449
+ });
450
+ assertSuccess(response, 'Failed to generate LINE code');
451
+ if (!response.data?.code || !response.data.add_friend_url) {
452
+ throw new Error('LINE setup returned no activation code.');
453
+ }
454
+
455
+ return {
456
+ addFriendUrl: response.data.add_friend_url,
457
+ code: response.data.code,
458
+ };
459
+ },
460
+
461
+ async disconnectConnector(agentId: string, connectorId: string): Promise<void> {
462
+ const endpoint = `${appsEndpoint}/${encodeURIComponent(agentId)}/external-auth/integrations/${encodeURIComponent(connectorId)}`;
463
+ const response = await httpClient.delete(endpoint, true);
464
+ assertSuccess(response, 'Failed to disconnect connector');
465
+ },
466
+
467
+ async removeConnector(agentId: string, connectorId: string): Promise<void> {
468
+ const endpoint = `${appsEndpoint}/${encodeURIComponent(agentId)}/external-auth/integrations/${encodeURIComponent(connectorId)}/remove`;
469
+ const response = await httpClient.delete(endpoint, true);
470
+ assertSuccess(response, 'Failed to remove connector');
471
+ },
472
+
473
+ async toggleAutomation(agentId: string, automation: SuperagentAutomation): Promise<SuperagentAutomation> {
474
+ const response = await httpClient.post<SuperagentAutomation>(
475
+ `${getAutomationPath(appsEndpoint, agentId, automation)}/toggle`,
476
+ undefined,
477
+ true,
478
+ );
479
+ assertSuccess(response, 'Failed to update automation status');
480
+ return normalizeAutomationResponse(response.data, automation);
481
+ },
482
+
483
+ async archiveAutomation(agentId: string, automation: SuperagentAutomation): Promise<SuperagentAutomation> {
484
+ const response = await httpClient.post<SuperagentAutomation>(
485
+ `${getAutomationPath(appsEndpoint, agentId, automation)}/archive`,
486
+ undefined,
487
+ true,
488
+ );
489
+ assertSuccess(response, 'Failed to archive automation');
490
+ return normalizeAutomationResponse(response.data, automation);
491
+ },
492
+
493
+ async restoreAutomation(agentId: string, automation: SuperagentAutomation): Promise<SuperagentAutomation> {
494
+ const response = await httpClient.post<SuperagentAutomation>(
495
+ `${getAutomationPath(appsEndpoint, agentId, automation)}/unarchive`,
496
+ undefined,
497
+ true,
498
+ );
499
+ assertSuccess(response, 'Failed to restore automation');
500
+ return normalizeAutomationResponse(response.data, automation);
501
+ },
502
+
503
+ async deleteAutomation(agentId: string, automation: SuperagentAutomation): Promise<void> {
504
+ const response = await httpClient.delete(getAutomationPath(appsEndpoint, agentId, automation), true);
505
+ assertSuccess(response, 'Failed to delete automation');
506
+ },
507
+
508
+ async runAutomationNow(agentId: string, automation: SuperagentAutomation): Promise<void> {
509
+ if (automation.automation_type !== 'scheduled') {
510
+ throw new Error('Only scheduled automations can be run manually from mobile.');
511
+ }
512
+
513
+ const response = await httpClient.post(
514
+ `${getAutomationPath(appsEndpoint, agentId, automation)}/run`,
515
+ undefined,
516
+ true,
517
+ );
518
+ assertSuccess(response, 'Failed to run automation');
519
+ },
520
+
521
+ async createVoiceLiveSession(agentId: string, conversationId: string | null): Promise<SuperagentVoiceLiveSession> {
522
+ const endpoint = `${appsEndpoint}/${encodeURIComponent(agentId)}/user-agent/voice/live-session`;
523
+ const response = await httpClient.post<VoiceLiveSessionResponse>(
524
+ endpoint,
525
+ {
526
+ conversation_id: conversationId,
527
+ },
528
+ true,
529
+ );
530
+ if (!response.success && response.error?.status === 404) {
531
+ throw new Error(
532
+ `Live Voice is not available on ${normalizeBaseUrl(config.baseUrl)}. Deploy the Superagent voice session endpoint or point the mobile app to a backend that has /user-agent/voice/live-session.`,
533
+ );
534
+ }
535
+ assertSuccess(response, 'Failed to start Live Voice');
536
+ if (!response.data?.session_id || !response.data.stream_token) {
537
+ throw new Error('Live Voice returned no session token');
538
+ }
539
+ return {
540
+ sessionId: response.data.session_id,
541
+ streamToken: response.data.stream_token,
542
+ websocketUrl: buildVoiceStreamUrl(config.baseUrl, agentId, response.data.session_id),
543
+ };
544
+ },
545
+
546
+ async deleteVoiceLiveSession(agentId: string, sessionId: string): Promise<void> {
547
+ const endpoint = `${appsEndpoint}/${encodeURIComponent(agentId)}/user-agent/voice/live-session/${encodeURIComponent(sessionId)}`;
548
+ const response = await httpClient.delete(endpoint, true);
549
+ assertSuccess(response, 'Failed to clean up Live Voice session');
550
+ },
551
+ };
552
+ }
553
+
554
+ function createHttpClient(config: SuperagentApiClientConfig) {
555
+ return {
556
+ async request<T>(endpoint: string, options: HttpRequestOptions): Promise<HttpResult<T>> {
557
+ const {
558
+ authRequired = true,
559
+ body,
560
+ headers = {},
561
+ method,
562
+ } = options;
563
+
564
+ const requestHeaders: Record<string, string> = {
565
+ 'X-Client-Platform': 'mobile_native',
566
+ ...(body === undefined ? {} : { 'Content-Type': 'application/json' }),
567
+ ...(await config.getHeaders?.()),
568
+ ...headers,
569
+ };
570
+
571
+ if (authRequired) {
572
+ const accessToken = await config.getAccessToken();
573
+ if (!accessToken) {
574
+ return {
575
+ success: false,
576
+ error: {message: 'User not authenticated'},
577
+ };
578
+ }
579
+ requestHeaders.Authorization = `Bearer ${accessToken}`;
580
+ }
581
+
582
+ try {
583
+ const response = await fetch(endpoint, {
584
+ body: body === undefined ? undefined : JSON.stringify(body),
585
+ headers: requestHeaders,
586
+ method,
587
+ });
588
+
589
+ const data = response.status === 204 ? undefined : await parseJson(response);
590
+ if (!response.ok) {
591
+ return {
592
+ success: false,
593
+ error: {
594
+ message: getResponseErrorMessage(data, response.status),
595
+ status: response.status,
596
+ },
597
+ };
598
+ }
599
+
600
+ return {
601
+ success: true,
602
+ data: data as T,
603
+ };
604
+ } catch (error) {
605
+ return {
606
+ success: false,
607
+ error: {message: error instanceof Error ? error.message : 'Request failed'},
608
+ };
609
+ }
610
+ },
611
+
612
+ get<T = unknown>(endpoint: string, authRequired = true): Promise<HttpResult<T>> {
613
+ return this.request<T>(endpoint, { authRequired, method: 'GET' });
614
+ },
615
+
616
+ post<T = unknown>(endpoint: string, body?: unknown, authRequired = true): Promise<HttpResult<T>> {
617
+ return this.request<T>(endpoint, { authRequired, body, method: 'POST' });
618
+ },
619
+
620
+ delete<T = unknown>(endpoint: string, authRequired = true): Promise<HttpResult<T>> {
621
+ return this.request<T>(endpoint, { authRequired, method: 'DELETE' });
622
+ },
623
+ };
624
+ }
625
+
626
+ async function parseJson(response: Response) {
627
+ try {
628
+ return await response.json();
629
+ } catch {
630
+ return undefined;
631
+ }
632
+ }
633
+
634
+ function getResponseErrorMessage(data: unknown, status: number) {
635
+ if (data && typeof data === 'object') {
636
+ const body = data as { detail?: unknown; message?: unknown };
637
+ if (typeof body.message === 'string') {
638
+ return body.message;
639
+ }
640
+ if (typeof body.detail === 'string') {
641
+ return body.detail;
642
+ }
643
+ }
644
+
645
+ return `Request failed with status ${status}`;
646
+ }
647
+
648
+ function normalizeBaseUrl(url: string) {
649
+ return url.trim().replace(/\/+$/, '');
650
+ }
651
+
652
+ function buildVoiceStreamUrl(baseUrl: string, agentId: string, sessionId: string) {
653
+ const normalized = normalizeBaseUrl(baseUrl);
654
+ const websocketBase = normalized
655
+ .replace(/^https:/i, 'wss:')
656
+ .replace(/^http:/i, 'ws:');
657
+
658
+ return `${websocketBase}/api/apps/${encodeURIComponent(agentId)}/user-agent/voice/live-session/${encodeURIComponent(sessionId)}/stream`;
659
+ }
660
+
661
+ async function listSandboxFilesAt(
662
+ httpClient: SuperagentHttpClient,
663
+ appsEndpoint: string,
664
+ agentId: string,
665
+ path: string,
666
+ ): Promise<string[]> {
667
+ const endpoint = buildUrl(`${appsEndpoint}/${encodeURIComponent(agentId)}/sandbox/files/list`, {
668
+ include_all: 'true',
669
+ path,
670
+ });
671
+ const response = await httpClient.get<SandboxFileListResponse>(endpoint, true);
672
+ assertSuccess(response, 'Failed to load Superagent files');
673
+ return response.data?.files ?? [];
674
+ }
675
+
676
+ async function listUserAgentSandboxFilePaths(
677
+ httpClient: SuperagentHttpClient,
678
+ appsEndpoint: string,
679
+ agentId: string,
680
+ ) {
681
+ const paths = new Set(DEFAULT_SANDBOX_FILE_PATHS);
682
+
683
+ await Promise.all(
684
+ USER_AGENT_SANDBOX_LIST_PATHS.map(async (sandboxPath) => {
685
+ try {
686
+ const files = await listSandboxFilesAt(httpClient, appsEndpoint, agentId, sandboxPath);
687
+ files.forEach((filePath) => paths.add(joinSandboxPath(sandboxPath, filePath)));
688
+ } catch {
689
+ // Missing optional directories should not make the Files tab look empty.
690
+ }
691
+ }),
692
+ );
693
+
694
+ return [...paths];
695
+ }
696
+
697
+ function mergeSandboxFilePaths(...pathGroups: string[][]) {
698
+ return [...new Set(pathGroups.flat())];
699
+ }
700
+
701
+ function joinSandboxPath(parentPath: string, childPath: string) {
702
+ return `${parentPath.replace(/\/+$/, '')}/${childPath.replace(/^\/+/, '')}`;
703
+ }
704
+
705
+ async function updateAgent(
706
+ httpClient: SuperagentHttpClient,
707
+ appsEndpoint: string,
708
+ agentId: string,
709
+ body: Partial<UserAgentApp>,
710
+ ): Promise<SuperagentAgent> {
711
+ const response = await httpClient.request<UserAgentApp>(`${appsEndpoint}/${encodeURIComponent(agentId)}`, {
712
+ authRequired: true,
713
+ body,
714
+ method: 'PUT',
715
+ });
716
+ assertSuccess(response, 'Failed to update Superagent');
717
+ if (!response.data?.id) {
718
+ throw new Error('Superagent update returned no app id');
719
+ }
720
+ return toAgent(response.data);
721
+ }
722
+
723
+ function toAgent(app: UserAgentApp): SuperagentAgent {
724
+ return {
725
+ id: app.id,
726
+ name: app.name || 'New Superagent',
727
+ description: app.user_description,
728
+ logoUrl: app.logo_url,
729
+ model: app.model ?? 'default',
730
+ organizationId: app.organization_id ?? null,
731
+ toolsPermissionConfig: app.tools_permission_config ?? undefined,
732
+ avatarIndex: app.avatar_index,
733
+ updatedAt: app.updated_date ?? app.created_date,
734
+ };
735
+ }
736
+
737
+ function toConnector(integration: AppIntegration): SuperagentConnector {
738
+ const meta = SUPERAGENT_CONNECTOR_CATALOG.find((connector) => connector.id === integration.integration_type);
739
+ return {
740
+ accessMode: detectAccessMode(integration.scopes ?? [], integration.integration_type),
741
+ accountIdentifier: integration.integration_account_identifier,
742
+ accessModes: meta?.accessModes,
743
+ category: meta?.category,
744
+ exampleScopes: meta?.exampleScopes,
745
+ iconBackgroundColor: meta?.iconBackgroundColor,
746
+ iconFallbackLabel: meta?.iconFallbackLabel,
747
+ iconUrl: meta?.iconUrl,
748
+ id: integration.integration_type,
749
+ name: meta?.name ?? formatConnectorName(integration.integration_type),
750
+ scopes: integration.scopes,
751
+ status: normalizeConnectorStatus(integration.status),
752
+ subtitle: meta?.subtitle,
753
+ supportsReadOnly: meta?.supportsReadOnly,
754
+ };
755
+ }
756
+
757
+ function detectAccessMode(scopes: string[], connectorId?: string): SuperagentConnectorAccessMode {
758
+ const connector = connectorId ? SUPERAGENT_CONNECTOR_CATALOG.find((item) => item.id === connectorId) : undefined;
759
+ if (connector?.accessModes) {
760
+ const filtered = scopes.filter((scope) => !OAUTH_INJECTED_SCOPES.has(scope));
761
+ const readOnlyScopes = connector.accessModes.readOnly;
762
+ const readOnlySet = new Set(readOnlyScopes);
763
+ if (filtered.length === readOnlyScopes.length && filtered.every((scope) => readOnlySet.has(scope))) {
764
+ return 'read_only';
765
+ }
766
+ return 'full_access';
767
+ }
768
+
769
+ const hasWriteScope = scopes.some((scope) => /write|send|create|edit|delete|manage|modify|repo/i.test(scope));
770
+ return hasWriteScope ? 'full_access' : 'read_only';
771
+ }
772
+
773
+ function formatConnectorName(connectorId: string) {
774
+ return connectorId
775
+ .split(/[_-]/)
776
+ .filter(Boolean)
777
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
778
+ .join(' ');
779
+ }
780
+
781
+ function getConnectorScopes(connectorId: string, accessMode?: SuperagentConnectorAccessMode) {
782
+ const connector = SUPERAGENT_CONNECTOR_CATALOG.find((item) => item.id === connectorId);
783
+ if (!connector) {
784
+ return null;
785
+ }
786
+
787
+ if (connector.accessModes) {
788
+ return accessMode === 'read_only' ? connector.accessModes.readOnly : connector.accessModes.fullAccess;
789
+ }
790
+
791
+ return connector.exampleScopes ?? null;
792
+ }
793
+
794
+ function isPaymentIntegration(integrationType: string) {
795
+ return integrationType === 'stripe' || integrationType === 'stripe_payment' || integrationType === 'wix_payments';
796
+ }
797
+
798
+ function normalizeConnectorStatus(status?: string): SuperagentConnector['status'] {
799
+ const normalized = status?.toLowerCase();
800
+ if (normalized === 'expired' || normalized === 'disconnected') {
801
+ return normalized;
802
+ }
803
+ return 'active';
804
+ }
805
+
806
+ function getAutomationPath(appsEndpoint: string, agentId: string, automation: SuperagentAutomation) {
807
+ const type = getAutomationType(automation);
808
+ return `${appsEndpoint}/${encodeURIComponent(agentId)}/automations/${type}/${encodeURIComponent(automation.id)}`;
809
+ }
810
+
811
+ function getAutomationType(automation: SuperagentAutomation) {
812
+ if (
813
+ automation.automation_type === 'scheduled' ||
814
+ automation.automation_type === 'entity' ||
815
+ automation.automation_type === 'connector'
816
+ ) {
817
+ return automation.automation_type;
818
+ }
819
+
820
+ throw new Error(`Unsupported automation type: ${automation.automation_type}`);
821
+ }
822
+
823
+ function normalizeAutomationResponse(
824
+ updated: SuperagentAutomation | undefined,
825
+ fallback: SuperagentAutomation,
826
+ ): SuperagentAutomation {
827
+ if (!updated?.id) {
828
+ return fallback;
829
+ }
830
+
831
+ return {
832
+ ...updated,
833
+ automation_type: updated.automation_type ?? fallback.automation_type,
834
+ };
835
+ }
836
+
837
+ function normalizeTelegramStatus(status: TelegramStatusResponse | undefined): SuperagentTelegramChannelStatus {
838
+ return {
839
+ botLink: status?.bot_link,
840
+ botName: status?.bot_name,
841
+ botUsername: status?.bot_username,
842
+ connected: !!status?.connected,
843
+ };
844
+ }
845
+
846
+ function normalizeIMessageStatus(status: IMessageStatusResponse | undefined): SuperagentIMessageChannelStatus {
847
+ return {
848
+ connected: !!status?.connected,
849
+ phoneNumber: status?.phone_number ?? null,
850
+ };
851
+ }
852
+
853
+ async function runtimeRequest<T = unknown>(
854
+ httpClient: SuperagentHttpClient,
855
+ appsEndpoint: string,
856
+ agentId: string,
857
+ runtimeAuthToken: string,
858
+ path: string,
859
+ options: {
860
+ body?: unknown;
861
+ method: 'DELETE' | 'GET' | 'POST';
862
+ },
863
+ ) {
864
+ return httpClient.request<T>(`${appsEndpoint}/${encodeURIComponent(agentId)}${path}`, {
865
+ authRequired: false,
866
+ body: options.body,
867
+ headers: {
868
+ Authorization: `Bearer ${runtimeAuthToken}`,
869
+ },
870
+ method: options.method,
871
+ });
872
+ }
873
+
874
+ function getAutomationTime(automation: SuperagentAutomation) {
875
+ const dateValue = automation.updated_date ?? automation.created_date ?? automation.last_run_at;
876
+ if (!dateValue) {
877
+ return 0;
878
+ }
879
+
880
+ const timestamp = Date.parse(dateValue);
881
+ return Number.isNaN(timestamp) ? 0 : timestamp;
882
+ }
883
+
884
+ function assertSuccess<T>(response: HttpResult<T>, fallback: string): asserts response is HttpResult<T> & {success: true} {
885
+ if (!response.success) {
886
+ throw new Error(response.error?.message || fallback);
887
+ }
888
+ }
889
+
890
+ function buildUrl(baseUrl: string, query: Record<string, string>) {
891
+ const queryString = Object.entries(query)
892
+ .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
893
+ .join('&');
894
+ return `${baseUrl}?${queryString}`;
895
+ }