@lobu/runtime-server 24.11.0 → 24.12.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 (275) hide show
  1. package/dist/catalogs/connectors.json +1113 -107
  2. package/dist/catalogs/skills.json +2 -2
  3. package/dist/component.json +1 -1
  4. package/dist/connectors/README.md +2 -2
  5. package/dist/connectors/chat-transport-actions.ts +50 -0
  6. package/dist/connectors/discord.ts +2 -0
  7. package/dist/connectors/gchat.ts +2 -0
  8. package/dist/connectors/github.ts +4 -4
  9. package/dist/connectors/google_drive.ts +20 -0
  10. package/dist/connectors/google_gmail.ts +49 -8
  11. package/dist/connectors/herdr.ts +1 -1
  12. package/dist/connectors/imessage.ts +1 -0
  13. package/dist/connectors/linkedin-browser-script.ts +11 -0
  14. package/dist/connectors/linkedin-draft-page.js +24 -8
  15. package/dist/connectors/linkedin-inbox-adapter.js +209 -19
  16. package/dist/connectors/linkedin-inbox.ts +152 -4
  17. package/dist/connectors/linkedin-network.ts +788 -0
  18. package/dist/connectors/linkedin-search.ts +1284 -0
  19. package/dist/connectors/linkedin.ts +892 -27
  20. package/dist/connectors/microsoft_outlook.ts +57 -19
  21. package/dist/connectors/rss.ts +179 -33
  22. package/dist/connectors/slack.ts +2 -0
  23. package/dist/connectors/source-file-attachment.ts +46 -0
  24. package/dist/connectors/teams.ts +2 -0
  25. package/dist/connectors/telegram.ts +2 -0
  26. package/dist/connectors/tiktok_web.ts +1 -1
  27. package/dist/connectors/whatsapp.ts +2 -0
  28. package/dist/connectors/whatsapp_web.ts +3 -3
  29. package/dist/connectors/x-dm-adapter.js +8 -10
  30. package/dist/connectors/x.ts +8 -9
  31. package/dist/db/migrations/20261115040000_account_two_factor.sql +20 -0
  32. package/dist/db/migrations/20261115120000_events_unbound_tool_audit_without_bridge.sql +40 -0
  33. package/dist/db/migrations/20261115120001_events_unbound_tool_audit_validate.sql +19 -0
  34. package/dist/db/migrations/20261115120002_drop_events_linked_org_ids.sql +119 -0
  35. package/dist/db/migrations/20261115130000_entities_retired_type_idx.sql +34 -0
  36. package/dist/db/migrations/20261115140000_entity_identities_personal_owner_idx.sql +34 -0
  37. package/dist/db/migrations/20261117090000_write_policy_kind_note.sql +65 -0
  38. package/dist/db/migrations/20261117120000_app_policy_principal.sql +48 -0
  39. package/dist/db/migrations/20261117170000_personal_org_connector_auto_policy_backfill.sql +57 -0
  40. package/dist/db/migrations/20261117190000_org_slug_reserved_paths.sql +29 -0
  41. package/dist/db/migrations/20261118120000_workspace_view_top_level_paths.sql +69 -0
  42. package/dist/db/migrations/preconditions/20261117190000_org_slug_reserved_paths.sql +14 -0
  43. package/dist/db/migrations/preconditions/20261118120000_workspace_view_top_level_paths.sql +21 -0
  44. package/dist/dependencies.bun.lock +51 -46
  45. package/dist/guest.bundle.js +11 -2
  46. package/dist/owletto/dist/assets/_-BC9j6MkU.js +2 -0
  47. package/dist/owletto/dist/assets/_-Z1u1cIe6.js +3 -0
  48. package/dist/owletto/dist/assets/_agentId-B-TFq9TP.js +2 -0
  49. package/dist/owletto/dist/assets/{_agentId-CGScf8z_.js → _agentId-BGatZWsd.js} +2 -2
  50. package/dist/owletto/dist/assets/_automationId-CMUrWPvr.js +2 -0
  51. package/dist/owletto/dist/assets/_connectorKey._connectionId-CUoAoP0_.js +2 -0
  52. package/dist/owletto/dist/assets/_connectorKey.index-Bs49QGGH.js +2 -0
  53. package/dist/owletto/dist/assets/_conversationId-CszP1den.js +2 -0
  54. package/dist/owletto/dist/assets/_eventId-C0AZUBnD.js +2 -0
  55. package/dist/owletto/dist/assets/_owner-B4ydA75k.js +3 -0
  56. package/dist/owletto/dist/assets/_shape-C4-ikE70.js +2 -0
  57. package/dist/owletto/dist/assets/_slug-DE5J3KVu.js +2 -0
  58. package/dist/owletto/dist/assets/_viewKey-Dkcd8JQC.js +2 -0
  59. package/dist/owletto/dist/assets/{accept-invitation-BKeIzZXE.js → accept-invitation-DmrQQu_W.js} +2 -2
  60. package/dist/owletto/dist/assets/{activity-route-location-sLvKaSCa.js → activity-route-location-Bec6fW-t.js} +2 -2
  61. package/dist/owletto/dist/assets/activity-route-view-DCSNBKZU.js +2 -0
  62. package/dist/owletto/dist/assets/agent-client-connections-xvabPpi6.js +4 -0
  63. package/dist/owletto/dist/assets/agent-connect-pages-DDPtkcmq.js +6 -0
  64. package/dist/owletto/dist/assets/{agent-editor-form-DVFyyMyd.js → agent-editor-form-BrhQbHZg.js} +2 -2
  65. package/dist/owletto/dist/assets/{agent-loading-shells-BLNHIy-r.js → agent-loading-shells-D3y98xuO.js} +2 -2
  66. package/dist/owletto/dist/assets/{agent-permissions-matrix-UBKRR5vs.js → agent-permissions-matrix-jQJjSa9i.js} +2 -2
  67. package/dist/owletto/dist/assets/{agent-skill-context-fqedKd0D.js → agent-skill-context-CCcknBYE.js} +2 -2
  68. package/dist/owletto/dist/assets/{agent-subpage-shell-BUCoY2Nf.js → agent-subpage-shell-6f_53cSf.js} +2 -2
  69. package/dist/owletto/dist/assets/agent-thread-v_lSSnJi.js +6 -0
  70. package/dist/owletto/dist/assets/{app._appId-ByIypCL9.js → app._appId-CKWzZ2ic.js} +2 -2
  71. package/dist/owletto/dist/assets/assist-composer-Q9ZJjAta.js +2 -0
  72. package/dist/owletto/dist/assets/automation-run-now-Dl0MKx3N.js +2 -0
  73. package/dist/owletto/dist/assets/{callback-Pz5uS-k7.js → callback-Bentv78L.js} +2 -2
  74. package/dist/owletto/dist/assets/{card-CAPpY9P5.js → card-C4oPCVh6.js} +2 -2
  75. package/dist/owletto/dist/assets/{claim-DgWWK0KI.js → claim-B3C4qIi2.js} +2 -2
  76. package/dist/owletto/dist/assets/client-activity-scopes-DqaFEyir.js +2 -0
  77. package/dist/owletto/dist/assets/{client-rows-Dd5YV8vn.js → client-rows-rse9thnk.js} +2 -2
  78. package/dist/owletto/dist/assets/{clients-Bf7ZgGro.js → clients-BhPMbxHi.js} +2 -2
  79. package/dist/owletto/dist/assets/{code-editor-z1Sy_hiX.js → code-editor-CTdKUDPY.js} +2 -2
  80. package/dist/owletto/dist/assets/connect-D8o7HBlo.js +2 -0
  81. package/dist/owletto/dist/assets/connect-menu-D5EZvSHb.js +2 -0
  82. package/dist/owletto/dist/assets/connect._clientId-Dbagcg9L.js +2 -0
  83. package/dist/owletto/dist/assets/connected._clientId-DALW9S2K.js +2 -0
  84. package/dist/owletto/dist/assets/connection-DyxzSqVE.js +2 -0
  85. package/dist/owletto/dist/assets/connection-feed-detail-LqpxUCdy.js +2 -0
  86. package/dist/owletto/dist/assets/{connector-page-shell-an3SYLim.js → connector-page-shell-DZjKv9zQ.js} +2 -2
  87. package/dist/owletto/dist/assets/{connector-provenance-mSZCOud-.js → connector-provenance-DtTJn1Nk.js} +2 -2
  88. package/dist/owletto/dist/assets/connectors-BVl-AR33.js +2 -0
  89. package/dist/owletto/dist/assets/{consent-1ulwyJ3k.js → consent-XCqsHLxS.js} +2 -2
  90. package/dist/owletto/dist/assets/{core.esm-Ctg_pXLe.js → core.esm-B1du4Zwy.js} +3 -3
  91. package/dist/owletto/dist/assets/create-BYKCtGL4.js +2 -0
  92. package/dist/owletto/dist/assets/create-D6Mmuxcq.js +2 -0
  93. package/dist/owletto/dist/assets/{create-CGuoqPh8.js → create-GHTb6wKX.js} +2 -2
  94. package/dist/owletto/dist/assets/{create-automation-form-CD6jSlWL.js → create-automation-form-CTiy_S9G.js} +3 -3
  95. package/dist/owletto/dist/assets/create._connectorKey-DMH97KkK.js +2 -0
  96. package/dist/owletto/dist/assets/custom-guardrail-edits-DZy66ucV.js +2 -0
  97. package/dist/owletto/dist/assets/definition-comparison-C2mPfIMD.js +2 -0
  98. package/dist/owletto/dist/assets/detail-page-skeleton-DNBL7nyk.js +2 -0
  99. package/dist/owletto/dist/assets/device-CwP1PY8q.js +2 -0
  100. package/dist/owletto/dist/assets/{device-pin-tombstone-Dkj7hrBE.js → device-pin-tombstone-DYTt7kU5.js} +2 -2
  101. package/dist/owletto/dist/assets/device._deviceId-DZ2kqI4Y.js +2 -0
  102. package/dist/owletto/dist/assets/{entity-options-D4t-NAcg.js → entity-options-D9K_5Lcs.js} +2 -2
  103. package/dist/owletto/dist/assets/entity-page-DggKXrcE.js +2 -0
  104. package/dist/owletto/dist/assets/entity-pages-C6M6yKFf.js +2 -0
  105. package/dist/owletto/dist/assets/{entity-schema-graph-Cq96SJ3c.js → entity-schema-graph-B255NKjF.js} +2 -2
  106. package/dist/owletto/dist/assets/entity-type-page-CGBAP2wt.js +2 -0
  107. package/dist/owletto/dist/assets/event-attachments-D8Z8uwv9.js +2 -0
  108. package/dist/owletto/dist/assets/event-detail-CgG3pDLA.js +2 -0
  109. package/dist/owletto/dist/assets/events-feed-ClhEywwV.js +2 -0
  110. package/dist/owletto/dist/assets/{filter-editors-DGVl9U4D.js → filter-editors-D_Sfn0dv.js} +3 -3
  111. package/dist/owletto/dist/assets/{full-page-spinner-CtVlF8GQ.js → full-page-spinner-C1clibUY.js} +2 -2
  112. package/dist/owletto/dist/assets/{index-CK5GDX4B.js → index-04B26s6E.js} +2 -2
  113. package/dist/owletto/dist/assets/index-2HrEO-nl.js +2 -0
  114. package/dist/owletto/dist/assets/index-BU3k9wpw.js +2 -0
  115. package/dist/owletto/dist/assets/{index-DvuJ_S_o.js → index-BXHqp23o.js} +2 -2
  116. package/dist/owletto/dist/assets/index-BdLRUDIR.js +2 -0
  117. package/dist/owletto/dist/assets/index-C2FrGwYN.js +2 -0
  118. package/dist/owletto/dist/assets/index-CB9wGfUm.js +2 -0
  119. package/dist/owletto/dist/assets/index-Caihaftb.js +2 -0
  120. package/dist/owletto/dist/assets/index-CwH59DJV.js +2 -0
  121. package/dist/owletto/dist/assets/index-DB2lVKuV.js +7908 -0
  122. package/dist/owletto/dist/assets/{index-DbjbHlDe.js → index-DTvJRjrM.js} +2 -2
  123. package/dist/owletto/dist/assets/index-SF2ni1Rs.css +1 -0
  124. package/dist/owletto/dist/assets/{index-BifR-LE9.js → index-mSrdbx3C.js} +9 -9
  125. package/dist/owletto/dist/assets/index-uFn-Ilrx.js +2 -0
  126. package/dist/owletto/dist/assets/{json-diff-OjtREegr.js → json-diff-Ce6YAXzY.js} +2 -2
  127. package/dist/owletto/dist/assets/{list-skeleton-CH0qQBYk.js → list-skeleton-DLPBTnbR.js} +2 -2
  128. package/dist/owletto/dist/assets/login-DeWlvogD.js +2 -0
  129. package/dist/owletto/dist/assets/{logout-DfdgOLoM.js → logout-CJY0ceN9.js} +2 -2
  130. package/dist/owletto/dist/assets/{member-scope-gate-Cxg2zGQT.js → member-scope-gate-CBPMprXu.js} +2 -2
  131. package/dist/owletto/dist/assets/memory-browse-page-D5kj1RaR.js +74 -0
  132. package/dist/owletto/dist/assets/{model-selector-D2OpDkwH.js → model-selector-CjkBPpjN.js} +2 -2
  133. package/dist/owletto/dist/assets/new-BKrNkOQD.js +2 -0
  134. package/dist/owletto/dist/assets/new-BetiMuDq.js +2 -0
  135. package/dist/owletto/dist/assets/new-dk_-eXqU.js +2 -0
  136. package/dist/owletto/dist/assets/new-efN--4Wx.js +2 -0
  137. package/dist/owletto/dist/assets/organization-C3rpwx_d.js +2 -0
  138. package/dist/owletto/dist/assets/pdf-document--AN-oCKj.css +1 -0
  139. package/dist/owletto/dist/assets/pdf-document-2W1q0sRA.js +56 -0
  140. package/dist/owletto/dist/assets/pdf.worker.min-CIqJB0yW.mjs +28 -0
  141. package/dist/owletto/dist/assets/peek-pane-content-ChsBWO0P.js +3 -0
  142. package/dist/owletto/dist/assets/{pending-seed-BBACroge.js → pending-seed-CTKYdA4X.js} +2 -2
  143. package/dist/owletto/dist/assets/proposal-review-shell-EyGWEYwQ.js +2 -0
  144. package/dist/owletto/dist/assets/public-shell-ready-_KWdfzEM.js +2 -0
  145. package/dist/owletto/dist/assets/record-session-D27VNxP_.js +2 -0
  146. package/dist/owletto/dist/assets/{renderer-CTKNMcXP.js → renderer-B8yZ5lql.js} +34 -33
  147. package/dist/owletto/dist/assets/{reset-password-DKBEneyR.js → reset-password-BGVJIh2I.js} +2 -2
  148. package/dist/owletto/dist/assets/run-initiator-C0sur8lU.js +2 -0
  149. package/dist/owletto/dist/assets/runs-list-CJOFMgpk.js +2 -0
  150. package/dist/owletto/dist/assets/schema-value-DDNHANGs.js +3 -0
  151. package/dist/owletto/dist/assets/{scoped-feed-bar-DNFL0sYX.js → scoped-feed-bar-BTv9mPcR.js} +2 -2
  152. package/dist/owletto/dist/assets/settings-Ponr5XbS.js +3 -0
  153. package/dist/owletto/dist/assets/{status-variants-SzXYYedJ.js → status-variants-mLqVhg5O.js} +2 -2
  154. package/dist/owletto/dist/assets/subDays-BGA_fkig.js +2 -0
  155. package/dist/owletto/dist/assets/two-factor-pqoxGSgL.js +2 -0
  156. package/dist/owletto/dist/assets/{use-automations-DfBtVzGa.js → use-automations-DcdlmVuX.js} +2 -2
  157. package/dist/owletto/dist/assets/{use-login-redirect-BDiS3eyl.js → use-login-redirect-D7HW5Ed6.js} +2 -2
  158. package/dist/owletto/dist/assets/{use-mention-search-khySpz_V.js → use-mention-search-BniE-K2d.js} +3 -3
  159. package/dist/owletto/dist/assets/view-card-Cg6PeEiV.js +2 -0
  160. package/dist/owletto/dist/assets/view-param-filters-CvrKw0mZ.js +2 -0
  161. package/dist/owletto/dist/index.html +2 -2
  162. package/dist/server-main.bundle.mjs +5766 -2999
  163. package/npm-shrinkwrap.json +195 -172
  164. package/package.json +2 -1
  165. package/vendor/connector-sdk/dist/connector-types.d.ts +20 -0
  166. package/vendor/connector-sdk/dist/define-connector.js +2 -0
  167. package/vendor/connector-sdk/dist/extension-dom-scrape.d.ts +2 -0
  168. package/vendor/connector-sdk/dist/extension-dom-scrape.js +5 -0
  169. package/vendor/connector-sdk/dist/reaction-client-types.d.ts +20 -0
  170. package/vendor/connector-sdk/package.json +1 -1
  171. package/vendor/core/dist/contracts/entity-reference.d.ts +2 -0
  172. package/vendor/core/dist/contracts/entity-reference.js +4 -3
  173. package/vendor/core/dist/contracts/tools/entity-list-sort.d.ts +18 -0
  174. package/vendor/core/dist/contracts/tools/entity-list-sort.js +64 -0
  175. package/vendor/core/dist/contracts/tools/manage-agents.d.ts +1 -1
  176. package/vendor/core/dist/contracts/tools/manage-agents.js +3 -3
  177. package/vendor/core/dist/contracts/tools/manage-entity-schema.d.ts +4 -0
  178. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +4 -0
  179. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +4 -0
  180. package/vendor/core/dist/contracts/tools/manage-entity.js +11 -1
  181. package/vendor/core/dist/contracts/tools/manage-operations.d.ts +29 -3
  182. package/vendor/core/dist/contracts/tools/manage-operations.js +24 -2
  183. package/vendor/core/dist/contracts/tools/manage-views.d.ts +36 -0
  184. package/vendor/core/dist/contracts/tools/manage-views.js +15 -2
  185. package/vendor/core/dist/contracts/tools/view-definition.js +7 -2
  186. package/vendor/core/dist/contracts/tools/view-host.js +5 -0
  187. package/vendor/core/dist/contracts/tools/view-path.d.ts +8 -1
  188. package/vendor/core/dist/contracts/tools/view-path.js +11 -1
  189. package/vendor/core/dist/reserved.d.ts +7 -1
  190. package/vendor/core/dist/reserved.js +17 -0
  191. package/vendor/core/package.json +6 -1
  192. package/vendor/views/dist/api.d.ts +19 -3
  193. package/vendor/views/dist/api.js +53 -5
  194. package/vendor/views/dist/components.d.ts +7 -0
  195. package/vendor/views/dist/components.js +223 -2
  196. package/vendor/views/dist/embed.js +13 -2
  197. package/vendor/views/dist/live-gate.d.ts +34 -0
  198. package/vendor/views/dist/live-gate.js +100 -0
  199. package/vendor/views/dist/native.d.ts +43 -1
  200. package/vendor/views/dist/native.js +1 -0
  201. package/vendor/views/package.json +1 -1
  202. package/dist/owletto/dist/assets/_-BDMUN9XZ.js +0 -2
  203. package/dist/owletto/dist/assets/_-CF5X4ANe.js +0 -3
  204. package/dist/owletto/dist/assets/_agentId-EQU2aUP0.js +0 -2
  205. package/dist/owletto/dist/assets/_automationId-PXZ33jsF.js +0 -2
  206. package/dist/owletto/dist/assets/_connectorKey._connectionId-DcI29kGy.js +0 -2
  207. package/dist/owletto/dist/assets/_connectorKey.index-Cr2NDJWX.js +0 -2
  208. package/dist/owletto/dist/assets/_conversationId-CnmLYlVS.js +0 -2
  209. package/dist/owletto/dist/assets/_eventId-w5sDz5oa.js +0 -2
  210. package/dist/owletto/dist/assets/_owner-CkOZR4n0.js +0 -3
  211. package/dist/owletto/dist/assets/_shape-C_FmSf9G.js +0 -2
  212. package/dist/owletto/dist/assets/_slug-COPpRXLt.js +0 -2
  213. package/dist/owletto/dist/assets/_viewKey-BVdJiilV.js +0 -2
  214. package/dist/owletto/dist/assets/_viewKey-mxxpqjtC.js +0 -2
  215. package/dist/owletto/dist/assets/activity-route-view-msesKUwn.js +0 -2
  216. package/dist/owletto/dist/assets/agent-connect-pages-DVq9nAR7.js +0 -4
  217. package/dist/owletto/dist/assets/agent-thread-Cqf9ITrT.js +0 -6
  218. package/dist/owletto/dist/assets/assist-composer-kG_heHXo.js +0 -2
  219. package/dist/owletto/dist/assets/automation-run-now-C5XTS00o.js +0 -2
  220. package/dist/owletto/dist/assets/client-activity-scopes-Aqdo6Pdr.js +0 -2
  221. package/dist/owletto/dist/assets/connect-BFNp1y_s.js +0 -2
  222. package/dist/owletto/dist/assets/connect-menu-BWrAhMqO.js +0 -2
  223. package/dist/owletto/dist/assets/connect._clientId-CSPfwYIN.js +0 -2
  224. package/dist/owletto/dist/assets/connected._clientId-CuOeHafK.js +0 -2
  225. package/dist/owletto/dist/assets/connection-CVeHmDLs.js +0 -2
  226. package/dist/owletto/dist/assets/connection-feed-detail-BYo7zdVD.js +0 -2
  227. package/dist/owletto/dist/assets/connectors-DBEM9QQz.js +0 -2
  228. package/dist/owletto/dist/assets/copy-button-Xhh7ZnjO.js +0 -2
  229. package/dist/owletto/dist/assets/create-Ccb5R-S4.js +0 -2
  230. package/dist/owletto/dist/assets/create-DmhbacIa.js +0 -2
  231. package/dist/owletto/dist/assets/create._connectorKey-CZsAqj1p.js +0 -2
  232. package/dist/owletto/dist/assets/custom-guardrail-edits-Ce_BwiwD.js +0 -2
  233. package/dist/owletto/dist/assets/definition-comparison-D_qP25jR.js +0 -2
  234. package/dist/owletto/dist/assets/detail-page-skeleton-CPAfZLG0.js +0 -2
  235. package/dist/owletto/dist/assets/device-DDl5XKvt.js +0 -2
  236. package/dist/owletto/dist/assets/device._deviceId-bNhTcops.js +0 -2
  237. package/dist/owletto/dist/assets/dynamic-schema-form-CRyUchXo.js +0 -2
  238. package/dist/owletto/dist/assets/entity-page-BOOL_vy3.js +0 -2
  239. package/dist/owletto/dist/assets/entity-pages-_nuesgnp.js +0 -2
  240. package/dist/owletto/dist/assets/entity-type-page-CkCSbkBx.js +0 -2
  241. package/dist/owletto/dist/assets/event-detail-DUvlqn9b.js +0 -2
  242. package/dist/owletto/dist/assets/events-feed-DcKTkJVe.js +0 -2
  243. package/dist/owletto/dist/assets/index-BUlkNJzX.js +0 -2
  244. package/dist/owletto/dist/assets/index-BoqrvLHQ.js +0 -7906
  245. package/dist/owletto/dist/assets/index-CA9mW_ZM.js +0 -2
  246. package/dist/owletto/dist/assets/index-CH0GzG4i.js +0 -2
  247. package/dist/owletto/dist/assets/index-CtI5Eomq.js +0 -2
  248. package/dist/owletto/dist/assets/index-DmtQ0bds.js +0 -2
  249. package/dist/owletto/dist/assets/index-Du_J8hnx.js +0 -2
  250. package/dist/owletto/dist/assets/index-Pae_f9LM.css +0 -1
  251. package/dist/owletto/dist/assets/index-XETZnN7L.js +0 -2
  252. package/dist/owletto/dist/assets/login-DG0b9uSC.js +0 -2
  253. package/dist/owletto/dist/assets/memory-browse-page-qEDQ9Z18.js +0 -74
  254. package/dist/owletto/dist/assets/missing-view-xT0B-f5z.js +0 -2
  255. package/dist/owletto/dist/assets/needs-you-list-3uMsWcDv.js +0 -2
  256. package/dist/owletto/dist/assets/new-AdGV6a8R.js +0 -2
  257. package/dist/owletto/dist/assets/new-BdtIhBpo.js +0 -2
  258. package/dist/owletto/dist/assets/new-BjGwX6s6.js +0 -2
  259. package/dist/owletto/dist/assets/new-D-iMjV74.js +0 -2
  260. package/dist/owletto/dist/assets/organization-qaIpEiQg.js +0 -2
  261. package/dist/owletto/dist/assets/peek-pane-content-CEsDVScl.js +0 -2
  262. package/dist/owletto/dist/assets/proposal-review-shell-C8ZfIAYn.js +0 -2
  263. package/dist/owletto/dist/assets/public-shell-ready-K2R8iXSI.js +0 -2
  264. package/dist/owletto/dist/assets/record-session-BrM9cdXu.js +0 -2
  265. package/dist/owletto/dist/assets/run-initiator-BKSgI1o0.js +0 -2
  266. package/dist/owletto/dist/assets/runs-k2NpbZm8.js +0 -2
  267. package/dist/owletto/dist/assets/runs-list-DUXRMkWN.js +0 -2
  268. package/dist/owletto/dist/assets/schema-value-wjqGxXhv.js +0 -3
  269. package/dist/owletto/dist/assets/settings-V0m5Om5j.js +0 -2
  270. package/dist/owletto/dist/assets/source-record-panels-BMut9YIA.js +0 -2
  271. package/dist/owletto/dist/assets/subDays-9s9OEl5t.js +0 -2
  272. package/dist/owletto/dist/assets/table-ZuYMOjVR.js +0 -2
  273. package/dist/owletto/dist/assets/view-card-DiHWlypr.js +0 -2
  274. package/dist/owletto/dist/assets/view-param-filters-DGKxSr7r.js +0 -2
  275. package/dist/owletto/dist/assets/views-access-required-HA-PiOwA.js +0 -2
@@ -1,2 +0,0 @@
1
- import{M as ne,n as Se,bo as we,cm as Le,V as ft,r as h,cn as pt,co as re,cp as yt,aw as bt,cq as jt,j as e,bQ as vt,bc as Ee,cr as Me,cs as Be,ct as Nt,B as Q,L as H,cu as Te,cv as wt,q as kt,cw as Ct,cx as St,cy as Lt,cz as Ye,cA as Et,cB as Mt,cC as Tt,Z as ee,bq as fe,br as pe,bs as ye,bt as be,bu as ie,cD as It,$ as Ve,cE as _t,bR as Rt,cF as At,cG as $t,cH as Pt,x as Ie,cI as Ot,c as Ue,u as Xe,cJ as Qe,cK as qe,cL as Ze,cM as Je,cN as Ht,cO as Wt,cP as et,aN as Dt,aP as Ft,b$ as Gt,ab as Kt,i as $,X as zt,s as Bt,cQ as Yt,cR as Vt,cS as Ut,m as W,cT as Xt,cU as Qt,cV as qt,a9 as Zt,cW as Ae,cX as te,ad as Jt,cY as en,a1 as tn,am as nn,cZ as sn,c_ as an,c$ as on,d0 as rn,d1 as ln,d2 as cn,d3 as dn,d4 as un,d5 as mn,d6 as hn,aC as gn,d7 as xn,d8 as fn,d9 as pn,da as yn,db as tt,bf as bn,dc as jn,bk as vn,d as nt,dd as Nn,de as wn,df as kn,dg as Cn,dh as Sn,di as Ln,dj as En,dk as Mn,w as Tn,dl as In,dm as _n,dn as Rn,at as An,aS as $n,au as Pn}from"./index-BoqrvLHQ.js";import{R as On,E as Hn,V as Wn,M as Dn}from"./view-card-DiHWlypr.js";import{M as Fn}from"./member-scope-gate-Cxg2zGQT.js";import{N as Gn}from"./needs-you-list-3uMsWcDv.js";import{V as $e}from"./missing-view-xT0B-f5z.js";import{H as je,n as ve,s as Kn,l as zn,b as Bn,a as Yn,G as Vn,c as Un}from"./entity-schema-graph-Cq96SJ3c.js";import{u as st}from"./use-automations-DfBtVzGa.js";import{f as Xn}from"./feed-event-kinds-BYuZCoU4.js";import{a as at}from"./list-skeleton-CH0qQBYk.js";import{u as Qn}from"./clients-Bf7ZgGro.js";import{u as qn}from"./client-activity-scopes-Aqdo6Pdr.js";import{g as Zn}from"./client-rows-Dd5YV8vn.js";import{P as Jn}from"./public-shell-ready-K2R8iXSI.js";function es({organizationId:t,ownerSlug:n,typeScope:s,entityScope:o}){const{orgContext:i}=ne(),{isMember:d,isLoading:a}=Se(),l=d&&!!t,c=s?we(s):void 0,u=!o&&!c,f=Le(l?n:null),w=ft({strict:!1}),x=h.useMemo(()=>pt(re(f.attentionCards),w),[f.attentionCards,w]),{feeds:g,pageIds:L}=yt(t,h.useMemo(()=>x.map(({item:R})=>R),[x])),r=h.useMemo(()=>[...x].sort((R,C)=>Number(L.has(C.item.id))-Number(L.has(R.item.id))),[x,L]),b=h.useMemo(()=>({approvalRunIds:new Set(r.flatMap(({item:R})=>R.approvalRunId!=null?[R.approvalRunId]:[])),eventIds:new Set(r.flatMap(({item:R,unreadIds:C})=>[...R.notificationId!=null?[R.notificationId]:[],...C]))}),[r]),v=R=>{R.length>0&&f.markManyRead.mutateAsync(R)},{data:p,isLoading:N,error:j}=bt(o?`/${n}/${jt(o)}`:`/${n}`,i),S=o?p?.entity:void 0,P=(o?S?.entity_type??we(o.split("/").at(-2)??""):c)==="$member",D=o!=null&&!N&&(j!=null||p?.entity==null),M=o?void 0:p?.counts,F=M?M.connections>0||M.agents>0:!1,_=l&&!a&&!N&&M!=null&&!F,G=o&&N?e.jsx(vt,{label:"Loading record…"}):D?e.jsx(Ee,{icon:Me,title:"Record not found",description:"It may have been deleted, or it may live in a workspace you can't access."}):S?e.jsx(On,{ownerSlug:n,entity:S,organizationId:t}):e.jsx(Hn,{organizationId:t,ownerSlug:n,hideSourceFilter:!0,scopedEntityTypes:c?[c]:void 0,pinned:u?{needsYou:f.isError?e.jsx("p",{role:"alert",className:"mb-4 text-sm text-destructive",children:"Could not load what needs you. Refresh to try again."}):e.jsx(Gn,{owner:n,entries:r,pageIds:L,onMarkRead:v,markPending:f.markManyRead.isPending}),rows:g.length>0?e.jsx(Be,{organizationId:t,feeds:g}):null,hidden:b}:void 0,toolbar:!0,emptyState:_?e.jsx(ts,{ownerSlug:n}):void 0});return e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:[o?null:e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Activity"}),P?e.jsx(Fn,{children:G}):G]})}function ts({ownerSlug:t}){return e.jsx("div",{className:"px-6",children:e.jsx(Ee,{icon:Nt,title:"Nothing to catch up on — yet",description:"No notifications here. Add a connector to bring in data, or bring your agent to Lobu and give it something to work with.",children:e.jsxs("div",{className:"mt-4 flex flex-wrap justify-center gap-2",children:[e.jsx(Q,{asChild:!0,children:e.jsxs(H,{to:"/$owner/connectors/create",params:{owner:t},children:[e.jsx(Te,{className:"mr-2 h-4 w-4"}),"Add a connector"]})}),e.jsx(Q,{asChild:!0,variant:"outline",children:e.jsxs(H,{to:"/$owner/agents/connect",params:{owner:t},children:[e.jsx(wt,{className:"mr-2 h-4 w-4"}),"Connect agent"]})})]})})})}const Pe={trigger:"runs on arrival",delivery:"delivers here"};function ns(t){const n=new Map,s=(o,i,d,a)=>{const l=Number(o);if(!Number.isInteger(l)||l<=0)return;const c=n.get(l)??[],u=c.find(f=>f.automation.automation_id===i.automation_id);if(u){if(u.reason===d)for(const f of a)u.eventTypes.includes(f)||u.eventTypes.push(f);return}c.push({automation:i,reason:d,eventTypes:[...a]}),n.set(l,c)};for(const o of t){for(const i of o.triggers??[]){const d=Array.isArray(i.event_types)?i.event_types.map(String):[];s(i.connection_id,o,"trigger",d)}s(o.delivery_target?.connection_id,o,"delivery",[])}return n}function ss(t){const n=new Map;for(const s of t){const o=n.get(s.connection_id)??[];o.push(s),n.set(s.connection_id,o)}return n}function as(t){const n=(s,o,i)=>`${s} ${s===1?o:i}`;return[n(t.feeds,"feed","feeds"),t.actions>0?n(t.actions,"action","actions"):null,t.automations>0?n(t.automations,"Automation","Automations"):null].filter(Boolean).join(" · ")}const ke="connector:",Oe=t=>`${ke}${t}`,os={event:"Zap",schedule:"CalendarClock",manual:"Hand"},is=0,rs=1,He=2;function ls(t,n){const s=new Map;for(const{kind:o,targets:i}of Xn(t?.feeds_schema?.[n]))for(const{entityType:d,creates:a}of i){const l=s.get(d)??{creates:!1,eventKinds:new Set};l.creates||=a,l.eventKinds.add(o),s.set(d,l)}return s}function cs(t,n){const s=new Map(t.connectorDefs.map(r=>[r.key,r])),o=new Map(t.connectorDefs.map(r=>[r.key,r.name])),i=new Map(t.connections.map(r=>[r.id,r])),d=ss(t.feeds),a=r=>`connection:${r}`,l=r=>`automation:${r}`,c=[],u=(r,b,v,p,N=!1)=>{c.push({id:`flow:${r}->${b}`,source:r,target:b,layoutReversed:N,data:{relationships:[],isSymmetric:!1,flow:{summary:v,details:p}}})},f=new Set(t.connections.map(r=>r.id));for(const r of t.connections){const b=new Map;for(const v of d.get(r.id)??[]){const p=ls(s.get(r.connector_key),v.feed_key);for(const[N,j]of p){const S=b.get(N)??{creates:!1,eventKinds:new Set};S.creates||=j.creates;for(const I of j.eventKinds)S.eventKinds.add(I);b.set(N,S)}}for(const[v,p]of b){const N=n.get(v);N&&u(a(r.id),N,p.creates?"creates records":"links records",[`From ${[...p.eventKinds].sort().join(", ")} events`])}}const w=ns(t.automations);for(const[r,b]of w)if(f.has(r))for(const{automation:v,reason:p,eventTypes:N}of b){const j=l(v.automation_id);p==="trigger"?u(a(r),j,Pe.trigger,N.length>0?[`On ${[...N].sort().join(", ")}`]:[]):u(j,a(r),Pe.delivery,[],!0)}const x=[];for(const r of t.automations){const b=l(r.automation_id),v=r.entity_type?n.get(r.entity_type):void 0;v&&u(v,b,"anchored here",[r.entity_name?`On ${r.entity_name}`:""].filter(Boolean));const p=kt(r,o,i),N=Ct(r),j=r.health==="degraded"?"Needs attention":void 0;x.push({id:b,lane:He,width:ve(`${p.does} ${j??""}`,p.when),height:je,data:{slug:b,label:p.does,icon:N?Oe(N):os[p.kind],isSystem:!1,badge:j,metaLabel:p.when,ref:{kind:"automation",automationId:r.automation_id}}})}const g=[];for(const r of t.metrics){const b=n.get(r.typeSlug);if(!b)continue;const v=`metric:${r.typeSlug}:${r.name}`;u(b,v,"measures",[r.description].filter(Boolean)),g.push({id:v,lane:He,width:ve(r.name,r.agg),height:je,data:{slug:v,label:r.name,icon:"ChartColumn",isSystem:!1,metaLabel:r.agg,ref:{kind:"metric",typeSlug:r.typeSlug,name:r.name}}})}return{nodes:[...t.connections.map(r=>{const b=St(r),v=Lt(r,s.get(r.connector_key)),p=as({feeds:d.get(r.id)?.length||r.feed_count,actions:r.operations_summary?.total??0,automations:w.get(r.id)?.length??0}),N=v.needsAttention?"Needs attention":r.device_label??void 0;return{id:a(r.id),lane:is,width:ve(`${b} ${N??""}`,p),height:je,data:{slug:a(r.id),label:b,icon:Oe(r.connector_key),isSystem:!1,badge:N,metaLabel:p,ref:{kind:"connection",connectorKey:r.connector_key,connectionId:r.id}}}}),...x,...g],edges:c}}function ot(t){switch(t.data.ref?.kind){case"connection":return"connections";case"automation":return"automations";case"metric":return"metrics";default:return"entities"}}function ds(t,n){const s=new Map;for(const c of t.nodes)(!c.data.organizationSlug||!s.has(c.data.slug))&&s.set(c.data.slug,c.id);const o=cs(n,s),{layers:i}=n,d=[...o.nodes,...t.nodes.map(c=>({...c,lane:rs}))].filter(c=>i[ot(c)]),a=new Set(d.map(c=>c.id)),l=[...t.edges,...o.edges].filter(c=>a.has(c.source)&&a.has(c.target));return{nodes:d,edges:l}}const We="__new__";function De(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function us({entityTypes:t,initialSource:n="",initialTarget:s="",onDone:o}){const i=h.useId(),d=`${i}-relationship`,a=`${i}-name`,l=`${i}-symmetric`,c=`${i}-source`,u=`${i}-target`,{orgContext:f}=ne(),{data:w=[]}=Ye(f),x=Et(),g=Mt(),[L,r]=h.useState(""),[b,v]=h.useState(""),[p,N]=h.useState(!1),[j,S]=h.useState(n),[I,P]=h.useState(s),[D,M]=h.useState(null),F=L===We,_=w.filter(C=>C.status==="active"&&C.purpose!==Tt&&(!C.organization_slug||C.organization_slug===f?.slug)),G=x.isPending||g.isPending,R=async()=>{if(M(null),!L)return M("Pick a relationship");if(!j||!I)return M("Pick both ends");try{let C=L;if(F){const K=b.trim();if(!K)return M("Name the relationship");const O=De(K);if(!O)return M("Name must contain a letter or number");C=(await x.mutateAsync({slug:O,name:K,is_symmetric:p})).relationship_type.slug,r(C)}await g.mutateAsync({slug:C,source_entity_type_slug:j,target_entity_type_slug:I}),o()}catch(C){M(C instanceof Error?C.message:"Could not save")}};return e.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-muted/30 p-3",children:[e.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:"Relationships are defined once for the workspace, then paired with the types they connect."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ee,{htmlFor:d,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"Relationship"}),e.jsxs(fe,{value:L,onValueChange:r,children:[e.jsx(pe,{id:d,className:"h-8 text-xs",children:e.jsx(ye,{placeholder:"Pick or define one"})}),e.jsxs(be,{children:[_.map(C=>e.jsx(ie,{value:C.slug,children:C.name||C.slug},C.slug)),_.length>0?e.jsx(It,{}):null,e.jsx(ie,{value:We,children:"Define a new one…"})]})]})]}),F?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ee,{htmlFor:a,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"Name"}),e.jsx(Ve,{id:a,value:b,onChange:C=>v(C.target.value),placeholder:"works at",className:"h-8 text-xs"}),b.trim()?e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Slug: ",e.jsx("code",{children:De(b)||"—"})]}):null]}),e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs(ee,{htmlFor:l,className:"text-xs font-normal",children:["Symmetric",e.jsx("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:"Both ends mean the same thing, like “connected with”."})]}),e.jsx(_t,{id:l,checked:p,onCheckedChange:N})]})]}):null,e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ee,{htmlFor:c,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"From"}),e.jsxs(fe,{value:j,onValueChange:S,children:[e.jsx(pe,{id:c,className:"h-8 text-xs",children:e.jsx(ye,{placeholder:"Type"})}),e.jsx(be,{children:t.map(C=>e.jsx(ie,{value:C.slug,children:C.label},C.slug))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ee,{htmlFor:u,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"To"}),e.jsxs(fe,{value:I,onValueChange:P,children:[e.jsx(pe,{id:u,className:"h-8 text-xs",children:e.jsx(ye,{placeholder:"Type"})}),e.jsx(be,{children:t.map(C=>e.jsx(ie,{value:C.slug,children:C.label},C.slug))})]})]}),D?e.jsx("p",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:D}):null,e.jsx(Rt,{onCancel:o,cancelDisabled:G,className:"[&>button]:h-7 [&>button]:px-3 [&>button]:text-xs",children:e.jsx(Q,{type:"button",size:"sm",onClick:R,disabled:G,children:G?"Saving…":"Add relationship"})})]})}const it=288,le=240,ce=720,ms=320,_e="lobu.schema-panel-width:v1";function de(t,n){if(!Number.isFinite(t))return it;const s=Math.max(le,Math.min(ce,n-ms));return Math.round(Math.min(s,Math.max(le,t)))}function hs(){const t=At(_e);if(t===null)return null;const n=Number.parseInt(t,10);return!Number.isFinite(n)||n<le||n>ce?null:n}function gs(t){$t(_e,String(Math.round(t)))}function xs(){Pt(_e)}const Fe={nodes:[],edges:[]};function fs(t,n,s){const{orgContext:o}=ne(),{data:i=[],isLoading:d,isError:a}=Ie(o),{data:l=[],isLoading:c,isError:u}=Ye(o),f=h.useMemo(()=>Kn(l,t),[l,t]),{data:w,isLoading:x,isError:g}=Ot(o),L=h.useMemo(()=>{const j=new Map(f.map(I=>[I.id,I.slug])),S={};for(const I of w??[]){const P=j.get(I.relationship_type_id);P&&(S[P]??=[]).push(I)}return S},[w,f]),r=h.useMemo(()=>({entityTypes:i,relationshipTypes:f,rulesBySlug:L,ownerSlug:t,targetAspect:n,flow:s}),[i,f,L,t,n,s]),[b,v]=h.useState(null),p=d||c||x,N=a||u||g;return h.useEffect(()=>{if(p||N)return;let j=!1;const S={targetAspect:r.targetAspect};let I;return r.flow?I=zn(ds(Bn(r),r.flow),S):I=Yn(r,S),I.then(P=>{j||v({graph:P,isError:!1})}).catch(()=>{j||v({graph:Fe,isError:!0})}),()=>{j=!0}},[r,p,N]),{graph:b?.graph??Fe,isLoading:!N&&!b,isError:N||b?.isError===!0}}function Ge(t){const n=t.ruleCount>1?` ×${t.ruleCount}`:"",s=typeof t.linkCount=="number"?` · ${t.linkCount.toLocaleString()}`:"";return`${t.label}${n}${s}`}const Ce={connections:"--chart-3",entities:"--chart-5",automations:"--chart-2",metrics:"--chart-4"};function ps(t,n){const s=t.nodes.some(a=>a.data.ref),o=new Map(t.nodes.map(a=>[a.id,a.data.label])),i=t.nodes.map(a=>({id:a.id,x:a.position.x+a.width/2,y:a.position.y+a.height/2,w:a.width,h:a.height,title:a.data.label,meta:a.data.metaLabel,icon:a.data.icon,badge:a.data.badge??a.data.organizationSlug,muted:a.data.isSystem,dimmed:n?!n.nodes.has(a.id):!1,accent:s?Ce[ot(a)]:void 0})),d=t.edges.map(a=>{const{relationships:l,isSymmetric:c,flow:u}=a.data;if(u)return{id:a.id,source:a.source,target:a.target,route:a.route??null,summary:u.summary,details:[u.summary,...u.details],directed:!0,dimmed:n?!n.edges.has(a.id):!1,ariaLabel:`${o.get(a.source)??a.source} to ${o.get(a.target)??a.target}: ${u.summary}`};const f=l.map(w=>w.label).join(", ");return{id:a.id,source:a.source,target:a.target,route:a.route??null,summary:l.length===1?Ge(l[0]):`${l.length} relationships`,details:l.map(Ge),directed:!c,dimmed:n?!n.edges.has(a.id):!1,ariaLabel:`${o.get(a.source)??a.source} ${c?"and":"to"} ${o.get(a.target)??a.target}: ${f}`}});return{boxes:i,edges:d}}const Ke=[{key:"connections",label:"Connections"},{key:"entities",label:"Entities"},{key:"automations",label:"Automations"},{key:"metrics",label:"Metrics"}],ys={count:"Count",count_distinct:"Distinct count",sum:"Sum",min:"Minimum",max:"Maximum"};function bs({metric:t,ownerSlug:n}){const s=(o,i)=>i.length>0?e.jsxs("section",{className:"flex flex-col gap-1.5",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:o}),e.jsx("ul",{className:"flex flex-col gap-1 text-sm",children:i.map(d=>e.jsxs("li",{children:[e.jsx("span",{className:"font-medium",children:d.name}),d.description?e.jsx("span",{className:"text-muted-foreground",children:` · ${d.description}`}):null]},d.name))})]}):null;return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"flex flex-col gap-1",children:[e.jsxs("p",{className:"text-sm",children:[ys[t.agg]??t.agg," of"," ",e.jsx("code",{className:"rounded bg-muted px-1 text-xs",children:t.eventSet})," ","events, per ",t.typeLabel]}),t.description?e.jsx("p",{className:"text-sm text-muted-foreground",children:t.description}):null]}),s("Data from",t.sources.map(o=>({name:o,description:""}))),s("Group by",t.dimensions),s("Segments",t.segments),e.jsx(Q,{asChild:!0,variant:"outline",size:"sm",className:"self-start",children:e.jsxs(H,{to:"/$owner/$entityType",params:{owner:n,entityType:t.typeSlug},children:["Open ",t.typeLabel]})})]})}function js({ownerSlug:t,metric:n,endpointOptions:s,canAuthor:o,mode:i,onModeChange:d}){const a=()=>d({kind:"index"});return i.kind==="metric"?n?e.jsx(bs,{metric:n,ownerSlug:t}):null:o&&i.kind==="new-relationship"?e.jsx(us,{entityTypes:s,initialSource:i.source,initialTarget:i.target,onDone:a},`${i.source??""}|${i.target??""}`):null}function vs(t){const{mode:n,canAuthor:s,onModeChange:o,isPeekOpen:i}=t,d=n.kind==="metric"?n.name:s&&n.kind==="new-relationship"?"New relationship":"Data map",a=h.useRef(null),l=JSON.stringify(n),c=h.useRef(l);return h.useEffect(()=>{c.current!==l&&(c.current=l,a.current?.focus({preventScroll:!0}))},[l]),e.jsx("aside",{style:{"--schema-panel-width":`${t.width}px`},className:$("order-first flex w-full shrink-0 flex-col lg:order-none lg:w-[var(--schema-panel-width)]",n.kind==="index"?"lg:absolute lg:top-0 lg:right-6 lg:z-10 lg:w-max lg:max-w-[calc(100%-3rem)] lg:max-h-[calc(100%-2rem)]":"bg-background lg:relative",i&&"lg:hidden"),children:e.jsxs("div",{className:$("flex min-h-0 flex-1 flex-col",n.kind!=="index"&&"lg:absolute lg:inset-0"),children:[e.jsxs("div",{className:n.kind==="index"?"sr-only":"flex h-11 shrink-0 items-center gap-1 border-b border-border px-3",children:[e.jsx("h2",{ref:a,tabIndex:-1,className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground outline-none",children:d}),n.kind!=="index"?e.jsx(Q,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground hover:text-foreground","aria-label":"Close",onClick:()=>o({kind:"index"}),children:e.jsx(zt,{className:"h-4 w-4"})}):null]}),e.jsx("div",{className:$("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto",n.kind==="index"?"pb-1":"p-4"),children:e.jsx(js,{...t})})]})})}function rt(t){const n=t.previousElementSibling,s=t.nextElementSibling;if(n instanceof HTMLElement&&s instanceof HTMLElement){const o=n.clientWidth+s.clientWidth;if(o>0)return o}return 0}function Ns({width:t,maxWidth:n,onResize:s,onCommit:o,onReset:i,className:d}){const[a,l]=h.useState(!1),c=h.useRef(0),u=x=>{const g=rt(x);return g>0?g:x.parentElement?.clientWidth??0},f=x=>{if(x.button!==0)return;const g=x.currentTarget;if(!g.parentElement)return;x.preventDefault(),c.current=u(g);const r=x.clientX,b=t;l(!0),g.setPointerCapture(x.pointerId);const v=S=>de(b-(S-r),c.current);let p=b;const N=S=>{p=v(S.clientX),s(p)},j=S=>{g.removeEventListener("pointermove",N),g.removeEventListener("pointerup",j),g.removeEventListener("pointercancel",j),l(!1),o(S.type==="pointercancel"?p:v(S.clientX))};g.addEventListener("pointermove",N),g.addEventListener("pointerup",j),g.addEventListener("pointercancel",j)},w=x=>{const g=u(x.currentTarget),L=r=>{x.preventDefault(),o(de(t+r,g))};x.key==="ArrowLeft"?L(16):x.key==="ArrowRight"?L(-16):x.key==="Home"&&(x.preventDefault(),i())};return e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize map panel","aria-valuenow":t,"aria-valuemin":le,"aria-valuemax":n,tabIndex:0,onPointerDown:f,onKeyDown:w,onDoubleClick:i,className:$("group hidden shrink-0 cursor-col-resize touch-none items-stretch justify-center px-1.5 outline-none lg:flex",a&&"cursor-col-resize",d),children:e.jsx("div",{className:$("w-px rounded-full bg-border transition-[background-color,width] group-hover:w-0.5 group-hover:bg-primary/60 group-focus-visible:w-0.5 group-focus-visible:bg-primary",a&&"w-0.5 bg-primary")})})}function ws({ownerSlug:t,renderToolbar:n}){const s=Ue(),o=Xe(),i=o?.item!=null,{orgContext:d}=ne(),{isAdmin:a}=Qe(d.organizationId),[l,c]=h.useState({connections:!0,entities:!0,automations:!0,metrics:!0}),[u,f]=h.useState({kind:"index"}),w=o?.close,x=h.useCallback(m=>{m.kind!=="index"&&i&&w?.(),f(m)},[i,w]),[g,L]=h.useState(),r=h.useRef(null),b=h.useCallback(m=>{if(r.current?.disconnect(),r.current=null,!m||typeof ResizeObserver>"u")return;const y=()=>{if(!m.clientWidth||!m.clientHeight)return;const A=Math.round(m.clientHeight/m.clientWidth*10)/10;L(E=>E===A?E:A)};y();const T=new ResizeObserver(y);T.observe(m),r.current=T},[]),v=d.organizationId,p=qe(v),N=Ze(v),j=Je(v),S=st(v??void 0),{data:I}=Ie(d),P=h.useMemo(()=>I?.filter(m=>Ht(m,t)),[I,t]),D=h.useMemo(()=>(P??[]).flatMap(m=>Object.entries(m.metrics_config?.measures??{}).map(([y,T])=>({typeSlug:m.slug,name:y,agg:T.agg,description:T.description}))),[P]),M=p.isLoading||N.isLoading||j.isLoading||S.isLoading,F=h.useMemo(()=>M?null:{connections:p.data??[],feeds:N.data??[],connectorDefs:j.data??[],automations:S.data??[],metrics:D,layers:l},[M,p.data,N.data,j.data,S.data,D,l]),{graph:_,isLoading:G,isError:R}=fs(t,g,F),C=G||M,K={connections:!M&&(p.data??[]).length===0,entities:!1,automations:!M&&(S.data??[]).length===0,metrics:!M&&D.length===0},O=u.kind==="metric"?u:null,B=h.useMemo(()=>{if(!O)return null;const m=`metric:${O.typeSlug}:${O.name}`,y=_.edges.find(E=>E.target===m);if(!y)return null;const T=y.source,A=_.edges.filter(E=>E.target===T&&_.nodes.find(Y=>Y.id===E.source)?.data.ref?.kind==="connection");return{typeId:T,nodes:new Set([m,T,...A.map(E=>E.source)]),edges:new Set([y.id,...A.map(E=>E.id)]),sources:A.map(E=>_.nodes.find(Y=>Y.id===E.source)?.data.label??E.source)}},[O,_]),{boxes:se,edges:ue}=h.useMemo(()=>ps(_,B),[_,B]),me=h.useMemo(()=>{if(!O)return null;const m=P?.find(A=>A.slug===O.typeSlug),y=m?.metrics_config,T=y?.measures?.[O.name];return!m||!T?null:{name:O.name,typeSlug:m.slug,typeLabel:m.name||m.slug,agg:T.agg,eventSet:T.eventSet,description:T.description,dimensions:Object.entries(y?.dimensions??{}).map(([A,E])=>({name:A,description:E.description})),segments:Object.entries(y?.segments??{}).map(([A,E])=>({name:A,description:E.description})),sources:B?.sources??[]}},[O,P,B]),V=h.useMemo(()=>new Map(_.nodes.map(m=>[m.id,m.data.slug])),[_.nodes]),U=h.useMemo(()=>new Map(_.nodes.flatMap(m=>m.data.ref?[[m.id,m.data.ref]]:[])),[_.nodes]),X=h.useMemo(()=>{const m=new Map;for(const y of _.nodes)y.data.ref||(!y.data.organizationSlug||!m.has(y.data.slug))&&m.set(y.data.slug,{slug:y.data.slug,label:y.data.label});return[...m.values()]},[_.nodes]),J=h.useCallback(m=>{const y=U.get(m);if(y?.kind==="connection"){s({to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:t,connectorKey:y.connectorKey,connectionId:String(y.connectionId)},search:{}});return}if(y?.kind==="metric"){x({kind:"metric",typeSlug:y.typeSlug,name:y.name});return}if(y?.kind==="automation"){s({to:"/$owner/automations/$automationId",params:{owner:t,automationId:y.automationId},search:{view:"activity",run_id:void 0}});return}s(Wt(t,V.get(m)??m))},[s,t,V,U,x]),he=h.useCallback((m,y)=>{U.has(m)||U.has(y)||x({kind:"new-relationship",source:V.get(m)??m,target:V.get(y)??y})},[V,U,x]),ge=h.useCallback(m=>{const y=m.startsWith(ke)?m.slice(ke.length):null;if(!y)return e.jsx(et,{icon:m||null,className:"h-4 w-4"});const T=Dt(y,j.data??[],{name:p.data?.find(A=>A.connector_key===y)?.connector_name??y});return e.jsx(Ft,{plain:!0,icon:T.icon,iconUrl:T.iconUrl,name:T.name,faviconDomain:T.faviconDomain})},[j.data,p.data]),ae=u.kind==="metric"||a&&u.kind!=="index",[oe,q]=h.useState(()=>hs()),k=oe??it,[z,dt]=h.useState(null),xe=h.useRef(null),ut=h.useCallback(m=>{if(xe.current?.disconnect(),xe.current=null,!m||typeof ResizeObserver>"u")return;const y=m.children[1];if(!y)return;const T=()=>{const E=rt(y);E>0&&dt(Y=>Y===E?Y:E)};T();const A=new ResizeObserver(T);A.observe(m),xe.current=A},[]),Re=z===null?k:de(k,z),mt=z===null?ce:de(ce,z),ht=h.useCallback(m=>{q(m),gs(m)},[]),gt=h.useCallback(()=>{q(null),xs()},[]);if(C)return e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[n(null),e.jsx(Vn,{label:"Loading data map",fill:!0})]});if(R)return e.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[n(null),e.jsx(Gt,{label:"data map"})]});const xt=e.jsxs("fieldset",{className:$("m-0 flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 border-0 p-0 text-sm",ae&&"hidden lg:flex"),children:[e.jsx("legend",{className:"sr-only",children:"Show on the map"}),Ke.map(({key:m,label:y})=>{const T=`memory-map-show-${m}`,A=l[m]&&!K[m]&&Ke.filter(({key:E})=>l[E]&&!K[E]).length===1;return e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Kt,{id:T,checked:l[m],disabled:A,style:{borderColor:`var(${Ce[m]})`,backgroundColor:l[m]?`var(${Ce[m]})`:void 0},onCheckedChange:E=>c(Y=>({...Y,[m]:E===!0}))}),e.jsx("label",{htmlFor:T,className:"inline-flex cursor-pointer select-none items-center",children:y})]},m)})]});return e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[n(xt),e.jsxs("div",{ref:ut,className:"relative flex min-h-0 min-w-0 flex-1 flex-col gap-3 lg:-mr-6 lg:-mb-8 lg:flex-row lg:gap-0",children:[e.jsx("div",{className:$("flex min-w-0 flex-1 flex-col lg:pb-8",ae&&"hidden lg:flex"),children:e.jsx("div",{ref:b,className:"min-h-[420px] min-w-0 flex-1 overflow-hidden rounded-lg bg-background",children:e.jsx(Un,{boxes:se,edges:ue,label:"Data map",onOpenBox:J,openLabel:m=>`Open ${m.title}`,onConnect:a?he:void 0,renderIcon:ge})})}),e.jsx(Ns,{width:Re,maxWidth:mt,onResize:q,onCommit:ht,onReset:gt,className:i||u.kind==="index"?"lg:hidden":void 0}),e.jsx(vs,{width:Re,metric:me,ownerSlug:t,endpointOptions:X,canAuthor:a,mode:u,onModeChange:x,isPeekOpen:i})]})]})}const ze=12,ks=5e3;function Cs(t,n){const s=!!t&&!!n.organizationId&&(n.enabled??!0),o=Bt({enabled:s}),{data:i}=o,d=i??[],a=h.useMemo(()=>d.map(g=>g.agentId),[d]),{threads:l,isLoading:c,isError:u}=Yt(t,a,{enabled:s&&a.length>0,limit:ze}),f=qn({enabled:s,limit:ze,excludeCommandClients:!1,organizationId:n.organizationId,refetchInterval:g=>g?ks:!1}),w=n.organizationId?f.data:void 0;return{items:h.useMemo(()=>[...l.map(g=>({kind:"conversation",at:g.updatedAt,thread:g})),...(w??[]).map(g=>({kind:"mcp",at:g.lastCallAt,conversation:g}))].sort((g,L)=>L.at-g.at),[w,l]),agents:d,isLoading:s&&(o.isLoading||c||f.isLoading),isError:o.isError||u||f.isError}}const Z=(t,n)=>t?{...t,label:n}:void 0;function Ss(t,n){const s=Vt(t,n,[],!1),o=new Map(s.map(c=>[c.key,c])),i=[Z(o.get("agent"),"Connect Claude Code, Codex, or Cursor"),Z(o.get("connection"),"Connect GitHub, your browser, or shell")].filter(c=>c!=null),d=[Z(o.get("connection"),"Connect Gmail or Calendar"),Z(o.get("agent"),"Connect Claude, ChatGPT, or Codex")].filter(c=>c!=null),a=[Z(o.get("connection"),"Connect Gmail, Calendar, or LinkedIn"),Z(o.get("agent"),"Connect Claude, ChatGPT, or Codex")].filter(c=>c!=null),l=(c,u,f,w,x,g)=>({id:c,eyebrow:u,title:f,description:w,icon:x,steps:g,next:g.find(L=>!L.complete)});return[l("coding-memory","For developers","Give your coding agent context","Connect Claude Code, Codex, or Cursor, give it GitHub, your browser, or shell, then let it ask what you decided instead of starting from zero.","code",i),l("inbox-crm","For customer teams","Turn your inbox into a CRM","Connect Gmail and Calendar. Lobu keeps people, companies, and every thread in one live model; your agent turns it into a working CRM.","crm",d),l("personal-network","For you","Remember everyone you meet","Connect Gmail, Calendar, or LinkedIn. Lobu builds a private people graph, and your agent reminds you when it's time to reconnect.","network",a)]}const Ls={code:qt,crm:Qt,network:Xt};function Es({owner:t,onSkip:n}){const s=Ut(t,{requireEntityTypes:!1});if(!s.ready||!s.counts)return e.jsx(Ts,{});const o=Ss(t,s.counts);return e.jsxs("section",{"aria-label":"Start here",className:"flex min-w-0 flex-col gap-4 pt-2 pb-6",children:[e.jsxs("div",{className:"flex flex-col gap-1 px-1",children:[e.jsx("p",{className:"text-[11px] font-medium tracking-wide text-muted-foreground uppercase",children:"Start here"}),e.jsx("h2",{className:"text-xl font-semibold tracking-tight",children:"Where do you want to start?"}),e.jsx("p",{className:"max-w-2xl text-sm leading-6 text-muted-foreground",children:"Lobu is a live context layer for your agents. Connect the tools you work in; ChatGPT, Claude, Codex, and your own agents resume from the same context. Pick a starting point; everything lands in the same workspace, and you can combine them later."})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:o.map((i,d)=>e.jsx(Ms,{recipe:i,className:$(d===o.length-1&&"md:col-span-2 xl:col-span-1")},i.id))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 px-1 text-xs text-muted-foreground",children:[e.jsx("span",{children:"None of these?"}),e.jsx(H,{to:"/$owner/connectors/create",params:{owner:t},className:"underline decoration-border underline-offset-4 transition-colors hover:text-foreground",children:"Browse all connectors"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:n,className:"underline decoration-border underline-offset-4 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:"Skip for now"})]})]})}function Ms({recipe:t,className:n}){const s=Ls[t.icon];return e.jsxs("article",{className:$("flex min-w-0 flex-col gap-3 rounded-lg border bg-card p-4",n),children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border bg-muted text-muted-foreground",children:e.jsx(s,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[10px] font-medium tracking-wide text-muted-foreground uppercase",children:t.eyebrow}),e.jsx("h3",{className:"text-sm leading-5 font-semibold",children:t.title})]})]}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:t.description}),e.jsx("ol",{className:"flex flex-col gap-1",children:t.steps.map(o=>{const i=o===t.next;return e.jsx("li",{children:o.complete?e.jsxs("span",{className:"flex min-h-7 items-center gap-2 px-1.5 text-xs text-muted-foreground",children:[e.jsx(Zt,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0",children:o.label})]}):i?e.jsxs(H,{...o.link,"aria-current":"step",className:$("flex min-h-9 items-center gap-2 rounded-md border border-primary/30 bg-primary/10 px-2 text-xs font-medium text-foreground transition-colors","hover:bg-primary/15 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"),children:[e.jsx(Ae,{className:"h-3.5 w-3.5 shrink-0 text-primary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1",children:o.label}),e.jsx(te,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"})]}):e.jsxs("span",{className:"flex min-h-7 items-center gap-2 px-1.5 text-xs text-muted-foreground",children:[e.jsx(Ae,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0",children:o.label})]})},o.key)})})]})}function Ts(){return e.jsxs("section",{"aria-label":"Start here",className:"flex min-w-0 flex-col gap-4 pt-2 pb-6",children:[e.jsxs("div",{className:"flex flex-col gap-2 px-1",children:[e.jsx(W,{className:"h-3 w-16"}),e.jsx(W,{className:"h-6 w-full max-w-lg"}),e.jsx(W,{className:"h-4 w-full max-w-xl"})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:[0,1,2].map(t=>e.jsxs("div",{className:$("flex flex-col gap-3 rounded-lg border p-4",t===2&&"md:col-span-2 xl:col-span-1"),children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(W,{className:"h-8 w-8 rounded-md"}),e.jsxs("div",{className:"flex flex-1 flex-col gap-1",children:[e.jsx(W,{className:"h-3 w-20"}),e.jsx(W,{className:"h-4 w-40"})]})]}),e.jsx(W,{className:"h-3 w-full"}),e.jsx(W,{className:"h-3 w-5/6"}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(W,{className:"h-6 w-full"}),e.jsx(W,{className:"h-6 w-full"}),e.jsx(W,{className:"h-6 w-full"})]})]},t))})]})}function Is({owner:t}){const{orgContext:n}=ne(),s=Jt(),o=Ie(n),i=s.isError||o.isError,d=s.data?.flatMap(a=>{if(a.visibility!=="public"||a.slug===t)return[];const l=(o.data??[]).filter(w=>!en(w)&&(w.organization_id===a.id||w.organization_slug===a.slug));if(!l.length)return[];const c=l.map(w=>w.name).sort((w,x)=>w.localeCompare(x)),u=c.slice(0,3);c.length>u.length&&u.push("more");const f=a.description?.trim()||`Includes ${new Intl.ListFormat("en",{style:"long",type:"conjunction"}).format(u)}.`;return[{...a,description:f}]});return!i&&!d?.length?null:e.jsxs("section",{"aria-label":"Public workspaces",className:"mt-6 space-y-3 pb-6",children:[e.jsxs("div",{className:"space-y-1 px-1",children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"Explore public workspaces"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Browse what others have shared. Open a workspace to look around."})]}),i?e.jsxs("div",{role:"alert",className:"px-1 text-sm text-muted-foreground",children:["Public workspaces could not be loaded."," ",e.jsx("button",{type:"button",onClick:()=>void Promise.all([s.refetch(),o.refetch()]),className:"rounded underline underline-offset-4 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:"Try again"})]}):e.jsx("ul",{className:"grid gap-x-6 sm:grid-cols-2",children:d?.map(a=>{const l=tn(a.slug);return e.jsx("li",{className:"min-w-0",children:e.jsxs("a",{href:l.kind==="cross-host"?l.href:l.to,className:"group flex min-h-16 items-center gap-3 rounded-lg px-3 py-3 transition-colors hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted text-muted-foreground",children:a.logo?e.jsx("img",{src:a.logo,alt:"",referrerPolicy:"no-referrer",className:"h-full w-full object-cover"}):e.jsx(nn,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block text-sm font-medium",children:a.name}),e.jsx("span",{className:"mt-0.5 block text-xs leading-5 text-muted-foreground",children:a.description})]}),e.jsx(te,{className:"h-4 w-4 shrink-0 text-muted-foreground group-hover:text-foreground","aria-hidden":"true"})]})},a.id)})})]})}const _s={automation:tt,connection:Te,agent:yn,"entity-type":Me},Rs={automation:{to:"/$owner",search:{section:"automation"}},connection:{to:"/$owner/connectors",search:{}},agent:{to:"/$owner",search:{section:"agent"}},"entity-type":{to:"/$owner",search:{section:"entity-type"}}},Ne={automation:{text:"No Automations yet.",action:{to:"/$owner/automations/new",label:"Start with a template"}},connection:{text:"No connections yet.",action:{to:"/$owner/connectors/create",label:"Connect a source"}},agent:{text:"No agents connected yet.",action:{to:"/$owner/agents/connect",label:"Connect an agent"}},"entity-type":{text:"No entity types yet.",action:{to:"/$owner/entity-types/new",label:"Create one"}}};function lt({owner:t,organizationId:n,section:s,layout:o}){const{isMember:i,isPublic:d,isLoading:a}=Se(t),l=d&&!i&&!a,[c,u]=h.useState(""),f=sn({slug:t}),w=k=>k.flatMap(z=>z.href?[z]:w(z.children)),x=(f.data??[]).flatMap(k=>w(k.items)),g=Le(l?null:t),L=re(g.attentionCards).length,r=st(n??void 0,void 0,{includeDetails:!1}),b=qe(n),v=Ze(n),{data:p=[],isLoading:N}=Je(n),j=Cs(t,{organizationId:n,enabled:!l}),S=Qn(null,{enabled:!l}),{visible:I,isTypesLoading:P}=an(t),D=h.useMemo(()=>on({owner:t,automations:r.data??[],connections:b.data??[],feeds:v.data??[],connectors:new Map(p.map(k=>[k.key,k])),recentItems:j.items,roster:j.agents,clientGroups:Zn(S.data??[]).filter(k=>k.connected),entityTypes:I,attention:re(g.attentionCards),now:Date.now()}),[t,r.data,b.data,v.data,p,j.items,j.agents,S.data,I,g.attentionCards]),M=c.trim().toLowerCase(),F=M.length>0,_=x.filter(k=>!M||k.label.toLowerCase().includes(M)),G=h.useMemo(()=>rn(D.filter(k=>!M||k.name.toLowerCase().includes(M)),{filtering:F,expanded:s!=null,kinds:s?[s]:l?["automation","connection","entity-type"]:["automation","connection","agent","entity-type"]}),[D,M,F,l,s]),R=ln(l?null:n,cn()),C={automation:r.isLoading,connection:b.isLoading||v.isLoading||N,agent:!l&&(j.isLoading||S.isLoading),"entity-type":P},K=n==null||r.isLoading||b.isLoading||!l&&(j.isLoading||g.isLoading),O=f.isError||r.isError||b.isError||v.isError||j.isError||g.isError,B=G.every(k=>k.count===0)&&R.length===0,se=`lobu:start-dismissed:${t}`,[ue,me]=h.useState(()=>{try{return window.localStorage.getItem(se)==="1"}catch{return!1}}),V=()=>{me(!0);try{window.localStorage.setItem(se,"1")}catch{}},U=D.some(k=>k.kind!=="entity-type"),X=o==="table",J=X&&i&&!K&&!F&&!l&&!ue&&!U&&x.length===0&&!f.isLoading&&R.length===0,he=X&&!s&&!F&&x.length>0,ge=X&&!s&&_.length>0,ae=D.filter(k=>k.problem).length,oe=e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Home"}),q=k=>e.jsx($s,{title:oe,owner:t,organizationId:n,layout:o,layerToggles:k,query:c,onQueryChange:u,canAdd:i&&!l});return e.jsxs("section",{"aria-label":"Home",className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[X?J?oe:q(null):null,X?e.jsxs(e.Fragment,{children:[O&&!J?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"Some of Home could not be loaded. Refresh to try again."}):null,ge?e.jsxs(e.Fragment,{children:[!l&&L>0?e.jsxs(H,{to:"/$owner/events",params:{owner:t},className:"flex min-h-11 items-center justify-between gap-3 rounded-md border border-border px-3 py-2 text-sm font-medium hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[e.jsxs("span",{children:[L," ",L===1?"item needs":"items need"," your attention"]}),e.jsx(te,{"aria-hidden":!0,className:"size-4 shrink-0"})]}):null,e.jsxs("nav",{"aria-label":"Workspace destinations",className:"pb-4",children:[e.jsx("h2",{className:"mb-2 text-sm font-medium text-muted-foreground",children:"Open your workspace"}),e.jsx("ul",{className:"grid gap-x-6 sm:grid-cols-2",children:_.map(k=>{const z=dn(k);return e.jsx("li",{className:"min-w-0 border-b border-border/60",children:e.jsxs(un,{item:k,active:!1,className:"group flex min-h-16 min-w-0 items-center gap-3 rounded-md px-2 py-3 hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[e.jsx(z,{"aria-hidden":!0,className:"size-5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1 break-words text-base font-medium",children:k.label}),e.jsx(te,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"})]})},k.id)})})]})]}):null,e.jsx(As,{pending:f.isLoading,fold:he,problems:ae,children:K&&B?e.jsx(ct,{}):B&&F?_.length?null:e.jsx(Ee,{icon:mn,title:"Nothing matches",description:"Nothing on Home matches this filter."}):J?e.jsx(Es,{owner:t,onSkip:V}):e.jsxs(e.Fragment,{children:[R.length>0?e.jsx("section",{"aria-label":"This page",className:"space-y-1",children:e.jsx(Be,{organizationId:n,feeds:R})}):null,G.map(k=>C[k.kind]?e.jsx(Os,{label:k.label},k.kind):e.jsx(Hs,{owner:t,organizationId:n,section:k,allRows:s===k.kind,connectorDefinitions:p},k.kind))]})}),!F&&!s&&!K&&!O&&B&&x.length===0&&!S.isError?e.jsx(Is,{owner:t}):null]}):e.jsx(ws,{ownerSlug:t,renderToolbar:q})]})}function As({pending:t,fold:n,problems:s,children:o}){const[i,d]=h.useState(!1);return t?e.jsx(ct,{}):n?e.jsxs("details",{open:i,onToggle:a=>d(a.currentTarget.open),className:"border-t border-border pt-3",children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-medium text-muted-foreground",children:["Workspace status and setup",s>0?e.jsxs("span",{className:"ml-2 text-destructive",children:[s," ",s===1?"issue":"issues"," to review"]}):null]}),i?e.jsx("div",{className:"space-y-4 pt-4",children:o}):null]}):o}function $s({title:t,owner:n,organizationId:s,layout:o,layerToggles:i,query:d,onQueryChange:a,canAdd:l}){const c=[{key:"table",label:"Table",Icon:xn,search:{}},{key:"graph",label:"Graph",Icon:fn,search:{layout:"graph"}}];return e.jsxs("header",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[t,e.jsxs("nav",{"aria-label":"Home views",className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-2",children:[e.jsx("fieldset",{className:"flex items-center rounded-md border p-0.5","aria-label":"Home layout",children:c.map(({key:u,label:f,Icon:w,search:x})=>{const g=o===u;return e.jsx(Q,{asChild:!0,variant:"ghost",size:"sm",className:$("h-7 px-2",g&&"bg-accent text-accent-foreground"),children:e.jsx(H,{to:"/$owner",params:{owner:n},search:x,replace:!0,"aria-label":f,"aria-current":g?"page":void 0,title:f,children:e.jsx(w,{className:"h-4 w-4"})})},u)})}),i,e.jsxs("div",{className:"ml-auto flex min-w-0 flex-1 items-center justify-end gap-2",children:[o==="table"?e.jsxs("div",{className:"relative min-w-40 max-w-64 flex-1",children:[e.jsx(pn,{"aria-hidden":"true",className:"absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Ve,{type:"search","aria-label":"Filter list",placeholder:"Filter…",maxLength:512,value:d,onChange:u=>a(u.target.value),className:"pl-9"})]}):null,l?e.jsx(Ps,{owner:n,organizationId:s}):null]})]})]})}function Ps({owner:t,organizationId:n}){const{isAdmin:s}=Qe(n??void 0),o=[{to:"/$owner/automations/new",label:"Automation",Icon:tt},{to:"/$owner/connectors/create",label:"Connection",Icon:Te},{to:"/$owner/agents/new",label:"Agent",Icon:En},...s?[{to:"/$owner/entity-types/new",label:"Entity type",Icon:Me}]:[]];return e.jsxs(wn,{children:[e.jsx(kn,{asChild:!0,children:e.jsxs(Q,{size:"sm",children:[e.jsx(Cn,{className:"mr-1.5 h-4 w-4"}),"Add",e.jsx(Sn,{className:"ml-1 h-3.5 w-3.5"})]})}),e.jsx(Ln,{align:"end",className:"w-44",children:o.map(({to:i,label:d,Icon:a})=>e.jsx(Mn,{asChild:!0,children:e.jsxs(H,{to:i,params:{owner:t},children:[e.jsx(a,{}),d]})},i))})]})}function ct(){return e.jsx("div",{role:"status","aria-label":"Loading Home",children:[0,1,2].map(t=>e.jsxs("div",{children:[e.jsx("div",{className:"px-1 pt-4 pb-1.5",children:e.jsx(W,{className:"h-4 w-24"})}),e.jsx("div",{className:"divide-y overflow-hidden rounded-lg border",children:[0,1,2].map(n=>e.jsx(at,{},n))})]},t))})}function Os({label:t}){return e.jsxs("section",{"aria-label":t,className:"min-w-0",children:[e.jsx("div",{className:"px-1 pt-4 pb-1.5",children:e.jsx("h2",{className:"text-sm font-semibold",children:t})}),e.jsx("div",{role:"status","aria-label":`Loading ${t}`,className:"divide-y overflow-hidden rounded-lg border",children:[0,1,2].map(n=>e.jsx(at,{},n))})]})}function Hs({owner:t,organizationId:n,section:s,allRows:o,connectorDefinitions:i}){const d=Rs[s.kind];return e.jsxs("section",{"aria-label":s.label,className:"min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-2 px-1 pt-4 pb-1.5",children:[e.jsx("h2",{className:"text-sm font-semibold",children:o?e.jsxs(e.Fragment,{children:[s.label,e.jsx("span",{className:"ml-1.5 font-normal text-muted-foreground tabular-nums",children:s.count})]}):e.jsx(H,{to:d.to,params:{owner:t},search:d.search,className:"underline-offset-4 hover:underline",children:s.label})}),o?e.jsxs(H,{to:"/$owner",params:{owner:t},search:{},className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",children:[e.jsx(hn,{"aria-hidden":"true",className:"h-3 w-3"}),"All sections"]}):s.count>s.rows.length?e.jsxs(H,{to:d.to,params:{owner:t},search:d.search,className:"text-xs text-muted-foreground hover:text-foreground",children:["See all ",s.count," →"]}):null]}),s.count===0?e.jsxs("p",{className:"px-2 py-2 text-xs text-muted-foreground",children:[Ne[s.kind].text," ",e.jsxs(H,{to:Ne[s.kind].action.to,params:{owner:t},className:"underline decoration-border underline-offset-4 transition-colors hover:text-foreground",children:[Ne[s.kind].action.label," →"]})]}):null,e.jsx("ul",{className:$("overflow-hidden rounded-lg border",s.rows.length===0&&"hidden"),children:s.rows.map(a=>e.jsxs("li",{className:$("flex min-w-0 items-center border-b last:border-b-0",gn),children:[e.jsx(Ws,{owner:t,organizationId:n,source:a,connectorDefinitions:i}),a.attention.length>0?e.jsx(Ds,{owner:t,source:a}):null]},a.key))})]})}function Ws({owner:t,organizationId:n,source:s,connectorDefinitions:o}){const i=_s[s.kind];return e.jsx(Fs,{owner:t,organizationId:n,source:s,className:$(vn,"min-w-0 flex-1"),children:e.jsx(bn,{mark:s.kind==="entity-type"?e.jsx(et,{icon:s.icon??null,className:"h-4 w-4 text-muted-foreground"}):e.jsx(jn,{source:s.mark,connectorDefinitions:o,label:s.name,fallback:e.jsx(i,{className:"h-4 w-4 text-muted-foreground"})}),name:s.name,tone:s.attention.length>0?"amber":s.problem?"destructive":null,details:s.status,at:s.at})})}function Ds({owner:t,source:n}){const s=n.attention.length,o=nt(Nn(t,n));return e.jsxs(H,{to:o.pathname,search:o.search,className:"mr-3 shrink-0 rounded-full bg-amber-500/10 px-2 py-0.5 text-xs font-medium text-amber-700 transition-colors hover:bg-amber-500/20 dark:text-amber-400",children:[s," need",s===1?"s":""," you"]})}function Fs({owner:t,organizationId:n,source:s,className:o,children:i}){const d=Xe(),{open:a}=s,l=nt(a.href),c=u=>{if(!(!d||a.kind==="entity-type"||u.metaKey||u.ctrlKey||u.shiftKey||u.altKey||u.button!==0)&&!(a.kind==="connection"&&!n)){if(u.preventDefault(),a.kind==="automation"||a.kind==="agent"){d.open({href:a.href,title:s.name,owner:t});return}d.open({href:a.href,title:s.name,key:s.key,connectorPanel:{section:"data",connectorKey:a.connectorKey,connectionId:a.connectionId,organizationId:n,ownerSlug:t}})}};return e.jsx(H,{to:l.pathname,search:l.search,className:o,onClick:c,children:i})}function Gs(t){return t.section||t.layout==="graph"?e.jsx(lt,{...t}):e.jsx(Ks,{...t})}function Ks(t){const{owner:n}=t,s=Ue(),o=Se(n),i=Tn({slug:n}),d=Le(o.isMember?n:null),a=re(d.attentionCards).length,l=In(i.data??[]);return i.data===void 0?i.isError?e.jsx($e,{error:i.error,onRetry:()=>void i.refetch()}):e.jsxs("div",{role:"status","aria-label":"Loading Home",className:"space-y-4",children:[e.jsx(W,{className:"h-8 w-24"}),e.jsx(W,{className:"h-64 w-full"})]}):l.length===0&&!i.isError?e.jsx(lt,{...t}):e.jsxs("section",{"aria-label":"Home",className:"flex min-w-0 flex-col gap-4",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Home"}),i.isError?e.jsx($e,{error:i.error,onRetry:()=>void i.refetch()}):null,a>0&&o.isMember?e.jsxs(H,{to:"/$owner/events",params:{owner:n},className:"flex min-h-11 items-center justify-between gap-3 rounded-md border px-3 py-2 text-sm font-medium hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[e.jsxs("span",{children:[a," ",a===1?"item needs":"items need"," your attention"]}),e.jsx(te,{"aria-hidden":!0,className:"size-4 shrink-0"})]}):null,e.jsx("div",{className:"grid min-w-0 gap-4 lg:grid-cols-2",children:l.map(c=>{const u=`/${n}/data${_n(c.key)}`;return e.jsx(Wn,{view:c,orgSlug:n,scope:{},open:()=>void s({href:u})},c.key)})})]})}function sa({owner:t,search:n,entityScope:s,home:o=!1}){const i=typeof n.type=="string"&&n.type.trim()?we(n.type.trim()):void 0,d=n.section==="automation"||n.section==="agent"||n.section==="entity-type"?n.section:void 0,a=n.layout==="graph"?"graph":"table",l=Object.entries(n).some(([u,f])=>(Rn.includes(u)||u.startsWith("clf_"))&&f!=null&&f!==""),c=o&&!l&&!i&&!s;return e.jsxs(An,{className:"gap-6 pt-2.5 pb-8",children:[e.jsx(Jn,{}),e.jsx($n,{owner:t,children:u=>e.jsx(Dn,{organizationId:u.organizationId,isWorkspaceLoading:u.isWorkspaceLoading,children:e.jsx(Pn,{wide:o,className:$("flex min-h-0 min-w-0 flex-1 flex-col",c&&a==="graph"&&"max-w-none"),children:c?e.jsx(Gs,{owner:u.ownerSlug,organizationId:u.organizationId,section:d,layout:a}):e.jsx(es,{organizationId:u.organizationId,ownerSlug:u.ownerSlug,typeScope:i,entityScope:s})})})})]})}export{sa as A};
2
- //# sourceMappingURL=activity-route-view-msesKUwn.js.map
@@ -1,4 +0,0 @@
1
- import{j as t,L as h,eY as f,a4 as R,at as C,au as A,dt as M,bd as $,du as O,dv as S,G as _,r as U,i5 as u,B as v,A as y}from"./index-BoqrvLHQ.js";import{C as E}from"./connector-page-shell-an3SYLim.js";import{C as g}from"./copy-button-Xhh7ZnjO.js";import{u as B}from"./clients-Bf7ZgGro.js";import{g as G,c as H}from"./client-rows-Dd5YV8vn.js";const D="https://raw.githubusercontent.com/lobu-ai/lobu/main/claude-plugin/skills/lobu/SKILL.md";function d(e){try{const a=new URL(e).hostname;return a==="lobu.ai"||a.endsWith(".lobu.ai")}catch{return!1}}function x(e,a){const n=`npx @lobu/cli@latest connect ${e}`;return d(a)?n:`${n} --url ${a}`}function b(e,a){return`npx @lobu/cli@latest connect ${e} --url ${a}`}const N={label:"Lobu MCP reference",href:"https://lobu.ai/reference/mcp/"};function P(e){return[`Paste the prompt into ${e} and review its proposed setup.`,"Approve Lobu sign-in in your browser or through the email approval link.",`Let ${e} verify access with a harmless read in this workspace.`]}const L=[{id:"claude",label:"Claude",tagline:"Web, desktop, and coding agent for one workspace",description:"Claude web, desktop, and Code apps for this workspace.",installTitle:"Add in one click, or run in your terminal",installLink:e=>({label:"Add Lobu to Claude",href:`https://claude.ai/customize/connectors?modal=add-custom-connector&connectorName=Lobu&connectorUrl=${encodeURIComponent(e)}`}),installText:e=>x("claude-code",e),promptUrl:e=>`https://claude.ai/new?q=${encodeURIComponent(e)}`,steps:e=>["Claude: open the Add to Claude link above and complete sign-in.",...d(e)?["The CLI adds Lobu's marketplace and installs the shared plugin."]:["The CLI registers this MCP endpoint and installs the Lobu workspace skill."],"Start a fresh Claude Code session, choose this workspace, and complete OAuth when prompted."],guideLinks:[{label:"Claude setup guide",href:"https://lobu.ai/connect-from/claude/"},{label:"Claude Code setup guide",href:"https://lobu.ai/connect-from/claude-code/"}]},{id:"chatgpt",label:"ChatGPT & Codex",tagline:"Web connector and coding agent for one workspace",description:"ChatGPT web connector and Codex coding agent for this workspace.",installTitle:"Pick a surface",installLink:e=>d(e)?{label:"Use Lobu in ChatGPT",href:"https://chatgpt.com/plugins/plugin_asdk_app_6a73b856e4348191a97dc8e3a1e58a94"}:null,promptUrl:e=>`https://chatgpt.com/?q=${encodeURIComponent(e)}`,installText:e=>d(e)?x("codex",e):["ChatGPT web — open Settings -> Connectors -> Create connector","Name: Lobu",`MCP URL: ${e}`,"Authentication: OAuth","",`Codex — ${x("codex",e)}`].join(`
2
- `),steps:e=>d(e)?["ChatGPT web: open the Lobu listing above and complete sign-in.","Codex: run the command above — the CLI adds Lobu's marketplace and installs the shared plugin.","Codex: start a fresh session, choose this workspace, and complete OAuth when prompted."]:["Codex: run the command above — the CLI registers this MCP endpoint and installs the Lobu workspace skill.","Codex: start a fresh session, choose this workspace, and complete OAuth when prompted."],guideLinks:[{label:"ChatGPT setup guide",href:"https://lobu.ai/connect-from/chatgpt/"},{label:"Codex setup guide",href:"https://lobu.ai/connect-from/codex/"}]},{id:"opencode",label:"OpenCode",tagline:"Native remote MCP plus a global Lobu skill",description:"Connect OpenCode through its native MCP setup and install the Lobu workspace skill globally.",installTitle:"Run in your terminal",installText:e=>b("opencode",e),steps:e=>[`The CLI launches OpenCode's native MCP setup for ${e}.`,"Choose remote and name the server lobu.","Run opencode mcp auth lobu and complete OAuth.","The CLI installs the Lobu skill into OpenCode's global skill directory.","Start a fresh OpenCode session."],guideLinks:[{label:"OpenCode MCP guide",href:"https://opencode.ai/docs/mcp-servers/"}]},{id:"antigravity",label:"Antigravity CLI",tagline:"Native remote MCP plus a global Lobu skill",description:"Connect Antigravity CLI through its native MCP profile and install the Lobu workspace skill globally.",installTitle:"Run in your terminal",installText:e=>b("antigravity",e),steps:()=>["The CLI adds Lobu to Antigravity's global MCP profile using serverUrl.","The CLI installs lobu.md into Antigravity CLI's global skills directory.","Start a fresh session with agy, confirm Lobu in /mcp, and complete OAuth when prompted."],guideLinks:[{label:"Antigravity MCP guide",href:"https://antigravity.google/docs/mcp"}]},{id:"cursor",label:"Cursor",tagline:"Native remote MCP setup",description:"Connect Cursor to shared workspace context and governed actions through its native MCP configuration.",installTitle:"Run in your terminal",installText:e=>b("cursor",e),steps:()=>["The CLI adds or updates the Lobu entry in Cursor's MCP configuration.","Restart Cursor and enable the Lobu MCP server.","Use a Lobu tool and complete OAuth when prompted."],guideLinks:[N]},{id:"openclaw",label:"OpenClaw",tagline:"Connect from your agent's workspace",description:"Let OpenClaw connect to Lobu through MCP or sign in with the Lobu CLI in its terminal.",installTitle:"Paste this into OpenClaw",setupMode:"agent-prompt",terminalLogin:!0,steps:()=>P("OpenClaw"),guideLinks:[{label:"OpenClaw terminal guide",href:"https://docs.openclaw.ai/tools/exec"}]},{id:"hermes",label:"Hermes",tagline:"Remote MCP or Lobu CLI sign-in",description:"Let Hermes configure Lobu with its MCP tools or sign in with the Lobu CLI in its terminal.",installTitle:"Paste this into Hermes",setupMode:"agent-prompt",terminalLogin:!0,steps:()=>P("Hermes"),guideLinks:[{label:"Hermes MCP guide",href:"https://hermes-agent.nousresearch.com/docs/user-guide/features/mcp/"}]},{id:"other",label:"Not listed here",tagline:"Let your agent configure Lobu",description:"Paste a setup prompt into another MCP-compatible agent and let it propose the exact skill and MCP configuration.",installTitle:"Paste this into your agent",setupMode:"agent-prompt",steps:()=>["Paste the prompt into the agent you want to connect.","Review the exact configuration and skill files it proposes before approving changes.","Complete Lobu OAuth and let the agent perform its read-only verification."],guideLinks:[N]}],I=["Connect my Gmail to Lobu.","Create a Lobu automation that sends me a morning briefing.","In Lobu, design a data model with entities and relationships for tracking deals.","Remember in Lobu that I prefer short answers that lead with the key point."],F={codex:"chatgpt","claude-code":"claude","claude-desktop":"claude"};function K(e){const a=F[e]??e;return L.find(n=>n.id===a)}function W(e){const{workspaceName:a,owner:n,mcpUrl:o,clientLabel:r}=e;return[`Connect this${r?` ${r}`:""} agent to the "${a}" Lobu workspace (${n}).`,"",`Use the remote HTTP MCP server ${o}. Detect this agent's native MCP and skill mechanisms. If it supports installable skills, install the Lobu workspace skill from ${D}.`,"Inspect the current client and show the exact proposed installation or configuration changes before applying them. The Lobu CLI may be used as the setup helper, but do not initialize a Lobu project. Do not install the separate project-building starter skill. Do not enable local Automation delivery.",...e.terminalLogin?[`If native remote MCP with OAuth is unavailable, use the Lobu CLI in this agent's persistent terminal environment. Before logging in, inspect CLI help and existing contexts to select the same Lobu server and workspace as the MCP URL above; never silently use the hosted server for a custom endpoint. If no context matches that server, create one with npx @lobu/cli@latest context add <name> --url <server-base-url>. Ask for the user's Lobu email address, then run npx @lobu/cli@latest login --email <address> --context <name> and wait for the user to approve the email link. Keep credentials in the CLI's own persistent storage; never print tokens or paste them into chat. Run npx @lobu/cli@latest memory health --context <name> --org ${n}, then make a harmless read using the CLI with the same --context and --org options.`]:[],"","For native MCP, complete Lobu OAuth in the user's browser, then start a fresh session and confirm Lobu tools are discoverable. After either setup path, make one harmless read-only call in the selected workspace. Use search_sdk before choosing SDK methods. Never fabricate a returned URL or identifier."].join(`
3
- `)}function q(e,a){return`flex items-center gap-3 px-3 py-2.5 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground ${e===a-1?"":"border-b"}`}function z({owner:e,dashed:a=!1}){return t.jsx("div",{className:`overflow-hidden rounded-lg border ${a?"border-dashed":""}`,children:L.map((n,o)=>t.jsxs(h,{to:"/$owner/agents/connect/$clientId",params:{owner:e,clientId:n.id},className:q(o,L.length),children:[t.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(f,{name:n.label})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-sm font-medium",children:n.label}),t.jsx("p",{className:"truncate text-xs text-muted-foreground",children:n.tagline})]}),t.jsx("span",{className:"shrink-0 text-xs",children:"Set up"})]},n.id))})}const Y="app.lobu.ai";function J(e,a){const n=a?`/mcp/${a}`:"/mcp";if(!e)return`http://localhost:8787${n}`;try{const o=new URL(e);return o.hostname===Y&&(o.hostname="lobu.ai"),o.pathname=n,o.toString()}catch{return`${e}${n}`}}function Q(e){return J(R,e)}const w="gap-3 pt-2.5 pb-8";function V(e,a){return`flex items-center gap-3 px-3 py-2.5 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground ${e===a-1?"":"border-b"}`}function T({owner:e}){return t.jsx(O,{crumbs:[t.jsx(h,{to:"/$owner",params:{owner:e},search:{section:"agent"},className:S,children:"Agents"},"agents")]})}function se({owner:e}){return t.jsx(C,{className:w,children:t.jsxs(A,{className:"flex flex-1 flex-col gap-6",children:[t.jsx(M,{breadcrumb:t.jsx(T,{owner:e}),icon:t.jsx($.agents.icon,{className:"h-6 w-6"}),title:"Connect an agent",caption:"Choose the agent you already use. Install directly where supported, or copy a setup prompt into the agent."}),t.jsx(z,{owner:e})]})})}function ae({owner:e,clientId:a}){const n=K(a),{data:o}=_(e,{slug:e}),{data:r=[]}=B(null,{refetchInterval:2500}),i=U.useMemo(()=>G(r).filter(s=>s.connected),[r]);if(!n)return t.jsx(C,{className:w,children:t.jsxs(A,{className:"space-y-3",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"There is no agent client by that name."}),t.jsx(h,{to:"/$owner/agents/connect",params:{owner:e},className:"text-sm text-primary hover:underline",children:"Back to agent clients"})]})});const l=Q(e),p=W({workspaceName:o?.workspace?.name??e,owner:e,mcpUrl:l,clientLabel:n.id==="other"?void 0:n.label,terminalLogin:n.terminalLogin}),m=n.setupMode==="agent-prompt",k=m?p:n.installText?.(l)??p;return t.jsx(C,{className:w,children:t.jsxs(E,{header:t.jsx(M,{breadcrumb:t.jsx(T,{owner:e}),icon:t.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",children:t.jsx(f,{name:n.label})}),title:n.label,caption:n.description}),children:[t.jsx(u,{title:"Set up",children:t.jsxs("div",{className:"space-y-4",children:[(()=>{const s=n.installLink?.(l);return s?t.jsx("div",{children:t.jsx(v,{asChild:!0,children:t.jsxs("a",{href:s.href,target:"_blank",rel:"noreferrer",children:[s.label,t.jsx(y,{className:"ml-1.5 h-3.5 w-3.5"})]})})}):null})(),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:n.installTitle}),t.jsxs("div",{className:"flex items-start gap-2 rounded-lg border bg-muted/40 p-2.5",children:[t.jsx("pre",{className:"min-w-0 flex-1 overflow-x-auto whitespace-pre-wrap font-mono text-xs leading-relaxed",children:k}),t.jsx(g,{text:k,label:m?"Copy setup prompt":"Copy"})]})]}),t.jsx("ol",{className:"space-y-1 text-xs text-muted-foreground",children:n.steps(l).map((s,c)=>t.jsxs("li",{children:[c+1,". ",s]},s))}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[m?null:t.jsx(g,{text:p,label:"Copy setup prompt"}),n.guideLinks.map(s=>t.jsx(v,{asChild:!0,variant:"ghost",size:"sm",className:"h-8 text-xs",children:t.jsxs("a",{href:s.href,target:"_blank",rel:"noreferrer",children:[s.label,t.jsx(y,{className:"ml-1.5 h-3.5 w-3.5"})]})},s.href))]})]})}),t.jsx(u,{title:"First prompts",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"After setup, start a new chat with Lobu enabled and try one of these."}),t.jsx("div",{className:"overflow-hidden rounded-lg border",children:I.map((s,c)=>{const j=n.promptUrl?.(s);return t.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 ${c===I.length-1?"":"border-b"}`,children:[j?t.jsx("a",{href:j,target:"_blank",rel:"noreferrer",className:"min-w-0 flex-1 text-sm hover:underline",children:s}):t.jsx("p",{className:"min-w-0 flex-1 text-sm",children:s}),t.jsx(g,{text:s,label:"prompt",iconOnly:!0})]},s)})})]})}),t.jsx(u,{title:"Connected agents",count:i.length>0?String(i.length):void 0,children:i.length===0?t.jsx("div",{className:"rounded-lg border border-dashed px-3 py-2.5 text-xs text-muted-foreground",children:"Nothing yet. Finish setup and make an authenticated Lobu MCP request; the agent appears here automatically."}):t.jsx("div",{className:"overflow-hidden rounded-lg border",children:i.map((s,c)=>t.jsxs(h,{to:"/$owner/agents/connected/$clientId",params:{owner:e,clientId:s.clientId},className:V(c,i.length),children:[t.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",children:t.jsx(f,{name:s.title})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-sm font-medium",children:s.title}),t.jsx("p",{className:"truncate text-xs text-muted-foreground",children:H(s)})]})]},s.key))})}),t.jsx(u,{title:"Manual MCP details",children:t.jsxs("dl",{className:"grid grid-cols-[5rem_1fr] gap-x-3 gap-y-1 rounded-lg border bg-muted/40 p-3 text-xs",children:[t.jsx("dt",{className:"text-muted-foreground",children:"Name"}),t.jsx("dd",{className:"font-mono",children:"lobu"}),t.jsx("dt",{className:"text-muted-foreground",children:"MCP URL"}),t.jsx("dd",{className:"break-all font-mono",children:l})]})})]})})}export{se as A,ae as a};
4
- //# sourceMappingURL=agent-connect-pages-DVq9nAR7.js.map
@@ -1,6 +0,0 @@
1
- import{j as s,r as a,b0 as Ht,y as zt,h9 as Wt,ha as Kt,af as tt,a4 as Be,ag as nt,cc as qt,hb as rt,hc as Gt,L as gt,i as P,g8 as Yt,hd as bt,he as Jt,hf as Qt,dh as Xt,hg as Zt,hh as en,aS as tn,B as fe,fZ as nn,hi as rn,hj as He,X as on,al as sn,fP as ln,e9 as Ne,hk as an,aE as cn,aF as un,hl as dn,aH as fn,hm as pn,hn as ot,ho as mn,hp as hn,f8 as gn,a8 as bn,hq as xn,hr as vn}from"./index-BoqrvLHQ.js";import{D as yn,E as Rn}from"./app-bridge-B-L0rGz9.js";import{A as wn,a as Sn,b as Tn,c as Ge,d as xt,e as Cn}from"./agent-loading-shells-BLNHIy-r.js";import{t as jn,P as Nn}from"./pending-seed-BBACroge.js";import{h as En,t as An,R as In,i as kn,u as _n,M as On,a as Pn}from"./use-mention-search-khySpz_V.js";import{E as Mn,c as Ln}from"./events-feed-DcKTkJVe.js";const vt=a.createContext(null);function $n({extension:e,children:t}){return s.jsx(vt.Provider,{value:e??null,children:t})}function Ye(){return a.useContext(vt)}var Je=(e=>(e.PROVIDER_QUOTA_EXHAUSTED="PROVIDER_QUOTA_EXHAUSTED",e.PROVIDER_AUTH="PROVIDER_AUTH",e.PROVIDER_UNKNOWN_MODEL="PROVIDER_UNKNOWN_MODEL",e.PROVIDER_BASE_URL_UNRESOLVED="PROVIDER_BASE_URL_UNRESOLVED",e.NO_MODEL_CONFIGURED="NO_MODEL_CONFIGURED",e.WORKER_UNRESPONSIVE="WORKER_UNRESPONSIVE",e.WORKER_DIED="WORKER_DIED",e.WORKER_STARTUP_FAILED="WORKER_STARTUP_FAILED",e.PROVIDER_TOOL_CALL_FAILED="PROVIDER_TOOL_CALL_FAILED",e.SESSION_TIMEOUT="SESSION_TIMEOUT",e))(Je||{});const Dn={PROVIDER_QUOTA_EXHAUSTED:{cta:"provider-management",ctaLabel:"Manage provider"},PROVIDER_AUTH:{cta:"provider-management",ctaLabel:"Reconnect provider"},PROVIDER_UNKNOWN_MODEL:{cta:"agent-settings",ctaLabel:"Choose model"},PROVIDER_BASE_URL_UNRESOLVED:{cta:"provider-management",ctaLabel:"Manage provider"},PROVIDER_TOOL_CALL_FAILED:{message:"The model provider rejected its own tool call and ended the turn. This is usually temporary — please try again.",cta:"none"},NO_MODEL_CONFIGURED:{message:"No model is configured for this agent. Choose a model in agent settings.",cta:"agent-settings",ctaLabel:"Choose a model"},WORKER_UNRESPONSIVE:{message:"The agent didn't finish responding in time. This is usually temporary — please try again.",cta:"none"},WORKER_DIED:{message:"The agent stopped unexpectedly before it could reply. This is usually temporary — please try again.",cta:"none"},WORKER_STARTUP_FAILED:{message:"The agent couldn't start, so your request wasn't processed. Please try again in a moment.",cta:"none"},SESSION_TIMEOUT:{cta:"none",silent:!0}};function Un(e){if(typeof e=="string")return Object.values(Je).includes(e)?e:void 0}const Fn=Object.freeze(Object.defineProperty({__proto__:null,AGENT_ERRORS:Dn,AgentErrorCode:Je,toAgentErrorCode:Un},Symbol.toStringTag,{value:"Module"})),{AGENT_ERRORS:Vn,toAgentErrorCode:Bn}=Fn;function st(e,t){if(!t)return null;try{const n=new URL(t);return n.protocol!=="http:"&&n.protocol!=="https:"?null:new URL(e,`${n.origin}/`).toString()}catch{return null}}function yt(e,t){const n=Bn(e);if(!n)return null;const r=Vn[n];if(r.cta==="none"||!t.workspaceSlug)return null;const o=encodeURIComponent(t.workspaceSlug);if(r.cta==="provider-connect"||r.cta==="provider-management"){const i=t.provider?`/${o}/connectors/${encodeURIComponent(`${Ht}${t.provider}`)}`:`/${o}/connectors`,c=st(i,t.webOrigin);if(!c)return null;const u=new URL(c);return t.provider&&t.model&&u.searchParams.set("model",t.model),{label:r.ctaLabel??"Connect a provider",href:u.toString()}}if(!t.agentId)return null;const l=st(`/${o}/agents/${encodeURIComponent(t.agentId)}#models`,t.webOrigin);return l?{label:r.ctaLabel??"Open settings",href:l}:null}function Rt(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.subscribable;if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t;if(typeof n.connector_key!="string"||!n.connector_key||typeof n.resource_type!="string"||!n.resource_type||typeof n.resource_ref!="string"||!n.resource_ref||typeof n.label!="string"||!n.label)return null;const r=Array.isArray(n.suggested_event_keys)?n.suggested_event_keys.filter(o=>typeof o=="string"&&!!o):void 0;return{connector_key:n.connector_key,resource_type:n.resource_type,resource_ref:n.resource_ref,label:n.label,...r?.length?{suggested_event_keys:r}:{}}}const lt=new Set(["localhost","127.0.0.1","::1","[::1]"]);function Hn(e){return e?.trim().toLowerCase().replace(/^\.+|\.+$/g,"")||null}function at(e,t){const n=Hn(t);if(!n)return!1;const r=e.toLowerCase().replace(/\.$/,"");return r===n||r.endsWith(`.${n}`)}function it(e,t,n){try{const r=new URL(t),o=new URL(e,t),l=lt.has(o.hostname)&&lt.has(r.hostname),i=o.protocol===r.protocol&&(o.protocol==="https:"||o.protocol==="http:")&&at(o.hostname,n)&&at(r.hostname,n);return o.origin!==r.origin&&(l||i)&&(o.protocol=r.protocol,o.host=r.host),o.origin===r.origin&&o.pathname.startsWith("/api/v1/agents")&&(o.pathname=`/lobu${o.pathname}`),o.toString()}catch{return e}}const zn=/\.(png|jpe?g|gif|webp|avif|bmp|svg)$/i,wt=new Set(["suggest_actions"]),Me="Thinking…";function Wn(e){const{textOut:t,statusLine:n,errorText:r,toolCalls:o}=e,l=[];n===Me&&l.push({type:"reasoning"}),r&&l.push({type:"error",text:r});let i=t;return n&&n!==Me&&(i=t?`${t}
2
-
3
- ${n}`:n),i&&l.push({type:"text",text:i}),l.push(...o),l}const St=[];function Kn(e,t,n){return e?.length?e:n===0?t:[]}const Qe=a.createContext(null);function Ee(){const e=a.useContext(Qe);if(!e)throw new Error("useLobuChat must be used within <LobuChatProvider>");return e}function Do({messages:e,workspaceSlug:t=null,children:n}){const r=a.useMemo(()=>({messages:e,running:!1,append:()=>{},cancel:()=>{},pendingAttachments:[],addAttachments:()=>{},removeAttachment:()=>{},agentId:null,conversationId:"",workspaceSlug:t,currentSuggestions:null,starters:St}),[e,t]);return s.jsx(Qe.Provider,{value:r,children:n})}const Tt=/\[([^\]]*)\]\((\S*?\/api\/v1\/files\/[^)\s]+)\)/g;function ct(e){return e.replace(/<lobu_internal_context>[\s\S]*?<\/lobu_internal_context>\n*/g,"").replace(Tt,"").replace(/\n{3,}/g,`
4
-
5
- `).trim()}function qn(e){const t=[];for(const n of e.matchAll(Tt)){const r=n[1]?.trim()||"file",o=n[2];o&&t.push({name:r,url:o})}return t}function Gn(e,t={}){if(typeof e=="string"){const r=ct(e);return r?[{type:"text",text:r}]:[]}if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||typeof r!="object")continue;const o=r;if(o.type==="text"&&typeof o.text=="string"){const l=ct(o.text);l&&n.push({type:"text",text:l})}else t.showToolCalls&&o.type==="toolCall"&&typeof o.name=="string"&&!wt.has(o.name)?n.push({type:"tool-call",toolCallId:o.id??`tc-${n.length}`,toolName:o.name,args:o.arguments??{},...o.result!==void 0?{result:o.result}:{}}):t.showToolCalls&&o.type==="tool_use"&&typeof o.name=="string"&&n.push({type:"tool-call",toolCallId:o.id??`tc-${n.length}`,toolName:o.name,args:o.input??{},...o.result!==void 0?{result:o.result}:{}})}return n}function Yn(e){const t=[],n=r=>{for(const{name:o,url:l}of qn(r))t.push({id:`file-${t.length}`,name:o,url:l,isImage:zn.test(o)})};if(typeof e=="string")return n(e),t.length>0?t:void 0;if(Array.isArray(e)){for(const r of e){if(!r||typeof r!="object")continue;const o=r;if(o.type==="image"&&typeof o.data=="string"){const l=o.mimeType||"image/png";t.push({id:`img-${t.length}`,name:`image-${t.length+1}`,imageDataUrl:`data:${l};base64,${o.data}`,isImage:!0})}else o.type==="text"&&typeof o.text=="string"&&n(o.text)}return t.length>0?t:void 0}}function Jn(e,t){if(e.type==="bashExecution"){const r=e.content??{},o=e.timestamp?new Date(e.timestamp).getTime():void 0;return{id:e.id,role:"user",parts:[{type:"bash",command:r.command??"",output:r.output??"",exitCode:r.exitCode,cancelled:r.cancelled??!1}],createdAt:o&&!Number.isNaN(o)?o:void 0}}if(e.type!=="message"||e.isVerbose||e.role!=="assistant"&&e.role!=="user"&&e.role!=="system")return null;const n=e.timestamp?new Date(e.timestamp).getTime():void 0;return{id:e.id,role:e.role,parts:Gn(e.content,t),attachments:Yn(e.content),createdAt:n&&!Number.isNaN(n)?n:void 0}}const Qn=[],Xn=[];function Zn(e){let t=null;for(const n of e)n.type==="suggestion"&&(t=n.prompts.length>0?n.prompts:null);return t}function er(e,t){if(e.length===0)return null;const n=[];for(const r of e)if(r.type!=="suggestion"){if(r.type==="agent-error"){n.push({type:"error",text:String(r.error??"Agent reported an error.")});const o=yt(r.errorCode,{...t,provider:r.errorContext?.provider,model:r.errorContext?.model});o&&n.push({type:"tool-call",toolCallId:`error-run-${r.runId}`,toolName:"link-button",args:{label:o.label,url:o.href}});continue}n.push({type:"tool-call",toolCallId:`approval-event-${r.eventId}`,toolName:"tool-approval",args:{runId:r.runId,action:r.action,proposal:r.proposal,current:r.current,fields:r.fields??null,attribution:r.attribution??null,resourceKind:r.resourceKind??null,reason:r.reason??null,status:r.status??"pending",reviewedByName:r.reviewedByName??null}})}return n.length===0?null:{id:"history-interactions",role:"assistant",parts:n}}const tr=3e4,nr=3*tr,rr=15e3;function ut(e){try{return JSON.parse(e.data)}catch{return{content:e.data}}}const be=e=>`${e}-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;function or(e){const t=[],n=new Set;for(const r of e){if(!r||typeof r!="object")continue;const{title:o,message:l}=r;if(typeof o!="string"||typeof l!="string")continue;const i=o.trim(),c=l.trim();if(i.length===0||c.length===0)continue;const u=`${i}\0${c}`;n.has(u)||(n.add(u),t.push({title:i,message:c}))}return t.length>0?t:null}function Uo({agentId:e,workspaceSlug:t,thread:n="agent-panel",loadHistory:r=!0,ephemeralContext:o,onFirstUserMessage:l,children:i,initialDraft:c}){const u=zt(),d=a.useRef(null),m=a.useRef(null),y=a.useRef(!1),h=a.useRef(o),g=a.useRef(!1),w=a.useRef(null);h.current=o;const{data:E,isLoading:v}=Wt(e,n,{orgSlug:t,enabled:r&&!!e&&!!n}),T=E?.messages??Qn,H=E?.interactions??Xn,{data:U}=Kt(e,{enabled:!!e}),K=U?.starters??St,z=!!(U?.showToolCalls??U?.settings?.showToolCalls),[N,L]=a.useState([]),[G,le]=a.useState(!1),[$,q]=a.useState([]),[Y,R]=a.useState(null),S=a.useRef(!1);S.current=G;const C=a.useMemo(()=>T.map(I=>Jn(I,{showToolCalls:z})).filter(I=>I!==null),[T,z]),O=a.useRef(!1);a.useEffect(()=>{if(O.current||v||S.current)return;O.current=!0;const I=er(H,{workspaceSlug:t,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin});L(I?[...C,I]:C),R(Zn(H))},[e,v,C,H,t]);const A=a.useCallback(()=>{u.invalidateQueries({queryKey:["agent-thread-messages",t,e,n]}),u.invalidateQueries({queryKey:["agent-threads",t,e]})},[u,t,e,n]),Z=a.useCallback(async()=>{if(d.current)return d.current;if(m.current)return m.current;if(!e)throw new Error("No agent selected");const I=(async()=>{const M=await tt(`${Be}/lobu/api/v1/agents`,{method:"POST",headers:{"Content-Type":"application/json",...t?{"x-lobu-org":t}:{}},credentials:"include",body:JSON.stringify({agentId:e,thread:n}),timeoutMs:2e4});if(!M.ok)throw await nt(M);const V=await M.json(),j=qt(),Q={sessionId:V.agentId,sseUrl:it(V.sseUrl,Be,j),messagesUrl:it(V.messagesUrl,Be,j)};return d.current=Q,Q})();m.current=I;try{return await I}catch(M){throw d.current=null,M}finally{m.current=null}},[e,t,n]),te=a.useCallback(async(I,M,V)=>{const j=crypto.randomUUID(),Q=new AbortController;w.current=Q;const W=f=>{L(p=>p.map(b=>b.id===V?{...b,parts:f}:b))};let B;try{B=await Z()}catch(f){W([{type:"text",text:`Error: ${f instanceof Error?f.message:"Could not start a session."}`}]);return}let X=await rt(B.sseUrl,{throwOnFailure:!0});const pe=[];let ie=null;const Re=()=>{const f=ie;ie=null,f?.()},we=f=>{pe.push(f),Re()},Se=(f,p)=>{const k=["question","link-button","tool-approval"].includes(f)?p.turnMessageId===j:p.messageId===j||Array.isArray(p.processedMessageIds)&&p.processedMessageIds.includes(j);(f==="closed"||k)&&we({kind:f,payload:p})};let me=!1,Te=null;const Ie=new Promise(f=>{Te=f});let ce=0,he=Date.now();const ue=f=>{he=Date.now();const p=Number(f.lastEventId);Number.isFinite(p)&&p>ce&&(ce=p)},ke=["output","status","complete","closed","agent-error","question","link-button","tool-approval","tool_use"],Ce=f=>{f.addEventListener("open",()=>{me=!0,Te?.()}),f.addEventListener("connected",b=>{ue(b),me||(me=!0,Te?.())}),f.addEventListener("ping",ue);const p=b=>k=>{ue(k);const ee=k;typeof ee.data=="string"&&Se(b,ut(ee))};for(const b of ke)f.addEventListener(b,p(b));f.addEventListener("error",b=>{const k=b;if(typeof k.data=="string"&&k.data){ue(b),Se("error",ut(k));return}f.readyState===EventSource.CLOSED&&we({kind:"error",payload:{error:"Connection closed"}})})};Ce(X);const _e=async()=>{X.close();let f=B.sseUrl;if(ce){const p=new URL(B.sseUrl,window.location.origin);p.searchParams.set("since",String(ce)),f=p.toString()}X=await rt(f,{throwOnFailure:!1}),Ce(X),he=Date.now()};await Promise.race([Ie,new Promise(f=>setTimeout(f,1500))]);const Oe=()=>{X.close(),Re()};Q.signal.addEventListener("abort",Oe,{once:!0});try{const f=h.current?.trim(),p=!!f&&!g.current;p&&(g.current=!0);let b;if(M.length>0){const x=new FormData;x.set("content",I),x.set("messageId",j),p&&f&&x.set("ephemeralContext",f);for(const _ of M)x.append("files",_,_.name);b={method:"POST",credentials:"include",body:x,timeoutMs:12e4}}else{const x={content:I,messageId:j};p&&f&&(x.ephemeralContext=f),b={method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(x),timeoutMs:2e4}}const k=await tt(B.messagesUrl,b);if(!k.ok)throw d.current=null,await nt(k);let ee="",D=Me,et=null;const ge=[],de=()=>Wn({textOut:ee,statusLine:D,errorText:et,toolCalls:ge});for(W(de());!Q.signal.aborted;){if(pe.length===0){let _;const ne=await Promise.race([new Promise(Ve=>{ie=()=>Ve(!0)}),new Promise(Ve=>{_=setTimeout(()=>Ve(!1),rr)})]);_&&clearTimeout(_),!ne&&Date.now()-he>=nr&&(await _e(),A());continue}const x=pe.shift();if(x){if(x.kind==="output")D=null,ee+=String(x.payload.content??"");else if(x.kind==="status")D=Me;else if(x.kind==="complete"){D=null;const _=x.payload.finalText;typeof _=="string"&&_.length>0&&(ee=_);const ne=x.payload.suggestions;ne!==void 0&&R(Array.isArray(ne)?or(ne):null),A(),W(de());return}else if(x.kind==="closed"){d.current=null;const _=x.payload.reason;D=`Session ended${_?`: ${_}`:""}.`,A(),W(de());return}else if(x.kind==="error"||x.kind==="agent-error"){D=null,et=typeof x.payload.error=="string"&&x.payload.error?x.payload.error:"Agent reported an error.";const _=x.payload.errorContext&&typeof x.payload.errorContext=="object"?x.payload.errorContext:void 0,ne=yt(x.payload.errorCode,{workspaceSlug:t,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin,provider:typeof _?.provider=="string"?_.provider:void 0,model:typeof _?.model=="string"?_.model:void 0});ne&&ge.push({type:"tool-call",toolCallId:be("l"),toolName:"link-button",args:{label:ne.label,url:ne.href}}),A(),W(de());return}else if(x.kind==="question")ge.push({type:"tool-call",toolCallId:be("q"),toolName:"question",args:{question:x.payload.question??"",options:x.payload.options??[]}});else if(x.kind==="tool_use"){if(D=null,wt.has(x.payload.name??"")){W(de());continue}const _=x.payload.result_summary,ne=Rt(_);if(!z&&!ne){W(de());continue}ge.push({type:"tool-call",toolCallId:x.payload.toolCallId??be("t"),toolName:z?x.payload.name??"tool":"subscription-candidate",args:z?x.payload.input??{}:null,result:_,isError:x.payload.isError})}else if(x.kind==="link-button")ge.push({type:"tool-call",toolCallId:be("l"),toolName:"link-button",args:{label:x.payload.label??"Open link",url:x.payload.url??""}});else if(x.kind==="tool-approval"){const _=x.payload.runId;if(typeof _!="number")continue;ge.push({type:"tool-call",toolCallId:`run-${_}`,toolName:"tool-approval",args:{runId:_,action:x.payload.action??null,proposal:x.payload.proposal??null,current:x.payload.current??null,fields:x.payload.fields??null,attribution:x.payload.attribution??null,resourceKind:x.payload.resourceKind??null}})}W(de())}}}catch(f){W([{type:"text",text:`Error: ${f instanceof Error?f.message:"Send failed."}`}])}finally{Q.signal.removeEventListener("abort",Oe),X.close()}},[e,Z,A,z,t]),re=a.useCallback(I=>{const M=I.trim(),V=$.map(B=>B.file);if(!M&&V.length===0||S.current||!e)return;y.current||(y.current=!0,l?.(M||V[0]?.name||""));const j={id:be("u"),role:"user",parts:M?[{type:"text",text:M}]:[],attachments:$.map(B=>({id:B.id,name:B.name,isImage:B.isImage,imageDataUrl:B.isImage?URL.createObjectURL(B.file):void 0})),createdAt:Date.now()},Q=be("asst"),W={id:Q,role:"assistant",parts:[{type:"reasoning"}],createdAt:Date.now()};L(B=>[...B,j,W]),q([]),le(!0),S.current=!0,te(M,V,Q).finally(()=>{le(!1),S.current=!1,w.current=null})},[e,l,$,te]),se=a.useCallback(()=>{w.current?.abort()},[]),ye=a.useCallback(I=>{const M=Array.from(I);q(V=>[...V,...M.map(j=>({id:crypto.randomUUID(),name:j.name,file:j,isImage:j.type.startsWith("image/")}))])},[]),J=a.useCallback(I=>{q(M=>M.filter(V=>V.id!==I))},[]),ae=a.useRef(!1);a.useEffect(()=>{if(ae.current)return;const I=jn(n);I&&(ae.current=!0,re(I))},[n,re]);const F=a.useMemo(()=>({messages:N,running:G,append:re,cancel:se,pendingAttachments:$,addAttachments:ye,removeAttachment:J,initialDraft:c,agentId:e,conversationId:n,workspaceSlug:t,currentSuggestions:Y,starters:K}),[N,G,re,se,$,ye,J,c,e,n,t,Y,K]);return r&&v?s.jsx(wn,{}):s.jsx(Qe.Provider,{value:F,children:i})}const dt="mx-0.5 inline-flex items-center gap-1 rounded-md bg-accent px-1.5 py-0.5 align-baseline font-medium text-[0.9em] text-accent-foreground no-underline";function sr({refItem:e}){const t=In[e.kind]??Gt;return kn(e.path)?s.jsxs("span",{className:dt,children:[s.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]}):s.jsxs(gt,{to:e.path,className:P(dt,"hover:bg-accent/80"),children:[s.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]})}const Xe=({text:e,renderText:t})=>En(e)?s.jsx(s.Fragment,{children:An(e).map((n,r)=>n.type==="ref"?s.jsx(sr,{refItem:n.ref},`r${r}`):s.jsx("span",{children:t(n.text)},`t${r}`))}):s.jsx(s.Fragment,{children:t(e)}),lr=({label:e="Thinking"})=>s.jsx("span",{className:"aui-thinking-shimmer inline-block text-sm","aria-live":"polite","aria-busy":"true",children:e}),Ct=a.createContext(null),jt=()=>{const e=a.useContext(Ct);if(!e)throw new Error("ChainOfThought components must be used within ChainOfThought");return e},Nt=a.memo(({className:e,open:t,defaultOpen:n=!1,onOpenChange:r,children:o,...l})=>{const[i,c]=Yt({prop:t,defaultProp:n,onChange:r}),u=a.useMemo(()=>({isOpen:i,setIsOpen:c}),[i,c]);return s.jsx(Ct.Provider,{value:u,children:s.jsx("div",{className:P("not-prose max-w-prose space-y-4",e),...l,children:o})})}),Et=a.memo(({className:e,children:t,...n})=>{const{isOpen:r,setIsOpen:o}=jt();return s.jsx(bt,{onOpenChange:o,open:r,children:s.jsxs(Jt,{className:P("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:[s.jsx(Qt,{className:"size-4"}),s.jsx("span",{className:"flex-1 text-left",children:t??"Chain of Thought"}),s.jsx(Xt,{className:P("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),At=a.memo(({className:e,icon:t=en,label:n,description:r,status:o="complete",children:l,...i})=>{const c={complete:"text-muted-foreground",active:"text-foreground",pending:"text-muted-foreground/50"};return s.jsxs("div",{className:P("flex gap-2 text-sm",c[o],"fade-in-0 slide-in-from-top-2 animate-in",e),...i,children:[s.jsxs("div",{className:"relative mt-0.5",children:[s.jsx(t,{className:"size-4"}),s.jsx("div",{className:"-mx-px absolute top-7 bottom-0 left-1/2 w-px bg-border"})]}),s.jsxs("div",{className:"flex-1 space-y-2 overflow-hidden",children:[s.jsx("div",{children:n}),r&&s.jsx("div",{className:"text-muted-foreground text-xs",children:r}),l]})]})}),It=a.memo(({className:e,children:t,...n})=>{const{isOpen:r}=jt();return s.jsx(bt,{open:r,children:s.jsx(Zt,{className:P("mt-2 space-y-3","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...n,children:t})})});Nt.displayName="ChainOfThought";Et.displayName="ChainOfThoughtHeader";At.displayName="ChainOfThoughtStep";It.displayName="ChainOfThoughtContent";function ar(e){return{contentIds:e.filter(n=>Number.isSafeInteger(n)&&n>0),sortBy:"date",sortOrder:"asc"}}function ir({ownerSlug:e,eventIds:t}){const n=t.join(","),r=a.useMemo(()=>ar(n.split(",").map(Number)),[n]);return r.contentIds.length===0?null:s.jsx(tn,{owner:e,children:({organizationId:o,ownerSlug:l})=>o?s.jsx(Mn,{organizationId:o,ownerSlug:l,filters:r,hideOriginator:!0}):null})}function cr({defaultTagName:e,props:t,render:n,state:r={},stateAttributesMapping:o}){let l=ze(ur(r,o),t);if(!n)return a.createElement(e,l);if(typeof n=="function")return n(l,r);if(!a.isValidElement(n))return null;let i=n.props,c={...ze(l,i),ref:Ae(l.ref,i.ref)};return a.cloneElement(n,c)}function ze(...e){let t={};for(let n of e){if(!n)continue;let r=n;for(let o of Object.keys(r)){let l=r[o];if(l===void 0)continue;let i=t[o];o==="className"?t[o]=[i,l].filter(Boolean).join(" "):o==="style"?t[o]={...i,...l}:o==="ref"?t[o]=Ae(i,l):fr(o)&&typeof i=="function"&&typeof l=="function"?t[o]=dr(l,i):t[o]=l}}return t}function ur(e,t){let n={};for(let r of Object.keys(e)){let o=e[r],l=t?.[r]?.(o);if(l){Object.assign(n,l);continue}if(r==="slot"){n["data-slot"]=o;continue}let i=`data-${String(r).replace(/[A-Z]/g,c=>`-${c.toLowerCase()}`)}`;typeof o=="boolean"?n[i]=o?"":void 0:o!=null&&(n[i]=String(o))}return n}function dr(e,t){return function(n){e(n),n.defaultPrevented||t(n)}}function fr(e){return/^on[A-Z]/.test(e)}function Ae(...e){let t=e.filter(Boolean);if(t.length!==0)return n=>{for(let r of t)typeof r=="function"?r(n):r&&(r.current=n)}}var pr=8,mr=64,hr=0,Le=.5,gr=180,br=new Set(["ArrowDown","ArrowUp","End","Home","PageDown","PageUp"," "]),kt={start:!1,end:!1},xr=[],$e={currentAnchorId:null,visibleMessageIds:xr};function vr({content:e,scrollEdgeThreshold:t,spacer:n,viewport:r}){if(!r||!e)return kt;let o=Ze({content:e,spacer:n,viewport:r});return{start:r.scrollTop>t,end:o-r.scrollTop-r.clientHeight>t}}function yr({content:e,scrollMargin:t,scrollPreviousItemPeek:n,spacer:r,viewport:o,visibleMessageIds:l}){if(!e||!o)return $e;let i=o.getBoundingClientRect(),c=i.top+t+n,u=typeof IntersectionObserver>"u",d=[],m=null;for(let y of je(e,r)){let h=y.dataset.messageId;if(!h)continue;let g=y.dataset.scrollAnchor==="true",w=g||u?y.getBoundingClientRect():null;(u&&w?w.bottom>c&&w.top<i.bottom:l.has(h))&&d.push(h),g&&w&&w.top<=c+Le&&(m=h)}return d.length===0&&m===null?$e:{currentAnchorId:m,visibleMessageIds:d}}function je(e,t){return Array.from(e.children).filter(n=>n instanceof HTMLElement&&n!==t)}function Rr(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r?.dataset.scrollAnchor==="true")return r}return null}function wr(e,t){for(let n of e)if(n.dataset.scrollAnchor==="true"&&!t.has(n))return n;return null}function Sr(e,t){let n=0;for(let r=t;r<e.length;r++)if(e[r]?.dataset.scrollAnchor==="true"&&(n+=1,n>1))return!0;return!1}function Tr(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.dataset.scrollAnchor==="true")return n}return null}function Cr({content:e,spacer:t,viewport:n}){let r=n.getBoundingClientRect();for(let o of je(e,t)){if(!o.dataset.messageId)continue;let l=o.getBoundingClientRect();if(l.bottom>r.top&&l.top<r.bottom)return o}return null}function jr({align:e,element:t,scrollMargin:n,spacer:r,viewport:o}){let l=_t(t,o),i=t.getBoundingClientRect().height,c=Ar(r);if(e==="center"){let u=Math.max(0,o.clientHeight-c.start-c.end);return l-c.start-(u-i)/2-n}if(e==="end")return l-o.clientHeight+i+c.end+n;if(e==="nearest"){let u=l+i,d=o.scrollTop+c.start,m=o.scrollTop+o.clientHeight-c.end;return l>=d&&u<=m?o.scrollTop:l<d?l-c.start-n:u-o.clientHeight+c.end+n}return l-c.start-n}function _t(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function Pe(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function Nr({content:e,scrollTop:t,spacer:n,viewport:r}){let o=Ze({content:e,spacer:n,viewport:r});return t+r.clientHeight-o}function Ze({content:e,spacer:t,viewport:n}){let r=je(e,t),o=Ot(e),l=n.getBoundingClientRect(),i=n.scrollTop,c=o.start+o.end;for(let u of r){let d=u.getBoundingClientRect();c=Math.max(c,d.bottom-l.top+i+o.end)}return c}function Er(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function Ot(e){let t=window.getComputedStyle(e);return{end:We(t.paddingBlockEnd||t.paddingBottom),start:We(t.paddingBlockStart||t.paddingTop)}}function Ar(e){let t=e?.parentElement;return t?Ot(t):{end:0,start:0}}function Ir(e){if(!e)return 0;let t=window.getComputedStyle(e),n=t.rowGap==="normal"?t.gap:t.rowGap;return We(n)}function We(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function kr({refs:e,commitScrollState:t,scheduleStateCommit:n,scheduleVisibilitySync:r}){let{streamingTurnRef:o,autoScrollRef:l,autoscrollingRef:i,autoscrollingTimeoutRef:c,contentRef:u,defaultScrollPositionAppliedRef:d,itemCountRef:m,messageElementsRef:y,modeRef:h,pendingScrollToMessageRef:g,prependRestoreRef:w,scrollMarginRef:E,scrollPreviousItemPeekRef:v,spacerGapRef:T,spacerHeightRef:H,spacerRef:U,viewportRef:K}=e,z=a.useCallback(R=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null),i.current!==R&&(i.current=R,t()),R&&(c.current=window.setTimeout(()=>{c.current=null,i.current=!1,t()},gr))},[t]),N=a.useCallback(R=>{let S=U.current;if(!S)return;let C=Math.max(0,Math.ceil(R));H.current!==C&&(H.current=C,S.hidden=C===0,S.style.height=`${C}px`,S.style.marginTop=C>0?`${-T.current}px`:"")},[]),L=a.useCallback((R,{behavior:S="auto",autoscrolling:C=!1}={})=>{let O=K.current;if(!O)return;let A=Math.max(0,R);if(Math.abs(O.scrollTop-A)<=Le){O.scrollTop=A,t();return}C&&z(!0),O.scrollTo({top:A,behavior:S}),n()},[t,n,z]),G=a.useCallback(({behavior:R="auto"}={})=>K.current?(N(0),o.current=null,h.current="free-scrolling",L(0,{behavior:R}),r(),!0):!1,[r,L,N]),le=a.useCallback(({behavior:R="auto"}={})=>{let S=K.current;return S?(N(0),o.current=null,h.current=l.current?"following-bottom":"free-scrolling",L(Er(S),{autoscrolling:!0,behavior:R}),r(),!0):!1},[r,L,N]),$=a.useCallback((R,{align:S="start",behavior:C="auto",scrollMargin:O=E.current}={},{keepPreviousPeek:A=!1}={})=>{let Z=u.current,te=K.current;if(!Z||!te||!Z.contains(R))return!1;let re=jr({align:S,element:R,scrollMargin:A?O+v.current:O,spacer:U.current,viewport:te}),se=Nr({content:Z,scrollTop:re,spacer:U.current,viewport:te});return N(se),w.current={element:R,viewportTop:Pe(R,te)},h.current=A?"anchored-to-message":"settling-jump",o.current=A?R:null,L(re,{behavior:C}),r(),!0},[r,L,N]),q=a.useCallback(()=>{let R=o.current;return!R||!R.isConnected||h.current!=="anchored-to-message"?!1:$(R,{align:"start"},{keepPreviousPeek:!0})},[$]),Y=a.useCallback((R,S)=>{let C=y.current.get(R);return C?(d.current=!0,$(C,S)?(g.current=null,!0):(g.current={messageId:R,options:S},!0)):m.current===0?(g.current={messageId:R,options:S},d.current=!0,!0):!1},[$]);return{flushPendingScrollToMessage:a.useCallback(()=>{let R=g.current;if(!R)return!1;let S=y.current.get(R.messageId);return!S||!$(S,R.options)?!1:(g.current=null,d.current=!0,!0)},[$]),reanchorToAnchoredMessage:q,scrollToElement:$,scrollToEnd:le,scrollToMessage:Y,scrollToStart:G}}function Pt(e,t){let n=e,r=new Set;return{getSnapshot:()=>n,hasListeners:()=>r.size>0,setSnapshot:o=>{t(n,o)||(n=o,r.forEach(l=>l()))},subscribe:(o,l,i)=>{let c=r.size===0;return r.add(o),c&&l?.(),()=>{r.delete(o),r.size===0&&i?.()}}}}function _r(e,t){return Pt(e,t)}function Or(){return Pt($e,Mr)}function Pr(e,t){return e.start===t.start&&e.end===t.end}function Mr(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?!1:e.visibleMessageIds.every((n,r)=>n===t.visibleMessageIds[r])}function Lr({autoScroll:e,scrollEdgeThreshold:t,scrollMargin:n,scrollPreviousItemPeek:r}){let o=a.useRef(e),l=a.useRef(!1),i=a.useRef(null),c=a.useRef(!1),u=a.useRef(t),d=a.useRef(0),m=a.useRef(null),y=a.useRef(0),h=a.useRef(e?"following-bottom":"free-scrolling"),g=a.useRef(new Map),w=a.useRef(null),E=a.useRef(null),v=a.useRef(null),T=a.useRef(r),H=a.useRef(!0),U=a.useRef(null),K=a.useRef(n),z=a.useRef(null),N=a.useRef(0),L=a.useRef(0),G=a.useRef(null),le=a.useRef(null),$=a.useRef(null),q=a.useRef(null),Y=a.useRef(null),R=a.useRef(null),S=a.useRef(null),C=a.useRef(null),O=a.useRef(new Set),A=a.useRef(new WeakSet);return $.current===null&&($.current=_r(kt,Pr)),C.current===null&&(C.current=Or()),o.current=e,u.current=t,K.current=n,T.current=r,{autoScrollRef:o,autoscrollingRef:l,autoscrollingTimeoutRef:q,streamingTurnRef:v,contentRef:i,defaultScrollPositionAppliedRef:c,firstItemRef:m,itemCountRef:d,lastScrollTopRef:y,messageElementsRef:g,modeRef:h,pendingScrollFrameRef:z,pendingScrollToMessageRef:w,prependRestoreRef:E,preserveScrollOnPrependRef:H,rootRef:U,scrollEdgeThresholdRef:u,scrollMarginRef:K,scrollPreviousItemPeekRef:T,spacerGapRef:N,spacerHeightRef:L,spacerRef:G,stateFrameRef:le,stateStore:$.current,viewportRef:Y,visibilityFrameRef:R,visibilityObserverRef:S,visibilityStore:C.current,visibleMessageIdsRef:O,handledScrollAnchorsRef:A}}function ft(e,t){return a.useCallback(n=>{e.current=n,n&&t()},[e,t])}function $r({autoScroll:e=!1,defaultScrollPosition:t="end",scrollEdgeThreshold:n=pr,scrollPreviousItemPeek:r=mr,scrollMargin:o=hr}){let l=Lr({autoScroll:e,scrollEdgeThreshold:n,scrollMargin:o,scrollPreviousItemPeek:r}),{streamingTurnRef:i,autoScrollRef:c,autoscrollingRef:u,autoscrollingTimeoutRef:d,contentRef:m,defaultScrollPositionAppliedRef:y,firstItemRef:h,itemCountRef:g,lastScrollTopRef:w,messageElementsRef:E,modeRef:v,pendingScrollFrameRef:T,pendingScrollToMessageRef:H,prependRestoreRef:U,preserveScrollOnPrependRef:K,rootRef:z,scrollEdgeThresholdRef:N,scrollMarginRef:L,scrollPreviousItemPeekRef:G,spacerGapRef:le,spacerHeightRef:$,spacerRef:q,stateFrameRef:Y,stateStore:R,viewportRef:S,visibilityFrameRef:C,visibilityObserverRef:O,visibilityStore:A,visibleMessageIdsRef:Z,handledScrollAnchorsRef:te}=l,re=a.useRef(t);re.current!==t&&(re.current=t,y.current=!1);let se=a.useCallback(f=>{let p=z.current,b=S.current,k=[f.start&&"start",f.end&&"end"].filter(Boolean).join(" "),ee=u.current;for(let D of[p,b])D&&(k?D.setAttribute("data-scrollable",k):D.removeAttribute("data-scrollable"),D.toggleAttribute("data-autoscrolling",ee))},[]),ye=a.useCallback(f=>{let p=S.current?.scrollTop??0,b=p<w.current-Le;w.current=p,c.current&&!f.end&&v.current!=="settling-jump"&&v.current!=="anchored-to-message"?v.current="following-bottom":v.current==="following-bottom"&&f.end&&b&&!u.current&&(v.current="free-scrolling")},[]),J=a.useCallback(()=>{let f=vr({content:m.current,scrollEdgeThreshold:N.current,spacer:q.current,viewport:S.current});ye(f);let p=v.current==="following-bottom"?{...f,end:!1}:f;se(p),R.setSnapshot(p)},[ye,R,se]),ae=a.useCallback(()=>{Y.current===null&&(Y.current=window.requestAnimationFrame(()=>{Y.current=null,J()}))},[J]),F=a.useCallback(()=>{A.hasListeners()&&C.current===null&&(C.current=window.requestAnimationFrame(()=>{C.current=null,A.hasListeners()&&A.setSnapshot(yr({content:m.current,scrollMargin:L.current,scrollPreviousItemPeek:G.current,spacer:q.current,viewport:S.current,visibleMessageIds:Z.current}))}))},[A]),{flushPendingScrollToMessage:I,reanchorToAnchoredMessage:M,scrollToElement:V,scrollToEnd:j,scrollToMessage:Q,scrollToStart:W}=kr({refs:l,commitScrollState:J,scheduleStateCommit:ae,scheduleVisibilitySync:F}),B=a.useCallback(()=>{let f=U.current,p=S.current;if(!f||!p||!f.element.isConnected)return!1;let b=Pe(f.element,p)-f.viewportTop;return Math.abs(b)<=Le?!1:(p.scrollTop+=b,f.viewportTop=Pe(f.element,p),ae(),F(),!0)},[ae,F]),X=a.useCallback(()=>{let f=m.current,p=S.current;if(!f||!p){U.current=null;return}let b=Cr({content:f,spacer:q.current,viewport:p});U.current=b?{element:b,viewportTop:Pe(b,p)}:null},[]),pe=a.useCallback(()=>{T.current===null&&(T.current=window.requestAnimationFrame(()=>{T.current=null,I()&&X()}))},[X,I]),ie=a.useCallback(()=>{if(!t||y.current||g.current===0)return!1;let f=!1;if(t==="last-anchor"){let p=m.current,b=S.current,k=p&&b?Tr(je(p,q.current)):null;if(!p||!b||!k)f=j({behavior:"auto"});else{let ee=_t(k,b);f=Ze({content:p,spacer:q.current,viewport:b})-ee<=b.clientHeight?j({behavior:"auto"}):V(k,{align:"start"},{keepPreviousPeek:!0})}}else f=t==="end"?j({behavior:"auto"}):W({behavior:"auto"});return f?(y.current=!0,!0):!1},[t,V,j,W]),Re=a.useCallback(()=>{let f=m.current;if(!f)return;let p=je(f,q.current),b=g.current,k=h.current;g.current=p.length,h.current=p[0]??null,(()=>{if(I())return;if(b===0){if(ie()||p.length>0&&c.current&&j({behavior:"auto"}))return;J(),F();return}let ee=k?p.indexOf(k):-1;if(K.current&&ee>0){B();return}if(p.length>b){let D=Rr(p,b);if(D){if(c.current&&v.current==="following-bottom"&&Sr(p,b)){j({behavior:"auto"});return}V(D,{align:"start"},{keepPreviousPeek:!0}),te.current.add(D);return}}if(p.length===b){let D=wr(p,te.current);if(D){V(D,{align:"start"},{keepPreviousPeek:!0}),te.current.add(D);return}}v.current==="following-bottom"&&c.current?j({behavior:"auto"}):(J(),F())})(),X()},[ie,X,J,I,B,F,V,j]),we=a.useCallback(()=>{if(v.current==="following-bottom"&&c.current){j({behavior:"auto"});return}let f=$.current;if(M()){c.current&&f>0&&$.current===0&&j({behavior:"auto"});return}ae(),F()},[M,ae,F,j]),Se=a.useCallback(()=>{let f=S.current;if(!(!f||!A.hasListeners())){if(typeof IntersectionObserver>"u"){F();return}O.current||(O.current=new IntersectionObserver(p=>{for(let b of p){let k=b.target.dataset.messageId;k&&(b.isIntersecting?Z.current.add(k):Z.current.delete(k))}F()},{root:f,rootMargin:`${-(L.current+G.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]})),E.current.forEach(p=>{O.current?.observe(p)}),F()}},[F,A]),me=a.useCallback(()=>{C.current!==null&&(window.cancelAnimationFrame(C.current),C.current=null),O.current?.disconnect(),O.current=null,Z.current.clear(),A.setSnapshot($e)},[A]),Te=a.useCallback((f,p,b)=>{if(p){E.current.set(f,p),O.current?.observe(p),F(),H.current?.messageId===f&&pe();return}b&&E.current.get(f)===b&&(E.current.delete(f),Z.current.delete(f),O.current?.unobserve(b),F())},[pe,F]),Ie=a.useCallback(()=>{(v.current==="following-bottom"||v.current==="anchored-to-message"||v.current==="settling-jump")&&(i.current=null,v.current="free-scrolling")},[]),ce=a.useCallback(()=>se(R.getSnapshot()),[R,se]),he=ft(z,ce),ue=ft(S,ce),ke=a.useCallback(f=>{m.current=f},[]),Ce=a.useCallback(f=>{q.current=f,le.current=Ir(f?.parentElement??null)},[]),_e=a.useCallback(()=>{J(),F(),X()},[X,J,F]),Oe=a.useMemo(()=>({handleContentChange:Re,handleResize:we,observeVisibility:Se,preserveScrollOnPrependRef:K,scrollToEnd:j,scrollToMessage:Q,scrollToStart:W,setContentElement:ke,setRootElement:he,setSpacerElement:Ce,setViewportElement:ue,stateStore:R,syncAfterScroll:_e,unobserveVisibility:me,userScrollIntent:Ie,viewportRef:S,visibilityStore:A}),[Re,we,Se,j,Q,W,ke,he,Ce,ue,R,_e,me,Ie,A]);return a.useLayoutEffect(()=>{ie()},[ie]),a.useEffect(()=>()=>{Y.current!==null&&(window.cancelAnimationFrame(Y.current),Y.current=null),C.current!==null&&(window.cancelAnimationFrame(C.current),C.current=null),d.current!==null&&(window.clearTimeout(d.current),d.current=null),T.current!==null&&(window.cancelAnimationFrame(T.current),T.current=null),O.current?.disconnect(),O.current=null},[]),a.useLayoutEffect(()=>{if(e&&v.current==="following-bottom"&&g.current>0){j({behavior:"auto"});return}J()},[e,J,j]),{context:Oe,registerMessage:Te}}function Dr(e){let t=a.useRef(e);return t.current=e,t}var Mt=a.createContext(null),Lt=a.createContext(null);function xe(){let e=a.useContext(Mt);if(!e)throw new Error("useMessageScroller must be used within a MessageScroller.");return e}function Ur(){let e=a.useContext(Lt);if(!e)throw new Error("MessageScrollerItem must be used within a MessageScroller.");return e}function $t(){let{scrollToEnd:e,scrollToMessage:t,scrollToStart:n}=xe();return a.useMemo(()=>({scrollToEnd:e,scrollToMessage:t,scrollToStart:n}),[e,t,n])}function Dt(){let{observeVisibility:e,unobserveVisibility:t,visibilityStore:n}=xe(),r=a.useCallback(o=>n.subscribe(o,e,t),[e,t,n]);return a.useSyncExternalStore(r,n.getSnapshot,n.getSnapshot)}function Fr({autoScroll:e=!1,children:t,defaultScrollPosition:n="end",scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:l}){let{context:i,registerMessage:c}=$r({autoScroll:e,defaultScrollPosition:n,scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:l});return s.jsx(Mt.Provider,{value:i,children:s.jsx(Lt.Provider,{value:c,children:t})})}function Vr({children:e,...t}){let{setRootElement:n}=xe();return s.jsx("div",{ref:n,...t,children:e})}function Br({"aria-label":e,children:t,onKeyDown:n,onScroll:r,onTouchMove:o,onWheel:l,preserveScrollOnPrepend:i=!0,ref:c,role:u,tabIndex:d,...m}){let{handleResize:y,preserveScrollOnPrependRef:h,setViewportElement:g,syncAfterScroll:w,userScrollIntent:E,viewportRef:v}=xe();h.current=i;let T=a.useCallback(N=>{g(N),Ae(c)?.(N)},[c,g]);function H(N){w(),r?.(N)}function U(N){E(),l?.(N)}function K(N){E(),o?.(N)}function z(N){br.has(N.key)&&E(),n?.(N)}return a.useEffect(()=>{let N=v.current;if(!N||typeof ResizeObserver>"u")return;let L=0,G=new ResizeObserver(()=>{window.cancelAnimationFrame(L),L=window.requestAnimationFrame(y)});return G.observe(N),()=>{window.cancelAnimationFrame(L),G.disconnect()}},[y,v]),s.jsx("div",{ref:T,role:u??"region","aria-label":e??"Messages",tabIndex:d??0,onKeyDown:z,onScroll:H,onTouchMove:K,onWheel:U,...m,children:t})}function Hr({"aria-relevant":e,children:t,ref:n,role:r,spacerClassName:o,...l}){let{handleContentChange:i,handleResize:c,setContentElement:u,setSpacerElement:d}=xe(),m=a.useRef(null),y=a.useCallback(h=>{m.current=h,u(h),Ae(n)?.(h)},[n,u]);return a.useLayoutEffect(()=>{let h=m.current;if(!h||(i(),typeof MutationObserver>"u"))return;let g=new MutationObserver(()=>{i()});return g.observe(h,{childList:!0}),()=>g.disconnect()},[i]),a.useEffect(()=>{let h=m.current;if(!h||typeof ResizeObserver>"u")return;let g=0,w=new ResizeObserver(()=>{window.cancelAnimationFrame(g),g=window.requestAnimationFrame(c)});return w.observe(h),()=>{window.cancelAnimationFrame(g),w.disconnect()}},[c]),s.jsxs("div",{ref:y,role:r??"log","aria-relevant":e??"additions",...l,children:[t,s.jsx("div",{ref:d,"aria-hidden":"true","data-message-scroller-spacer":"",hidden:!0,className:o})]})}function zr({messageId:e,ref:t,scrollAnchor:n=!1,...r}){let o=Ur(),l=a.useRef(null),i=a.useCallback(c=>{let u=l.current;l.current=c,e&&o(e,c,u),Ae(t)?.(c)},[e,t,o]);return s.jsx("div",{ref:i,"data-message-id":e,"data-scroll-anchor":n?"true":"false",...r})}function Wr({behavior:e="smooth",children:t,direction:n="end",onClick:r,render:o,tabIndex:l,type:i="button",...c}){let{scrollToEnd:u,scrollToStart:d,stateStore:m}=xe(),y=Dr(r),h=a.useCallback(v=>m.subscribe(v),[m]),g=a.useCallback(()=>{let v=m.getSnapshot();return n==="start"?v.start:v.end},[n,m]),w=a.useSyncExternalStore(h,g,g),E=a.useCallback(v=>{w&&(y.current?.(v),v.defaultPrevented||(v.currentTarget.blur(),n==="start"?d({behavior:e}):u({behavior:e})))},[e,n,w,y,u,d]);return cr({defaultTagName:"button",props:ze({type:i,inert:!w,tabIndex:w?l:-1,children:t??s.jsxs("span",{children:["Scroll to ",n]}),onClick:E},c),render:o,state:{active:w,direction:n},stateAttributesMapping:{active:v=>({"data-active":v?"true":"false"})}})}var ve={Provider:Fr,Root:Vr,Viewport:Br,Content:Hr,Item:zr,Button:Wr};const Kr=ve.Provider;function qr({className:e,...t}){return s.jsx(ve.Root,{className:P("relative flex size-full min-h-0 flex-col overflow-hidden",e),...t})}function Gr({className:e,...t}){return s.jsx(ve.Viewport,{className:P("size-full min-h-0 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]",e),...t})}function Yr({className:e,...t}){return s.jsx(ve.Content,{className:P("flex h-max min-h-full flex-col",e),...t})}function Jr({className:e,...t}){return s.jsx(ve.Item,{className:P("min-w-0 shrink-0",e),...t})}function Qr({className:e,...t}){return s.jsx(ve.Button,{direction:"end",behavior:"smooth",render:({active:n,...r})=>n?s.jsx(fe,{...r,type:"button",variant:"outline",size:"icon",className:P("absolute right-4 bottom-4 z-20 rounded-full bg-background ",e),"aria-label":"Scroll to latest message",children:s.jsx(nn,{})}):null,...t})}function Xr(e){if(!e)return"";const t=e.startsWith("?")?e.slice(1):e,n=new URLSearchParams(t);return n.get("message_id")?.trim()||n.get("message")?.trim()||""}function Zr(e){const t=e.scrollTarget.trim();return t?e.alreadyScrolledTo===t?{scroll:!1}:e.messageIds.includes(t)?{scroll:!0,id:t}:{scroll:!1}:{scroll:!1}}const eo="lobu-spa";function pt(e){return typeof e=="string"&&/^https?:\/\//i.test(e.trim())}function De(e,t){return t.type==="tool-call"?`tc-${t.toolCallId}`:t.type==="reasoning"?`${e.id}-reasoning`:t.type==="bash"?`${e.id}-bash-${t.command.slice(0,24)}`:t.type==="error"?`${e.id}-error`:`${e.id}-text-${t.text.slice(0,24)}`}const Fo=({afterMessagesContent:e,readOnly:t=!1,readerPositionMode:n="messages",interactionExtension:r,onRunSelect:o})=>{const{messages:l,agentId:i,conversationId:c}=Ee(),{data:u=[]}=rn(i,{conversationId:c});return s.jsx($n,{extension:r,children:s.jsxs("div",{"data-agent-thread":!0,className:"flex min-h-0 flex-1 flex-col",children:[s.jsx(to,{messages:l,trips:u,mode:n,afterMessagesContent:e,onRunSelect:o}),t?null:s.jsx("div",{className:Sn,children:s.jsx(Io,{})})]})})},to=({messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})=>s.jsx(Kr,{autoScroll:!0,defaultScrollPosition:n==="runs"?"last-anchor":"end",scrollPreviousItemPeek:48,children:s.jsx(ro,{messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})});function no(e){if(!e.startsWith("sep:"))return null;const t=Number(e.slice(4));return Number.isFinite(t)&&t>0?t:null}const ro=({messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})=>{const{currentAnchorId:l}=Dt(),{scrollToMessage:i}=$t(),c=a.useRef(null);a.useEffect(()=>{if(e.length===0||typeof window>"u")return;const d=Zr({messageIds:e.map(m=>m.id),scrollTarget:Xr(window.location.search),alreadyScrolledTo:c.current});d.scroll&&(c.current=d.id,i(d.id,{align:"start",behavior:"smooth"}))},[e,i]);const u=d=>n==="runs"?d.id.startsWith("sep:"):d.role==="user";return s.jsxs(qr,{children:[s.jsx(Gr,{"aria-label":n==="runs"?"Automation run history":"Conversation",children:s.jsxs(Yr,{className:P(Ge,Tn),children:[e.map(d=>{const m=n==="runs"&&o?no(d.id):null;return s.jsx(Jr,{messageId:d.id,scrollAnchor:u(d),"aria-current":d.id===l?"location":void 0,className:P("flex flex-col",n==="runs"&&u(d)&&"border-l-2 border-transparent pl-2 transition-colors",n==="runs"&&d.id===l&&"border-primary"),children:m!=null?s.jsx(xo,{message:d,onClick:()=>o?.(m)}):s.jsx(ao,{message:d})},d.id)}),t.map(d=>s.jsx(so,{trip:d},d.id)),s.jsx(lo,{}),r?s.jsx("div",{className:"mt-auto shrink-0 py-2",children:r}):null]})}),e.length>0?s.jsx(oo,{messages:e,mode:n}):null,s.jsx(Qr,{})]})},oo=({messages:e,mode:t})=>{const{scrollToMessage:n}=$t(),{currentAnchorId:r,visibleMessageIds:o}=Dt(),l=t==="runs"?e.flatMap(c=>c.parts).filter(c=>c.type==="tool-call"&&c.toolName==="tool-approval"&&c.args!==null&&typeof c.args=="object"&&c.args.status==="pending").length:0,i=e.flatMap(c=>{if(!(t==="runs"?c.id.startsWith("sep:"):c.role==="user"))return[];const d=c.parts.find(m=>m.type==="text");return[{id:c.id,label:d?.type==="text"?d.text:"Automation run"}]});return i.length===0?null:s.jsxs(cn,{children:[s.jsx(un,{asChild:!0,children:s.jsxs(fe,{type:"button",variant:"outline",size:"icon",className:P("absolute top-1/2 right-4 z-20 -translate-y-1/2 rounded-full bg-background/95 ",l>0&&"w-auto px-3"),"aria-label":l>0?`Open transcript outline, ${l} ${l===1?"approval":"approvals"} waiting`:"Open transcript outline",children:[s.jsx(dn,{}),l>0?s.jsxs("span",{className:"text-xs tabular-nums",children:[l," waiting"]}):null]})}),s.jsxs(fn,{side:"left",align:"center",className:"w-80 space-y-3 p-3",children:[s.jsxs("div",{className:"px-1",children:[s.jsx("p",{className:"text-sm font-medium",children:"Transcript outline"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:t==="runs"?"Track and jump between Automation runs.":"Track and jump between your messages."})]}),s.jsx("div",{className:"max-h-80 space-y-1 overflow-y-auto",children:i.map(c=>{const u=c.id===r,d=o.includes(c.id);return s.jsxs(fe,{type:"button",variant:u?"secondary":"ghost",className:"h-auto w-full justify-start gap-2 px-2 py-2 text-left text-xs font-normal","aria-current":u?"location":void 0,onClick:()=>n(c.id,{align:"start",behavior:"smooth"}),children:[s.jsx("span",{className:P("size-1.5 shrink-0 rounded-full bg-muted-foreground/30",d&&"bg-primary/60",u&&"bg-primary")}),s.jsx("span",{className:"line-clamp-2",children:c.label})]},c.id)})})]})]})},so=({trip:e})=>s.jsxs("div",{className:P(Ge,"flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive"),children:[s.jsx(an,{className:"mt-0.5 size-4 shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"font-medium",children:["Guardrail blocked: ",e.guardrailName," ",s.jsxs("span",{className:"font-normal opacity-70",children:["(",e.stage,")"]})]}),e.reason?s.jsx("div",{className:"mt-0.5 break-words opacity-80",children:e.reason}):null]})]}),lo=()=>{const{currentSuggestions:e,starters:t,messages:n,running:r,append:o}=Ee(),l=Kn(e,t,n.length);return r||l.length===0?null:s.jsx(Nn,{prompts:l,className:P(Ge,n.length===0&&"mt-auto"),onPick:i=>o(i)})},ao=({message:e})=>e.role==="user"?s.jsx(io,{message:e}):e.role==="system"?s.jsx(vo,{message:e}):s.jsx(fo,{message:e}),Ut=({attachment:e})=>{const t=e.isImage?e.imageDataUrl??e.url:void 0;if(t)return s.jsx("a",{href:e.url??t,target:"_blank",rel:"noreferrer",children:s.jsx("img",{src:t,alt:e.name,className:"max-h-64 rounded-lg border object-contain"})});const n=s.jsxs(s.Fragment,{children:[s.jsx(He,{className:"h-3 w-3 shrink-0"}),s.jsx("span",{className:"max-w-[14rem] truncate",children:e.name})]});return s.jsx("div",{className:"flex items-center gap-1.5 rounded-md border bg-background px-2 py-1 text-xs",children:e.url?s.jsx("a",{href:e.url,target:"_blank",rel:"noreferrer",className:"flex items-center gap-1.5 hover:underline",children:n}):n})},io=({message:e})=>{const t=e.parts.filter(n=>n.type==="bash");return t.length>0?s.jsx("div",{className:xt,children:s.jsx("div",{className:"space-y-2",children:t.map(n=>s.jsx(co,{part:n},De(e,n)))})}):s.jsx("div",{className:Cn,children:s.jsxs("div",{className:P(Ne,"px-3 py-2 text-sm"),children:[e.attachments&&e.attachments.length>0?s.jsx("div",{className:"mb-1.5 flex flex-wrap gap-1.5",children:e.attachments.map(n=>s.jsx(Ut,{attachment:n},n.id))}):null,e.parts.map(n=>n.type==="text"?s.jsx("div",{className:"whitespace-pre-wrap break-words",children:s.jsx(Xe,{text:n.text,renderText:r=>r})},De(e,n)):null)]})})},co=({part:e})=>{const t=e.cancelled||e.exitCode!==void 0&&e.exitCode!==0;return s.jsxs("div",{className:P(Ne,"overflow-hidden text-xs"),children:[s.jsxs("div",{className:"flex items-center gap-1.5 border-border/60 border-b px-3 py-1.5",children:[s.jsx(pn,{className:"size-3.5 shrink-0 text-muted-foreground"}),s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-foreground/90",children:e.command}),e.cancelled?s.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-medium text-[10px] text-muted-foreground",children:"cancelled"}):t?s.jsxs("span",{className:"rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-[10px] text-destructive",children:["exit ",e.exitCode]}):null]}),e.output.trim()?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-foreground/80",children:e.output}):null]})},Ft=new Set(["question","link-button","tool-approval"]),uo="subscription-candidate",fo=({message:e})=>{const t=Ye(),{agentId:n,workspaceSlug:r}=Ee(),o=u=>u.type==="tool-call"&&(Ft.has(u.toolName)||t?.toolNames.has(u.toolName)),l=e.parts.filter(u=>u.type==="tool-call"&&!o(u)&&u.toolName!==uo),i=e.parts.filter(u=>u.type!=="tool-call"||o(u)),c=e.parts.flatMap(u=>{if(u.type!=="tool-call")return[];const d=Rt(u.result);return d?[d]:[]});return s.jsx("div",{className:xt,children:s.jsxs("div",{className:"space-y-2 text-sm",children:[l.length>0?s.jsx(ho,{tools:l,workspaceSlug:r}):null,n&&r?c.map(u=>s.jsx(po,{candidate:u,agentId:n,workspaceSlug:r},`${u.connector_key}:${u.resource_ref}`)):null,i.map(u=>s.jsx(bo,{part:u},De(e,u))),e.attachments&&e.attachments.length>0?s.jsx("div",{className:"flex flex-wrap gap-2",children:e.attachments.map(u=>s.jsx(Ut,{attachment:u},u.id))}):null]})})},po=({candidate:e,agentId:t,workspaceSlug:n})=>s.jsxs("div",{className:P(Ne,"flex items-center justify-between gap-3 p-3"),children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"truncate text-sm font-medium",children:e.label}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Run this agent when the resource changes."})]}),s.jsx(fe,{asChild:!0,size:"sm",variant:"outline",className:"shrink-0",children:s.jsxs(gt,{to:"/$owner/automations/new",params:{owner:n},search:{agent:t,platform:e.connector_key,resource_type:e.resource_type,resource:e.resource_ref,events:e.suggested_event_keys?.join(","),label:e.label},children:[s.jsx(hn,{className:"mr-1.5 h-4 w-4"}),"Add automation"]})})]});function mo(e){try{return JSON.parse(e)}catch{return null}}function Vt(e){if(Array.isArray(e)){const o=e.flatMap(l=>l?.type==="text"&&typeof l.text=="string"?Vt(l.text)??[]:[]);return o.length>0?[...new Set(o)]:null}const t=typeof e=="string"&&e.trimStart().startsWith("{")?mo(e):e;if(!t||typeof t!="object")return null;const n=t.events_persisted;if(!Array.isArray(n))return null;const r=n.flatMap(o=>{const l=o&&typeof o=="object"?o.id:null;return typeof l=="number"&&Number.isSafeInteger(l)&&l>0?[l]:[]});return r.length>0?r:null}const ho=({tools:e,workspaceSlug:t})=>s.jsxs(Nt,{defaultOpen:!1,children:[s.jsx(Et,{children:e.length===1?ot(e[0].args,e[0].toolName)??e[0].toolName:`${e.length} tool calls`}),s.jsx(It,{children:e.map(n=>{const r=ot(n.args,n.toolName),o=n.args!==void 0&&n.args!==null,l=n.result!==void 0&&n.result!==null,i=Vt(n.result);return s.jsxs(At,{icon:mn,label:s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"font-medium",children:r??n.toolName}),r?s.jsx("span",{className:"text-muted-foreground",children:n.toolName}):null,n.isError?s.jsx("span",{className:"rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-[10px] text-destructive",children:"error"}):null]}),status:n.isError?"active":"complete",children:[o?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:Fe(n.args)}):null,l?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:Fe(n.result)}):null,i&&t?s.jsx(ir,{ownerSlug:t,eventIds:i}):null]},n.toolCallId)})})]}),go=({text:e})=>{let t=e,n=null;const r=e.match(/\{[\s\S]*\}/);if(r)try{const l=JSON.parse(r[0])?.error?.message;typeof l=="string"&&l.trim()&&(t=l,n=e)}catch{}return s.jsxs("div",{className:"flex gap-2 rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2.5 text-sm",children:[s.jsx(bn,{className:"mt-0.5 size-4 shrink-0 text-destructive"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsx("p",{className:"text-foreground/80",children:t}),n&&s.jsxs("details",{className:"text-xs text-muted-foreground",children:[s.jsx("summary",{className:"cursor-pointer select-none hover:text-foreground",children:"Technical details"}),s.jsx("pre",{className:"mt-1 overflow-x-auto whitespace-pre-wrap break-all font-mono",children:n})]})]})]})},bo=({part:e})=>{const t=Ye();return e.type==="reasoning"?s.jsx(lr,{}):e.type==="error"?s.jsx(go,{text:e.text}):e.type==="text"?e.text.trim()?s.jsx(Xe,{text:e.text,renderText:n=>s.jsx(gn,{text:n})}):null:e.type!=="tool-call"?null:Ft.has(e.toolName)||t?.toolNames.has(e.toolName)?s.jsx(Ao,{toolName:e.toolName,args:e.args}):null},xo=({message:e,onClick:t})=>{const n=e.parts.find(r=>r.type==="text");return s.jsx("button",{type:"button",onClick:t,className:P(Ne,"block w-full cursor-pointer whitespace-pre-wrap break-words px-3 py-2 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/50"),children:n?.type==="text"?n.text:"Automation run"})},vo=({message:e})=>s.jsx("div",{className:"self-stretch",children:s.jsx("div",{className:P(Ne,"px-3 py-2 text-xs text-muted-foreground"),children:e.parts.map(t=>t.type==="text"?s.jsx("div",{className:"whitespace-pre-wrap break-words",children:s.jsx(Xe,{text:t.text,renderText:n=>n})},De(e,t)):null)})}),yo="/mcp-apps/interaction/index.html";function mt(e){return new Promise(t=>{e({onSettled:(n,r)=>t(!!r)})})}const Ro=({src:e,title:t,renderPayload:n,onToolCall:r,onOpenLink:o})=>{const l=a.useRef(null),[i,c]=a.useState(48),u=a.useRef({renderPayload:n,onToolCall:r,onOpenLink:o});return u.current={renderPayload:n,onToolCall:r,onOpenLink:o},a.useEffect(()=>{const d=l.current;if(!d?.contentWindow)return;const m=new yn(null,{name:"Lobu",version:"1.0.0"},{openLinks:{},serverTools:{}},{hostContext:{theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"}});m.addEventListener("sizechange",({height:g})=>{typeof g=="number"&&c(Math.max(32,Math.ceil(g)))}),m.oncalltool=async({name:g,arguments:w})=>{const E=await u.current.onToolCall(g,w??{});return{isError:E,content:[{type:"text",text:E?"Action failed.":"Action completed."}]}},m.onopenlink=async({url:g})=>({isError:await u.current.onOpenLink(g)}),m.addEventListener("initialized",()=>{(async()=>(await m.sendToolInput({arguments:{}}),await m.sendToolResult({content:[],structuredContent:{...u.current.renderPayload,version:1,source:eo}})))()});const y=new Rn(d.contentWindow,d.contentWindow);m.connect(y).catch(g=>{console.error("[mcp-app-host] failed to initialize",g)});const h=new MutationObserver(()=>{m.setHostContext({theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"})});return h.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{h.disconnect(),y.close()}},[]),s.jsx("iframe",{ref:l,title:t,src:e,sandbox:"allow-scripts",style:{width:"100%",height:i,border:"none",display:"block"}})},wo=new Set(["action"]),So=["name","description","identity_md"];function oe(e){return e==null||e===""?"":typeof e=="string"?e:Fe(e)}function ht(e){return e===null?"(cleared)":e===void 0?"":typeof e=="string"?e===""?"":e:Fe(e)}function Ue(e){return e.length>0?e[0].toUpperCase()+e.slice(1):e}const Bt=new Set(["delete","disconnect","remove","remove_rule","reset","revoke"]);function Ke(e){return e&&Bt.has(e)?"warning":"default"}function qe(e,t){return e&&Bt.has(e)?{level:"high",reason:t}:{level:"normal"}}function To(e,t){const n=e.attribution==="automation"?"An Automation":"An agent",r=Object.keys(t),o=r.map(l=>({label:l,before:oe(e.current?.[l]),after:oe(t[l])}));return{title:`${n} proposes a change`,icon:"entity",impact:{level:"normal"},tone:"default",blocks:o.length>0?[{type:"diff",fields:o}]:[{type:"text",value:"No field changes.",muted:!0}],actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${r.join(", ")} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${r.join(", ")} was not applied.`}]}}function Co(e){const t=e.action??"change",n=e.proposal?.slug??e.proposal?.name??(e.proposal?.automation_id!=null?String(e.proposal.automation_id):void 0)??e.current?.slug??e.current?.name??"automation",r=[];e.action==="delete"&&r.push({type:"text",value:"This will archive the Automation.",muted:!0});const o=e.proposal??{},l=Object.keys(o).filter(i=>!wo.has(i)&&o[i]!==void 0).map(i=>({label:i,...e.action==="update"&&e.current?.[i]!==void 0?{before:ht(e.current?.[i])}:{},after:ht(o[i])}));return r.push(l.length>0?{type:"diff",fields:l}:{type:"text",value:"No field changes.",muted:!0}),{title:`${Ue(t)} Automation ${n}`,icon:"automation",impact:qe(e.action,"This archives the Automation and stops future runs."),tone:Ke(e.action),blocks:r,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${t} ${n} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${t} ${n} was not applied.`}]}}function jo(e){if(e.resourceKind==="automation")return Co(e);if(e.fields&&Object.keys(e.fields).length>0)return To(e,e.fields);const t=e.resourceKind==="entity"||e.proposal?.entity_id!==void 0||e.current?.entity_type!==void 0||e.proposal?.entity_type!==void 0;if(t&&(e.action==="link"||e.action==="unlink"))return Ln({...e,action:e.action});if(t){const l=e.proposal?.name??e.current?.name??e.proposal?.entity_id??e.current?.id??"entity",i=e.action??"change",c=[];if(e.action==="delete")c.push({type:"text",value:"This will delete the entity.",muted:!0});else{const u=Object.keys(e.proposal??{}).filter(d=>!["entity_id","id"].includes(d)&&e.proposal?.[d]!==void 0&&oe(e.proposal?.[d])!==oe(e.current?.[d])).map(d=>({label:d,...e.action==="update"?{before:oe(e.current?.[d])}:{},after:oe(e.proposal?.[d])}));c.push(u.length>0?{type:"diff",fields:u}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${Ue(i)} entity ${l}`,icon:"entity",impact:qe(e.action,"This deletes the entity."),tone:Ke(e.action),blocks:c,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${i} ${l} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${i} ${l} was not applied.`}]}}const n=e.proposal?.agent_id??e.current?.id??"agent",r=e.action??"change",o=[];if(e.action==="delete")o.push({type:"text",value:"This will permanently delete the agent.",muted:!0});else{const l=So.filter(i=>e.proposal?.[i]!==void 0&&oe(e.proposal?.[i])!==oe(e.current?.[i])).map(i=>({label:i,...e.action==="update"?{before:oe(e.current?.[i])}:{},after:oe(e.proposal?.[i])}));o.push(l.length>0?{type:"diff",fields:l}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${Ue(r)} agent ${n}`,icon:"agent",impact:qe(e.action,"This permanently deletes the agent and its configuration."),tone:Ke(e.action),blocks:o,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${r} ${n} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${r} ${n} was not applied.`}]}}function No(e){const t=Array.isArray(e.options)?e.options.filter(o=>typeof o=="string"):[],n=[{type:"text",value:e.question||"The agent has a question."}];t.length===0&&n.push({type:"text",value:"Reply below to answer.",muted:!0});const r=t.map(o=>({id:o,label:o,variant:"outline",tool:"answer_question",args:{answer:o},resolvedLabel:`Answered: ${o}`}));return{title:"Input needed",icon:"question",tone:"default",blocks:n,actions:r}}function Eo(e,t){return{tone:"bare",actions:[{id:"open",label:e.label??"Open link",variant:"outline",icon:"external",terminal:!1,href:t}]}}const Ao=({toolName:e,args:t})=>{const n=xn(),r=vn(),{append:o}=Ee(),l=Ye(),i=t??{},c=l?.resolve(e,t)??null;let u=c?.view??null;const d={...c?.handlers??{}},m=new Set;if(!c){if(e==="tool-approval"&&typeof i.runId=="number"&&Number.isSafeInteger(i.runId)&&i.runId>0){const y=i.runId,h=typeof i.status=="string"?i.status:"pending",g=h==="pending",w=jo(i),E=h==="confirmed"?"Approved":Ue(h);u=g?w:{...w,title:`${w.title??"Approval"} · ${E}`,tone:h==="failed"?"warning":"default",blocks:[...w.blocks??[],{type:"text",value:typeof i.reviewedByName=="string"?`${h==="rejected"?"Rejected":"Approved"} by ${i.reviewedByName}.`:`${E}.`,muted:!0}],actions:(w.actions??[]).filter(v=>v.terminal===!1)},g&&(d.manage_operations=v=>{if(v.action==="approve")return mt(T=>n.mutate({run_id:y},T));if(v.action==="reject"){const T=typeof v.reason=="string"?v.reason:void 0;return mt(H=>r.mutate({run_id:y,...T?{reason:T}:{}},H))}return Promise.resolve(!0)})}else if(e==="question"){const y=Array.isArray(i.options)?i.options.filter(h=>typeof h=="string"):[];u=No(i),d.answer_question=h=>{const g=typeof h.answer=="string"?h.answer:"";return y.includes(g)?(o(g),Promise.resolve(!1)):Promise.resolve(!0)}}else if(e==="link-button"){if(!pt(i.url))return null;const y=i.url;m.add(y),u=Eo(i,y)}}return u?s.jsx(Ro,{src:yo,title:u.title??"Interaction",renderPayload:u,onToolCall:(y,h)=>d[y]?d[y](h):Promise.resolve(!0),onOpenLink:y=>!m.has(y)||!pt(y)?Promise.resolve(!0):(window.open(y,"_blank","noopener,noreferrer"),Promise.resolve(!1))}):null};function Fe(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}const Io=()=>{const{running:e,append:t,cancel:n,pendingAttachments:r,addAttachments:o,removeAttachment:l,initialDraft:i,currentSuggestions:c}=Ee(),u=ko({suggestions:e?null:c}),[d,m]=a.useState(i??""),y=a.useRef(null),h=a.useRef(null),g=_n(On),w=a.useRef(i??"");a.useEffect(()=>{const T=i??"";if(T===w.current)return;const H=w.current;w.current=T,T!==""&&m(U=>U===""||U===H?T:U)},[i]);const E=a.useRef(d);E.current=d;const v=()=>{e||(t(E.current),m(""),h.current?.clear())};return s.jsxs("div",{className:"rounded-2xl border bg-background transition-colors focus-within:ring-1 focus-within:ring-ring",children:[r.length>0?s.jsx("div",{className:"flex flex-wrap gap-1.5 px-3 pt-3",children:r.map(T=>s.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border bg-muted/50 px-2 py-1 text-xs",children:[s.jsx(He,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"max-w-[12rem] truncate",children:T.name}),s.jsx("button",{type:"button",className:"text-muted-foreground transition-colors hover:text-foreground","aria-label":"Remove attachment",onClick:()=>l(T.id),children:s.jsx(on,{className:"h-3 w-3"})})]},T.id))}):null,s.jsx(Pn,{value:d,onChange:m,onSubmit:v,searchRefs:g,handleRef:h,placeholder:u,className:"max-h-48 overflow-y-auto"}),s.jsxs("div",{className:"flex items-center justify-between px-3 pb-2",children:[s.jsx("input",{ref:y,type:"file",multiple:!0,className:"hidden",onChange:T=>{T.target.files&&o(T.target.files),T.target.value=""}}),s.jsxs(fe,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 rounded-full text-muted-foreground hover:text-foreground",onClick:()=>y.current?.click(),children:[s.jsx(He,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Attach files"})]}),e?s.jsxs(fe,{type:"button",size:"icon",variant:"secondary",className:"h-8 w-8 rounded-full",onClick:n,children:[s.jsx(sn,{size:"lg"}),s.jsx("span",{className:"sr-only",children:"Cancel"})]}):s.jsxs(fe,{type:"button",size:"icon",className:"h-8 w-8 rounded-full",onClick:v,children:[s.jsx(ln,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Send message"})]})]})]})};function ko({suggestions:e}){const t=e?.find(n=>n.message.trim().length>0)?.message;return t?`Recommended: ${t.trim()}`:"Chat… (@ to mention, / for commands)"}export{Fo as A,Uo as L,Do as R,er as h,Jn as s};
6
- //# sourceMappingURL=agent-thread-Cqf9ITrT.js.map
@@ -1,2 +0,0 @@
1
- import{c as b,s as k,r as o,jM as v,j as e,L as x,B as M,jN as P}from"./index-BoqrvLHQ.js";import{u as S,a as y,M as R}from"./use-mention-search-khySpz_V.js";import{P as C,s as I}from"./pending-seed-BBACroge.js";import{n as A,c as E}from"./agent-thread-storage-Bx2-WBHQ.js";import"./index-Vcq4gwWv.js";import"./use-automations-DfBtVzGa.js";function $({ownerSlug:i,starters:m,preferredMentionKinds:u,onSent:f}){const g=b(),{data:j=[]}=k(),l=S(R),n=o.useMemo(()=>new Set(u??[]),[u]),N=o.useCallback(async d=>{const t=await l(d);return n.size===0?t:[...t].sort((a,w)=>Number(n.has(w.kind))-Number(n.has(a.kind)))},[n,l]),r=v(j),[s,h]=o.useState(""),p=o.useRef(s);p.current=s;const c=d=>{const t=d.trim();if(!t||!r)return;const a=A();I(a,t),h(""),g(E(i,r.agentId,a)),f?.()};return e.jsxs("div",{className:"rounded-lg border bg-background p-4 transition-colors focus-within:ring-1 focus-within:ring-ring",children:[r?e.jsx(y,{value:s,onChange:h,onSubmit:()=>c(p.current),searchRefs:N,placeholder:"Ask Lobu…",className:"[&_.ProseMirror]:max-h-40 [&_.ProseMirror]:min-h-24 [&_.ProseMirror]:overflow-y-auto"}):e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Bring your"," ",e.jsx(x,{to:"/$owner/agents/connect",params:{owner:i},className:"text-foreground hover:underline",children:"agent"})," ","or"," ",e.jsx(x,{to:"/$owner/agents/new",params:{owner:i},search:{},className:"text-foreground hover:underline",children:"create a new agent"})," ","to get started."]}),e.jsxs("div",{className:"flex items-end justify-between gap-3 pt-2",children:[r&&m&&!s.trim()?e.jsx(C,{prompts:m,onPick:c}):e.jsx("span",{}),e.jsxs(M,{type:"button",size:"icon",className:"h-10 w-10 shrink-0 rounded-full",disabled:!r||!s.trim(),onClick:()=>c(s),children:[e.jsx(P,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Send message"})]})]})]})}export{$ as AssistComposer};
2
- //# sourceMappingURL=assist-composer-kG_heHXo.js.map
@@ -1,2 +0,0 @@
1
- import{M as k,j as e,L as P,eo as $,r as p,al as R,B as F,fM as w,ez as K,fa as q,aw as B,H as O,n as L,z as H,m as I,cm as z,hR as J,co as Q,fh as W,dL as Y,K as V,f1 as G,hS as U,hT as X,y as Z,i as ee,u as te}from"./index-BoqrvLHQ.js";import{E as se}from"./event-detail-DUvlqn9b.js";import{a as ne,M as ie}from"./needs-you-list-3uMsWcDv.js";import{S as re}from"./scoped-feed-bar-DNFL0sYX.js";import{C as ae,A as oe}from"./create-automation-form-CD6jSlWL.js";import{P as ue}from"./proposal-review-shell-C8ZfIAYn.js";import{u as A,a as ce,i as le}from"./runs-k2NpbZm8.js";import{E as de}from"./events-feed-DcKTkJVe.js";import{D as me,a as fe}from"./definition-comparison-D_qP25jR.js";import{R as xe}from"./runs-list-DUXRMkWN.js";import{a as T,h as ge}from"./use-automations-DfBtVzGa.js";function C({automationId:t}){const{currentOwner:s}=k();return s?e.jsx(P,{to:"/$owner/events",params:{owner:s},search:$({semanticTypes:["change"],eventCategory:"config",resourceKind:"automation",resourceId:t}),className:"text-sm text-primary underline underline-offset-4",children:"View definition history in Events"}):null}const pe={workspace:!0},he=6,je=["name","title"],S=10;function j(t){return t==null?!1:typeof t=="string"?t.trim().length>0:Array.isArray(t)?t.some(j):typeof t=="object"?Object.values(t).some(j):!0}function ye(t){const s=t.split("_").join(" ").trim();return s.charAt(0).toUpperCase()+s.slice(1)}function _({value:t,depth:s=0}){if(!j(t))return null;if(typeof t!="object"||t==null)return e.jsx("span",{className:"break-words",children:String(t)});if(s>=he)return e.jsx("span",{className:"break-words text-muted-foreground",children:JSON.stringify(t).slice(0,200)});if(Array.isArray(t))return e.jsx("ul",{className:"space-y-1.5",children:t.filter(j).map((a,u)=>e.jsx("li",{className:"border-l-2 border-border pl-2",children:e.jsx(_,{value:a,depth:s+1})},u))});const n=t,r=je.find(a=>typeof n[a]=="string"&&j(n[a])),i=Object.entries(n).filter(([a,u])=>a!==r&&j(u));return e.jsxs("div",{className:"space-y-1",children:[r?e.jsx("p",{className:"font-medium text-foreground",children:String(n[r])}):null,i.length>0?e.jsx("dl",{className:"space-y-1",children:i.map(([a,u])=>e.jsxs("div",{children:[e.jsxs("dt",{className:"inline text-muted-foreground",children:[ye(a),":"," "]}),e.jsx("dd",{className:"inline",children:typeof u=="object"?e.jsx("div",{className:"mt-1",children:e.jsx(_,{value:u,depth:s+1})}):e.jsx(_,{value:u,depth:s+1})})]},a))}):null]})}function E({run:t}){const s=t.completed_at??t.created_at;return e.jsx("time",{dateTime:new Date(s).toISOString(),title:q(s),className:"text-xs text-muted-foreground",children:K(s)})}function b({rows:t}){return t.length===0?null:e.jsx("ul",{className:"divide-y overflow-hidden rounded-lg border",children:t.map(s=>e.jsx("li",{children:s.content},s.key))})}function Ne({owner:t,automationId:s,failedRows:n}){const r=p.useId(),i=A(pe,{runTypes:["automation"],automationIds:[s],status:"completed"},t),a=i.data?.pages.flatMap(d=>d.runs)??[],u=a.filter(d=>j(d.output)),c=a.length-u.length,[o,...m]=u,f=i.data?.pages.length??0,{hasNextPage:x,isFetching:l,fetchNextPage:h}=i;p.useEffect(()=>{!o&&x&&!l&&f<S&&h()},[o,x,l,f,h]);const y=i.hasNextPage?e.jsx("div",{className:"flex justify-center",children:i.isFetchingNextPage?e.jsx(R,{role:"status","aria-label":"Loading earlier runs",className:"text-muted-foreground"}):e.jsx(F,{variant:"link",size:"sm",className:"h-auto p-0 text-xs font-normal text-muted-foreground",disabled:i.isFetching,onClick:()=>void i.fetchNextPage(),children:"Show earlier runs"})}):null,N=o?[...m.map(d=>({key:String(d.id),occurredAt:d.completed_at??d.created_at,content:e.jsxs("div",{className:"space-y-1 px-3 py-2 text-xs",children:[e.jsx(E,{run:d}),e.jsx(_,{value:d.output})]})})),...n].sort((d,g)=>(w(g.occurredAt)??0)-(w(d.occurredAt)??0)):[];return i.isError?e.jsxs("div",{className:"space-y-6 py-6",children:[e.jsx("p",{role:"alert",className:"text-sm text-muted-foreground",children:"Couldn't load this Automation's runs."}),e.jsx(b,{rows:n})]}):i.isLoading||!o&&x&&f<S?null:o?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{"aria-label":"Latest result",className:"space-y-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("h2",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Latest result"}),e.jsx(E,{run:o})]}),e.jsx("div",{className:"text-sm",children:e.jsx(_,{value:o.output})})]}),N.length>0?e.jsxs("section",{"aria-labelledby":r,className:"space-y-2",children:[e.jsx("h2",{id:r,className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Earlier results"}),e.jsx(b,{rows:N})]}):null,c>0?e.jsxs("p",{className:"text-xs text-muted-foreground",children:[c," other ",c===1?"run":"runs"," found nothing new."]}):null,y]}):e.jsxs("div",{className:"space-y-6 py-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:a.length===0?"This Automation hasn't run yet. Its results appear here, newest first.":`It ran ${a.length}${i.hasNextPage?"+":""} times without returning a result.`}),e.jsx(b,{rows:n}),y]})}function D(t){const{orgContext:s,hasOrgContext:n}=k(),{data:r,isLoading:i}=B(`/${t}`,s),{isAuthenticated:a}=O(),{isMember:u,isLoading:c}=L(),o=a&&u,m=r?.workspace,f=o?!n||i||c:i||c;return{organizationId:m?.id??"",isLoading:f}}function Be(t){return D(t)}const _e={workspace:!0};function M(t,s,n=!0){const r=n?_e:null,i=A(r,{runTypes:["automation"],automationIds:[s],status:"failed"},t),a=A(r,{runTypes:["automation"],automationIds:[s],status:"timeout"},t);return p.useMemo(()=>[...i.data?.pages[0]?.runs??[],...a.data?.pages[0]?.runs??[]].sort((u,c)=>Date.parse(c.created_at)-Date.parse(u.created_at)||c.id-u.id),[i.data,a.data])}function ve(t,s){const n=z(t),{decisions:r,notices:i}=p.useMemo(()=>{const c=n.attentionCards.filter(o=>o.automation_id===s);return{decisions:Q(c),notices:c.filter(o=>!J(o)&&o.unread&&o.notification_id!=null)}},[n.attentionCards,s]);return{attention:n,decisions:r,notices:i,markRead:c=>{c.length>0&&n.markManyRead.mutateAsync(c)},unreadFor:c=>i.flatMap(o=>o.run_id!=null&&o.run_id===c.run_id||W(o.href?.split(/[?#]/)[0]??"")?.eventId===Number(c.id)?[o.notification_id]:[])}}function be({owner:t,automationId:s,organizationId:n}){const r=Number(s),i=p.useMemo(()=>({producedByAutomationId:r}),[r]),{attention:a,decisions:u,notices:c,markRead:o,unreadFor:m}=ve(t,r),f=M(t,r);if(!Number.isFinite(r))return null;const x=f.map(l=>({key:`run:${l.id}`,occurredAt:l.completed_at??l.created_at,content:e.jsx(xe,{run:l,ownerSlug:t})}));return e.jsxs(e.Fragment,{children:[a.isError?e.jsx("p",{role:"alert",className:"mb-6 text-sm text-destructive",children:"Could not load notifications. Refresh to try again."}):u.length>0?e.jsxs("section",{"aria-label":"Needs you",className:"mb-6 space-y-2",children:[e.jsx("h2",{className:"px-1 text-sm font-semibold",children:"Needs you"}),e.jsx(ne,{owner:t,entries:u})]}):null,e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx(re,{owner:t,organizationId:n||null,activitySearch:{produced_by:String(r)}}),e.jsx(ie,{entries:c.map(l=>({unreadIds:[l.notification_id]})),disabled:a.markManyRead.isPending,onMarkRead:o})]}),e.jsx(de,{organizationId:n,ownerSlug:t,filters:i,foldRunSatellites:!1,unreadNotices:m,onMarkRead:o,extraRows:x,renderLead:(l,{hasEarlier:h})=>e.jsxs("div",{className:"mb-4 space-y-6",children:[e.jsxs("section",{"aria-label":"Latest result",className:"space-y-2",children:[e.jsx("h2",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Latest result"}),e.jsx(se,{owner:t,organizationId:n,eventId:l.id})]}),h?e.jsx("h2",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Earlier results"}):null]}),emptyState:e.jsx(Ne,{owner:t,automationId:r,failedRows:x})})]})}function Ae({agentId:t,automationId:s,runId:n,organizationId:r,onDone:i}){const[a,u]=p.useState({ready:!1,triggers:[]}),c=p.useCallback(d=>{u(g=>JSON.stringify(g)===JSON.stringify(d)?g:d)},[]),o=T(s,void 0,r,{includeVersions:!0}),m=o.data?.automation,{currentOwner:f}=k(),x=H({queryKey:["automations-list",f,"editor",s,m?.status],enabled:!!f&&!!r&&!!m,queryFn:async()=>{const g=(await Y("manage_automations",{action:"list",automation_id:s,status:m?.status,include_details:!0,limit:1},{slug:f})).automations.find(v=>v.automation_id===s);if(!g)throw new V("Automation not found",404);return g},staleTime:3e4}),l=x.data,h=p.useMemo(()=>m&&l?{automation_id:m.automation_id,name:l.name,slug:l.slug,description:l.description,prompt:l.prompt,sources:l.sources,reaction_script:m.reaction_script,managed_agent_id:l.managed_agent_id,device_worker_id:l.device_worker_id,agent_kind:l.agent_kind,delivery_target:l.delivery_target??void 0,execution_config:l.execution_config??void 0,model_config:l.model_config,tags:l.tags,keying_config:m.keying_config,reactions_guidance:l.reactions_guidance,triggers:l.triggers}:void 0,[m,l]),y=e.jsx("div",{className:"flex flex-col gap-4",children:[0,1,2].map(d=>e.jsx(I,{className:"h-16 w-full rounded-lg"},d))}),N=x.isError?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load the saved Automation definition."}),e.jsx("button",{type:"button",className:"text-primary underline underline-offset-4",onClick:()=>void x.refetch(),children:"Retry"})]}):o.isLoading||m&&x.isPending?y:h?e.jsx(ae,{organizationId:r,prefillAgentId:t??void 0,editingAutomation:h,createFields:{triggers:a.triggers},triggerFields:e.jsx(oe,{organizationId:r,initialTriggers:h.triggers??[],onChange:c},JSON.stringify(h.triggers??[])),hideHeader:!0,hideCancel:!0,submitDisabled:!a.ready,onClose:i}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automation not found. It may have been removed."});return t?e.jsxs("div",{className:"space-y-6",children:[e.jsx(ue,{resource:{kind:"automation",agentId:t,automationId:s},runId:n,onDone:i,children:({reviewMode:d,proposal:g})=>d==="active"?e.jsx(me,{current:g?.current??null,proposed:{...g?.current??{},...g?.proposedAfter??{}},render:v=>e.jsx(fe,{value:v})}):d==="loading"?y:d==="error"?null:N}),e.jsx(C,{automationId:s})]}):e.jsxs("div",{className:"space-y-6",children:[N,e.jsx(C,{automationId:s})]})}function He({owner:t,agentId:s,automationId:n,view:r,runId:i,onDone:a}){const{organizationId:u}=D(t),c=T(n,void 0,u),o=s??c.data?.automation?.managed_agent_id??null;return i||r==="definition"?e.jsx(Ae,{agentId:o,automationId:n,runId:i,organizationId:u,onDone:a},`${t}/${n}`):e.jsx(be,{owner:t,automationId:n,organizationId:u})}function Ie(t,s,n,r=!0){const{isAuthenticated:i}=O(),{isMember:a}=L(),u=ge(),c=r&&i&&a&&n?.status==="active",o=c&&n?.schedule_auto_paused_at!=null,m=Number(s),[f]=M(t,m,o&&Number.isFinite(m));return{owner:t,automationId:s,canRun:c,paused:o,pending:u.isPending,run:()=>u.mutate(s),failures:n?.consecutive_scheduled_failures??0,scheduled:n?.triggers?.some(x=>x.kind==="schedule")??!1,external:["external","manual"].includes(G(n)),error:(f?.error_message??n?.last_scheduling_error)?.trim()||null,result:c?u.data:void 0}}function ze({runNow:t}){return e.jsxs(e.Fragment,{children:[t.paused?e.jsx(Re,{failures:t.failures,error:t.error,scheduled:t.scheduled,external:t.external,action:e.jsx(ke,{variant:"default",pending:t.pending,onRun:t.run})}):null,t.result?e.jsx(Se,{owner:t.owner,automationId:t.automationId,result:t.result},t.result.run_id):null]})}function ke({pending:t,onRun:s,variant:n="ghost"}){return e.jsxs(F,{type:"button",variant:n,size:"sm",className:"h-8 gap-1.5",disabled:t,onClick:s,children:[t?e.jsx(R,{}):e.jsx(U,{className:"h-3.5 w-3.5","aria-hidden":!0}),t?"Starting...":"Run now"]})}function Re({failures:t,error:s,scheduled:n,external:r,action:i}){const a=r?`Run now resumes it right away${n?" and restarts its schedule":""}.`:"Run now retries it, and a successful run resumes it.";return e.jsxs("section",{"aria-label":"Automation paused",className:"flex flex-wrap items-start gap-3 rounded-lg bg-amber-500/10 px-3 py-2.5 text-sm",children:[e.jsx(X,{"aria-hidden":!0,className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsxs("p",{className:"font-medium",children:["Automation paused after"," ",t===1?"a failed run":`${t} consecutive failed runs`]}),s?e.jsxs("p",{title:s,className:"line-clamp-3 whitespace-pre-wrap break-words text-muted-foreground",children:["Latest error: ",s]}):null,e.jsxs("p",{className:"text-muted-foreground",children:[a,n?" Changing its schedule also resumes it.":null]})]}),i]})}function we({owner:t,automationId:s,runId:n}){const r=te();return e.jsxs(P,{to:"/$owner/events",params:{owner:t},search:{run_ids:String(n)},className:"font-medium text-foreground underline-offset-4 hover:underline",onClick:i=>{!r||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||(i.preventDefault(),r.open({href:`/${t}/automations/${s}?view=activity&run_id=${n}`,title:`Run #${n}`,runId:n}))},children:["Run #",n]})}function Ce(t,s){return t==="running"||t==="claimed"?"is running":t==="pending"?s==="external_client"?"is waiting for a connected client to pick it up":s==="device_worker"?"is waiting for its device":"is queued":t==="completed"?"completed":t==="timeout"?"timed out":t==="cancelled"?"was cancelled":t}function Se({owner:t,automationId:s,result:n}){const r=ce(t,n.run_id),i=r.data?.status??n.status,a=le(i),u=Z(),c=p.useRef(!1);p.useEffect(()=>{if(a){c.current=!0;return}if(c.current){c.current=!1;for(const f of["automation-detail","automations-list","runs-infinite"])u.invalidateQueries({queryKey:[f]})}},[a,u]);const o=a?null:r.data?.error_message?.trim(),m=i==="failed"||i==="timeout"||i==="cancelled";return e.jsxs("p",{role:"status",className:ee("flex items-center gap-1.5 text-sm",m?"text-destructive":"text-muted-foreground"),children:[a&&!r.isError?e.jsx(R,{className:"shrink-0"}):null,e.jsxs("span",{className:"min-w-0 break-words",children:[!n.created&&a?"Already in progress: ":null,e.jsx(we,{owner:t,automationId:s,runId:n.run_id})," ",Ce(i,n.execution.lane),o?`: ${o}`:"."]})]})}export{He as A,ke as R,ze as a,Be as b,Ie as u};
2
- //# sourceMappingURL=automation-run-now-C5XTS00o.js.map
@@ -1,2 +0,0 @@
1
- import{H as m,z as f,af as y,a4 as I,dN as v}from"./index-BoqrvLHQ.js";function w(t){const{session:o,isReady:u}=m(),c=u?o?.user.id:void 0,l=t?.limit??20,i=(t?.clientIds??[]).join(","),a=t?.activityKind??null,d=t?.excludeCommandClients??!1,n=t?.organizationId??null,s=t?.refetchInterval;return f({queryKey:["client-activity-scopes",c,l,i,a,d,n],queryFn:async()=>{const e=new URLSearchParams({limit:String(l)});i&&e.set("client_ids",i),a&&e.set("activity_kind",a),d&&e.set("exclude_command_clients","true"),n&&e.set("organization_id",n);const r=await y(`${I}/api/me/clients/activity-scopes?${e}`,{credentials:"include"});return await v(r,"Failed to load client activity"),(await r.json()).scopes??[]},enabled:!!c&&(t?.enabled??!0),staleTime:15e3,refetchInterval:typeof s=="function"?e=>s((e.state.data?.length??0)>0):s})}export{w as u};
2
- //# sourceMappingURL=client-activity-scopes-Aqdo6Pdr.js.map
@@ -1,2 +0,0 @@
1
- import{j as t,O as o}from"./index-BoqrvLHQ.js";const n=()=>t.jsx(o,{});export{n as component};
2
- //# sourceMappingURL=connect-BFNp1y_s.js.map
@@ -1,2 +0,0 @@
1
- import{H as fe,cJ as ie,iA as ge,iB as oe,iC as ke,aV as ce,iG as je,iH as ve,iI as be,iJ as ye,r as j,u as re,iK as Ae,j as s,di as Ce,iL as _e,a7 as ue,dk as w,iM as Ne,dg as Q,df as Se,B as f,dh as Oe,i as E,de as ne,hI as De,hJ as Le,hK as we,hL as Me,hM as Pe,iN as $e,iO as ae,iP as Fe,L as Re,iQ as Ue,iR as ze,iS as Be,c4 as B,iT as Ie,iU as Ee,c3 as Ke,fp as Te,Z as G,gd as qe,e9 as Ve,$ as le,fq as Je,c8 as He,al as Ge,fr as Qe}from"./index-BoqrvLHQ.js";function es({connector:t,organizationId:l,ownerSlug:n,connections:r,openNewApp:g=!1,onNewAppHandled:c}){const{session:v}=fe(),{isAdmin:u,isLoading:C}=ie(l),M=ge(t.auth_schema),o=oe(t.auth_schema),_=ke(t.auth_schema),N=ce(l,{connectorKey:t.key,provider:o?.provider}),m=je(l,t.key),S=ve(),P=be(),p=ye(),[O,D]=j.useState(null),[b,y]=j.useState(null),[x,$]=j.useState([]),F=re(),k=j.useCallback(e=>F?.open({href:"",key:`oauth-apps:${t.key}`,title:"OAuth apps",connectorPanel:{section:"oauth-apps",connectorKey:t.key,organizationId:l,ownerSlug:n,newApp:e}}),[F,t.key,l,n]);j.useEffect(()=>{!g||!u||(k(!0),c?.())},[g,u,k,c]);const R=v?.user?.id;if(!R||C||N.isLoading||m.isPending)return null;const a=(N.data??[]).filter(e=>e.profile_kind==="oauth_app"),A=a.filter(e=>e.status==="active"),W=e=>I(e,t.key),U=A.find(W),de=new Set(r.map(e=>e.auth_profile_slug)),pe=(N.data??[]).filter(e=>e.profile_kind==="oauth_account"&&e.created_by===R&&!de.has(e.slug)),he=(m.data?.options??[]).filter(e=>e.kind!=="local"&&e.configured&&!!e.url),K=m.data?.options.find(e=>e.kind==="local"),T=m.isError||m.data?.cloud_status==="unavailable",d=[],X=e=>({key:`app:${e.slug}`,kind:"app",slug:e.slug,button:"Connect account",label:e.display_name,hint:"Your OAuth app",badge:W(e)?"Default":void 0,canLead:!!U||A.length===1}),q=u?A:U?[U]:[],V=U??(q.length===1?q[0]:void 0);V&&d.push(X(V));for(const e of he)d.push({key:`offer:${e.kind}:${e.managed_by_org??e.url}`,kind:"link",href:e.url,external:!0,note:e.instructions,button:e.label,label:e.label,hint:e.execution==="cloud"?"Runs in Lobu Cloud":"The cloud holds the grant; data syncs here",canLead:!0});_&&K?.configured&&K.url&&d.push({key:"install",kind:"link",href:Ae(K.url,{installShape:_.installShape}),external:!1,button:`Install ${t.name} app`,label:`Install ${t.name} app`,hint:"Installs on your provider account",canLead:!0});for(const e of q)e!==V&&d.push(X(e));for(const e of pe){const i=e.status==="active";d.push({key:`account:${e.slug}`,kind:"account",profile:e,button:i?"Use this account":"Reconnect",label:`${i?"Use":"Reconnect"} ${e.display_name}`,canLead:!1})}(!o||M.some(e=>e.type!=="oauth"))&&d.push({key:"create",kind:"create",button:"Add connection",label:_?"Use your own app":"Add connection",canLead:!0});const me=u&&o?{key:"new-app",kind:"new-app",button:"New OAuth app",label:"New OAuth app…",canLead:!0}:void 0,h=d.find(e=>e.canLead)??(d.length?void 0:me),Y=e=>p.begin(()=>S.mutateAsync({connector_key:t.key,app_auth_profile_slug:e,requested_scopes:o?Ue(o,x):[]})),J=e=>{if(D(null),e.kind==="app")o&&ae(o).length?y(e.slug):Y(e.slug);else if(e.kind==="account"){const{profile:i}=e;p.begin(()=>i.status==="active"?S.mutateAsync({connector_key:t.key,auth_profile_slug:i.slug}):P.mutateAsync({auth_profile_slug:i.slug}))}else e.kind==="new-app"?k(!0):e.kind==="link"&&D(e.note??null)},Z=(e,i)=>e.kind==="link"?s.jsx("a",{href:e.href,...e.external?{target:"_blank",rel:"noopener noreferrer"}:{},onClick:()=>J(e),children:i}):e.kind==="create"?s.jsx(Re,{to:"/$owner/connectors/create/$connectorKey",params:{owner:n,connectorKey:t.key},children:i}):null,z=d.length===1&&d[0]===h?[]:d,ee=!!(u&&o),H=z.length>0||T||ee&&(d.length>0||a.length>0),se=s.jsxs(Ce,{align:"end",className:"w-72",children:[z.length?s.jsx(_e,{children:"Connect with"}):null,z.map(e=>{const i=s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate",children:e.label}),e.hint?s.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:e.hint}):null]}),e.badge?s.jsx(ue,{variant:"secondary",className:"text-[10px]",children:e.badge}):null]}),L=Z(e,i);return L?s.jsx(w,{asChild:!0,children:L},e.key):s.jsx(w,{onSelect:()=>J(e),children:i},e.key)}),T?s.jsx(w,{onSelect:e=>{e.preventDefault(),m.refetch()},children:s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block",children:"Retry cloud options"}),s.jsx("span",{className:"block text-xs text-muted-foreground",children:"Cloud connection options could not be checked"})]})}):null,ee?s.jsxs(s.Fragment,{children:[z.length||T?s.jsx(Ne,{}):null,s.jsxs(w,{onSelect:()=>k(!0),children:[s.jsx(Q,{}),"New OAuth app…"]}),a.length?s.jsx(w,{onSelect:()=>k(!1),children:"Manage OAuth apps…"}):null]}):null]}),te=s.jsx(Se,{asChild:!0,children:s.jsxs(f,{size:"sm",variant:h?"default":"outline",className:E(h&&"rounded-l-none border-l border-primary-foreground/25 px-2"),"aria-label":h?"More ways to connect":void 0,children:[h?null:"Connect",s.jsx(Oe,{className:"size-3.5"})]})});return s.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-1.5",children:[h?s.jsxs(ne,{children:[s.jsxs("div",{className:"inline-flex",children:[(()=>{const e=s.jsxs(s.Fragment,{children:[h.kind==="new-app"||h.kind==="create"?s.jsx(Q,{className:"size-3.5"}):null,h.button]}),i=Z(h,e);return s.jsx(f,{size:"sm",disabled:p.pending,className:E(H&&"rounded-r-none"),asChild:!!i,onClick:i?void 0:()=>J(h),children:i??e})})(),H?te:null]}),se]}):H?s.jsxs(ne,{children:[te,se]}):s.jsxs(s.Fragment,{children:[s.jsx(f,{size:"sm",disabled:!0,children:"Connect account"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask an administrator to set the workspace-default OAuth app."})]}),O?s.jsx("p",{className:"max-w-sm text-xs text-muted-foreground",children:O}):null,p.error?s.jsx("p",{role:"alert",className:"max-w-sm text-xs text-destructive",children:p.error}):null,p.continueUrl?s.jsx("a",{href:p.continueUrl,target:"_blank",rel:"noreferrer",className:"text-xs underline",children:"Continue authorization in your browser"}):null,o?s.jsx(De,{open:b!==null,onOpenChange:e=>!e&&y(null),children:s.jsxs(Le,{className:"max-w-md",children:[s.jsxs(we,{children:[s.jsx(Me,{children:"Permissions"}),s.jsxs(Pe,{children:["Choose what ",t.name," may access."]})]}),s.jsx($e,{requiredScopes:Fe(o),optionalScopes:ae(o),selectedOptionalScopes:x,onToggleOptionalScope:(e,i)=>$(L=>i?[...new Set([...L,e])]:L.filter(xe=>xe!==e))}),s.jsx("div",{className:"flex justify-end",children:s.jsx(f,{size:"sm",disabled:p.pending,onClick:()=>{const e=b;y(null),e&&Y(e)},children:"Continue"})})]})}):null]})}function ss({connector:t,organizationId:l,newApp:n}){const r=re(),{isAdmin:g}=ie(l),c=oe(t.auth_schema),v=ce(l,{connectorKey:t.key,provider:c?.provider});return c?s.jsx(We,{connector:t,oauthMethod:c,appProfiles:(v.data??[]).filter(u=>u.profile_kind==="oauth_app"),isAdmin:g,initialOpen:n,onClose:n?()=>r?.close():void 0,refetchProfiles:()=>void v.refetch()}):null}function We({initialOpen:t=!1,onClose:l,connector:n,oauthMethod:r,appProfiles:g,isAdmin:c,refetchProfiles:v}){const u=ze(),C=Be(),[M,o]=B(n.key,t&&c),[_,N]=j.useState(!1);j.useEffect(()=>{t&&c&&o(!0)},[t,c,o]);const m=`${Ie()}/connect/oauth/callback`,[S,P]=B(n.key,`${n.name} OAuth App`),[p,O]=B(n.key,""),[D,b]=B(n.key,null),y=Ee(r),x=Ke(`${n.key}:${M}`,Te(y),y),{values:$,setValues:F}=x,k=g.find(a=>I(a,n.key)),R=()=>{x.canSubmit&&(b(null),u.mutate({connector_key:n.key,profile_kind:"oauth_app",display_name:S.trim()||`${n.name} OAuth App`,slug:p.trim()||void 0,credentials:Ye(Qe($))},{onSuccess:a=>{const A=a.auth_profile?.slug;A&&!k&&C.mutate({connector_key:n.key,auth_profile_slug:A}),o(!1),l?.(),P(`${n.name} OAuth App`),O(""),v()},onError:a=>{b(a instanceof Error?a.message:"Failed to add OAuth app")}}))};return s.jsxs("div",{className:"min-w-0 space-y-4",children:[c&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(G,{children:"OAuth callback URL"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"min-w-0 flex-1 break-all text-xs",children:m}),s.jsxs(f,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(m).then(()=>N(!0)).catch(()=>b("Could not copy the callback URL. Select and copy it above."))},children:[s.jsx(qe,{className:"mr-1.5 h-3.5 w-3.5"}),_?"Copied":"Copy callback URL"]})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Register this exact URL in your provider’s app settings before saving the client configuration."})]}),g.length>0?s.jsx("div",{className:"space-y-2",children:g.map(a=>s.jsxs("div",{className:E(Ve,"flex flex-wrap items-center gap-3 p-3"),children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"truncate text-sm font-medium",children:a.display_name}),I(a,n.key)?s.jsx(ue,{variant:"secondary",className:"text-[10px]",children:"Default"}):null,s.jsx(Xe,{status:a.status})]}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a.slug})]}),c&&!I(a,n.key)&&a.connector_key===n.key&&a.status==="active"?s.jsx(f,{variant:"outline",size:"sm",disabled:C.isPending,onClick:()=>C.mutate({connector_key:n.key,auth_profile_slug:a.slug}),children:"Set default"}):null]},a.slug))}):null,c?M?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(G,{htmlFor:"oauth-app-name",children:"Display name"}),s.jsx(le,{id:"oauth-app-name",value:S,onChange:a=>P(a.target.value)})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(G,{htmlFor:"oauth-app-slug",children:"Slug"}),s.jsx(le,{id:"oauth-app-slug",placeholder:"optional",value:p,onChange:a=>O(a.target.value)})]}),s.jsx(Je,{schema:x.revision??void 0,values:$,onValuesChange:F,fieldIdPrefix:"oauth-app-"}),s.jsx(He,{visible:x.hasConflict,onReload:x.reset}),D?s.jsx("p",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:D}):null,s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(f,{variant:"outline",size:"sm",disabled:u.isPending,onClick:()=>{o(!1),l?.()},children:"Cancel"}),s.jsxs(f,{size:"sm",disabled:u.isPending||!x.canSubmit,onClick:R,children:[u.isPending?s.jsx(Ge,{size:"md",className:"mr-1.5"}):null,"Save OAuth app"]})]})]}):s.jsxs(f,{variant:"outline",size:"sm",onClick:()=>o(!0),children:[s.jsx(Q,{className:"size-3.5"}),"Add OAuth app"]}):null]})}function I(t,l){return!!t.is_default_for_connector&&t.connector_key===l}function Xe({status:t}){const l=t==="active"?"text-green-500":t==="error"||t==="revoked"?"text-destructive":"text-amber-500";return s.jsxs("span",{className:E("text-xs",l),children:["· ",t]})}function Ye(t){const l={};for(const[n,r]of Object.entries(t))typeof r=="string"&&r.trim()?l[n]=r.trim():(typeof r=="number"||typeof r=="boolean")&&(l[n]=String(r));return l}export{Xe as A,es as C,ss as O};
2
- //# sourceMappingURL=connect-menu-BWrAhMqO.js.map
@@ -1,2 +0,0 @@
1
- import{jA as r,j as t,aS as a}from"./index-BoqrvLHQ.js";import{a as s}from"./agent-connect-pages-DVq9nAR7.js";import"./connector-page-shell-an3SYLim.js";import"./copy-button-Xhh7ZnjO.js";import"./clients-Bf7ZgGro.js";import"./client-rows-Dd5YV8vn.js";function x(){const{owner:e,clientId:o}=r.useParams();return t.jsx(a,{owner:e,children:({ownerSlug:n})=>t.jsx(s,{owner:n,clientId:o})})}export{x as component};
2
- //# sourceMappingURL=connect._clientId-CSPfwYIN.js.map
@@ -1,2 +0,0 @@
1
- import{j as e,a7 as R,c as E,L as N,ez as M,A as $,M as D,cJ as _,r as u,m as I,dO as K,eR as H,i5 as f,B as y,al as O,at as G,dt as Q,eY as J,du as V,dv as W,jz as Y,aS as q}from"./index-BoqrvLHQ.js";import{T as F,a as X,b as S,c as d,d as Z,e as x}from"./table-ZuYMOjVR.js";import{a as w,g as P}from"./client-rows-Dd5YV8vn.js";import{u as A}from"./client-activity-scopes-Aqdo6Pdr.js";import{u as z,a as ee}from"./clients-Bf7ZgGro.js";import{C as se}from"./connector-page-shell-an3SYLim.js";function te({isLive:n}){return e.jsx(R,{variant:n?"default":"secondary",className:`shrink-0 text-[10px] ${n?"":"text-muted-foreground"}`,title:n?"Live MCP transport":"No live MCP transport; activity history is retained",children:n?"Active":"Ended"})}function L({scopes:n,ownerSlug:i}){const l=E(),c=t=>({to:"/$owner/events",params:{owner:t.organizationId===null?"me":i},search:{client_ids:t.clientId,mcp_activity_id:t.activityId}}),r=t=>{l(c(t))};return e.jsx("div",{className:"rounded-lg border",children:e.jsxs(F,{children:[e.jsx(X,{children:e.jsxs(S,{children:[e.jsx(d,{className:"px-3 py-1.5 text-xs",children:"Conversation"}),e.jsx(d,{className:"px-3 py-1.5 text-xs",children:"Calls"}),e.jsx(d,{className:"px-3 py-1.5 text-xs",children:"Last action"}),e.jsx(d,{className:"px-3 py-1.5 text-xs",children:"Last active"}),e.jsx(d,{className:"w-8 px-3 py-1.5"})]})}),e.jsx(Z,{children:n.map(t=>e.jsxs(S,{className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>r(t),children:[e.jsx(x,{className:"max-w-0 px-3 py-2 text-xs font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{...c(t),onClick:o=>o.stopPropagation(),className:"truncate hover:underline",children:w(t)}),t.activityKind==="session"?e.jsx(te,{isLive:t.isLive}):null,t.unreadNotificationCount>0?e.jsxs(R,{variant:"secondary",className:"shrink-0 text-[10px]",children:[t.unreadNotificationCount," unread"]}):null]})}),e.jsx(x,{className:"px-3 py-2 font-mono text-xs text-muted-foreground",children:t.callCount}),e.jsx(x,{className:"max-w-0 truncate px-3 py-2 text-xs text-muted-foreground",children:t.lastAction||"—"}),e.jsx(x,{className:"px-3 py-2 text-xs text-muted-foreground",children:M(t.lastCallAt)}),e.jsx(x,{className:"px-3 py-2 text-right",children:e.jsx("button",{type:"button","aria-label":`View ${w(t)} activity`,className:"text-muted-foreground hover:text-foreground",tabIndex:-1,children:e.jsx($,{className:"h-3.5 w-3.5"})})})]},`${t.clientId}:${t.activityId}`))})]})})}function ne({ownerSlug:n,clientId:i}){const{orgContext:l}=D(),{isAdmin:c}=_(l.organizationId),{data:r=[],isLoading:t}=z(null),o=ee(),[B,h]=u.useState(!1),s=u.useMemo(()=>P(r),[r]).find(a=>a.clientIds.includes(i)),b=s?.clientIds??[],g=A({enabled:!!s,limit:100,clientIds:b,activityKind:"conversation",organizationId:l?.organizationId??null}),p=A({enabled:!!s,limit:100,clientIds:b,activityKind:"session",organizationId:l?.organizationId??null,refetchInterval:a=>a?5e3:!1}),m=g.data??[],v=p.data??[],T=u.useMemo(()=>r.filter(a=>s?.clientIds.includes(a.id)),[r,s]);if(t)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(I,{className:"h-16 w-full rounded-lg"}),e.jsx(I,{className:"h-24 w-full rounded-lg"})]});if(!s)return e.jsx("p",{className:"text-sm text-muted-foreground",children:"This app isn't connected to this workspace, so its details aren't available."});const j=T[0],C=j?.details?.redirectUris??[],k=s.linkedUserEntitySlug?K(n,[{entity_type:"$member",slug:s.linkedUserEntitySlug}]):null,U=[{label:"Registered",value:s.title},{label:s.clientIds.length===1?"Client ID":"Client IDs",value:e.jsx("div",{className:"space-y-1",children:s.clientIds.map(a=>e.jsx("code",{className:"block break-all",children:a},a))})},...s.drivenBy&&s.drivenBy!==s.title?[{label:"Driven by",value:s.drivenBy}]:[],...j?.platform?[{label:"Software",value:j.platform}]:[],...C.length>0?[{label:"Redirects",value:C.join(", ")}]:[],{label:"Granted by",value:k&&s.linkedUser?e.jsx(N,{to:k,className:"font-medium text-primary hover:underline",children:s.linkedUser}):s.linkedUser??"—"},{label:"Last active",value:s.connected?H(s.lastSeenAt):"disconnected"},{label:"Registrations",value:String(s.clientIds.length)}];return e.jsxs("div",{className:"space-y-7",children:[e.jsx(f,{title:"Settings",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"overflow-hidden rounded-lg border text-xs",children:e.jsx("dl",{className:"divide-y",children:U.map(a=>e.jsxs("div",{className:"flex gap-3 px-3 py-2",children:[e.jsx("dt",{className:"w-28 shrink-0 text-muted-foreground",children:a.label}),e.jsx("dd",{className:"min-w-0 flex-1 break-words",children:a.value})]},a.label))})}),c&&s.connected?e.jsxs("div",{className:"space-y-2 rounded-lg border p-3",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Revoking disconnects every registration this app holds",s.clientIds.length>1?` (${s.clientIds.length} of them)`:""," ","and kills its live sessions. It can reconnect by authorizing again."]}),B?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"destructive",size:"sm",className:"h-7 px-2 text-xs",disabled:o.isPending,onClick:()=>o.mutate({clientId:s.clientIds[0],scope:"all"},{onSettled:()=>h(!1)}),children:o.isPending?"Revoking…":"Confirm revoke"}),e.jsx(y,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",disabled:o.isPending,onClick:()=>h(!1),children:"Cancel"})]}):e.jsx(y,{variant:"outline",size:"sm",className:"h-7 px-2 text-xs text-destructive hover:text-destructive",onClick:()=>h(!0),children:"Revoke"})]}):null]})}),e.jsx(f,{title:"Conversations",count:m.length>0?String(m.length):void 0,children:g.isLoading||p.isLoading?e.jsxs("div",{className:"flex items-center py-4 text-xs text-muted-foreground",children:[e.jsx(O,{className:"mr-2"})," Loading client activity…"]}):g.isError||p.isError?e.jsx("p",{className:"py-3 text-xs text-destructive",children:"Could not load this app's activity."}):m.length===0?e.jsx("p",{className:"py-3 text-xs text-muted-foreground",children:"No recent conversations."}):e.jsx(L,{scopes:m,ownerSlug:n})}),v.length>0?e.jsx(f,{title:"Sessions",count:String(v.length),children:e.jsx(L,{scopes:v,ownerSlug:n})}):null]})}function ae({owner:n,clientId:i}){const{data:l=[]}=z(null),r=u.useMemo(()=>P(l).find(t=>t.clientIds.includes(i)),[i,l])?.title??"Connected agent";return e.jsx(G,{className:"gap-3 pt-2.5 pb-8",children:e.jsx(se,{header:e.jsx(Q,{breadcrumb:e.jsx(V,{crumbs:[e.jsx(N,{to:"/$owner",params:{owner:n},search:{section:"agent"},className:W,children:"Agents"},"agents")]}),icon:e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",children:e.jsx(J,{name:r})}),title:r,caption:"An external agent connected to this workspace through Lobu. Review its Lobu conversations, activity, and access."}),children:e.jsx(ne,{ownerSlug:n,clientId:i},i)})})}function me(){const{owner:n,clientId:i}=Y.useParams();return e.jsx(q,{owner:n,children:({ownerSlug:l})=>e.jsx(ae,{owner:l,clientId:i})})}export{me as component};
2
- //# sourceMappingURL=connected._clientId-CuOeHafK.js.map
@@ -1,2 +0,0 @@
1
- import{bp as W,V as F,r as l,af as z,a4 as R,j as e,al as N,B as f,bq as V,br as q,bs as M,bt as Y,bu as E,$ as B,Q as D,F as G,ah as K,an as H,a0 as J}from"./index-BoqrvLHQ.js";import{s as Q}from"./index-BifR-LE9.js";import{C as X,a as Z,b as ee,c as ne}from"./card-CAPpY9P5.js";const C="__new_org__";function te(r){return r.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function w(r){return Q.find(i=>i.provider===r)?.name??r}function re(r,i){return`${window.location.origin}/connector/${encodeURIComponent(r)}/connection?${new URLSearchParams({ref:i})}`}function ie(r,i){return r==="account_already_linked_to_different_user"?`This ${i} account belongs to a different Lobu account than the one you are signed in to. Sign out, then continue with ${i} to finish setup as that account.`:`We couldn’t verify your ${i} account for this setup. Sign out, then continue with ${i} to try again.`}function oe(r,i){const[s,n]=l.useState({}),o=i?`${i}:${r}`:null;return l.useEffect(()=>{if(!o||!i||o in s)return;let c=!1;return D(i).then(h=>h.find(g=>g.key===r)?.name??null).catch(()=>null).then(h=>{c||n(g=>({...g,[o]:h}))}),()=>{c=!0}},[o,r,s,i]),o?s[o]??null:null}function I(r,i,s){if(!r)return"/";const n=`/${encodeURIComponent(r)}/`;if(s?.startsWith(n)){const o=new URL(s,window.location.origin);if(o.origin===window.location.origin&&o.pathname.startsWith(n))return o.pathname+o.search}return`${n}connectors/${encodeURIComponent(i)}?connected=1`}function se(r,i){return r==="not_admin"?`You must be an admin or owner to connect ${i} to Lobu.`:`You don't have permission to connect ${i} to Lobu.`}function T(r,i,s){switch(r){case"not_authorized":return se(i,s);case"no_pending":return`No Lobu install was found for ${s}. Add Lobu from the marketplace to get started.`;case"no_org":return`Your account has no Lobu organization to connect ${s} to.`;default:return`Something went wrong while connecting ${s}. Please try again.`}}function de(){const{name:r}=W({from:"/connector/$name/connection"}),{ref:i,error:s}=F({from:"/connector/$name/connection"}),[n,o]=l.useState({kind:"loading"}),[c,h]=l.useState(""),[g,O]=l.useState(""),[x,$]=l.useState(!1),[_,p]=l.useState(null),[j,k]=l.useState(null),u=oe(r,n.kind==="confirm"?n.orgs[0]?.slug??null:n.kind==="already_connected"?n.orgSlug:null),m=n.kind==="confirm"&&n.subjectKind||"connection",S=n.kind==="confirm"&&n.subjectName?n.subjectName:u?`this ${u} ${m}`:`this ${m}`,P=l.useCallback(async()=>{if(!i){o({kind:"error",message:"This connection link is missing its reference."});return}o({kind:"loading"});try{const t=await(await z(`${R}/api/connector/${encodeURIComponent(r)}/connection/claim-context?ref=${encodeURIComponent(i)}`,{credentials:"include"})).json();if("error"in t){if(t.error==="unauthenticated"){o({kind:"signin",signinProvider:t.signinProvider??r,linkAccount:!1});return}if(t.error==="signin_required"){o(s?{kind:"link_failed",signinProvider:t.signinProvider??r,error:s}:{kind:"signin",signinProvider:t.signinProvider??r,linkAccount:!0});return}o({kind:"error",message:T(t.error,t.code,"this connection")});return}if("alreadyConnected"in t){o({kind:"already_connected",orgSlug:t.orgSlug,nextUrl:t.nextUrl});return}h(t.orgs[0]?.slug??""),o({kind:"confirm",subjectKind:t.subjectKind,subjectName:t.subjectName,orgs:t.orgs})}catch{o({kind:"error",message:"We couldn’t load this connection link. Please try again."})}},[r,i,s]);l.useEffect(()=>{P()},[P]);const L=async d=>{if(!i)return;const t=re(r,i);if(n.kind==="signin"&&n.linkAccount){const y=await G.linkSocial({provider:d,callbackURL:t,errorCallbackURL:t});y.error&&o({kind:"error",message:y.error.message??"Couldn’t verify this account."});return}n.kind==="link_failed"&&await K(),await H.social({provider:d,callbackURL:t,errorCallbackURL:t})},U=async(d=!1)=>{if(!(!i||!c)){$(!0),p(null),k(null);try{let t=c;if(c===C){const b=g.trim();if(!b){p("Enter a name for the new organization.");return}const v=await J.create({name:b,slug:te(b)});if(v.error||!v.data){p(v.error?.message??"Couldn’t create the organization.");return}t=v.data.slug}const a=await(await z(`${R}/api/connector/${encodeURIComponent(r)}/connection/claim`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({ref:i,org:t,confirmMove:d})})).json();if("error"in a){if(a.error==="signin_required"||a.error==="unauthenticated"){o({kind:"signin",signinProvider:a.signinProvider??r,linkAccount:a.error==="signin_required"});return}if((a.error==="already_connected_elsewhere"||a.error==="enterprise_scope_overlap")&&a.existing){k({kind:a.error,existing:a.existing});return}p(T(a.error,a.code,S));return}window.location.href=I(a.orgSlug,r,a.nextUrl)}catch{p(`Something went wrong while connecting this ${m}. Please try again.`)}finally{$(!1)}}},A=n.kind==="signin"?"Sign in to continue":n.kind==="link_failed"?"Use a different account":n.kind==="error"?`Can’t connect this ${m}`:n.kind==="already_connected"?"Already connected":u?`Connect ${u} to Lobu`:"Connect to Lobu";return e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:e.jsx("div",{className:"w-full max-w-md p-8",children:e.jsxs(X,{children:[e.jsx(Z,{children:e.jsx(ee,{asChild:!0,children:e.jsx("h1",{children:A})})}),e.jsxs(ne,{children:[n.kind==="loading"&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[e.jsx(N,{size:"lg"}),e.jsx("span",{children:"Checking this connection link…"})]}),n.kind==="error"&&e.jsx("div",{className:"rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive",children:n.message}),n.kind==="already_connected"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This ",u?`${u} `:"",m," is already connected to Lobu."]}),e.jsx(f,{className:"w-full",asChild:!0,children:e.jsx("a",{href:I(n.orgSlug,r,n.nextUrl),children:n.nextUrl?"Choose an agent":"Open Lobu"})})]}),n.kind==="signin"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Sign in with ",w(n.signinProvider)," to verify you can connect this ",m,"."]}),e.jsxs(f,{className:"w-full",onClick:()=>L(n.signinProvider),children:["Sign in with ",w(n.signinProvider)]})]}),n.kind==="link_failed"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{role:"alert",className:"rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive",children:ie(n.error,w(n.signinProvider))}),e.jsxs(f,{className:"w-full",onClick:()=>L(n.signinProvider),children:["Sign out and continue with"," ",w(n.signinProvider)]})]}),n.kind==="confirm"&&(()=>{const d=n.subjectName||S;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Connecting"," ",e.jsx("strong",{className:"font-medium text-foreground",children:d}),". Choose the organization to connect it to:"]}),e.jsxs(V,{value:c,onValueChange:t=>{k(null),h(t)},children:[e.jsx(q,{children:e.jsx(M,{placeholder:"Select an organization"})}),e.jsxs(Y,{children:[n.orgs.map(t=>e.jsxs(E,{value:t.slug,children:[t.name,t.isPersonal&&e.jsx("span",{className:"ml-1 text-muted-foreground",children:"(personal)"})]},t.id)),e.jsx(E,{value:C,children:"+ New organization"})]})]}),c===C&&e.jsx(B,{autoFocus:!0,value:g,onChange:t=>O(t.target.value),placeholder:"New organization name","aria-label":"New organization name"}),_&&e.jsx("div",{className:"rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive",children:_}),j&&(()=>{const t=j.existing.orgName??j.existing.orgSlug??"another organization";return j.kind==="already_connected_elsewhere"?e.jsxs("div",{className:"space-y-3 rounded-lg border border-border bg-muted/40 px-3 py-3",children:[e.jsxs("p",{className:"text-sm text-foreground",children:[d," is already connected in"," ",e.jsx("strong",{className:"font-medium",children:t}),". Move it here?"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(f,{className:"flex-1",onClick:()=>U(!0),disabled:x,children:x?e.jsxs(e.Fragment,{children:[e.jsx(N,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Moving…"})]}):"Move it here"}),e.jsx(f,{className:"flex-1",variant:"outline",onClick:()=>k(null),disabled:x,children:"Cancel"})]})]}):e.jsxs("div",{className:"rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive",children:["This ",u?`${u} `:"","Enterprise Grid is already connected in"," ",e.jsx("strong",{className:"font-medium",children:t}),"; ","connecting this ",m," here may change how its messages route. Contact support to move it."]})})(),e.jsx(f,{className:"w-full",onClick:()=>U(),disabled:x||j!==null||!c||c===C&&!g.trim(),children:x?e.jsxs(e.Fragment,{children:[e.jsx(N,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Connecting…"})]}):`Connect ${d}`})]})})()]})]})})})}export{de as component};
2
- //# sourceMappingURL=connection-CVeHmDLs.js.map
@@ -1,2 +0,0 @@
1
- import{r as d,j as e,d_ as J,jr as O,m as z,B as v,js as Q,L as E,i as w,al as F,fx as B,hC as Y,gL as Z,aO as ee,a9 as se,gN as te,jt as ne,c3 as W,fp as V,hH as L,bq as ae,br as ce,bs as ie,bt as le,bu as re,fq as q,c8 as H,bR as oe,d6 as de,da as me,ac as ue,ju as xe,e9 as he,jv as pe,jw as fe,jx as ge,hS as je,fd as ye,i5 as A,u as ve,jy as Ne,f6 as I,a7 as U,ez as T}from"./index-BoqrvLHQ.js";import{S as _e}from"./scoped-feed-bar-DNFL0sYX.js";import{E as be}from"./events-feed-DcKTkJVe.js";import{f as Se,C as ke}from"./entity-options-D4t-NAcg.js";import{V as Ce,a as we}from"./runs-list-DUXRMkWN.js";import{S as P,g as K}from"./status-variants-SzXYYedJ.js";import{f as Fe}from"./feed-event-kinds-BYuZCoU4.js";function Re({connection:s,ownerSlug:t}){const[a,c]=d.useState([]),x=d.useMemo(()=>[s.connector_key],[s.connector_key]),m=d.useMemo(()=>({connectionIds:[s.id],...a.length>0?{semanticTypes:a}:{}}),[s.id,a]),r=s.facets?.chat??!1;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{"aria-label":r?"Channels":"Feeds",className:"space-y-2",children:[e.jsx("h2",{className:"text-sm font-semibold",children:r?"Channels":"Feeds"}),e.jsx(Ee,{connection:s,ownerSlug:t})]}),e.jsxs("section",{"aria-label":"What came in",className:"space-y-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("h2",{className:"shrink-0 text-sm font-semibold",children:"What came in"}),e.jsx(_e,{owner:t,organizationId:s.organization_id,activitySearch:{connection_ids:String(s.id)},kinds:a,onKindsChange:c,platforms:x})]}),e.jsx(be,{organizationId:s.organization_id,ownerSlug:t,filters:m,hideOriginator:!0,emptyState:e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing has come in from this connection yet."})})]})]})}function Ee({connection:s,ownerSlug:t}){const{data:a=[],isLoading:c,isError:x,refetch:m}=J(s.id),r=O();return c?e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{className:"h-12 w-full rounded-lg"}),e.jsx(z,{className:"h-12 w-full rounded-lg"})]}):x?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load feeds."}),e.jsx(v,{variant:"outline",size:"sm",onClick:()=>void m(),children:"Retry"})]}):a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No feeds yet. Add one from Settings."}):e.jsx("ul",{className:"divide-y overflow-hidden rounded-lg border",children:a.map(i=>{const l=Q(i),p=i.operations.includes("sync"),u=i.active_runs>0||r.isPending&&r.variables===i.id;return e.jsxs("li",{className:"flex items-center gap-3 px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(E,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:t,connectorKey:s.connector_key,connectionId:String(s.id)},search:{feedId:i.id},className:"block truncate text-sm font-medium hover:underline",children:i.display_name?.trim()||i.feed_key}),e.jsx("p",{className:w("truncate text-xs",l.failed?"text-destructive":"text-muted-foreground"),title:l.text,children:p&&i.execution_mode==="no_schedule"?`${l.text} No schedule: it runs only when you sync it.`:p?l.text:"Live access, nothing to sync."})]}),p?e.jsxs(v,{type:"button",size:"sm",variant:l.failed?"default":"outline",className:"h-7 shrink-0 text-xs",disabled:u,onClick:()=>r.mutate(i.id),children:[u?e.jsx(F,{size:"sm",className:"mr-1"}):e.jsx(B,{className:"mr-1 h-3 w-3"}),u?"Syncing":l.failed?"Try again":"Sync now"]}):null]},i.id)})})}function $e({organizationId:s,value:t,onChange:a,entities:c,className:x}){const{data:m=[]}=Y(c?void 0:s),r=d.useMemo(()=>c??Se(m),[c,m]),i=new Set(t),l=r.filter(o=>i.has(o.id)),p=o=>{const n=new Set(i);n.has(o)?n.delete(o):n.add(o),a(Array.from(n).sort((f,N)=>f-N))},u=l.length===0?"All entities":l.length===1?l[0].name:`${l.length} entities selected`;return e.jsx(Z,{contentClassName:"w-[320px]",searchPlaceholder:"Filter entities...",emptyText:"No entities found.",trigger:o=>e.jsxs(v,{variant:"outline",role:"combobox","aria-expanded":o,className:w("justify-between",x),children:[u,e.jsx(te,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:()=>r.map(o=>{const n=i.has(o.id);return e.jsxs(ee,{value:`${o.name} ${o.entityType}`,onSelect:()=>p(o.id),className:"cursor-pointer",children:[e.jsx(se,{className:w("mr-2 h-4 w-4",n?"opacity-100":"opacity-0")}),e.jsxs("span",{children:[o.name," ",e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",o.entityType,")"]})]})]},o.id)})})}function De(s){return s?.feeds_schema?Object.entries(s.feeds_schema).map(([t,a])=>({key:t,name:a.name??t,description:a.description,configSchema:a.configSchema})):[]}const Oe="Feeds are optional scheduled sync targets for an existing connection.";function Be({organizationId:s,connections:t,connectorDefinitions:a,entityId:c,onClose:x}){const m=t.length===1,[r,i]=d.useState(m?String(t[0].id):""),[l,p]=d.useState(""),[u,o]=d.useState(c?[c]:[]),[n,f]=d.useState(null),N=ne(),k=d.useMemo(()=>new Map(a.map(h=>[h.key,h])),[a]),y=d.useMemo(()=>t.find(h=>String(h.id)===r),[t,r]),_=d.useMemo(()=>y?De(k.get(y.connector_key)):[],[y,k]),C=d.useMemo(()=>_.find(h=>h.key===l)??null,[_,l]),j=W(`${r}:${l}`,V(C?.configSchema),C?.configSchema),{values:b,setValues:$}=j,S=d.useCallback(()=>{i(m?String(t[0].id):""),p(""),o(c?[c]:[]),f(null)},[c,m,t]),g=d.useCallback(()=>{S(),x()},[x,S]),D=d.useCallback(async()=>{if(!j.canSubmit||!y||!l)return;f(null);const h=L(b);try{await N.mutateAsync({connection_id:y.id,feed_key:l,config:Object.keys(h).length>0?h:void 0,entity_ids:c?[c]:u.length>0?u:void 0}),g()}catch(M){f(M instanceof Error?M.message:"Failed to create feed")}},[b,j.canSubmit,N,c,g,y,u,l]),X=e.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto py-6 pr-1",children:[!m&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Connection"}),e.jsx(ke,{connections:t,value:r,onValueChange:h=>{i(h),p(""),f(null)},placeholder:"Select a connection"})]}),y&&_.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Feed Type"}),e.jsxs(ae,{value:l,onValueChange:p,children:[e.jsx(ce,{children:e.jsx(ie,{placeholder:"Select feed type"})}),e.jsx(le,{children:_.map(h=>e.jsx(re,{value:h.key,children:e.jsxs("div",{children:[e.jsx("span",{children:h.name}),h.description&&e.jsxs("span",{className:"text-muted-foreground ml-1 text-xs",children:["— ",h.description]})]})},h.key))})]})]}),c?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Target Entity"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This feed will be attached to the current entity."})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Target Entities"}),e.jsx($e,{organizationId:s,value:u,onChange:o,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Leave empty to create an unscoped feed."})]}),j.revision&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Feed Configuration"}),e.jsx(q,{schema:j.revision,values:b,onValuesChange:$})]}),y&&_.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"This connector has no configurable feed types."}),e.jsx(H,{visible:j.hasConflict,onReload:j.reset}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]}),G=e.jsx(oe,{onCancel:g,className:"mt-2",children:e.jsxs(v,{disabled:!j.canSubmit||!l||N.isPending,onClick:()=>void D(),children:[N.isPending&&e.jsx(F,{size:"lg",className:"mr-2"}),"Create Feed"]})});return e.jsxs("div",{className:"flex flex-col",children:[X,G]})}function We({feed:s,onClose:t,hideHeader:a=!1}){const c=s.display_name?.trim()||s.feed_key,x=s.feed_key.includes(":")?s.feed_key.slice(s.feed_key.indexOf(":")+1):s.feed_key,m=s.external_tenant_id,r=s.connector_key==="slack"&&m?`https://app.slack.com/client/${m}/${x}`:void 0;return e.jsxs("div",{className:"flex max-w-xl flex-col gap-4",children:[a?null:e.jsxs(e.Fragment,{children:[t?e.jsxs("button",{type:"button",onClick:t,className:"inline-flex w-fit items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(de,{className:"h-3 w-3"}),"Back to connection"]}):null,e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h2",{className:"text-lg font-semibold leading-tight",children:c}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"chat channel"})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Messages captured for this channel are available to Lobu Automations. Open Slack to read the channel history."}),r?e.jsx(v,{asChild:!0,variant:"outline",className:"w-full justify-center",children:e.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(ue,{className:"mr-2 h-4 w-4"}),"Open in Slack"]})}):null,e.jsxs("div",{className:w(he,"flex flex-col gap-3 p-4"),children:[e.jsx("div",{className:"text-xs font-medium uppercase text-muted-foreground",children:"Channel"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(xe,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"break-all",children:c})]}),m?e.jsxs("div",{className:"flex items-baseline justify-between gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Workspace"}),e.jsx("span",{className:"break-all font-mono text-xs",children:m})]}):null,e.jsx("p",{className:"text-xs text-muted-foreground",children:"Messages the bot sees here are captured as they arrive. Open the channel in Slack to read the full history."})]})]})}function qe(s,t){return s.display_name?s.display_name:t?.feeds_schema?.[s.feed_key]?.name??s.feed_key}function Ie(s,t){const a=s?.feeds_schema;if(!a)return;if(a[t])return a[t];const c=Object.values(a);return c.find(x=>x?.key===t)??(c.length===1?c[0]:void 0)}const R=8;function Ve({kinds:s,feedId:t,ownerSlug:a}){const[c,x]=d.useState(!1),m=ve(),r=c?s:s.slice(0,R);return e.jsxs(A,{title:"Event types",count:`${s.length} ${s.length===1?"kind":"kinds"}`,children:[e.jsx("ul",{className:"divide-y",children:r.map(({kind:i,description:l,targets:p})=>{const u=Ne(a,t,[i]),o=`${I(i)} events`;return e.jsx("li",{children:e.jsxs(E,{to:u,className:"flex flex-col gap-1 py-2 text-left transition-colors hover:bg-accent/50 sm:flex-row sm:items-start sm:gap-4",onClick:n=>{!m||n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||n.button!==0||(n.preventDefault(),m.open({href:u,title:o}))},children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:I(i)}),e.jsx("code",{className:"truncate font-mono text-[11px] text-muted-foreground",children:i})]}),l?e.jsx("p",{className:"line-clamp-2 text-xs text-muted-foreground",title:l,children:l}):null]}),p.length>0?e.jsx("div",{className:"flex flex-wrap gap-1 sm:max-w-[40%] sm:justify-end",children:p.map(({entityType:n,creates:f})=>e.jsx(U,{variant:"secondary",className:"font-normal",title:f?`Creates ${n} records`:`Links to existing ${n} records`,children:I(n)},n))}):null]})},i)})}),s.length>R?e.jsx(v,{variant:"ghost",size:"sm",className:"mt-1 h-7 px-2 text-xs text-muted-foreground",onClick:()=>x(i=>!i),children:c?"Show fewer":`Show all ${s.length}`}):null]})}function He({feed:s,ownerSlug:t}){return e.jsxs(e.Fragment,{children:[e.jsx(P,{status:K(s.status),showDot:!0,children:s.status}),s.connection_status&&s.connection_status!==s.status&&e.jsxs(P,{status:K(s.connection_status),showDot:!0,children:["Connection: ",s.connection_status]}),s.device_worker_id?e.jsx(E,{to:"/$owner/connectors/device/$deviceId",params:{owner:t,deviceId:s.device_worker_id},children:e.jsx(U,{variant:s.device_status==="offline"?"secondary":"outline",className:"text-xs hover:bg-accent",children:s.device_status==="offline"?`Waiting for ${s.device_label||s.device_platform||"device"}`:`On ${s.device_label||s.device_platform||"device"}`})}):null]})}function Ue({feed:s}){return s.operations.includes("sync")?e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:["Last sync: ",s.last_sync_at?T(s.last_sync_at):"—"]}),e.jsxs("span",{children:["Next: ",s.next_run_at?T(s.next_run_at):"—"]}),s.event_count!=null&&e.jsxs("span",{className:"font-mono",children:[s.event_count.toLocaleString()," events"]})]}):e.jsx("span",{children:"Read live when queried"})}function Xe({feed:s,connectorDef:t,ownerSlug:a}){const{data:c,refetch:x}=pe(s.id),m=d.useMemo(()=>(c?.recent_runs??[]).map(g=>({...g,run_type:"sync"})),[c?.recent_runs]),r=fe(),i=O(),l=c?.recent_runs?.some(g=>["running","pending","claimed"].includes(g.status));d.useEffect(()=>{if(!l)return;const g=setInterval(()=>x(),5e3);return()=>clearInterval(g)},[l,x]);const p=d.useMemo(()=>Ie(t,s.feed_key),[t,s.feed_key]),u=p?.configSchema,o=d.useMemo(()=>Fe(p).sort((g,D)=>g.kind.localeCompare(D.kind)),[p]),n=W(s.id,V(u,s.config??{}),u),{values:f,setValues:N,dirty:k}=n,y=d.useCallback(async()=>{n.canSubmit&&(await r.mutateAsync({feed_id:s.id,config:L(f)}),n.accept(f,V(u,L(f))))},[r,s.id,f,u,n.canSubmit,n.accept]),_=d.useCallback(async()=>{const g=s.status==="active"?"paused":"active";await r.mutateAsync({feed_id:s.id,status:g})},[r,s.id,s.status]),C=d.useCallback(async()=>{await i.mutateAsync(s.id)},[i,s.id]),j=s.status==="active",b=s.operations.includes("sync"),$=s.auth_profile_status&&s.auth_profile_status!=="active",S=r.isPending||i.isPending;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(v,{variant:"outline",size:"sm",disabled:S,onClick:()=>void _(),children:[j?e.jsx(ge,{className:"h-3.5 w-3.5 mr-1.5"}):e.jsx(je,{className:"h-3.5 w-3.5 mr-1.5"}),j?"Pause":"Resume"]}),b?e.jsxs(v,{variant:"outline",size:"sm",disabled:S||!j,onClick:()=>void C(),children:[i.isPending?e.jsx(F,{size:"md",className:"mr-1.5"}):e.jsx(B,{className:"h-3.5 w-3.5 mr-1.5"}),"Sync now"]}):null,e.jsx(Ce,{ownerSlug:a,scope:{kind:"feed",id:s.id},variant:"ghost",label:"View in memory"})]}),$&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-amber-50 dark:bg-amber-950/20 px-3 py-2 text-sm",children:[e.jsx(ye,{className:"h-4 w-4 text-amber-500 shrink-0"}),e.jsxs("span",{className:"text-amber-700 dark:text-amber-400",children:["Authentication issue: ",s.auth_profile_status]}),e.jsx(v,{asChild:!0,variant:"outline",size:"sm",className:"ml-auto h-7 text-xs",children:e.jsx(E,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:a,connectorKey:s.connector_key,connectionId:String(s.connection_id)},search:{settings:!0},children:"Fix auth"})})]}),n.revision?e.jsx(A,{title:"Settings",children:e.jsxs("div",{className:"max-w-xl space-y-4",children:[e.jsx(q,{schema:n.revision,values:f,onValuesChange:N}),e.jsx(H,{visible:n.hasConflict,onReload:n.reset}),k&&e.jsx("div",{className:"flex justify-end",children:e.jsxs(v,{size:"sm",disabled:S||!n.canSubmit,onClick:()=>void y(),children:[r.isPending?e.jsx(F,{size:"md",className:"mr-1.5"}):null,"Save"]})})]})}):null,o.length>0?e.jsx(Ve,{kinds:o,feedId:s.id,ownerSlug:a}):null,b?e.jsx(A,{title:"Recent syncs",children:e.jsx(we,{runs:m,ownerSlug:a,emptyState:e.jsx("p",{className:"rounded-lg border bg-muted/20 px-3 py-6 text-center text-xs text-muted-foreground",children:"No syncs yet."})})}):null]})}export{Be as A,Re as C,He as F,We as a,Ue as b,Xe as c,Oe as d,qe as f};
2
- //# sourceMappingURL=connection-feed-detail-BYo7zdVD.js.map
@@ -1,2 +0,0 @@
1
- import{j as e,at as s,O as t}from"./index-BoqrvLHQ.js";function n(){return e.jsx(s,{className:"gap-3 pt-2.5 pb-8",children:e.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:e.jsx(t,{})})})}export{n as component};
2
- //# sourceMappingURL=connectors-DBEM9QQz.js.map
@@ -1,2 +0,0 @@
1
- import{r as s,j as a,B as p,a9 as n,gd as d,by as i}from"./index-BoqrvLHQ.js";function m({text:u,label:o,iconOnly:t=!1}){const[r,c]=s.useState(!1),e=s.useRef(void 0);return s.useEffect(()=>()=>clearTimeout(e.current),[]),a.jsxs(p,{type:"button",variant:t?"ghost":"outline",size:t?"icon":"sm",className:t?"h-6 w-6 shrink-0":"h-8 text-xs","aria-label":t?`Copy ${o}`:void 0,onClick:async()=>{try{await navigator.clipboard.writeText(u),c(!0),i.success("Copied to clipboard"),clearTimeout(e.current),e.current=setTimeout(()=>c(!1),1500)}catch{i.error("Could not copy. Please select and copy the text.")}},children:[r?a.jsx(n,{className:"h-3.5 w-3.5"}):a.jsx(d,{className:"h-3.5 w-3.5"}),!t&&(r?"Copied":o)]})}export{m as C};
2
- //# sourceMappingURL=copy-button-Xhh7ZnjO.js.map
@@ -1,2 +0,0 @@
1
- import{c as h,ha as G,iW as b,iX as L,i3 as y,j as t,dx as v,by as r,jE as w}from"./index-BoqrvLHQ.js";import{A as S,v as N,a as P}from"./custom-guardrail-edits-Ce_BwiwD.js";import{A as $,a as E}from"./agent-subpage-shell-BUCoY2Nf.js";import"./model-selector-D2OpDkwH.js";function F({owner:e,agentId:a}){const i=h(),{data:n,isLoading:c}=G(a),{data:m,isLoading:p}=b(a),{data:o=null,isLoading:f}=L(a),C=c||p||f,u=y(a),g=n?.guardrailsInline??[],x=(m??[]).map(s=>s.name),A=async s=>{if(!n){r.error("Still loading agent settings — try again in a moment");return}const d=N(s,g,x,o);if(d){r.error(d);return}try{await u.mutateAsync({guardrailsInline:P(g,s)}),r.success("Guardrail created"),i({to:"/$owner/agents/$agentId",params:{owner:e,agentId:a},hash:"guardrails"})}catch(l){r.error(l instanceof Error?l.message:"Failed to create guardrail")}},j=()=>void i({to:"/$owner/agents/$agentId",params:{owner:e,agentId:a},hash:"guardrails"});return t.jsxs("div",{className:"space-y-6",children:[t.jsx($,{title:"New custom guardrail",description:"A custom guardrail judges text at one stage against a policy you write."}),C?t.jsx(v,{rows:4}):t.jsx(S,{judgeModelDefault:o,submitLabel:"Create guardrail",submitting:u.isPending,onSubmit:A,onCancel:j})]})}function R({owner:e,agentId:a}){return t.jsx(E,{children:t.jsx(F,{owner:e,agentId:a})})}function M(){const{owner:e,agentId:a}=w.useParams();return t.jsx(R,{owner:e,agentId:a})}export{M as component};
2
- //# sourceMappingURL=create-Ccb5R-S4.js.map
@@ -1,2 +0,0 @@
1
- import{c as A,r as t,j as e,dg as I,Z as h,$ as P,fj as F,bR as R,B as $,i as L,e9 as D,hP as E,hQ as M,jD as B}from"./index-BoqrvLHQ.js";import{u as Q,c as T,f as H}from"./agent-skill-context-fqedKd0D.js";import{A as z,a as K}from"./agent-subpage-shell-BUCoY2Nf.js";import{a as k}from"./skill-route-key-sF006xiz.js";import"./core.esm-Ctg_pXLe.js";import"./skill-editor-D_W3QlRz.js";function O({owner:a,agentId:l}){const r=A(),[o,x]=t.useState(""),[p,c]=t.useState(!1),[n,f]=t.useState(""),[u,j]=t.useState(""),{skillRows:m,catalog:d,isLoading:S,addSkillFromCatalog:C,addCustomSkill:v}=Q(),g=t.useMemo(()=>new Set(m.map(s=>s.repo)),[m]),i=t.useMemo(()=>T(d?.catalog??[],g),[d?.catalog,g]),N=t.useMemo(()=>H(i,o),[i,o]),w=s=>{C(s),r({to:"/$owner/agents/$agentId",params:{owner:a,agentId:l},search:{skill:k(s)},hash:"skills"})},y=()=>{const s=v({name:n,instructions:u});s&&r({to:"/$owner/agents/$agentId",params:{owner:a,agentId:l},search:{skill:k(s)},hash:"skills"})},b=e.jsx(z,{title:"Add a skill",description:"Skills bundle instructions, tools, and knowledge an agent can reuse. Pick one from the catalog or create your own."});return e.jsxs("div",{className:"space-y-6",children:[b,e.jsx("div",{className:L(D,"w-full"),children:p?e.jsxs("div",{className:"space-y-3 p-3",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(h,{htmlFor:"custom-skill-name",children:"Name"}),e.jsx(P,{id:"custom-skill-name",value:n,onChange:s=>f(s.target.value),placeholder:"my-skill"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(h,{htmlFor:"custom-skill-instructions",children:"Instructions"}),e.jsx(F,{id:"custom-skill-instructions",value:u,onChange:s=>j(s.target.value),placeholder:"Instructions for the agent when this skill is active...",rows:3})]})]}),e.jsx(R,{onCancel:()=>c(!1),children:e.jsx($,{type:"button",size:"sm",onClick:y,disabled:!n.trim(),children:"Add custom skill"})})]}):e.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 p-3 text-left text-muted-foreground transition-colors hover:text-foreground",onClick:()=>c(!0),children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted",children:e.jsx(I,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Create custom skill"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define instructions and packages"})]})]})}),S?e.jsx(E,{}):e.jsx(M,{items:N,searchQuery:o,onSearchChange:x,onSelect:s=>w(s.key),searchPlaceholder:"Search skills...",searchAriaLabel:"Search skills",emptyMessage:o.trim()?`No skills match "${o}"`:i.length===0?"All catalog skills are already configured":"No skills available"})]})}function X({owner:a,agentId:l}){return e.jsx(K,{children:e.jsx(O,{owner:a,agentId:l})})}function V(){const{owner:a,agentId:l}=B.useParams();return e.jsx(X,{owner:a,agentId:l})}export{V as component};
2
- //# sourceMappingURL=create-DmhbacIa.js.map