@lobu/runtime-server 23.0.0 → 24.0.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 (262) hide show
  1. package/dist/catalogs/connectors.json +70 -6
  2. package/dist/catalogs/skills.json +1 -1
  3. package/dist/component.json +1 -1
  4. package/dist/connectors/README.md +1 -1
  5. package/dist/connectors/linkedin-inbox-adapter.js +4 -7
  6. package/dist/connectors/linkedin.ts +53 -34
  7. package/dist/connectors/reddit.ts +92 -20
  8. package/dist/connectors/slack.ts +1 -0
  9. package/dist/connectors/whatsapp-web-adapter.js +41 -11
  10. package/dist/connectors/whatsapp-web-helpers.ts +1 -1
  11. package/dist/connectors/whatsapp_web.ts +2 -2
  12. package/dist/connectors/x-identity.ts +5 -3
  13. package/dist/db/migrations/20261019120000_retire_identities_of_deleted_entities.sql +21 -0
  14. package/dist/db/migrations/20261020120000_entities_live_metadata_domain.sql +66 -0
  15. package/dist/db/migrations/20261020130000_agents_starters.sql +14 -0
  16. package/dist/db/migrations/20261020140000_view_attachments_by_page.sql +71 -0
  17. package/dist/dependencies.bun.lock +63 -60
  18. package/dist/guest.bundle.js +362 -300
  19. package/dist/owletto/dist/assets/_-CC8cTmRg.js +3 -0
  20. package/dist/owletto/dist/assets/_-ksFp4zVf.js +2 -0
  21. package/dist/owletto/dist/assets/_agentId-DWUFSrVp.js +2 -0
  22. package/dist/owletto/dist/assets/_agentId-MENLoohA.js +2 -0
  23. package/dist/owletto/dist/assets/_automationId-BnHqdXOC.js +2 -0
  24. package/dist/owletto/dist/assets/_connectorKey._connectionId-CefXIqy2.js +2 -0
  25. package/dist/owletto/dist/assets/_connectorKey.index-C1QPGf9E.js +2 -0
  26. package/dist/owletto/dist/assets/_conversationId-DinuPCUp.js +2 -0
  27. package/dist/owletto/dist/assets/{_deploymentId-BuUzGtVL.js → _deploymentId-BeyzVjRm.js} +2 -2
  28. package/dist/owletto/dist/assets/_eventId-3L_qeL_l.js +2 -0
  29. package/dist/owletto/dist/assets/_name-Dgedji78.js +2 -0
  30. package/dist/owletto/dist/assets/_owner-DbrKma4e.js +3 -0
  31. package/dist/owletto/dist/assets/_shape-DtVfRFz_.js +2 -0
  32. package/dist/owletto/dist/assets/_skillKey-CqLHzm7L.js +2 -0
  33. package/dist/owletto/dist/assets/_slug-ndDr_CUg.js +2 -0
  34. package/dist/owletto/dist/assets/_viewKey-3CH5w8mr.js +2 -0
  35. package/dist/owletto/dist/assets/_viewKey-DHQY9A8u.js +2 -0
  36. package/dist/owletto/dist/assets/{accept-invitation-w17IFTtf.js → accept-invitation-CRKbM2Xy.js} +2 -2
  37. package/dist/owletto/dist/assets/activity-route-view-CFLNukhD.js +2 -0
  38. package/dist/owletto/dist/assets/{agent-card-controls-mnTN2AZt.js → agent-card-controls-Be1Okb2C.js} +2 -2
  39. package/dist/owletto/dist/assets/{agent-client-setup-list-Bg3hBfUV.js → agent-client-setup-list-BA8dU_C6.js} +2 -2
  40. package/dist/owletto/dist/assets/agent-connect-pages-CAV-yXus.js +2 -0
  41. package/dist/owletto/dist/assets/agent-editor-form-Bi6WvYX-.js +2 -0
  42. package/dist/owletto/dist/assets/{agent-guardrails-route-BOrCXcAl.js → agent-guardrails-route-DMOjG1D4.js} +2 -2
  43. package/dist/owletto/dist/assets/{agent-loading-shells-Dqcvky-k.js → agent-loading-shells-De_2d8Lr.js} +2 -2
  44. package/dist/owletto/dist/assets/{agent-permissions-matrix-BOo_4r_4.js → agent-permissions-matrix-gZWl6mAe.js} +2 -2
  45. package/dist/owletto/dist/assets/{agent-skill-context-CCdvtlmH.js → agent-skill-context-JLaTamGR.js} +2 -2
  46. package/dist/owletto/dist/assets/{agent-skills-route-BUxIswuq.js → agent-skills-route-DcK41PWj.js} +2 -2
  47. package/dist/owletto/dist/assets/agent-subpage-shell-BBJoyTuC.js +2 -0
  48. package/dist/owletto/dist/assets/agent-thread-Buz3naVF.js +6 -0
  49. package/dist/owletto/dist/assets/agents-C-ReckCa.js +2 -0
  50. package/dist/owletto/dist/assets/agents-workbench-CqaKGggb.js +2 -0
  51. package/dist/owletto/dist/assets/app._appId-Cl1fTuIt.js +2 -0
  52. package/dist/owletto/dist/assets/automation-detail-content-BMLL4lxO.js +2 -0
  53. package/dist/owletto/dist/assets/automations-C-ReckCa.js +2 -0
  54. package/dist/owletto/dist/assets/callback-DTKKsfkz.js +2 -0
  55. package/dist/owletto/dist/assets/{card-Djgp00r_.js → card-yU0TmNRH.js} +2 -2
  56. package/dist/owletto/dist/assets/{claim-BYUZnyMp.js → claim-DJfTvlT2.js} +2 -2
  57. package/dist/owletto/dist/assets/client-rows--FrZfJol.js +2 -0
  58. package/dist/owletto/dist/assets/{clients-D3Zbjxin.js → clients-L4K1UT8c.js} +2 -2
  59. package/dist/owletto/dist/assets/{code-editor-DHeyRGZI.js → code-editor-U54Gwjit.js} +2 -2
  60. package/dist/owletto/dist/assets/connect-4zqtnDHb.js +2 -0
  61. package/dist/owletto/dist/assets/connect._clientId-Dj0SqgbE.js +2 -0
  62. package/dist/owletto/dist/assets/connected._clientId-sgtocSvf.js +2 -0
  63. package/dist/owletto/dist/assets/connected._clientId.activity-DTpSW1Xy.js +2 -0
  64. package/dist/owletto/dist/assets/connected._clientId.index-h9X5H1x8.js +2 -0
  65. package/dist/owletto/dist/assets/{connection-C3XXFEqh.js → connection-ByvKkyFm.js} +2 -2
  66. package/dist/owletto/dist/assets/{connection-feed-detail-CIJJLDP8.js → connection-feed-detail-DWM9lTao.js} +2 -2
  67. package/dist/owletto/dist/assets/connections-browser-CEwYrYqt.js +2 -0
  68. package/dist/owletto/dist/assets/{connector-provenance-8-d8hl10.js → connector-provenance-BocTm__v.js} +2 -2
  69. package/dist/owletto/dist/assets/connector-scope-lists-OYDOydtz.js +2 -0
  70. package/dist/owletto/dist/assets/connectors-CyZpcE5f.js +2 -0
  71. package/dist/owletto/dist/assets/{consent-CdSvVCgx.js → consent-DdfINrVp.js} +2 -2
  72. package/dist/owletto/dist/assets/{conversations-table-BdXoZAfc.js → conversations-table-BSznfdYt.js} +2 -2
  73. package/dist/owletto/dist/assets/{core.esm-CYvgWCuv.js → core.esm-Dr7tcIB-.js} +2 -2
  74. package/dist/owletto/dist/assets/create-CBGwASon.js +2 -0
  75. package/dist/owletto/dist/assets/create-Cf5hp6Z8.js +2 -0
  76. package/dist/owletto/dist/assets/create-CwThQtd3.js +2 -0
  77. package/dist/owletto/dist/assets/{create-automation-form-CtSSeYj3.js → create-automation-form-9T5WnoUs.js} +3 -3
  78. package/dist/owletto/dist/assets/create._connectorKey-sNHQHNpg.js +2 -0
  79. package/dist/owletto/dist/assets/{cronstrue-n4qGUraE.js → cronstrue-BWFEyy_P.js} +2 -2
  80. package/dist/owletto/dist/assets/deployments-DHh9dyzv.js +2 -0
  81. package/dist/owletto/dist/assets/{deployments-body-BMp7UsMo.js → deployments-body-2xKS8gRo.js} +2 -2
  82. package/dist/owletto/dist/assets/{deployments-RvUdVkj3.js → deployments-wG_8QzOF.js} +2 -2
  83. package/dist/owletto/dist/assets/{device-CPU6CjkJ.js → device-6z-xgsoW.js} +2 -2
  84. package/dist/owletto/dist/assets/device-pin-tombstone-Cwq88RMU.js +2 -0
  85. package/dist/owletto/dist/assets/device._deviceId-BDerBfD9.js +2 -0
  86. package/dist/owletto/dist/assets/entity-avatar-Cc1CuI-0.js +2 -0
  87. package/dist/owletto/dist/assets/entity-options-DHdMC1Lx.js +2 -0
  88. package/dist/owletto/dist/assets/entity-page--OkXmlNP.js +2 -0
  89. package/dist/owletto/dist/assets/entity-type-page-89RoK_-P.js +2 -0
  90. package/dist/owletto/dist/assets/event-detail-D4YZRtrA.js +2 -0
  91. package/dist/owletto/dist/assets/events-feed-DsrkV2ix.js +2 -0
  92. package/dist/owletto/dist/assets/filter-editors-B1_QUpg_.js +2 -0
  93. package/dist/owletto/dist/assets/{full-page-spinner-DqpH99np.js → full-page-spinner-Cqih-8IW.js} +2 -2
  94. package/dist/owletto/dist/assets/guardrails-B8Rs1be3.js +2 -0
  95. package/dist/owletto/dist/assets/identity-B0nH4yiC.js +2 -0
  96. package/dist/owletto/dist/assets/index-4TSkcsth.js +2 -0
  97. package/dist/owletto/dist/assets/index-BSH07yVD.css +1 -0
  98. package/dist/owletto/dist/assets/index-BgkhXElB.js +2 -0
  99. package/dist/owletto/dist/assets/index-CoW4Bz3w.js +2 -0
  100. package/dist/owletto/dist/assets/index-Codw-Qqi.js +2 -0
  101. package/dist/owletto/dist/assets/{index-BQVliQW1.js → index-DAOyXG1X.js} +2 -2
  102. package/dist/owletto/dist/assets/{index-B9uPN6FC.js → index-DKPwCasf.js} +2 -2
  103. package/dist/owletto/dist/assets/index-DMyXd3bJ.js +2 -0
  104. package/dist/owletto/dist/assets/index-DYCqXaMf.js +7950 -0
  105. package/dist/owletto/dist/assets/index-DYYZLcJ0.js +2 -0
  106. package/dist/owletto/dist/assets/index-DYzWV5_z.js +2 -0
  107. package/dist/owletto/dist/assets/index-Da6CrGEu.js +2 -0
  108. package/dist/owletto/dist/assets/{index-Hio-HRfo.js → index-DfyDUpuI.js} +2 -2
  109. package/dist/owletto/dist/assets/index-DneshLbf.js +2 -0
  110. package/dist/owletto/dist/assets/index-TgRS2v_F.js +2 -0
  111. package/dist/owletto/dist/assets/{index-ICgKp3YK.js → index-ZNlrDc_f.js} +2 -2
  112. package/dist/owletto/dist/assets/{json-diff-DBoag_OS.js → json-diff-DFvYINBT.js} +3 -3
  113. package/dist/owletto/dist/assets/{list-skeleton-C_GuoxAH.js → list-skeleton-DFsEqLU1.js} +2 -2
  114. package/dist/owletto/dist/assets/login-DO0j-AYr.js +2 -0
  115. package/dist/owletto/dist/assets/{logout-CLGgeZB7.js → logout-BmNwoAf7.js} +2 -2
  116. package/dist/owletto/dist/assets/member-scope-gate-B2LrMWBU.js +2 -0
  117. package/dist/owletto/dist/assets/memory-browse-page-Cjpl8EbB.js +103 -0
  118. package/dist/owletto/dist/assets/{model-selector-dAbDgJvx.js → model-selector-TQcA93xm.js} +2 -2
  119. package/dist/owletto/dist/assets/models-D7aED5Sa.js +2 -0
  120. package/dist/owletto/dist/assets/new-BMrFy5Qa.js +2 -0
  121. package/dist/owletto/dist/assets/{new-BkdULx2r.js → new-ByBhteWA.js} +2 -2
  122. package/dist/owletto/dist/assets/new-DWp3deoW.js +2 -0
  123. package/dist/owletto/dist/assets/{oauth-workspace-access-BxsjwgdH.js → oauth-workspace-access-D_5uESuz.js} +2 -2
  124. package/dist/owletto/dist/assets/{organization-gxGeDjIV.js → organization-DTFoYP4V.js} +2 -2
  125. package/dist/owletto/dist/assets/peek-pane-content-DF5iGC3c.js +2 -0
  126. package/dist/owletto/dist/assets/{permissions-aPHaKLec.js → permissions-C_auqxfP.js} +2 -2
  127. package/dist/owletto/dist/assets/proposal-review-shell-DsNiavG_.js +2 -0
  128. package/dist/owletto/dist/assets/public-shell-ready-B2NUI89V.js +2 -0
  129. package/dist/owletto/dist/assets/{recent-D-65Pgu-.js → recent-3d99S2IE.js} +2 -2
  130. package/dist/owletto/dist/assets/record-activity-C9KfBkXb.js +2 -0
  131. package/dist/owletto/dist/assets/record-field-peek-BBZcRuGT.js +2 -0
  132. package/dist/owletto/dist/assets/record-session-BizRugWs.js +2 -0
  133. package/dist/owletto/dist/assets/{reset-password-uX_V6bip.js → reset-password-DqfcSn8M.js} +2 -2
  134. package/dist/owletto/dist/assets/runs-panel-T1ZxTVz6.js +2 -0
  135. package/dist/owletto/dist/assets/runs-table-D_8QlCCN.js +2 -0
  136. package/dist/owletto/dist/assets/schema-value-normalization-CylKX3PK.js +97 -0
  137. package/dist/owletto/dist/assets/settings-B_ClYztB.js +2 -0
  138. package/dist/owletto/dist/assets/settings-DgX1-xo7.js +2 -0
  139. package/dist/owletto/dist/assets/skills-Drw5tcZw.js +2 -0
  140. package/dist/owletto/dist/assets/{source-record-panels-CPyzlfD1.js → source-record-panels-Cg249m1S.js} +2 -2
  141. package/dist/owletto/dist/assets/{use-mention-search-By8RZyKW.js → use-mention-search-BYbFvHbJ.js} +2 -2
  142. package/dist/owletto/dist/assets/view-param-filters-DMSqkN2J.js +2 -0
  143. package/dist/owletto/dist/index.html +2 -2
  144. package/dist/server-main.bundle.mjs +3881 -3215
  145. package/npm-shrinkwrap.json +277 -261
  146. package/package.json +6 -5
  147. package/vendor/connector-sdk/package.json +1 -1
  148. package/vendor/core/dist/agent-policy.js +0 -3
  149. package/vendor/core/dist/agent-tooling.d.ts +1 -1
  150. package/vendor/core/dist/agent-tooling.js +3 -1
  151. package/vendor/core/dist/contracts/agent-settings.d.ts +6 -2
  152. package/vendor/core/dist/contracts/agent-settings.js +12 -1
  153. package/vendor/core/dist/contracts/tools/manage-views.d.ts +53 -234
  154. package/vendor/core/dist/contracts/tools/manage-views.js +50 -76
  155. package/vendor/core/dist/contracts/tools/view-attach.d.ts +5 -8
  156. package/vendor/core/dist/contracts/tools/view-attach.js +14 -31
  157. package/vendor/core/dist/contracts/tools/view-definition.d.ts +21 -0
  158. package/vendor/core/dist/contracts/tools/view-definition.js +165 -0
  159. package/vendor/core/dist/contracts/worker/protocol.d.ts +39 -2
  160. package/vendor/core/dist/contracts/worker/protocol.js +24 -1
  161. package/vendor/core/dist/index.d.ts +1 -1
  162. package/vendor/core/dist/index.js +2 -1
  163. package/vendor/core/dist/suggestions.d.ts +15 -2
  164. package/vendor/core/dist/suggestions.js +48 -3
  165. package/vendor/core/dist/types.d.ts +26 -0
  166. package/vendor/core/dist/types.js +5 -0
  167. package/vendor/core/package.json +11 -5
  168. package/vendor/postgres/cf/src/connection.js +18 -0
  169. package/vendor/postgres/cjs/src/connection.js +18 -0
  170. package/vendor/postgres/src/connection.js +18 -0
  171. package/vendor/views/dist/api.d.ts +71 -17
  172. package/vendor/views/dist/api.js +200 -35
  173. package/vendor/views/dist/bridge.d.ts +3 -0
  174. package/vendor/views/dist/bridge.js +9 -1
  175. package/vendor/views/dist/components.d.ts +170 -0
  176. package/vendor/views/dist/components.js +361 -0
  177. package/vendor/views/dist/index.d.ts +1 -1
  178. package/vendor/views/package.json +11 -1
  179. package/dist/owletto/dist/assets/_-3J-IrxWk.js +0 -2
  180. package/dist/owletto/dist/assets/_-DYUE3ix4.js +0 -3
  181. package/dist/owletto/dist/assets/_agentId-Bn2IAjIy.js +0 -2
  182. package/dist/owletto/dist/assets/_agentId-Cam7Z0N7.js +0 -2
  183. package/dist/owletto/dist/assets/_automationId-CXEiKVZJ.js +0 -2
  184. package/dist/owletto/dist/assets/_connectorKey._connectionId-CS85l61t.js +0 -2
  185. package/dist/owletto/dist/assets/_connectorKey.index-clVDIyW0.js +0 -2
  186. package/dist/owletto/dist/assets/_conversationId-Ci2k-BuN.js +0 -2
  187. package/dist/owletto/dist/assets/_eventId-B0662F8h.js +0 -2
  188. package/dist/owletto/dist/assets/_name-CwWePlOl.js +0 -2
  189. package/dist/owletto/dist/assets/_owner-dTWkrKsK.js +0 -3
  190. package/dist/owletto/dist/assets/_shape-BtS3y4M9.js +0 -2
  191. package/dist/owletto/dist/assets/_skillKey-Dc9m-nlR.js +0 -2
  192. package/dist/owletto/dist/assets/_slug-DQHutM41.js +0 -2
  193. package/dist/owletto/dist/assets/_viewKey-B30ik8ma.js +0 -2
  194. package/dist/owletto/dist/assets/_viewKey-CUHypQnF.js +0 -2
  195. package/dist/owletto/dist/assets/activity-route-view-CMqYiiKM.js +0 -2
  196. package/dist/owletto/dist/assets/agent-connect-pages-B_vrqLVc.js +0 -2
  197. package/dist/owletto/dist/assets/agent-editor-form-hTs7eO_U.js +0 -2
  198. package/dist/owletto/dist/assets/agent-subpage-shell-D92imvSt.js +0 -2
  199. package/dist/owletto/dist/assets/agent-thread-BJOijbT0.js +0 -6
  200. package/dist/owletto/dist/assets/agents-9XjpDj_S.js +0 -2
  201. package/dist/owletto/dist/assets/agents-workbench-Bt5QCYQ7.js +0 -2
  202. package/dist/owletto/dist/assets/app._appId-CKv7_squ.js +0 -2
  203. package/dist/owletto/dist/assets/automation-detail-content-vUwVumXf.js +0 -2
  204. package/dist/owletto/dist/assets/automations-9XjpDj_S.js +0 -2
  205. package/dist/owletto/dist/assets/callback-BRgcL8gz.js +0 -2
  206. package/dist/owletto/dist/assets/client-rows-EJSKR6z1.js +0 -2
  207. package/dist/owletto/dist/assets/connect-CfsFsy9P.js +0 -2
  208. package/dist/owletto/dist/assets/connect._clientId-DkiC8xos.js +0 -2
  209. package/dist/owletto/dist/assets/connected._clientId-CIXrGOsT.js +0 -2
  210. package/dist/owletto/dist/assets/connected._clientId.activity-Ckdz6I0y.js +0 -2
  211. package/dist/owletto/dist/assets/connected._clientId.index-CNxafNeo.js +0 -2
  212. package/dist/owletto/dist/assets/connections-browser-CKZjzRz6.js +0 -2
  213. package/dist/owletto/dist/assets/connector-scope-lists-CadPVsI3.js +0 -2
  214. package/dist/owletto/dist/assets/connectors-lvLJ30lo.js +0 -2
  215. package/dist/owletto/dist/assets/create-0xW9eXxG.js +0 -2
  216. package/dist/owletto/dist/assets/create-B0qhrrX4.js +0 -2
  217. package/dist/owletto/dist/assets/create-CAfF-yI1.js +0 -2
  218. package/dist/owletto/dist/assets/create._connectorKey-i6xxkWKV.js +0 -2
  219. package/dist/owletto/dist/assets/deployments-4Itm35Xc.js +0 -2
  220. package/dist/owletto/dist/assets/device-pin-tombstone-CrjG7gPo.js +0 -2
  221. package/dist/owletto/dist/assets/device._deviceId-Cs3ZmXWo.js +0 -2
  222. package/dist/owletto/dist/assets/entity-options-uXjgT7y9.js +0 -2
  223. package/dist/owletto/dist/assets/entity-page-Dc0LGr5U.js +0 -2
  224. package/dist/owletto/dist/assets/entity-type-page-CwZxa0BR.js +0 -2
  225. package/dist/owletto/dist/assets/event-detail-ve2d6Gbb.js +0 -2
  226. package/dist/owletto/dist/assets/events-feed-BtvhZF1f.js +0 -2
  227. package/dist/owletto/dist/assets/filter-editors-Cj-v6NtH.js +0 -2
  228. package/dist/owletto/dist/assets/guardrails-HFo2Ut8B.js +0 -2
  229. package/dist/owletto/dist/assets/identity-BigVSBCl.js +0 -2
  230. package/dist/owletto/dist/assets/index-BLEcy9-T.css +0 -1
  231. package/dist/owletto/dist/assets/index-BfedB4Rc.js +0 -2
  232. package/dist/owletto/dist/assets/index-CUw3aKBI.js +0 -2
  233. package/dist/owletto/dist/assets/index-CXhxUkv3.js +0 -2
  234. package/dist/owletto/dist/assets/index-Cr5hwh-C.js +0 -7950
  235. package/dist/owletto/dist/assets/index-CzkTV4ZQ.js +0 -2
  236. package/dist/owletto/dist/assets/index-DKSx8JN_.js +0 -2
  237. package/dist/owletto/dist/assets/index-DVk7Ug0d.js +0 -2
  238. package/dist/owletto/dist/assets/index-DmZuKGf8.js +0 -2
  239. package/dist/owletto/dist/assets/index-cPcroOH0.js +0 -2
  240. package/dist/owletto/dist/assets/index-n7sTbNv4.js +0 -2
  241. package/dist/owletto/dist/assets/index-xiFpcWKv.js +0 -2
  242. package/dist/owletto/dist/assets/login-Ci6ixHuL.js +0 -2
  243. package/dist/owletto/dist/assets/member-scope-gate-B44INDPY.js +0 -2
  244. package/dist/owletto/dist/assets/memory-browse-page-DyQiRvzl.js +0 -103
  245. package/dist/owletto/dist/assets/models-DpVP7ZwX.js +0 -2
  246. package/dist/owletto/dist/assets/new-BUb7AnEW.js +0 -2
  247. package/dist/owletto/dist/assets/new-CHOr-EcI.js +0 -2
  248. package/dist/owletto/dist/assets/peek-pane-content-CHoQHe2H.js +0 -2
  249. package/dist/owletto/dist/assets/proposal-review-shell-UcZr87_Q.js +0 -2
  250. package/dist/owletto/dist/assets/public-shell-ready-DcnlADmj.js +0 -2
  251. package/dist/owletto/dist/assets/record-activity-CBXH6v1d.js +0 -2
  252. package/dist/owletto/dist/assets/renderer-mEDnVW0O.js +0 -97
  253. package/dist/owletto/dist/assets/runs-C0rCgGwX.js +0 -2
  254. package/dist/owletto/dist/assets/runs-panel-Du1JMjg5.js +0 -2
  255. package/dist/owletto/dist/assets/runs-table-syPJ6r6T.js +0 -2
  256. package/dist/owletto/dist/assets/settings-9NkNA1G1.js +0 -2
  257. package/dist/owletto/dist/assets/settings-E-10sLQX.js +0 -2
  258. package/dist/owletto/dist/assets/skills-D2Ri9b4f.js +0 -2
  259. package/dist/owletto/dist/assets/status-dot-B-EWMgq6.js +0 -2
  260. package/dist/owletto/dist/assets/tabs-DqIIkCX-.js +0 -2
  261. package/dist/owletto/dist/assets/view-param-filters-CqLZQrnO.js +0 -2
  262. /package/vendor/postgres/{.bun-tag-f39dafdb2305d504 → .bun-tag-2f292c6554a8475e} +0 -0
@@ -1,2 +1,2 @@
1
- import{aw as v,ax as N,j as s,fe as y,ck as m,dd as p,P as f,B as w,fg as b}from"./index-Cr5hwh-C.js";function M(o,r){const l=new Map(r.map(e=>[e.slug,e])),i=new Map,d=e=>{const a=e.model?.trim();if(!a)return;const t=`${e.slug}/${a}`;i.has(t)||i.set(t,{value:t,provider:e.provider,model:a,isDefault:e.isDefault})};for(const e of o){const a=l.get(e.kind)??l.get(e.slug),t={slug:e.slug,provider:e.displayName||e.slug,isDefault:e.isDefault};d({...t,model:e.capabilities.text?.model}),d({...t,model:a?.defaultModel});for(const x of a?.models??[])d({...t,model:x})}for(const e of r){if(!e.systemAvailable)continue;const a={slug:e.slug,provider:e.displayName||e.slug,isDefault:!1};d({...a,model:e.defaultModel});for(const t of e.models)d({...a,model:t})}return[...i.values()]}function _(o,r){const l=o.trim();return l.length>0&&l!=="auto"&&!r.some(i=>i.value===l)}function S({value:o,onChange:r,placeholder:l,disabled:i,className:d}){const{data:e=[]}=v(),{data:a=[]}=N(),t=M(e,a),x=t.find(c=>c.value===o),h=o==="auto"?"auto":x?.value??o;return s.jsx(y,{contentClassName:"w-[--radix-popover-trigger-width] min-w-[280px]",searchPlaceholder:"Search or type a model ref…",emptyText:"Type a full provider/model ref to use it.",trigger:c=>s.jsxs(w,{type:"button",variant:"outline",role:"combobox","aria-expanded":c,disabled:i,className:f("w-full justify-between font-normal",o?"":"text-muted-foreground",d),children:[s.jsx("span",{className:"truncate",children:o?h:l}),s.jsx(b,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:(c,j)=>{const u=j.trim(),g=_(u,t);return s.jsxs(s.Fragment,{children:[s.jsxs(m,{value:"__inherit__ use default inherit",onSelect:()=>{r(""),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===""?"opacity-100":"opacity-0")}),s.jsx("span",{className:"text-muted-foreground",children:l})]}),s.jsxs(m,{value:"auto newest latest",onSelect:()=>{r("auto"),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o==="auto"?"opacity-100":"opacity-0")}),s.jsxs("span",{children:["auto"," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:"(newest for the provider)"})]})]}),t.map(n=>s.jsxs(m,{value:`${n.provider} ${n.model} ${n.value}`,onSelect:()=>{r(n.value),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===n.value?"opacity-100":"opacity-0")}),s.jsxs("span",{className:"truncate",children:[n.provider," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:n.model}),n.isDefault?s.jsx("span",{className:"ml-1.5 text-muted-foreground text-xs",children:"· org default"}):null]})]},n.value)),g?s.jsxs(m,{value:`__custom__ ${u}`,onSelect:()=>{r(u),c()},className:"cursor-pointer",children:[s.jsx(p,{className:"mr-2 h-4 w-4 opacity-0"}),s.jsxs("span",{children:["Use ",s.jsx("span",{className:"font-mono text-xs",children:u})]})]}):null]})}})}export{S as M,M as b,_ as s};
2
- //# sourceMappingURL=model-selector-dAbDgJvx.js.map
1
+ import{ax as g,ay as y,j as s,eE as N,cF as m,dy as p,Q as f,B as w,eG as b}from"./index-DYCqXaMf.js";function M(o,r){const l=new Map(r.map(e=>[e.slug,e])),i=new Map,d=e=>{const a=e.model?.trim();if(!a)return;const t=`${e.slug}/${a}`;i.has(t)||i.set(t,{value:t,provider:e.provider,model:a,isDefault:e.isDefault})};for(const e of o){const a=l.get(e.kind)??l.get(e.slug),t={slug:e.slug,provider:e.displayName||e.slug,isDefault:e.isDefault};d({...t,model:e.capabilities.text?.model}),d({...t,model:a?.defaultModel});for(const x of a?.models??[])d({...t,model:x})}for(const e of r){if(!e.systemAvailable)continue;const a={slug:e.slug,provider:e.displayName||e.slug,isDefault:!1};d({...a,model:e.defaultModel});for(const t of e.models)d({...a,model:t})}return[...i.values()]}function _(o,r){const l=o.trim();return l.length>0&&l!=="auto"&&!r.some(i=>i.value===l)}function S({value:o,onChange:r,placeholder:l,disabled:i,className:d}){const{data:e=[]}=g(),{data:a=[]}=y(),t=M(e,a),x=t.find(c=>c.value===o),h=o==="auto"?"auto":x?.value??o;return s.jsx(N,{contentClassName:"w-[--radix-popover-trigger-width] min-w-[280px]",searchPlaceholder:"Search or type a model ref…",emptyText:"Type a full provider/model ref to use it.",trigger:c=>s.jsxs(w,{type:"button",variant:"outline",role:"combobox","aria-expanded":c,disabled:i,className:f("w-full justify-between font-normal",o?"":"text-muted-foreground",d),children:[s.jsx("span",{className:"truncate",children:o?h:l}),s.jsx(b,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:(c,j)=>{const u=j.trim(),v=_(u,t);return s.jsxs(s.Fragment,{children:[s.jsxs(m,{value:"__inherit__ use default inherit",onSelect:()=>{r(""),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===""?"opacity-100":"opacity-0")}),s.jsx("span",{className:"text-muted-foreground",children:l})]}),s.jsxs(m,{value:"auto newest latest",onSelect:()=>{r("auto"),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o==="auto"?"opacity-100":"opacity-0")}),s.jsxs("span",{children:["auto"," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:"(newest for the provider)"})]})]}),t.map(n=>s.jsxs(m,{value:`${n.provider} ${n.model} ${n.value}`,onSelect:()=>{r(n.value),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===n.value?"opacity-100":"opacity-0")}),s.jsxs("span",{className:"truncate",children:[n.provider," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:n.model}),n.isDefault?s.jsx("span",{className:"ml-1.5 text-muted-foreground text-xs",children:"· org default"}):null]})]},n.value)),v?s.jsxs(m,{value:`__custom__ ${u}`,onSelect:()=>{r(u),c()},className:"cursor-pointer",children:[s.jsx(p,{className:"mr-2 h-4 w-4 opacity-0"}),s.jsxs("span",{children:["Use ",s.jsx("span",{className:"font-mono text-xs",children:u})]})]}):null]})}})}export{S as M,M as b,_ as s};
2
+ //# sourceMappingURL=model-selector-TQcA93xm.js.map
@@ -0,0 +1,2 @@
1
+ import{iN as e,j as r}from"./index-DYCqXaMf.js";import{a as n}from"./agents-workbench-CqaKGggb.js";import"./agent-editor-form-Bi6WvYX-.js";import"./model-selector-TQcA93xm.js";import"./proposal-review-shell-DsNiavG_.js";function u(){const{owner:o,agentId:t}=e.useParams();return r.jsx(n,{owner:o,agentId:t,tab:"models"})}export{u as component};
2
+ //# sourceMappingURL=models-D7aED5Sa.js.map
@@ -0,0 +1,2 @@
1
+ import{h7 as r,o as p,$ as x,i as h,bh as b,a_ as f,j as a,aC as w,g9 as A,ag as L,ga as C,L as j,gb as S,f4 as N,aR as k,bS as y}from"./index-DYCqXaMf.js";import{A as E}from"./agent-editor-form-Bi6WvYX-.js";import"./model-selector-TQcA93xm.js";const _="flex min-h-0 flex-1 flex-col gap-3 px-4 pt-2.5 pb-8 lg:px-6";function $(){const{owner:e}=r.useParams(),t=r.useSearch(),o=p(),i=x(),{isAuthenticated:c}=h(),{isMember:g,isLoading:m}=b(),n=c&&g,{data:u=[],isLoading:l}=f({enabled:n});return a.jsx("div",{className:_,children:a.jsxs(w,{className:"flex flex-1 flex-col gap-6",children:[a.jsx(A,{breadcrumb:a.jsx(C,{crumbs:[a.jsx(j,{to:"/$owner/agents",params:{owner:e},className:S,children:"Agents"},"agents")]}),icon:a.jsx(L.agents.icon,{className:"h-6 w-6"}),title:"Build a managed agent",caption:"Create an agent that Lobu runs and manages for this workspace."}),m||n&&l?a.jsx(N,{rows:1}):n?a.jsx(E,{mode:{kind:"create"},existingAgentIds:u.map(s=>s.agentId),onCreated:async s=>{const d=["agents",e];if(await i.refetchQueries({queryKey:d,exact:!0}),t.platform&&t.listen){await o({to:"/$owner/automations/new",params:{owner:e},search:{...t,agent:s}});return}await o({to:"/$owner/agents/$agentId/settings",params:{owner:e,agentId:s},search:{run_id:void 0}})}}):a.jsx(k,{icon:y,title:"Workspace membership required",description:"Only workspace members can build managed agents."})]})})}export{$ as component};
2
+ //# sourceMappingURL=new-BMrFy5Qa.js.map
@@ -1,2 +1,2 @@
1
- import{m as R,g as E,x as F,r,j as e,y as v,I as S,B as L,z as N,E as U}from"./index-Cr5hwh-C.js";import{C as I,a as A,b as T,c as k}from"./card-Djgp00r_.js";import{F as B}from"./full-page-spinner-DqpH99np.js";function c(l){return l.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function H(){const l=R(),{session:u,isReady:d}=E(),{slug:n,name:i}=F.useSearch(),[m,y]=r.useState(i||n||""),[g,h]=r.useState(n||(i?c(i):"")),[b,C]=r.useState(!!n),[x,o]=r.useState(null),[f,p]=r.useState(!1),j=r.useRef(!1);if(r.useEffect(()=>{if(!d||u||j.current)return;j.current=!0;const a=new URL("/orgs/new",window.location.origin);n&&a.searchParams.set("slug",n),i&&a.searchParams.set("name",i);const s=new URL("/auth/login",window.location.origin);s.searchParams.set("callbackUrl",`${a.pathname}${a.search}`),window.location.assign(s.toString())},[d,u,n,i]),!d||!u)return e.jsx(B,{});const P=a=>{const s=U(a);if(s.kind==="cross-host"){window.location.assign(s.href);return}l({to:s.to})},z=async a=>{a.preventDefault(),o(null);const s=m.trim(),w=(g.trim()||c(s)).trim();if(!s){o("Name is required");return}if(!w){o("Slug is required");return}p(!0);try{const t=await N.create({name:s,slug:w});if(t.error){o(t.error.message||"Failed to create organization");return}t.data&&(await N.setActive({organizationId:t.data.id}),P(t.data.slug))}catch(t){o(t instanceof Error?t.message:"An error occurred")}finally{p(!1)}};return e.jsx("div",{className:"container mx-auto max-w-md px-4 py-10",children:e.jsxs(I,{children:[e.jsx(A,{children:e.jsx(T,{children:"Create organization"})}),e.jsx(k,{children:e.jsxs("form",{onSubmit:z,className:"space-y-4",children:[x&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:x}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{htmlFor:"org-name",children:["Name",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"org-name",value:m,onChange:a=>{y(a.target.value),b||h(c(a.target.value))},placeholder:"Acme Inc.",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{htmlFor:"org-slug",children:["Slug",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"org-slug",value:g,onChange:a=>{C(!0),h(c(a.target.value))},placeholder:"acme"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used in URLs and as the org id in ",e.jsx("code",{children:"lobu.toml"}),". Lowercase letters, numbers, and hyphens."]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(L,{type:"submit",disabled:f,children:f?"Creating…":"Create organization"})})]})})]})})}export{H as component};
2
- //# sourceMappingURL=new-BkdULx2r.js.map
1
+ import{o as R,i as F,y as E,r,j as e,z as v,I as S,B as L,E as N,F as U}from"./index-DYCqXaMf.js";import{C as I,a as A,b as T,c as k}from"./card-yU0TmNRH.js";import{F as B}from"./full-page-spinner-Cqih-8IW.js";function c(l){return l.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function H(){const l=R(),{session:u,isReady:d}=F(),{slug:n,name:i}=E.useSearch(),[m,y]=r.useState(i||n||""),[g,h]=r.useState(n||(i?c(i):"")),[b,C]=r.useState(!!n),[x,o]=r.useState(null),[f,p]=r.useState(!1),j=r.useRef(!1);if(r.useEffect(()=>{if(!d||u||j.current)return;j.current=!0;const a=new URL("/orgs/new",window.location.origin);n&&a.searchParams.set("slug",n),i&&a.searchParams.set("name",i);const s=new URL("/auth/login",window.location.origin);s.searchParams.set("callbackUrl",`${a.pathname}${a.search}`),window.location.assign(s.toString())},[d,u,n,i]),!d||!u)return e.jsx(B,{});const P=a=>{const s=U(a);if(s.kind==="cross-host"){window.location.assign(s.href);return}l({to:s.to})},z=async a=>{a.preventDefault(),o(null);const s=m.trim(),w=(g.trim()||c(s)).trim();if(!s){o("Name is required");return}if(!w){o("Slug is required");return}p(!0);try{const t=await N.create({name:s,slug:w});if(t.error){o(t.error.message||"Failed to create organization");return}t.data&&(await N.setActive({organizationId:t.data.id}),P(t.data.slug))}catch(t){o(t instanceof Error?t.message:"An error occurred")}finally{p(!1)}};return e.jsx("div",{className:"container mx-auto max-w-md px-4 py-10",children:e.jsxs(I,{children:[e.jsx(A,{children:e.jsx(T,{children:"Create organization"})}),e.jsx(k,{children:e.jsxs("form",{onSubmit:z,className:"space-y-4",children:[x&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:x}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{htmlFor:"org-name",children:["Name",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"org-name",value:m,onChange:a=>{y(a.target.value),b||h(c(a.target.value))},placeholder:"Acme Inc.",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{htmlFor:"org-slug",children:["Slug",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"org-slug",value:g,onChange:a=>{C(!0),h(c(a.target.value))},placeholder:"acme"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used in URLs and as the org id in ",e.jsx("code",{children:"lobu.toml"}),". Lowercase letters, numbers, and hyphens."]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(L,{type:"submit",disabled:f,children:f?"Creating…":"Create organization"})})]})})]})})}export{H as component};
2
+ //# sourceMappingURL=new-ByBhteWA.js.map
@@ -0,0 +1,2 @@
1
+ import{o as p,bh as j,d7 as N,r as x,j as e,B as w,gK as b,bb as y,L as _,S as f,gL as v,ai as C}from"./index-DYCqXaMf.js";import{C as k,A}from"./create-automation-form-9T5WnoUs.js";import"./cronstrue-BWFEyy_P.js";import"./entity-options-DHdMC1Lx.js";import"./connection-label-BobuYiAG.js";import"./model-selector-TQcA93xm.js";import"./skill-editor-D_W3QlRz.js";import"./code-editor-U54Gwjit.js";import"./index-CDz3-ieP.js";import"./index-Vcq4gwWv.js";import"./use-mention-search-BYbFvHbJ.js";function S(s){return s.includes(":")?s.slice(s.indexOf(":")+1):s}function T({prefillAgentId:s,onCancel:t,initialTriggers:m}){const{org:g}=j(),[o,i]=x.useState({ready:!1,triggers:[]}),[a,l]=x.useState(),h=x.useCallback(n=>{i(u=>JSON.stringify(u)===JSON.stringify(n)?u:n)},[]),c=a??m;return e.jsx(k,{startFromScratch:!!m,organizationId:g?.id??"",prefillAgentId:s,onClose:t,onPrefillTriggers:n=>l(n.length>0?n:void 0),onSuccess:t,hideHeader:!0,hideCancel:!0,submitLabel:"Create Automation",submitDisabled:!o.ready,createFields:{triggers:o.triggers},triggerFields:e.jsx(A,{organizationId:g?.id??null,initialTriggers:c,onChange:h},JSON.stringify(c??"new"))})}function L({owner:s,prefilled:t}){const m=p(),{org:g}=j(),o=N(g?.id??null,{status:"active",limit:500}),i=!!(t?.platform&&(t.listen||t.resource)),a=x.useMemo(()=>{if(!t?.platform||!t.listen&&!t.resource)return;const c=o.data??[],n=t.connection?c.find(r=>r.slug===t.connection):(()=>{const r=c.filter(d=>d.connector_key!==t.platform?!1:t.resource?!0:d.facets.chat&&(d.external_tenant_id??"")===(t.team??""));return r.length===1?r[0]:void 0})();if(t.connection&&!n)return;const u=t.events?.split(",").map(r=>r.trim()).filter(Boolean)??[];return[{kind:"event",source:"connector",connector_key:t.platform,...n?{connection_id:n.id}:{},event_types:u.length>0?u:t.listen?["message.created"]:[],match:t.resource?{resource_ref:t.resource,...t.resource_type?{resource_type:t.resource_type}:{}}:{channel_id:S(t.listen??"")},execution:"turn",active_run:t.listen?"steer":"queue",output:t.listen?"reply_to_source":"silent",skip_if_unchanged:!t.listen}]},[o.data,t]),l=()=>void m({to:"/$owner/automations",params:{owner:s}}),h=a?t?.resource?`React to changes on ${t.label??t.resource}.`:`React to messages in ${t?.label??t?.listen}.`:i&&!o.isLoading?"Choose the matching connection and event, then define the reaction.":"Start from a template, from scratch, or clone an existing Automation.";return e.jsx("div",{className:"flex flex-1 flex-col gap-6 px-4 pt-2.5 pb-8 lg:px-6",children:e.jsxs("div",{className:"mx-auto flex w-full min-w-0 max-w-3xl flex-col gap-4",children:[e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3",children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsxs(w,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1.5 text-muted-foreground hover:text-foreground",onClick:l,children:[e.jsx(b,{className:"h-3.5 w-3.5"}),"Automations"]}),e.jsxs("h1",{className:"flex min-w-0 items-center gap-2 truncate font-display text-xl font-semibold",children:[e.jsx(y,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),"New automation"]})]})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:h}),t?.listen&&a?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Choose an agent below, or"," ",e.jsx(_,{to:"/$owner/agents/new",params:{owner:s},search:t,className:"underline underline-offset-4",children:"create an agent"})," ","and return to this conversation setup."]}):null,i&&o.isLoading?e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{className:"h-10 w-full"}),e.jsx(f,{className:"h-32 w-full"})]}):i&&t?.connection&&!a?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"This connection is no longer available. Reopen setup from your conversation."}):e.jsx(T,{prefillAgentId:t?.agent,onCancel:l,initialTriggers:a})]})})}function W(){const{owner:s}=v.useParams(),t=v.useSearch();return e.jsx(C,{owner:s,children:()=>e.jsx(L,{owner:s,prefilled:t})})}export{W as component};
2
+ //# sourceMappingURL=new-DWp3deoW.js.map
@@ -1,2 +1,2 @@
1
- import{j as e,M as y,P as $,Q as E,B as R,r as u,T as P}from"./index-Cr5hwh-C.js";const W=["mcp:read","mcp:write","mcp:admin"],U=[{value:"read",title:"Read only",description:"Search and view authorized workspace data."},{value:"write",title:"Read and make changes",description:"Includes read access. Create and update authorized workspace data."},{value:"admin",title:"Administer workspaces",description:"Includes read and write access. Manage administrator-only settings.",risk:"high"}],S={read:0,write:1,admin:2};function I(s){return s.includes("mcp:admin")?"admin":s.includes("mcp:write")?"write":s.includes("mcp:read")?"read":null}function D(s,a){const r=s.filter(x=>!W.includes(x));if(!a)return r;const i=I(s);return!i||S[a]>S[i]?r:["mcp:read",...a==="write"||a==="admin"?["mcp:write"]:[],...a==="admin"?["mcp:admin"]:[],...r]}function H({idPrefix:s,clientName:a,requestedScopes:r,accessLevel:i,onAccessLevelChange:x,sensitiveScopesAcknowledged:v=!1,onSensitiveScopesAcknowledgedChange:g,disabled:b=!1}){const k=I(r),f=r.includes("profile:read"),p=r.includes("device_worker:run"),o=r.includes("connections:token"),j=p||o,c=r.filter(n=>!W.includes(n)&&n!=="profile:read"&&n!=="device_worker:run"&&n!=="connections:token");return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{"aria-labelledby":`${s}-application`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-application`,className:"text-sm font-medium",children:"Application"}),e.jsx("div",{className:"rounded-lg border p-4",children:e.jsx("span",{className:"text-sm font-semibold text-foreground",children:a||"Unnamed application"})})]}),k&&e.jsxs("fieldset",{className:"space-y-2",disabled:b,children:[e.jsx("legend",{className:"text-sm font-medium",children:"Access level"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose the maximum access this application should receive."}),e.jsx("div",{className:"space-y-2",children:U.filter(n=>S[n.value]<=S[k]).map(n=>{const l=`${s}-access-${n.value}`,h=i===n.value;return e.jsxs("label",{htmlFor:l,className:$("flex cursor-pointer items-start gap-3 rounded-md border p-3 transition-colors",h&&"border-primary bg-primary/5"),children:[e.jsx("input",{id:l,type:"radio",name:`${s}-access-level`,value:n.value,checked:h,onChange:()=>x(n.value),className:"mt-1 h-4 w-4 accent-primary"}),e.jsxs("span",{className:"min-w-0 space-y-0.5",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:[n.title,n.risk==="high"&&e.jsx(y,{variant:"destructive",children:"High risk"})]}),e.jsx("span",{className:"block text-sm text-muted-foreground",children:n.description})]})]},n.value)})})]}),f&&e.jsxs("section",{"aria-labelledby":`${s}-profile`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-profile`,className:"text-sm font-medium",children:"Account information"}),e.jsxs("div",{className:"rounded-md border p-3",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:["Basic profile",e.jsx(y,{variant:"secondary",children:"Included"})]}),e.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:"See your basic Lobu identity and the names and slugs of workspaces you belong to."})]})]}),c.length>0&&e.jsxs("section",{"aria-labelledby":`${s}-additional`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-additional`,className:"text-sm font-medium",children:"Additional permissions"}),e.jsx("ul",{className:"space-y-2",children:c.map(n=>e.jsx("li",{className:"rounded-md border p-3 font-mono text-xs text-foreground",children:n},n))})]}),j&&e.jsxs("section",{className:"space-y-3 rounded-md border border-destructive/40 bg-destructive/5 p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Device capabilities"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"These capabilities are fixed by the device request and cannot be reduced here."})]}),e.jsxs("ul",{className:"space-y-2",children:[p&&e.jsxs("li",{className:"rounded-md bg-background/70 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Operate this device"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Run jobs and Automations through capabilities advertised by this device."})]}),o&&e.jsxs("li",{className:"rounded-md bg-background/70 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Use connected services"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Request short-lived access for services you connected to Lobu."})]})]}),e.jsxs("div",{className:"flex items-start gap-3 rounded-md border bg-background p-3",children:[e.jsx(E,{id:`${s}-sensitive-acknowledgement`,checked:v,disabled:b,onCheckedChange:n=>g?.(n===!0),className:"mt-0.5"}),e.jsx("label",{htmlFor:`${s}-sensitive-acknowledgement`,className:"cursor-pointer text-sm font-medium text-foreground",children:"I initiated this request and confirmed that the device code matches."})]})]})]})}function T({idPrefix:s,orgList:a,selectedOrgIds:r,onWorkspaceAccessChange:i,onSelectedOrgChange:x,orgsLoading:v,orgsError:g,onRetry:b,disabled:k=!1,deviceHomeOrgId:f=null,allowMultiple:p}){const o=`${s}-workspace-access-legend`,j=r.length===a.length;return v?e.jsxs("section",{"aria-labelledby":o,className:"space-y-2",children:[e.jsx("p",{id:o,className:"text-sm font-medium",children:"Workspace access"}),e.jsx("p",{role:"status","aria-live":"polite",className:"text-sm text-muted-foreground",children:"Loading your workspaces..."})]}):g?e.jsxs("section",{"aria-labelledby":o,className:"space-y-2",children:[e.jsx("p",{id:o,className:"text-sm font-medium",children:"Workspace access"}),e.jsxs("div",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[e.jsx("p",{children:"Workspaces could not be loaded. Approval is unavailable until they load."}),e.jsx(R,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:b,children:"Retry"})]})]}):a.length===0?e.jsxs("section",{"aria-labelledby":o,className:"space-y-2",children:[e.jsx("p",{id:o,className:"text-sm font-medium",children:"Workspace access"}),e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:"No member workspaces are available for this connection."})]}):e.jsxs("fieldset",{className:"space-y-3",disabled:k,children:[e.jsx("legend",{id:o,className:"sr-only",children:"Workspace access"}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Workspaces"}),e.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:p?"Choose where this application can operate.":"Choose one workspace this application can access."})]}),p&&!j&&e.jsxs(R,{type:"button",variant:"outline",size:"sm",onClick:()=>i("all_current"),children:["Select all ",a.length]})]}),f&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p?"The device workspace is always included. Additional workspaces grant MCP access only.":"MCP access follows the device workspace."}),e.jsx("div",{className:"space-y-2",children:a.map(c=>{const n=`${s}-workspace-${c.id}`,l=c.id===f,h=r.includes(c.id);return e.jsxs("div",{className:$("flex items-start gap-3 rounded-md border p-3 transition-colors",h&&"border-primary/40 bg-primary/5"),children:[e.jsx(E,{id:n,checked:h,disabled:k||l||f!==null&&!p,onCheckedChange:N=>x(c.id,N===!0),className:"mt-0.5"}),e.jsxs("label",{htmlFor:n,className:"min-w-0 flex-1 cursor-pointer space-y-0.5",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:[c.name,c.isPersonal&&e.jsx(y,{variant:"outline",children:"Personal"}),l&&e.jsx(y,{variant:"secondary",children:"Device workspace"})]}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:c.slug})]})]},c.id)})}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-muted-foreground",children:[e.jsxs("p",{"aria-live":"polite",children:[r.length," of ",a.length," workspaces selected."]}),j&&e.jsx(y,{variant:"secondary",children:"All currently available"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Workspaces you join later are not added automatically."}),r.length===0&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"Choose at least one workspace."})]})}function q(s,a){u.useEffect(()=>{if(a||s)return;const r=new URL("/auth/login",window.location.origin);r.searchParams.set("callbackUrl",window.location.href),window.location.href=r.toString()},[s,a])}function F(s,a){return s.length===a.length&&s.every((r,i)=>r===a[i])}function V(s={}){const{requireDeviceHome:a=!1,deviceHomeOrgId:r=null,allowMultiple:i=!0}=s,{data:x,error:v,isPending:g,refetch:b}=P(),[k,f]=u.useState("selected"),[p,o]=u.useState([]),j=u.useRef(!1),c=u.useMemo(()=>x?x.filter(t=>t.is_member).map(t=>({id:t.id,name:t.name,slug:t.slug,isPersonal:t.is_personal===!0})):[],[x]),n=c.find(t=>t.isPersonal)?.id??null,l=a?r&&c.some(t=>t.id===r)?r:n:null,h=u.useRef(c);h.current=c;const N=v instanceof Error?v.message:v?"Unable to load workspaces":null;u.useEffect(()=>{if(g||N)return;const t=c.map(d=>d.id),m=new Set(t);o(d=>{const C=j.current?d.filter(A=>m.has(A)):[n??t[0]].filter(A=>!!A);return j.current=!0,F(d,C)?d:C})},[c,N,g,n]);const L=u.useCallback(t=>{if(t==="all_current"){if(!i)return;o(h.current.map(m=>m.id))}f(t)},[i]),M=u.useCallback((t,m)=>{h.current.some(d=>d.id===t)&&(a&&(t===l||!i)||(f("selected"),o(d=>m?i?d.includes(t)?d:[...d,t]:[t]:d.filter(C=>C!==t))))},[i,l,a]),w=u.useMemo(()=>{if(a&&l&&!i)return[l];const t=new Set(p);return a&&l&&t.add(l),c.filter(m=>t.has(m.id)).map(m=>m.id)},[i,p,l,c,a]),_=u.useCallback(()=>{const t=h.current,m=t.find(d=>d.isPersonal)?.id??t[0]?.id;j.current=t.length>0,f("selected"),o(m?[m]:[])},[]),O=!g&&!N&&c.length>0&&w.length>0&&(i||w.length===1)&&(!a||l!==null&&w.includes(l)),z=u.useCallback(()=>{b()},[b]);return{orgList:c,workspaceAccess:k,setWorkspaceAccess:L,selectedOrgIds:w,toggleSelectedOrgId:M,resetWorkspaceSelection:_,personalOrgId:n,deviceHomeOrgId:l,orgsLoading:g,orgsError:N,retryOrgs:z,workspaceSelectionReady:O}}function K(s){if(!s)return null;try{return new URL(s).pathname.match(/^\/mcp\/([^/]+)$/)?.[1]?.trim()||null}catch{return null}}export{H as A,T as W,I as a,q as b,K as g,D as s,V as u};
2
- //# sourceMappingURL=oauth-workspace-access-BxsjwgdH.js.map
1
+ import{j as e,P as y,Q as $,T as E,B as R,r as u,U as z}from"./index-DYCqXaMf.js";const W=["mcp:read","mcp:write","mcp:admin"],P=[{value:"read",title:"Read only",description:"Search and view authorized workspace data."},{value:"write",title:"Read and make changes",description:"Includes read access. Create and update authorized workspace data."},{value:"admin",title:"Administer workspaces",description:"Includes read and write access. Manage administrator-only settings.",risk:"high"}],S={read:0,write:1,admin:2};function I(s){return s.includes("mcp:admin")?"admin":s.includes("mcp:write")?"write":s.includes("mcp:read")?"read":null}function D(s,a){const r=s.filter(x=>!W.includes(x));if(!a)return r;const i=I(s);return!i||S[a]>S[i]?r:["mcp:read",...a==="write"||a==="admin"?["mcp:write"]:[],...a==="admin"?["mcp:admin"]:[],...r]}function H({idPrefix:s,clientName:a,requestedScopes:r,accessLevel:i,onAccessLevelChange:x,sensitiveScopesAcknowledged:v=!1,onSensitiveScopesAcknowledgedChange:g,disabled:b=!1}){const k=I(r),f=r.includes("profile:read"),p=r.includes("device_worker:run"),o=r.includes("connections:token"),j=p||o,c=r.filter(n=>!W.includes(n)&&n!=="profile:read"&&n!=="device_worker:run"&&n!=="connections:token");return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{"aria-labelledby":`${s}-application`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-application`,className:"text-sm font-medium",children:"Application"}),e.jsx("div",{className:"rounded-lg border p-4",children:e.jsx("span",{className:"text-sm font-semibold text-foreground",children:a||"Unnamed application"})})]}),k&&e.jsxs("fieldset",{className:"space-y-2",disabled:b,children:[e.jsx("legend",{className:"text-sm font-medium",children:"Access level"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose the maximum access this application should receive."}),e.jsx("div",{className:"space-y-2",children:P.filter(n=>S[n.value]<=S[k]).map(n=>{const l=`${s}-access-${n.value}`,h=i===n.value;return e.jsxs("label",{htmlFor:l,className:$("flex cursor-pointer items-start gap-3 rounded-md border p-3 transition-colors",h&&"border-primary bg-primary/5"),children:[e.jsx("input",{id:l,type:"radio",name:`${s}-access-level`,value:n.value,checked:h,onChange:()=>x(n.value),className:"mt-1 h-4 w-4 accent-primary"}),e.jsxs("span",{className:"min-w-0 space-y-0.5",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:[n.title,n.risk==="high"&&e.jsx(y,{variant:"destructive",children:"High risk"})]}),e.jsx("span",{className:"block text-sm text-muted-foreground",children:n.description})]})]},n.value)})})]}),f&&e.jsxs("section",{"aria-labelledby":`${s}-profile`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-profile`,className:"text-sm font-medium",children:"Account information"}),e.jsxs("div",{className:"rounded-md border p-3",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:["Basic profile",e.jsx(y,{variant:"secondary",children:"Included"})]}),e.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:"See your basic Lobu identity and the names and slugs of workspaces you belong to."})]})]}),c.length>0&&e.jsxs("section",{"aria-labelledby":`${s}-additional`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-additional`,className:"text-sm font-medium",children:"Additional permissions"}),e.jsx("ul",{className:"space-y-2",children:c.map(n=>e.jsx("li",{className:"rounded-md border p-3 font-mono text-xs text-foreground",children:n},n))})]}),j&&e.jsxs("section",{className:"space-y-3 rounded-md border border-destructive/40 bg-destructive/5 p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Device capabilities"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"These capabilities are fixed by the device request and cannot be reduced here."})]}),e.jsxs("ul",{className:"space-y-2",children:[p&&e.jsxs("li",{className:"rounded-md bg-background/70 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Operate this device"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Run jobs and Automations through capabilities advertised by this device."})]}),o&&e.jsxs("li",{className:"rounded-md bg-background/70 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Use connected services"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Request short-lived access for services you connected to Lobu."})]})]}),e.jsxs("div",{className:"flex items-start gap-3 rounded-md border bg-background p-3",children:[e.jsx(E,{id:`${s}-sensitive-acknowledgement`,checked:v,disabled:b,onCheckedChange:n=>g?.(n===!0),className:"mt-0.5"}),e.jsx("label",{htmlFor:`${s}-sensitive-acknowledgement`,className:"cursor-pointer text-sm font-medium text-foreground",children:"I initiated this request and confirmed that the device code matches."})]})]})]})}function T({idPrefix:s,orgList:a,selectedOrgIds:r,onWorkspaceAccessChange:i,onSelectedOrgChange:x,orgsLoading:v,orgsError:g,onRetry:b,disabled:k=!1,deviceHomeOrgId:f=null,allowMultiple:p}){const o=`${s}-workspace-access-legend`,j=r.length===a.length;return v?e.jsxs("section",{"aria-labelledby":o,className:"space-y-2",children:[e.jsx("p",{id:o,className:"text-sm font-medium",children:"Workspace access"}),e.jsx("p",{role:"status","aria-live":"polite",className:"text-sm text-muted-foreground",children:"Loading your workspaces..."})]}):g?e.jsxs("section",{"aria-labelledby":o,className:"space-y-2",children:[e.jsx("p",{id:o,className:"text-sm font-medium",children:"Workspace access"}),e.jsxs("div",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[e.jsx("p",{children:"Workspaces could not be loaded. Approval is unavailable until they load."}),e.jsx(R,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:b,children:"Retry"})]})]}):a.length===0?e.jsxs("section",{"aria-labelledby":o,className:"space-y-2",children:[e.jsx("p",{id:o,className:"text-sm font-medium",children:"Workspace access"}),e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:"No member workspaces are available for this connection."})]}):e.jsxs("fieldset",{className:"space-y-3",disabled:k,children:[e.jsx("legend",{id:o,className:"sr-only",children:"Workspace access"}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Workspaces"}),e.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:p?"Choose where this application can operate.":"Choose one workspace this application can access."})]}),p&&!j&&e.jsxs(R,{type:"button",variant:"outline",size:"sm",onClick:()=>i("all_current"),children:["Select all ",a.length]})]}),f&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p?"The device workspace is always included. Additional workspaces grant MCP access only.":"MCP access follows the device workspace."}),e.jsx("div",{className:"space-y-2",children:a.map(c=>{const n=`${s}-workspace-${c.id}`,l=c.id===f,h=r.includes(c.id);return e.jsxs("div",{className:$("flex items-start gap-3 rounded-md border p-3 transition-colors",h&&"border-primary/40 bg-primary/5"),children:[e.jsx(E,{id:n,checked:h,disabled:k||l||f!==null&&!p,onCheckedChange:N=>x(c.id,N===!0),className:"mt-0.5"}),e.jsxs("label",{htmlFor:n,className:"min-w-0 flex-1 cursor-pointer space-y-0.5",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:[c.name,c.isPersonal&&e.jsx(y,{variant:"outline",children:"Personal"}),l&&e.jsx(y,{variant:"secondary",children:"Device workspace"})]}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:c.slug})]})]},c.id)})}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-muted-foreground",children:[e.jsxs("p",{"aria-live":"polite",children:[r.length," of ",a.length," workspaces selected."]}),j&&e.jsx(y,{variant:"secondary",children:"All currently available"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Workspaces you join later are not added automatically."}),r.length===0&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"Choose at least one workspace."})]})}function q(s,a){u.useEffect(()=>{if(a||s)return;const r=new URL("/auth/login",window.location.origin);r.searchParams.set("callbackUrl",window.location.href),window.location.href=r.toString()},[s,a])}function F(s,a){return s.length===a.length&&s.every((r,i)=>r===a[i])}function V(s={}){const{requireDeviceHome:a=!1,deviceHomeOrgId:r=null,allowMultiple:i=!0}=s,{data:x,error:v,isPending:g,refetch:b}=z(),[k,f]=u.useState("selected"),[p,o]=u.useState([]),j=u.useRef(!1),c=u.useMemo(()=>x?x.filter(t=>t.is_member).map(t=>({id:t.id,name:t.name,slug:t.slug,isPersonal:t.is_personal===!0})):[],[x]),n=c.find(t=>t.isPersonal)?.id??null,l=a?r&&c.some(t=>t.id===r)?r:n:null,h=u.useRef(c);h.current=c;const N=v instanceof Error?v.message:v?"Unable to load workspaces":null;u.useEffect(()=>{if(g||N)return;const t=c.map(d=>d.id),m=new Set(t);o(d=>{const C=j.current?d.filter(A=>m.has(A)):[n??t[0]].filter(A=>!!A);return j.current=!0,F(d,C)?d:C})},[c,N,g,n]);const L=u.useCallback(t=>{if(t==="all_current"){if(!i)return;o(h.current.map(m=>m.id))}f(t)},[i]),M=u.useCallback((t,m)=>{h.current.some(d=>d.id===t)&&(a&&(t===l||!i)||(f("selected"),o(d=>m?i?d.includes(t)?d:[...d,t]:[t]:d.filter(C=>C!==t))))},[i,l,a]),w=u.useMemo(()=>{if(a&&l&&!i)return[l];const t=new Set(p);return a&&l&&t.add(l),c.filter(m=>t.has(m.id)).map(m=>m.id)},[i,p,l,c,a]),_=u.useCallback(()=>{const t=h.current,m=t.find(d=>d.isPersonal)?.id??t[0]?.id;j.current=t.length>0,f("selected"),o(m?[m]:[])},[]),O=!g&&!N&&c.length>0&&w.length>0&&(i||w.length===1)&&(!a||l!==null&&w.includes(l)),U=u.useCallback(()=>{b()},[b]);return{orgList:c,workspaceAccess:k,setWorkspaceAccess:L,selectedOrgIds:w,toggleSelectedOrgId:M,resetWorkspaceSelection:_,personalOrgId:n,deviceHomeOrgId:l,orgsLoading:g,orgsError:N,retryOrgs:U,workspaceSelectionReady:O}}function K(s){if(!s)return null;try{return new URL(s).pathname.match(/^\/mcp\/([^/]+)$/)?.[1]?.trim()||null}catch{return null}}export{H as A,T as W,I as a,q as b,K as g,D as s,V as u};
2
+ //# sourceMappingURL=oauth-workspace-access-D_5uESuz.js.map
@@ -1,2 +1,2 @@
1
- import{Z as pe,r as v,bs as Fe,bt as qe,bu as Be,bv as Ke,bw as ye,j as e,bx as Z,B as N,by as Me,aQ as Ve,bz as He,bA as Ue,bB as Ye,bC as Ge,bD as Je,bE as Ze,bF as Xe,bG as be,bH as X,bI as et,bJ as tt,bK as st,bL as de,bM as nt,bN as it,m as at,T as Ie,k as ot,bO as rt,bP as J,i as ct,y as ve,I as je,bQ as lt,bR as dt,bS as ut,a1 as Ne,a_ as mt,z as re,bT as pt,bU as Ce,bV as _e,bW as ht,E as gt,bX as ke,bY as xt}from"./index-Cr5hwh-C.js";import{P as ue,a as De,A as ft}from"./agent-permissions-matrix-BOo_4r_4.js";import{C as Se,a as Ae,b as we,c as ze}from"./card-Djgp00r_.js";const Oe=["auto","approval","deny"],yt={matched_rule:"Matching policy rules apply.",default_approval:"No rule matches; approval is required.",unresolved_principal:"The requesting agent or Automation could not be identified.",parent_approval:"Approval is inherited from the parent action.",unavailable_operation:"This action is unavailable on the connection."},Le={read:"Reads",write:"Writes",destructive:"Destructive writes",non_destructive:"Non-destructive writes",unknown:"Unclassified writes"};function me(t){return{operation_key:t.operation_key??null,connector_key:t.connector_key??null,connection_id:t.connection_id??null,operation_category:t.operation_category??null}}const ce=t=>JSON.stringify(me(t)),Pe=t=>({...t,effect:t.effects.execute??"approval"});function F({label:t,value:i,onChange:a,children:o,disabled:m}){return e.jsxs("label",{className:"flex min-w-0 flex-col gap-1 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:t}),e.jsx("select",{"aria-label":t,value:i,onChange:d=>a(d.target.value),disabled:m,className:"h-9 w-full rounded-lg border bg-background px-2 text-foreground",children:o})]})}function bt(t,i){const a=i.connections?.find(o=>o.id===t.connection_id);return t.connection_id?`Connection: ${a?.display_name||a?.connector_key||"Unavailable"} (#${t.connection_id})`:t.connector_key?`Connector: ${i.connectors?.find(o=>o.key===t.connector_key)?.name||t.connector_key}`:"All connectors"}function vt(t,i){return t.operation_key?i.connector_operations.find(a=>a.operation_key===t.operation_key)?.name||t.operation_key:t.operation_category?Le[t.operation_category]:"All actions"}function le(t,i){return`${bt(t,i)} · ${vt(t,i)}`}function $e(t){return t.connection_id?`connection:${t.connection_id}`:t.connector_key?`connector:${t.connector_key}`:"all"}function Ee({catalog:t}){return e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"all",children:"All connectors"}),e.jsx("optgroup",{label:"Connectors",children:t.connectors?.map(i=>e.jsx("option",{value:`connector:${i.key}`,children:i.name},i.key))}),e.jsx("optgroup",{label:"Connections",children:t.connections?.map(i=>e.jsxs("option",{value:`connection:${i.id}`,children:[i.display_name||i.connector_key," (#",i.id,")"]},i.id))})]})}function jt({label:t,ariaLabel:i,disabled:a,onRemove:o}){const[m,d]=v.useState(!1);return m?e.jsxs("div",{className:"flex gap-1",children:[e.jsx(N,{type:"button",variant:"destructive",size:"sm",disabled:a,"aria-label":"Confirm removal",onClick:async()=>{await o()&&d(!1)},children:"Confirm"}),e.jsx(N,{type:"button",variant:"ghost",size:"sm",disabled:a,onClick:()=>d(!1),children:"Cancel"})]}):e.jsx(N,{type:"button",variant:"ghost",size:"sm",disabled:a,"aria-label":i,onClick:()=>d(!0),children:t})}function Nt({owner:t,connector:i,connection:a,agent:o}){const m=pe(),[d,j]=v.useState(o??""),S=Fe(t),r=S.data,u=r?.agents.some(s=>s.id===d)?d:"",n=qe(t,u),g=Be(t,!u),[C,W]=v.useState(a?`connection:${a}`:i?`connector:${i}`:"all"),[Y,Q]=v.useState(C),[I,A]=v.useState(!1),[O,q]=v.useState(""),[_,B]=v.useState("all"),[$,K]=v.useState("approval"),[p,D]=v.useState(!1),[M,E]=v.useState(null),[V,ee]=v.useState(a?String(a):""),[T,G]=v.useState(""),P=r?.connections?.some(s=>String(s.id)===V)?V:"",k=Ke(t,P?Number(P):void 0,T,u||void 0);async function H(s,b){D(!0),E(null);try{if(u){const l={resource_class:"connector_action",...me(s)};b?await Ye(t,u,{...l,effects:{execute:b}}):await Ge(t,u,l)||E("This rule was already removed. The list has been refreshed.")}else{const l=g.data;if(!l)return;const L=l.rules.filter(Qe=>ce(Qe)!==ce(s));b&&L.push({...me(s),effect:b});const oe=await Je(t,{revision:l.revision,rules:L});m.setQueryData(Ze(t),oe)}return await Promise.all(["write-permissions","agent-permissions","available-operations","connector-operations","policy-explanation"].map(l=>m.invalidateQueries({queryKey:[l]}))),s}catch(l){l instanceof ye&&l.status===409?(E("Policies changed in another session. Review the refreshed rules before saving again."),await g.refetch()):E(l instanceof Error?l.message:"Could not save policy.")}finally{D(!1)}}const f=S.error||(u?n.error:g.error);if(f instanceof ye&&f.status===403)return e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Only organization owners and admins can manage policies."});if(f)return e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Could not load policies. ",String(f)]});if(!r||(u?!n.data:!g.data))return e.jsx(Z,{label:"policies",rows:2});const c=s=>s==="all"||r.connectors?.some(b=>`connector:${b.key}`===s)||r.connections?.some(b=>`connection:${b.id}`===s)?s:"all",h=c(C),x=c(Y),w=r.connections?.find(s=>`connection:${s.id}`===x),y=w?.connector_key??(x.startsWith("connector:")?x.slice(10):void 0),R=s=>x==="all"||$e(s)==="all"?!0:s.connection_id?w?s.connection_id===w.id:r.connections?.some(b=>b.id===s.connection_id&&b.connector_key===y):s.connector_key===y;function te(s){return u?s.principal_kind==="agent"&&s.principal_id===u:!s.principal_kind}const z=h.startsWith("connector:")?h.slice(10):h.startsWith("connection:")?r.connections?.find(s=>s.id===Number(h.slice(11)))?.connector_key:void 0,U=r.connector_operations.filter(s=>!z||s.connector_key===z),se=r.connections?.find(s=>s.id===Number(P))?.connector_key,ne=r.connector_operations.filter(s=>s.connector_key===se),ie=u?(n.data?.agent??[]).filter(s=>s.resource_class==="connector_action").map(Pe):g.data?.rules??[],ge=(n.data?.floor??[]).filter(s=>s.resource_class==="connector_action"&&R(s)).map(Pe),We={connector_key:h.startsWith("connector:")?h.slice(10):h==="all"&&_==="specific"?U.find(s=>s.operation_key===O)?.connector_key??null:null,connection_id:h.startsWith("connection:")?Number(h.slice(11)):null,operation_key:_==="specific"?O:null,operation_category:_.startsWith("category:")?_.slice(9):null},ae=ie.filter(R);function xe(){W(x),B("all"),q(""),K("approval"),A(!0)}const fe=(s,b=!1)=>e.jsx("div",{className:"divide-y rounded-lg border",children:s.map(l=>{const L=!b&&te(l);return e.jsxs(De,{controls:e.jsxs(e.Fragment,{children:[e.jsx(ue,{options:Oe,value:l.effect,floor:"auto",compact:!0,disabled:p||!L,ariaLabel:`Policy for ${le(l,r)}`,onChange:oe=>void H(l,oe)}),L&&e.jsx(jt,{label:"Remove",disabled:p,ariaLabel:`Remove rule: ${le(l,r)}`,onRemove:()=>H(l)})]}),children:[e.jsx("p",{className:"text-sm break-words",children:le(l,r)}),!L&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.principal_kind==="agent"&&!l.principal_id?"All agents":"Inherited restriction"})]},JSON.stringify([l.principal_kind,l.principal_id,ce(l)]))})});return e.jsxs("div",{className:"space-y-4",children:[(x!==Y||u!==d)&&e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"The requested scope is unavailable. Showing organization rules; install the connector or choose an available scope."}),e.jsxs("div",{className:"space-y-1 text-sm text-muted-foreground",children:[e.jsx("p",{children:"Auto runs immediately. Ask waits for human approval. Block prevents execution and hides the action from agents. Authentication and guardrails still apply."}),e.jsxs("details",{className:"space-y-2",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-foreground",children:"How rules combine"}),e.jsx("p",{children:"A rule overrides another when it is narrower in target or actions and at least as narrow in the other. When rules are narrower in different ways, or use different categories, the stricter choice wins: Block, then Ask, then Auto. With no matching rule, the result is Ask. Impact categories apply only to writes."}),e.jsx("p",{children:"A connection-wide Auto does not override an organization-wide destructive Block. Add a destructive rule for that connection to make an exception."}),e.jsx("p",{children:"Agents and their Automations can only tighten organization policy. Internal browser steps inherit the parent approval; an explicit browser Block still wins."})]})]}),e.jsxs(F,{label:"Policy owner",value:u,onChange:j,disabled:p,children:[e.jsx("option",{value:"",children:"Organization"}),r.agents.map(s=>e.jsxs("option",{value:s.id,children:["Agent: ",s.name]},s.id))]}),u&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Auto adds no restriction for this agent. It inherits organization policy and cannot bypass Ask or Block."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u?"Without a matching restriction, this agent inherits organization policy.":"Without a matching rule, actions require approval (Ask)."}),e.jsx(F,{label:"Show rules for",value:x,onChange:Q,disabled:p,children:e.jsx(Ee,{catalog:r})}),u&&ge.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Inherited organization rules"}),fe(ge,!0)]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:u?"Saved restrictions":"Saved rules"}),!I&&ae.length>0&&e.jsx(N,{variant:"outline",size:"sm",disabled:p,onClick:xe,children:"Add rule"})]}),I&&e.jsxs("form",{className:"space-y-3 border-t pt-4",onSubmit:s=>{s.preventDefault(),!p&&(_!=="specific"||O)&&H(We,$).then(b=>{b&&(A(!1),Q($e(b)))})},children:[e.jsx("h3",{className:"text-sm font-medium",children:"Add rule"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(F,{label:"Applies to",value:h,onChange:s=>{W(s),B("all"),q("")},disabled:p,children:e.jsx(Ee,{catalog:r})}),e.jsxs(F,{label:"Actions",value:_,onChange:B,disabled:p,children:[e.jsx("option",{value:"all",children:"All actions"}),e.jsx("optgroup",{label:"Categories",children:r.operation_categories?.map(s=>e.jsx("option",{value:`category:${s}`,children:Le[s]},s))}),e.jsx("option",{value:"specific",children:"Specific action"})]})]}),_==="specific"&&e.jsxs(F,{label:"Specific action",value:O,onChange:q,disabled:p,children:[e.jsx("option",{value:"",children:"Choose action"}),U.map(s=>e.jsxs("option",{value:s.operation_key,children:[s.connector_name,": ",s.name]},s.operation_key))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx(ue,{options:Oe,value:$,floor:"auto",compact:!0,disabled:p,ariaLabel:"New rule decision",onChange:K}),e.jsx(Me,{onCancel:()=>A(!1),cancelDisabled:p,children:e.jsx(N,{type:"submit",disabled:p||_==="specific"&&!O,children:p?"Saving…":"Save rule"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saving an existing scope replaces its decision. Removing a rule reveals the next matching rule."})]}),ae.length?fe(ae):!I&&e.jsx(Ve,{icon:He,title:"No saved rules in this scope",description:"Add a rule for all actions, a category, or a specific action.",actionLabel:"Add rule",onAction:xe})]}),M&&e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:M}),e.jsxs("details",{className:"space-y-3 border-t pt-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"Check an action"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs(F,{label:"Check connection",value:P,onChange:s=>{ee(s),G("")},children:[e.jsx("option",{value:"",children:"Choose connection"}),r.connections?.map(s=>e.jsxs("option",{value:String(s.id),children:[s.display_name||s.connector_key," (#",s.id,")"]},s.id))]}),e.jsxs(F,{label:"Check action",value:T,onChange:G,disabled:!P,children:[e.jsx("option",{value:"",children:"Choose action"}),ne.map(s=>e.jsx("option",{value:s.operation_key.slice(s.connector_key.length+2),children:s.name},s.operation_key))]})]}),k.error?e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Could not check policy. ",String(k.error)]}):e.jsx("p",{"aria-live":"polite",className:"text-sm",children:T?k.isPending?"Checking…":k.data?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:Ue[k.data.effect]})," ·"," ",yt[k.data.reason]??"The server evaluated this action.",k.data.rule_ids.length>0?` · Rules ${k.data.rule_ids.map(s=>`#${s}`).join(", ")}`:""]}):"":""})]})]})}const Ct=[{action:"create_type",label:"Create entity types",description:"Add a new type and its initial fields."},{action:"update_type",label:"Edit entity types",description:"Change fields, write rules, event kinds, or type metadata."},{action:"delete_type",label:"Delete entity types",description:"Remove an entity-type definition."}],_t=[{action:"create_relationship_type",label:"Create relationship types",description:"Add a new kind of link between entity types."},{action:"update_relationship_type",label:"Edit relationship types",description:"Change a definition, or which types it may connect."},{action:"delete_relationship_type",label:"Delete relationship types",description:"Remove a relationship-type definition."}];function he(t){return t.resource_class==="entity_schema"&&t.principal_kind===null&&t.entity_type_slug===null&&t.operation_key===null&&t.target_agent_id===null}function kt(t){return t.agent.find(he)}function St(t,i){return{...t,agent:[...t.agent.filter(a=>!he(a)),i]}}function At(t){return{...t,agent:t.agent.filter(i=>!he(i))}}function wt({label:t,description:i,action:a,value:o,pending:m,onChange:d}){return e.jsxs(De,{controls:e.jsx(ue,{options:it("entity_schema",a),value:o,floor:"auto",disabled:m,compact:!0,ariaLabel:t,onChange:d}),children:[e.jsx("p",{children:t}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:i})]})}function Te({title:t,actions:i,effects:a,pending:o,onChange:m}){return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:t}),e.jsx("div",{className:"divide-y overflow-hidden rounded-lg border",children:i.map(({action:d,label:j,description:S})=>e.jsx(wt,{action:d,label:j,description:S,value:a[d]??de.entity_schema[d]??"deny",pending:o,onChange:r=>m(d,r)},d))})]})}function zt({owner:t}){const i=pe(),a=Xe(t),o=Fe(t),m=be({mutationFn:n=>et(t,{resource_class:"entity_schema",effects:n}),onSuccess:n=>{i.setQueryData(a,g=>g&&St(g,n)),i.invalidateQueries({queryKey:a})},onError:n=>{X.error(n instanceof Error?n.message:"Failed to save schema policy")}}),d=be({mutationFn:()=>tt(t,{resource_class:"entity_schema"}),onSuccess:()=>{i.setQueryData(a,n=>n&&At(n)),i.invalidateQueries({queryKey:a})},onError:n=>{X.error(n instanceof Error?n.message:"Failed to reset schema policy")}});if(o.isLoading)return e.jsx(Z,{label:"schema policy",variant:"cards",cards:1});if(o.isError||!o.data)return e.jsx(st,{label:"schema policy"});const j=kt(o.data),S=j?.effects??de.entity_schema,r=m.isPending||d.isPending,u=(n,g)=>{m.mutate({...j?.effects??de.entity_schema,[n]:g})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:j?"Custom policy":"Workspace defaults"}),j?e.jsxs(N,{type:"button",variant:"outline",size:"sm",disabled:r,onClick:()=>d.mutate(),children:[e.jsx(nt,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove custom policy"]}):null]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Te,{title:"Entity types",actions:Ct,effects:S,pending:r,onChange:u}),e.jsx(Te,{title:"Relationship types",actions:_t,effects:S,pending:r,onChange:u})]})]})}function Re(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ot(t,i,a){const o=t.split("/");return o[1]===i?(o[1]=a,o.join("/")||"/"):`/${a}`}function Pt({owner:t,connector:i,connection:a,agent:o}){const m=at(),d=pe(),{data:j,error:S}=Ie(),{activeOrg:r,urlOrgSlug:u}=ot(),n=(j??[]).find(c=>c.slug===t&&c.is_member)??null,g=n?.id??t,C=rt(g,{name:n?.name??"",slug:n?.slug??"",visibility:n?.visibility??"private"}),[W,Y]=C.field("name"),[Q,I]=C.field("slug"),[A,O]=C.field("visibility"),[q,_]=J(g,!!n),[B,$]=J(g,!1),[K,p]=J(g,null),[D,M]=v.useState(!1),[E,V]=v.useState(!1),[ee,T]=J(g,!1);if(ct(S)&&j===void 0)return e.jsxs(Se,{role:"alert",children:[e.jsx(Ae,{children:e.jsx(we,{children:"Couldn't load organizations"})}),e.jsx(ze,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Please try again in a moment."})})]});if(j===void 0)return e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsx(Z,{label:"organization",variant:"cards",cards:1}),e.jsx(Z,{label:"visibility",variant:"panel"})]});if(!n)return e.jsxs(Se,{children:[e.jsx(Ae,{children:e.jsx(we,{children:"Organization not found"})}),e.jsx(ze,{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You aren't a member of an organization at"," ",e.jsx("span",{className:"font-mono",children:t}),", or it has been deleted."]})})]});const G=c=>{const h=gt(c);if(h.kind==="cross-host"){window.location.assign(h.href);return}m({to:h.to})},P=c=>{if(c==="public"&&n.visibility!=="public"){$(!0);return}O(c),$(!1)},k=async()=>{if(!C.canSubmit)return;const c=W.trim();if(!c){p("Name is required");return}const h=Q.trim()||Re(c);if(!h){p("Slug is required");return}M(!0),p(null);try{const x=c!==n.name||h!==n.slug,w=A!==n.visibility;let y=n.slug;if(x){const z=await re.update({organizationId:n.id,data:{name:c,slug:h}});if(z.error){p(z.error.message||"Failed to update organization");return}y=z.data?.slug??h}w&&(y=(await pt(y,A)).slug),(x||w)&&(C.accept(C.values,{name:c,slug:y,visibility:A}),await d.invalidateQueries({queryKey:["organizations"]}),X.success("Organization updated"));const R=r?.id===n.id||u===n.slug,te=y!==n.slug;if(R&&te){const z=Ce(),U=_e();if(z===n.slug&&U){const ne=ht(window.location.pathname,n.slug)||"/",ie=`${window.location.protocol}//${y}.${U}${ne}${window.location.search}${window.location.hash}`;window.location.assign(ie);return}const se=Ot(window.location.pathname,n.slug,y);m({to:`${se}${window.location.search}${window.location.hash}`});return}}catch(x){p(x instanceof Error?x.message:"Failed to update organization")}finally{M(!1)}},H=async()=>{V(!0),p(null);try{const c=await re.delete({organizationId:n.id});if(c.error){p(c.error.message||"Failed to delete organization");return}await d.invalidateQueries({queryKey:["organizations"]}),X.success("Organization deleted");const x=(j??[]).filter(y=>y.is_member).find(y=>y.id!==n.id)??null,w=r?.id===n.id||u===n.slug;if(w&&x){await re.setActive({organizationId:x.id}),G(x.slug);return}if(w){const y=Ce(),R=_e();if(y===n.slug&&R){window.location.assign(`${window.location.protocol}//app.${R}/`);return}m({to:"/"});return}m({to:"/"})}catch(c){p(c instanceof Error?c.message:"Failed to delete organization")}finally{V(!1),T(!1)}},f=D||E;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Identity"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"org-name",children:"Name"}),e.jsx(je,{id:"org-name",value:W,onChange:c=>{Y(c.target.value),q||I(Re(c.target.value))},placeholder:"e.g. My Team",disabled:f})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"org-slug",children:"Slug"}),e.jsx(je,{id:"org-slug",value:Q,onChange:c=>{_(!0),I(c.target.value)},placeholder:"e.g. my-team",disabled:f}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Changing the slug rewrites this workspace's URL. Existing links to"," ",e.jsxs("span",{className:"font-mono",children:["/",n.slug]})," redirect for a grace period."]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Workspace visibility"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Choose who can browse this workspace and its public pages."})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("button",{type:"button",onClick:()=>P("private"),disabled:f,className:`flex items-start gap-3 rounded-lg border p-3 text-left transition-colors ${A==="private"?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[e.jsx(lt,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Private"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only members can access this workspace."})]})]}),e.jsxs("button",{type:"button",onClick:()=>P("public"),disabled:f,className:`flex items-start gap-3 rounded-lg border p-3 text-left transition-colors ${A==="public"?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[e.jsx(dt,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Public"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Anyone can browse public pages for this workspace."})]})]})]}),B&&e.jsxs("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm",children:[e.jsx("p",{className:"text-foreground",children:"Make this workspace public? Catalog-style content may become visible outside the membership."}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(N,{type:"button",size:"sm",onClick:()=>{O("public"),$(!1)},disabled:f,children:"Confirm public"}),e.jsx(N,{type:"button",size:"sm",variant:"ghost",onClick:()=>$(!1),disabled:f,children:"Cancel"})]})]})]}),K&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:K}),e.jsx(ut,{visible:C.hasConflict,onReload:C.reset}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{variant:"outline",onClick:()=>void m({to:`/${t}`}),disabled:f,children:"Cancel"}),e.jsxs(N,{onClick:k,disabled:f||!C.canSubmit,children:[D?e.jsx(Ne,{size:"lg",className:"mr-1.5"}):null,D?"Saving...":"Save changes"]})]}),e.jsxs("section",{id:"policies",className:"scroll-mt-6 space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Policies"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Control connector actions across the organization. Changes to existing rules save automatically."})]}),e.jsx(Nt,{owner:t,connector:i,connection:a,agent:o},`${t}:${o??""}:${i??""}:${a??""}`)]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Agent write defaults"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the defaults agents inherit for entities and agents. Changes save automatically; agents can only tighten them."})]}),e.jsx(ft,{owner:t,variant:"org-floor"})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Schema governance"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Control structural changes by agents and connected AI clients. Changes save automatically."})]}),e.jsx(zt,{owner:t})]}),e.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:n.is_personal?"Personal workspace":"Delete this organization"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n.is_personal?"Your personal workspace can't be deleted — your devices and personal connections are bound to it.":"Permanently removes the organization and all members' workspace access. This cannot be undone."}),!n.is_personal&&e.jsx("div",{className:"mt-3",children:ee?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(N,{variant:"destructive",size:"sm",onClick:H,disabled:f,children:[E?e.jsx(Ne,{className:"mr-1.5"}):null,"Confirm delete"]}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>T(!1),disabled:f,children:"Cancel"})]}):e.jsxs(N,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>T(!0),disabled:f,children:[e.jsx(mt,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete organization"]})})]})]})}function Rt(){const{owner:t}=ke.useParams(),i=ke.useSearch(),{data:a}=Ie(),o=(a??[]).find(m=>m.slug===t&&m.is_member)?.name;return e.jsxs("div",{className:"mx-auto flex w-full max-w-4xl flex-1 flex-col gap-6 px-4 py-6 lg:px-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xt,{className:"h-7 w-7"}),e.jsx("h1",{className:"text-3xl font-semibold leading-tight",children:"Organization settings"})]}),o?e.jsx("p",{className:"text-base font-medium text-foreground",children:o}):null]}),e.jsx(Pt,{owner:t,...i})]})}export{Rt as component};
2
- //# sourceMappingURL=organization-gxGeDjIV.js.map
1
+ import{$ as pe,r as v,bu as Fe,bv as qe,bw as Be,bx as Ke,by as ye,j as e,bz as Z,B as N,bA as Me,aR as Ue,bB as Ve,bC as He,bD as Ye,bE as Ge,bF as Je,bG as Ze,bH as Xe,bI as be,bJ as X,bK as et,bL as tt,bM as st,bN as de,bO as nt,bP as it,o as at,U as Ie,n as ot,bQ as rt,bR as J,k as ct,z as ve,I as je,bS as lt,bT as dt,bU as ut,a2 as Ne,a$ as mt,E as re,bV as pt,bW as Ce,bX as _e,bY as ht,F as gt,bZ as ke,b_ as xt}from"./index-DYCqXaMf.js";import{P as ue,a as De,A as ft}from"./agent-permissions-matrix-gZWl6mAe.js";import{C as Se,a as Ae,b as we,c as ze}from"./card-yU0TmNRH.js";const Oe=["auto","approval","deny"],yt={matched_rule:"Matching policy rules apply.",default_approval:"No rule matches; approval is required.",unresolved_principal:"The requesting agent or Automation could not be identified.",parent_approval:"Approval is inherited from the parent action.",unavailable_operation:"This action is unavailable on the connection."},Le={read:"Reads",write:"Writes",destructive:"Destructive writes",non_destructive:"Non-destructive writes",unknown:"Unclassified writes"};function me(t){return{operation_key:t.operation_key??null,connector_key:t.connector_key??null,connection_id:t.connection_id??null,operation_category:t.operation_category??null}}const ce=t=>JSON.stringify(me(t)),Pe=t=>({...t,effect:t.effects.execute??"approval"});function F({label:t,value:i,onChange:a,children:o,disabled:m}){return e.jsxs("label",{className:"flex min-w-0 flex-col gap-1 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:t}),e.jsx("select",{"aria-label":t,value:i,onChange:d=>a(d.target.value),disabled:m,className:"h-9 w-full rounded-lg border bg-background px-2 text-foreground",children:o})]})}function bt(t,i){const a=i.connections?.find(o=>o.id===t.connection_id);return t.connection_id?`Connection: ${a?.display_name||a?.connector_key||"Unavailable"} (#${t.connection_id})`:t.connector_key?`Connector: ${i.connectors?.find(o=>o.key===t.connector_key)?.name||t.connector_key}`:"All connectors"}function vt(t,i){return t.operation_key?i.connector_operations.find(a=>a.operation_key===t.operation_key)?.name||t.operation_key:t.operation_category?Le[t.operation_category]:"All actions"}function le(t,i){return`${bt(t,i)} · ${vt(t,i)}`}function $e(t){return t.connection_id?`connection:${t.connection_id}`:t.connector_key?`connector:${t.connector_key}`:"all"}function Ee({catalog:t}){return e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"all",children:"All connectors"}),e.jsx("optgroup",{label:"Connectors",children:t.connectors?.map(i=>e.jsx("option",{value:`connector:${i.key}`,children:i.name},i.key))}),e.jsx("optgroup",{label:"Connections",children:t.connections?.map(i=>e.jsxs("option",{value:`connection:${i.id}`,children:[i.display_name||i.connector_key," (#",i.id,")"]},i.id))})]})}function jt({label:t,ariaLabel:i,disabled:a,onRemove:o}){const[m,d]=v.useState(!1);return m?e.jsxs("div",{className:"flex gap-1",children:[e.jsx(N,{type:"button",variant:"destructive",size:"sm",disabled:a,"aria-label":"Confirm removal",onClick:async()=>{await o()&&d(!1)},children:"Confirm"}),e.jsx(N,{type:"button",variant:"ghost",size:"sm",disabled:a,onClick:()=>d(!1),children:"Cancel"})]}):e.jsx(N,{type:"button",variant:"ghost",size:"sm",disabled:a,"aria-label":i,onClick:()=>d(!0),children:t})}function Nt({owner:t,connector:i,connection:a,agent:o}){const m=pe(),[d,j]=v.useState(o??""),S=Fe(t),r=S.data,u=r?.agents.some(s=>s.id===d)?d:"",n=qe(t,u),g=Be(t,!u),[C,W]=v.useState(a?`connection:${a}`:i?`connector:${i}`:"all"),[Y,Q]=v.useState(C),[I,A]=v.useState(!1),[O,q]=v.useState(""),[_,B]=v.useState("all"),[$,K]=v.useState("approval"),[p,D]=v.useState(!1),[M,E]=v.useState(null),[U,ee]=v.useState(a?String(a):""),[T,G]=v.useState(""),P=r?.connections?.some(s=>String(s.id)===U)?U:"",k=Ke(t,P?Number(P):void 0,T,u||void 0);async function V(s,b){D(!0),E(null);try{if(u){const l={resource_class:"connector_action",...me(s)};b?await Ye(t,u,{...l,effects:{execute:b}}):await Ge(t,u,l)||E("This rule was already removed. The list has been refreshed.")}else{const l=g.data;if(!l)return;const L=l.rules.filter(Qe=>ce(Qe)!==ce(s));b&&L.push({...me(s),effect:b});const oe=await Je(t,{revision:l.revision,rules:L});m.setQueryData(Ze(t),oe)}return await Promise.all(["write-permissions","agent-permissions","available-operations","connector-operations","policy-explanation"].map(l=>m.invalidateQueries({queryKey:[l]}))),s}catch(l){l instanceof ye&&l.status===409?(E("Policies changed in another session. Review the refreshed rules before saving again."),await g.refetch()):E(l instanceof Error?l.message:"Could not save policy.")}finally{D(!1)}}const f=S.error||(u?n.error:g.error);if(f instanceof ye&&f.status===403)return e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Only organization owners and admins can manage policies."});if(f)return e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Could not load policies. ",String(f)]});if(!r||(u?!n.data:!g.data))return e.jsx(Z,{label:"policies",rows:2});const c=s=>s==="all"||r.connectors?.some(b=>`connector:${b.key}`===s)||r.connections?.some(b=>`connection:${b.id}`===s)?s:"all",h=c(C),x=c(Y),w=r.connections?.find(s=>`connection:${s.id}`===x),y=w?.connector_key??(x.startsWith("connector:")?x.slice(10):void 0),R=s=>x==="all"||$e(s)==="all"?!0:s.connection_id?w?s.connection_id===w.id:r.connections?.some(b=>b.id===s.connection_id&&b.connector_key===y):s.connector_key===y;function te(s){return u?s.principal_kind==="agent"&&s.principal_id===u:!s.principal_kind}const z=h.startsWith("connector:")?h.slice(10):h.startsWith("connection:")?r.connections?.find(s=>s.id===Number(h.slice(11)))?.connector_key:void 0,H=r.connector_operations.filter(s=>!z||s.connector_key===z),se=r.connections?.find(s=>s.id===Number(P))?.connector_key,ne=r.connector_operations.filter(s=>s.connector_key===se),ie=u?(n.data?.agent??[]).filter(s=>s.resource_class==="connector_action").map(Pe):g.data?.rules??[],ge=(n.data?.floor??[]).filter(s=>s.resource_class==="connector_action"&&R(s)).map(Pe),We={connector_key:h.startsWith("connector:")?h.slice(10):h==="all"&&_==="specific"?H.find(s=>s.operation_key===O)?.connector_key??null:null,connection_id:h.startsWith("connection:")?Number(h.slice(11)):null,operation_key:_==="specific"?O:null,operation_category:_.startsWith("category:")?_.slice(9):null},ae=ie.filter(R);function xe(){W(x),B("all"),q(""),K("approval"),A(!0)}const fe=(s,b=!1)=>e.jsx("div",{className:"divide-y rounded-lg border",children:s.map(l=>{const L=!b&&te(l);return e.jsxs(De,{controls:e.jsxs(e.Fragment,{children:[e.jsx(ue,{options:Oe,value:l.effect,floor:"auto",compact:!0,disabled:p||!L,ariaLabel:`Policy for ${le(l,r)}`,onChange:oe=>void V(l,oe)}),L&&e.jsx(jt,{label:"Remove",disabled:p,ariaLabel:`Remove rule: ${le(l,r)}`,onRemove:()=>V(l)})]}),children:[e.jsx("p",{className:"text-sm break-words",children:le(l,r)}),!L&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.principal_kind==="agent"&&!l.principal_id?"All agents":"Inherited restriction"})]},JSON.stringify([l.principal_kind,l.principal_id,ce(l)]))})});return e.jsxs("div",{className:"space-y-4",children:[(x!==Y||u!==d)&&e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"The requested scope is unavailable. Showing organization rules; install the connector or choose an available scope."}),e.jsxs("div",{className:"space-y-1 text-sm text-muted-foreground",children:[e.jsx("p",{children:"Auto runs immediately. Ask waits for human approval. Block prevents execution and hides the action from agents. Authentication and guardrails still apply."}),e.jsxs("details",{className:"space-y-2",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-foreground",children:"How rules combine"}),e.jsx("p",{children:"A rule overrides another when it is narrower in target or actions and at least as narrow in the other. When rules are narrower in different ways, or use different categories, the stricter choice wins: Block, then Ask, then Auto. With no matching rule, the result is Ask. Impact categories apply only to writes."}),e.jsx("p",{children:"A connection-wide Auto does not override an organization-wide destructive Block. Add a destructive rule for that connection to make an exception."}),e.jsx("p",{children:"Agents and their Automations can only tighten organization policy. Internal browser steps inherit the parent approval; an explicit browser Block still wins."})]})]}),e.jsxs(F,{label:"Policy owner",value:u,onChange:j,disabled:p,children:[e.jsx("option",{value:"",children:"Organization"}),r.agents.map(s=>e.jsxs("option",{value:s.id,children:["Agent: ",s.name]},s.id))]}),u&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Auto adds no restriction for this agent. It inherits organization policy and cannot bypass Ask or Block."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u?"Without a matching restriction, this agent inherits organization policy.":"Without a matching rule, actions require approval (Ask)."}),e.jsx(F,{label:"Show rules for",value:x,onChange:Q,disabled:p,children:e.jsx(Ee,{catalog:r})}),u&&ge.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Inherited organization rules"}),fe(ge,!0)]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:u?"Saved restrictions":"Saved rules"}),!I&&ae.length>0&&e.jsx(N,{variant:"outline",size:"sm",disabled:p,onClick:xe,children:"Add rule"})]}),I&&e.jsxs("form",{className:"space-y-3 border-t pt-4",onSubmit:s=>{s.preventDefault(),!p&&(_!=="specific"||O)&&V(We,$).then(b=>{b&&(A(!1),Q($e(b)))})},children:[e.jsx("h3",{className:"text-sm font-medium",children:"Add rule"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(F,{label:"Applies to",value:h,onChange:s=>{W(s),B("all"),q("")},disabled:p,children:e.jsx(Ee,{catalog:r})}),e.jsxs(F,{label:"Actions",value:_,onChange:B,disabled:p,children:[e.jsx("option",{value:"all",children:"All actions"}),e.jsx("optgroup",{label:"Categories",children:r.operation_categories?.map(s=>e.jsx("option",{value:`category:${s}`,children:Le[s]},s))}),e.jsx("option",{value:"specific",children:"Specific action"})]})]}),_==="specific"&&e.jsxs(F,{label:"Specific action",value:O,onChange:q,disabled:p,children:[e.jsx("option",{value:"",children:"Choose action"}),H.map(s=>e.jsxs("option",{value:s.operation_key,children:[s.connector_name,": ",s.name]},s.operation_key))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx(ue,{options:Oe,value:$,floor:"auto",compact:!0,disabled:p,ariaLabel:"New rule decision",onChange:K}),e.jsx(Me,{onCancel:()=>A(!1),cancelDisabled:p,children:e.jsx(N,{type:"submit",disabled:p||_==="specific"&&!O,children:p?"Saving…":"Save rule"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saving an existing scope replaces its decision. Removing a rule reveals the next matching rule."})]}),ae.length?fe(ae):!I&&e.jsx(Ue,{icon:Ve,title:"No saved rules in this scope",description:"Add a rule for all actions, a category, or a specific action.",actionLabel:"Add rule",onAction:xe})]}),M&&e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:M}),e.jsxs("details",{className:"space-y-3 border-t pt-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"Check an action"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs(F,{label:"Check connection",value:P,onChange:s=>{ee(s),G("")},children:[e.jsx("option",{value:"",children:"Choose connection"}),r.connections?.map(s=>e.jsxs("option",{value:String(s.id),children:[s.display_name||s.connector_key," (#",s.id,")"]},s.id))]}),e.jsxs(F,{label:"Check action",value:T,onChange:G,disabled:!P,children:[e.jsx("option",{value:"",children:"Choose action"}),ne.map(s=>e.jsx("option",{value:s.operation_key.slice(s.connector_key.length+2),children:s.name},s.operation_key))]})]}),k.error?e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Could not check policy. ",String(k.error)]}):e.jsx("p",{"aria-live":"polite",className:"text-sm",children:T?k.isPending?"Checking…":k.data?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:He[k.data.effect]})," ·"," ",yt[k.data.reason]??"The server evaluated this action.",k.data.rule_ids.length>0?` · Rules ${k.data.rule_ids.map(s=>`#${s}`).join(", ")}`:""]}):"":""})]})]})}const Ct=[{action:"create_type",label:"Create entity types",description:"Add a new type and its initial fields."},{action:"update_type",label:"Edit entity types",description:"Change fields, write rules, event kinds, or type metadata."},{action:"delete_type",label:"Delete entity types",description:"Remove an entity-type definition."}],_t=[{action:"create_relationship_type",label:"Create relationship types",description:"Add a new kind of link between entity types."},{action:"update_relationship_type",label:"Edit relationship types",description:"Change a definition, or which types it may connect."},{action:"delete_relationship_type",label:"Delete relationship types",description:"Remove a relationship-type definition."}];function he(t){return t.resource_class==="entity_schema"&&t.principal_kind===null&&t.entity_type_slug===null&&t.operation_key===null&&t.target_agent_id===null}function kt(t){return t.agent.find(he)}function St(t,i){return{...t,agent:[...t.agent.filter(a=>!he(a)),i]}}function At(t){return{...t,agent:t.agent.filter(i=>!he(i))}}function wt({label:t,description:i,action:a,value:o,pending:m,onChange:d}){return e.jsxs(De,{controls:e.jsx(ue,{options:it("entity_schema",a),value:o,floor:"auto",disabled:m,compact:!0,ariaLabel:t,onChange:d}),children:[e.jsx("p",{children:t}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:i})]})}function Te({title:t,actions:i,effects:a,pending:o,onChange:m}){return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:t}),e.jsx("div",{className:"divide-y overflow-hidden rounded-lg border",children:i.map(({action:d,label:j,description:S})=>e.jsx(wt,{action:d,label:j,description:S,value:a[d]??de.entity_schema[d]??"deny",pending:o,onChange:r=>m(d,r)},d))})]})}function zt({owner:t}){const i=pe(),a=Xe(t),o=Fe(t),m=be({mutationFn:n=>et(t,{resource_class:"entity_schema",effects:n}),onSuccess:n=>{i.setQueryData(a,g=>g&&St(g,n)),i.invalidateQueries({queryKey:a})},onError:n=>{X.error(n instanceof Error?n.message:"Failed to save schema policy")}}),d=be({mutationFn:()=>tt(t,{resource_class:"entity_schema"}),onSuccess:()=>{i.setQueryData(a,n=>n&&At(n)),i.invalidateQueries({queryKey:a})},onError:n=>{X.error(n instanceof Error?n.message:"Failed to reset schema policy")}});if(o.isLoading)return e.jsx(Z,{label:"schema policy",variant:"cards",cards:1});if(o.isError||!o.data)return e.jsx(st,{label:"schema policy"});const j=kt(o.data),S=j?.effects??de.entity_schema,r=m.isPending||d.isPending,u=(n,g)=>{m.mutate({...j?.effects??de.entity_schema,[n]:g})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:j?"Custom policy":"Workspace defaults"}),j?e.jsxs(N,{type:"button",variant:"outline",size:"sm",disabled:r,onClick:()=>d.mutate(),children:[e.jsx(nt,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove custom policy"]}):null]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Te,{title:"Entity types",actions:Ct,effects:S,pending:r,onChange:u}),e.jsx(Te,{title:"Relationship types",actions:_t,effects:S,pending:r,onChange:u})]})]})}function Re(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ot(t,i,a){const o=t.split("/");return o[1]===i?(o[1]=a,o.join("/")||"/"):`/${a}`}function Pt({owner:t,connector:i,connection:a,agent:o}){const m=at(),d=pe(),{data:j,error:S}=Ie(),{activeOrg:r,urlOrgSlug:u}=ot(),n=(j??[]).find(c=>c.slug===t&&c.is_member)??null,g=n?.id??t,C=rt(g,{name:n?.name??"",slug:n?.slug??"",visibility:n?.visibility??"private"}),[W,Y]=C.field("name"),[Q,I]=C.field("slug"),[A,O]=C.field("visibility"),[q,_]=J(g,!!n),[B,$]=J(g,!1),[K,p]=J(g,null),[D,M]=v.useState(!1),[E,U]=v.useState(!1),[ee,T]=J(g,!1);if(ct(S)&&j===void 0)return e.jsxs(Se,{role:"alert",children:[e.jsx(Ae,{children:e.jsx(we,{children:"Couldn't load organizations"})}),e.jsx(ze,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Please try again in a moment."})})]});if(j===void 0)return e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsx(Z,{label:"organization",variant:"cards",cards:1}),e.jsx(Z,{label:"visibility",variant:"panel"})]});if(!n)return e.jsxs(Se,{children:[e.jsx(Ae,{children:e.jsx(we,{children:"Organization not found"})}),e.jsx(ze,{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You aren't a member of an organization at"," ",e.jsx("span",{className:"font-mono",children:t}),", or it has been deleted."]})})]});const G=c=>{const h=gt(c);if(h.kind==="cross-host"){window.location.assign(h.href);return}m({to:h.to})},P=c=>{if(c==="public"&&n.visibility!=="public"){$(!0);return}O(c),$(!1)},k=async()=>{if(!C.canSubmit)return;const c=W.trim();if(!c){p("Name is required");return}const h=Q.trim()||Re(c);if(!h){p("Slug is required");return}M(!0),p(null);try{const x=c!==n.name||h!==n.slug,w=A!==n.visibility;let y=n.slug;if(x){const z=await re.update({organizationId:n.id,data:{name:c,slug:h}});if(z.error){p(z.error.message||"Failed to update organization");return}y=z.data?.slug??h}w&&(y=(await pt(y,A)).slug),(x||w)&&(C.accept(C.values,{name:c,slug:y,visibility:A}),await d.invalidateQueries({queryKey:["organizations"]}),X.success("Organization updated"));const R=r?.id===n.id||u===n.slug,te=y!==n.slug;if(R&&te){const z=Ce(),H=_e();if(z===n.slug&&H){const ne=ht(window.location.pathname,n.slug)||"/",ie=`${window.location.protocol}//${y}.${H}${ne}${window.location.search}${window.location.hash}`;window.location.assign(ie);return}const se=Ot(window.location.pathname,n.slug,y);m({to:`${se}${window.location.search}${window.location.hash}`});return}}catch(x){p(x instanceof Error?x.message:"Failed to update organization")}finally{M(!1)}},V=async()=>{U(!0),p(null);try{const c=await re.delete({organizationId:n.id});if(c.error){p(c.error.message||"Failed to delete organization");return}await d.invalidateQueries({queryKey:["organizations"]}),X.success("Organization deleted");const x=(j??[]).filter(y=>y.is_member).find(y=>y.id!==n.id)??null,w=r?.id===n.id||u===n.slug;if(w&&x){await re.setActive({organizationId:x.id}),G(x.slug);return}if(w){const y=Ce(),R=_e();if(y===n.slug&&R){window.location.assign(`${window.location.protocol}//app.${R}/`);return}m({to:"/"});return}m({to:"/"})}catch(c){p(c instanceof Error?c.message:"Failed to delete organization")}finally{U(!1),T(!1)}},f=D||E;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Identity"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"org-name",children:"Name"}),e.jsx(je,{id:"org-name",value:W,onChange:c=>{Y(c.target.value),q||I(Re(c.target.value))},placeholder:"e.g. My Team",disabled:f})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"org-slug",children:"Slug"}),e.jsx(je,{id:"org-slug",value:Q,onChange:c=>{_(!0),I(c.target.value)},placeholder:"e.g. my-team",disabled:f}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Changing the slug rewrites this workspace's URL. Existing links to"," ",e.jsxs("span",{className:"font-mono",children:["/",n.slug]})," redirect for a grace period."]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Workspace visibility"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Choose who can browse this workspace and its public pages."})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("button",{type:"button",onClick:()=>P("private"),disabled:f,className:`flex items-start gap-3 rounded-lg border p-3 text-left transition-colors ${A==="private"?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[e.jsx(lt,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Private"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only members can access this workspace."})]})]}),e.jsxs("button",{type:"button",onClick:()=>P("public"),disabled:f,className:`flex items-start gap-3 rounded-lg border p-3 text-left transition-colors ${A==="public"?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[e.jsx(dt,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Public"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Anyone can browse public pages for this workspace."})]})]})]}),B&&e.jsxs("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm",children:[e.jsx("p",{className:"text-foreground",children:"Make this workspace public? Catalog-style content may become visible outside the membership."}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(N,{type:"button",size:"sm",onClick:()=>{O("public"),$(!1)},disabled:f,children:"Confirm public"}),e.jsx(N,{type:"button",size:"sm",variant:"ghost",onClick:()=>$(!1),disabled:f,children:"Cancel"})]})]})]}),K&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:K}),e.jsx(ut,{visible:C.hasConflict,onReload:C.reset}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{variant:"outline",onClick:()=>void m({to:`/${t}`}),disabled:f,children:"Cancel"}),e.jsxs(N,{onClick:k,disabled:f||!C.canSubmit,children:[D?e.jsx(Ne,{size:"lg",className:"mr-1.5"}):null,D?"Saving...":"Save changes"]})]}),e.jsxs("section",{id:"policies",className:"scroll-mt-6 space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Policies"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Control connector actions across the organization. Changes to existing rules save automatically."})]}),e.jsx(Nt,{owner:t,connector:i,connection:a,agent:o},`${t}:${o??""}:${i??""}:${a??""}`)]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Agent write defaults"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the defaults agents inherit for entities and agents. Changes save automatically; agents can only tighten them."})]}),e.jsx(ft,{owner:t,variant:"org-floor"})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Schema governance"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Control structural changes by agents and connected AI clients. Changes save automatically."})]}),e.jsx(zt,{owner:t})]}),e.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:n.is_personal?"Personal workspace":"Delete this organization"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n.is_personal?"Your personal workspace can't be deleted — your devices and personal connections are bound to it.":"Permanently removes the organization and all members' workspace access. This cannot be undone."}),!n.is_personal&&e.jsx("div",{className:"mt-3",children:ee?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(N,{variant:"destructive",size:"sm",onClick:V,disabled:f,children:[E?e.jsx(Ne,{className:"mr-1.5"}):null,"Confirm delete"]}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>T(!1),disabled:f,children:"Cancel"})]}):e.jsxs(N,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>T(!0),disabled:f,children:[e.jsx(mt,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete organization"]})})]})]})}function Rt(){const{owner:t}=ke.useParams(),i=ke.useSearch(),{data:a}=Ie(),o=(a??[]).find(m=>m.slug===t&&m.is_member)?.name;return e.jsxs("div",{className:"mx-auto flex w-full max-w-4xl flex-1 flex-col gap-6 px-4 pt-2.5 pb-8 lg:px-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xt,{className:"h-7 w-7"}),e.jsx("h1",{className:"text-3xl font-semibold leading-tight",children:"Organization settings"})]}),o?e.jsx("p",{className:"text-base font-medium text-foreground",children:o}):null]}),e.jsx(Pt,{owner:t,...i})]})}export{Rt as component};
2
+ //# sourceMappingURL=organization-DTFoYP4V.js.map
@@ -0,0 +1,2 @@
1
+ import{j3 as z,j4 as M,r as h,h3 as B,u as L,j as t,di as F,av as K,d7 as H,S as g,iv as V,B as j,j5 as U,j6 as N,j7 as q,j8 as C,j9 as R,ja as G,cP as W,h as S,ao as $,cs as T,a2 as I,ai as Q,jb as Z,g as J,jc as X,f as Y,dV as ee,jd as te,bd as se,je as ne,e3 as re,cz as oe,jf as ie,e7 as ae,b9 as ce}from"./index-DYCqXaMf.js";import{u as de,A as le}from"./automation-detail-content-BMLL4lxO.js";import{A as ue}from"./agent-loading-shells-De_2d8Lr.js";import{s as pe,h as me,R as xe,A as he}from"./agent-thread-Buz3naVF.js";import{C as fe,b as ge,A as je}from"./connection-feed-detail-DWM9lTao.js";import{f as ye}from"./connector-scope-lists-OYDOydtz.js";import{a as ve}from"./connections-browser-CEwYrYqt.js";import{S as Ne}from"./source-record-panels-Cg249m1S.js";import{E as O,L as we,l as ke,d as be}from"./events-feed-DsrkV2ix.js";import{E as Ae}from"./event-detail-D4YZRtrA.js";import{R as Ce}from"./record-field-peek-BBZcRuGT.js";import{a as Se}from"./view-param-filters-DMSqkN2J.js";import"./create-automation-form-9T5WnoUs.js";import"./cronstrue-BWFEyy_P.js";import"./entity-options-DHdMC1Lx.js";import"./connection-label-BobuYiAG.js";import"./model-selector-TQcA93xm.js";import"./skill-editor-D_W3QlRz.js";import"./code-editor-U54Gwjit.js";import"./index-CDz3-ieP.js";import"./index-Vcq4gwWv.js";import"./use-mention-search-BYbFvHbJ.js";import"./proposal-review-shell-DsNiavG_.js";import"./json-diff-DFvYINBT.js";import"./deployments-wG_8QzOF.js";import"./app-bridge-BCm4muqj.js";import"./runs-table-D_8QlCCN.js";import"./conversations-table-BSznfdYt.js";import"./clients-L4K1UT8c.js";import"./schema-value-normalization-CylKX3PK.js";import"./card-yU0TmNRH.js";import"./record-session-BizRugWs.js";import"./filter-editors-B1_QUpg_.js";const E=Symbol("trusted-automation-interaction");function Ie(e){return Object.defineProperty(e,E,{value:!0}),e}function Pe(e){return{title:`${e} items waiting for you`,icon:"entity",impact:{level:"normal"},tone:"default",blocks:[{type:"text",value:"Review the individual proposals below, or decide the whole run at once.",muted:!0}],actions:[{id:"approve-all",label:"Approve all",variant:"primary",icon:"check",confirm:!0,confirmPrompt:`Approve all ${e} proposals?`,tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved all ${e} proposals.`},{id:"reject-all",label:"Reject all",variant:"outline",icon:"x",confirm:!0,confirmPrompt:`Reject all ${e} proposals?`,tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected all ${e} proposals.`}]}}const _e=new Set(["automation-approval-batch"]);function Le(e){return new Promise(s=>{e({onSettled:(o,n)=>s(!!n)})})}function Re(){const e=z(),s=M();return h.useMemo(()=>({toolNames:_e,resolve:(o,n)=>{if(!n||typeof n!="object"||n[E]!==!0)return null;const r=n;if(o==="automation-approval-batch"){const i=typeof r.runId=="number"&&Number.isSafeInteger(r.runId)&&r.runId>0?r.runId:null,a=typeof r.count=="number"&&Number.isSafeInteger(r.count)&&r.count>1?r.count:null,c=Array.isArray(r.runIds)?r.runIds.filter(d=>typeof d=="number"&&Number.isSafeInteger(d)&&d>0):[];return i===null||a===null||c.length!==a||new Set(c).size!==a?null:{view:Pe(a),handlers:{manage_operations:d=>d.action!=="approve"&&d.action!=="reject"?Promise.resolve(!0):Le(p=>d.action==="approve"?e.mutate({run_id:i,run_ids:c},p):s.mutate({run_id:i,run_ids:c},p))}}}return null}}),[e,s])}function $e(e){const s=[];return e.forEach((o,n)=>{s.push({id:`sep:${o.runId}`,role:"system",parts:[{type:"text",text:Te(o,n)}],createdAt:o.completedAt?new Date(o.completedAt).getTime():void 0});for(const r of o.messages)s.push({...r,id:`r${o.runId}:${r.id}`})}),s}function Te(e,s){const o=(e.pendingActionCount??0)>0?`Waiting for you (${e.pendingActionCount})`:e.status==="completed"?"Completed":e.status??"Completed",n=(e.autoAppliedCount??0)>0?` · ${e.autoAppliedCount} applied automatically`:"",r=e.completedAt?new Date(e.completedAt).toLocaleString():null;return r?`Run ${s+1} · ${o}${n} · ${r}`:`Run ${s+1} · ${o}${n}`}const Oe=/(?:^|\n)Run this Automation now/;function Ee(e){return e.role==="user"&&e.parts.some(s=>s.type==="text"&&Oe.test(s.text))}function De(e){return`history-interaction:${e.runId}:${e.eventId??"error"}`}function ze({agentId:e,automationId:s,ownerSlug:o,runId:n}){const{data:r,isLoading:i}=B(e,s,{orgSlug:o,...n!=null?{runId:n}:{}}),a=Re(),c=L(),d=h.useCallback(l=>{c?.open({href:`/${o}/automations/${s}?run_id=${l}`,title:`Automation run #${l}`,runId:l})},[c,o,s]),p=h.useMemo(()=>{const l=r?.runs??[],y=(n!=null?l.filter(u=>u.runId===n):l).slice().reverse();return $e(y.map(u=>{const x=u.messages.map(m=>pe(m,{showToolCalls:!0})).filter(m=>m!==null&&!Ee(m));u.task?.trim()&&x.unshift({id:"task",role:"user",parts:[{type:"text",text:u.task.trim()}]});const v=u.actions??[],k=v.filter(m=>m.status==="pending");if(k.length>1){const m=k.map(f=>f.runId).sort((f,D)=>f-D);x.push({id:"approval-batch",role:"assistant",parts:[{type:"tool-call",toolCallId:`approval-batch-${u.runId}`,toolName:"automation-approval-batch",args:Ie({runId:u.runId,count:k.length,runIds:m})}]})}for(const m of v){const f=me([m],{workspaceSlug:o,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin});f&&x.push({...f,id:De(m)})}return{runId:u.runId,completedAt:u.completedAt,status:u.status,pendingActionCount:u.pendingActionCount,autoAppliedCount:u.autoAppliedCount,messages:x}}))},[e,r,o,n]);return i?t.jsx(ue,{readOnly:!0}):p.length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No run transcripts yet. Recent runs will show here when the Automation fires (failed runs appear with their prompt even without a full transcript)."}):t.jsx("div",{className:"flex h-[calc(100dvh-12rem)] min-h-[24rem] min-w-0 flex-1 flex-col",children:t.jsx(xe,{messages:p,workspaceSlug:o,children:t.jsx(he,{readOnly:!0,readerPositionMode:"runs",interactionExtension:a,onRunSelect:n==null&&c?d:void 0})})})}function Me(e){if(!e||typeof e!="object")return[];const s=e.properties;if(!s)return[];const o=Array.isArray(e.required)?new Set(e.required.map(String)):new Set;return Object.entries(s).map(([n,r])=>({name:n,type:String(r.type??"any"),required:o.has(n),description:typeof r.description=="string"?r.description:void 0}))}function Be({fields:e}){return e.length===0?t.jsx("p",{className:"text-xs text-muted-foreground",children:"No fields."}):t.jsx("ul",{className:"space-y-2",children:e.map(s=>t.jsxs("li",{className:"space-y-0.5",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2",children:[t.jsx("code",{className:"text-xs font-medium text-foreground",children:s.name}),t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/70",children:s.type}),s.required?t.jsx("span",{className:"text-[10px] font-medium text-amber-600 dark:text-amber-400",children:"required"}):null]}),s.description?t.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}):null]},s.name))})}function w({item:e,hideHeading:s=!1}){const o=e.schemaSections;return o?t.jsxs("article",{className:s?"space-y-4":"space-y-4 px-5 py-5",children:[!s&&t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(F,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),t.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[t.jsx("h2",{className:"text-base font-medium text-foreground",children:e.title}),o.description?t.jsx("p",{className:"text-xs text-muted-foreground",children:o.description}):null]})]}),o.sections.map(n=>{const r=Me(n.schema);return t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:n.title}),n.description?t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:n.description}):null]}),t.jsx(Be,{fields:r})]},n.title)})]}):null}function Fe({panel:e}){const s=K(e.organizationId),o=e.section==="connections"||!!e.connectionId,n=H(e.organizationId,{connectorKey:e.connectorKey,connectionIds:e.connectionId?[e.connectionId]:void 0,enabled:o}),r=s.data?.find(a=>a.key===e.connectorKey),i=n.data?.find(a=>a.id===e.connectionId&&a.connector_key===e.connectorKey);return s.isLoading||o&&n.isLoading?t.jsx("div",{className:"p-5",children:t.jsx(g,{className:"h-28 w-full"})}):s.isError||o&&n.isError?t.jsx("p",{role:"alert",className:"p-5 text-sm",children:"Could not load this connector. Close the pane and try again."}):e.connectionId&&!i||!r&&!i&&e.section!=="connections"?t.jsx("p",{className:"p-5 text-sm",children:"This connection is no longer available."}):t.jsx("div",{className:"p-5",children:e.section==="connections"?t.jsx(ve,{connections:n.data??[],connector:r,connectorKey:e.connectorKey,ownerSlug:e.ownerSlug}):i?t.jsx(Ve,{connection:i,connector:r,panel:e}):r?e.section==="feeds"?t.jsx(Ke,{connector:r}):r.installed===!1?t.jsx(He,{connector:r,ownerSlug:e.ownerSlug}):t.jsx(qe,{connector:r,ownerSlug:e.ownerSlug}):null},`${e.connectorKey}:${e.connectionId??"connector"}:${e.section}`)}function Ke({connector:e}){const s=Object.entries(e.feeds_schema??{}).map(([o,n])=>{const r=n;return{id:o,name:r.name??o,description:r.description,feed:r}});return t.jsx(N,{entries:s,label:"feed types",renderDetail:({name:o,feed:n})=>t.jsx(w,{item:{href:"",title:o,schemaSections:q(n)},hideHeading:!0})})}function He({connector:e,ownerSlug:s}){const o=Object.entries(e.actions_schema??{}).map(([n,r])=>{const i=r;return{id:n,name:i.name??n,description:i.description,action:i}});return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Policy depends on connection."," ",t.jsx(C,{ownerSlug:s,connectorKey:e.key})]}),t.jsx(N,{entries:o,label:"actions",renderDetail:({name:n,action:r})=>t.jsx(w,{hideHeading:!0,item:{href:"",title:n,schemaSections:R(r)}})})]})}function Ve({connection:e,connector:s,panel:o}){const[n,r]=h.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsx("div",{hidden:n,children:o.section==="feeds"?t.jsx(Ue,{connection:e,connector:s,ownerSlug:o.ownerSlug}):t.jsx(V,{connection:e,ownerSlug:o.ownerSlug,inPeek:!0,onReviewPermissions:s?()=>r(!0):void 0})}),n&&s&&t.jsxs("div",{className:"space-y-4",children:[t.jsx(j,{variant:"ghost",size:"sm",onClick:()=>r(!1),children:"Back to actions"}),t.jsx("h2",{className:"text-base font-semibold",children:"Provider permissions"}),t.jsx(U,{connection:e,connectorDef:s})]})]})}function Ue({connection:e,connector:s,ownerSlug:o}){const{data:n=[],isLoading:r,isError:i}=W(e.id),[a,c]=h.useState(!1),d=e.facets?.chat??!1;if(r)return t.jsx(g,{className:"h-28 w-full"});if(i)return t.jsx("p",{role:"alert",children:"Could not load sources. Close the pane and try again."});const p=n.map(l=>({id:String(l.id),name:l.display_name||l.feed_key,status:ye(l)??(l.operations.includes("sync")?"Sync enabled":"Live access"),feed:l}));return t.jsxs(t.Fragment,{children:[t.jsx("div",{hidden:a,children:t.jsx(N,{entries:p,label:d?"channels":"feeds",action:Object.keys(s?.feeds_schema??{}).length>0?t.jsx(j,{size:"sm",variant:"outline",onClick:()=>c(!0),children:d?"Add channel":"Add feed"}):void 0,renderDetail:({feed:l})=>l.store==="channel_messages"?t.jsx(fe,{feed:l,hideHeader:!0}):t.jsx(ge,{feed:l,connectorDef:s,ownerSlug:o})})}),a&&s&&t.jsxs("div",{className:"space-y-4",children:[t.jsx("h2",{className:"text-base font-semibold",children:d?"Add channel":"Add feed"}),t.jsx(je,{organizationId:e.organization_id,connections:[e],connectorDefinitions:[s],onClose:()=>c(!1)})]})]})}function qe({connector:e,ownerSlug:s}){const{data:o=[],isLoading:n,isError:r}=G(e.key);if(n)return t.jsx(g,{className:"h-28 w-full"});if(r)return t.jsx("p",{role:"alert",children:"Could not load actions. Close the pane and try again."});const i=e.actions_schema??{},a=o.map(c=>({id:c.operation_key,name:c.name??c.operation_key,description:c.description,operation:c}));return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Policy depends on connection. Click an action to inspect its inputs."," ",t.jsx(C,{ownerSlug:s,connectorKey:e.key})]}),t.jsx(N,{entries:a,label:"actions",renderControl:()=>t.jsx(C,{ownerSlug:s,connectorKey:e.key}),renderDetail:({operation:c,name:d})=>i[c.operation_key]?t.jsx(w,{hideHeading:!0,item:{href:"",title:d,schemaSections:R(i[c.operation_key])}}):t.jsx("p",{className:"text-sm text-muted-foreground",children:"No input fields."})})]})}function Ge({owner:e,path:s}){const{data:o,isLoading:n}=S(e,{slug:e}),r=o?.workspace,i=r?.type==="organization"?r.id:null,a=i?{slug:e}:void 0,{data:c,isLoading:d}=$(`/${e}/${T(s)}`,a),p=c?.entity,l=p?.id;return n||d?t.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[t.jsx(I,{className:"mr-2"})," Loading…"]}):i?l==null?t.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't find this record. It may have been deleted, or it may live in a workspace you can't access."}):p?.is_derived?t.jsx(Ne,{record:{type:p.entity_type,key:p.slug},orgContext:a}):t.jsx("div",{className:"px-4 py-4",children:t.jsx(O,{organizationId:i,ownerSlug:e,entityId:l,filters:{sortBy:"date",sortOrder:"desc"},emptyState:t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing has happened to this record yet."})})}):t.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."})}function We({owner:e,eventId:s,viewKey:o}){const n=L(),r=(i,a)=>t.jsx(Ae,{owner:a,organizationId:i,eventId:s,viewKey:o,dense:!0,onSelectView:n?c=>n.retarget(c):void 0},`${a}/${s}/${o??""}`);return t.jsx("div",{className:"px-4 py-4",children:e==="me"?r(null,e):t.jsx(Q,{owner:e,children:({organizationId:i,ownerSlug:a})=>i?r(i,a):t.jsx("div",{className:"h-40 animate-pulse rounded-md bg-muted/40"})})})}function b({owner:e,runId:s,runIds:o,contentIds:n}){const{data:r,isLoading:i}=S(e==="me"?null:e,{slug:e}),a=r?.workspace,c=e!=="me"&&a?.type==="organization"?a.id:null,d=h.useMemo(()=>{if(e==="me")return n?.length?{contentIds:n,sortBy:"date",sortOrder:"desc"}:void 0;const l=o??(s!=null?[s]:void 0);if(!(!l?.length&&!n?.length))return{...l?.length?{runIds:l}:{},...n?.length?{contentIds:n}:{}}},[e,n,s,o]),p=d!=null;return e!=="me"&&i?t.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[t.jsx(I,{className:"mr-2"})," Loading…"]}):e!=="me"&&c==null?t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."}):p?t.jsx("div",{className:"px-4 py-4",children:t.jsx(O,{presentation:"detail",organizationId:c,ownerSlug:e,filters:d,emptyState:t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"No matching events yet."})})}):t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing to preview."})}const A=25;function Qe({target:e}){const[s,o]=h.useState(0),{data:n,isLoading:r,isError:i,refetch:a}=Z(e.entityId,e.orgContext,{relationshipType:e.relationshipType,limit:A,offset:s}),c=n?.total??0;return t.jsxs("div",{className:"space-y-3 px-5 py-4",children:[t.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.label," · ",e.entityName,n?` · ${c} current ${c===1?"link":"links"}`:""]}),r?t.jsxs("div",{className:"space-y-2",children:[t.jsx(g,{className:"h-6 w-full"}),t.jsx(g,{className:"h-6 w-full"})]}):i||!n?t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Could not load these links."," ",t.jsx("button",{type:"button",className:"underline",onClick:()=>void a(),children:"Retry"})]}):n.rows.length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No links on this page."}):t.jsx("ul",{className:"divide-y divide-border",children:n.rows.map(d=>t.jsxs("li",{className:"flex items-center justify-between gap-3 py-1.5",children:[t.jsx(we,{row:d,entityId:e.entityId,ownerSlug:e.ownerSlug,orgContext:e.orgContext}),t.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ke(d,e.entityId).type})]},d.id))}),n&&(s>0||n.hasMore)?t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(j,{type:"button",variant:"outline",size:"sm",disabled:s===0,onClick:()=>o(Math.max(0,s-A)),children:"Previous"}),t.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground",children:[s+1,"–",s+n.rows.length," of ",c]}),t.jsx(j,{type:"button",variant:"outline",size:"sm",disabled:!n.hasMore,onClick:()=>o(s+A),children:"Next"})]}):null]})}function Ze({owner:e,path:s,viewKey:o}){const[n,r]=h.useState({}),{data:i,isLoading:a}=S(e,{slug:e}),c=i?.workspace,d=c?.type==="organization"?c.id:null,p=d?{slug:e,organizationId:d}:void 0,{data:l,isLoading:P}=$(`/${e}/${T(s)}`,p),y=J(p??{slug:e}),u=l?.entity;if(a||P||y.isLoading)return t.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[t.jsx(I,{className:"mr-2"})," Loading…"]});const x=u?X(y.data??[],{type:u.entity_type,id:u.id}).find(v=>v.key===o):void 0;return!d||!u||!x?t.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"This view isn't attached to this record any more."}):t.jsx("div",{className:"px-4 py-4",children:t.jsx(Se,{orgSlug:e,viewKey:x.key,scope:{type:u.entity_type,entity:u.is_derived?u.slug:u.id},params:n,onParamsChange:r,contentHash:x.content_hash,title:x.name,minHeight:320})})}function Rt({item:e}){if(e.connectorPanel)return t.jsx(Fe,{panel:e.connectorPanel});if(e.schemaSections)return t.jsx(w,{item:e});if(e.recordField)return t.jsx(Ce,{target:e.recordField});if(e.recordPeer)return t.jsx(be,{target:e.recordPeer});if(e.recordLinks)return t.jsx(Qe,{target:e.recordLinks});if(typeof e.browserUrl=="string"&&e.browserUrl.length>0)return t.jsx(_,{item:e});const s=e.href?Y(e.href):null;return s?s.kind==="memory"?"runId"in s?t.jsx(b,{owner:s.owner,runId:s.runId}):"runIds"in s?t.jsx(b,{owner:s.owner,runIds:s.runIds}):t.jsx(b,{owner:s.owner,contentIds:s.contentIds}):s.kind==="entity"?t.jsx(Ge,{owner:s.owner,path:s.path}):s.kind==="record-view"?t.jsx(Ze,{owner:s.owner,path:s.path,viewKey:s.viewKey}):s.kind==="event"?t.jsx(We,{owner:s.owner,eventId:s.eventId,viewKey:s.viewKey}):e.runId?t.jsx(Je,{owner:s.owner,automationId:s.automationId,runId:e.runId}):t.jsx(Xe,{owner:s.owner,automationId:s.automationId,initialView:s.view??"activity",runId:s.runId}):t.jsx(_,{item:e})}function _({item:e}){const s=e.body,o=e.notificationType??"generic",n=e.createdAt,r=e.browserUrl??null,i=e.browserHandoff??null;return t.jsxs("article",{className:"space-y-4 px-5 py-5",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(ee,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-0.5 text-xs text-muted-foreground",children:[t.jsx("span",{children:te(o)}),n?t.jsx("span",{children:se(n)}):null]})]}),s?t.jsx("div",{className:"text-sm leading-6 text-foreground/90",children:t.jsx(ne,{text:s,linkPolicy:o==="action_approval_needed"?"app-links":"strip"})}):t.jsx("p",{className:"text-sm text-muted-foreground",children:"No additional details were provided."}),e.owner&&e.sourceAttribution?t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground/80",children:"Generated from"}),t.jsx(re,{owner:e.owner,source:e.sourceAttribution,className:"text-xs"})]}):null,r?t.jsx("div",{className:"space-y-2",children:i?.state==="expired"?t.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:i.error_message??"This draft expired before the page was opened."}):i?.state==="completed"||i?.state==="preparing"?t.jsx("p",{className:"text-sm text-muted-foreground",children:i.state==="preparing"?"Preparing draft — keep your browser tab open.":"Draft prepared — review and post in your browser."}):t.jsxs(j,{type:"button",size:"sm",className:"h-8 text-sm",onClick:()=>{ie(r)},children:[t.jsx(oe,{className:"mr-1.5 h-3.5 w-3.5"}),"Open post"]})}):null]})}function Je({owner:e,automationId:s,runId:o}){const{organizationId:n}=de(e),r=ae(s,void 0,n),i=r.data?.automation?.managed_agent_id??null;return i?t.jsx(ze,{agentId:i,automationId:s,ownerSlug:e,runId:o}):r.isLoading?t.jsx(g,{className:"h-24 w-full rounded-lg"}):t.jsx("p",{className:"text-sm text-muted-foreground",children:"This run has no agent transcript."})}function Xe({owner:e,automationId:s,initialView:o,runId:n}){const[r,i]=h.useState(o),a=r==="definition";return t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"flex justify-end",children:t.jsx(j,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1.5 text-muted-foreground hover:text-foreground",onClick:()=>i(a?"activity":"definition"),children:a?"Done":t.jsxs(t.Fragment,{children:[t.jsx(ce,{className:"h-3.5 w-3.5"}),"Edit"]})})}),t.jsx(le,{owner:e,agentId:null,automationId:s,view:r,runId:n,onDone:()=>i("activity")})]})}export{Rt as PeekPaneContent};
2
+ //# sourceMappingURL=peek-pane-content-DF5iGC3c.js.map
@@ -1,2 +1,2 @@
1
- import{k as i,eq as r,j as e,ij as m}from"./index-Cr5hwh-C.js";import{A as c}from"./agent-permissions-matrix-BOo_4r_4.js";import{A as l}from"./agent-subpage-shell-D92imvSt.js";function x({owner:s,agentId:t}){const{orgContext:n}=i(),{isAdmin:a,isLoading:o}=r(n.organizationId);return e.jsx(l,{owner:s,agentId:t,backLabel:"Permissions",backTo:"/$owner/agents/$agentId/permissions",children:a?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"Control which data, agent settings, and connector actions this agent may use automatically, with approval, or not at all."}),e.jsx("div",{className:"overflow-x-auto",children:e.jsx(c,{owner:s,agentId:t})})]}):o?null:e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"Only organization admins can view or change agent permissions."})})}function p(){const{owner:s,agentId:t}=m.useParams();return e.jsx(x,{owner:s,agentId:t})}export{p as component};
2
- //# sourceMappingURL=permissions-aPHaKLec.js.map
1
+ import{n as i,e_ as r,j as e,iM as m}from"./index-DYCqXaMf.js";import{A as c}from"./agent-permissions-matrix-gZWl6mAe.js";import{A as l}from"./agent-subpage-shell-BBJoyTuC.js";function x({owner:s,agentId:t}){const{orgContext:n}=i(),{isAdmin:a,isLoading:o}=r(n.organizationId);return e.jsx(l,{owner:s,agentId:t,backLabel:"Permissions",backTo:"/$owner/agents/$agentId/permissions",children:a?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"Control which data, agent settings, and connector actions this agent may use automatically, with approval, or not at all."}),e.jsx("div",{className:"overflow-x-auto",children:e.jsx(c,{owner:s,agentId:t})})]}):o?null:e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"Only organization admins can view or change agent permissions."})})}function p(){const{owner:s,agentId:t}=m.useParams();return e.jsx(x,{owner:s,agentId:t})}export{p as component};
2
+ //# sourceMappingURL=permissions-C_auqxfP.js.map
@@ -0,0 +1,2 @@
1
+ import{h4 as R,h5 as f,gw as y,gx as N,r as k,j as e,b8 as C,B as d,z as P,fN as A}from"./index-DYCqXaMf.js";function T({resource:p,runId:t,children:h,onDone:l}){const c=!!t,{data:a,isLoading:E,isError:u,refetch:v}=R(p,c?t:void 0),s=f({isReview:c,isError:u,status:a?.status}),x=a?.status==="pending"?a.proposal:null,n=y(),i=N(),[g,j]=k.useState(""),o=n.isPending||i.isPending,m=s==="active"||s==="loading"||s==="error",b=()=>{t&&n.mutate({run_id:t},{onSuccess:()=>l?.()})},w=()=>{if(!t)return;const r=g.trim();i.mutate({run_id:t,...r?{reason:r}:{}},{onSuccess:()=>l?.()})};return e.jsxs("div",{className:"grid content-start gap-4",children:[s==="active"?e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-950 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("p",{children:["Review the change the builder agent proposed. The values below show the proposed change — ",e.jsx("strong",{children:"Approve"})," to apply, or"," ",e.jsx("strong",{children:"Reject"}),"."]})]})}):null,s==="gone"?e.jsx("div",{className:"rounded-lg border bg-muted/30 p-3 text-sm text-muted-foreground",children:"This change is no longer pending (it may have been approved or rejected already)."}):null,s==="error"?e.jsx("div",{className:"rounded-lg border border-destructive/40 bg-destructive/5 p-3 text-sm",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("p",{className:"text-destructive",children:"Couldn't load the proposed change to review. Editing is disabled until it loads — retry, or reopen the link."}),e.jsx(d,{type:"button",variant:"outline",size:"sm",onClick:()=>void v(),children:"Retry"})]})}):null,h({reviewMode:s,proposal:x,controlsDisabled:m}),s==="active"?e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(P,{htmlFor:"review-reject-reason",children:"Reason (optional)"}),e.jsx(A,{id:"review-reject-reason",rows:2,value:g,onChange:r=>j(r.target.value),placeholder:"Why you're rejecting — shared back to the requester.",disabled:o})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:justify-end",children:[e.jsx(d,{type:"button",variant:"outline",onClick:w,disabled:o,children:i.isPending?"Rejecting...":"Reject"}),e.jsx(d,{type:"button",onClick:b,disabled:o,children:n.isPending?"Approving...":"Approve"})]})]}):null]})}export{T as P};
2
+ //# sourceMappingURL=proposal-review-shell-DsNiavG_.js.map
@@ -0,0 +1,2 @@
1
+ import{r as e,dn as l}from"./index-DYCqXaMf.js";function a(){return e.useEffect(()=>{l()},[]),null}export{a as P};
2
+ //# sourceMappingURL=public-shell-ready-B2NUI89V.js.map
@@ -1,2 +1,2 @@
1
- import{af as t,j as e,ag as o,ah as d,ai as m,aj as h}from"./index-Cr5hwh-C.js";function f({section:s,icon:a,title:i,description:n,action:l}){const c=s?t[s]:null,x=s!==void 0?t[s].icon:a,r=i??c?.label??"";return e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{className:"h-7 w-7 shrink-0","aria-hidden":!0}),e.jsx("h1",{className:"font-display text-3xl font-semibold leading-tight",children:r})]}),n?e.jsx("p",{className:"text-sm text-muted-foreground",children:n}):null]}),l?e.jsx("div",{className:"shrink-0",children:l}):null]})}function u(){const{owner:s}=o.useParams();return e.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-3 px-4 pt-4 pb-8 lg:px-6",children:e.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:e.jsx(d,{owner:s,children:a=>e.jsxs("div",{className:"mx-auto flex min-h-0 w-full min-w-0 max-w-3xl flex-1 flex-col gap-4",children:[e.jsx(f,{icon:m,title:"Recent",description:"Chats, connected apps, and Automations you used last."}),e.jsx(h,{owner:a.ownerSlug,tone:"page",empty:"message"})]})})})})}export{u as component};
2
- //# sourceMappingURL=recent-D-65Pgu-.js.map
1
+ import{ag as t,j as e,ah as o,ai as d,aj as m,ak as h}from"./index-DYCqXaMf.js";function p({section:s,icon:a,title:i,description:n,action:l}){const c=s?t[s]:null,x=s!==void 0?t[s].icon:a,r=i??c?.label??"";return e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{className:"h-7 w-7 shrink-0","aria-hidden":!0}),e.jsx("h1",{className:"font-display text-3xl font-semibold leading-tight",children:r})]}),n?e.jsx("p",{className:"text-sm text-muted-foreground",children:n}):null]}),l?e.jsx("div",{className:"shrink-0",children:l}):null]})}function u(){const{owner:s}=o.useParams();return e.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-3 px-4 pt-2.5 pb-8 lg:px-6",children:e.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:e.jsx(d,{owner:s,children:a=>e.jsxs("div",{className:"mx-auto flex min-h-0 w-full min-w-0 max-w-3xl flex-1 flex-col gap-4",children:[e.jsx(p,{icon:m,title:"Recent",description:"Chats, connected apps, and Automations you used last."}),e.jsx(h,{owner:a.ownerSlug,tone:"page",empty:"message"})]})})})})}export{u as component};
2
+ //# sourceMappingURL=recent-3d99S2IE.js.map
@@ -0,0 +1,2 @@
1
+ import{au as gn,j as n,r as b,o as z,q as ce,cx as xn,ch as Tt,cy as At,L as Ie,cz as bn,cA as jn,n as kn,cB as Et,cC as Sn,b_ as Nn,cD as Cn,aj as _n,cE as Ft,cF as A,cG as In,bn as Tn,cH as An,cI as En,bo as Fn,cJ as On,cK as ae,ct as Rn,cL as Ot,cM as wn,ao as Mn,cN as Ln,a_ as Pn,bb as $n,ar as Ce,cO as Dn,cP as Bn,bh as Rt,ci as wt,cQ as Kn,cR as Gn,cS as Un,cT as Mt,cU as Vn,cs as Qn,cV as Wn,bf as zn,aW as Hn,S as Lt,cW as qn,I as Yn,Q as Te,X as Zn,B as ie,cX as Xn,bp as Jn,bq as es,br as ts,bs as ns,bt as ss,cY as os,cZ as as,bB as is,c_ as cs,c$ as rs,d0 as ls,af as Pt,d1 as ht,i as ds,d2 as us,d3 as $t,d4 as De,d5 as vt,cg as ms,d6 as fs,d7 as ps,d8 as hs,d9 as vs,da as ys,db as gs,dc as xs,dd as bs,de as js,df as ks,bM as Ss,dg as Ns,dh as Cs,aR as yt,di as gt,dj as Be,dk as Dt,dl as _s,dm as Ke}from"./index-DYCqXaMf.js";import{S as K,F as Is,d as Ts,o as Ne,r as As,f as Es,a as Fs}from"./filter-editors-B1_QUpg_.js";import{c as xt}from"./connection-label-BobuYiAG.js";import{S as Os}from"./source-record-panels-Cg249m1S.js";import{u as Rs}from"./clients-L4K1UT8c.js";import{g as ws}from"./client-rows--FrZfJol.js";import{E as Ms}from"./events-feed-DsrkV2ix.js";import{L as Ls,u as Ps}from"./schema-value-normalization-CylKX3PK.js";import{E as $s}from"./agent-loading-shells-De_2d8Lr.js";import{M as Ds}from"./member-scope-gate-B2LrMWBU.js";const Qe=b.createContext(null);function Bs({organizationId:e,isWorkspaceLoading:t,children:o}){const{data:s=[],isLoading:a}=gn(e);return n.jsx(Qe.Provider,{value:{groups:s,isLoading:!!t||a},children:o})}function Ks(){const e=b.useContext(Qe);if(!e)throw new Error("useMemoryConnectorGroups must be used within MemoryConnectorGroupsProvider");return e}function Gs(){return b.useContext(Qe)}function Bt(e){const{parse:t,serialize:o,filterKeys:s,clearClassifications:a=!0,replace:c=!0,merge:f}=e,u=z(),d=ce(),i=b.useMemo(()=>{const m=new URLSearchParams;for(const[h,y]of Object.entries(d.search||{}))y!=null&&m.set(h,typeof y=="object"&&!Array.isArray(y)?JSON.stringify(y):String(y));return t(m)},[d.search,t]),r=b.useCallback((m,h)=>{const y=f?f(i,m):{...i,...m},g=o(y),N={};for(const[j,x]of Object.entries(d.search||{}))x!=null&&(N[j]=x);for(const j of s)delete N[j];if(a)for(const j of Object.keys(N))j.startsWith("clf_")&&delete N[j];for(const[j,x]of Object.entries(g))x!==void 0&&(N[j]=x);u({to:d.pathname,search:N,replace:h?.replace??c})},[i,o,s,a,f,u,d,c]),l=b.useCallback(()=>{const m={};for(const[h,y]of Object.entries(d.search||{}))y!=null&&(s.includes(h)||a&&h.startsWith("clf_")||(m[h]=y));u({to:d.pathname,search:m,replace:c})},[u,d.pathname,d.search,s,a,c]);return{filters:i,updateFilters:r,clearFilters:l}}function Us(e){const{slug:t}=xn();return Tt({queryKey:["schedules",t,e],queryFn:async()=>((await At("manage_schedules",{action:"list",action_type:"wake_agent",include_paused:!0})).schedules??[]).filter(s=>s.action_args?.agent_id===e),enabled:!!t&&!!e,staleTime:3e4})}function Vs(e,t){return{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:e,connectorKey:t.connector_key,connectionId:String(t.connection_id)},search:{feedId:t.id}}}function Qs(e,t){return{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:e,connectorKey:t.connector_key,connectionId:String(t.id)}}}function Ws(e,t){return{to:"/$owner/agents/connected/$clientId",params:{owner:e,clientId:t}}}function zs(e,t){return{to:"/$owner/automations/$automationId",params:{owner:e,automationId:t}}}function Hs(e,t,o){return{to:"/$owner/events",params:{owner:e},search:{agent:t,schedule:o}}}function xe({id:e,label:t,value:o,sourceLink:s,details:a,onRemove:c}){return{id:e,label:t,op:"is",value:o,onRemove:c,editor:s||a?{kind:"custom",className:"w-80",render:()=>n.jsxs("div",{className:"flex flex-col gap-2 p-3 text-sm",children:[s?n.jsxs(Ie,{to:s.to,params:s.params,search:s.search,className:"inline-flex min-w-0 items-center gap-1.5 font-medium text-foreground hover:underline",children:[n.jsx("span",{className:"truncate",children:o}),n.jsx(bn,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]}):n.jsx("span",{className:"font-medium",children:o}),a]})}:void 0}}function qs({ownerSlug:e,clientIds:t,linkedUser:o,linkedUserEntitySlug:s}){const a=e&&s?jn(e,[{entity_type:"$member",slug:s}]):null;return n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"inline-flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground",children:[n.jsx("span",{children:t.length===1?"Client ID":"Client IDs"}),t.map(c=>n.jsx("code",{className:"break-all text-foreground",children:c},c))]}),o?n.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:["Granted by",a?n.jsx(Ie,{to:a,className:"font-medium text-foreground hover:underline",children:o}):n.jsx("span",{className:"font-medium text-foreground",children:o})]}):null]})}function ee(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function be(e,t,o){const s=new Set;for(const[a,c]of Object.entries(e.feeds_schema??{})){if(o&&!o.has(a))continue;const f=ee(ee(c)?.eventKinds);if(f)for(const[u,d]of Object.entries(f)){if(!t){s.add(u);continue}const i=ee(d)?.attributions;Array.isArray(i)&&i.some(r=>{const l=ee(ee(r)?.target);return typeof l?.entityType=="string"&&t.has(l.entityType)})&&s.add(u)}}return s}function Ys({connectors:e,entityTypes:t,selectedPlatforms:o=[],selectedFeeds:s=[],selectedEntityTypes:a=[]}){const c=new Set,f=new Set(o),u=new Set(a),d=new Map;for(const i of s){const r=d.get(i.connectorKey)??new Set;r.add(i.feedKey),d.set(i.connectorKey,r)}if(d.size>0)for(const i of e){const r=d.get(i.key);if(r)for(const l of be(i,void 0,r))c.add(l)}else if(f.size>0){for(const i of e)if(f.has(i.key))for(const r of be(i))c.add(r)}else if(u.size>0){for(const i of t)if(u.has(i.slug))for(const r of Object.keys(i.event_kinds??{}))c.add(r);for(const i of e)for(const r of be(i,u))c.add(r)}else{for(const i of t)for(const r of Object.keys(i.event_kinds??{}))c.add(r);for(const i of e)for(const r of be(i))c.add(r)}return[...c].sort((i,r)=>i.localeCompare(r))}function Zs(e){const{orgContext:t}=kn(),{data:o=[],isLoading:s}=Et(t);return{visible:b.useMemo(()=>o.filter(c=>!Sn(c)&&(!c.organization_slug||c.organization_slug===e)),[o,e]),isTypesLoading:s}}function oe({to:e,params:t,search:o,label:s}){return n.jsx(Ie,{to:e,params:t,search:o,onClick:a=>a.stopPropagation(),onPointerDown:a=>a.stopPropagation(),className:"shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity hover:text-foreground group-hover:opacity-100 focus-visible:opacity-100","aria-label":`Manage ${s}`,children:n.jsx(Nn,{className:"h-3.5 w-3.5"})})}const Ge=["produced","analyzed"],_e=e=>e==="produced"?"Produced by":"Analyzed by";function Xs({enabled:e,...t}){const o=Js(t,e);if(!e)return{fields:[],chips:[]};const s=eo(t);return{fields:[o.field,s.field],chips:[...o.chips,...s.chips]}}function Js({ownerSlug:e,filters:t,onFiltersChange:o},s){const a=Tt({queryKey:["automations-list","activity",e],queryFn:async()=>{const r=await Promise.all(["active","archived"].map(l=>At("manage_automations",{action:"list",status:l,include_details:!1},{slug:e})));return[...new Map(r.flatMap(l=>l.automations).map(l=>[Number(l.automation_id),l])).values()].sort((l,m)=>l.name.localeCompare(m.name))},enabled:s&&!!e,staleTime:3e4}),c=a.data??[],f=r=>r==="produced"?t.producedByAutomationId:t.automationId,u=r=>c.find(l=>Number(l.automation_id)===r)?.name??`#${r}`,d=Ge.flatMap(r=>{const l=f(r);return l==null?[]:[{id:`automation-${r}`,field:"automation",label:_e(r),value:u(l),onRemove:()=>o(r==="produced"?{producedByAutomationId:null}:{automationId:null})}]}),i={kind:"list",className:"w-80",searchPlaceholder:"Search Automations...",emptyText:a.isLoading?"Loading Automations...":"No Automations found",items:r=>n.jsxs(n.Fragment,{children:[Ge.map(l=>{const m=f(l),h=c.map(g=>({id:Number(g.automation_id),label:`${g.name}${g.status==="archived"?" (archived)":""}`}));m!=null&&!h.some(g=>g.id===m)&&h.unshift({id:m,label:`Automation #${m} (selected)`});const y=g=>{o(l==="produced"?{producedByAutomationId:g}:{automationId:g}),r()};return n.jsx(Ft,{heading:_e(l),children:h.map(g=>n.jsxs(A,{"aria-label":g.label,value:`${l} ${g.label} ${g.id}`,onSelect:()=>y(g.id),className:"group",children:[n.jsx(K,{selected:m===g.id}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:g.label}),n.jsx(oe,{...zs(e,String(g.id)),label:g.label})]},g.id))},l)}),a.isError?n.jsx(A,{forceMount:!0,onSelect:()=>void a.refetch(),children:"Could not load Automations. Retry"}):null]})};return{chips:d,field:{key:"automation",label:"Automation",group:"Scope",icon:n.jsx(Cn,{className:"h-4 w-4"}),editor:i}}}function eo(e){const{filters:t,onFiltersChange:o}=e,s=[];t.runIds?.length&&s.push({id:"run-produced",field:"run",label:"Produced by run",value:t.runIds.map(c=>`#${c}`).join(", "),onRemove:()=>o({runIds:null})}),t.runId!=null&&s.push({id:"run-analyzed",field:"run",label:"Analyzed by run",value:`#${t.runId}`,onRemove:()=>o({runId:null})});const a={kind:"list",className:"w-96",searchPlaceholder:"Search runs or enter a run ID...",emptyText:"No matching runs. Enter an exact run ID or load more.",items:(c,f)=>Ge.map(u=>n.jsx(to,{...e,mode:u,query:f,close:c},u))};return{chips:s,field:{key:"run",label:"Run",group:"Scope",icon:n.jsx(_n,{className:"h-4 w-4"}),editor:a}}}function to({ownerSlug:e,filters:t,onFiltersChange:o,mode:s,query:a,close:c}){const f=s==="produced"?t.producedByAutomationId:t.automationId,u=In({workspace:!0},{automationIds:f==null?void 0:[f],runTypes:s==="analyzed"?["automation"]:void 0,connectionIds:s==="produced"?t.connectionIds??void 0:void 0,feedIds:s==="produced"?t.feedIds??void 0:void 0},e),d=s==="produced"?t.runIds??[]:t.runId==null?[]:[t.runId],i=u.data?.pages.flatMap(h=>h.runs)??[],r=[...new Map(i.map(h=>[h.id,{id:h.id,label:`Run #${h.id} · ${h.feed_display_name??h.operation_key??h.run_type} · ${h.status}`}])).values()];for(const h of d)r.some(y=>y.id===h)||r.unshift({id:h,label:`Run #${h} (selected)`});const l=h=>{if(s==="produced"){const y=d.includes(h)?d.filter(g=>g!==h):[...d,h];o({runIds:y.length?y:null})}else o({runId:h}),c()},m=/^\d+$/.test(a.trim())?Number(a.trim()):0;return n.jsxs(Ft,{heading:_e(s),children:[r.map(h=>n.jsxs(A,{value:`${s} ${h.label}`,onSelect:()=>l(h.id),children:[n.jsx(K,{selected:d.includes(h.id)}),n.jsx("span",{className:"truncate",children:h.label})]},h.id)),Number.isSafeInteger(m)&&m>0&&!r.some(h=>h.id===m)?n.jsxs(A,{value:`${s} ${m}`,onSelect:()=>l(m),children:[_e(s)," run #",m]}):null,u.isLoading?n.jsx(A,{disabled:!0,forceMount:!0,children:"Loading runs..."}):null,u.isError?n.jsx(A,{forceMount:!0,onSelect:()=>void(u.isFetchNextPageError?u.fetchNextPage():u.refetch()),children:"Could not load runs. Retry"}):null,!u.isLoading&&!u.isError&&!r.length?n.jsx(A,{disabled:!0,forceMount:!0,children:"No runs found"}):null,u.hasNextPage?n.jsx(A,{forceMount:!0,disabled:u.isFetching,onSelect:()=>void u.fetchNextPage(),children:u.isFetchingNextPage?"Loading more runs...":"Load more runs"}):null]})}const We="Scope",Pe="Source",H="h-4 w-4";function re(){return ce().search??{}}function Kt(e){const{pathname:t}=ce(),{_splat:o}=Fn({strict:!1}),s=!!(o&&!On(o.split("/")[0])&&!t.startsWith(`/${e}/events/`));return{pathname:t,embedded:s,recordPath:s||t.startsWith(`/${e}/events/`)?o:void 0}}function Gt(e){const t=re(),{recordPath:o,pathname:s,embedded:a}=Kt(e);return c=>{const f=ae(e,t,c,o);return a?{to:s,search:f.search}:f}}const bt=e=>new Set((e??"").split(",").map(t=>t.trim()).filter(Boolean));function no({ownerSlug:e,sourceRead:t=!1,filters:o,onFiltersChange:s}){const a=re(),{recordPath:c,embedded:f}=Kt(e),u=c?c.split("/").at(-2):void 0,d=typeof a.type=="string"&&a.type.trim()?a.type.trim():void 0,i=u??(d?Tn(d):void 0),r=An(a),l=En(a),m=typeof a.feed_ids=="string"?a.feed_ids:typeof a.feed_ids=="number"?String(a.feed_ids):void 0,h=so(e,i,!f),y=oo(e,i,c,f),g=ao(e,r,!t),N=Xs({ownerSlug:e,filters:o,onFiltersChange:s,enabled:!t}),j=io(e,l,m);return[h,y,g,N,j].reduce((x,F)=>({fields:[...x.fields,...F.fields],chips:[...x.chips,...F.chips]}),{fields:[],chips:[]})}function so(e,t,o){const s=z(),a=re(),{visible:c}=Zs(e);if(!o)return{fields:[],chips:[]};const f=c.find(d=>d.slug===t),u={kind:"list",searchPlaceholder:"Search types...",emptyText:"No entity types",items:d=>n.jsxs(n.Fragment,{children:[c.map(i=>n.jsxs(A,{onSelect:()=>{s(ae(e,a,{entity:void 0,create:void 0,type:i.slug})),d()},className:"group gap-2",children:[n.jsx(K,{selected:i.slug===t}),n.jsx(Un,{icon:i.icon,className:"h-4 w-4 shrink-0"}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:i.name}),typeof i.entity_count=="number"?n.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:i.entity_count}):null,n.jsx(oe,{to:"/$owner/entity-types/$slug",params:{owner:e,slug:i.slug},label:i.name})]},i.id)),n.jsxs(A,{onSelect:()=>{s(Vn(e)),d()},className:"text-muted-foreground",children:[n.jsx(Mt,{className:"h-4 w-4 shrink-0"}),"Add entity type"]})]})};return{fields:[{key:"type",label:"Entity type",group:We,icon:n.jsx(Rn,{className:H}),editor:u}],chips:t?[{id:"type",label:"Entity type",op:"is",value:f?.name??t,onRemove:()=>void s(ae(e,a,{type:void 0}))}]:[]}}function oo(e,t,o,s){const a=z(),c=re(),[f,u]=b.useState(""),[d,i]=b.useState(0),r=Ot(f,250),l={slug:e},{data:m,isLoading:h,isError:y,refetch:g}=wn(t??"",l,{search:r,offset:d,limit:30,enabled:!s&&!!t}),{data:N}=Mn(o?`/${e}/${o}`:"",l),j=o?N?.entity:void 0,x=j?.name??(o?o.split("/").at(-1):void 0);if(s)return{fields:[],chips:x?[{id:"entity",label:"Entity",op:"is",value:x}]:[]};if(!t)return{fields:[],chips:[]};const F={kind:"list",searchPlaceholder:"Search entities...",emptyText:h?"Loading entities...":"No matching entities",className:"w-80",onQueryChange:R=>{u(R),i(0)},items:R=>n.jsxs(n.Fragment,{children:[y?n.jsx(A,{onSelect:()=>void g(),children:"Could not load entities. Retry"}):m?.entities.map(I=>n.jsxs(A,{value:I.slug,onSelect:()=>{const L=Qn(Wn([...I.parent_slug&&I.parent_entity_type?[{entity_type:I.parent_entity_type,slug:I.parent_slug}]:[],{entity_type:I.entity_type,slug:I.slug}]));a(ae(e,c,{type:t},L)),R()},children:[n.jsx(K,{selected:j?.slug===I.slug}),I.name]},I.slug)),d>0&&n.jsx(A,{onSelect:()=>i(Math.max(0,d-30)),children:"Previous entities"}),m?.metadata.has_more&&n.jsx(A,{disabled:h,onSelect:()=>i(d+30),children:"More entities"})]})};return{fields:[{key:"entity",label:"Entity",group:We,icon:n.jsx(Ln,{className:H}),editor:F}],chips:x?[{id:"entity",label:"Entity",op:"is",value:x,onRemove:()=>void a(ae(e,c,{type:t}))}]:[]}}function ao(e,t,o){const s=z(),a=Gt(e),{data:c=[]}=Pn(),f=b.useMemo(()=>[...c].sort((i,r)=>i.name.localeCompare(r.name)),[c]);if(!o)return{fields:[],chips:[]};const u=f.find(i=>i.agentId===t),d={kind:"list",searchPlaceholder:"Search agents...",emptyText:"No agents",items:i=>f.map(r=>n.jsxs(A,{onSelect:()=>{s(a({agent:r.agentId,schedule:void 0})),i()},className:"gap-2",children:[n.jsx(K,{selected:r.agentId===t}),n.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-muted text-[10px] font-medium",children:r.name.trim().charAt(0).toUpperCase()||"?"}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:r.name})]},r.agentId))};return{fields:[{key:"agent",label:"Agent",group:We,icon:n.jsx($n,{className:H}),editor:d}],chips:t?[{id:"agent",label:"Agent",op:"is",value:u?.name??t,onRemove:()=>void s(a({agent:void 0,schedule:void 0}))}]:[]}}function io(e,t,o){const s=z(),a=Gt(e),{groups:c}=Ks(),f=re(),u=Ce({platforms:String(f.platforms??f.platform??"")}).platforms??[],d=b.useMemo(()=>bt(t),[t]),i=b.useMemo(()=>bt(o),[o]),r=u.length===1?u[0]:Dn(c,d),l=c.find(T=>T.connector_key===r),m=d.size===1?Number([...d][0]):void 0,h=Bn(m),{org:y}=Rt(),g=wt(y?.id,{feedIds:[...i].map(Number),enabled:m==null&&i.size>0}),N=m==null?g:h,j=N.data??[],x={platforms:void 0,platform:void 0,connection_ids:void 0,feed_ids:void 0},F={kind:"list",searchPlaceholder:"Search connectors...",emptyText:"No connectors",items:T=>n.jsxs(n.Fragment,{children:[c.map(S=>{const _=S.connector_name??S.connector_key;return n.jsxs(A,{disabled:S.connections.length===0,onSelect:()=>{s(a({...x,platforms:S.connector_key})),T()},className:"group gap-2",children:[n.jsx(K,{selected:S.connector_key===l?.connector_key}),n.jsx(Hn,{plain:!0,name:_,faviconDomain:S.favicon_domain,className:"h-5 w-5 shrink-0 rounded-md text-[10px]"}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:_}),S.connection_count>0?n.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:S.connection_count}):null,n.jsx(oe,{to:"/$owner/connectors/$connectorKey",params:{owner:e,connectorKey:S.connector_key},label:_})]},S.connector_key)}),n.jsx(A,{asChild:!0,onSelect:T,className:"text-muted-foreground",children:n.jsxs(Ie,{to:"/$owner/connectors/create",params:{owner:e},className:"flex items-center gap-2",children:[n.jsx(Mt,{className:"h-4 w-4 shrink-0"}),"Add connector"]})})]})},R=[{key:"connector",label:"Connector",group:Pe,icon:n.jsx(zn,{className:H}),editor:F}],I=[],L=l?.connector_name??l?.connector_key??(u.join(", ")||(d.size?`Connections ${[...d].join(", ")}`:void 0));if(L&&I.push({id:"connector",label:"Connector",op:"is",value:L,onRemove:()=>void s(a(x))}),l){R.push({key:"connection",label:"Connection",group:Pe,icon:n.jsx(Kn,{className:H}),editor:P(l)});const T=d.size===1?l.connections.find(S=>d.has(String(S.id))):void 0;T&&I.push({id:"connection",label:"Connection",op:"is",value:xt({display_name:T.display_name,connector_name:l.connector_name,connector_key:l.connector_key}),onRemove:()=>void s(a({...x,platforms:l.connector_key}))})}if((m||o)&&R.push({key:"feed",label:"Feed",group:Pe,icon:n.jsx(Gn,{className:H}),editor:G()}),i.size>0){const T=i.size===1?j.find(S=>i.has(String(S.id))):void 0;I.push({id:"feed",label:"Feed",op:"is",value:T?je(T):`#${o}`,onRemove:()=>void s(a({...m!=null?{connection_ids:String(m)}:{},feed_ids:void 0}))})}return{fields:R,chips:I};function P(T){return{kind:"list",searchPlaceholder:"Search connections...",emptyText:"No connections",items:S=>T.connections.map(_=>{const $=xt({display_name:_.display_name,connector_name:T.connector_name,connector_key:T.connector_key});return n.jsxs(A,{onSelect:()=>{s(a({connection_ids:String(_.id),feed_ids:void 0})),S()},className:"group gap-2",children:[n.jsx(K,{selected:d.has(String(_.id))}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:$}),_.feed_count>0?n.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:_.feed_count}):null,n.jsx(oe,{...Qs(e,{id:_.id,connector_key:T.connector_key}),label:$})]},_.id)})}}function G(){return{kind:"list",searchPlaceholder:"Search feeds...",emptyText:N.isLoading?"Loading feeds...":"No feeds",items:T=>j.map(S=>n.jsxs(A,{"aria-label":je(S),onSelect:()=>{s(a({...m!=null?{connection_ids:String(m)}:{},feed_ids:String(S.id)})),T()},className:"group gap-2",children:[n.jsx(K,{selected:i.has(String(S.id))}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:je(S)}),n.jsx(oe,{...Vs(e,S),label:je(S)})]},S.id))}}}function je(e){return e.display_name?.trim()||e.feed_key}const co=["notification"],ro=["note","summary","decision","observation","fact","change","preference","identity"],lo=[...co,...ro],jt=[{value:"date-desc",label:"Newest first"},{value:"date-asc",label:"Oldest first"},{value:"score-desc",label:"Highest score"},{value:"score-asc",label:"Lowest score"}],$e={value:"notifications",label:"Notifications first"},kt=[{value:"user",label:"Manual review"},{value:"system",label:"Auto-classified"},{value:"llm",label:"LLM-classified"}],St=[{value:"pending",label:"Pending approval"},{value:"approved",label:"Approved"},{value:"rejected",label:"Rejected"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}],ke=0,Se=100,te="Event",ne="h-4 w-4";function se(e){const t=e.replace(/[_-]+/g," ").trim();return t.length>0?`${t.charAt(0).toUpperCase()}${t.slice(1)}`:e}function uo(e,t,o){const s=e.semanticTypes??[],a=o.length>0?o:lo,c=[...new Set([...a,...s])].sort((l,m)=>se(l).localeCompare(se(m))).map(l=>({value:l,label:se(l)})),f=e.engagementRange??[ke,Se],u=e.reviewStatus,d=e.interactionStatus,i=[{key:"date",label:"Date",group:te,icon:n.jsx(os,{className:ne}),editor:Ts({value:e.dateRange??void 0,onApply:l=>t({dateRange:l})})},{key:"kind",label:"Event kind",group:te,icon:n.jsx(as,{className:ne}),editor:Ne({searchPlaceholder:"Search event kinds...",emptyText:"No event kinds found",options:c,selected:s,multiple:!0,onSelect:l=>{const m=s.includes(l)?s.filter(h=>h!==l):[...s,l];t({semanticTypes:m.length>0?m:void 0})}})},{key:"approval",label:"Approval",group:te,icon:n.jsx(is,{className:ne}),editor:Ne({searchPlaceholder:"Search statuses...",options:[...St],selected:d?[d]:[],onSelect:l=>t({interactionStatus:l})})},{key:"review",label:"Reviewed by",group:te,icon:n.jsx(cs,{className:ne}),editor:Ne({searchPlaceholder:"Search reviewers...",options:[...kt],selected:u&&u!=="all"?[u]:[],onSelect:l=>t({reviewStatus:l})})},{key:"score",label:"Engagement score",group:te,icon:n.jsx(rs,{className:ne}),editor:As({value:f,min:ke,max:Se,onApply:l=>t({engagementRange:l})})}],r=[];return e.dateRange&&r.push({id:"date",label:"Date",op:"is",value:Es(e.dateRange),onRemove:()=>t({dateRange:null})}),s.length&&r.push({id:"kind",label:"Event kind",op:s.length>1?"is any of":"is",value:s.length<=2?s.map(se).join(", "):`${s.length} kinds`,title:s.map(se).join(", "),onRemove:()=>t({semanticTypes:void 0})}),d&&r.push({id:"approval",label:"Approval",op:"is",value:St.find(l=>l.value===d)?.label??d,onRemove:()=>t({interactionStatus:null})}),u&&u!=="all"&&r.push({id:"review",label:"Reviewed by",op:"is",value:kt.find(l=>l.value===u)?.label??u,onRemove:()=>t({reviewStatus:void 0})}),(f[0]!==ke||f[1]!==Se)&&r.push({id:"score",label:"Engagement score",value:Fs(f,ke,Se),onRemove:()=>t({engagementRange:void 0})}),{fields:i,chips:r}}function Ut({filters:e,onFiltersChange:t,eventKinds:o=[],searchQuery:s,onSearchChange:a,scope:c,extraFields:f=[],drillChips:u=[],total:d,isListLoading:i=!1,isTotalLoading:r=!1,hasCursorInUrl:l=!1,onGoToLatest:m,notificationsFirst:h,sourceRead:y=!1,filterTrailing:g,filterActions:N,onClearFilters:j}){const x=s.trim().length>0,F=y?{fields:[],chips:[]}:uo(e,t,o),R=[...c?.fields??[],...F.fields,...f],I=[...c?.chips??[],...u,...F.chips],L=I.length>0||x,P=h===void 0?jt:[$e,...jt],G=h?$e.value:`${e.sortBy??"date"}-${e.sortOrder??"desc"}`,T=P.find(_=>_.value===G)?.label??"Newest first",S=i||r?n.jsx(Lt,{className:"h-4 w-20"}):d==null?null:L?`${d.toLocaleString()} ${d===1?"match":"matches"}`:`${d.toLocaleString()} ${d===1?"item":"items"}`;return n.jsxs("div",{className:"w-full space-y-2.5",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[!y&&n.jsxs("div",{className:"relative w-full min-w-48 flex-1 sm:max-w-xs",children:[n.jsx(qn,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),n.jsx(Yn,{type:"search","aria-label":"Search events",placeholder:"Search events...",value:s,onChange:_=>a(_.target.value),className:Te("pl-9",x&&"pr-8")}),x&&n.jsx("button",{type:"button","aria-label":"Clear search",onClick:()=>a(""),className:"absolute right-2 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground transition-colors hover:text-foreground",children:n.jsx(Zn,{className:"h-3.5 w-3.5"})})]}),n.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[!i&&l&&m&&n.jsxs(ie,{variant:"ghost",size:"sm",className:"h-8 gap-1",onClick:m,children:[n.jsx(Xn,{className:"h-3.5 w-3.5"}),"Back to latest"]}),!y&&n.jsxs(Jn,{value:G,onValueChange:_=>{if(_===$e.value){t({sortBy:void 0,sortOrder:void 0});return}const[$,U]=_.split("-");t({sortBy:$,sortOrder:U})},children:[n.jsx(es,{"aria-label":"Sort",className:"h-9 w-[200px] px-2.5",children:n.jsx(ts,{children:n.jsxs("span",{className:"truncate",children:[n.jsx("span",{className:"text-muted-foreground",children:"Sort: "}),T]})})}),n.jsx(ns,{children:P.map(_=>n.jsx(ss,{value:_.value,children:_.label},_.value))})]})]})]}),n.jsx(Is,{label:"Event filters",fields:R,chips:I,meta:S,actions:N,trailing:g,onClearAll:j,hasClearableState:x})]})}function Vt({ownerSlug:e,...t}){const o=no({ownerSlug:e,sourceRead:t.sourceRead,filters:t.filters,onFiltersChange:t.onFiltersChange});return n.jsx(Ut,{...t,scope:o})}const Ue=3600*1e3,Nt=24*Ue;function Ct(e){const t=e instanceof Date?e:new Date(String(e));return Number.isNaN(t.getTime())?null:t}function _t(e){return e.toISOString().split("T")[0]}function Ve(e){return e.toLocaleDateString(void 0,{timeZone:"UTC",month:"short",day:"numeric"})}function mo(e){const o=e[e.length-1].date.getTime()-e[0].date.getTime()>180*Nt,s=new Map;for(const a of e){const c=new Date(a.date);o&&c.setUTCDate(c.getUTCDate()-c.getUTCDay()),s.set(c.getTime(),(s.get(c.getTime())??0)+a.count)}return[...s.entries()].sort(([a],[c])=>a-c).map(([a,c])=>{const f=new Date(a);return{start:f,end:new Date(a+(o?7:1)*Nt),count:c,label:`${f.getUTCMonth()+1}/${f.getUTCDate()}`,tooltip:o?`Week of ${Ve(f)}`:Ve(f)}})}function fo(e){const t=f=>{const u=new Date(f);return u.setMinutes(0,0,0),u.getTime()},o=new Map;for(const f of e)o.set(t(f),(o.get(t(f))??0)+1);const s=Math.min(...o.keys()),a=Math.max(...o.keys()),c=[];for(let f=s;f<=a;f+=Ue){const u=new Date(f);c.push({start:u,end:new Date(f+Ue),count:o.get(f)??0,label:ht(u,"HH:mm"),tooltip:ht(u,"MMM d, HH:mm")})}return c}function po({entityId:e,organizationId:t,ownerSlug:o,eventTimes:s,selectedRange:a,onSelectRange:c}){const{data:f,isLoading:u,error:d}=ls(t,{entityId:e},{slug:o}),i=b.useMemo(()=>(f??[]).map(y=>{const g=Ct(y.date);return g?{date:g,count:y.count}:null}).filter(y=>y!==null).sort((y,g)=>y.date.getTime()-g.date.getTime()),[f]),r=b.useMemo(()=>{if(i.length===0)return[];if(i.length>1)return mo(i);const[y]=i,g=_t(y.date),N=(s??[]).map(Ct).filter(j=>j!==null&&_t(j)===g);return N.length===y.count?fo(N):[]},[i,s]),l=b.useCallback(y=>{const g=r[y.dataIndex];g&&c&&c(g.start,g.end)},[r,c]),m=b.useCallback(y=>{if(c&&y.startValue!==void 0&&y.endValue!==void 0){const g=new Date(y.startValue),N=new Date(y.endValue);c(g,N)}},[c]),h=b.useMemo(()=>{if(r.length<2)return null;let y;if(a){const[g,N]=a,j=r.filter(x=>x.start<N&&x.end>g);j.length>0&&(y=[[{xAxis:j[0].label},{xAxis:j[j.length-1].label}]])}return{tooltip:{trigger:"axis",axisPointer:{type:"line"},formatter:g=>{const N=g[0];return`${r[N.dataIndex]?.tooltip}: ${N.value} items`}},grid:{left:50,right:20,top:20,bottom:60},xAxis:{type:"category",boundaryGap:!1,data:r.map(g=>g.label)},yAxis:{type:"value",minInterval:1,splitLine:{lineStyle:{color:"rgba(0,0,0,0.05)"}}},dataZoom:[{type:"slider",start:0,end:100,height:20,bottom:10,borderColor:"transparent",backgroundColor:"rgba(0,0,0,0.02)",fillerColor:"rgba(99, 102, 241, 0.1)",handleStyle:{color:"#6366f1"}}],series:[{type:"line",smooth:!0,areaStyle:{opacity:.3,color:new Ls(0,0,0,1,[{offset:0,color:"rgba(99, 102, 241, 0.5)"},{offset:1,color:"rgba(99, 102, 241, 0.05)"}])},lineStyle:{width:2,color:"#6366f1"},itemStyle:{color:"#6366f1"},showSymbol:!1,data:r.map(g=>g.count),markLine:{silent:!0,symbol:"none",label:{position:"insideEndTop",formatter:"avg: {c}",fontSize:10,color:"#9ca3af"},lineStyle:{color:"#d1d5db",type:"dashed",width:1},data:[{type:"average",name:"Average"}]},markArea:y?{silent:!0,itemStyle:{color:"rgba(99, 102, 241, 0.1)"},data:y}:void 0}]}},[r,a]);if(u||d)return n.jsx("div",{className:Te(Pt,"p-4"),children:n.jsx("div",{className:"flex h-48 w-full items-center justify-center",children:u?n.jsx($s,{}):n.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to load timeline"})})});if(i.length===0)return null;if(!h){const[y]=i;return n.jsxs("p",{className:"text-xs text-muted-foreground",children:[y.count===1?"1 event":`All ${y.count} events`," on"," ",Ve(y.date),"."]})}return n.jsx(ho,{option:h,onClick:l,onDataZoom:m})}function ho({option:e,onClick:t,onDataZoom:o}){const{chartRef:s,setOption:a}=Ps({onClick:t,onDataZoom:o});return b.useEffect(()=>{a(e,!0)},[e,a]),n.jsx("div",{"data-testid":"events-timeline",className:Te(Pt,"p-4 relative"),children:n.jsx("div",{ref:s,className:"h-48 w-full"})})}const It="change";function vo({kinds:e,onFiltersChange:t}){const o=!e?.length,s=e?.length===1&&e[0]===It,a=c=>Te("h-7 px-2.5 text-xs",c?"bg-muted text-foreground":"text-muted-foreground");return n.jsxs("fieldset",{"aria-label":"Show",className:"m-0 inline-flex min-w-0 items-center rounded-md border border-border p-0.5",children:[n.jsx(ie,{type:"button",variant:"ghost",size:"sm",className:a(o),"aria-pressed":o,onClick:()=>t({semanticTypes:void 0}),children:"All"}),n.jsx(ie,{type:"button",variant:"ghost",size:"sm",className:a(s),"aria-pressed":s,onClick:()=>t({semanticTypes:[It]}),children:"Changes"})]})}function yo({organizationId:e,ownerSlug:t,entityId:o,hideSourceFilter:s=!1,scopedEntityTypes:a,notificationsFirst:c,emptyState:f,changesShortcut:u=!1}){const{isAuthenticated:d,isReady:i}=ds(),{isMember:r,isLoading:l}=Rt(),m=i&&d&&r,h=i&&(!d||!l&&!r),y=z(),g=ce(),N=us(),j=c!=null,{filters:x,updateFilters:F,clearFilters:R}=Bt({parse:Ce,serialize:Be,filterKeys:Dt,replace:!1,merge:b.useCallback((p,v)=>{const k=$t(p,v);return j&&p.sortBy==null&&p.sortOrder==null&&!("sortBy"in v)&&!("sortOrder"in v)&&(k.sortBy=void 0,k.sortOrder=void 0),k},[j])}),I=j&&x.sortBy==null&&x.sortOrder==null,[L,P]=b.useState(x.searchQuery||""),[G,T]=b.useState(De(x)||s&&(o!=null||!!a?.length)),S=L.trim(),_=S.length>=3?S:void 0,$=Ot(_,1e3),U=b.useRef(!1);b.useEffect(()=>N.history.subscribe(({location:p,action:v})=>{const k=Ce(new URLSearchParams(p.search)).searchQuery??"";!(v.type==="BACK"||v.type==="FORWARD"||v.type==="GO")&&U.current&&(k===(x.searchQuery??"")||k===(_??""))||(U.current=!1,P(k))}),[N.history,_,x.searchQuery]);const C=b.useMemo(()=>vt({...x,...a?.length?{entityTypes:a}:{}}),[x,a]),w=F;b.useEffect(()=>{U.current&&(x.searchQuery||void 0)!==$&&F({searchQuery:$})},[$,F,x.searchQuery]);const ze=()=>{U.current=!1,P(""),s&&t?y({...Ke(t,g.search??{}),...o!==void 0&&!g.pathname.startsWith(`/${t}/events/`)?{to:g.pathname}:{}}):R()},le=De(vt(x)),He=o===void 0,{data:Qt=[]}=ms(i&&m?e:null),{data:Wt=[]}=fs(h?t:null),qe=m?Qt:Wt,{data:Ye=[]}=Et(m&&e?{organizationId:e}:void 0),de=Gs(),ue=C.connectionIds,Ae=(ue?.length??0)>0,{data:Ze=[]}=ps(i&&m?e??"":"",{connectionIds:ue??void 0,enabled:!de&&i&&m&&Ae}),Xe=C.feedIds,Ee=(Xe?.length??0)>0,{data:Je=[]}=wt(i&&m?e:null,{feedIds:Xe??void 0,enabled:i&&m&&Ee}),et=b.useMemo(()=>de?de.groups.flatMap(p=>p.connections.map(v=>({id:v.id,display_name:v.display_name,connector_name:p.connector_name,connector_key:p.connector_key}))):Ze,[Ze,de]),Fe=b.useMemo(()=>{const p=new Set(ue??[]);return[...new Set([...C.platforms??[],...et.filter(v=>p.has(v.id)).map(v=>v.connector_key)])]},[ue,et,C.platforms]),Oe=b.useMemo(()=>Je.map(p=>({connectorKey:p.connector_key,feedKey:p.feed_key})),[Je]),zt=b.useMemo(()=>Ae&&Fe.length===0||Ee&&Oe.length===0?[]:Ys({connectors:qe,entityTypes:Ye,selectedPlatforms:Fe,selectedFeeds:Oe,selectedEntityTypes:C.entityTypes}),[qe,C.entityTypes,Ae,Ee,Fe,Oe,Ye]),O=C.clientIds,me=(O?.length??0)>0,{data:tt=[]}=Rs(null,{enabled:i&&m&&me}),fe=b.useMemo(()=>{if(!O)return[];const p=new Set(O);return ws(tt).filter(v=>v.clientIds.some(k=>p.has(k)))},[O,tt]),nt=b.useMemo(()=>{if(!me||!O)return null;const p=fe.map(v=>v.title);return p.length>0?p.join(", "):O.length>1?`${O.length} client registrations`:"Client registration"},[fe,O,me]),pe=fe.length===1?fe[0]:null,Ht=t&&pe?Ws(t,pe.clientId):void 0,he=C.mcpActivityId??null,{data:st=[]}=hs({enabled:i&&m&&me&&!!he,clientIds:O??[],limit:100}),ot=b.useMemo(()=>{if(!he)return null;const p=st.find(k=>k.activityId===he);if(!p)return"Selected conversation";const v=p.title?.trim();return v||(p.activityKind==="session"?"MCP session":p.clientId)},[he,st]),q=C.agentId,Y=C.schedule,{data:at=[]}=Us(q??void 0),it=b.useMemo(()=>!Y||!q?null:at.find(v=>v.id===Y)?.description?.trim()||"Scheduled task",[q,Y,at]),{data:qt}=vs(i&&m?e:null,o),{data:Yt}=ys(h&&!He?t:null,o),ct=m?qt:Yt,Re=b.useMemo(()=>{const p=new Map;for(const v of ct||[]){const k=v.automation_name??"__global__";p.has(k)||p.set(k,{automationName:v.automation_name??null,classifiers:[]});const E=p.get(k),D=v.attribute_values||{},M=Object.keys(D);let ge=null;const Z={};for(const[X,W]of Object.entries(D))if(W.parent)for(const[Le,J]of Object.entries(W.parent))ge=Le,Z[J]||(Z[J]=[]),Z[J].push(X);const B=E.classifiers.find(X=>X.slug===v.slug);if(B){const X=new Set([...B.values,...M]);B.values=[...X];for(const[W,Le]of Object.entries(Z)){B.valuesByParentValue[W]||(B.valuesByParentValue[W]=[]);const J=new Set([...B.valuesByParentValue[W],...Le]);B.valuesByParentValue[W]=[...J]}ge&&(B.parentSlug=ge)}else E.classifiers.push({slug:v.slug,name:v.name,values:M,parentSlug:ge,valuesByParentValue:Z})}for(const v of p.values())v.classifiers.sort((k,E)=>k.parentSlug===null&&E.parentSlug!==null?-1:k.parentSlug!==null&&E.parentSlug===null?1:0);return[...p.values()]},[ct]),Zt=gs(i&&m?e:null,o,C,t),Xt=xs(h?t:null,o,C),Jt=h?Xt:Zt,{data:V,isLoading:en,error:tn}=Jt,nn=b.useMemo(()=>V?.pages.flatMap(p=>p.content.map(v=>v.occurred_at)),[V]),rt=V?.pages[0],lt=(rt?.content.length??0)>0,sn=bs(i&&m?e:null,o,C,t),on=js(h?t:null,o,C),we=h?on:sn,an=we.data?.total??void 0,cn=we.data?.classification_stats,rn=we.isLoading,ln=!!(C.beforeOccurredAt||C.afterOccurredAt),dt=ks(C),ut=V?.pages[V.pages.length-1],Q=ut?.content[ut.content.length-1];b.useEffect(()=>{!dt||!Q||V?.pages.length===1||x.beforeOccurredAt===Q.occurred_at&&x.beforeId===Q.id||F({beforeOccurredAt:Q.occurred_at,beforeId:Q.id},{replace:!0})},[Q?.id,dt,F,V?.pages.length,Q,x.beforeOccurredAt,x.beforeId]);const dn=b.useCallback(()=>{w({beforeOccurredAt:void 0,beforeId:void 0,afterOccurredAt:void 0,afterId:void 0}),window.scrollTo({top:0,behavior:"smooth"})},[w]),un=(p,v)=>{w({dateRange:[p,v]})},mt=(p,v)=>{const k={...C.classificationFilters||{}};if(v.length>0)k[p]=v;else{delete k[p];for(const E of Re)for(const D of E.classifiers)D.parentSlug===p&&delete k[D.slug]}w({classificationFilters:k})},mn=(p,v)=>{const k=C.classificationFilters?.[p]||[];mt(p,k.includes(v)?k.filter(E=>E!==v):[...k,v])},fn=p=>mt(p,[]);if(tn)return n.jsx(Ss,{label:"knowledge"});const Me=!i||d&&l||m&&!e||en,ve={fields:[],chips:[]};for(const p of Re)for(const v of p.classifiers){const k=C.classificationFilters?.[v.slug]??[],E=v.parentSlug?C.classificationFilters?.[v.parentSlug]??[]:void 0,D=E?[...new Set(E.flatMap(M=>v.valuesByParentValue[M]??[]))]:v.values;D.length>0&&ve.fields.push({key:`clf:${v.slug}`,label:v.name,group:p.automationName??"Classifiers",icon:n.jsx(Ns,{className:"h-4 w-4"}),editor:Ne({searchPlaceholder:`Search ${v.name.toLowerCase()}...`,options:D.map(M=>({value:M,label:M,count:cn?.[v.slug]?.[M]})),selected:k,multiple:!0,onSelect:M=>mn(v.slug,M)})})}for(const[p,v]of Object.entries(C.classificationFilters??{})){if(v.length===0)continue;const k=Re.flatMap(E=>E.classifiers).find(E=>E.slug===p);ve.chips.push({id:`clf:${p}`,field:`clf:${p}`,label:k?.name??p,op:v.length>1?"is any of":"is",value:v.join(", "),onRemove:()=>fn(p)})}const pn=[C.contentIds?.length?xe({id:"contentIds",label:C.contentIds.length>1?"Events":"Event",value:`#${C.contentIds.join(", #")}`,onRemove:()=>w({contentIds:void 0})}):null,ot?xe({id:"mcpActivityId",label:"Conversation",value:ot,onRemove:()=>w({mcpActivityId:void 0})}):null,nt?xe({id:"clientIds",label:"Connected app",value:nt,sourceLink:Ht,details:O&&O.length>0?n.jsx(qs,{ownerSlug:t,clientIds:O,linkedUser:pe?.linkedUser,linkedUserEntitySlug:pe?.linkedUserEntitySlug}):void 0,onRemove:()=>w({clientIds:void 0})}):null,it?xe({id:"schedule",label:"Schedule",value:it,sourceLink:t&&q&&Y?Hs(t,q,Y):void 0,onRemove:()=>w({schedule:void 0,runIds:void 0})}):null,...ve.chips].filter(p=>p!=null),hn=!!(m&&o&&e),ye=c&&I&&!le?c:void 0,ft={filterActions:u||ye?.filterActions?n.jsxs(n.Fragment,{children:[u?n.jsx(vo,{kinds:x.semanticTypes,onFiltersChange:w}):null,ye?.filterActions]}):void 0,filterTrailing:hn?n.jsxs(ie,{variant:"ghost",size:"sm",className:"h-8 text-muted-foreground","aria-pressed":G,onClick:()=>T(p=>!p),children:[n.jsx(_s,{className:"mr-1.5 h-3.5 w-3.5"}),"Timeline"]}):void 0,onClearFilters:ze,notificationsFirst:j?I:void 0,filters:C,onFiltersChange:w,eventKinds:zt,searchQuery:L,onSearchChange:p=>{U.current=!0,P(p)},extraFields:ve.fields,drillChips:pn,total:an,isListLoading:Me,isTotalLoading:rn,hasCursorInUrl:ln&&lt,onGoToLatest:dn},vn=!Me&&!!rt&&!lt&&!le,yn=d?m?"Activity is the workspace's live feed — every message, email, file, and record a connector pulls in lands here as an event. Connect your data to start collecting.":"Activity is the workspace's live feed of connector events. Join this workspace to add connectors and collect knowledge here.":"No public knowledge items are available yet",pt=!!(m&&t);return n.jsx(Cs,{children:n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:s?"sticky top-0 z-10 -mx-4 bg-background px-4 pb-2 lg:-mx-6 lg:px-6":void 0,children:s&&t?n.jsx(Vt,{...ft,ownerSlug:t}):n.jsx(Ut,{...ft})}),G&&m&&o&&e&&n.jsx(po,{entityId:o,organizationId:e,ownerSlug:t||"",eventTimes:nn,selectedRange:C.dateRange||void 0,onSelectRange:un}),ye?.pinned,Me?n.jsx("div",{className:"space-y-4",children:["skeleton-1","skeleton-2","skeleton-3","skeleton-4","skeleton-5"].map(p=>n.jsx(Lt,{className:"h-32 rounded-lg"},p))}):vn?f??n.jsx(yt,{icon:gt,title:"No activity yet",description:yn,actionLabel:pt?"Add a connector":void 0,onAction:pt&&t?()=>void y({to:"/$owner/connectors/create",params:{owner:t}}):void 0}):n.jsx(Ms,{onFiltersChange:w,organizationId:e,ownerSlug:t,entityId:o,filters:C,showEntityLinks:He,foldConsecutiveCalls:!0,groupByConversation:!0,hiddenApprovalRunIds:ye?.hiddenApprovalRunIds,emptyState:n.jsx(yt,{icon:gt,title:"No results found",description:"Try adjusting your filters to find what you are looking for",actionLabel:le?"Clear filters":void 0,onAction:le?ze:void 0})})]})})}function go({record:e,ownerSlug:t}){const o=ce(),s=z(),{filters:a,updateFilters:c}=Bt({parse:Ce,serialize:Be,filterKeys:Dt,replace:!1,merge:$t}),f=De({...a,platforms:void 0,connectionIds:void 0,feedIds:void 0})||a.sortBy!=null&&a.sortBy!=="date"||a.sortOrder!=null&&a.sortOrder!=="desc",u=()=>{s({...Ke(t,o.search??{}),...o.pathname.startsWith(`/${t}/events/`)?{}:{to:o.pathname}})};return n.jsxs("div",{className:"space-y-4",children:[n.jsx(Vt,{ownerSlug:t,sourceRead:!0,filters:a,onFiltersChange:c,searchQuery:a.searchQuery??"",onSearchChange:d=>c({searchQuery:d}),onClearFilters:u}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Live activity supports connector, connection and feed filters. Search and other event filters are available for saved activity."}),f?n.jsxs("div",{role:"alert",className:"space-y-2 rounded-md border p-3 text-sm",children:[n.jsx("p",{children:"Some selected filters aren't supported for live activity. Clear them to see results."}),n.jsx(ie,{variant:"outline",size:"sm",onClick:()=>{const d=Be({platforms:a.platforms,connectionIds:a.connectionIds,feedIds:a.feedIds}),i={...Ke(t,o.search??{}).search,...d};s({to:o.pathname,search:i})},children:"Clear unsupported filters"})]}):n.jsx(Os,{record:e,orgContext:{slug:t},filters:a})]})}function Eo({entity:e,organizationId:t,ownerSlug:o}){const s=e.is_derived?n.jsx(go,{ownerSlug:o,record:{type:e.entity_type,key:e.slug}}):n.jsx(yo,{organizationId:t,ownerSlug:o,entityId:e.id,hideSourceFilter:!0,changesShortcut:!0});return n.jsx(Bs,{organizationId:t,children:e.entity_type==="$member"?n.jsx(Ds,{children:s}):s})}export{yo as E,Bs as M,Eo as R};
2
+ //# sourceMappingURL=record-activity-C9KfBkXb.js.map
@@ -0,0 +1,2 @@
1
+ import{j as e,u as R,ez as S,ep as k,eq as I,er as N,es as b,ev as w,ew as F,B as v,dF as A,cT as P,a$ as z}from"./index-DYCqXaMf.js";import{g as y,l as L,S as C,D as M}from"./schema-value-normalization-CylKX3PK.js";import{R as O,s as B}from"./events-feed-DsrkV2ix.js";import{u as q}from"./record-session-BizRugWs.js";const D=3;function H(s,t,a,o){const d=$(s.schema,t),r=y(t,d??{});return{href:"",key:`record-field:${s.entity.id}:${t}${a===void 0?"":`:${a}`}`,title:a===void 0?r:o?`${r} ${a+1} of ${o}`:`${r} ${a+1}`,recordField:{entityId:s.entity.id,field:t,row:a}}}function $(s,t){return s?.properties?.[t]}function J({target:s}){const t=q(s.entityId),a=$(t?.schema,s.field);return t?a?e.jsx("div",{className:"space-y-3 px-5 py-4",children:s.row===void 0?e.jsx(V,{session:t,field:s.field,prop:a}):e.jsx(_,{session:t,field:s.field,prop:a,row:s.row})}):e.jsx("p",{className:"px-5 py-5 text-sm text-muted-foreground",children:"This field is no longer part of the record's type."}):e.jsx("p",{className:"px-5 py-5 text-sm text-muted-foreground",children:"This record is no longer open. Open it again to see this field."})}function V({session:s,field:t,prop:a}){const o=R(),{record:d,editing:r}=s,i=d.values.metadata[t],n=Array.isArray(i)?i:[],m=Object.entries(a.items?.properties??{}),h=(i==null||Array.isArray(i))&&m.length>0&&n.every(S),u=y(t,a),p=a.maxItems===void 0||n.length<a.maxItems,x=e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Field of ",s.entity.name," · ",n.length," ",n.length===1?"item":"items",h&&n.length>0?" · open an item for every field":""]});if(!h)return e.jsxs(e.Fragment,{children:[x,r?e.jsx(L,{fieldPath:`peek.${t}`,fieldKey:t,prop:a,value:i,onChange:l=>d.setMetadataField(t,l),isRequired:!1,readonly:!1,orgContext:s.orgContext,ariaLabel:u}):e.jsx("div",{className:"text-sm",children:e.jsx(C,{value:i,prop:a})})]});const j=m.slice(0,D),f=(l,c=n.length)=>o?.open(H(s,t,l,c));return e.jsxs(e.Fragment,{children:[x,n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No items yet."}):e.jsx("div",{className:"rounded-md border",children:e.jsxs(k,{children:[e.jsx(I,{children:e.jsxs(N,{children:[j.map(([l,c])=>e.jsx(b,{children:y(l,c)},l)),e.jsx(b,{className:"w-10",children:e.jsx("span",{className:"sr-only",children:"Open"})})]})}),e.jsx(w,{children:n.map((l,c)=>e.jsxs(N,{className:"cursor-pointer",onClick:()=>f(c),children:[j.map(([g,T])=>e.jsx(F,{className:"max-w-[10rem] truncate",children:e.jsx(C,{value:l[g],prop:T})},g)),e.jsx(F,{children:e.jsx(v,{type:"button",variant:"ghost",size:"icon",className:"size-7","aria-label":`Open ${u} ${c+1}`,onClick:g=>{g.stopPropagation(),f(c)},children:e.jsx(A,{className:"h-4 w-4"})})})]},c))})]})}),r?e.jsxs(v,{type:"button",variant:"outline",size:"sm",disabled:!p,onClick:()=>{d.setMetadataField(t,[...n,{}]),f(n.length,n.length+1)},children:[e.jsx(P,{className:"mr-1.5 h-4 w-4"}),"Add item"]}):null]})}function _({session:s,field:t,prop:a,row:o}){const d=R(),{record:r,editing:i}=s,n=r.values.metadata[t],m=Array.isArray(n)?n:[],h=m[o],u=a.minItems===void 0||m.length>a.minItems;return S(h)?i?e.jsxs(e.Fragment,{children:[e.jsx(M,{schema:a.items,values:h,onValuesChange:p=>r.setMetadataField(t,m.map((x,j)=>j===o?p:x)),orgContext:s.orgContext}),e.jsxs(v,{type:"button",variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",disabled:!u,onClick:()=>{r.setMetadataField(t,m.filter((p,x)=>x!==o)),d?.back?.()},children:[e.jsx(z,{className:"mr-1.5 h-4 w-4"}),"Remove item"]})]}):e.jsx(O,{fields:B(a.items),values:h,context:{ownerSlug:s.ownerSlug,orgContext:s.orgContext}}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"This item is no longer in the list."})}export{J as R,H as r};
2
+ //# sourceMappingURL=record-field-peek-BBZcRuGT.js.map
@@ -0,0 +1,2 @@
1
+ import{r as s,j as c}from"./index-DYCqXaMf.js";function u(){const o=new Map,e=new Set,n=()=>{for(const t of e)t()};return{get:t=>o.get(t),set:t=>{o.get(t.entity.id)!==t&&(o.set(t.entity.id,t),n())},remove:t=>{o.delete(t)&&n()},subscribe:t=>(e.add(t),()=>e.delete(t))}}const r=s.createContext(null);function d({children:o}){const[e]=s.useState(u);return c.jsx(r.Provider,{value:e,children:o})}function f(o){const e=s.useContext(r);s.useLayoutEffect(()=>{e?.set(o)});const n=o.entity.id;s.useEffect(()=>()=>e?.remove(n),[e,n])}const i=()=>()=>{};function S(o){const e=s.useContext(r);return s.useSyncExternalStore(e?.subscribe??i,()=>e?.get(o),()=>e?.get(o))}export{d as R,f as a,S as u};
2
+ //# sourceMappingURL=record-session-BizRugWs.js.map
@@ -1,2 +1,2 @@
1
- import{U as v,r as o,j as e,L as h,V as j,H as y,W as N}from"./index-Cr5hwh-C.js";import{C as k,a as C,b as S,c as L}from"./card-Djgp00r_.js";function R(){const{token:n,error:x}=v.useSearch(),[a,p]=o.useState(""),[i,f]=o.useState(""),[d,s]=o.useState(null),[l,c]=o.useState(!1),[u,g]=o.useState(!1),w=async t=>{if(t.preventDefault(),!n){s("This reset link is invalid or expired.");return}if(a.length<8){s("Password must be at least 8 characters.");return}if(a!==i){s("Passwords do not match.");return}c(!0),s(null);try{const r=await j(`${y}/api/auth/reset-password`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({token:n,newPassword:a})});if(!r.ok)throw await N(r);g(!0)}catch(r){s(r instanceof Error?r.message:"Failed to reset password")}finally{c(!1)}},b=!n||x==="INVALID_TOKEN",m={callbackUrl:void 0,mode:void 0,error:void 0,errorDescription:void 0,loginHint:void 0,invitationOrg:void 0,intent:void 0};return e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-md p-8",children:[e.jsx("img",{src:"/lobu-logo.svg",alt:"Lobu",className:"mx-auto mb-6 h-8 w-auto"}),e.jsxs(k,{children:[e.jsx(C,{children:e.jsx(S,{asChild:!0,children:e.jsx("h1",{className:"text-center text-2xl",children:"Reset your password"})})}),e.jsx(L,{children:b&&!u?e.jsxs("div",{className:"mt-6 space-y-4 text-center",children:[e.jsx("p",{className:"text-sm text-destructive",children:"This reset link is invalid or expired."}),e.jsx(h,{to:"/auth/login",search:m,className:"text-sm text-primary hover:underline",children:"Back to sign in"})]}):u?e.jsxs("div",{className:"mt-6 space-y-4 text-center",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your password has been reset successfully."}),e.jsx(h,{to:"/auth/login",search:m,className:"text-sm text-primary hover:underline",children:"Continue to sign in"})]}):e.jsxs("form",{onSubmit:w,className:"mt-6 space-y-4",children:[d&&e.jsx("div",{className:"p-3 text-sm text-destructive bg-destructive/10 rounded-lg",children:d}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"new-password",className:"block text-sm font-medium",children:"New password"}),e.jsx("input",{id:"new-password",type:"password",value:a,onChange:t=>p(t.target.value),minLength:8,required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium",children:"Confirm new password"}),e.jsx("input",{id:"confirm-password",type:"password",value:i,onChange:t=>f(t.target.value),minLength:8,required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsx("button",{type:"submit",disabled:l,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:l?"Resetting password...":"Reset password"})]})})]})]})})}export{R as component};
2
- //# sourceMappingURL=reset-password-uX_V6bip.js.map
1
+ import{V as v,r as o,j as e,L as h,W as j,J as y,Y as N}from"./index-DYCqXaMf.js";import{C as k,a as C,b as S,c as L}from"./card-yU0TmNRH.js";function R(){const{token:n,error:x}=v.useSearch(),[a,p]=o.useState(""),[i,f]=o.useState(""),[d,s]=o.useState(null),[l,c]=o.useState(!1),[u,g]=o.useState(!1),w=async t=>{if(t.preventDefault(),!n){s("This reset link is invalid or expired.");return}if(a.length<8){s("Password must be at least 8 characters.");return}if(a!==i){s("Passwords do not match.");return}c(!0),s(null);try{const r=await j(`${y}/api/auth/reset-password`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({token:n,newPassword:a})});if(!r.ok)throw await N(r);g(!0)}catch(r){s(r instanceof Error?r.message:"Failed to reset password")}finally{c(!1)}},b=!n||x==="INVALID_TOKEN",m={callbackUrl:void 0,mode:void 0,error:void 0,errorDescription:void 0,loginHint:void 0,invitationOrg:void 0,intent:void 0};return e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-md p-8",children:[e.jsx("img",{src:"/lobu-logo.svg",alt:"Lobu",className:"mx-auto mb-6 h-8 w-auto"}),e.jsxs(k,{children:[e.jsx(C,{children:e.jsx(S,{asChild:!0,children:e.jsx("h1",{className:"text-center text-2xl",children:"Reset your password"})})}),e.jsx(L,{children:b&&!u?e.jsxs("div",{className:"mt-6 space-y-4 text-center",children:[e.jsx("p",{className:"text-sm text-destructive",children:"This reset link is invalid or expired."}),e.jsx(h,{to:"/auth/login",search:m,className:"text-sm text-primary hover:underline",children:"Back to sign in"})]}):u?e.jsxs("div",{className:"mt-6 space-y-4 text-center",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your password has been reset successfully."}),e.jsx(h,{to:"/auth/login",search:m,className:"text-sm text-primary hover:underline",children:"Continue to sign in"})]}):e.jsxs("form",{onSubmit:w,className:"mt-6 space-y-4",children:[d&&e.jsx("div",{className:"p-3 text-sm text-destructive bg-destructive/10 rounded-lg",children:d}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"new-password",className:"block text-sm font-medium",children:"New password"}),e.jsx("input",{id:"new-password",type:"password",value:a,onChange:t=>p(t.target.value),minLength:8,required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium",children:"Confirm new password"}),e.jsx("input",{id:"confirm-password",type:"password",value:i,onChange:t=>f(t.target.value),minLength:8,required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsx("button",{type:"submit",disabled:l,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:l?"Resetting password...":"Reset password"})]})})]})]})})}export{R as component};
2
+ //# sourceMappingURL=reset-password-DqfcSn8M.js.map
@@ -0,0 +1,2 @@
1
+ import{j as e,Q as g,i7 as T,S as r,r as i,cG as w,a2 as A}from"./index-DYCqXaMf.js";import{F,o as P}from"./filter-editors-B1_QUpg_.js";import{R as E}from"./runs-table-D_8QlCCN.js";const v=[{value:"all",label:"All"},{value:"sync",label:"Sync",runTypes:["sync"]},{value:"action",label:"Action",runTypes:["action"]},{value:"auth",label:"Auth",runTypes:["auth"]}];function B(s){return v.find(n=>n.value===s)?.runTypes}const h=[{value:"running",label:"Running"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"pending",label:"Pending"}];function I({bucket:s,status:n,onBucketChange:t,onStatusChange:l}){return e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"inline-flex rounded-md border bg-muted/30 p-0.5 text-sm",children:v.map(a=>e.jsx("button",{type:"button",onClick:()=>t(a.value),className:g("rounded px-3 py-1 transition-colors",s===a.value?"bg-background text-foreground ":"text-muted-foreground hover:text-foreground"),children:a.label},a.value))}),e.jsx(F,{label:"Run filters",className:"flex-1",fields:[{key:"status",label:"Status",icon:e.jsx(T,{className:"h-4 w-4"}),editor:P({searchPlaceholder:"Search statuses...",options:h,selected:n==="all"?[]:[n],onSelect:l})}],chips:n==="all"?[]:[{id:"status",label:"Status",op:"is",value:h.find(a=>a.value===n)?.label??n,onRemove:()=>l("all")}]})]})}function C({labels:s,className:n}){return e.jsx("div",{className:g("inline-flex rounded-md border bg-muted/30 p-0.5 text-sm",n),children:s.map((t,l)=>e.jsx("span",{className:l===0?"rounded bg-background px-3 py-1 text-foreground ":"px-3 py-1 text-muted-foreground",children:t},t))})}function b({rows:s=6}){return e.jsxs("div",{className:"rounded-lg border",role:"status","aria-label":"Loading runs",children:[e.jsx("div",{className:"border-b px-3 py-2",children:e.jsx(r,{className:"h-3 w-1/4"})}),e.jsx("div",{className:"divide-y",children:Array.from({length:s}).map((n,t)=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5",children:[e.jsx(r,{className:"h-3.5 w-3.5 rounded-full shrink-0"}),e.jsx(r,{className:"h-3 w-20"}),e.jsx(r,{className:"h-3 w-16"}),e.jsx(r,{className:"ml-auto h-3 w-12 shrink-0"}),e.jsx(r,{className:"h-7 w-7 rounded-md shrink-0"})]},t))})]})}function U({rows:s=6}){return e.jsxs("div",{className:"space-y-4",role:"status","aria-label":"Loading runs",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(C,{labels:["All","Sync","Action","Auth"]}),e.jsx("div",{className:"h-9 w-[150px] rounded-md border border-input"})]}),e.jsx(b,{rows:s})]})}function _({scope:s,ownerSlug:n}){const[t,l]=i.useState("all"),[a,j]=i.useState("all"),N=i.useMemo(()=>({runTypes:B(t),status:a==="all"?void 0:a}),[t,a]),{data:u,isLoading:y,isError:S,hasNextPage:d,isFetchingNextPage:c,fetchNextPage:x}=w(s,N,n),m=i.useMemo(()=>u?.pages.flatMap(o=>o.runs)??[],[u]),R={runType:t==="all",feed:!0,connection:"deviceId"in s||"connectorKey"in s},p=i.useRef(null);return i.useEffect(()=>{const o=p.current;if(!o||!d)return;const f=new IntersectionObserver(k=>{k[0]?.isIntersecting&&!c&&x()},{rootMargin:"200px"});return f.observe(o),()=>f.disconnect()},[d,c,x]),e.jsxs("div",{className:"space-y-3",children:[e.jsx(I,{bucket:t,status:a,onBucketChange:l,onStatusChange:j}),y?e.jsx(b,{}):S?e.jsx("p",{className:"rounded-lg border bg-destructive/5 px-3 py-6 text-center text-xs text-destructive",children:"Failed to load runs."}):m.length===0?e.jsx("p",{className:"rounded-lg border bg-muted/20 px-3 py-6 text-center text-xs text-muted-foreground",children:t==="all"&&a==="all"?"No runs yet.":"No runs match these filters."}):e.jsxs(e.Fragment,{children:[e.jsx(E,{runs:m,ownerSlug:n,columns:R}),e.jsx("div",{ref:p,className:"h-1"}),c&&e.jsx("div",{className:"flex justify-center py-3",children:e.jsx(A,{size:"lg",className:"text-muted-foreground"})})]})]})}export{_ as R,U as a};
2
+ //# sourceMappingURL=runs-panel-T1ZxTVz6.js.map
@@ -0,0 +1,2 @@
1
+ import{j as e,Q as l,i8 as u,B as b,L as N,cW as w,dK as k,dL as v,dN as T,i9 as C,ia as _,ep as S,eq as V,er as p,es as n,ev as R,ew as i,bd as L,dY as D,P as B,ib as E,e1 as P,ab as I,a2 as M,be as O,r as h,dr as m,dt as g,ds as j}from"./index-DYCqXaMf.js";const A=u("inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors",{variants:{status:{active:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",paused:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",error:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",pending:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",rejected:"bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",default:"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"}},defaultVariants:{status:"default"}}),F=u("h-1.5 w-1.5 rounded-full",{variants:{status:{active:"bg-green-500",paused:"bg-yellow-500",error:"bg-red-500",pending:"bg-blue-500",rejected:"bg-gray-500",default:"bg-gray-500"}},defaultVariants:{status:"default"}});function H({className:t,status:a,showDot:r=!0,children:x,...s}){return e.jsxs("span",{className:l(A({status:a}),t),...s,children:[r&&e.jsx("span",{className:F({status:a})}),x]})}function W(t,a){switch(a.kind){case"connection":return _(t,a.id);case"feed":return C(t,a.id);case"run":return{to:"/$owner/events",params:{owner:t},search:{run_ids:String(a.id)}}}}function q({ownerSlug:t,scope:a,variant:r="outline",iconOnly:x=!1,label:s,className:c,title:f}){const d=W(t,a),y=f??s??"View in memory",o=e.jsx(b,{asChild:!0,variant:r,size:x?"icon":"sm",className:l(x&&"h-7 w-7",c),children:e.jsxs(N,{to:d.to,params:d.params,search:d.search,children:[e.jsx(w,{className:l("h-3.5 w-3.5",!x&&"mr-1.5")}),!x&&(s??"View in memory")]})});return x?e.jsxs(k,{children:[e.jsx(v,{asChild:!0,children:o}),e.jsx(T,{children:y})]}):o}const z=new Set(["error","failed","revoked"]);function J(t){return t==="active"?"active":t==="paused"?"paused":t==="pending"||t==="pending_auth"?"pending":z.has(t)?"error":"default"}function K({status:t}){return t==="completed"?e.jsx(P,{className:"h-3.5 w-3.5 text-green-500"}):t==="failed"?e.jsx(I,{className:"h-3.5 w-3.5 text-destructive"}):t==="running"?e.jsx(M,{className:"text-blue-500"}):e.jsx(O,{className:"h-3.5 w-3.5 text-muted-foreground"})}function Q({error:t}){const[a,r]=h.useState(!1);return t.length>80?e.jsxs(m,{open:a,onOpenChange:r,children:[e.jsx(g,{asChild:!0,children:e.jsx("button",{type:"button",className:"text-left text-destructive truncate max-w-[200px] hover:underline",children:t})}),e.jsx(j,{className:"w-96 max-h-64 overflow-auto",children:e.jsx("pre",{className:"text-xs whitespace-pre-wrap break-words text-destructive",children:t})})]}):e.jsx("span",{className:"text-destructive",children:t})}function U({checkpoint:t}){const[a,r]=h.useState(!1);return e.jsxs(m,{open:a,onOpenChange:r,children:[e.jsx(g,{asChild:!0,children:e.jsx("button",{type:"button",className:"text-left text-muted-foreground hover:underline",children:"view"})}),e.jsx(j,{className:"w-80 max-h-64 overflow-auto",children:e.jsx("pre",{className:"text-xs whitespace-pre-wrap break-words",children:JSON.stringify(t,null,2)})})]})}function X(t){return t.feed_display_name??t.feed_key??"—"}function $({runs:t,ownerSlug:a,columns:r={}}){const x=t.some(s=>s.checkpoint);return e.jsx("div",{className:"rounded-lg border",children:e.jsxs(S,{children:[e.jsx(V,{children:e.jsxs(p,{children:[e.jsx(n,{className:"text-xs py-1.5 px-3 w-8"}),e.jsx(n,{className:"text-xs py-1.5 px-3",children:"When"}),r.runType&&e.jsx(n,{className:"text-xs py-1.5 px-3",children:"Type"}),r.connection&&e.jsx(n,{className:"text-xs py-1.5 px-3",children:"Connection"}),r.feed&&e.jsx(n,{className:"text-xs py-1.5 px-3",children:"Feed"}),e.jsx(n,{className:"text-xs py-1.5 px-3",children:"Status"}),e.jsx(n,{className:"text-xs py-1.5 px-3",children:"Items"}),e.jsx(n,{className:"text-xs py-1.5 px-3",children:"Duration"}),e.jsx(n,{className:"text-xs py-1.5 px-3",children:"Version"}),x&&e.jsx(n,{className:"text-xs py-1.5 px-3",children:"Checkpoint"}),e.jsx(n,{className:"text-xs py-1.5 px-3",children:"Error"}),e.jsx(n,{className:"text-xs py-1.5 px-3 w-8"})]})}),e.jsx(R,{children:t.map(s=>{const c=s.completed_at?Math.round((new Date(s.completed_at).getTime()-new Date(s.created_at).getTime())/1e3):null;return e.jsxs(p,{children:[e.jsx(i,{className:"py-1.5 px-3",children:e.jsx(K,{status:s.status})}),e.jsx(i,{className:"py-1.5 px-3 text-xs text-muted-foreground",title:D(s.created_at),children:L(s.created_at)}),r.runType&&e.jsx(i,{className:"py-1.5 px-3 text-xs",children:e.jsx(B,{variant:"secondary",className:"font-mono text-[10px]",children:s.run_type??"—"})}),r.connection&&e.jsx(i,{className:"py-1.5 px-3 text-xs text-muted-foreground",children:s.connection_display_name??"—"}),r.feed&&e.jsx(i,{className:"py-1.5 px-3 text-xs text-muted-foreground",children:X(s)}),e.jsx(i,{className:"py-1.5 px-3 text-xs",children:e.jsx(H,{status:J(s.status),children:s.status})}),e.jsx(i,{className:"py-1.5 px-3 text-xs font-mono text-muted-foreground",children:s.items_collected??"—"}),e.jsx(i,{className:"py-1.5 px-3 text-xs text-muted-foreground",children:c!=null?E(c):"—"}),e.jsx(i,{className:"py-1.5 px-3 text-xs font-mono text-muted-foreground",children:s.connector_version??"—"}),x&&e.jsx(i,{className:"py-1.5 px-3 text-xs",children:s.checkpoint?e.jsx(U,{checkpoint:s.checkpoint}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(i,{className:"py-1.5 px-3 text-xs",children:s.error_message?e.jsx(Q,{error:s.error_message}):""}),e.jsx(i,{className:"py-1.5 px-3 text-right",children:e.jsx(q,{ownerSlug:a,scope:{kind:"run",id:s.id},variant:"ghost",iconOnly:!0,title:"View events from this run"})})]},s.id)})})]})})}export{$ as R,H as S,q as V,J as g};
2
+ //# sourceMappingURL=runs-table-D_8QlCCN.js.map