@stigmer/react 3.1.16 → 3.2.0

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 (824) hide show
  1. package/README.md +16 -1
  2. package/agent-instance/AgentInstanceList.d.ts.map +1 -1
  3. package/agent-instance/AgentInstanceList.js +11 -3
  4. package/agent-instance/AgentInstanceList.js.map +1 -1
  5. package/channel/AgentChannelsPanel.d.ts +60 -0
  6. package/channel/AgentChannelsPanel.d.ts.map +1 -0
  7. package/channel/AgentChannelsPanel.js +255 -0
  8. package/channel/AgentChannelsPanel.js.map +1 -0
  9. package/channel/ChannelConversationsDialog.d.ts +41 -0
  10. package/channel/ChannelConversationsDialog.d.ts.map +1 -0
  11. package/channel/ChannelConversationsDialog.js +94 -0
  12. package/channel/ChannelConversationsDialog.js.map +1 -0
  13. package/channel/ChannelCredentialsDialog.d.ts +37 -0
  14. package/channel/ChannelCredentialsDialog.d.ts.map +1 -0
  15. package/channel/ChannelCredentialsDialog.js +75 -0
  16. package/channel/ChannelCredentialsDialog.js.map +1 -0
  17. package/channel/ChannelToolCredentials.d.ts +31 -0
  18. package/channel/ChannelToolCredentials.d.ts.map +1 -0
  19. package/channel/ChannelToolCredentials.js +41 -0
  20. package/channel/ChannelToolCredentials.js.map +1 -0
  21. package/channel/ConnectSlackDialog.d.ts +61 -0
  22. package/channel/ConnectSlackDialog.d.ts.map +1 -0
  23. package/channel/ConnectSlackDialog.js +238 -0
  24. package/channel/ConnectSlackDialog.js.map +1 -0
  25. package/channel/ConnectWhatsAppDialog.d.ts +70 -0
  26. package/channel/ConnectWhatsAppDialog.d.ts.map +1 -0
  27. package/channel/ConnectWhatsAppDialog.js +256 -0
  28. package/channel/ConnectWhatsAppDialog.js.map +1 -0
  29. package/channel/SlackMarkIcon.d.ts +11 -0
  30. package/channel/SlackMarkIcon.d.ts.map +1 -0
  31. package/channel/SlackMarkIcon.js +13 -0
  32. package/channel/SlackMarkIcon.js.map +1 -0
  33. package/channel/WhatsAppMarkIcon.d.ts +12 -0
  34. package/channel/WhatsAppMarkIcon.d.ts.map +1 -0
  35. package/channel/WhatsAppMarkIcon.js +14 -0
  36. package/channel/WhatsAppMarkIcon.js.map +1 -0
  37. package/channel/connect/ServingAppSection.d.ts +57 -0
  38. package/channel/connect/ServingAppSection.d.ts.map +1 -0
  39. package/channel/connect/ServingAppSection.js +49 -0
  40. package/channel/connect/ServingAppSection.js.map +1 -0
  41. package/channel/connect/ToolCredentialsSection.d.ts +20 -0
  42. package/channel/connect/ToolCredentialsSection.d.ts.map +1 -0
  43. package/channel/connect/ToolCredentialsSection.js +22 -0
  44. package/channel/connect/ToolCredentialsSection.js.map +1 -0
  45. package/channel/connect/VerbatimRefusal.d.ts +16 -0
  46. package/channel/connect/VerbatimRefusal.d.ts.map +1 -0
  47. package/channel/connect/VerbatimRefusal.js +18 -0
  48. package/channel/connect/VerbatimRefusal.js.map +1 -0
  49. package/channel/connect/icons.d.ts +16 -0
  50. package/channel/connect/icons.d.ts.map +1 -0
  51. package/channel/connect/icons.js +21 -0
  52. package/channel/connect/icons.js.map +1 -0
  53. package/channel/index.d.ts +36 -0
  54. package/channel/index.d.ts.map +1 -0
  55. package/channel/index.js +19 -0
  56. package/channel/index.js.map +1 -0
  57. package/channel/providerPresentation.d.ts +44 -0
  58. package/channel/providerPresentation.d.ts.map +1 -0
  59. package/channel/providerPresentation.js +106 -0
  60. package/channel/providerPresentation.js.map +1 -0
  61. package/channel/providers.d.ts +62 -0
  62. package/channel/providers.d.ts.map +1 -0
  63. package/channel/providers.js +26 -0
  64. package/channel/providers.js.map +1 -0
  65. package/channel/useAgentChannel.d.ts +31 -0
  66. package/channel/useAgentChannel.d.ts.map +1 -0
  67. package/channel/useAgentChannel.js +34 -0
  68. package/channel/useAgentChannel.js.map +1 -0
  69. package/channel/useAgentChannelList.d.ts +43 -0
  70. package/channel/useAgentChannelList.d.ts.map +1 -0
  71. package/channel/useAgentChannelList.js +39 -0
  72. package/channel/useAgentChannelList.js.map +1 -0
  73. package/channel/useChannelSessions.d.ts +47 -0
  74. package/channel/useChannelSessions.d.ts.map +1 -0
  75. package/channel/useChannelSessions.js +38 -0
  76. package/channel/useChannelSessions.js.map +1 -0
  77. package/channel/useChannelToolReadiness.d.ts +23 -0
  78. package/channel/useChannelToolReadiness.d.ts.map +1 -0
  79. package/channel/useChannelToolReadiness.js +28 -0
  80. package/channel/useChannelToolReadiness.js.map +1 -0
  81. package/channel/useConnectSlackChannel.d.ts +75 -0
  82. package/channel/useConnectSlackChannel.d.ts.map +1 -0
  83. package/channel/useConnectSlackChannel.js +115 -0
  84. package/channel/useConnectSlackChannel.js.map +1 -0
  85. package/channel/useCreateAgentChannel.d.ts +42 -0
  86. package/channel/useCreateAgentChannel.d.ts.map +1 -0
  87. package/channel/useCreateAgentChannel.js +48 -0
  88. package/channel/useCreateAgentChannel.js.map +1 -0
  89. package/channel/useDeleteAgentChannel.d.ts +40 -0
  90. package/channel/useDeleteAgentChannel.d.ts.map +1 -0
  91. package/channel/useDeleteAgentChannel.js +44 -0
  92. package/channel/useDeleteAgentChannel.js.map +1 -0
  93. package/channel/useInstallChannel.d.ts +60 -0
  94. package/channel/useInstallChannel.d.ts.map +1 -0
  95. package/channel/useInstallChannel.js +63 -0
  96. package/channel/useInstallChannel.js.map +1 -0
  97. package/channel/useOrgAgentChannelList.d.ts +32 -0
  98. package/channel/useOrgAgentChannelList.d.ts.map +1 -0
  99. package/channel/useOrgAgentChannelList.js +29 -0
  100. package/channel/useOrgAgentChannelList.js.map +1 -0
  101. package/channel/useSaveAgentChannel.d.ts +63 -0
  102. package/channel/useSaveAgentChannel.d.ts.map +1 -0
  103. package/channel/useSaveAgentChannel.js +104 -0
  104. package/channel/useSaveAgentChannel.js.map +1 -0
  105. package/channel-app/ChannelAppDetailPanel.d.ts +46 -0
  106. package/channel-app/ChannelAppDetailPanel.d.ts.map +1 -0
  107. package/channel-app/ChannelAppDetailPanel.js +142 -0
  108. package/channel-app/ChannelAppDetailPanel.js.map +1 -0
  109. package/channel-app/ChannelAppListPanel.d.ts +36 -0
  110. package/channel-app/ChannelAppListPanel.d.ts.map +1 -0
  111. package/channel-app/ChannelAppListPanel.js +63 -0
  112. package/channel-app/ChannelAppListPanel.js.map +1 -0
  113. package/channel-app/CreateChannelAppForm.d.ts +54 -0
  114. package/channel-app/CreateChannelAppForm.d.ts.map +1 -0
  115. package/channel-app/CreateChannelAppForm.js +140 -0
  116. package/channel-app/CreateChannelAppForm.js.map +1 -0
  117. package/channel-app/index.d.ts +18 -0
  118. package/channel-app/index.d.ts.map +1 -0
  119. package/channel-app/index.js +10 -0
  120. package/channel-app/index.js.map +1 -0
  121. package/channel-app/internal.d.ts +33 -0
  122. package/channel-app/internal.d.ts.map +1 -0
  123. package/channel-app/internal.js +44 -0
  124. package/channel-app/internal.js.map +1 -0
  125. package/channel-app/slackAppSetup.d.ts +80 -0
  126. package/channel-app/slackAppSetup.d.ts.map +1 -0
  127. package/channel-app/slackAppSetup.js +123 -0
  128. package/channel-app/slackAppSetup.js.map +1 -0
  129. package/channel-app/useChannelAppList.d.ts +35 -0
  130. package/channel-app/useChannelAppList.d.ts.map +1 -0
  131. package/channel-app/useChannelAppList.js +34 -0
  132. package/channel-app/useChannelAppList.js.map +1 -0
  133. package/channel-app/useCreateChannelApp.d.ts +39 -0
  134. package/channel-app/useCreateChannelApp.d.ts.map +1 -0
  135. package/channel-app/useCreateChannelApp.js +50 -0
  136. package/channel-app/useCreateChannelApp.js.map +1 -0
  137. package/channel-app/useDeleteChannelApp.d.ts +31 -0
  138. package/channel-app/useDeleteChannelApp.d.ts.map +1 -0
  139. package/channel-app/useDeleteChannelApp.js +43 -0
  140. package/channel-app/useDeleteChannelApp.js.map +1 -0
  141. package/channel-app/useUpdateChannelApp.d.ts +39 -0
  142. package/channel-app/useUpdateChannelApp.d.ts.map +1 -0
  143. package/channel-app/useUpdateChannelApp.js +50 -0
  144. package/channel-app/useUpdateChannelApp.js.map +1 -0
  145. package/channel-app/whatsappAppSetup.d.ts +51 -0
  146. package/channel-app/whatsappAppSetup.d.ts.map +1 -0
  147. package/channel-app/whatsappAppSetup.js +57 -0
  148. package/channel-app/whatsappAppSetup.js.map +1 -0
  149. package/environment/index.d.ts +2 -0
  150. package/environment/index.d.ts.map +1 -1
  151. package/environment/index.js +1 -0
  152. package/environment/index.js.map +1 -1
  153. package/environment/useToolCredentialsReadiness.d.ts +52 -0
  154. package/environment/useToolCredentialsReadiness.d.ts.map +1 -0
  155. package/environment/useToolCredentialsReadiness.js +84 -0
  156. package/environment/useToolCredentialsReadiness.js.map +1 -0
  157. package/execution/ArtifactContentBody.d.ts.map +1 -1
  158. package/execution/ArtifactContentBody.js +5 -21
  159. package/execution/ArtifactContentBody.js.map +1 -1
  160. package/execution/ArtifactFileContent.d.ts +28 -0
  161. package/execution/ArtifactFileContent.d.ts.map +1 -0
  162. package/execution/ArtifactFileContent.js +36 -0
  163. package/execution/ArtifactFileContent.js.map +1 -0
  164. package/execution/ArtifactRow.d.ts +8 -20
  165. package/execution/ArtifactRow.d.ts.map +1 -1
  166. package/execution/ArtifactRow.js +12 -45
  167. package/execution/ArtifactRow.js.map +1 -1
  168. package/execution/ArtifactRowView.d.ts +43 -0
  169. package/execution/ArtifactRowView.d.ts.map +1 -0
  170. package/execution/ArtifactRowView.js +35 -0
  171. package/execution/ArtifactRowView.js.map +1 -0
  172. package/execution/FileChangesView.d.ts.map +1 -1
  173. package/execution/FileChangesView.js +1 -61
  174. package/execution/FileChangesView.js.map +1 -1
  175. package/execution/SubAgentSection.d.ts.map +1 -1
  176. package/execution/SubAgentSection.js +4 -15
  177. package/execution/SubAgentSection.js.map +1 -1
  178. package/execution/ToolCallItem.d.ts.map +1 -1
  179. package/execution/ToolCallItem.js +16 -61
  180. package/execution/ToolCallItem.js.map +1 -1
  181. package/execution/agent-execution-document.d.ts +31 -0
  182. package/execution/agent-execution-document.d.ts.map +1 -0
  183. package/execution/agent-execution-document.js +48 -0
  184. package/execution/agent-execution-document.js.map +1 -0
  185. package/{session → execution}/artifact-document.d.ts +2 -3
  186. package/execution/artifact-document.d.ts.map +1 -0
  187. package/execution/artifact-document.js +23 -0
  188. package/execution/artifact-document.js.map +1 -0
  189. package/execution/artifact-row-item.d.ts +56 -0
  190. package/execution/artifact-row-item.d.ts.map +1 -0
  191. package/execution/artifact-row-item.js +57 -0
  192. package/execution/artifact-row-item.js.map +1 -0
  193. package/execution/deriveExecutionFileChanges.d.ts +55 -0
  194. package/execution/deriveExecutionFileChanges.d.ts.map +1 -0
  195. package/execution/deriveExecutionFileChanges.js +216 -0
  196. package/execution/deriveExecutionFileChanges.js.map +1 -0
  197. package/execution/file-change-document.d.ts +22 -0
  198. package/execution/file-change-document.d.ts.map +1 -0
  199. package/execution/file-change-document.js +34 -0
  200. package/execution/file-change-document.js.map +1 -0
  201. package/execution/index.d.ts +14 -0
  202. package/execution/index.d.ts.map +1 -1
  203. package/execution/index.js +9 -0
  204. package/execution/index.js.map +1 -1
  205. package/execution/useArtifactContentById.d.ts +61 -0
  206. package/execution/useArtifactContentById.d.ts.map +1 -0
  207. package/execution/useArtifactContentById.js +63 -0
  208. package/execution/useArtifactContentById.js.map +1 -0
  209. package/execution/useArtifactDownload.d.ts +4 -3
  210. package/execution/useArtifactDownload.d.ts.map +1 -1
  211. package/execution/useArtifactDownload.js +4 -3
  212. package/execution/useArtifactDownload.js.map +1 -1
  213. package/execution/useCreateAgentExecution.d.ts +1 -1
  214. package/execution/useLiveAgentExecution.d.ts +59 -0
  215. package/execution/useLiveAgentExecution.d.ts.map +1 -0
  216. package/execution/useLiveAgentExecution.js +73 -0
  217. package/execution/useLiveAgentExecution.js.map +1 -0
  218. package/index.d.ts +15 -10
  219. package/index.d.ts.map +1 -1
  220. package/index.js +21 -6
  221. package/index.js.map +1 -1
  222. package/internal/DecisionButton.d.ts +4 -3
  223. package/internal/DecisionButton.d.ts.map +1 -1
  224. package/internal/DecisionButton.js +4 -3
  225. package/internal/DecisionButton.js.map +1 -1
  226. package/internal/oauthPopup.d.ts +101 -0
  227. package/internal/oauthPopup.d.ts.map +1 -0
  228. package/internal/oauthPopup.js +208 -0
  229. package/internal/oauthPopup.js.map +1 -0
  230. package/internal/store/index.d.ts +0 -2
  231. package/internal/store/index.d.ts.map +1 -1
  232. package/internal/store/index.js +0 -1
  233. package/internal/store/index.js.map +1 -1
  234. package/internal/store/workflow-execution-event-store.d.ts +34 -1
  235. package/internal/store/workflow-execution-event-store.d.ts.map +1 -1
  236. package/internal/store/workflow-execution-event-store.js +81 -3
  237. package/internal/store/workflow-execution-event-store.js.map +1 -1
  238. package/internal/store/workspace-file-selection-store.d.ts +1 -2
  239. package/internal/store/workspace-file-selection-store.d.ts.map +1 -1
  240. package/internal/store/workspace-file-selection-store.js +2 -5
  241. package/internal/store/workspace-file-selection-store.js.map +1 -1
  242. package/internal/thread-card/ThreadCardShell.d.ts +91 -0
  243. package/internal/thread-card/ThreadCardShell.d.ts.map +1 -0
  244. package/internal/thread-card/ThreadCardShell.js +41 -0
  245. package/internal/thread-card/ThreadCardShell.js.map +1 -0
  246. package/internal/thread-card/glyphs.d.ts +34 -0
  247. package/internal/thread-card/glyphs.d.ts.map +1 -0
  248. package/internal/thread-card/glyphs.js +50 -0
  249. package/internal/thread-card/glyphs.js.map +1 -0
  250. package/internal/thread-card/index.d.ts +3 -0
  251. package/internal/thread-card/index.d.ts.map +1 -0
  252. package/internal/thread-card/index.js +3 -0
  253. package/internal/thread-card/index.js.map +1 -0
  254. package/internal/useRevealLine.d.ts +2 -2
  255. package/internal/useRevealLine.js +2 -2
  256. package/mcp-server/OAuthCallbackHandler.js +1 -1
  257. package/mcp-server/OAuthCallbackHandler.js.map +1 -1
  258. package/mcp-server/useMcpServerOAuthConnect.d.ts +4 -23
  259. package/mcp-server/useMcpServerOAuthConnect.d.ts.map +1 -1
  260. package/mcp-server/useMcpServerOAuthConnect.js +12 -145
  261. package/mcp-server/useMcpServerOAuthConnect.js.map +1 -1
  262. package/package.json +4 -4
  263. package/provider.d.ts +32 -0
  264. package/provider.d.ts.map +1 -1
  265. package/provider.js +25 -1
  266. package/provider.js.map +1 -1
  267. package/session/NewSessionViewer.d.ts.map +1 -1
  268. package/session/NewSessionViewer.js +0 -1
  269. package/session/NewSessionViewer.js.map +1 -1
  270. package/session/SessionPanelChip.d.ts +7 -22
  271. package/session/SessionPanelChip.d.ts.map +1 -1
  272. package/session/SessionPanelChip.js +8 -36
  273. package/session/SessionPanelChip.js.map +1 -1
  274. package/session/SessionViewer.d.ts +7 -4
  275. package/session/SessionViewer.d.ts.map +1 -1
  276. package/session/SessionViewer.js +32 -30
  277. package/session/SessionViewer.js.map +1 -1
  278. package/session/audience.d.ts +15 -1
  279. package/session/audience.d.ts.map +1 -1
  280. package/session/channelOrigin.d.ts +33 -0
  281. package/session/channelOrigin.d.ts.map +1 -0
  282. package/session/channelOrigin.js +36 -0
  283. package/session/channelOrigin.js.map +1 -0
  284. package/session/facets/index.d.ts +0 -2
  285. package/session/facets/index.d.ts.map +1 -1
  286. package/session/facets/index.js +0 -1
  287. package/session/facets/index.js.map +1 -1
  288. package/session/index.d.ts +2 -2
  289. package/session/index.d.ts.map +1 -1
  290. package/session/index.js +5 -3
  291. package/session/index.js.map +1 -1
  292. package/session/useSessionFileChanges.d.ts +10 -34
  293. package/session/useSessionFileChanges.d.ts.map +1 -1
  294. package/session/useSessionFileChanges.js +9 -141
  295. package/session/useSessionFileChanges.js.map +1 -1
  296. package/session/useSessionPanel.d.ts +5 -15
  297. package/session/useSessionPanel.d.ts.map +1 -1
  298. package/session/useSessionPanel.js +3 -35
  299. package/session/useSessionPanel.js.map +1 -1
  300. package/session/useSessionRailViews.d.ts +3 -6
  301. package/session/useSessionRailViews.d.ts.map +1 -1
  302. package/session/useSessionRailViews.js +3 -17
  303. package/session/useSessionRailViews.js.map +1 -1
  304. package/settings/ChannelAppsSection.d.ts +13 -0
  305. package/settings/ChannelAppsSection.d.ts.map +1 -0
  306. package/settings/ChannelAppsSection.js +48 -0
  307. package/settings/ChannelAppsSection.js.map +1 -0
  308. package/settings/index.d.ts +1 -0
  309. package/settings/index.d.ts.map +1 -1
  310. package/settings/index.js +1 -0
  311. package/settings/index.js.map +1 -1
  312. package/settings/settings-nav.d.ts.map +1 -1
  313. package/settings/settings-nav.js +6 -1
  314. package/settings/settings-nav.js.map +1 -1
  315. package/sharing/AgentShareList.d.ts.map +1 -1
  316. package/sharing/AgentShareList.js +11 -3
  317. package/sharing/AgentShareList.js.map +1 -1
  318. package/sharing/ShareAgentDialog.js +1 -1
  319. package/sharing/useShareToolReadiness.d.ts +9 -38
  320. package/sharing/useShareToolReadiness.d.ts.map +1 -1
  321. package/sharing/useShareToolReadiness.js +7 -72
  322. package/sharing/useShareToolReadiness.js.map +1 -1
  323. package/src/__tests__/provider-container.layout.test.tsx +165 -0
  324. package/src/__tests__/provider-theme-scope.test.tsx +31 -0
  325. package/src/agent-instance/AgentInstanceList.tsx +60 -42
  326. package/src/agent-instance/__tests__/AgentInstanceList.test.tsx +161 -0
  327. package/src/channel/AgentChannelsPanel.tsx +688 -0
  328. package/src/channel/ChannelConversationsDialog.tsx +267 -0
  329. package/src/channel/ChannelCredentialsDialog.tsx +219 -0
  330. package/src/channel/ChannelToolCredentials.tsx +124 -0
  331. package/src/channel/ConnectSlackDialog.tsx +611 -0
  332. package/src/channel/ConnectWhatsAppDialog.tsx +624 -0
  333. package/src/channel/SlackMarkIcon.tsx +21 -0
  334. package/src/channel/WhatsAppMarkIcon.tsx +22 -0
  335. package/src/channel/__tests__/AgentChannelsPanel.test.tsx +638 -0
  336. package/src/channel/__tests__/ChannelConversationsDialog.test.tsx +114 -0
  337. package/src/channel/__tests__/ChannelCredentialsDialog.test.tsx +240 -0
  338. package/src/channel/__tests__/ConnectSlackDialog.test.tsx +659 -0
  339. package/src/channel/__tests__/ConnectWhatsAppDialog.test.tsx +564 -0
  340. package/src/channel/__tests__/providers.test.ts +118 -0
  341. package/src/channel/__tests__/useAgentChannel.test.tsx +116 -0
  342. package/src/channel/__tests__/useAgentChannelList.test.tsx +166 -0
  343. package/src/channel/__tests__/useChannelSessions.test.tsx +95 -0
  344. package/src/channel/__tests__/useChannelToolReadiness.test.tsx +158 -0
  345. package/src/channel/__tests__/useConnectSlackChannel.test.tsx +276 -0
  346. package/src/channel/__tests__/useDeleteAgentChannel.test.tsx +97 -0
  347. package/src/channel/__tests__/useInstallChannel.test.tsx +177 -0
  348. package/src/channel/__tests__/useSaveAgentChannel.test.tsx +294 -0
  349. package/src/channel/connect/ServingAppSection.tsx +185 -0
  350. package/src/channel/connect/ToolCredentialsSection.tsx +67 -0
  351. package/src/channel/connect/VerbatimRefusal.tsx +27 -0
  352. package/src/channel/connect/icons.tsx +42 -0
  353. package/src/channel/index.ts +65 -0
  354. package/src/channel/providerPresentation.ts +154 -0
  355. package/src/channel/providers.ts +73 -0
  356. package/src/channel/useAgentChannel.ts +58 -0
  357. package/src/channel/useAgentChannelList.ts +69 -0
  358. package/src/channel/useChannelSessions.ts +73 -0
  359. package/src/channel/useChannelToolReadiness.ts +39 -0
  360. package/src/channel/useConnectSlackChannel.ts +195 -0
  361. package/src/channel/useCreateAgentChannel.ts +73 -0
  362. package/src/channel/useDeleteAgentChannel.ts +71 -0
  363. package/src/channel/useInstallChannel.ts +117 -0
  364. package/src/channel/useOrgAgentChannelList.ts +60 -0
  365. package/src/channel/useSaveAgentChannel.ts +133 -0
  366. package/src/channel-app/ChannelAppDetailPanel.tsx +510 -0
  367. package/src/channel-app/ChannelAppListPanel.tsx +201 -0
  368. package/src/channel-app/CreateChannelAppForm.tsx +529 -0
  369. package/src/channel-app/__tests__/channelAppWhatsApp.test.tsx +270 -0
  370. package/src/channel-app/__tests__/slackAppSetup.test.ts +75 -0
  371. package/src/channel-app/__tests__/useChannelAppHooks.test.tsx +157 -0
  372. package/src/channel-app/__tests__/whatsappAppSetup.test.ts +39 -0
  373. package/src/channel-app/index.ts +30 -0
  374. package/src/channel-app/internal.tsx +180 -0
  375. package/src/channel-app/slackAppSetup.ts +153 -0
  376. package/src/channel-app/useChannelAppList.ts +59 -0
  377. package/src/channel-app/useCreateChannelApp.ts +70 -0
  378. package/src/channel-app/useDeleteChannelApp.ts +62 -0
  379. package/src/channel-app/useUpdateChannelApp.ts +70 -0
  380. package/src/channel-app/whatsappAppSetup.ts +62 -0
  381. package/src/environment/index.ts +2 -0
  382. package/src/environment/useToolCredentialsReadiness.ts +122 -0
  383. package/src/execution/ArtifactContentBody.tsx +6 -88
  384. package/src/execution/ArtifactFileContent.tsx +110 -0
  385. package/src/execution/ArtifactRow.tsx +28 -118
  386. package/src/execution/ArtifactRowView.tsx +137 -0
  387. package/src/execution/FileChangesView.tsx +4 -69
  388. package/src/execution/SubAgentSection.tsx +2 -36
  389. package/src/execution/ToolCallItem.tsx +48 -175
  390. package/src/execution/__tests__/ArtifactFileContent.test.tsx +60 -0
  391. package/src/execution/__tests__/ArtifactRowView.test.tsx +78 -0
  392. package/src/execution/__tests__/agent-execution-document.test.ts +45 -0
  393. package/src/execution/__tests__/artifact-row-item.test.ts +128 -0
  394. package/src/execution/__tests__/deriveExecutionFileChanges.test.ts +270 -0
  395. package/src/execution/__tests__/useArtifactContentById.test.tsx +85 -0
  396. package/src/execution/__tests__/useLiveAgentExecution.test.tsx +202 -0
  397. package/src/execution/agent-execution-document.ts +54 -0
  398. package/src/execution/artifact-document.ts +24 -0
  399. package/src/execution/artifact-row-item.ts +97 -0
  400. package/src/execution/deriveExecutionFileChanges.ts +237 -0
  401. package/src/execution/file-change-document.ts +37 -0
  402. package/src/execution/index.ts +36 -0
  403. package/src/execution/useArtifactContentById.ts +120 -0
  404. package/src/execution/useArtifactDownload.ts +4 -3
  405. package/src/execution/useCreateAgentExecution.ts +1 -1
  406. package/src/execution/useLiveAgentExecution.ts +127 -0
  407. package/src/index.ts +155 -11
  408. package/src/internal/DecisionButton.tsx +4 -3
  409. package/src/internal/__tests__/ThreadCardShell.test.tsx +105 -0
  410. package/src/internal/__tests__/oauthPopup.test.ts +245 -0
  411. package/src/internal/oauthPopup.ts +261 -0
  412. package/src/internal/store/__tests__/workflow-execution-event-store.test.ts +375 -5
  413. package/src/internal/store/index.ts +0 -3
  414. package/src/internal/store/workflow-execution-event-store.ts +123 -4
  415. package/src/internal/store/workspace-file-selection-store.ts +2 -5
  416. package/src/internal/thread-card/ThreadCardShell.tsx +189 -0
  417. package/src/internal/thread-card/glyphs.tsx +108 -0
  418. package/src/internal/thread-card/index.ts +19 -0
  419. package/src/internal/useRevealLine.ts +2 -2
  420. package/src/mcp-server/OAuthCallbackHandler.tsx +2 -2
  421. package/src/mcp-server/useMcpServerOAuthConnect.ts +22 -184
  422. package/src/provider.tsx +42 -0
  423. package/src/session/NewSessionViewer.tsx +0 -1
  424. package/src/session/SessionPanelChip.tsx +10 -96
  425. package/src/session/SessionViewer.tsx +170 -144
  426. package/src/session/__tests__/SessionViewer-artifactTabs.test.tsx +1 -1
  427. package/src/session/__tests__/observerAudience.test.tsx +241 -0
  428. package/src/session/__tests__/useSessionPanel.test.ts +6 -61
  429. package/src/session/__tests__/useSessionRailViews.test.tsx +5 -27
  430. package/src/session/audience.ts +15 -1
  431. package/src/session/channelOrigin.ts +45 -0
  432. package/src/session/facets/index.ts +0 -3
  433. package/src/session/index.ts +9 -6
  434. package/src/session/useSessionFileChanges.ts +12 -153
  435. package/src/session/useSessionPanel.ts +8 -51
  436. package/src/session/useSessionRailViews.tsx +2 -27
  437. package/src/settings/ChannelAppsSection.tsx +133 -0
  438. package/src/settings/index.ts +1 -0
  439. package/src/settings/settings-nav.ts +6 -0
  440. package/src/sharing/AgentShareList.tsx +85 -64
  441. package/src/sharing/ShareAgentDialog.tsx +1 -1
  442. package/src/sharing/__tests__/AgentShareList.test.tsx +92 -12
  443. package/src/sharing/useShareToolReadiness.ts +13 -101
  444. package/src/styles.css +14 -0
  445. package/src/workflow/WorkflowAgentExecutionDocument.tsx +283 -0
  446. package/src/workflow/WorkflowApprovalList.tsx +158 -0
  447. package/src/workflow/WorkflowArtifactDocument.tsx +257 -0
  448. package/src/workflow/WorkflowExecutionGraph.tsx +40 -78
  449. package/src/workflow/WorkflowExecutionViewer.tsx +610 -287
  450. package/src/workflow/WorkflowFileReviewList.tsx +1 -1
  451. package/src/workflow/WorkflowTaskApprovalCard.tsx +5 -4
  452. package/src/workflow/WorkflowTaskApprovalSummary.tsx +6 -6
  453. package/src/workflow/__tests__/WorkflowAgentExecutionDocument.test.tsx +651 -0
  454. package/src/workflow/__tests__/WorkflowApprovalList.test.tsx +229 -0
  455. package/src/workflow/__tests__/WorkflowArtifactDocument.test.tsx +90 -0
  456. package/src/workflow/__tests__/WorkflowArtifactsTab.test.tsx +85 -0
  457. package/src/workflow/__tests__/WorkflowChangesTab.test.tsx +113 -0
  458. package/src/workflow/__tests__/WorkflowExecutionViewer.approvals.test.tsx +473 -0
  459. package/src/workflow/__tests__/WorkflowExecutionViewer.reconciliation.test.tsx +632 -0
  460. package/src/workflow/__tests__/WorkflowTaskApprovalSummary.test.tsx +1 -1
  461. package/src/workflow/__tests__/WorkflowTaskThread.test.tsx +947 -0
  462. package/src/workflow/__tests__/WorkflowUsageTab.test.tsx +163 -0
  463. package/src/workflow/__tests__/agent-call-live-experience.test.ts +6 -53
  464. package/src/workflow/__tests__/derive-execution-overlays.test.ts +4 -0
  465. package/src/workflow/__tests__/deriveWorkflowArtifactItems.test.ts +71 -0
  466. package/src/workflow/__tests__/deriveWorkflowUsageItems.test.ts +132 -0
  467. package/src/workflow/__tests__/execution-graph.test.ts +8 -0
  468. package/src/workflow/__tests__/project-thread-items.test.ts +428 -0
  469. package/src/workflow/__tests__/structured-data-viewer.test.tsx +1 -1
  470. package/src/workflow/__tests__/task-approval.test.ts +149 -0
  471. package/src/workflow/__tests__/task-detail-io.test.ts +40 -0
  472. package/src/workflow/__tests__/task-presentation.test.ts +479 -0
  473. package/src/workflow/__tests__/useActiveTaskName.test.ts +4 -0
  474. package/src/workflow/__tests__/useApprovalBoundary.test.ts +158 -0
  475. package/src/workflow/__tests__/useExecutionAnnouncements.test.ts +4 -0
  476. package/src/workflow/__tests__/useFollowExecution.test.ts +2 -89
  477. package/src/workflow/__tests__/useWorkflowExecutionFileChanges.test.tsx +412 -0
  478. package/src/workflow/__tests__/useWorkflowExecutionPanel.test.ts +297 -0
  479. package/src/workflow/__tests__/useWorkflowExecutionRailViews.test.tsx +115 -0
  480. package/src/workflow/deriveWorkflowArtifactItems.ts +59 -0
  481. package/src/workflow/deriveWorkflowUsageItems.ts +73 -0
  482. package/src/workflow/diagnosis-document.ts +31 -0
  483. package/src/workflow/execution/index.ts +0 -15
  484. package/src/workflow/facets/WorkflowArtifactsTab.tsx +99 -0
  485. package/src/workflow/facets/WorkflowChangesTab.tsx +129 -0
  486. package/src/workflow/facets/WorkflowUsageTab.tsx +258 -0
  487. package/src/workflow/format-utils.ts +2 -3
  488. package/src/workflow/index.ts +106 -62
  489. package/src/workflow/inspector/index.ts +0 -4
  490. package/src/workflow/instance/WorkflowInstanceList.tsx +59 -41
  491. package/src/workflow/instance/__tests__/WorkflowInstanceList.test.tsx +156 -0
  492. package/src/workflow/task-detail/index.ts +11 -0
  493. package/src/workflow/task-detail/task-approval.ts +158 -0
  494. package/src/workflow/task-detail/task-detail-io.ts +65 -0
  495. package/src/workflow/thread/WorkflowTaskThread.tsx +845 -0
  496. package/src/workflow/thread/project-thread-items.ts +235 -0
  497. package/src/workflow/thread/task-presentation.ts +427 -0
  498. package/src/workflow/thread/thread-presentation.ts +59 -0
  499. package/src/workflow/thread/useWorkflowThreadItems.ts +34 -0
  500. package/src/workflow/useApprovalBoundary.ts +72 -0
  501. package/src/workflow/useFollowExecution.ts +0 -26
  502. package/src/workflow/useWorkflowArtifactDownload.ts +68 -0
  503. package/src/workflow/useWorkflowExecutionActions.ts +3 -2
  504. package/src/workflow/useWorkflowExecutionFileChanges.ts +341 -0
  505. package/src/workflow/useWorkflowExecutionGraph.ts +3 -43
  506. package/src/workflow/useWorkflowExecutionPanel.ts +292 -0
  507. package/src/workflow/useWorkflowExecutionRailViews.tsx +173 -0
  508. package/src/workspace/FileViewer.tsx +3 -3
  509. package/src/workspace/PanelChip.tsx +103 -0
  510. package/src/workspace/WorkspaceSurface.tsx +50 -6
  511. package/src/workspace/__tests__/WorkspaceSurface.test.tsx +110 -0
  512. package/src/workspace/index.ts +3 -0
  513. package/styles.css +1 -1
  514. package/workflow/WorkflowAgentExecutionDocument.d.ts +79 -0
  515. package/workflow/WorkflowAgentExecutionDocument.d.ts.map +1 -0
  516. package/workflow/WorkflowAgentExecutionDocument.js +87 -0
  517. package/workflow/WorkflowAgentExecutionDocument.js.map +1 -0
  518. package/workflow/WorkflowApprovalList.d.ts +62 -0
  519. package/workflow/WorkflowApprovalList.d.ts.map +1 -0
  520. package/workflow/WorkflowApprovalList.js +52 -0
  521. package/workflow/WorkflowApprovalList.js.map +1 -0
  522. package/workflow/WorkflowArtifactDocument.d.ts +29 -0
  523. package/workflow/WorkflowArtifactDocument.d.ts.map +1 -0
  524. package/workflow/WorkflowArtifactDocument.js +89 -0
  525. package/workflow/WorkflowArtifactDocument.js.map +1 -0
  526. package/workflow/WorkflowExecutionGraph.d.ts +15 -13
  527. package/workflow/WorkflowExecutionGraph.d.ts.map +1 -1
  528. package/workflow/WorkflowExecutionGraph.js +18 -53
  529. package/workflow/WorkflowExecutionGraph.js.map +1 -1
  530. package/workflow/WorkflowExecutionViewer.d.ts +8 -5
  531. package/workflow/WorkflowExecutionViewer.d.ts.map +1 -1
  532. package/workflow/WorkflowExecutionViewer.js +329 -54
  533. package/workflow/WorkflowExecutionViewer.js.map +1 -1
  534. package/workflow/WorkflowFileReviewList.d.ts +1 -1
  535. package/workflow/WorkflowFileReviewList.js +1 -1
  536. package/workflow/WorkflowTaskApprovalCard.d.ts +4 -3
  537. package/workflow/WorkflowTaskApprovalCard.d.ts.map +1 -1
  538. package/workflow/WorkflowTaskApprovalCard.js +5 -4
  539. package/workflow/WorkflowTaskApprovalCard.js.map +1 -1
  540. package/workflow/WorkflowTaskApprovalSummary.d.ts +6 -6
  541. package/workflow/WorkflowTaskApprovalSummary.js +5 -5
  542. package/workflow/deriveWorkflowArtifactItems.d.ts +30 -0
  543. package/workflow/deriveWorkflowArtifactItems.d.ts.map +1 -0
  544. package/workflow/deriveWorkflowArtifactItems.js +38 -0
  545. package/workflow/deriveWorkflowArtifactItems.js.map +1 -0
  546. package/workflow/deriveWorkflowUsageItems.d.ts +36 -0
  547. package/workflow/deriveWorkflowUsageItems.d.ts.map +1 -0
  548. package/workflow/deriveWorkflowUsageItems.js +50 -0
  549. package/workflow/deriveWorkflowUsageItems.js.map +1 -0
  550. package/workflow/diagnosis-document.d.ts +17 -0
  551. package/workflow/diagnosis-document.d.ts.map +1 -0
  552. package/workflow/diagnosis-document.js +29 -0
  553. package/workflow/diagnosis-document.js.map +1 -0
  554. package/workflow/execution/index.d.ts +0 -2
  555. package/workflow/execution/index.d.ts.map +1 -1
  556. package/workflow/execution/index.js +0 -2
  557. package/workflow/execution/index.js.map +1 -1
  558. package/workflow/facets/WorkflowArtifactsTab.d.ts +26 -0
  559. package/workflow/facets/WorkflowArtifactsTab.d.ts.map +1 -0
  560. package/workflow/facets/WorkflowArtifactsTab.js +34 -0
  561. package/workflow/facets/WorkflowArtifactsTab.js.map +1 -0
  562. package/workflow/facets/WorkflowChangesTab.d.ts +37 -0
  563. package/workflow/facets/WorkflowChangesTab.d.ts.map +1 -0
  564. package/workflow/facets/WorkflowChangesTab.js +50 -0
  565. package/workflow/facets/WorkflowChangesTab.js.map +1 -0
  566. package/workflow/facets/WorkflowUsageTab.d.ts +27 -0
  567. package/workflow/facets/WorkflowUsageTab.d.ts.map +1 -0
  568. package/workflow/facets/WorkflowUsageTab.js +87 -0
  569. package/workflow/facets/WorkflowUsageTab.js.map +1 -0
  570. package/workflow/format-utils.d.ts +2 -3
  571. package/workflow/format-utils.d.ts.map +1 -1
  572. package/workflow/format-utils.js +2 -3
  573. package/workflow/format-utils.js.map +1 -1
  574. package/workflow/index.d.ts +21 -10
  575. package/workflow/index.d.ts.map +1 -1
  576. package/workflow/index.js +29 -14
  577. package/workflow/index.js.map +1 -1
  578. package/workflow/inspector/index.d.ts +0 -2
  579. package/workflow/inspector/index.d.ts.map +1 -1
  580. package/workflow/inspector/index.js +0 -2
  581. package/workflow/inspector/index.js.map +1 -1
  582. package/workflow/instance/WorkflowInstanceList.d.ts.map +1 -1
  583. package/workflow/instance/WorkflowInstanceList.js +11 -3
  584. package/workflow/instance/WorkflowInstanceList.js.map +1 -1
  585. package/workflow/task-detail/StructuredDataViewer.d.ts.map +1 -0
  586. package/workflow/task-detail/StructuredDataViewer.js.map +1 -0
  587. package/workflow/task-detail/index.d.ts +4 -0
  588. package/workflow/task-detail/index.d.ts.map +1 -0
  589. package/workflow/task-detail/index.js +4 -0
  590. package/workflow/task-detail/index.js.map +1 -0
  591. package/workflow/task-detail/task-approval.d.ts +89 -0
  592. package/workflow/task-detail/task-approval.d.ts.map +1 -0
  593. package/workflow/task-detail/task-approval.js +84 -0
  594. package/workflow/task-detail/task-approval.js.map +1 -0
  595. package/workflow/task-detail/task-detail-io.d.ts +39 -0
  596. package/workflow/task-detail/task-detail-io.d.ts.map +1 -0
  597. package/workflow/task-detail/task-detail-io.js +42 -0
  598. package/workflow/task-detail/task-detail-io.js.map +1 -0
  599. package/workflow/thread/WorkflowTaskThread.d.ts +91 -0
  600. package/workflow/thread/WorkflowTaskThread.d.ts.map +1 -0
  601. package/workflow/thread/WorkflowTaskThread.js +318 -0
  602. package/workflow/thread/WorkflowTaskThread.js.map +1 -0
  603. package/workflow/thread/project-thread-items.d.ts +108 -0
  604. package/workflow/thread/project-thread-items.d.ts.map +1 -0
  605. package/workflow/thread/project-thread-items.js +126 -0
  606. package/workflow/thread/project-thread-items.js.map +1 -0
  607. package/workflow/thread/task-presentation.d.ts +73 -0
  608. package/workflow/thread/task-presentation.d.ts.map +1 -0
  609. package/workflow/thread/task-presentation.js +331 -0
  610. package/workflow/thread/task-presentation.js.map +1 -0
  611. package/workflow/thread/thread-presentation.d.ts +28 -0
  612. package/workflow/thread/thread-presentation.d.ts.map +1 -0
  613. package/workflow/thread/thread-presentation.js +28 -0
  614. package/workflow/thread/thread-presentation.js.map +1 -0
  615. package/workflow/thread/useWorkflowThreadItems.d.ts +16 -0
  616. package/workflow/thread/useWorkflowThreadItems.d.ts.map +1 -0
  617. package/workflow/thread/useWorkflowThreadItems.js +22 -0
  618. package/workflow/thread/useWorkflowThreadItems.js.map +1 -0
  619. package/workflow/useApprovalBoundary.d.ts +38 -0
  620. package/workflow/useApprovalBoundary.d.ts.map +1 -0
  621. package/workflow/useApprovalBoundary.js +55 -0
  622. package/workflow/useApprovalBoundary.js.map +1 -0
  623. package/workflow/useFollowExecution.d.ts +0 -20
  624. package/workflow/useFollowExecution.d.ts.map +1 -1
  625. package/workflow/useFollowExecution.js +0 -17
  626. package/workflow/useFollowExecution.js.map +1 -1
  627. package/workflow/useWorkflowArtifactDownload.d.ts +28 -0
  628. package/workflow/useWorkflowArtifactDownload.d.ts.map +1 -0
  629. package/workflow/useWorkflowArtifactDownload.js +45 -0
  630. package/workflow/useWorkflowArtifactDownload.js.map +1 -0
  631. package/workflow/useWorkflowExecutionActions.d.ts +3 -2
  632. package/workflow/useWorkflowExecutionActions.d.ts.map +1 -1
  633. package/workflow/useWorkflowExecutionActions.js.map +1 -1
  634. package/workflow/useWorkflowExecutionFileChanges.d.ts +107 -0
  635. package/workflow/useWorkflowExecutionFileChanges.d.ts.map +1 -0
  636. package/workflow/useWorkflowExecutionFileChanges.js +244 -0
  637. package/workflow/useWorkflowExecutionFileChanges.js.map +1 -0
  638. package/workflow/useWorkflowExecutionGraph.d.ts +1 -14
  639. package/workflow/useWorkflowExecutionGraph.d.ts.map +1 -1
  640. package/workflow/useWorkflowExecutionGraph.js +2 -25
  641. package/workflow/useWorkflowExecutionGraph.js.map +1 -1
  642. package/workflow/useWorkflowExecutionPanel.d.ts +108 -0
  643. package/workflow/useWorkflowExecutionPanel.d.ts.map +1 -0
  644. package/workflow/useWorkflowExecutionPanel.js +103 -0
  645. package/workflow/useWorkflowExecutionPanel.js.map +1 -0
  646. package/workflow/useWorkflowExecutionRailViews.d.ts +46 -0
  647. package/workflow/useWorkflowExecutionRailViews.d.ts.map +1 -0
  648. package/workflow/useWorkflowExecutionRailViews.js +81 -0
  649. package/workflow/useWorkflowExecutionRailViews.js.map +1 -0
  650. package/workspace/FileViewer.d.ts +1 -1
  651. package/workspace/FileViewer.js +3 -3
  652. package/workspace/FileViewer.js.map +1 -1
  653. package/workspace/PanelChip.d.ts +27 -0
  654. package/workspace/PanelChip.d.ts.map +1 -0
  655. package/workspace/PanelChip.js +42 -0
  656. package/workspace/PanelChip.js.map +1 -0
  657. package/workspace/WorkspaceSurface.d.ts +25 -1
  658. package/workspace/WorkspaceSurface.d.ts.map +1 -1
  659. package/workspace/WorkspaceSurface.js +21 -9
  660. package/workspace/WorkspaceSurface.js.map +1 -1
  661. package/workspace/index.d.ts +3 -1
  662. package/workspace/index.d.ts.map +1 -1
  663. package/workspace/index.js +1 -0
  664. package/workspace/index.js.map +1 -1
  665. package/execution/ThreadSelectionContext.d.ts +0 -17
  666. package/execution/ThreadSelectionContext.d.ts.map +0 -1
  667. package/execution/ThreadSelectionContext.js +0 -18
  668. package/execution/ThreadSelectionContext.js.map +0 -1
  669. package/execution/useThreadSelection.d.ts +0 -35
  670. package/execution/useThreadSelection.d.ts.map +0 -1
  671. package/execution/useThreadSelection.js +0 -65
  672. package/execution/useThreadSelection.js.map +0 -1
  673. package/internal/store/selection-store.d.ts +0 -53
  674. package/internal/store/selection-store.d.ts.map +0 -1
  675. package/internal/store/selection-store.js +0 -88
  676. package/internal/store/selection-store.js.map +0 -1
  677. package/session/artifact-document.d.ts.map +0 -1
  678. package/session/artifact-document.js +0 -22
  679. package/session/artifact-document.js.map +0 -1
  680. package/session/facets/InspectTab.d.ts +0 -13
  681. package/session/facets/InspectTab.d.ts.map +0 -1
  682. package/session/facets/InspectTab.js +0 -19
  683. package/session/facets/InspectTab.js.map +0 -1
  684. package/src/execution/ThreadSelectionContext.tsx +0 -20
  685. package/src/execution/useThreadSelection.ts +0 -95
  686. package/src/internal/store/__tests__/selection-store.test.ts +0 -115
  687. package/src/internal/store/selection-store.ts +0 -112
  688. package/src/session/artifact-document.ts +0 -23
  689. package/src/session/facets/InspectTab.tsx +0 -57
  690. package/src/workflow/WorkflowExecutionApprovalCard.tsx +0 -154
  691. package/src/workflow/WorkflowExecutionArtifactPanel.tsx +0 -107
  692. package/src/workflow/WorkflowExecutionCostPanel.tsx +0 -120
  693. package/src/workflow/WorkflowExecutionTaskPanel.tsx +0 -129
  694. package/src/workflow/WorkflowExecutionTimeline.tsx +0 -151
  695. package/src/workflow/WorkflowExecutionTimelineEvent.tsx +0 -497
  696. package/src/workflow/__tests__/ExecutionInspector.test.tsx +0 -155
  697. package/src/workflow/__tests__/WorkflowExecutionApprovalCard.test.tsx +0 -129
  698. package/src/workflow/__tests__/derive-task-detail.test.ts +0 -1265
  699. package/src/workflow/__tests__/derive-waterfall-entries.test.ts +0 -521
  700. package/src/workflow/__tests__/execution-inspector.test.tsx +0 -332
  701. package/src/workflow/execution/derive-waterfall-entries.ts +0 -377
  702. package/src/workflow/execution/useWaterfallEntries.ts +0 -125
  703. package/src/workflow/execution-inspector/AgentCallTab.tsx +0 -169
  704. package/src/workflow/execution-inspector/ErrorTab.tsx +0 -110
  705. package/src/workflow/execution-inspector/EventLogTab.tsx +0 -79
  706. package/src/workflow/execution-inspector/ExecutionInspector.tsx +0 -341
  707. package/src/workflow/execution-inspector/InputOutputTab.tsx +0 -325
  708. package/src/workflow/execution-inspector/RetriesTab.tsx +0 -68
  709. package/src/workflow/execution-inspector/SummaryTab.tsx +0 -62
  710. package/src/workflow/execution-inspector/derive-task-detail.ts +0 -584
  711. package/src/workflow/execution-inspector/index.ts +0 -14
  712. package/src/workflow/execution-inspector/useExecutionTaskDetail.ts +0 -55
  713. package/src/workflow/inspector/ExecutionInspectorAdapter.tsx +0 -40
  714. package/src/workflow/waterfall/WaterfallBar.tsx +0 -167
  715. package/src/workflow/waterfall/WaterfallRow.tsx +0 -112
  716. package/src/workflow/waterfall/WaterfallScale.tsx +0 -52
  717. package/src/workflow/waterfall/WaterfallTimeline.tsx +0 -138
  718. package/src/workflow/waterfall/WaterfallTooltip.tsx +0 -74
  719. package/src/workflow/waterfall/index.ts +0 -5
  720. package/workflow/WorkflowExecutionApprovalCard.d.ts +0 -34
  721. package/workflow/WorkflowExecutionApprovalCard.d.ts.map +0 -1
  722. package/workflow/WorkflowExecutionApprovalCard.js +0 -46
  723. package/workflow/WorkflowExecutionApprovalCard.js.map +0 -1
  724. package/workflow/WorkflowExecutionArtifactPanel.d.ts +0 -15
  725. package/workflow/WorkflowExecutionArtifactPanel.d.ts.map +0 -1
  726. package/workflow/WorkflowExecutionArtifactPanel.js +0 -46
  727. package/workflow/WorkflowExecutionArtifactPanel.js.map +0 -1
  728. package/workflow/WorkflowExecutionCostPanel.d.ts +0 -18
  729. package/workflow/WorkflowExecutionCostPanel.d.ts.map +0 -1
  730. package/workflow/WorkflowExecutionCostPanel.js +0 -31
  731. package/workflow/WorkflowExecutionCostPanel.js.map +0 -1
  732. package/workflow/WorkflowExecutionTaskPanel.d.ts +0 -24
  733. package/workflow/WorkflowExecutionTaskPanel.d.ts.map +0 -1
  734. package/workflow/WorkflowExecutionTaskPanel.js +0 -51
  735. package/workflow/WorkflowExecutionTaskPanel.js.map +0 -1
  736. package/workflow/WorkflowExecutionTimeline.d.ts +0 -42
  737. package/workflow/WorkflowExecutionTimeline.d.ts.map +0 -1
  738. package/workflow/WorkflowExecutionTimeline.js +0 -52
  739. package/workflow/WorkflowExecutionTimeline.js.map +0 -1
  740. package/workflow/WorkflowExecutionTimelineEvent.d.ts +0 -25
  741. package/workflow/WorkflowExecutionTimelineEvent.d.ts.map +0 -1
  742. package/workflow/WorkflowExecutionTimelineEvent.js +0 -179
  743. package/workflow/WorkflowExecutionTimelineEvent.js.map +0 -1
  744. package/workflow/execution/derive-waterfall-entries.d.ts +0 -85
  745. package/workflow/execution/derive-waterfall-entries.d.ts.map +0 -1
  746. package/workflow/execution/derive-waterfall-entries.js +0 -268
  747. package/workflow/execution/derive-waterfall-entries.js.map +0 -1
  748. package/workflow/execution/useWaterfallEntries.d.ts +0 -25
  749. package/workflow/execution/useWaterfallEntries.d.ts.map +0 -1
  750. package/workflow/execution/useWaterfallEntries.js +0 -67
  751. package/workflow/execution/useWaterfallEntries.js.map +0 -1
  752. package/workflow/execution-inspector/AgentCallTab.d.ts +0 -21
  753. package/workflow/execution-inspector/AgentCallTab.d.ts.map +0 -1
  754. package/workflow/execution-inspector/AgentCallTab.js +0 -36
  755. package/workflow/execution-inspector/AgentCallTab.js.map +0 -1
  756. package/workflow/execution-inspector/ErrorTab.d.ts +0 -9
  757. package/workflow/execution-inspector/ErrorTab.d.ts.map +0 -1
  758. package/workflow/execution-inspector/ErrorTab.js +0 -29
  759. package/workflow/execution-inspector/ErrorTab.js.map +0 -1
  760. package/workflow/execution-inspector/EventLogTab.d.ts +0 -11
  761. package/workflow/execution-inspector/EventLogTab.d.ts.map +0 -1
  762. package/workflow/execution-inspector/EventLogTab.js +0 -47
  763. package/workflow/execution-inspector/EventLogTab.js.map +0 -1
  764. package/workflow/execution-inspector/ExecutionInspector.d.ts +0 -69
  765. package/workflow/execution-inspector/ExecutionInspector.d.ts.map +0 -1
  766. package/workflow/execution-inspector/ExecutionInspector.js +0 -145
  767. package/workflow/execution-inspector/ExecutionInspector.js.map +0 -1
  768. package/workflow/execution-inspector/InputOutputTab.d.ts +0 -20
  769. package/workflow/execution-inspector/InputOutputTab.d.ts.map +0 -1
  770. package/workflow/execution-inspector/InputOutputTab.js +0 -124
  771. package/workflow/execution-inspector/InputOutputTab.js.map +0 -1
  772. package/workflow/execution-inspector/RetriesTab.d.ts +0 -7
  773. package/workflow/execution-inspector/RetriesTab.d.ts.map +0 -1
  774. package/workflow/execution-inspector/RetriesTab.js +0 -11
  775. package/workflow/execution-inspector/RetriesTab.js.map +0 -1
  776. package/workflow/execution-inspector/StructuredDataViewer.d.ts.map +0 -1
  777. package/workflow/execution-inspector/StructuredDataViewer.js.map +0 -1
  778. package/workflow/execution-inspector/SummaryTab.d.ts +0 -7
  779. package/workflow/execution-inspector/SummaryTab.d.ts.map +0 -1
  780. package/workflow/execution-inspector/SummaryTab.js +0 -10
  781. package/workflow/execution-inspector/SummaryTab.js.map +0 -1
  782. package/workflow/execution-inspector/derive-task-detail.d.ts +0 -140
  783. package/workflow/execution-inspector/derive-task-detail.d.ts.map +0 -1
  784. package/workflow/execution-inspector/derive-task-detail.js +0 -366
  785. package/workflow/execution-inspector/derive-task-detail.js.map +0 -1
  786. package/workflow/execution-inspector/index.d.ts +0 -4
  787. package/workflow/execution-inspector/index.d.ts.map +0 -1
  788. package/workflow/execution-inspector/index.js +0 -4
  789. package/workflow/execution-inspector/index.js.map +0 -1
  790. package/workflow/execution-inspector/useExecutionTaskDetail.d.ts +0 -38
  791. package/workflow/execution-inspector/useExecutionTaskDetail.d.ts.map +0 -1
  792. package/workflow/execution-inspector/useExecutionTaskDetail.js +0 -37
  793. package/workflow/execution-inspector/useExecutionTaskDetail.js.map +0 -1
  794. package/workflow/inspector/ExecutionInspectorAdapter.d.ts +0 -26
  795. package/workflow/inspector/ExecutionInspectorAdapter.d.ts.map +0 -1
  796. package/workflow/inspector/ExecutionInspectorAdapter.js +0 -23
  797. package/workflow/inspector/ExecutionInspectorAdapter.js.map +0 -1
  798. package/workflow/waterfall/WaterfallBar.d.ts +0 -19
  799. package/workflow/waterfall/WaterfallBar.d.ts.map +0 -1
  800. package/workflow/waterfall/WaterfallBar.js +0 -70
  801. package/workflow/waterfall/WaterfallBar.js.map +0 -1
  802. package/workflow/waterfall/WaterfallRow.d.ts +0 -18
  803. package/workflow/waterfall/WaterfallRow.d.ts.map +0 -1
  804. package/workflow/waterfall/WaterfallRow.js +0 -45
  805. package/workflow/waterfall/WaterfallRow.js.map +0 -1
  806. package/workflow/waterfall/WaterfallScale.d.ts +0 -14
  807. package/workflow/waterfall/WaterfallScale.d.ts.map +0 -1
  808. package/workflow/waterfall/WaterfallScale.js +0 -22
  809. package/workflow/waterfall/WaterfallScale.js.map +0 -1
  810. package/workflow/waterfall/WaterfallTimeline.d.ts +0 -46
  811. package/workflow/waterfall/WaterfallTimeline.d.ts.map +0 -1
  812. package/workflow/waterfall/WaterfallTimeline.js +0 -60
  813. package/workflow/waterfall/WaterfallTimeline.js.map +0 -1
  814. package/workflow/waterfall/WaterfallTooltip.d.ts +0 -15
  815. package/workflow/waterfall/WaterfallTooltip.d.ts.map +0 -1
  816. package/workflow/waterfall/WaterfallTooltip.js +0 -20
  817. package/workflow/waterfall/WaterfallTooltip.js.map +0 -1
  818. package/workflow/waterfall/index.d.ts +0 -6
  819. package/workflow/waterfall/index.d.ts.map +0 -1
  820. package/workflow/waterfall/index.js +0 -6
  821. package/workflow/waterfall/index.js.map +0 -1
  822. /package/src/workflow/{execution-inspector → task-detail}/StructuredDataViewer.tsx +0 -0
  823. /package/workflow/{execution-inspector → task-detail}/StructuredDataViewer.d.ts +0 -0
  824. /package/workflow/{execution-inspector → task-detail}/StructuredDataViewer.js +0 -0
@@ -0,0 +1,238 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useCallback, useMemo, useRef, useState } from "react";
4
+ import { cn } from "@stigmer/theme";
5
+ import { getErrorReason } from "@stigmer/sdk";
6
+ import { AgentChannelInstallState } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/status_pb";
7
+ import { Button } from "../button/Button.js";
8
+ import { useChannelAppList } from "../channel-app/useChannelAppList.js";
9
+ import { useDeploymentMode } from "../deployment-mode.js";
10
+ import { CloudFeatureNotice } from "../internal/CloudFeatureNotice.js";
11
+ import { RegisterChannelAppAffordance, ServingAppSection, } from "./connect/ServingAppSection.js";
12
+ import { ToolCredentialsSection } from "./connect/ToolCredentialsSection.js";
13
+ import { RefusalBox, VerbatimRefusal } from "./connect/VerbatimRefusal.js";
14
+ import { CheckIcon, CloseIcon, Spinner } from "./connect/icons.js";
15
+ import { useConnectSlackChannel } from "./useConnectSlackChannel.js";
16
+ import { useCreateAgentChannel } from "./useCreateAgentChannel.js";
17
+ import { useOrgAgentChannelList } from "./useOrgAgentChannelList.js";
18
+ import { SlackMarkIcon } from "./SlackMarkIcon.js";
19
+ /**
20
+ * The connect flow for a Slack channel: create the {@link AgentChannel}
21
+ * (create mode), then run the "Add to Slack" OAuth install in a popup
22
+ * and report progress phase by phase.
23
+ *
24
+ * Requires a deployment with platform Slack app credentials — on a
25
+ * `local` (OSS) backend the flow is preempted with a cloud-feature
26
+ * notice, matching the server's FAILED_PRECONDITION refusal. Install
27
+ * refusals (unconfigured deployment, duplicate workspace, Enterprise
28
+ * Grid) render the server's copy verbatim — the server owns that
29
+ * vocabulary.
30
+ *
31
+ * Built on the native `<dialog>` element for focus trapping and escape
32
+ * handling, matching the SDK's modal convention ({@link ShareAgentDialog}).
33
+ * All visual properties flow through `--stgm-*` design tokens.
34
+ *
35
+ * Most hosts mount it via {@link AgentChannelsPanel} (the Channels tab).
36
+ * Render it directly only when you own the open-state.
37
+ */
38
+ export function ConnectSlackDialog({ open, onOpenChange, agent, channel, onChannelsChanged, modal = true, channelAppsHref, }) {
39
+ const dialogRef = useRef(null);
40
+ const handleClose = useCallback(() => {
41
+ dialogRef.current?.close();
42
+ onOpenChange(false);
43
+ }, [onOpenChange]);
44
+ // Sync native dialog open state (matches the SDK dialog convention).
45
+ // Non-modal hosts pass `open` as a plain attribute instead — the dialog
46
+ // renders in-flow with no top layer to manage.
47
+ const prevOpenRef = useRef(false);
48
+ if (modal && open !== prevOpenRef.current) {
49
+ prevOpenRef.current = open;
50
+ if (open) {
51
+ requestAnimationFrame(() => {
52
+ if (dialogRef.current && !dialogRef.current.open) {
53
+ dialogRef.current.showModal();
54
+ }
55
+ });
56
+ }
57
+ else if (dialogRef.current?.open) {
58
+ dialogRef.current.close();
59
+ }
60
+ }
61
+ return (_jsx("dialog", { ref: dialogRef, open: modal ? undefined : open, onClose: handleClose, className: cn("w-full max-w-md rounded-xl border border-border bg-popover p-0 shadow-xl", modal ? "fixed inset-0 m-auto backdrop:bg-black/50" : "relative"), "aria-labelledby": "connect-slack-title", children: open && (_jsx(ConnectSlackDialogBody, { agent: agent, channel: channel ?? null, onChannelsChanged: onChannelsChanged, onClose: handleClose, channelAppsHref: channelAppsHref })) }));
62
+ }
63
+ function ConnectSlackDialogBody({ agent, channel, onChannelsChanged, onClose, channelAppsHref, }) {
64
+ const deploymentMode = useDeploymentMode();
65
+ const agentName = agent.metadata?.name || agent.metadata?.slug || "this agent";
66
+ const org = agent.metadata?.org ?? "";
67
+ const { createChannel, isPending: isCreating } = useCreateAgentChannel();
68
+ const slack = useConnectSlackChannel();
69
+ const [name, setName] = useState(() => channel ? (channel.metadata?.name ?? "") : `${agentName} Slack`);
70
+ // Tool credentials bound at connect time (create mode only — a
71
+ // reconnect keeps the channel's existing bindings untouched; edits go
72
+ // through the channel card's credentials dialog).
73
+ const [environmentRefs, setEnvironmentRefs] = useState([]);
74
+ // The serving app (create mode only): null = the platform Stigmer app;
75
+ // a ref = one of the org's own channel apps (BYO — the bot carries that
76
+ // app's name, and each app is its own bot identity). A reconnect keeps
77
+ // the channel's existing binding — an installed channel's app_ref is
78
+ // frozen server-side.
79
+ const [appRef, setAppRef] = useState(null);
80
+ const [installed, setInstalled] = useState(null);
81
+ const [error, setError] = useState(null);
82
+ // The org's channel apps, fetched once here so the serving-app picker,
83
+ // the addressing copy, and the advisory all read one consistent list.
84
+ const { channelApps } = useChannelAppList(org || null);
85
+ const slackApps = useMemo(() => channelApps.filter((app) => app.spec?.providerConfig?.case === "slack"), [channelApps]);
86
+ // The app the install will (or did) go through: the picker's choice in
87
+ // create mode, the frozen spec.app_ref on a reconnect. null = platform.
88
+ const effectiveAppRef = channel
89
+ ? channel.spec?.appRef?.slug
90
+ ? { org: channel.spec.appRef.org || org, slug: channel.spec.appRef.slug }
91
+ : null
92
+ : appRef;
93
+ const selectedApp = effectiveAppRef
94
+ ? slackApps.find((app) => app.metadata?.slug === effectiveAppRef.slug) ?? null
95
+ : null;
96
+ // What members type after "@" in Slack. App-level, not agent-level: the
97
+ // platform app's bot is "Stigmer"; a BYO app's bot carries the name its
98
+ // manifest declared — which the registration form seeded from the
99
+ // ChannelApp's own name.
100
+ const botName = effectiveAppRef
101
+ ? selectedApp?.metadata?.name || effectiveAppRef.slug
102
+ : "Stigmer";
103
+ // Workspaces the selected serving app already occupies, matched on the
104
+ // same key the database enforces uniqueness on: (team, channel app).
105
+ // Advisory only — the list is permission-bounded, and other orgs'
106
+ // holds are invisible; completeInstall stays the arbiter.
107
+ const advisoryActive = deploymentMode === "cloud" && !channel && !installed;
108
+ const { channels: orgChannels } = useOrgAgentChannelList(advisoryActive && org ? org : null);
109
+ const alreadyServed = useMemo(() => {
110
+ // Platform app installs stamp an empty channel_app_id.
111
+ const selectedAppId = effectiveAppRef ? selectedApp?.metadata?.id : "";
112
+ if (selectedAppId === undefined)
113
+ return [];
114
+ return orgChannels.filter((c) => c.status?.installState === AgentChannelInstallState.installed &&
115
+ c.status?.providerStatus?.case === "slack" &&
116
+ c.status.providerStatus.value.channelAppId === selectedAppId);
117
+ }, [orgChannels, effectiveAppRef, selectedApp]);
118
+ // One click drives the whole journey: (create →) initiate → popup →
119
+ // complete. It must stay a single synchronous entry point — the popup
120
+ // opens inside connect(), and browsers only allow that from a
121
+ // user-gesture call stack.
122
+ const handleConnect = useCallback(async () => {
123
+ setError(null);
124
+ try {
125
+ let target = channel;
126
+ if (!target) {
127
+ target = await createChannel({
128
+ name: name.trim() || `${agentName} Slack`,
129
+ org,
130
+ agentRef: {
131
+ org,
132
+ slug: agent.metadata?.slug ?? "",
133
+ },
134
+ enabled: true,
135
+ slack: {},
136
+ ...(appRef ? { appRef } : {}),
137
+ ...(environmentRefs.length > 0 ? { environmentRefs } : {}),
138
+ });
139
+ // The channel now exists even if the install below fails or is
140
+ // abandoned — surface it in the list either way.
141
+ onChannelsChanged?.();
142
+ }
143
+ const result = await slack.connect(target.metadata?.id ?? "");
144
+ setInstalled(result);
145
+ onChannelsChanged?.();
146
+ }
147
+ catch (err) {
148
+ // Cancellation is a user decision, not a failure — the hook keeps
149
+ // error null for it; everything else renders below.
150
+ setError(slack.error ?? (err instanceof Error ? err : new Error(String(err))));
151
+ }
152
+ }, [agent, agentName, appRef, channel, createChannel, environmentRefs, name, org, onChannelsChanged, slack]);
153
+ const handleCancel = useCallback(() => {
154
+ slack.clearError();
155
+ setError(null);
156
+ }, [slack]);
157
+ const busy = isCreating || slack.isInProgress;
158
+ return (_jsxs("div", { className: "flex flex-col", children: [_jsxs("div", { className: "flex items-start justify-between gap-3 border-b border-border px-5 py-4", children: [_jsxs("div", { className: "flex items-center gap-2.5", children: [_jsx(SlackMarkIcon, { className: "size-5 text-foreground" }), _jsx("h2", { id: "connect-slack-title", className: "text-sm font-semibold text-foreground", children: channel ? "Reconnect to Slack" : "Connect to Slack" })] }), _jsx("button", { type: "button", onClick: onClose, "aria-label": "Close dialog", className: cn("rounded p-1 text-muted-foreground", "hover:bg-accent-hover hover:text-foreground", "focus:outline-none focus:ring-1 focus:ring-ring"), children: _jsx(CloseIcon, {}) })] }), _jsx("div", { className: "space-y-4 px-5 py-4", children: deploymentMode === "local" ? (
159
+ // Preempt the doomed flow: the OSS backend answers every install
160
+ // with FAILED_PRECONDITION, so don't open a popup destined to fail.
161
+ _jsx(CloudFeatureNotice, { children: "Channel installs require Stigmer Cloud. The local backend manages channel configuration, but connecting to Slack uses the platform's hosted Slack app." })) : installed ? (_jsx(InstalledSummary, { channel: installed, agentName: agentName, botName: botName })) : busy ? (_jsx(FlowProgress, { phase: slack.phase, onCancel: handleCancel })) : (_jsxs(_Fragment, { children: [!channel && (_jsxs("label", { className: "block", children: [_jsx("span", { className: "mb-1.5 block text-xs font-medium text-foreground", children: "Channel name" }), _jsx("input", { type: "text", value: name, onChange: (e) => setName(e.target.value), disabled: busy, className: cn("w-full rounded-md border border-input bg-background px-3 py-1.5", "text-sm text-foreground placeholder:text-muted-foreground", "focus:outline-none focus:ring-1 focus:ring-ring") }), _jsx("span", { className: "mt-1 block text-xs text-muted-foreground", children: "Names the connection in Stigmer \u2014 pick something that identifies the workspace if you connect more than one." })] })), !channel && (_jsx(ServingAppSection, { org: org, apps: slackApps, value: appRef, onChange: setAppRef, disabled: busy, channelAppsHref: channelAppsHref, idPrefix: "stgm-slack-app", platformOption: {
162
+ label: "Stigmer app",
163
+ hint: "Fastest — no setup, the bot is named Stigmer",
164
+ }, appHint: "Your app \u2014 your bot name and icon", emptyBody: _jsxs("p", { className: "text-xs text-muted-foreground", children: ["The platform", " ", _jsx("span", { className: "font-medium text-foreground", children: "Stigmer" }), " ", "app \u2014 no setup needed. Want the bot to carry your own name and icon, or several agents in one workspace?", " ", _jsx(RegisterChannelAppAffordance, { channelAppsHref: channelAppsHref, children: "Register a channel app" }), "."] }) })), alreadyServed.length > 0 && (_jsx(AlreadyServedNote, { botName: botName, channels: alreadyServed })), !channel && (_jsx(ToolCredentialsSection, { agent: agent, org: org, value: environmentRefs, onChange: setEnvironmentRefs, disabled: busy })), _jsx("p", { className: "text-sm text-muted-foreground", children: "When you continue, Slack asks which workspace to add the bot to \u2014 pick the one where your team should chat with this agent." }), _jsxs("p", { className: "text-sm text-muted-foreground", children: ["Members reach the agent by opening a direct message with", " ", _jsx("span", { className: "font-medium text-foreground", children: botName }), ", or typing @ in a channel and picking", " ", _jsx("span", { className: "font-medium text-foreground", children: botName }), " ", "from the list \u2014 it answers as", " ", _jsx("span", { className: "font-medium text-foreground", children: agentName }), "."] }), _jsxs("p", { className: "text-xs text-muted-foreground", children: ["Conversations from Slack are billed to", " ", _jsx("span", { className: "font-medium", children: org }), ". A workspace can host one agent per Slack app."] }), error && (_jsx(InstallRefusal, { error: error, channelAppsHref: channelAppsHref }))] })) }), _jsx("div", { className: "flex justify-end gap-2 border-t border-border px-5 py-3", children: installed || deploymentMode === "local" ? (_jsx(Button, { variant: "outline", size: "sm", onClick: onClose, children: installed ? "Done" : "Close" })) : (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "ghost", size: "sm", onClick: onClose, disabled: busy, children: "Cancel" }), _jsx(Button, { variant: "primary", size: "sm", onClick: () => void handleConnect(), disabled: busy, icon: _jsx(SlackMarkIcon, { className: "size-3.5" }), "data-cursor-target": "dialog-connect-slack", children: error ? "Try again" : channel ? "Reconnect to Slack" : "Connect to Slack" })] })) })] }));
165
+ }
166
+ // ---------------------------------------------------------------------------
167
+ // Install refusal — guided for the duplicate-workspace reason
168
+ // ---------------------------------------------------------------------------
169
+ /**
170
+ * The reason code the server attaches (google.rpc.ErrorInfo, domain
171
+ * stigmer.ai) to a duplicate-workspace completeInstall refusal — see the
172
+ * completeInstall rpc comment for the vocabulary.
173
+ */
174
+ const REASON_WORKSPACE_ALREADY_CONNECTED = "SLACK_WORKSPACE_ALREADY_CONNECTED";
175
+ /**
176
+ * Install-refusal rendering. The duplicate-workspace refusal is the one
177
+ * a user can act on from here, so it gets a guided treatment — names the
178
+ * occupied workspace (from the ErrorInfo metadata) and offers the
179
+ * register-a-channel-app path. Every other refusal (and any error from a
180
+ * server not attaching reasons) renders the server's copy verbatim — the
181
+ * server owns that vocabulary.
182
+ */
183
+ function InstallRefusal({ error, channelAppsHref, }) {
184
+ const reason = getErrorReason(error);
185
+ if (reason?.reason !== REASON_WORKSPACE_ALREADY_CONNECTED) {
186
+ return _jsx(VerbatimRefusal, { error: error });
187
+ }
188
+ const team = reason.metadata.team_name || "This workspace";
189
+ return (_jsxs(RefusalBox, { children: [_jsxs("p", { children: [_jsx("span", { className: "font-medium", children: team }), " already hosts an agent through this app \u2014 a workspace hosts one agent per Slack app."] }), _jsxs("p", { children: ["To reach it with this agent, disconnect the existing channel, or", " ", _jsx(RegisterChannelAppAffordance, { channelAppsHref: channelAppsHref, children: "register a channel app" }), " ", "and connect through that instead."] })] }));
190
+ }
191
+ /**
192
+ * Pre-OAuth advisory: the selected serving app already occupies these
193
+ * workspaces, matched on the exact key the database enforces —
194
+ * (workspace, serving app). Shown before the user spends a Slack OAuth
195
+ * round-trip discovering it. Best-effort by design: the list is bounded
196
+ * by the caller's visibility and cannot see other orgs' holds, so the
197
+ * copy warns rather than forbids.
198
+ */
199
+ function AlreadyServedNote({ botName, channels, }) {
200
+ return (_jsx("div", { role: "status", className: "space-y-0.5 text-xs text-warning", children: channels.map((c) => {
201
+ const slack = c.status?.providerStatus?.case === "slack"
202
+ ? c.status.providerStatus.value
203
+ : null;
204
+ const team = slack?.teamName || slack?.teamId || "a workspace";
205
+ const agent = c.spec?.agentRef?.slug || "another agent";
206
+ return (_jsxs("p", { children: [_jsx("span", { className: "font-medium", children: botName }), " already serves", " ", _jsx("span", { className: "font-medium", children: team }), " via ", agent, " \u2014 a workspace hosts one agent per app, so connect through a different channel app to reach it."] }, c.metadata?.id ?? team));
207
+ }) }));
208
+ }
209
+ // ---------------------------------------------------------------------------
210
+ // Flow progress — one row per phase, the active one live
211
+ // ---------------------------------------------------------------------------
212
+ const FLOW_STEPS = [
213
+ { phase: "initiating", label: "Contacting Slack" },
214
+ { phase: "awaiting-callback", label: "Waiting for your approval in the Slack window" },
215
+ { phase: "completing", label: "Finalizing the connection" },
216
+ ];
217
+ function FlowProgress({ phase, onCancel, }) {
218
+ const activeIndex = FLOW_STEPS.findIndex((s) => s.phase === phase);
219
+ return (_jsxs("div", { className: "space-y-3", "aria-live": "polite", children: [_jsx("ul", { className: "space-y-2", children: FLOW_STEPS.map((step, i) => {
220
+ const isActive = i === activeIndex;
221
+ const isDone = activeIndex > i;
222
+ return (_jsxs("li", { className: cn("flex items-center gap-2 text-sm", isActive
223
+ ? "text-foreground"
224
+ : isDone
225
+ ? "text-muted-foreground"
226
+ : "text-muted-foreground-subtle"), children: [isDone ? (_jsx(CheckIcon, { className: "size-3.5 shrink-0 text-success" })) : isActive ? (_jsx(Spinner, { className: "size-3.5 shrink-0" })) : (_jsx("span", { className: "size-3.5 shrink-0 rounded-full border border-border", "aria-hidden": "true" })), step.label] }, step.phase));
227
+ }) }), _jsx(Button, { variant: "ghost", size: "xs", onClick: onCancel, children: "Cancel" })] }));
228
+ }
229
+ // ---------------------------------------------------------------------------
230
+ // Installed summary — the success state with the observed Slack facts
231
+ // ---------------------------------------------------------------------------
232
+ function InstalledSummary({ channel, agentName, botName, }) {
233
+ const slack = channel.status?.providerStatus?.case === "slack"
234
+ ? channel.status.providerStatus.value
235
+ : null;
236
+ return (_jsxs("div", { className: "space-y-2", role: "status", children: [_jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-foreground", children: [_jsx(CheckIcon, { className: "size-4 text-success" }), "Connected", slack?.teamName ? ` to ${slack.teamName}` : ""] }), _jsxs("p", { className: "text-sm text-muted-foreground", children: ["In Slack, open a direct message with", " ", _jsx("span", { className: "font-medium text-foreground", children: botName }), " \u2014 or type @ in any channel and pick", " ", _jsx("span", { className: "font-medium text-foreground", children: botName }), " from the list \u2014 then ask your question. Answers come from", " ", _jsx("span", { className: "font-medium text-foreground", children: agentName }), "."] })] }));
237
+ }
238
+ //# sourceMappingURL=ConnectSlackDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectSlackDialog.js","sourceRoot":"","sources":["../../src/channel/ConnectSlackDialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,cAAc,EAAoB,MAAM,cAAc,CAAC;AAGhE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8DAA8D,CAAC;AACxG,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,iBAAi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SAAS,EAAC,6BAA6B,YAAE,OAAO,GAAQ,qEACT,GAAG,EACxD,eAAM,SAAS,EAAC,6BAA6B,YAAE,SAAS,GAAQ,SAC9D,IACA,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,70 @@
1
+ import type { Agent } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
2
+ import type { AgentChannel } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/api_pb";
3
+ /** Props for {@link ConnectWhatsAppDialog}. */
4
+ export interface ConnectWhatsAppDialogProps {
5
+ /** Whether the dialog is open. */
6
+ readonly open: boolean;
7
+ /** Called when the dialog requests an open-state change. */
8
+ readonly onOpenChange: (open: boolean) => void;
9
+ /** The agent the channel connects. */
10
+ readonly agent: Agent;
11
+ /**
12
+ * An existing channel to (re)connect — a `pending_install` channel
13
+ * whose install never completed. Unlike Slack's frozen reconnect, the
14
+ * number and serving app stay editable here: a failed direct install
15
+ * usually means one of them is wrong, and both are server-mutable
16
+ * while the channel isn't installed. When omitted, the dialog opens in
17
+ * **create mode**.
18
+ */
19
+ readonly channel?: AgentChannel | null;
20
+ /**
21
+ * Called after the channel set changes (created, or install completed).
22
+ * Hosts typically pass the channel list's `refetch`.
23
+ */
24
+ readonly onChannelsChanged?: () => void;
25
+ /**
26
+ * When `false`, renders as an in-flow open dialog instead of a
27
+ * top-layer modal — no `showModal()`, no backdrop, no focus trap.
28
+ * For embedding the dialog in a constrained surface (documentation
29
+ * demos, visual tests). Interactive hosts keep the default.
30
+ * @default true
31
+ */
32
+ readonly modal?: boolean;
33
+ /**
34
+ * Where the host manages Channel Apps (the console passes
35
+ * `/settings/channel-apps`). When provided, the serving-app section
36
+ * and install refusals render a "Register a channel app" link there.
37
+ * SDK components never hardcode host routes — hosts inject the
38
+ * destination. Absent, the affordance degrades to plain guidance text.
39
+ */
40
+ readonly channelAppsHref?: string;
41
+ }
42
+ /**
43
+ * The connect flow for a WhatsApp channel: create the
44
+ * {@link AgentChannel} (create mode), then run the direct install — one
45
+ * server call that verifies the declared phone number against Meta's
46
+ * Graph API through the selected channel app's credentials (DD-WA-1).
47
+ * No consent popup, no callback route.
48
+ *
49
+ * WhatsApp is BYO-only (DD-WA-2): there is no platform Meta app, so a
50
+ * serving channel app is required — with none registered, the flow
51
+ * blocks on registering one first. The declared phone number ID is
52
+ * likewise required: the install proves it, and an empty value can only
53
+ * fail there.
54
+ *
55
+ * Requires Stigmer Cloud — on a `local` (OSS) backend the flow is
56
+ * preempted with a cloud-feature notice, matching the server's
57
+ * FAILED_PRECONDITION refusal. Install refusals render the server's
58
+ * copy verbatim except the duplicate-number refusal, which gets a
59
+ * guided treatment.
60
+ *
61
+ * Built on the native `<dialog>` element for focus trapping and escape
62
+ * handling, matching the SDK's modal convention
63
+ * ({@link ConnectSlackDialog}). All visual properties flow through
64
+ * `--stgm-*` design tokens.
65
+ *
66
+ * Most hosts mount it via {@link AgentChannelsPanel} (the Channels tab).
67
+ * Render it directly only when you own the open-state.
68
+ */
69
+ export declare function ConnectWhatsAppDialog({ open, onOpenChange, agent, channel, onChannelsChanged, modal, channelAppsHref, }: ConnectWhatsAppDialogProps): import("react/jsx-runtime").JSX.Element;
70
+ //# sourceMappingURL=ConnectWhatsAppDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectWhatsAppDialog.d.ts","sourceRoot":"","sources":["../../src/channel/ConnectWhatsAppDialog.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oDAAoD,CAAC;AAChF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2DAA2D,CAAC;AAoB9F,+CAA+C;AAC/C,MAAM,WAAW,0BAA0B;IACzC,kCAAkC;IAClC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,4DAA4D;IAC5D,QAAQ,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/C,sCAAsC;IACtC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB;;;;;;;OAOG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IACvC;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IACxC;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,OAAO,EACP,iBAAiB,EACjB,KAAY,EACZ,eAAe,GAChB,EAAE,0BAA0B,2CAiD5B"}
@@ -0,0 +1,256 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useCallback, useMemo, useRef, useState } from "react";
4
+ import { cn } from "@stigmer/theme";
5
+ import { getErrorReason } from "@stigmer/sdk";
6
+ import { AgentChannelInstallState } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/status_pb";
7
+ import { Button } from "../button/Button.js";
8
+ import { useChannelAppList } from "../channel-app/useChannelAppList.js";
9
+ import { useDeploymentMode } from "../deployment-mode.js";
10
+ import { useStigmer } from "../hooks.js";
11
+ import { CloudFeatureNotice } from "../internal/CloudFeatureNotice.js";
12
+ import { RegisterChannelAppAffordance, ServingAppSection, } from "./connect/ServingAppSection.js";
13
+ import { ToolCredentialsSection } from "./connect/ToolCredentialsSection.js";
14
+ import { RefusalBox, VerbatimRefusal } from "./connect/VerbatimRefusal.js";
15
+ import { CheckIcon, CloseIcon, Spinner } from "./connect/icons.js";
16
+ import { useCreateAgentChannel } from "./useCreateAgentChannel.js";
17
+ import { useInstallChannel } from "./useInstallChannel.js";
18
+ import { useOrgAgentChannelList } from "./useOrgAgentChannelList.js";
19
+ import { agentChannelToInput, useSaveAgentChannel } from "./useSaveAgentChannel.js";
20
+ import { WhatsAppMarkIcon } from "./WhatsAppMarkIcon.js";
21
+ /**
22
+ * The connect flow for a WhatsApp channel: create the
23
+ * {@link AgentChannel} (create mode), then run the direct install — one
24
+ * server call that verifies the declared phone number against Meta's
25
+ * Graph API through the selected channel app's credentials (DD-WA-1).
26
+ * No consent popup, no callback route.
27
+ *
28
+ * WhatsApp is BYO-only (DD-WA-2): there is no platform Meta app, so a
29
+ * serving channel app is required — with none registered, the flow
30
+ * blocks on registering one first. The declared phone number ID is
31
+ * likewise required: the install proves it, and an empty value can only
32
+ * fail there.
33
+ *
34
+ * Requires Stigmer Cloud — on a `local` (OSS) backend the flow is
35
+ * preempted with a cloud-feature notice, matching the server's
36
+ * FAILED_PRECONDITION refusal. Install refusals render the server's
37
+ * copy verbatim except the duplicate-number refusal, which gets a
38
+ * guided treatment.
39
+ *
40
+ * Built on the native `<dialog>` element for focus trapping and escape
41
+ * handling, matching the SDK's modal convention
42
+ * ({@link ConnectSlackDialog}). All visual properties flow through
43
+ * `--stgm-*` design tokens.
44
+ *
45
+ * Most hosts mount it via {@link AgentChannelsPanel} (the Channels tab).
46
+ * Render it directly only when you own the open-state.
47
+ */
48
+ export function ConnectWhatsAppDialog({ open, onOpenChange, agent, channel, onChannelsChanged, modal = true, channelAppsHref, }) {
49
+ const dialogRef = useRef(null);
50
+ const handleClose = useCallback(() => {
51
+ dialogRef.current?.close();
52
+ onOpenChange(false);
53
+ }, [onOpenChange]);
54
+ // Sync native dialog open state (matches the SDK dialog convention).
55
+ // Non-modal hosts pass `open` as a plain attribute instead — the dialog
56
+ // renders in-flow with no top layer to manage.
57
+ const prevOpenRef = useRef(false);
58
+ if (modal && open !== prevOpenRef.current) {
59
+ prevOpenRef.current = open;
60
+ if (open) {
61
+ requestAnimationFrame(() => {
62
+ if (dialogRef.current && !dialogRef.current.open) {
63
+ dialogRef.current.showModal();
64
+ }
65
+ });
66
+ }
67
+ else if (dialogRef.current?.open) {
68
+ dialogRef.current.close();
69
+ }
70
+ }
71
+ return (_jsx("dialog", { ref: dialogRef, open: modal ? undefined : open, onClose: handleClose, className: cn("w-full max-w-md rounded-xl border border-border bg-popover p-0 shadow-xl", modal ? "fixed inset-0 m-auto backdrop:bg-black/50" : "relative"), "aria-labelledby": "connect-whatsapp-title", children: open && (_jsx(ConnectWhatsAppDialogBody, { agent: agent, channel: channel ?? null, onChannelsChanged: onChannelsChanged, onClose: handleClose, channelAppsHref: channelAppsHref })) }));
72
+ }
73
+ function ConnectWhatsAppDialogBody({ agent, channel, onChannelsChanged, onClose, channelAppsHref, }) {
74
+ const stigmer = useStigmer();
75
+ const deploymentMode = useDeploymentMode();
76
+ const agentName = agent.metadata?.name || agent.metadata?.slug || "this agent";
77
+ const org = agent.metadata?.org ?? "";
78
+ const { createChannel, isPending: isCreating } = useCreateAgentChannel();
79
+ const { save, isPending: isSaving } = useSaveAgentChannel();
80
+ const installer = useInstallChannel();
81
+ const [name, setName] = useState(() => channel ? (channel.metadata?.name ?? "") : `${agentName} WhatsApp`);
82
+ // The declared number (spec.whatsapp.phone_number_id). Genuinely
83
+ // user-declared — a WABA holds many numbers; the owner picks which one
84
+ // the agent serves. Required client-side: the write path defers it to
85
+ // the install probe, where an empty value can only fail.
86
+ const [phoneNumberId, setPhoneNumberId] = useState(() => channel?.spec?.providerConfig?.case === "whatsapp"
87
+ ? channel.spec.providerConfig.value.phoneNumberId
88
+ : "");
89
+ // Tool credentials bound at connect time (create mode only — a retry
90
+ // keeps the channel's existing bindings untouched; edits go through
91
+ // the channel card's credentials dialog).
92
+ const [environmentRefs, setEnvironmentRefs] = useState([]);
93
+ // The serving app — required (DD-WA-2: no platform Meta app exists).
94
+ // Editable in retry mode too: app_ref is server-mutable while the
95
+ // channel isn't installed, and a wrong app is a likely failure cause.
96
+ const [appRef, setAppRef] = useState(() => channel?.spec?.appRef?.slug
97
+ ? { org: channel.spec.appRef.org || org, slug: channel.spec.appRef.slug }
98
+ : null);
99
+ const [installed, setInstalled] = useState(null);
100
+ const [error, setError] = useState(null);
101
+ // The org's channel apps, fetched once here so the serving-app picker
102
+ // and the advisory read one consistent list.
103
+ const { channelApps } = useChannelAppList(org || null);
104
+ const whatsappApps = useMemo(() => channelApps.filter((app) => app.spec?.providerConfig?.case === "whatsapp"), [channelApps]);
105
+ // A sole registered app is the only possible choice — preselect it so
106
+ // the required picker never blocks on a decision with one answer
107
+ // (Hick's law). Derived, not effect-synced: apps load async.
108
+ const effectiveAppRef = appRef ??
109
+ (whatsappApps.length === 1
110
+ ? { org, slug: whatsappApps[0].metadata?.slug ?? "" }
111
+ : null);
112
+ const selectedApp = effectiveAppRef
113
+ ? whatsappApps.find((app) => app.metadata?.slug === effectiveAppRef.slug) ?? null
114
+ : null;
115
+ // Numbers the selected serving app already serves, matched on the same
116
+ // key the database enforces uniqueness on: (phone number, channel app).
117
+ // Advisory only — the list is permission-bounded; the install stays
118
+ // the arbiter.
119
+ const advisoryActive = deploymentMode === "cloud" && !installed;
120
+ const { channels: orgChannels } = useOrgAgentChannelList(advisoryActive && org ? org : null);
121
+ const trimmedNumber = phoneNumberId.trim();
122
+ const alreadyServed = useMemo(() => {
123
+ const selectedAppId = selectedApp?.metadata?.id;
124
+ if (!selectedAppId || !trimmedNumber)
125
+ return [];
126
+ return orgChannels.filter((c) => c.metadata?.id !== channel?.metadata?.id &&
127
+ c.status?.installState === AgentChannelInstallState.installed &&
128
+ c.status?.providerStatus?.case === "whatsapp" &&
129
+ c.status.providerStatus.value.phoneNumberId === trimmedNumber &&
130
+ c.status.providerStatus.value.channelAppId === selectedAppId);
131
+ }, [orgChannels, selectedApp, trimmedNumber, channel]);
132
+ // One click drives the whole journey: (create/update →) direct
133
+ // install → fetch the installed facts. No popup, so nothing here needs
134
+ // the synchronous-gesture treatment the Slack flow does.
135
+ const handleConnect = useCallback(async () => {
136
+ setError(null);
137
+ try {
138
+ let target = channel;
139
+ if (!target) {
140
+ target = await createChannel({
141
+ name: name.trim() || `${agentName} WhatsApp`,
142
+ org,
143
+ agentRef: {
144
+ org,
145
+ slug: agent.metadata?.slug ?? "",
146
+ },
147
+ enabled: true,
148
+ whatsapp: { phoneNumberId: trimmedNumber },
149
+ ...(effectiveAppRef ? { appRef: effectiveAppRef } : {}),
150
+ ...(environmentRefs.length > 0 ? { environmentRefs } : {}),
151
+ });
152
+ // The channel now exists even if the install below fails —
153
+ // surface it in the list either way.
154
+ onChannelsChanged?.();
155
+ }
156
+ else {
157
+ // Retry mode: persist edits to the number or app before
158
+ // re-installing. Skipped when nothing changed so a plain retry
159
+ // is one call, not two.
160
+ const existingNumber = target.spec?.providerConfig?.case === "whatsapp"
161
+ ? target.spec.providerConfig.value.phoneNumberId
162
+ : "";
163
+ const existingAppSlug = target.spec?.appRef?.slug ?? "";
164
+ if (existingNumber !== trimmedNumber ||
165
+ existingAppSlug !== (effectiveAppRef?.slug ?? "")) {
166
+ target = await save({
167
+ ...agentChannelToInput(target),
168
+ whatsapp: { phoneNumberId: trimmedNumber },
169
+ ...(effectiveAppRef ? { appRef: effectiveAppRef } : {}),
170
+ });
171
+ onChannelsChanged?.();
172
+ }
173
+ }
174
+ await installer.install(target.metadata?.id ?? "");
175
+ // The install answer carries no channel — read the recorded facts
176
+ // (display number, verified name) for the success summary.
177
+ const result = await stigmer.agentChannel.get(target.metadata?.id ?? "");
178
+ setInstalled(result);
179
+ onChannelsChanged?.();
180
+ }
181
+ catch (err) {
182
+ setError(installer.error ?? (err instanceof Error ? err : new Error(String(err))));
183
+ }
184
+ }, [agent, agentName, channel, createChannel, effectiveAppRef, environmentRefs, installer, name, org, onChannelsChanged, save, stigmer, trimmedNumber]);
185
+ const busy = isCreating || isSaving || installer.isInProgress;
186
+ const canConnect = trimmedNumber !== "" && effectiveAppRef !== null && !busy;
187
+ return (_jsxs("div", { className: "flex flex-col", children: [_jsxs("div", { className: "flex items-start justify-between gap-3 border-b border-border px-5 py-4", children: [_jsxs("div", { className: "flex items-center gap-2.5", children: [_jsx(WhatsAppMarkIcon, { className: "size-5 text-foreground" }), _jsx("h2", { id: "connect-whatsapp-title", className: "text-sm font-semibold text-foreground", children: channel ? "Reconnect to WhatsApp" : "Connect to WhatsApp" })] }), _jsx("button", { type: "button", onClick: onClose, "aria-label": "Close dialog", className: cn("rounded p-1 text-muted-foreground", "hover:bg-accent-hover hover:text-foreground", "focus:outline-none focus:ring-1 focus:ring-ring"), children: _jsx(CloseIcon, {}) })] }), _jsx("div", { className: "space-y-4 px-5 py-4", children: deploymentMode === "local" ? (
188
+ // Preempt the doomed flow: the OSS backend answers every
189
+ // install with FAILED_PRECONDITION.
190
+ _jsx(CloudFeatureNotice, { children: "Channel installs require Stigmer Cloud. The local backend manages channel configuration, but connecting to WhatsApp verifies your number through Stigmer's hosted webhook infrastructure." })) : installed ? (_jsx(InstalledSummary, { channel: installed, agentName: agentName })) : busy ? (_jsx(InstallingIndicator, {})) : (_jsxs(_Fragment, { children: [!channel && (_jsxs("label", { className: "block", children: [_jsx("span", { className: "mb-1.5 block text-xs font-medium text-foreground", children: "Channel name" }), _jsx("input", { type: "text", value: name, onChange: (e) => setName(e.target.value), disabled: busy, className: cn("w-full rounded-md border border-input bg-background px-3 py-1.5", "text-sm text-foreground placeholder:text-muted-foreground", "focus:outline-none focus:ring-1 focus:ring-ring") }), _jsx("span", { className: "mt-1 block text-xs text-muted-foreground", children: "Names the connection in Stigmer \u2014 pick something that identifies the number if you connect more than one." })] })), _jsxs("label", { className: "block", children: [_jsx("span", { className: "mb-1.5 block text-xs font-medium text-foreground", children: "Phone number ID" }), _jsx("input", { type: "text", value: phoneNumberId, onChange: (e) => setPhoneNumberId(e.target.value), disabled: busy, required: true, placeholder: "106540352242922", "data-cursor-target": "dialog-whatsapp-number", className: cn("w-full rounded-md border border-input bg-background px-3 py-1.5", "font-mono text-sm text-foreground placeholder:text-muted-foreground", "focus:outline-none focus:ring-1 focus:ring-ring") }), _jsx("span", { className: "mt-1 block text-xs text-muted-foreground", children: "From Meta's WhatsApp Manager (API Setup) \u2014 the numeric ID of the number this agent should answer, not the phone number itself." })] }), _jsx(ServingAppSection, { org: org, apps: whatsappApps, value: effectiveAppRef, onChange: setAppRef, disabled: busy, channelAppsHref: channelAppsHref, idPrefix: "stgm-whatsapp-app", appHint: "Your Meta app \u2014 its credentials verify and serve the number", emptyBody: _jsxs("p", { className: "text-xs text-muted-foreground", children: ["WhatsApp channels connect through your own Meta app \u2014 there is no shared platform app.", " ", _jsx(RegisterChannelAppAffordance, { channelAppsHref: channelAppsHref, children: "Register a channel app" }), " ", "with your Meta app's credentials first, then connect here."] }) }), alreadyServed.length > 0 && (_jsx(AlreadyServedNote, { channels: alreadyServed })), !channel && (_jsx(ToolCredentialsSection, { agent: agent, org: org, value: environmentRefs, onChange: setEnvironmentRefs, disabled: busy })), _jsx("p", { className: "text-sm text-muted-foreground", children: "When you continue, Stigmer verifies the number with WhatsApp through the selected app's credentials \u2014 the connection completes right here, with no browser hand-off." }), _jsxs("p", { className: "text-sm text-muted-foreground", children: ["People reach the agent by sending a WhatsApp message to the connected number \u2014 it answers as", " ", _jsx("span", { className: "font-medium text-foreground", children: agentName }), "."] }), _jsxs("p", { className: "text-xs text-muted-foreground", children: ["Conversations from WhatsApp are billed to", " ", _jsx("span", { className: "font-medium", children: org }), ". Each number serves one agent per channel app."] }), error && (_jsx(InstallRefusal, { error: error, channelAppsHref: channelAppsHref }))] })) }), _jsx("div", { className: "flex justify-end gap-2 border-t border-border px-5 py-3", children: installed || deploymentMode === "local" ? (_jsx(Button, { variant: "outline", size: "sm", onClick: onClose, children: installed ? "Done" : "Close" })) : (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "ghost", size: "sm", onClick: onClose, disabled: busy, children: "Cancel" }), _jsx(Button, { variant: "primary", size: "sm", onClick: () => void handleConnect(), disabled: !canConnect, icon: _jsx(WhatsAppMarkIcon, { className: "size-3.5" }), "data-cursor-target": "dialog-connect-whatsapp", children: error ? "Try again" : channel ? "Reconnect to WhatsApp" : "Connect to WhatsApp" })] })) })] }));
191
+ }
192
+ // ---------------------------------------------------------------------------
193
+ // Install refusal — guided for the duplicate-number reason
194
+ // ---------------------------------------------------------------------------
195
+ /**
196
+ * The reason code the server attaches (google.rpc.ErrorInfo, domain
197
+ * stigmer.ai) to a duplicate-number initiateInstall refusal — see the
198
+ * initiateInstall rpc comment for the vocabulary.
199
+ */
200
+ const REASON_NUMBER_ALREADY_CONNECTED = "WHATSAPP_NUMBER_ALREADY_CONNECTED";
201
+ /**
202
+ * Install-refusal rendering. The duplicate-number refusal is the one a
203
+ * user can act on from here, so it gets a guided treatment — names the
204
+ * occupied number (from the ErrorInfo metadata) and the ways out. Every
205
+ * other refusal (bad token, unknown number, dangling app — and any error
206
+ * from a server not attaching reasons) renders the server's copy
207
+ * verbatim — the server owns that vocabulary.
208
+ */
209
+ function InstallRefusal({ error, channelAppsHref, }) {
210
+ const reason = getErrorReason(error);
211
+ if (reason?.reason !== REASON_NUMBER_ALREADY_CONNECTED) {
212
+ return _jsx(VerbatimRefusal, { error: error });
213
+ }
214
+ const number = reason.metadata.display_phone_number || "This number";
215
+ return (_jsxs(RefusalBox, { children: [_jsxs("p", { children: [_jsx("span", { className: "font-medium", children: number }), " is already connected to an agent through this channel app \u2014 each number serves one agent."] }), _jsxs("p", { children: ["To reach it with this agent, disconnect the existing channel, use a different number, or", " ", _jsx(RegisterChannelAppAffordance, { channelAppsHref: channelAppsHref, children: "register a channel app" }), " ", "and connect through that instead."] })] }));
216
+ }
217
+ /**
218
+ * Pre-install advisory: the selected serving app already serves this
219
+ * number, matched on the exact key the database enforces — (phone
220
+ * number, serving app). Shown before the user spends the install
221
+ * round-trip discovering it. Best-effort by design: the list is bounded
222
+ * by the caller's visibility, so the copy warns rather than forbids.
223
+ */
224
+ function AlreadyServedNote({ channels, }) {
225
+ return (_jsx("div", { role: "status", className: "space-y-0.5 text-xs text-warning", children: channels.map((c) => {
226
+ const whatsapp = c.status?.providerStatus?.case === "whatsapp"
227
+ ? c.status.providerStatus.value
228
+ : null;
229
+ const number = whatsapp?.displayPhoneNumber || whatsapp?.phoneNumberId || "this number";
230
+ const agent = c.spec?.agentRef?.slug || "another agent";
231
+ return (_jsxs("p", { children: [_jsx("span", { className: "font-medium", children: number }), " is already served via ", agent, " \u2014 each number serves one agent per channel app, so disconnect that channel or pick a different number."] }, c.metadata?.id ?? number));
232
+ }) }));
233
+ }
234
+ // ---------------------------------------------------------------------------
235
+ // Installing indicator — a single live step, deliberately not a ladder
236
+ // ---------------------------------------------------------------------------
237
+ /**
238
+ * The busy state of a direct install: one server call, so one live line —
239
+ * not the Slack dialog's three-step OAuth ladder, which would render two
240
+ * permanently-empty rungs here. No cancel affordance either: there is no
241
+ * popup to abandon, and the call settles in seconds.
242
+ */
243
+ function InstallingIndicator() {
244
+ return (_jsxs("div", { className: "flex items-center gap-2 text-sm text-foreground", "aria-live": "polite", children: [_jsx(Spinner, { className: "size-3.5 shrink-0" }), "Verifying the number with WhatsApp\u2026"] }));
245
+ }
246
+ // ---------------------------------------------------------------------------
247
+ // Installed summary — the success state with the observed WhatsApp facts
248
+ // ---------------------------------------------------------------------------
249
+ function InstalledSummary({ channel, agentName, }) {
250
+ const whatsapp = channel.status?.providerStatus?.case === "whatsapp"
251
+ ? channel.status.providerStatus.value
252
+ : null;
253
+ const number = whatsapp?.displayPhoneNumber || whatsapp?.phoneNumberId || null;
254
+ return (_jsxs("div", { className: "space-y-2", role: "status", children: [_jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-foreground", children: [_jsx(CheckIcon, { className: "size-4 text-success" }), "Connected", number ? ` to ${number}` : "", whatsapp?.verifiedName ? ` (${whatsapp.verifiedName})` : ""] }), _jsxs("p", { className: "text-sm text-muted-foreground", children: ["Send a WhatsApp message to", " ", _jsx("span", { className: "font-medium text-foreground", children: number ?? "the connected number" }), " ", "and ask your question \u2014 answers come from", " ", _jsx("span", { className: "font-medium text-foreground", children: agentName }), "."] })] }));
255
+ }
256
+ //# sourceMappingURL=ConnectWhatsAppDialog.js.map