@lobu/runtime-server 24.1.1 → 24.3.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 (322) hide show
  1. package/dist/catalogs/connectors.json +175 -39
  2. package/dist/catalogs/skills.json +2 -2
  3. package/dist/component.json +1 -1
  4. package/dist/connectors/gchat.ts +31 -1
  5. package/dist/connectors/google_gmail.ts +70 -41
  6. package/dist/connectors/google_gmail_references.ts +406 -0
  7. package/dist/connectors/linkedin-inbox-adapter.js +107 -36
  8. package/dist/connectors/linkedin-inbox.ts +13 -0
  9. package/dist/connectors/linkedin.ts +1 -1
  10. package/dist/connectors/postgres.ts +14 -8
  11. package/dist/connectors/reddit.ts +171 -5
  12. package/dist/connectors/whatsapp-web-adapter.js +147 -61
  13. package/dist/connectors/whatsapp-web-helpers.ts +6 -2
  14. package/dist/connectors/whatsapp_web.ts +48 -17
  15. package/dist/connectors/x-dm-adapter.js +252 -35
  16. package/dist/connectors/x.ts +189 -13
  17. package/dist/db/migrations/20261020140000_view_attachments_by_page.sql +3 -1
  18. package/dist/db/migrations/20261024050000_events_source_reference_arrival.sql +27 -0
  19. package/dist/db/migrations/20261026000000_turn_write_receipts.sql +36 -0
  20. package/dist/db/migrations/20261026190000_federated_relationship_endpoints.sql +143 -0
  21. package/dist/dependencies.bun.lock +137 -202
  22. package/dist/embeddings-server.mjs +81 -11
  23. package/dist/guest.bundle.js +62 -25
  24. package/dist/owletto/dist/assets/_-XKF0m81R.js +3 -0
  25. package/dist/owletto/dist/assets/_-e8MbEBtw.js +2 -0
  26. package/dist/owletto/dist/assets/_agentId-Cv9goIFf.js +2 -0
  27. package/dist/owletto/dist/assets/_agentId-emObu67X.js +2 -0
  28. package/dist/owletto/dist/assets/_automationId-CfFFAYK1.js +2 -0
  29. package/dist/owletto/dist/assets/_connectorKey._connectionId-D6NKXSOE.js +2 -0
  30. package/dist/owletto/dist/assets/_connectorKey.index-DFrkLLTU.js +2 -0
  31. package/dist/owletto/dist/assets/_conversationId-D3vuAQPe.js +2 -0
  32. package/dist/owletto/dist/assets/_eventId-BV5SQaUA.js +2 -0
  33. package/dist/owletto/dist/assets/_name-DjtJMop4.js +2 -0
  34. package/dist/owletto/dist/assets/_owner-oBX68rb9.js +3 -0
  35. package/dist/owletto/dist/assets/_shape-C4lLPAwI.js +2 -0
  36. package/dist/owletto/dist/assets/_skillKey-Cw-7q6hI.js +2 -0
  37. package/dist/owletto/dist/assets/_slug-B2g5qzn3.js +2 -0
  38. package/dist/owletto/dist/assets/_viewKey-CIKGCtdK.js +2 -0
  39. package/dist/owletto/dist/assets/_viewKey-Dx4kJo7o.js +2 -0
  40. package/dist/owletto/dist/assets/accept-invitation-38lHBvjO.js +2 -0
  41. package/dist/owletto/dist/assets/activity-route-view-voRYSM3a.js +2 -0
  42. package/dist/owletto/dist/assets/agent-card-controls-DiU7Un5w.js +2 -0
  43. package/dist/owletto/dist/assets/{agent-client-setup-list-BlXB4SE5.js → agent-client-setup-list-Bkyw22GW.js} +4 -4
  44. package/dist/owletto/dist/assets/agent-connect-pages-CpBxQCpx.js +2 -0
  45. package/dist/owletto/dist/assets/{agent-editor-form-DsSoeQeF.js → agent-editor-form-QrIDroFL.js} +2 -2
  46. package/dist/owletto/dist/assets/agent-guardrails-route-CyoGSxcZ.js +2 -0
  47. package/dist/owletto/dist/assets/{agent-loading-shells-B7v6Cffw.js → agent-loading-shells-CamDtzHY.js} +2 -2
  48. package/dist/owletto/dist/assets/agent-permissions-matrix-CgsQ8BK_.js +2 -0
  49. package/dist/owletto/dist/assets/{agent-skill-context-DFucg4c4.js → agent-skill-context-lWbXKEm1.js} +2 -2
  50. package/dist/owletto/dist/assets/agent-skills-route-D-w3tY_2.js +2 -0
  51. package/dist/owletto/dist/assets/agent-subpage-shell-CLqpn5Tb.js +2 -0
  52. package/dist/owletto/dist/assets/{agent-thread-D38STyeu.js → agent-thread-CsRexwTv.js} +4 -4
  53. package/dist/owletto/dist/assets/agents-DzH_FFKU.js +2 -0
  54. package/dist/owletto/dist/assets/agents-workbench-CmGrMvPC.js +2 -0
  55. package/dist/owletto/dist/assets/app-bridge-C4nPtae3.js +121 -0
  56. package/dist/owletto/dist/assets/app._appId-BO7G38fL.js +2 -0
  57. package/dist/owletto/dist/assets/automation-detail-content-DMYxs6F6.js +2 -0
  58. package/dist/owletto/dist/assets/automations-DzH_FFKU.js +2 -0
  59. package/dist/owletto/dist/assets/calendar-DDCCSPW6.js +2 -0
  60. package/dist/owletto/dist/assets/callback-DFciMR8u.js +2 -0
  61. package/dist/owletto/dist/assets/{card-jzhQrMDP.js → card-BCsbrdGs.js} +2 -2
  62. package/dist/owletto/dist/assets/{claim-B-wq745Q.js → claim-BRua2b_7.js} +2 -2
  63. package/dist/owletto/dist/assets/client-activity-scopes-BLIy1Zc3.js +2 -0
  64. package/dist/owletto/dist/assets/client-rows-DiJQ5D1z.js +2 -0
  65. package/dist/owletto/dist/assets/clients-8-EpRjsm.js +2 -0
  66. package/dist/owletto/dist/assets/{code-editor-CEqoCky-.js → code-editor-BFZa4EIt.js} +3 -3
  67. package/dist/owletto/dist/assets/connect-C0cHE9Xl.js +2 -0
  68. package/dist/owletto/dist/assets/connect-menu-D2K4tmvW.js +2 -0
  69. package/dist/owletto/dist/assets/connect._clientId-D4EG5a0v.js +2 -0
  70. package/dist/owletto/dist/assets/connected._clientId-DhoCT6sT.js +2 -0
  71. package/dist/owletto/dist/assets/connected._clientId.activity-Dn4qw2Us.js +2 -0
  72. package/dist/owletto/dist/assets/connected._clientId.index-BTI5JXA3.js +2 -0
  73. package/dist/owletto/dist/assets/connection-X9VU9Ijm.js +2 -0
  74. package/dist/owletto/dist/assets/connection-feed-detail-B6ydKasK.js +2 -0
  75. package/dist/owletto/dist/assets/connections-browser-BMV8bf54.js +2 -0
  76. package/dist/owletto/dist/assets/connector-boxes-DqZA-FdG.js +2 -0
  77. package/dist/owletto/dist/assets/{connector-provenance-D-ECOlMJ.js → connector-provenance-BIg8P8WY.js} +2 -2
  78. package/dist/owletto/dist/assets/connector-scope-lists-CJYz53YF.js +2 -0
  79. package/dist/owletto/dist/assets/{connectors-CH4KBZyT.js → connectors-BroKpwhB.js} +2 -2
  80. package/dist/owletto/dist/assets/{consent-C9ZpHb7V.js → consent-fzLN-Qy7.js} +2 -2
  81. package/dist/owletto/dist/assets/copy-button-Df7QXE0w.js +2 -0
  82. package/dist/owletto/dist/assets/{core.esm-BupT3V0i.js → core.esm-A1UnFbGs.js} +2 -2
  83. package/dist/owletto/dist/assets/create-BjwsYarn.js +2 -0
  84. package/dist/owletto/dist/assets/create-Dzr4mlr0.js +2 -0
  85. package/dist/owletto/dist/assets/create-automation-form-DHW6OUoS.js +3 -0
  86. package/dist/owletto/dist/assets/create-c94SPL21.js +2 -0
  87. package/dist/owletto/dist/assets/create._connectorKey-DLLn2nej.js +2 -0
  88. package/dist/owletto/dist/assets/{cronstrue-CWImw-kf.js → cronstrue-xxpD1P2-.js} +2 -2
  89. package/dist/owletto/dist/assets/{device-D-7WBe9E.js → device-C3AEoL5c.js} +2 -2
  90. package/dist/owletto/dist/assets/{device-pin-tombstone-2U0UMu3_.js → device-pin-tombstone-B_te59GE.js} +2 -2
  91. package/dist/owletto/dist/assets/device._deviceId-ZU09qrot.js +2 -0
  92. package/dist/owletto/dist/assets/elk-worker.min-BENGc9gn.js +23 -0
  93. package/dist/owletto/dist/assets/{entity-avatar-mdh7Kq5D.js → entity-avatar-CEV4ttUQ.js} +2 -2
  94. package/dist/owletto/dist/assets/entity-options-DJv2EhVV.js +2 -0
  95. package/dist/owletto/dist/assets/entity-page-BUghWZ1s.js +2 -0
  96. package/dist/owletto/dist/assets/entity-type-page-Lf6ONdpf.js +2 -0
  97. package/dist/owletto/dist/assets/event-card-CBlsG32u.js +2 -0
  98. package/dist/owletto/dist/assets/event-detail-BKSGEOdW.js +2 -0
  99. package/dist/owletto/dist/assets/events-feed-VfU4csn2.js +2 -0
  100. package/dist/owletto/dist/assets/feed-event-kinds-BYuZCoU4.js +2 -0
  101. package/dist/owletto/dist/assets/filter-bar-COU0sBFQ.js +2 -0
  102. package/dist/owletto/dist/assets/{full-page-spinner-BVbcpW3R.js → full-page-spinner-C1Q_jEzD.js} +2 -2
  103. package/dist/owletto/dist/assets/guardrails-6ZJv1uzM.js +2 -0
  104. package/dist/owletto/dist/assets/identity-BaFLmbSo.js +2 -0
  105. package/dist/owletto/dist/assets/index-008wj-Pz.js +7950 -0
  106. package/dist/owletto/dist/assets/index-BaetvYLa.js +2 -0
  107. package/dist/owletto/dist/assets/index-BiEf5xOE.css +1 -0
  108. package/dist/owletto/dist/assets/{index-CxF2XXzl.js → index-BrDP4PCs.js} +2 -2
  109. package/dist/owletto/dist/assets/index-BuXIeK7D.js +2 -0
  110. package/dist/owletto/dist/assets/index-CAVcR9za.js +2 -0
  111. package/dist/owletto/dist/assets/index-CMLfWGPU.js +2 -0
  112. package/dist/owletto/dist/assets/index-D0YEYP7N.js +2 -0
  113. package/dist/owletto/dist/assets/index-DFyBbp7b.js +2 -0
  114. package/dist/owletto/dist/assets/{index-D7gHOpfg.js → index-DNtYqkiA.js} +2 -2
  115. package/dist/owletto/dist/assets/index-DQxzeM37.js +2 -0
  116. package/dist/owletto/dist/assets/index-DkO0nPex.js +2 -0
  117. package/dist/owletto/dist/assets/index-KlRId0g6.js +2 -0
  118. package/dist/owletto/dist/assets/index-Ywnqi4A6.js +2 -0
  119. package/dist/owletto/dist/assets/index-wHFQv1aT.js +12 -0
  120. package/dist/owletto/dist/assets/index-xnxhf3Op.js +2 -0
  121. package/dist/owletto/dist/assets/{index-BTlx9K_t.js → index-yIub2xUM.js} +2 -2
  122. package/dist/owletto/dist/assets/json-diff-LE_vNZrM.js +4 -0
  123. package/dist/owletto/dist/assets/{list-skeleton-CepswBka.js → list-skeleton-Kzxi2OXB.js} +2 -2
  124. package/dist/owletto/dist/assets/login-DWOT6jtS.js +2 -0
  125. package/dist/owletto/dist/assets/logout-Dt_VDilG.js +2 -0
  126. package/dist/owletto/dist/assets/{member-scope-gate-DD4YBFn-.js → member-scope-gate-De75CR7W.js} +2 -2
  127. package/dist/owletto/dist/assets/memory-browse-page-p2vIbfkC.js +74 -0
  128. package/dist/owletto/dist/assets/{model-selector-CDrAjH31.js → model-selector-3l9lY50C.js} +2 -2
  129. package/dist/owletto/dist/assets/model-udnQ_S43.js +2 -0
  130. package/dist/owletto/dist/assets/models-CQj7GIOp.js +2 -0
  131. package/dist/owletto/dist/assets/new-BOwIHkre.js +2 -0
  132. package/dist/owletto/dist/assets/{new-ktz9Cs_P.js → new-BbdwuJPm.js} +2 -2
  133. package/dist/owletto/dist/assets/new-DTuFCQhV.js +2 -0
  134. package/dist/owletto/dist/assets/{oauth-workspace-access-lZNZ9gul.js → oauth-workspace-access-QPo4YwRX.js} +2 -2
  135. package/dist/owletto/dist/assets/organization-BDzjnqPf.js +2 -0
  136. package/dist/owletto/dist/assets/peek-pane-content-D7yt0PrA.js +2 -0
  137. package/dist/owletto/dist/assets/permissions-CfoY4WFY.js +2 -0
  138. package/dist/owletto/dist/assets/proposal-review-shell-CVkLnnKo.js +2 -0
  139. package/dist/owletto/dist/assets/public-shell-ready-DXUTTGGp.js +2 -0
  140. package/dist/owletto/dist/assets/record-activity-BXhvJbd9.js +2 -0
  141. package/dist/owletto/dist/assets/{record-session-Pbr5czGw.js → record-session-D07szzqN.js} +2 -2
  142. package/dist/owletto/dist/assets/renderer-AJxSmE3-.js +97 -0
  143. package/dist/owletto/dist/assets/reset-password-kRYyQuTY.js +2 -0
  144. package/dist/owletto/dist/assets/runs-lG2ChtOt.js +2 -0
  145. package/dist/owletto/dist/assets/runs-panel-LnGpHCAQ.js +2 -0
  146. package/dist/owletto/dist/assets/schema-type-editor-panel-C_Es0qDf.js +2 -0
  147. package/dist/owletto/dist/assets/settings-CEAOg7fr.js +2 -0
  148. package/dist/owletto/dist/assets/settings-gGYXbFfd.js +2 -0
  149. package/dist/owletto/dist/assets/skills-BOL5c_Tk.js +2 -0
  150. package/dist/owletto/dist/assets/source-record-panels-CjFPgKKJ.js +2 -0
  151. package/dist/owletto/dist/assets/status-dot-CSBtKT4g.js +2 -0
  152. package/dist/owletto/dist/assets/table-DHM-vCxP.js +2 -0
  153. package/dist/owletto/dist/assets/use-automations-C4TSie1i.js +2 -0
  154. package/dist/owletto/dist/assets/{use-mention-search-Dcunv4L0.js → use-mention-search-PfZrNbu_.js} +4 -4
  155. package/dist/owletto/dist/assets/use-scroll-sentinel-D-fJx_Md.js +2 -0
  156. package/dist/owletto/dist/assets/view-param-filters-DkX4YdDT.js +2 -0
  157. package/dist/owletto/dist/assets/views-access-required-2ubIf_3N.js +2 -0
  158. package/dist/owletto/dist/index.html +2 -2
  159. package/dist/server-main.bundle.mjs +137007 -132255
  160. package/npm-shrinkwrap.json +723 -1095
  161. package/package.json +7 -10
  162. package/vendor/@better-auth-kysely-adapter/LICENSE.md +20 -0
  163. package/vendor/@better-auth-kysely-adapter/README.md +17 -0
  164. package/vendor/@better-auth-kysely-adapter/dist/bun-sqlite-dialect-DoOVo4ja.mjs +123 -0
  165. package/vendor/@better-auth-kysely-adapter/dist/d1-sqlite-dialect-Cru74LbR.mjs +133 -0
  166. package/vendor/@better-auth-kysely-adapter/dist/index.d.mts +116 -0
  167. package/vendor/@better-auth-kysely-adapter/dist/index.mjs +719 -0
  168. package/vendor/@better-auth-kysely-adapter/dist/node-sqlite-dialect.d.mts +27 -0
  169. package/vendor/@better-auth-kysely-adapter/dist/node-sqlite-dialect.mjs +123 -0
  170. package/vendor/@better-auth-kysely-adapter/dist/sqlite-introspector-DSCAP82F.mjs +90 -0
  171. package/vendor/@better-auth-kysely-adapter/package.json +52 -0
  172. package/vendor/connector-sdk/dist/browser-requirement.js +1 -1
  173. package/vendor/connector-sdk/dist/connector-types.d.ts +34 -1
  174. package/vendor/connector-sdk/dist/index.d.ts +3 -1
  175. package/vendor/connector-sdk/dist/index.js +4 -0
  176. package/vendor/connector-sdk/dist/redact.d.ts +10 -0
  177. package/vendor/connector-sdk/dist/redact.js +130 -0
  178. package/vendor/connector-sdk/dist/types.d.ts +2 -1
  179. package/vendor/connector-sdk/package.json +6 -1
  180. package/vendor/core/dist/agent-tooling.d.ts +8 -0
  181. package/vendor/core/dist/agent-tooling.js +9 -1
  182. package/vendor/core/dist/capabilities.d.ts +1 -1
  183. package/vendor/core/dist/capabilities.js +5 -0
  184. package/vendor/core/dist/connector-query-errors.d.ts +6 -0
  185. package/vendor/core/dist/connector-query-errors.js +4 -0
  186. package/vendor/core/dist/contracts/entity-reference.d.ts +3 -0
  187. package/vendor/core/dist/contracts/entity-reference.js +31 -0
  188. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +3 -0
  189. package/vendor/core/dist/contracts/tools/manage-automations.js +4 -1
  190. package/vendor/core/dist/contracts/tools/manage-connections.js +1 -1
  191. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +2 -2
  192. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +117 -34
  193. package/vendor/core/dist/contracts/tools/manage-entity.js +47 -14
  194. package/vendor/core/dist/contracts/tools/manage-operations.d.ts +13 -4
  195. package/vendor/core/dist/contracts/tools/manage-operations.js +19 -7
  196. package/vendor/core/dist/contracts/tools/read-knowledge.d.ts +6 -1
  197. package/vendor/core/dist/contracts/tools/read-knowledge.js +20 -1
  198. package/vendor/core/dist/contracts/tools/view-attach.d.ts +1 -1
  199. package/vendor/core/dist/contracts/tools/view-runtime.d.ts +2 -0
  200. package/vendor/core/dist/contracts/tools/view-runtime.js +3 -1
  201. package/vendor/core/dist/contracts/worker/device-automation.d.ts +4 -9
  202. package/vendor/core/dist/contracts/worker/device-automation.js +10 -15
  203. package/vendor/core/dist/contracts/worker/protocol.d.ts +20 -0
  204. package/vendor/core/dist/contracts/worker/protocol.js +20 -0
  205. package/vendor/core/dist/errors.d.ts +0 -20
  206. package/vendor/core/dist/errors.js +1 -25
  207. package/vendor/core/dist/otel.js +38 -10
  208. package/vendor/core/dist/reserved.d.ts +6 -3
  209. package/vendor/core/dist/reserved.js +6 -3
  210. package/vendor/core/dist/utils/ajv.js +3 -1
  211. package/vendor/core/dist/worker/auth.d.ts +3 -2
  212. package/vendor/core/package.json +31 -5
  213. package/vendor/postgres/.bun-tag-22d644c2873790db +0 -0
  214. package/vendor/postgres/cf/src/query.js +3 -1
  215. package/vendor/postgres/cjs/src/query.js +3 -1
  216. package/vendor/postgres/src/query.js +3 -1
  217. package/vendor/views/dist/api.js +31 -7
  218. package/vendor/views/dist/bridge.d.ts +2 -1
  219. package/vendor/views/dist/bridge.js +10 -1
  220. package/vendor/views/package.json +1 -1
  221. package/dist/owletto/dist/assets/_-BorucF19.js +0 -3
  222. package/dist/owletto/dist/assets/_-CkGyNi0G.js +0 -2
  223. package/dist/owletto/dist/assets/_agentId-BrhcaxUk.js +0 -2
  224. package/dist/owletto/dist/assets/_agentId-DgRrCE2B.js +0 -2
  225. package/dist/owletto/dist/assets/_automationId-DSrZIYcs.js +0 -2
  226. package/dist/owletto/dist/assets/_connectorKey._connectionId-DWxv1uoi.js +0 -2
  227. package/dist/owletto/dist/assets/_connectorKey.index-BTP5ijdT.js +0 -2
  228. package/dist/owletto/dist/assets/_conversationId-98Y3RuRO.js +0 -2
  229. package/dist/owletto/dist/assets/_deploymentId-B1UWPY0i.js +0 -2
  230. package/dist/owletto/dist/assets/_eventId-BAnr8g8z.js +0 -2
  231. package/dist/owletto/dist/assets/_name-BUfFO_A0.js +0 -2
  232. package/dist/owletto/dist/assets/_owner-C79BwQ0I.js +0 -3
  233. package/dist/owletto/dist/assets/_shape-Ep6JpyFX.js +0 -2
  234. package/dist/owletto/dist/assets/_skillKey-B24alBfT.js +0 -2
  235. package/dist/owletto/dist/assets/_slug-DbPdDc-5.js +0 -2
  236. package/dist/owletto/dist/assets/_viewKey-DDUxjjFD.js +0 -2
  237. package/dist/owletto/dist/assets/_viewKey-hdpq3RoX.js +0 -2
  238. package/dist/owletto/dist/assets/accept-invitation-UXU5Fx2G.js +0 -2
  239. package/dist/owletto/dist/assets/activity-route-view-D7ORHntE.js +0 -2
  240. package/dist/owletto/dist/assets/agent-card-controls-CplnPhbv.js +0 -2
  241. package/dist/owletto/dist/assets/agent-connect-pages-BmknviTI.js +0 -2
  242. package/dist/owletto/dist/assets/agent-guardrails-route-TdvvIc_J.js +0 -2
  243. package/dist/owletto/dist/assets/agent-permissions-matrix-BkZu1LYE.js +0 -2
  244. package/dist/owletto/dist/assets/agent-skills-route-B3vvvZZe.js +0 -2
  245. package/dist/owletto/dist/assets/agent-subpage-shell-CZJvnjNC.js +0 -2
  246. package/dist/owletto/dist/assets/agents-DAOln24A.js +0 -2
  247. package/dist/owletto/dist/assets/agents-workbench-DJ67GZ93.js +0 -2
  248. package/dist/owletto/dist/assets/app-bridge-BCm4muqj.js +0 -128
  249. package/dist/owletto/dist/assets/app._appId-Cp78oEZ9.js +0 -2
  250. package/dist/owletto/dist/assets/automation-detail-content-DSwbRpbx.js +0 -2
  251. package/dist/owletto/dist/assets/automations-DAOln24A.js +0 -2
  252. package/dist/owletto/dist/assets/callback-CBexCo3F.js +0 -2
  253. package/dist/owletto/dist/assets/client-rows-BYbsXGy9.js +0 -2
  254. package/dist/owletto/dist/assets/clients-BhNl1tVq.js +0 -2
  255. package/dist/owletto/dist/assets/connect-wx-qqLir.js +0 -2
  256. package/dist/owletto/dist/assets/connect._clientId-kk0_4Svo.js +0 -2
  257. package/dist/owletto/dist/assets/connected._clientId-QR8o-7M5.js +0 -2
  258. package/dist/owletto/dist/assets/connected._clientId.activity-BqprYeOX.js +0 -2
  259. package/dist/owletto/dist/assets/connected._clientId.index-DhRoSzBr.js +0 -2
  260. package/dist/owletto/dist/assets/connection-CNm2ukrI.js +0 -2
  261. package/dist/owletto/dist/assets/connection-feed-detail-WcGCA6qY.js +0 -2
  262. package/dist/owletto/dist/assets/connections-browser-CrtnAs0Q.js +0 -2
  263. package/dist/owletto/dist/assets/connector-scope-lists-CRFEpSvk.js +0 -2
  264. package/dist/owletto/dist/assets/conversations-table-D_HOe1jN.js +0 -2
  265. package/dist/owletto/dist/assets/create-C4lptGWj.js +0 -2
  266. package/dist/owletto/dist/assets/create-CCjZxIkK.js +0 -2
  267. package/dist/owletto/dist/assets/create-DkgUQAbB.js +0 -2
  268. package/dist/owletto/dist/assets/create-automation-form-Bpy92SM5.js +0 -3
  269. package/dist/owletto/dist/assets/create._connectorKey-D6Kc-YQ3.js +0 -2
  270. package/dist/owletto/dist/assets/deployments-C5hvipQh.js +0 -2
  271. package/dist/owletto/dist/assets/deployments-CPpFAd_w.js +0 -2
  272. package/dist/owletto/dist/assets/deployments-body-DGII20dQ.js +0 -2
  273. package/dist/owletto/dist/assets/device._deviceId-Bn37UpWH.js +0 -2
  274. package/dist/owletto/dist/assets/entity-options-Clz_WXK-.js +0 -2
  275. package/dist/owletto/dist/assets/entity-page-D3e4iPle.js +0 -2
  276. package/dist/owletto/dist/assets/entity-type-page-DebN1vCM.js +0 -2
  277. package/dist/owletto/dist/assets/event-detail-DV_zfWnC.js +0 -2
  278. package/dist/owletto/dist/assets/events-feed-DO3IiJO2.js +0 -2
  279. package/dist/owletto/dist/assets/filter-editors-Bwhqj7lY.js +0 -2
  280. package/dist/owletto/dist/assets/guardrails-BiJollCA.js +0 -2
  281. package/dist/owletto/dist/assets/identity-HCFWtdaI.js +0 -2
  282. package/dist/owletto/dist/assets/index-8wxsyxqt.js +0 -2
  283. package/dist/owletto/dist/assets/index-9YuSRymd.js +0 -7950
  284. package/dist/owletto/dist/assets/index-B3c-0eZG.js +0 -2
  285. package/dist/owletto/dist/assets/index-B64PGxQm.js +0 -2
  286. package/dist/owletto/dist/assets/index-BSH07yVD.css +0 -1
  287. package/dist/owletto/dist/assets/index-BX0EA_oB.js +0 -2
  288. package/dist/owletto/dist/assets/index-CDz3-ieP.js +0 -12
  289. package/dist/owletto/dist/assets/index-CdJJaQDX.js +0 -2
  290. package/dist/owletto/dist/assets/index-CfT_W8Vo.js +0 -2
  291. package/dist/owletto/dist/assets/index-D3WHeGql.js +0 -2
  292. package/dist/owletto/dist/assets/index-DB1iWI_a.js +0 -2
  293. package/dist/owletto/dist/assets/index-DMNzF8Lf.js +0 -2
  294. package/dist/owletto/dist/assets/index-DyB3IzOA.js +0 -2
  295. package/dist/owletto/dist/assets/index-Vcq4gwWv.js +0 -2
  296. package/dist/owletto/dist/assets/index-fgAJydgX.js +0 -2
  297. package/dist/owletto/dist/assets/json-diff-DIN5Jhfx.js +0 -4
  298. package/dist/owletto/dist/assets/login-DxGYyE4n.js +0 -2
  299. package/dist/owletto/dist/assets/logout-Bkzc7J44.js +0 -2
  300. package/dist/owletto/dist/assets/memory-browse-page-BnuhLJ6X.css +0 -1
  301. package/dist/owletto/dist/assets/memory-browse-page-D_UlBa27.js +0 -103
  302. package/dist/owletto/dist/assets/models-BAVeysNq.js +0 -2
  303. package/dist/owletto/dist/assets/new-C2av0diq.js +0 -2
  304. package/dist/owletto/dist/assets/new-snm1ctHn.js +0 -2
  305. package/dist/owletto/dist/assets/organization-Cb0W823y.js +0 -2
  306. package/dist/owletto/dist/assets/peek-pane-content-BNR9ImQY.js +0 -2
  307. package/dist/owletto/dist/assets/permissions-Dv39zWKt.js +0 -2
  308. package/dist/owletto/dist/assets/proposal-review-shell-CFhOqCLf.js +0 -2
  309. package/dist/owletto/dist/assets/public-shell-ready-DqX8AXfw.js +0 -2
  310. package/dist/owletto/dist/assets/recent-QhnLDU1_.js +0 -2
  311. package/dist/owletto/dist/assets/record-activity-ZJntBfN_.js +0 -2
  312. package/dist/owletto/dist/assets/record-field-peek-Brh1IQGy.js +0 -2
  313. package/dist/owletto/dist/assets/reset-password-CzZw6RcC.js +0 -2
  314. package/dist/owletto/dist/assets/runs-panel-C0_DNTcq.js +0 -2
  315. package/dist/owletto/dist/assets/runs-table-B1APZv7d.js +0 -2
  316. package/dist/owletto/dist/assets/schema-value-normalization-CKdPjdPC.js +0 -97
  317. package/dist/owletto/dist/assets/settings-CgZ5Z7wD.js +0 -2
  318. package/dist/owletto/dist/assets/settings-VDNiffKU.js +0 -2
  319. package/dist/owletto/dist/assets/skills-DgDGscm5.js +0 -2
  320. package/dist/owletto/dist/assets/source-record-panels-BdfOVPWn.js +0 -2
  321. package/dist/owletto/dist/assets/view-param-filters-B0quibBi.js +0 -2
  322. /package/vendor/{postgres/.bun-tag-2f292c6554a8475e → @better-auth-kysely-adapter/.bun-tag-abf95749a412716} +0 -0
@@ -1,2 +0,0 @@
1
- import{r as f,j as e,S as p,e7 as y,n as A,ao as _,i as b,bh as C,u as S,h3 as k}from"./index-9YuSRymd.js";import{C as P,A as D}from"./create-automation-form-Bpy92SM5.js";import{P as E}from"./proposal-review-shell-CFhOqCLf.js";import{J as j}from"./json-diff-DIN5Jhfx.js";import{u as R,a as w}from"./deployments-C5hvipQh.js";import{E as F}from"./events-feed-DO3IiJO2.js";const L=20;function N({automationId:a}){const t=R({resourceKind:"automation",resourceId:a}),[d,c]=f.useState(null),s=w(d!=null?String(d):null),o=(t.data?.pages.length??0)>=L&&!!t.hasNextPage,r=!!t.isFetchNextPageError;f.useEffect(()=>{!o&&t.hasNextPage&&!t.isFetchingNextPage&&!t.isError&&!r&&t.fetchNextPage()},[o,t.fetchNextPage,t.hasNextPage,t.isFetchingNextPage,t.isError,r]);const l=f.useMemo(()=>(t.data?.pages??[]).flatMap(x=>x.items).filter(x=>x.type==="change"&&x.resourceKind==="automation"&&x.resourceId===String(a)),[t.data,a]),i=!!t.hasNextPage&&!o,m=typeof t.refetch=="function",h=typeof t.fetchNextPage=="function";return t.isLoading?e.jsx(p,{className:"h-20 w-full rounded-lg"}):t.isError&&!r?e.jsxs("section",{className:"space-y-2","aria-label":"Automation definition history","data-testid":"automation-definition-history",children:[e.jsx("h3",{className:"font-medium text-sm",children:"Definition history"}),e.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"automation-definition-history-error",children:"Definition history unavailable."}),m?e.jsx("button",{type:"button",className:"text-sm underline","data-testid":"automation-definition-history-retry",onClick:()=>void t.refetch(),children:"Retry"}):null]}):e.jsxs("section",{className:"space-y-2","aria-label":"Automation definition history","data-testid":"automation-definition-history",children:[e.jsx("h3",{className:"font-medium text-sm",children:"Definition history"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Runtime and delivery configuration changes with actor and before/after. Content versions (prompt, sources) are listed separately."}),l.length===0&&!i?e.jsx("p",{className:"py-4 text-sm text-muted-foreground","data-testid":"automation-definition-history-empty",children:"No definition changes recorded yet."}):e.jsx("ul",{className:"space-y-1","data-testid":"automation-definition-history-list",children:l.map(n=>{if(n.type!=="change")return null;const g=n.createdBy??n.agentId??n.actorSource??"unknown";return e.jsx("li",{children:e.jsxs("button",{type:"button",className:"flex w-full flex-wrap items-center justify-between gap-2 rounded-lg border border-border/60 px-3 py-2 text-left text-sm hover:bg-muted/50",onClick:()=>c(x=>x===n.id?null:n.id),"data-testid":`automation-definition-history-item-${n.id}`,children:[e.jsx("span",{className:"font-medium",children:n.action??n.op??"change"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:(n.changedFields??[]).join(", ")}),e.jsx("span",{className:"text-xs text-muted-foreground",children:g}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(n.createdAt).toLocaleString()})]})},n.id)})}),i?e.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"automation-definition-history-loading-more",children:"Loading more history…"}):null,o?e.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"automation-definition-history-capped",children:"Showing recent definition changes"}):null,r?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"automation-definition-history-page-error",children:"Couldn't load more history."}),h?e.jsx("button",{type:"button",className:"text-xs underline","data-testid":"automation-definition-history-retry-next",onClick:()=>void t.fetchNextPage(),children:"Retry"}):null]}):null,d!=null?e.jsx("div",{"data-testid":"automation-definition-history-detail",children:s.isLoading?e.jsx(p,{className:"h-24 w-full rounded-lg"}):s.isError?e.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"automation-definition-history-detail-error",children:"Change detail unavailable."}):s.data?e.jsx(j,{before:s.data.before,after:s.data.after}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Change detail unavailable."})}):null]})}function v(a){const{orgContext:t,hasOrgContext:d}=A(),{data:c,isLoading:s}=_(`/${a}`,t),{isAuthenticated:u}=b(),{isMember:o,isLoading:r}=C(),l=u&&o,i=c?.workspace,m=l?!d||s||r:s||r;return{organizationId:i?.id??"",isLoading:m}}function G(a){return v(a)}function O({owner:a,automationId:t,organizationId:d}){const c=Number(t),s=f.useMemo(()=>({producedByAutomationId:c}),[c]),u=S(),o=y(t,void 0,d),r=o.data?.automation?.automation_name?.trim()||null,l=o.data?.automation?.managed_agent_id??null,{data:i}=k(l,t,{orgSlug:a}),m=f.useMemo(()=>(i?.runs??[]).map(n=>({runId:n.runId,status:n.status,completedAt:n.completedAt})),[i]),h=f.useCallback(n=>{u?.open({href:`/${a}/automations/${t}?run_id=${n}`,title:r!=null?`${r} · Run #${n}`:`Automation run #${n}`,runId:n})},[u,a,t,r]);return Number.isFinite(c)?e.jsx(F,{organizationId:d,ownerSlug:a,filters:s,groupByRun:!0,onRunSelect:h,runs:m,hideRunAction:!0,hideAttribution:!0,emptyState:e.jsx("p",{className:"py-6 text-sm text-muted-foreground",children:"This Automation hasn't written anything yet. Runs appear here with the events they created; clicking a run opens its conversation."})}):null}function T({agentId:a,automationId:t,runId:d,organizationId:c,onDone:s}){const[u,o]=f.useState({ready:!1,triggers:[]}),r=f.useCallback(n=>{o(g=>JSON.stringify(g)===JSON.stringify(n)?g:n)},[]),l=y(t,void 0,c,{includeVersions:!0}),i=l.data?.automation,m=e.jsx("div",{className:"flex flex-col gap-4",children:[0,1,2].map(n=>e.jsx(p,{className:"h-16 w-full rounded-lg"},n))}),h=l.isLoading?m:i?e.jsx(P,{organizationId:c,prefillAgentId:a??void 0,editingAutomation:{automation_id:i.automation_id,name:i.automation_name,slug:i.slug,description:i.description,prompt:i.prompt,sources:i.sources,reaction_script:i.reaction_script,managed_agent_id:i.managed_agent_id,device_worker_id:i.device_worker_id,agent_kind:i.agent_kind,delivery_target:i.delivery_target??void 0,execution_config:i.execution_config??void 0,keying_config:i.keying_config,reactions_guidance:i.reactions_guidance,triggers:i.triggers},createFields:{triggers:u.triggers},triggerFields:e.jsx(D,{organizationId:c,initialTriggers:i.triggers??[],onChange:r},JSON.stringify(i.triggers??[])),hideHeader:!0,hideCancel:!0,submitDisabled:!u.ready,onClose:s,onSuccess:s}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automation not found. It may have been removed."});return a?e.jsxs("div",{className:"space-y-6",children:[e.jsx(E,{resource:{kind:"automation",agentId:a,automationId:t},runId:d,onDone:s,children:({reviewMode:n,proposal:g})=>n==="active"?e.jsx(j,{before:g?.current??null,after:{...g?.current??{},...g?.proposedAfter??{}}}):n==="loading"?m:n==="error"?null:h}),e.jsx(N,{automationId:t})]}):e.jsxs("div",{className:"space-y-6",children:[h,e.jsx(N,{automationId:t})]})}function V({owner:a,agentId:t,automationId:d,view:c,runId:s,onDone:u}){const{organizationId:o}=v(a),r=y(d,void 0,o),l=t??r.data?.automation?.managed_agent_id??null;return s||c==="definition"?e.jsx(T,{agentId:l,automationId:d,runId:s,organizationId:o,onDone:u}):e.jsx(O,{owner:a,automationId:d,organizationId:o})}export{V as A,G as u};
2
- //# sourceMappingURL=automation-detail-content-DSwbRpbx.js.map
@@ -1,2 +0,0 @@
1
- import{j as t,O as o}from"./index-9YuSRymd.js";const n=()=>t.jsx(o,{});export{n as component};
2
- //# sourceMappingURL=automations-DAOln24A.js.map
@@ -1,2 +0,0 @@
1
- import{o as a,i,r as n,j as t}from"./index-9YuSRymd.js";function r(){const s=a(),{isReady:e}=i();return n.useEffect(()=>{e&&setTimeout(()=>{s({to:"/"})},500)},[e,s]),t.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:t.jsx("div",{className:"text-center",children:t.jsx("p",{className:"text-muted-foreground",children:e?"Redirecting...":"Completing sign in..."})})})}export{r as component};
2
- //# sourceMappingURL=callback-CBexCo3F.js.map
@@ -1,2 +0,0 @@
1
- import{dE as c}from"./index-9YuSRymd.js";function o(n){const t=new Map;for(const e of n){if(e.kind!=="mcp")continue;const l=e.title?.trim()||e.identifier||"Unknown app",s=e.registrationGroupKey||e.id,i=t.get(s);if(!i){t.set(s,{key:s,clientId:e.id,title:l,drivenBy:e.drivenBy?.trim()||null,clientIds:[e.id],connected:e.status==="connected",lastSeenAt:e.lastSeenAt??null,linkedUser:e.linkedUserName??e.linkedUserEmail??null,linkedUserEntitySlug:e.linkedUserEntitySlug??null});continue}i.clientIds.push(e.id),i.connected=i.connected||e.status==="connected",(e.lastSeenAt??0)>(i.lastSeenAt??0)&&(i.lastSeenAt=e.lastSeenAt??null,i.drivenBy=e.drivenBy?.trim()||null)}return[...t.values()].sort((e,l)=>(l.lastSeenAt??0)-(e.lastSeenAt??0))}function r(n){const t=[n.linkedUser];return t.push(n.connected?`active ${c(n.lastSeenAt)}`:"disconnected"),n.drivenBy&&n.drivenBy!==n.title&&t.push(`via ${n.drivenBy}`),t.filter(Boolean).join(" · ")}export{r as c,o as g};
2
- //# sourceMappingURL=client-rows-BYbsXGy9.js.map
@@ -1,2 +0,0 @@
1
- import{cx as c,ch as u,$ as d,bI as p,bJ as r,W as o,dD as i,J as w}from"./index-9YuSRymd.js";function l(t,a="",e){const n=`${w}/api/${t}/clients${a}`,s=e?.toString();return s?`${n}?${s}`:n}function h(t,a){const e=a?.ownerSlug??c().slug;return u({queryKey:["connected-clients",e,t??null],queryFn:async()=>{if(!e)throw new Error("Workspace required");const n=new URLSearchParams;t&&n.set("agentId",t);const s=await o(l(e,"",n),{credentials:"include"});return await i(s,"Failed to load connected clients"),(await s.json()).clients??[]},enabled:!!e&&(a?.enabled??!0),staleTime:15e3,refetchInterval:a?.refetchInterval})}function y(){const{slug:t}=c(),a=d();return p({mutationFn:async e=>{if(!t)throw new Error("Workspace required");const n=new URLSearchParams;e.scope==="all"&&n.set("scope","all");const s=await o(l(t,`/mcp/${encodeURIComponent(e.clientId)}`,n),{method:"DELETE",credentials:"include"});return await i(s,"Failed to revoke client"),await s.json()},onSuccess:()=>{a.invalidateQueries({queryKey:["connected-clients",t]}),r.success("App access revoked")},onError:e=>{r.error(e.message||"Failed to revoke app access")}})}export{y as a,h as u};
2
- //# sourceMappingURL=clients-BhNl1tVq.js.map
@@ -1,2 +0,0 @@
1
- import{j as t,O as o}from"./index-9YuSRymd.js";const n=()=>t.jsx(o,{});export{n as component};
2
- //# sourceMappingURL=connect-wx-qqLir.js.map
@@ -1,2 +0,0 @@
1
- import{iJ as r,j as t,ai as a}from"./index-9YuSRymd.js";import{a as i}from"./agent-connect-pages-BmknviTI.js";import"./agent-client-setup-list-BlXB4SE5.js";import"./clients-BhNl1tVq.js";import"./client-rows-BYbsXGy9.js";function x(){const{owner:e,clientId:o}=r.useParams();return t.jsx(a,{owner:e,children:({ownerSlug:n})=>t.jsx(i,{owner:n,clientId:o})})}export{x as component};
2
- //# sourceMappingURL=connect._clientId-kk0_4Svo.js.map
@@ -1,2 +0,0 @@
1
- import{j as t,O as n}from"./index-9YuSRymd.js";function e(){return t.jsx(n,{})}export{e as component};
2
- //# sourceMappingURL=connected._clientId-QR8o-7M5.js.map
@@ -1,2 +0,0 @@
1
- import{j as e,ai as w,r as N,d8 as y,ht as p,g9 as x,ga as h,L as r,gb as o,x as _,bk as j,aR as L,di as A,B as $,A as k,iX as g}from"./index-9YuSRymd.js";import{c as E}from"./conversations-table-D_HOe1jN.js";import{E as B}from"./events-feed-DO3IiJO2.js";import{u as P}from"./clients-BhNl1tVq.js";import{g as R}from"./client-rows-BYbsXGy9.js";import"./schema-value-normalization-CKdPjdPC.js";import"./card-jzhQrMDP.js";const S="flex min-h-0 flex-1 flex-col gap-3 px-4 pt-2.5 pb-8 lg:px-6";function D({owner:s,clientId:a,mcpActivityId:t}){return e.jsx("div",{className:S,children:e.jsx(w,{owner:s,children:({organizationId:n,ownerSlug:l})=>e.jsx(T,{ownerSlug:l,organizationId:n,clientId:a,mcpActivityId:t})})})}function T({ownerSlug:s,organizationId:a,clientId:t,mcpActivityId:n}){const{data:l=[],isLoading:f}=P(null),i=N.useMemo(()=>R(l).find(u=>u.clientIds.includes(t)),[t,l]),d=i?.clientIds??[],{data:b=[],isLoading:v}=y({enabled:!!i&&!!a,limit:100,clientIds:d,organizationId:a}),c=n?b.find(u=>u.activityId===n)??null:null,m=i?.title??"Connected agent",C=c?E(c):"Conversation";return!a||f||n&&v?e.jsx(p,{header:e.jsx(x,{breadcrumb:e.jsx(h,{crumbs:[e.jsx(r,{to:"/$owner/agents",params:{owner:s},className:o,children:"Agents"},"agents")]}),title:"Conversation"}),children:e.jsx("p",{className:"py-3 text-xs text-muted-foreground",children:"Loading…"})}):n&&(!i||!c||c.organizationId===null)?e.jsx(_,{to:"/$owner/events",params:{owner:"me"},search:{client_ids:i?d.join(","):t,mcp_activity_id:n},replace:!0}):i?n?e.jsx(p,{header:e.jsx(x,{breadcrumb:e.jsx(h,{crumbs:[e.jsx(r,{to:"/$owner/agents",params:{owner:s},className:o,children:"Agents"},"agents"),e.jsx(r,{to:"/$owner/agents/connected/$clientId",params:{owner:s,clientId:t},className:o,children:m},"app")]}),icon:e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",children:e.jsx(j,{name:c?.clientName??m})}),title:C,meta:e.jsx($,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(r,{to:"/$owner/events",params:{owner:s},search:{client_ids:d.join(","),mcp_activity_id:n},children:["See in Activity",e.jsx(k,{className:"h-3.5 w-3.5"})]})})}),children:e.jsx(B,{organizationId:a,ownerSlug:s,filters:{clientIds:d,mcpActivityId:n,sortBy:"date",sortOrder:"desc"},hideOriginator:!0,foldConsecutiveCalls:!0,emptyState:e.jsx(L,{icon:A,title:"No activity in this conversation yet",description:"Calls this app makes will appear here."})})}):e.jsx(p,{header:e.jsx(x,{breadcrumb:e.jsx(h,{crumbs:[e.jsx(r,{to:"/$owner/agents",params:{owner:s},className:o,children:"Agents"},"agents"),e.jsx(r,{to:"/$owner/agents/connected/$clientId",params:{owner:s,clientId:t},className:o,children:m},"app")]}),icon:e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",children:e.jsx(j,{name:m})}),title:"Conversation"}),children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a conversation on this app's page to see its activity."})}):e.jsx(p,{header:e.jsx(x,{breadcrumb:e.jsx(h,{crumbs:[e.jsx(r,{to:"/$owner/agents",params:{owner:s},className:o,children:"Agents"},"agents")]}),title:"Conversation"}),children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"This app isn't connected to this workspace, so its activity isn't available."})})}function W(){const{owner:s,clientId:a}=g.useParams(),t=g.useSearch();return e.jsx(D,{owner:s,clientId:a,mcpActivityId:typeof t.mcp_activity_id=="string"?t.mcp_activity_id:null})}export{W as component};
2
- //# sourceMappingURL=connected._clientId.activity-BqprYeOX.js.map
@@ -1,2 +0,0 @@
1
- import{n as E,e_ as z,r as c,d8 as C,j as e,S as N,cA as P,L as I,dE as U,hL as p,B as v,a2 as B,ht as D,g9 as M,bk as _,ga as T,gb as G,iQ as K,ai as Q}from"./index-9YuSRymd.js";import{C as k}from"./conversations-table-D_HOe1jN.js";import{u as S,a as $}from"./clients-BhNl1tVq.js";import{g as A}from"./client-rows-BYbsXGy9.js";function O({ownerSlug:n,clientId:i}){const{orgContext:a}=E(),{isAdmin:f}=z(a.organizationId),{data:l=[],isLoading:d}=S(null),r=$(),[L,u]=c.useState(!1),s=c.useMemo(()=>A(l),[l]).find(t=>t.clientIds.includes(i)),j=s?.clientIds??[],m=C({enabled:!!s,limit:100,clientIds:j,activityKind:"conversation",organizationId:a?.organizationId??null}),x=C({enabled:!!s,limit:100,clientIds:j,activityKind:"session",organizationId:a?.organizationId??null,refetchInterval:t=>t?5e3:!1}),o=m.data??[],g=x.data??[],w=c.useMemo(()=>l.filter(t=>s?.clientIds.includes(t.id)),[l,s]);if(d)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(N,{className:"h-16 w-full rounded-lg"}),e.jsx(N,{className:"h-24 w-full rounded-lg"})]});if(!s)return e.jsx("p",{className:"text-sm text-muted-foreground",children:"This app isn't connected to this workspace, so its details aren't available."});const h=w[0],b=h?.details?.redirectUris??[],y=s.linkedUserEntitySlug?P(n,[{entity_type:"$member",slug:s.linkedUserEntitySlug}]):null,R=[{label:"Registered",value:s.title},{label:s.clientIds.length===1?"Client ID":"Client IDs",value:e.jsx("div",{className:"space-y-1",children:s.clientIds.map(t=>e.jsx("code",{className:"block break-all",children:t},t))})},...s.drivenBy&&s.drivenBy!==s.title?[{label:"Driven by",value:s.drivenBy}]:[],...h?.platform?[{label:"Software",value:h.platform}]:[],...b.length>0?[{label:"Redirects",value:b.join(", ")}]:[],{label:"Granted by",value:y&&s.linkedUser?e.jsx(I,{to:y,className:"font-medium text-primary hover:underline",children:s.linkedUser}):s.linkedUser??"—"},{label:"Last active",value:s.connected?U(s.lastSeenAt):"disconnected"},{label:"Registrations",value:String(s.clientIds.length)}];return e.jsxs("div",{className:"space-y-7",children:[e.jsx(p,{title:"Settings",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"overflow-hidden rounded-lg border text-xs",children:e.jsx("dl",{className:"divide-y",children:R.map(t=>e.jsxs("div",{className:"flex gap-3 px-3 py-2",children:[e.jsx("dt",{className:"w-28 shrink-0 text-muted-foreground",children:t.label}),e.jsx("dd",{className:"min-w-0 flex-1 break-words",children:t.value})]},t.label))})}),f&&s.connected?e.jsxs("div",{className:"space-y-2 rounded-lg border p-3",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Revoking disconnects every registration this app holds",s.clientIds.length>1?` (${s.clientIds.length} of them)`:""," ","and kills its live sessions. It can reconnect by authorizing again."]}),L?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{variant:"destructive",size:"sm",className:"h-7 px-2 text-xs",disabled:r.isPending,onClick:()=>r.mutate({clientId:s.clientIds[0],scope:"all"},{onSettled:()=>u(!1)}),children:r.isPending?"Revoking…":"Confirm revoke"}),e.jsx(v,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",disabled:r.isPending,onClick:()=>u(!1),children:"Cancel"})]}):e.jsx(v,{variant:"outline",size:"sm",className:"h-7 px-2 text-xs text-destructive hover:text-destructive",onClick:()=>u(!0),children:"Revoke"})]}):null]})}),e.jsx(p,{title:"Conversations",count:o.length>0?String(o.length):void 0,children:m.isLoading||x.isLoading?e.jsxs("div",{className:"flex items-center py-4 text-xs text-muted-foreground",children:[e.jsx(B,{className:"mr-2"})," Loading client activity…"]}):m.isError||x.isError?e.jsx("p",{className:"py-3 text-xs text-destructive",children:"Could not load this app's activity."}):o.length===0?e.jsx("p",{className:"py-3 text-xs text-muted-foreground",children:"No recent conversations."}):e.jsx(k,{scopes:o,ownerSlug:n})}),g.length>0?e.jsx(p,{title:"Sessions",count:String(g.length),children:e.jsx(k,{scopes:g,ownerSlug:n})}):null]})}const H="flex min-h-0 flex-1 flex-col gap-3 px-4 pt-2.5 pb-8 lg:px-6";function W({owner:n,clientId:i}){const{data:a=[]}=S(null),l=c.useMemo(()=>A(a).find(d=>d.clientIds.includes(i)),[i,a])?.title??"Connected agent";return e.jsx("div",{className:H,children:e.jsx(D,{header:e.jsx(M,{breadcrumb:e.jsx(T,{crumbs:[e.jsx(I,{to:"/$owner/agents",params:{owner:n},className:G,children:"Agents"},"agents")]}),icon:e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",children:e.jsx(_,{name:l})}),title:l,caption:"An external agent connected to this workspace through Lobu. Review its Lobu conversations, activity, and access."}),children:e.jsx(O,{ownerSlug:n,clientId:i},i)})})}function Y(){const{owner:n,clientId:i}=K.useParams();return e.jsx(Q,{owner:n,children:({ownerSlug:a})=>e.jsx(W,{owner:a,clientId:i})})}export{Y as component};
2
- //# sourceMappingURL=connected._clientId.index-DhRoSzBr.js.map
@@ -1,2 +0,0 @@
1
- import{bo as A,w as T,r as l,W as $,J as P,j as e,a2 as C,B as x,bp as W,bq as q,br as V,bs as D,bt as z,I as F,a8 as K,a5 as M,E as Y}from"./index-9YuSRymd.js";import{C as B,a as G,b as J,c as H}from"./card-jzhQrMDP.js";const j="__new_org__";function Q(r){return r.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function y(r){return r.charAt(0).toUpperCase()+r.slice(1)}function L(r,o,t){if(!r)return"/";const i=`/${encodeURIComponent(r)}/`;if(t?.startsWith(i)){const a=new URL(t,window.location.origin);if(a.origin===window.location.origin&&a.pathname.startsWith(i))return a.pathname+a.search}return`${i}connectors/${encodeURIComponent(o)}?connected=1`}function X(r,o){return r==="not_admin"?`You must be an admin or owner to connect ${o} to Lobu.`:`You don't have permission to connect ${o} to Lobu.`}function U(r,o,t){switch(r){case"not_authorized":return X(o,t);case"no_pending":return`No Lobu install was found for ${t}. Add Lobu from the marketplace to get started.`;case"no_org":return`Your account has no Lobu organization to connect ${t} to.`;default:return`Something went wrong while connecting ${t}. Please try again.`}}function te(){const{name:r}=A({from:"/connector/$name/connection"}),{ref:o}=T({from:"/connector/$name/connection"}),[t,i]=l.useState({kind:"loading"}),[a,N]=l.useState(""),[w,E]=l.useState(""),[g,b]=l.useState(!1),[k,m]=l.useState(null),[h,f]=l.useState(null),d=y(r),u=t.kind==="confirm"&&t.subjectKind||"connection",I=t.kind==="confirm"&&t.subjectName?t.subjectName:`this ${d} ${u}`,S=l.useCallback(async()=>{if(!o){i({kind:"error",message:"This connection link is missing its reference."});return}i({kind:"loading"});try{const n=await(await $(`${P}/api/connector/${encodeURIComponent(r)}/connection/claim-context?ref=${encodeURIComponent(o)}`,{credentials:"include"})).json();if("error"in n){if(n.error==="unauthenticated"){i({kind:"signin",signinProvider:n.signinProvider??r,linkAccount:!1});return}if(n.error==="signin_required"){i({kind:"signin",signinProvider:n.signinProvider??r,linkAccount:n.error==="signin_required"});return}i({kind:"error",message:U(n.error,n.code,`this ${d} connection`)});return}if("alreadyConnected"in n){i({kind:"already_connected",orgSlug:n.orgSlug,nextUrl:n.nextUrl});return}N(n.orgs[0]?.slug??""),i({kind:"confirm",subjectKind:n.subjectKind,subjectName:n.subjectName,orgs:n.orgs})}catch{i({kind:"error",message:"We couldn’t load this connection link. Please try again."})}},[r,o,d]);l.useEffect(()=>{S()},[S]);const R=async c=>{if(t.kind==="signin"&&t.linkAccount){const n=await K.linkSocial({provider:c,callbackURL:window.location.href});n.error&&i({kind:"error",message:n.error.message??"Couldn’t verify this account."});return}await M.social({provider:c,callbackURL:window.location.href})},_=async(c=!1)=>{if(!(!o||!a)){b(!0),m(null),f(null);try{let n=a;if(a===j){const v=w.trim();if(!v){m("Enter a name for the new organization.");return}const p=await Y.create({name:v,slug:Q(v)});if(p.error||!p.data){m(p.error?.message??"Couldn’t create the organization.");return}n=p.data.slug}const s=await(await $(`${P}/api/connector/${encodeURIComponent(r)}/connection/claim`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({ref:o,org:n,confirmMove:c})})).json();if("error"in s){if(s.error==="signin_required"||s.error==="unauthenticated"){i({kind:"signin",signinProvider:s.signinProvider??r,linkAccount:s.error==="signin_required"});return}if((s.error==="already_connected_elsewhere"||s.error==="enterprise_scope_overlap")&&s.existing){f({kind:s.error,existing:s.existing});return}m(U(s.error,s.code,`this ${d} ${u}`));return}window.location.href=L(s.orgSlug,r,s.nextUrl)}catch{m(`Something went wrong while connecting this ${u}. Please try again.`)}finally{b(!1)}}},O=t.kind==="signin"?"Sign in to continue":t.kind==="error"?`Can’t connect this ${u}`:t.kind==="already_connected"?"Already connected":`Connect ${d} to Lobu`;return e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:e.jsx("div",{className:"w-full max-w-md p-8",children:e.jsxs(B,{children:[e.jsx(G,{children:e.jsx(J,{asChild:!0,children:e.jsx("h1",{children:O})})}),e.jsxs(H,{children:[t.kind==="loading"&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[e.jsx(C,{size:"lg"}),e.jsx("span",{children:"Checking this connection link…"})]}),t.kind==="error"&&e.jsx("div",{className:"rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive",children:t.message}),t.kind==="already_connected"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This ",d," ",u," is already connected to Lobu."]}),e.jsx(x,{className:"w-full",asChild:!0,children:e.jsx("a",{href:L(t.orgSlug,r,t.nextUrl),children:t.nextUrl?"Choose an agent":"Open Lobu"})})]}),t.kind==="signin"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Sign in with ",y(t.signinProvider)," to verify you can connect this ",u,"."]}),e.jsxs(x,{className:"w-full",onClick:()=>R(t.signinProvider),children:["Sign in with ",y(t.signinProvider)]})]}),t.kind==="confirm"&&(()=>{const c=t.subjectName||I;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Connecting"," ",e.jsx("strong",{className:"font-medium text-foreground",children:c}),". Choose the organization to connect it to:"]}),e.jsxs(W,{value:a,onValueChange:n=>{f(null),N(n)},children:[e.jsx(q,{children:e.jsx(V,{placeholder:"Select an organization"})}),e.jsxs(D,{children:[t.orgs.map(n=>e.jsxs(z,{value:n.slug,children:[n.name,n.isPersonal&&e.jsx("span",{className:"ml-1 text-muted-foreground",children:"(personal)"})]},n.id)),e.jsx(z,{value:j,children:"+ New organization"})]})]}),a===j&&e.jsx(F,{autoFocus:!0,value:w,onChange:n=>E(n.target.value),placeholder:"New organization name","aria-label":"New organization name"}),k&&e.jsx("div",{className:"rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive",children:k}),h&&(()=>{const n=h.existing.orgName??h.existing.orgSlug??"another organization";return h.kind==="already_connected_elsewhere"?e.jsxs("div",{className:"space-y-3 rounded-lg border border-border bg-muted/40 px-3 py-3",children:[e.jsxs("p",{className:"text-sm text-foreground",children:[c," is already connected in"," ",e.jsx("strong",{className:"font-medium",children:n}),". Move it here?"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(x,{className:"flex-1",onClick:()=>_(!0),disabled:g,children:g?e.jsxs(e.Fragment,{children:[e.jsx(C,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Moving…"})]}):"Move it here"}),e.jsx(x,{className:"flex-1",variant:"outline",onClick:()=>f(null),disabled:g,children:"Cancel"})]})]}):e.jsxs("div",{className:"rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive",children:["This ",d," Enterprise Grid is already connected in"," ",e.jsx("strong",{className:"font-medium",children:n}),"; ","connecting this ",u," here may change how its messages route. Contact support to move it."]})})(),e.jsx(x,{className:"w-full",onClick:()=>_(),disabled:g||h!==null||!a||a===j&&!w.trim(),children:g?e.jsxs(e.Fragment,{children:[e.jsx(C,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Connecting…"})]}):`Connect ${c}`})]})})()]})]})})})}export{te as component};
2
- //# sourceMappingURL=connection-CNm2ukrI.js.map
@@ -1,2 +0,0 @@
1
- import{gJ as U,r as o,j as e,eE as q,cF as H,dy as G,Q as C,B as N,eG as Q,iE as W,bQ as M,ec as w,gO as F,bp as J,bq as X,br as Y,bs as Z,bt as ee,ed as O,bU as P,bA as se,a2 as E,gK as te,eo as ne,cz as ae,iF as ce,af as ie,iG as le,iH as re,cj as oe,iI as de,e6 as ue,co as me,e0 as xe,L as I,hL as T,P as he,bd as V}from"./index-9YuSRymd.js";import{f as ge,C as pe}from"./entity-options-Clz_WXK-.js";import{V as fe,R as je,S as L,g as $}from"./runs-table-B1APZv7d.js";function ve({organizationId:s,value:t,onChange:a,entities:n,className:m}){const{data:i=[]}=U(n?void 0:s),u=o.useMemo(()=>n??ge(i),[n,i]),f=new Set(t),l=u.filter(c=>f.has(c.id)),d=c=>{const p=new Set(f);p.has(c)?p.delete(c):p.add(c),a(Array.from(p).sort((v,y)=>v-y))},x=l.length===0?"All entities":l.length===1?l[0].name:`${l.length} entities selected`;return e.jsx(q,{contentClassName:"w-[320px]",searchPlaceholder:"Filter entities...",emptyText:"No entities found.",trigger:c=>e.jsxs(N,{variant:"outline",role:"combobox","aria-expanded":c,className:C("justify-between",m),children:[x,e.jsx(Q,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:()=>u.map(c=>{const p=f.has(c.id);return e.jsxs(H,{value:`${c.name} ${c.entityType}`,onSelect:()=>d(c.id),className:"cursor-pointer",children:[e.jsx(G,{className:C("mr-2 h-4 w-4",p?"opacity-100":"opacity-0")}),e.jsxs("span",{children:[c.name," ",e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",c.entityType,")"]})]})]},c.id)})})}function ye(s){return s?.feeds_schema?Object.entries(s.feeds_schema).map(([t,a])=>({key:t,name:a.name??t,description:a.description,configSchema:a.configSchema})):[]}const ke="Feeds are optional scheduled sync targets for an existing connection.";function Ce({organizationId:s,connections:t,connectorDefinitions:a,entityId:n,onClose:m}){const i=t.length===1,[u,f]=o.useState(i?String(t[0].id):""),[l,d]=o.useState(""),[x,c]=o.useState(n?[n]:[]),[p,v]=o.useState(null),y=W(),_=o.useMemo(()=>new Map(a.map(r=>[r.key,r])),[a]),h=o.useMemo(()=>t.find(r=>String(r.id)===u),[t,u]),b=o.useMemo(()=>h?ye(_.get(h.connector_key)):[],[h,_]),S=o.useMemo(()=>b.find(r=>r.key===l)??null,[b,l]),g=M(`${u}:${l}`,w(S?.configSchema),S?.configSchema),{values:j,setValues:R}=g,A=o.useCallback(()=>{f(i?String(t[0].id):""),d(""),c(n?[n]:[]),v(null)},[n,i,t]),k=o.useCallback(()=>{A(),m()},[m,A]),B=o.useCallback(async()=>{if(!g.canSubmit||!h||!l)return;v(null);const r=F(j);try{await y.mutateAsync({connection_id:h.id,feed_key:l,config:Object.keys(r).length>0?r:void 0,entity_ids:n?[n]:x.length>0?x:void 0}),k()}catch(D){v(D instanceof Error?D.message:"Failed to create feed")}},[j,g.canSubmit,y,n,k,h,x,l]),z=e.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto py-6 pr-1",children:[!i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Connection"}),e.jsx(pe,{connections:t,value:u,onValueChange:r=>{f(r),d(""),v(null)},placeholder:"Select a connection"})]}),h&&b.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Feed Type"}),e.jsxs(J,{value:l,onValueChange:d,children:[e.jsx(X,{children:e.jsx(Y,{placeholder:"Select feed type"})}),e.jsx(Z,{children:b.map(r=>e.jsx(ee,{value:r.key,children:e.jsxs("div",{children:[e.jsx("span",{children:r.name}),r.description&&e.jsxs("span",{className:"text-muted-foreground ml-1 text-xs",children:["— ",r.description]})]})},r.key))})]})]}),n?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Target Entity"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This feed will be attached to the current entity."})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Target Entities"}),e.jsx(ve,{organizationId:s,value:x,onChange:c,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Leave empty to create an unscoped feed."})]}),g.revision&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Feed Configuration"}),e.jsx(O,{schema:g.revision,values:j,onValuesChange:R})]}),h&&b.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"This connector has no configurable feed types."}),e.jsx(P,{visible:g.hasConflict,onReload:g.reset}),p&&e.jsx("p",{className:"text-sm text-destructive",children:p})]}),K=e.jsx(se,{onCancel:k,className:"mt-2",children:e.jsxs(N,{disabled:!g.canSubmit||!l||y.isPending,onClick:()=>void B(),children:[y.isPending&&e.jsx(E,{size:"lg",className:"mr-2"}),"Create Feed"]})});return e.jsxs("div",{className:"flex flex-col",children:[z,K]})}function we({feed:s,onClose:t,hideHeader:a=!1}){const n=s.display_name?.trim()||s.feed_key,m=s.feed_key.includes(":")?s.feed_key.slice(s.feed_key.indexOf(":")+1):s.feed_key,i=s.external_tenant_id,u=s.connector_key==="slack"&&i?`https://app.slack.com/client/${i}/${m}`:void 0;return e.jsxs("div",{className:"flex max-w-xl flex-col gap-4",children:[a?null:e.jsxs(e.Fragment,{children:[t?e.jsxs("button",{type:"button",onClick:t,className:"inline-flex w-fit items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(te,{className:"h-3 w-3"}),"Back to connection"]}):null,e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h2",{className:"text-lg font-semibold leading-tight",children:n}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"chat channel"})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Messages captured for this channel are available to Lobu Automations. Open Slack to read the channel history."}),u?e.jsx(N,{asChild:!0,variant:"outline",className:"w-full justify-center",children:e.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(ae,{className:"mr-2 h-4 w-4"}),"Open in Slack"]})}):null,e.jsxs("div",{className:C(ie,"flex flex-col gap-3 p-4"),children:[e.jsx("div",{className:"text-xs font-medium uppercase text-muted-foreground",children:"Channel"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(ce,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"break-all",children:n})]}),i?e.jsxs("div",{className:"flex items-baseline justify-between gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Workspace"}),e.jsx("span",{className:"break-all font-mono text-xs",children:i})]}):null,e.jsx("p",{className:"text-xs text-muted-foreground",children:"Messages the bot sees here are captured as they arrive. Open the channel in Slack to read the full history."})]})]})}function Fe(s,t){return s.display_name?s.display_name:t?.feeds_schema?.[s.feed_key]?.name??s.feed_key}function be(s,t){const a=s?.feeds_schema;if(!a)return;if(a[t]?.configSchema)return a[t].configSchema;for(const m of Object.values(a))if(m?.key===t&&m.configSchema)return m.configSchema;const n=Object.values(a);if(n.length===1&&n[0]?.configSchema)return n[0].configSchema}function Ee({feed:s,ownerSlug:t}){return e.jsxs(e.Fragment,{children:[e.jsx(L,{status:$(s.status),showDot:!0,children:s.status}),s.connection_status&&s.connection_status!==s.status&&e.jsxs(L,{status:$(s.connection_status),showDot:!0,children:["Connection: ",s.connection_status]}),s.device_worker_id?e.jsx(I,{to:"/$owner/connectors/device/$deviceId",params:{owner:t,deviceId:s.device_worker_id},children:e.jsx(he,{variant:s.device_status==="offline"?"secondary":"outline",className:"text-xs hover:bg-accent",children:s.device_status==="offline"?`Waiting for ${s.device_label||s.device_platform||"device"}`:`On ${s.device_label||s.device_platform||"device"}`})}):null]})}function Ae({feed:s}){return s.operations.includes("sync")?e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:["Last sync: ",s.last_sync_at?V(s.last_sync_at):"—"]}),e.jsxs("span",{children:["Next: ",s.next_run_at?V(s.next_run_at):"—"]}),e.jsxs("span",{className:"font-mono",children:[(s.event_count??0).toLocaleString()," events"]})]}):e.jsx("span",{children:"Read live when queried"})}function De({feed:s,connectorDef:t,ownerSlug:a}){const{data:n,refetch:m}=le(s.id),i=re(),u=oe(),f=n?.recent_runs?.some(j=>["running","pending","claimed"].includes(j.status));o.useEffect(()=>{if(!f)return;const j=setInterval(()=>m(),5e3);return()=>clearInterval(j)},[f,m]);const l=o.useMemo(()=>be(t,s.feed_key),[t,s.feed_key]),d=M(s.id,w(l,s.config??{}),l),{values:x,setValues:c,dirty:p}=d,v=o.useCallback(async()=>{d.canSubmit&&(await i.mutateAsync({feed_id:s.id,config:F(x)}),d.accept(x,w(l,F(x))))},[i,s.id,x,l,d.canSubmit,d.accept]),y=o.useCallback(async()=>{const j=s.status==="active"?"paused":"active";await i.mutateAsync({feed_id:s.id,status:j})},[i,s.id,s.status]),_=o.useCallback(async()=>{await u.mutateAsync(s.id)},[u,s.id]),h=s.status==="active",b=s.operations.includes("sync"),S=s.auth_profile_status&&s.auth_profile_status!=="active",g=i.isPending||u.isPending;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(N,{variant:"outline",size:"sm",disabled:g,onClick:()=>void y(),children:[h?e.jsx(de,{className:"h-3.5 w-3.5 mr-1.5"}):e.jsx(ue,{className:"h-3.5 w-3.5 mr-1.5"}),h?"Pause":"Resume"]}),b?e.jsxs(N,{variant:"outline",size:"sm",disabled:g||!h,onClick:()=>void _(),children:[u.isPending?e.jsx(E,{size:"md",className:"mr-1.5"}):e.jsx(me,{className:"h-3.5 w-3.5 mr-1.5"}),"Sync now"]}):null,e.jsx(fe,{ownerSlug:a,scope:{kind:"feed",id:s.id},variant:"ghost",label:"View in memory"})]}),S&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-amber-50 dark:bg-amber-950/20 px-3 py-2 text-sm",children:[e.jsx(xe,{className:"h-4 w-4 text-amber-500 shrink-0"}),e.jsxs("span",{className:"text-amber-700 dark:text-amber-400",children:["Authentication issue: ",s.auth_profile_status]}),e.jsx(N,{asChild:!0,variant:"outline",size:"sm",className:"ml-auto h-7 text-xs",children:e.jsx(I,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:a,connectorKey:s.connector_key,connectionId:String(s.connection_id)},search:{settings:!0},children:"Fix auth"})})]}),d.revision?e.jsx(T,{title:"Settings",children:e.jsxs("div",{className:"max-w-xl space-y-4",children:[e.jsx(O,{schema:d.revision,values:x,onValuesChange:c}),e.jsx(P,{visible:d.hasConflict,onReload:d.reset}),p&&e.jsx("div",{className:"flex justify-end",children:e.jsxs(N,{size:"sm",disabled:g||!d.canSubmit,onClick:()=>void v(),children:[i.isPending?e.jsx(E,{size:"md",className:"mr-1.5"}):null,"Save"]})})]})}):null,b?e.jsx(T,{title:"Recent syncs",children:n?.recent_runs&&n.recent_runs.length>0?e.jsx(je,{runs:n.recent_runs,ownerSlug:a}):e.jsx("p",{className:"rounded-lg border bg-muted/20 px-3 py-6 text-center text-xs text-muted-foreground",children:"No syncs yet."})}):null]})}export{Ce as A,we as C,Ee as F,Ae as a,De as b,ke as c,Fe as f};
2
- //# sourceMappingURL=connection-feed-detail-WcGCA6qY.js.map
@@ -1,2 +0,0 @@
1
- import{h$ as h,hs as g,j as e,B as u,L as m,cT as j,hL as p,r as f,i5 as v,i6 as N,dF as w}from"./index-9YuSRymd.js";import{c as b}from"./connection-label-BobuYiAG.js";function C(n){return e.jsx(p,{title:"Connections",count:n.isLoading||n.isError?void 0:String(n.entries.length),children:e.jsx(x,{...n})})}function x({entries:n,action:i,isLoading:r,isError:o,onRetry:c}){const[a,d]=f.useState("");if(r)return e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading connections…"});if(o)return e.jsxs("div",{role:"alert",className:"space-y-2",children:[e.jsx("p",{children:"Could not load connections."}),c&&e.jsx(u,{variant:"outline",size:"sm",onClick:c,children:"Retry"})]});const s=n.filter(t=>`${t.name} ${t.description??""}`.toLowerCase().includes(a.trim().toLowerCase())).sort((t,l)=>+!!l.needsAttention-+!!t.needsAttention);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{label:"connections",query:a,onQueryChange:d,count:s.length,action:i}),e.jsx("ul",{className:s.length>0?"overflow-hidden rounded-lg border divide-y":void 0,children:s.map(t=>e.jsx("li",{children:e.jsxs(m,{...t.link,className:"flex items-center justify-between gap-3 px-3 py-2.5 transition-colors hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",children:[e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx(N,{tone:t.tone}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:t.name}),t.description&&e.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:t.description})]})]}),e.jsxs("span",{className:"flex min-w-0 max-w-1/2 shrink-0 items-center gap-2",children:[t.status&&e.jsx("span",{className:"min-w-0 truncate text-xs text-muted-foreground",children:t.status}),e.jsx(w,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground"})]})]})},t.id))}),s.length===0&&e.jsx("p",{className:"py-5 text-sm text-muted-foreground",children:a.trim()?"No matches. Try another search.":"No connections yet."})]})}function _({connections:n,connector:i,connectorKey:r,ownerSlug:o,section:c=!1}){const a=n.filter(s=>s.connector_key===r).map(s=>{const t=!!i&&h(i)&&!s.device_worker_id,l=["error","revoked","pending_auth"].includes(s.status);return{id:String(s.id),name:b({...s,connector_name:s.connector_name??i?.name??null}),needsAttention:l||t,tone:s.status==="error"||s.status==="revoked"?"destructive":t||s.status!=="active"?"amber":null,status:t?"Needs a device":l?s.error_message?.trim()||(s.status==="pending_auth"?"needs reconnect":s.status):void 0,link:g({to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:o,connectorKey:r,connectionId:String(s.id)},search:{}})}}),d=c?C:x;return e.jsx(d,{entries:a,action:e.jsx(u,{asChild:!0,size:"sm",variant:"outline",children:e.jsxs(m,{to:"/$owner/connectors/create/$connectorKey",params:{owner:o,connectorKey:r},children:[e.jsx(j,{className:"size-3.5"}),"Add connection"]})})})}export{C,_ as a};
2
- //# sourceMappingURL=connections-browser-CrtnAs0Q.js.map
@@ -1,2 +0,0 @@
1
- import{cP as y,j as t,S as f,B as p,aR as v,cR as j,L as _,cT as N,i6 as $,bd as b,u as w,hZ as k}from"./index-9YuSRymd.js";function g(e){switch(e.attention){case"needs_auth":return"Needs authentication";case"setup_required":return e.attention_reason?.trim()||"Setup required";case"paused":return"Paused";case"misconfigured":return"Configuration error";case"device_offline":return`Waiting for ${e.device_label||e.device_platform||"device"}`;case"last_attempt_failed":{const r=Number(e.consecutive_failures??0);return e.last_error?.trim()||(r>0?`${r} consecutive sync ${r===1?"failure":"failures"}`:"Last sync failed")}case"overdue":return"Scheduled run overdue";case"no_trigger":return"No schedule — this feed only runs when you sync it";case"never_run":return e.execution_mode==="scheduled"?"Scheduled, not run yet":"Not synced yet";default:return null}}function C(e){switch(e.attention){case"last_attempt_failed":case"misconfigured":return"destructive";case"needs_auth":case"setup_required":case"device_offline":case"overdue":case"no_trigger":case"never_run":return e.attention==="never_run"&&e.execution_mode!=="scheduled"?"muted":"amber";case"paused":return"muted";default:return e.status==="active"?null:e.status==="error"?"destructive":"muted"}}function S(e){return Object.keys(e?.feeds_schema??{}).length>0}function A({connection:e,ownerSlug:r,connectorKey:u,connectorDef:h}){const{data:i=[],isLoading:l,isError:m,refetch:a}=y(e.id),d=S(h),c=e.facets?.chat??!1,o={owner:r,connectorKey:u,connectionId:String(e.id)};return l?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(f,{className:"h-12 w-full rounded-lg"}),t.jsx(f,{className:"h-12 w-full rounded-lg"})]}):m?t.jsxs("div",{role:"alert",className:"space-y-2",children:[t.jsx("p",{children:"Could not load feeds."}),t.jsx(p,{variant:"outline",size:"sm",onClick:()=>void a(),children:"Retry"})]}):i.length===0?t.jsx(v,{icon:j,title:c?"No channels":"No feeds",description:d?c?"Bind a channel to route conversations to this connection.":"Add a feed to start collecting data from this connection.":c?"This chat connection has no bound channels yet.":"This connector doesn't provide any feeds.",children:d?t.jsx(p,{asChild:!0,size:"sm",children:t.jsxs(_,{to:"/$owner/connectors/$connectorKey/$connectionId",params:o,search:{addFeed:!0},children:[t.jsx(N,{className:"h-3.5 w-3.5"}),c?"Add channel":"Add feed"]})}):null}):t.jsx("ul",{className:"flex flex-col gap-2",children:i.map(n=>{const s=n.display_name?.trim()||n.feed_key,x=g(n);return t.jsx("li",{children:t.jsxs(_,{to:"/$owner/connectors/$connectorKey/$connectionId",params:o,search:{feedId:n.id},className:"flex w-full items-center justify-between gap-3 rounded-lg border border-border px-3 py-2.5 text-left transition-colors hover:bg-accent/50",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx($,{tone:C(n)}),t.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:s})]}),t.jsx("span",{className:n.attention==="last_attempt_failed"||n.attention==="misconfigured"?"max-w-[50%] shrink-0 text-right text-xs text-destructive":n.attention&&n.attention!=="healthy"?"max-w-[50%] shrink-0 text-right text-xs text-amber-600 dark:text-amber-400":"shrink-0 text-xs text-muted-foreground",title:x??void 0,children:x??(n.store==="channel_messages"?"chat channel":n.operations.includes("read")&&n.operations.includes("sync")?"synced + live":n.operations.includes("read")?"live":n.last_sync_at?`synced ${b(n.last_sync_at)}`:"not synced yet")})]})},n.id)})})}function F({connection:e,ownerSlug:r,title:u}){const h=w(),{data:i=[],isLoading:l,isError:m}=y(e.id),a=i.filter(s=>["needs_auth","setup_required","misconfigured","last_attempt_failed","device_offline","overdue"].includes(s.attention??"")),d=i.filter(s=>s.status==="paused").length,c=l?e.feed_count:i.length,o=e.facets?.chat?"channels":"feeds",n=l?`Loading ${o}…`:m?`Could not load ${o} — open to retry`:`${c} ${o}${a.length?` · ${a.length} need attention`:""}${d?` · ${d} paused`:""}`;return t.jsxs("div",{className:"space-y-2",children:[t.jsx(k,{title:u,summary:n,onOpen:()=>h?.open({href:"",title:e.facets?.chat?"Channels":"Feeds",connectorPanel:{section:"feeds",connectorKey:e.connector_key,connectionId:e.id,organizationId:e.organization_id,ownerSlug:r}})}),a.length>0&&t.jsxs("ul",{className:"space-y-1 text-xs text-destructive",children:[a.slice(0,3).map(s=>t.jsxs("li",{children:[s.display_name||s.feed_key,": ",g(s)]},s.id)),a.length>3&&t.jsxs("li",{children:[a.length-3," more sources need attention."]})]})]})}export{A as C,F as a,S as c,g as f};
2
- //# sourceMappingURL=connector-scope-lists-CRFEpSvk.js.map
@@ -1,2 +0,0 @@
1
- import{j as t,P as o,o as u,ep as h,eq as v,er as l,es as n,ev as j,ew as s,L as p,bd as y,A as N}from"./index-9YuSRymd.js";function f({isLive:a}){return t.jsx(o,{variant:a?"default":"secondary",className:`shrink-0 text-[10px] ${a?"":"text-muted-foreground"}`,title:a?"Live MCP transport":"No live MCP transport; activity history is retained",children:a?"Active":"Ended"})}function c(a){const i=a.title?.trim();return i||(a.activityKind==="session"?"MCP session":a.clientId)}function b({scopes:a,ownerSlug:i}){const d=u(),r=e=>e.organizationId===null?{to:"/$owner/events",params:{owner:"me"},search:{client_ids:e.clientId,mcp_activity_id:e.activityId}}:{to:"/$owner/agents/connected/$clientId/activity",params:{owner:i,clientId:e.clientId},search:{mcp_activity_id:e.activityId}},x=e=>{d(r(e))};return t.jsx("div",{className:"rounded-lg border",children:t.jsxs(h,{children:[t.jsx(v,{children:t.jsxs(l,{children:[t.jsx(n,{className:"px-3 py-1.5 text-xs",children:"Conversation"}),t.jsx(n,{className:"px-3 py-1.5 text-xs",children:"Calls"}),t.jsx(n,{className:"px-3 py-1.5 text-xs",children:"Last action"}),t.jsx(n,{className:"px-3 py-1.5 text-xs",children:"Last active"}),t.jsx(n,{className:"w-8 px-3 py-1.5"})]})}),t.jsx(j,{children:a.map(e=>t.jsxs(l,{className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>x(e),children:[t.jsx(s,{className:"max-w-0 px-3 py-2 text-xs font-medium",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(p,{...r(e),onClick:m=>m.stopPropagation(),className:"truncate hover:underline",children:c(e)}),e.activityKind==="session"?t.jsx(f,{isLive:e.isLive}):null,e.unreadNotificationCount>0?t.jsxs(o,{variant:"secondary",className:"shrink-0 text-[10px]",children:[e.unreadNotificationCount," unread"]}):null]})}),t.jsx(s,{className:"px-3 py-2 font-mono text-xs text-muted-foreground",children:e.callCount}),t.jsx(s,{className:"max-w-0 truncate px-3 py-2 text-xs text-muted-foreground",children:e.lastAction||"—"}),t.jsx(s,{className:"px-3 py-2 text-xs text-muted-foreground",children:y(e.lastCallAt)}),t.jsx(s,{className:"px-3 py-2 text-right",children:t.jsx("button",{type:"button","aria-label":`View ${c(e)} activity`,className:"text-muted-foreground hover:text-foreground",tabIndex:-1,children:t.jsx(N,{className:"h-3.5 w-3.5"})})})]},`${e.clientId}:${e.activityId}`))})]})})}export{b as C,c};
2
- //# sourceMappingURL=conversations-table-D_HOe1jN.js.map
@@ -1,2 +0,0 @@
1
- import{i_ as o,j as e}from"./index-9YuSRymd.js";import{a}from"./agent-guardrails-route-TdvvIc_J.js";import"./model-selector-CDrAjH31.js";import"./agent-subpage-shell-CZJvnjNC.js";import"./agent-loading-shells-B7v6Cffw.js";import"./agent-card-controls-CplnPhbv.js";function g(){const{owner:r,agentId:t}=o.useParams();return e.jsx(a,{owner:r,agentId:t})}export{g as component};
2
- //# sourceMappingURL=create-C4lptGWj.js.map
@@ -1,2 +0,0 @@
1
- import{j as n,ai as t,O as c,d7 as r,aC as i,g9 as l,ag as m,ga as x,L as d,gb as C,gc as u,f4 as j}from"./index-9YuSRymd.js";function p({owner:o,initialConnectorKey:e}){return n.jsx(t,{owner:o,children:a=>n.jsx(g,{ownerSlug:a.ownerSlug,organizationId:a.organizationId,initialConnectorKey:e})})}function g({ownerSlug:o,organizationId:e,initialConnectorKey:a}){const{data:s=[]}=r(e??"");return n.jsxs(i,{className:"flex flex-1 flex-col gap-6",children:[n.jsx(l,{breadcrumb:n.jsx(x,{crumbs:[n.jsx(d,{to:"/$owner/connectors",params:{owner:o},search:{},className:C,children:"Connectors"},"connectors")]}),icon:n.jsx(m.connectors.icon,{className:"h-6 w-6"}),title:"Add a connection",caption:"Pick a connector from the catalog or drop in an MCP URL — Lobu handles auth and brings the data into memory."}),e?n.jsx(u,{ownerSlug:o,organizationId:e,connections:s,initialConnectorKey:a}):n.jsx("div",{className:"max-w-3xl",children:n.jsx(j,{rows:4})})]})}const f=()=>n.jsx(c,{});export{p as ConnectionsCreateRouteContent,f as component};
2
- //# sourceMappingURL=create-CCjZxIkK.js.map
@@ -1,2 +0,0 @@
1
- import{iY as r,j as e}from"./index-9YuSRymd.js";import{a as i}from"./agent-skills-route-B3vvvZZe.js";import"./agent-subpage-shell-CZJvnjNC.js";import"./agent-skill-context-DFucg4c4.js";import"./core.esm-BupT3V0i.js";import"./skill-editor-D_W3QlRz.js";import"./agent-loading-shells-B7v6Cffw.js";import"./agent-card-controls-CplnPhbv.js";function x(){const{owner:t,agentId:o}=r.useParams();return e.jsx(i,{owner:t,agentId:o})}export{x as component};
2
- //# sourceMappingURL=create-DkgUQAbB.js.map
@@ -1,3 +0,0 @@
1
- import{r as i,j as e,bp as ie,bq as re,br as ce,bs as le,bt as D,I as oe,B as Q,X as Yt,d7 as gs,cg as ps,cB as Zt,gM as fs,gN as vs,S as Ct,z as k,Q as R,af as Ie,ed as Et,ef as ys,eg as js,fT as _s,d$ as es,eh as Ns,eS as ks,b0 as Ft,gO as bs,eE as st,cF as Ke,dy as tt,eG as yt,a$ as ts,cT as Je,ch as Ss,W as ws,J as Cs,ci as Es,gP as Fs,gQ as As,gR as Os,gS as Ts,gT as Ms,P as Ds,L as Ps,n as ss,gJ as Ls,a_ as Rs,aA as $s,f3 as At,gj as Is,gU as qs,b_ as Ks,fN as Ws,bA as pt,a2 as Bs,gV as zs,gW as Vs,gX as Us,gY as Qs,gZ as Gs,g_ as Js,g$ as Hs,h0 as Xs,h1 as Ys,b1 as Zs,bz as en}from"./index-9YuSRymd.js";import{c as tn}from"./cronstrue-CWImw-kf.js";import{C as sn,f as nn}from"./entity-options-Clz_WXK-.js";import{M as an}from"./model-selector-CDrAjH31.js";import{b as on}from"./skill-editor-D_W3QlRz.js";import{C as ft}from"./code-editor-CEqoCky-.js";import{u as rn,b as Ot,c as Tt,s as cn,o as ln,M as dn,d as un,e as mn,f as hn,v as xn,r as gn}from"./use-mention-search-Dcunv4L0.js";const Ze=[{value:"*/15 * * * *",label:"Every 15 minutes"},{value:"0 * * * *",label:"Every hour"},{value:"0 */6 * * *",label:"Every 6 hours"},{value:"0 9 * * *",label:"Daily at 9:00 AM"},{value:"0 18 * * *",label:"Daily at 6:00 PM"},{value:"0 9 * * 1-5",label:"Weekdays at 9:00 AM"},{value:"0 9 * * 1",label:"Weekly · Monday 9:00 AM"},{value:"0 9 1 * *",label:"Monthly · 1st at 9:00 AM"},{value:"custom",label:"Custom cron…"}];function pn(n){const t=n.trim();if(!t)return null;try{return tn.toString(t,{throwExceptionOnParseError:!0})}catch{return null}}function fn({value:n,onChange:t,placeholder:s="No schedule",className:r}){const d=n??"",u=Ze.some(f=>f.value===d),[c,a]=i.useState(!u&&d!==""),x=f=>{f==="custom"?a(!0):(a(!1),t(f))},m=d?pn(d):null,S=d?e.jsx("p",{className:m?"text-xs text-muted-foreground":"text-xs text-destructive",children:m??"Not a valid cron expression."}):null;return!d&&!c?e.jsxs(ie,{onValueChange:x,children:[e.jsx(re,{className:r??"w-full",children:e.jsx(ce,{placeholder:s})}),e.jsx(le,{children:Ze.map(f=>e.jsxs(D,{value:f.value,children:[f.label,f.value!=="custom"&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground font-mono",children:f.value})]},f.value))})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[c?e.jsx(oe,{placeholder:"0 */6 * * *",value:d,onChange:f=>t(f.target.value),className:"font-mono text-sm flex-1"}):e.jsxs(ie,{value:d,onValueChange:x,children:[e.jsx(re,{className:r??"w-full flex-1",children:e.jsx(ce,{children:Ze.find(f=>f.value===d)?.label??d})}),e.jsx(le,{children:Ze.map(f=>e.jsxs(D,{value:f.value,children:[f.label,f.value!=="custom"&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground font-mono",children:f.value})]},f.value))})]}),e.jsx(Q,{type:"button",variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0",onClick:()=>{a(!1),t("")},children:e.jsx(Yt,{className:"h-4 w-4"})})]}),S]})}const dt="__all_workspace_event_types__",vn=[],yn={};function Mt(n,t,s){const r=new Map;if(!t)for(const[u,c]of Object.entries(s??{}))r.set(u,{key:u,label:Ft(u),description:c.description});const d=[...n].filter(u=>!t||u.slug===t).sort((u,c)=>u.slug.localeCompare(c.slug));for(const u of d)for(const[c,a]of Object.entries(u.event_kinds??{})){const x=r.get(c);if(x){!x.description&&a.description&&(x.description=a.description),JSON.stringify(x.metadataSchema??null)!==JSON.stringify(a.metadataSchema??null)&&(x.metadataSchema=void 0);continue}r.set(c,{key:c,label:Ft(c),description:a.description,metadataSchema:a.metadataSchema})}return[...r.values()].sort((u,c)=>u.label.localeCompare(c.label))}function Dt(n){const t=n[0];if(!t)return;const s=d=>JSON.stringify(Object.keys(d?.properties??{}).sort()),r=s(t);return n.every(d=>s(d)===r)?t:void 0}function Pt(n,t,s){const r=new Set(Object.keys(t.properties??{}));return{...Object.fromEntries(Object.entries(n).filter(([d])=>!r.has(d))),...s}}function $e(n,t,s){return s==="steer"&&(n==="window"||t!=="reply_to_source")?"coalesce":s}function Qe(n,t){return n==="window"?"silent":t}function Lt(n){return Object.fromEntries(Object.entries(n).filter(([t])=>t==="resource_ref"||t==="resource_type"))}function Rt(n,t,s){const r=new Set(Object.keys(t?.properties??{})),d=new Set(s.flatMap(u=>Object.keys(u.filterSchema?.properties??{})));return Object.fromEntries(Object.entries(bs(n)).filter(([u])=>u==="resource_ref"||u==="resource_type"||!d.has(u)||r.has(u)))}function jn({value:n,options:t,onChange:s}){return e.jsx("div",{className:"inline-flex rounded-md border bg-muted/30 p-0.5 text-sm",children:t.map(r=>e.jsx("button",{type:"button","aria-pressed":n===r.value,onClick:()=>s(r.value),className:R("rounded px-3 py-1 transition-colors",n===r.value?"bg-background text-foreground ":"text-muted-foreground hover:text-foreground"),children:r.label},r.value))})}function $t({events:n,selectedKeys:t,onToggle:s,ariaLabel:r="Events"}){const d=i.useId(),u=n.filter(a=>t.includes(a.key)).map(a=>a.label),c=u.length===0?"Choose events":u.length===1?u[0]:`${u.length} events selected`;return e.jsx(st,{contentClassName:"w-[var(--radix-popover-trigger-width)] min-w-[280px]",searchPlaceholder:"Filter events...",emptyText:"No events found.",trigger:a=>e.jsxs(Q,{type:"button",variant:"outline",role:"combobox","aria-label":r,"aria-expanded":a,className:"w-full justify-between font-normal",children:[e.jsx("span",{className:R(u.length===0&&"text-muted-foreground"),children:c}),e.jsx(yt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:()=>n.map((a,x)=>{const m=t.includes(a.key),S=`${d}-${x}-state`;return e.jsxs(Ke,{value:`${a.label} ${a.key}`,onSelect:()=>s(a.key),"aria-label":a.label,"aria-describedby":S,className:"cursor-pointer",children:[e.jsx(tt,{className:R("mr-2 h-4 w-4",m?"opacity-100":"opacity-0")}),a.label,e.jsx("span",{id:S,className:"sr-only",children:m?"Selected":"Not selected"})]},a.key)})})}function _n({organizationId:n,initialTrigger:t,onChange:s,allowedKinds:r,showSectionHeader:d=!0,fieldIdPrefix:u="automation-trigger-"}){const c=gs(n,{status:"active",limit:500}),a=ps(n),x=Zt({organizationId:n}),m=fs({organizationId:n}),S=c.data??[],f=a.data??[],I=x.data??vn,h=m.data??yn,j=i.useMemo(()=>I.filter(l=>l.organization_id===n),[I,n]),y=t?.kind==="event"&&t?.source==="workspace",w=y||t===void 0,P=r?.length?[...r]:["event","time","manual"],_=P.join("|"),q=(()=>{const l=t===null?"manual":t?.kind==="schedule"?"time":"event";return P.includes(l)?l:P[0]??"event"})(),[N,K]=i.useState(q),[X,te]=i.useState(y?"workspace":typeof t?.connection_id=="number"?String(t.connection_id):t?.kind==="event"&&t.connector_key?"":"workspace"),b=X==="workspace",C=b?"":X,[g,G]=i.useState(typeof t?.entity_type=="string"?t.entity_type:""),se=i.useMemo(()=>Array.isArray(t?.event_types)?t.event_types:[],[t]),[$,V]=i.useState(()=>se.filter(l=>typeof l=="string")),[Y,he]=i.useState(t?.match&&typeof t.match=="object"&&!Array.isArray(t.match)?t.match:{}),[xe,ke]=i.useState(typeof t?.cron=="string"?t.cron:"0 9 * * 1-5"),be=typeof t?.timezone=="string"?t.timezone:void 0,[M,ge]=i.useState(t?.kind==="schedule"||w&&t?.execution!=="turn"||t?.execution==="window"?"window":"turn"),[ne,Z]=i.useState(Qe(M,t?.output==="reply_to_source"?"reply_to_source":"silent")),[J,ae]=i.useState(t?.kind==="schedule"||w&&t?.active_run!=="queue"?"coalesce":$e(M,ne,t?.active_run==="coalesce"||t?.active_run==="steer"?t.active_run:"queue")),[Se,Fe]=i.useState(t?.skip_if_unchanged!==!1),[we,p]=i.useState(!1);i.useEffect(()=>{const l=_.split("|");if(!l.includes(N)){const v=l[0]??"event";K(v),ge(v==="time"||v==="event"&&b?"window":"turn"),ae(v==="time"||v==="event"&&b?"coalesce":"queue"),Z("silent")}},[_,N,b]);const W=S.find(l=>String(l.id)===C),H=c.isLoading||a.isLoading,pe=x.isLoading,E=typeof t?.connector_key=="string"?t.connector_key:void 0,Ae=N==="event"&&!b&&t?.kind==="event"&&t?.source!=="workspace"&&typeof t.connection_id=="number"&&String(t.connection_id)===C&&!W,ve=N==="event"&&!b&&t?.kind==="event"&&t?.source!=="workspace"&&t.connection_id==null&&E!==void 0&&C==="",Oe=f.find(l=>l.key===(W?.connector_key??(ve?E:void 0))),de=Oe?.automation_events??[],B=de.filter(l=>$.includes(l.key)),ye=B[0],Me=j.find(l=>l.slug===g),Te=[...j.filter(l=>Object.keys(l.event_kinds??{}).length>0||l.slug===g),...g&&!Me?[{slug:g,name:g}]:[]],ue=i.useMemo(()=>Mt(j,g||void 0,h),[j,g,h]),De=ue.filter(l=>$.includes(l.key)),We=De[0],fe=Dt(B.map(l=>l.filterSchema)),me=Dt(De.map(l=>l.metadataSchema)),Be=!!(b&&g&&!Me),Pe=Ae||ve,Ce=(N==="event"?b?$.length>0&&!Be:!!($.length>0&&(C&&W||Pe)):N==="time"?!!xe.trim():!0)&&(N!=="event"||!vs(Y));i.useEffect(()=>{let l;if(Ce&&N==="event"&&!b){const v=Rt(Y,fe,Oe?.automation_events??[]);W||ve?l={kind:"event",source:"connector",connector_key:W?.connector_key??E,...W?{connection_id:Number(C)}:{},event_types:$,...Object.keys(v).length>0?{match:v}:{},execution:M,active_run:$e(M,ne,J),output:Qe(M,ne),skip_if_unchanged:Se}:Ae&&(l=t?{...t,source:"connector"}:void 0)}else if(Ce&&N==="event"&&b){const v=Rt(Y,me,ue.map(F=>({filterSchema:F.metadataSchema})));l={kind:"event",source:"workspace",...g?{entity_type:g}:{},event_types:$,...Object.keys(v).length>0?{match:v}:{},execution:M,active_run:J==="queue"?"queue":"coalesce"}}else Ce&&N==="time"&&(l={kind:"schedule",cron:xe.trim(),...be?{timezone:be}:{},execution:"window",active_run:"coalesce",skip_if_unchanged:Se});s({ready:Ce,kind:N,trigger:l})},[J,C,W,xe,Oe,$,M,Y,N,E,be,t,b,s,ne,Ce,fe,me,Se,g,ue,ve,Ae]);const at=l=>{const v=S.find(A=>String(A.id)===l),F=f.find(A=>A.key===v?.connector_key),ee=$.filter(A=>F?.automation_events?.some(Re=>Re.key===A)),T=F?.automation_events?.find(A=>A.key===ee[0]),je=v?.connector_key!==(W?.connector_key??E);if(te(l),V(ee),!T)he(Lt);else if(je){const A=T.defaults?.execution??"turn",Re=T.defaults?.activeRun??"queue",Ue=Qe(A,T.defaults?.output??"silent");he(Lt),ge(A),ae($e(A,Ue,Re)),Z(Ue)}},ot=l=>{if(l==="workspace"){te("workspace"),V(v=>v.filter(F=>ue.some(ee=>ee.key===F))),he({}),ge("window"),ae("coalesce"),Z("silent");return}at(l)},ze=l=>{const v=$.includes(l)?$.filter(A=>A!==l):de.map(A=>A.key).filter(A=>A===l||$.includes(A));if(V(v),v[0]===$[0])return;const F=de.find(A=>A.key===v[0]),ee=F?.defaults?.execution??"turn",T=F?.defaults?.activeRun??"queue",je=Qe(ee,F?.defaults?.output??"silent");ge(ee),ae($e(ee,je,T)),Z(je)},Xe=l=>{const v=l===dt?"":l,F=j.find(T=>T.slug===v),ee=Mt(j,F?.slug,h);G(v),V(T=>T.filter(je=>ee.some(A=>A.key===je))),he({})},Ve=l=>{V(v=>v.includes(l)?v.filter(F=>F!==l):ue.map(F=>F.key).filter(F=>F===l||v.includes(F)))},Le=[{value:"event",label:"Event"},{value:"time",label:"Schedule"},{value:"manual",label:"Manual"}].filter(l=>P.includes(l.value));return e.jsxs("div",{className:"space-y-4",children:[d?e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"When"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose what starts this Automation. Its goal and context stay reusable."})]}):null,Le.length>1?e.jsx(jn,{value:N,options:Le,onChange:l=>{K(l),ge(l==="time"||l==="event"&&b?"window":"turn"),ae(l==="time"||l==="event"&&b?"coalesce":"queue"),Z("silent")}}):null,N==="event"?H||b&&pe?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ct,{className:"h-9 w-full"}),e.jsx(Ct,{className:"h-9 w-full"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Source"}),e.jsx(sn,{connections:S,value:X,onValueChange:ot,disabled:Pe,includeWorkspaceEvents:!0,ariaLabel:"Source",placeholder:"Choose a source"}),Ae?e.jsx("p",{className:"text-xs text-muted-foreground",children:"This shared connection is managed outside this organization. Other Automation fields can still be edited."}):ve?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This Automation listens across all"," ",String(t?.connector_key)," connections. Other Automation fields can still be edited."]}):null]}),b?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:ue.length>1?"Events":"Event"}),ue.length>0?e.jsx($t,{events:ue,selectedKeys:$,onToggle:Ve}):e.jsx("div",{className:R(Ie,"px-3 py-2 text-sm text-muted-foreground"),children:g?"This entity type has no declared Automation events.":"This workspace has no declared Automation events."}),We?.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:We.description}):null,Be?e.jsxs("p",{className:"text-xs text-destructive",children:["This trigger filters on entity type “",g,"”, which no longer exists in this workspace. Clear the Entity type filter under Trigger options to save."]}):null,e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only declared Automation outputs in the current workspace can trigger this Automation. Ordinary saved events remain data."})]}),me?e.jsx(Et,{schema:me,values:Y,onValuesChange:l=>he(v=>Pt(v,me,l)),fieldIdPrefix:`${u}workspace-`},`${g||"workspace"}:${$.join(",")}`):null]}):W||ve?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:de.length>1?"Events":"Event"}),de.length?e.jsx($t,{events:de,selectedKeys:$,onToggle:ze}):e.jsx("div",{className:R(Ie,"px-3 py-2 text-sm text-muted-foreground"),children:"This connector has not published subscribable events."}),ye?.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:ye.description}):null]}),typeof Y.resource_ref=="string"||fe?e.jsxs("div",{className:"space-y-3",children:[typeof Y.resource_ref=="string"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Resource"}),e.jsx("div",{className:R(Ie,"px-3 py-2 text-sm"),children:Y.resource_ref})]}):null,fe?e.jsx(Et,{schema:fe,values:Y,onValuesChange:l=>he(v=>Pt(v,fe,l)),fieldIdPrefix:u},$.join(",")):null]}):null]}):X?null:e.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose workspace events or a connected app as the source."})]}):N==="time"?e.jsx(fn,{value:xe,onChange:ke}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Run this Automation explicitly from Lobu, the API, CLI, or MCP."}),N!=="manual"&&!Pe?e.jsxs(ys,{open:we,onOpenChange:p,children:[e.jsx(js,{asChild:!0,children:e.jsxs(Q,{type:"button",variant:"ghost",className:"h-auto w-full justify-between px-0 py-1 text-muted-foreground hover:bg-transparent hover:text-foreground",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[e.jsx(_s,{className:"h-4 w-4"}),"Trigger options",e.jsxs("span",{className:"font-normal text-muted-foreground",children:["· ",M==="turn"?"Each event":"Window"," ·"," ",N==="time"?"Combine":b?J==="queue"?"Queue":"Combine":J==="queue"?"Queue":J==="coalesce"?"Combine":"Update current run",N==="event"&&!b?` · ${M==="turn"&&ne==="reply_to_source"?"Reply":"Save in Lobu"}`:""]})]}),e.jsx(es,{className:R("h-4 w-4 transition-transform",we&&"rotate-180")})]})}),e.jsxs(Ns,{className:"space-y-4 pt-3",children:[N==="event"&&b?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Entity type filter"}),e.jsxs(ie,{value:g||dt,onValueChange:Xe,children:[e.jsx(re,{"aria-label":"Entity type filter",children:e.jsx(ce,{})}),e.jsxs(le,{children:[e.jsx(D,{value:dt,children:"All event types"}),Te.map(l=>e.jsx(D,{value:l.slug,children:l.name},l.slug))]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Limit selected events to outputs linked to this entity type."})]}):null,N==="event"?e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Run"}),e.jsxs(ie,{value:M,onValueChange:l=>{const v=l,F=Qe(v,ne);ge(v),Z(F),ae($e(v,F,J))},children:[e.jsx(re,{children:e.jsx(ce,{})}),e.jsxs(le,{children:[e.jsx(D,{value:"turn",children:"Start a run for each event"}),e.jsx(D,{value:"window",children:"Batch events into a window"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"When busy"}),e.jsxs(ie,{value:J,onValueChange:l=>ae(l),children:[e.jsx(re,{children:e.jsx(ce,{})}),e.jsxs(le,{children:[e.jsx(D,{value:"queue",children:"Queue"}),e.jsx(D,{value:"coalesce",children:"Combine waiting events"}),!b&&M==="turn"&&ne==="reply_to_source"&&ye?.capabilities?.steering?e.jsx(D,{value:"steer",children:"Update the current run"}):null]})]})]})]}):null,M==="window"&&(N==="time"||!b)?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Skip unchanged windows"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No source changes means no agent run or LLM call."})]}),e.jsx(ks,{"aria-label":"Skip unchanged windows",checked:Se,onCheckedChange:Fe})]}):null,N==="event"&&!b&&M==="turn"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Result"}),e.jsxs(ie,{value:ne,onValueChange:l=>{const v=l;Z(v),ae($e(M,v,J))},children:[e.jsx(re,{children:e.jsx(ce,{})}),e.jsxs(le,{children:[ye?.capabilities?.replyToSource?e.jsx(D,{value:"reply_to_source",children:"Reply where it happened"}):null,e.jsx(D,{value:"silent",children:"Save in Lobu"})]})]}),ye?.capabilities?.replyToSource?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Messages matching this trigger run the Automation; anything else in the conversation stays with the connected agent."}):null]}):null]})]}):null]})}const Nn=16;function qe(){return crypto.randomUUID()}function kn(n){return n===void 0?[{key:qe(),initial:void 0}]:n.length===0?[{key:qe(),initial:null}]:n.map(t=>({key:qe(),initial:t}))}function ns(n){return n?n.kind==="time"||n.trigger?.kind==="schedule":!1}function bn(n,t){return n?n.ready===t.ready&&n.kind===t.kind&&JSON.stringify(n.trigger)===JSON.stringify(t.trigger):!1}function Sn(n,t){const s=n.map(a=>t[a.key]??{ready:!1,kind:"event"});if(!(n.length>1)&&s[0]?.kind==="manual")return{ready:s[0].ready,triggers:[]};const d=s.filter(ns).length;return{ready:!s.some(a=>a.kind==="manual")&&d<=1&&s.length>0&&s.every(a=>a.ready&&a.trigger),triggers:s.filter(a=>a.trigger).map(a=>a.trigger)}}function na({organizationId:n,initialTriggers:t,onChange:s}){const r=i.useId(),[d,u]=i.useState(()=>kn(t)),[c,a]=i.useState({}),x=i.useRef("");i.useEffect(()=>{const h=Sn(d,c),j=JSON.stringify(h);j!==x.current&&(x.current=j,s(h))},[d,c,s]);const m=d.find(h=>ns(c[h.key]))?.key??d.find(h=>h.initial&&typeof h.initial=="object"&&h.initial.kind==="schedule"&&!c[h.key])?.key??null,S=i.useCallback((h,j)=>{a(y=>bn(y[h],j)?y:{...y,[h]:j})},[]),f=()=>{const h=d[0],j=h?c[h.key]:void 0;if(d.length===1&&(j?.kind==="manual"||h?.initial===null)){const y=qe();a({}),u([{key:y,initial:void 0}]);return}u(y=>[...y,{key:qe(),initial:void 0}])},I=h=>{if(d.length<=1){const j=qe();a({}),u([{key:j,initial:null}]);return}a(j=>{const y={...j};return delete y[h],y}),u(j=>j.filter(y=>y.key!==h))};return e.jsxs("section",{className:"space-y-4","aria-labelledby":`${r}-heading`,children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{id:`${r}-heading`,className:"text-sm font-medium",children:"When"}),d.length>1?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Each trigger can start this Automation independently (OR). At most one schedule. If several match the same event, the first listed wins for run options."}):null]}),e.jsx("div",{className:"space-y-3",children:d.map((h,j)=>{const y=d.length>1,w=y?m&&m!==h.key?["event"]:["event","time"]:["event","time","manual"],P=c[h.key],_=y||(P?P.kind!=="manual":h.initial!==null);return e.jsxs("div",{className:R("space-y-3 rounded-lg border bg-card/40 p-3",y&&"relative"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:y?`Trigger ${j+1}`:"Trigger"}),_?e.jsx(Q,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive","aria-label":y?`Remove trigger ${j+1}`:"Clear trigger",onClick:()=>I(h.key),children:e.jsx(ts,{className:"h-3.5 w-3.5"})}):null]}),e.jsx(wn,{slotKey:h.key,organizationId:n,initial:h.initial,kinds:w,fieldIdPrefix:`${r}-${h.key}-`,onChange:S})]},h.key)})}),e.jsxs(Q,{type:"button",variant:"outline",size:"sm",className:"w-full sm:w-auto",onClick:f,disabled:d.length>=Nn,children:[e.jsx(Je,{className:"mr-1.5 h-3.5 w-3.5"}),"Add another trigger"]})]})}function wn({slotKey:n,organizationId:t,initial:s,kinds:r,fieldIdPrefix:d,onChange:u}){const c=i.useCallback(a=>u(n,a),[u,n]);return e.jsx(_n,{organizationId:t,initialTrigger:s,allowedKinds:r,showSectionHeader:!1,fieldIdPrefix:d,onChange:c})}const Cn=["claude-code","codex","opencode","pi","agy"],En={"claude-code":"Claude Code",codex:"Codex",opencode:"OpenCode",pi:"Pi",agy:"Antigravity (agy)"},Fn=[{kind:"claude-code",binaryName:"claude",promptDelivery:{kind:"flag",flag:"-p"},mcpDelivery:{kind:"claude-config-file",flag:"--mcp-config",extraArgs:["--strict-mcp-config","--allowedTools","mcp__lobu__query_sdk,mcp__lobu__run_sdk"]},headlessArgs:[],modelFlag:"--model",effortFlag:"--effort",permissionModeFlag:"--permission-mode",budgetFlag:"--max-budget-usd",timeoutFlag:null,trailingArgs:[]},{kind:"agy",binaryName:"agy",promptDelivery:{kind:"flag",flag:"-p"},mcpDelivery:{kind:"none"},headlessArgs:["--dangerously-skip-permissions"],modelFlag:"--model",effortFlag:"--effort",permissionModeFlag:null,budgetFlag:null,timeoutFlag:{flag:"--print-timeout",suffix:"s"},trailingArgs:[]},{kind:"opencode",binaryName:"opencode",promptDelivery:{kind:"positional",subcommand:["run"]},mcpDelivery:{kind:"opencode-config-env",variable:"OPENCODE_CONFIG_CONTENT"},headlessArgs:["--auto","--print-logs","--log-level","ERROR"],modelFlag:"-m",effortFlag:"--variant",permissionModeFlag:null,budgetFlag:null,timeoutFlag:null,trailingArgs:[]},{kind:"codex",binaryName:"codex",promptDelivery:{kind:"positional",subcommand:["exec"]},mcpDelivery:{kind:"none"},headlessArgs:["--skip-git-repo-check","--sandbox","workspace-write","-c","sandbox_workspace_write.network_access=true"],modelFlag:"-m",effortFlag:"-c",effortConfigKey:"model_reasoning_effort",permissionModeFlag:null,budgetFlag:null,timeoutFlag:null,trailingArgs:[]},{kind:"pi",binaryName:"pi",promptDelivery:{kind:"positional",subcommand:[]},mcpDelivery:{kind:"none"},headlessArgs:["-p","--no-session","--tools","read,bash,edit,write"],modelFlag:"--model",effortFlag:"--thinking",permissionModeFlag:null,budgetFlag:null,timeoutFlag:null,trailingArgs:[]}];new Map(Fn.map(n=>[n.kind,n]));const It={agents:!0,lobuEmbedded:!1};function An(){const{data:n}=Ss({queryKey:["features"],queryFn:async()=>{const t=await ws(`${Cs}/api/features`);return t.ok?t.json():It},staleTime:3e4,refetchInterval:6e4});return n??It}const qt=["slack","imessage"],ut="__none__";function Ge(n){return`${n.connection_id}:${n.feed_key}`}function On(n){const t=n.indexOf(":");if(t<=0)return null;const s=Number(n.slice(0,t)),r=n.slice(t+1);return!Number.isSafeInteger(s)||s<=0||!r?null:{connection_id:s,channel_id:r}}function mt(n){return n?`${n.connection_id}:${n.channel_id}`:""}function et(n){return`${n.display_name||n.feed_key} (${n.feed_key})`}function Tn({organizationId:n,agentId:t,value:s,onChange:r,disabled:d=!1,automationName:u,onPendingChange:c}){const{data:a=[],isLoading:x}=Es(n),m=mt(s),[S,f]=i.useState(null),[I,h]=i.useState(!1),j=i.useRef(t),y=i.useMemo(()=>a.filter(g=>g.store==="channel_messages"&&g.target_agent_id===t&&qt.includes(g.connector_key)),[a,t]);i.useEffect(()=>{if(j.current===t||(j.current=t,f(null),h(!1),s==null))return;const g=mt(s);if(g==="")return;a.some(se=>se.store==="channel_messages"&&se.target_agent_id===t&&qt.includes(se.connector_key)&&Ge(se)===g)||r(null)},[t,a,s,r]);const w=S??m,P=w===""?ut:w,_=y.find(g=>Ge(g)===w),q=S!==null&&S!==""&&S!==m;i.useEffect(()=>{c?.(q)},[q,c]);const N=_??(S?void 0:y.find(g=>Ge(g)===m)),K=g=>{const G=g===ut?"":g;if(G===""){f(null),h(!1),r(null);return}if(G===m){f(null),h(!1);return}f(G),h(!1)},X=g=>{if(h(g),g&&S){const G=On(S);G&&(f(null),r(G))}else!g&&S&&f(null)},b=(s&&mt(s)!==""?s:void 0)??(_?{connection_id:_.connection_id,channel_id:_.feed_key}:void 0),C=(u??"").trim()||"This automation";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{htmlFor:"automation-delivery-target",children:["Digest destination"," ",e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(optional)"})]}),t?e.jsxs(ie,{value:P,onValueChange:K,disabled:d||x,children:[e.jsx(re,{id:"automation-delivery-target",className:"font-mono text-sm",children:e.jsx(ce,{placeholder:x?"Loading bound channels…":y.length===0?"No bound Slack or iMessage channels":"No digest — runs stay silent"})}),e.jsxs(le,{children:[e.jsx(D,{value:ut,children:"No digest — runs stay silent"}),y.map(g=>e.jsxs(D,{value:Ge(g),children:[et(g)," · ",g.connector_key]},Ge(g)))]})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"Select a managed agent first — only channels bound to that agent can receive digests."}),t&&!x&&y.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No Slack or iMessage channels are bound to this agent yet. Link a private channel first, then select it here."}):null,q&&_?e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:I,onChange:g=>X(g.target.checked),className:"mt-0.5","aria-label":`Confirm digest delivery to ${et(_)}`}),e.jsxs("span",{className:"text-muted-foreground",children:["I confirm posting material-change digests to"," ",e.jsx("span",{className:"font-medium text-foreground",children:et(_)}),". Destination changes are audited."]})]}):null,N||b?e.jsxs("div",{className:R(Ie,"space-y-1.5 px-3 py-2"),children:[e.jsxs("p",{className:"text-xs font-medium",children:["Digest preview →"," ",e.jsx("span",{className:"font-mono font-normal",children:N?`${N.connector_key} ${et(N)} · connection ${N.connection_id}`:`${b?.channel_id} · connection ${b?.connection_id}`})]}),e.jsxs("p",{className:"font-mono text-xs",children:[C," applied 2 new + 1 updated"]}),e.jsx("p",{className:"whitespace-pre-line font-mono text-xs text-muted-foreground",children:`+ Example task (#12)
2
- ~ Follow-up item (#34)`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Sends only after a successful run with material changes. Runs with zero changes send nothing. Retries reuse the same notification and delivery receipts dedupe channel posts, but provider acceptance with a lost receipt can still duplicate."})]}):null]})}const Kt=4096;function Mn({open:n,onOpenChange:t,initial:s,onSubmit:r}){const[d,u]=i.useState(""),[c,a]=i.useState(""),[x,m]=i.useState(null);i.useEffect(()=>{n&&(u(s?.name??""),a(s?.query??""),m(null))},[n,s]);const S=()=>{const I=d.trim(),h=c.trim();if(!I){m("Give the SQL source a name.");return}if(!h){m("Enter a query.");return}if(h.length>Kt){m(`Query is too long (${h.length} chars, max ${Kt}).`);return}r({name:I,query:h}),t(!1)},f=!!s;return e.jsx(Fs,{open:n,onOpenChange:t,children:e.jsxs(As,{className:"max-w-2xl",children:[e.jsxs(Os,{children:[e.jsx(Ts,{children:f?"Edit SQL source":"SQL source"}),e.jsx(Ms,{children:"Write a query the automation runs each period. It becomes a reference in the prompt — the query travels with the chip."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"sql-source-name",children:"Name"}),e.jsx(oe,{id:"sql-source-name",value:d,onChange:I=>u(I.target.value),placeholder:"recent_cancellations",autoFocus:!f}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The output-field name this source fills."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"sql-source-query",children:"Query"}),e.jsx(ft,{value:c,onChange:a,language:"sql",placeholder:"SELECT id, payload_text, occurred_at FROM events ORDER BY occurred_at DESC",minHeight:"160px"})]}),x?e.jsx("p",{className:"text-sm text-destructive",children:x}):null]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Q,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(Q,{onClick:S,children:f?"Save":"Add source"})]})]})})}const Dn=["skill","feed","connection","connector","metric","entity_type"];function Pn({value:n,onChange:t,library:s,pinned:r,required:d,error:u,owner:c,agentId:a,sources:x,onAddSources:m}){const S=rn(Dn,Ot,{skills:s,skillAgentId:a||null}),f=i.useRef(null),[I,h]=i.useState(null),j=i.useMemo(()=>{if(!x)return[];const _=new Set(x.map(q=>q.query.trim()));return Tt(n).filter(q=>!_.has(q.query.trim()))},[n,x]),y=cn(n),w=ln(r.filter(_=>y.includes(_.name)),s),P=s.length>0;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs(k,{htmlFor:"automation-prompt",children:["Instructions"," ",d?e.jsx("span",{className:"text-destructive",children:"*"}):e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(optional)"})]}),y.length>0?e.jsxs("span",{className:"text-xs text-muted-foreground",children:[y.length,"/",Ot," skills"]}):null]}),e.jsx("div",{className:"rounded-lg border bg-background focus-within:ring-1 focus-within:ring-ring",children:e.jsx(dn,{value:n,onChange:t,onSubmit:()=>{},submitOnEnter:!1,searchRefs:S,handleRef:f,onSqlRequest:()=>h({}),onSqlEdit:(_,q)=>h({initial:_,pos:q}),placeholder:P?"What should this Automation do? Type @ to pull in a skill or a data source.":"What should this Automation do? Type @ to pull in a data source.",className:"[&_.ProseMirror]:min-h-[7rem] [&_.ProseMirror]:max-h-72 [&_.ProseMirror]:overflow-y-auto"})}),e.jsx(Mn,{open:I!==null,onOpenChange:_=>{_||h(null)},initial:I?.initial,onSubmit:_=>{f.current?.insertSql(_,I?.pos),h(null)}}),j.length>0&&m?e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-lg border border-dashed p-3",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:[j.length===1?`"${j[0]?.name}" is referenced in the instructions but is not a source on this Automation.`:`${j.length} references in the instructions are not sources on this Automation.`," ","Editing an Automation does not add them automatically."]}),e.jsx(Q,{type:"button",variant:"outline",size:"sm",onClick:()=>m(Tt(n,x)),children:j.length===1?"Add as a source":"Add as sources"})]}):null,y.length>0?e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:y.map(_=>{const q=w.includes(_),N=!s.some(K=>K.name===_);return e.jsxs(Ds,{variant:N?"destructive":"secondary",className:"font-normal",children:[_,N?" · unavailable":q?" · newer text":null]},_)})}):null,w.length>0?e.jsxs("p",{className:"rounded-lg border border-dashed p-3 text-xs text-muted-foreground",children:[w.length===1?`"${w[0]}" has been edited since this Automation pinned it.`:`${w.length} skills have been edited since this Automation pinned them.`," ","This Automation keeps running the pinned text until you save it again."]}):null,u?e.jsx("p",{className:"text-xs text-destructive",children:u}):null,!P&&a?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This agent has no skills yet."," ",e.jsx(Ps,{to:"/$owner/agents/$agentId/skills",params:{owner:c,agentId:a},className:"font-medium text-foreground underline underline-offset-2",children:"Add one"})," ","to reuse instructions across Automations."]}):u?null:e.jsx("p",{className:"text-xs text-muted-foreground",children:P?"Type @ to pull in a skill, a feed, connection, connector, metric, entity type, or a SQL query. Skill text is saved with this version, so later edits to the skill do not change this Automation until you update it.":"Type @ to pull in a feed, connection, connector, metric, entity type, or a SQL query this Automation should read."})]})}const Ln=["connection","connector","feed","metric","entity_type"];function Rn({sources:n,onChange:t,disabled:s}){const{currentOwner:r,resolvedOrganizationId:d}=ss(),[u,c]=i.useState(""),{refs:a}=un({owner:r,organizationId:d,kinds:Ln,query:u,limitPerKind:10});return e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Sources"}),n.length>0?e.jsx("ul",{className:"space-y-2",children:n.map(x=>e.jsxs("li",{className:"flex items-start gap-2 rounded-lg border bg-background p-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-mono text-xs font-medium",children:x.name}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:x.query})]}),e.jsx(Q,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0","aria-label":`Remove source ${x.name}`,disabled:s,onClick:()=>t(n.filter(m=>m.query!==x.query)),children:e.jsx(Yt,{className:"h-3.5 w-3.5"})})]},x.query))}):null,e.jsx("div",{className:"flex gap-2",children:e.jsx(st,{searchPlaceholder:"Search feeds, connections, metrics…",emptyText:"No matching reference.",onQueryChange:c,trigger:()=>e.jsxs(Q,{type:"button",variant:"outline",size:"sm",disabled:s,children:[e.jsx(Je,{className:"mr-2 h-3.5 w-3.5"}),"Add source"]}),children:x=>a.map(m=>e.jsxs(Ke,{value:`${m.label} ${m.kind}`,onSelect:()=>{t(mn(m,n)),x()},children:[e.jsx("span",{className:"truncate text-sm",children:m.label}),e.jsx("span",{className:"ml-2 shrink-0 text-xs text-muted-foreground",children:m.kind})]},`${m.kind}:${m.id}`))})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Data handed to the agent alongside its instructions, and what change detection is measured against. Editing an Automation does not re-read the instructions for these — this list is what runs. To add a SQL source, write it with @ in the instructions above. Automation-owned; skills never add or remove sources."})]})}function $n({organizationId:n,value:t,onChange:s,className:r}){const{data:d=[]}=Ls(n),u=nn(d),c=u.find(a=>a.id===t);return e.jsx(st,{contentClassName:"w-[300px]",searchPlaceholder:"Search entities...",emptyText:"No entities found.",trigger:a=>e.jsxs(Q,{variant:"outline",role:"combobox","aria-expanded":a,className:R("w-full justify-between",r),children:[c?`${c.name} (${c.entityType})`:"All workspace",e.jsx(yt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:a=>e.jsxs(e.Fragment,{children:[e.jsxs(Ke,{value:"all workspace",onSelect:()=>{s(void 0),a()},className:"cursor-pointer",children:[e.jsx(tt,{className:R("mr-2 h-4 w-4",t===void 0?"opacity-100":"opacity-0")}),e.jsx("span",{children:"All workspace"})]}),u.map(x=>e.jsxs(Ke,{value:`${x.name} ${x.entityType}`,onSelect:()=>{s(x.id),a()},className:"cursor-pointer",children:[e.jsx(tt,{className:R("mr-2 h-4 w-4",t===x.id?"opacity-100":"opacity-0")}),e.jsxs("span",{children:[x.name," ",e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",x.entityType,")"]})]})]},x.id))]})})}function vt(n){if(Array.isArray(n))return n;if(typeof n=="string"&&n.startsWith("{")&&n.endsWith("}")){const t=n.slice(1,-1);return t?t.split(",").map(s=>s.trim()):[]}return[]}const In=Cn.map(n=>({value:n,label:En[n]})),Wt=[{value:"agent",label:"Agent",hint:"An agent reads the window and follows your instructions."},{value:"code",label:"Code",hint:"A deterministic script processes each completed window."},{value:"both",label:"Agent + code",hint:"An agent extracts per your instructions, then the script runs."}];function Bt(n){const t=!!(n?.prompt?.trim()||n?.skills?.some(r=>r.content.trim())),s=!!n?.reaction_script?.trim();return t&&s?"both":s?"code":"agent"}const qn=["text","number","date","boolean","json"],Kn=[{value:"key",label:"Key"},{value:"plain",label:"Plain"}],ht=[{value:"plan",label:"Plan first"},{value:"auto",label:"Auto"},{value:"acceptEdits",label:"Accept edits"},{value:"dontAsk",label:"Don't ask"},{value:"bypassPermissions",label:"Bypass permissions"}];let zt=0;function Wn(){return zt+=1,`field-${zt}`}function as(n={}){return{id:Wn(),name:n.name??"",type:n.type??"text",role:n.role??"plain"}}function He(n){return n.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"")}function Bn(n){return n?Object.keys(n).every(t=>["entity_type","entity_path","key_fields","key_output_field"].includes(t)):!0}function Vt(n){return n?Bn(n.keying_config)?"fields":"json":"fields"}function Ut(n){const t=n?.keying_config?.entity_type;return typeof t=="string"?t:""}function Qt(n){const t=n?.keying_config?.entity_path;return typeof t=="string"&&t.trim()?t:"$"}function Gt(n){const t=new Map,s=Array.isArray(n?.keying_config?.key_fields)?n?.keying_config?.key_fields:[];for(const r of s){if(typeof r!="string")continue;const d=He(r);d&&t.set(d,as({name:d,role:"key"}))}return Array.from(t.values())}function _e(n,t){const s=n?.execution_config?.[t];return typeof s=="number"||typeof s=="string"?String(s):""}function Jt(n,t,s){const r=n?.execution_config?.[t];return typeof r=="string"&&s.includes(r)?r:""}function xt(n,t){const s=n.trim();if(!s)return{};const r=Number(s);return Number.isFinite(r)?{value:r}:{error:`${t} must be a number.`}}function Ht({entityType:n,entityPath:t,fields:s}){const d=s.map(a=>({...a,name:He(a.name)})).filter(a=>a.name).filter(a=>a.role==="key").map(a=>a.name),u=He(n),c=t.trim()||"$";return d.length>0&&!u?{error:"Key fields need an output entity type."}:(d.length>0,{keyingConfig:d.length>0?{entity_type:u,entity_path:c,key_fields:d,key_output_field:`${u}_key`}:void 0})}function zn(n,t){return e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:n}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t})]})}function Xt(n){return!!(n?.keying_config||n?.reactions_guidance||n?.model_config||n?.execution_config||n?.sources?.length||vt(n?.tags).length)}function Vn({organizationId:n,entityId:t,prefill:s,onSubmit:r,isSubmitting:d,error:u,isEditing:c,onCancel:a,triggerFields:x,submitLabel:m="Create Automation",submitDisabled:S=!1,triggers:f}){const{lobuEmbedded:I}=An(),{currentOwner:h}=ss(),{data:j=[]}=Rs(),{data:y=[]}=$s(),[w,P]=i.useState(s?.managed_agent_id??""),_=!!s?.managed_agent_id&&!c,[q,N]=i.useState(s?.delivery_target??null),[K,X]=i.useState(!1),[te,b]=i.useState(s?.device_worker_id??""),[C,g]=i.useState(s?.device_worker_id?"device":"agent"),[G,se]=i.useState(s?.agent_kind??""),{data:$=[]}=Zt({organizationId:n}),[V,Y]=i.useState(s?.name??""),[he,xe]=i.useState(s?.slug??""),[ke,be]=i.useState(!!s?.slug),[M,ge]=i.useState(s?.description??""),[ne,Z]=i.useState(s?.prompt??""),[J,ae]=i.useState(!1),Se=s?.skills??[],[Fe,we]=i.useState(s?.sources??[]),[p,W]=i.useState(s?.entity_id??t),[H,pe]=i.useState(s?.reaction_script??""),[E,Ae]=i.useState(()=>Bt(s)),[ve,Oe]=i.useState(s?.keying_config?JSON.stringify(s.keying_config,null,2):""),[de,B]=i.useState(null),[ye,Me]=i.useState(()=>Vt(s)),[Te,ue]=i.useState(()=>Ut(s)),[De,We]=i.useState(()=>Qt(s)),[fe,me]=i.useState(()=>Gt(s)),[Be,Pe]=i.useState(s?.reactions_guidance??""),[nt,Ce]=i.useState(()=>_e(s,"timeout_seconds")),[at,ot]=i.useState(()=>_e(s,"max_budget_usd")),[ze,Xe]=i.useState(()=>_e(s,"model")),[Ve,it]=i.useState(()=>Jt(s,"permission_mode",ht.map(o=>o.value))),[Le,l]=i.useState(()=>_e(s,"effort")),[v,F]=i.useState(()=>_e(s,"finalize_nudges")),[ee,T]=i.useState(null),[je,A]=i.useState(vt(s?.tags).join(", ")),[Re,Ue]=i.useState(""),[rt,jt]=i.useState(!!(c||Xt(s)));i.useEffect(()=>{s&&(Y(s.name??""),xe(s.slug??""),be(!!s.slug),ge(s.description??""),Z(s.prompt??""),ae(!1),we(s.sources??[]),W(s.entity_id??t),b(s.device_worker_id??""),g(s.device_worker_id?"device":"agent"),se(s.agent_kind??""),pe(s.reaction_script??""),Ae(Bt(s)),Oe(s.keying_config?JSON.stringify(s.keying_config,null,2):""),B(null),Me(Vt(s)),ue(Ut(s)),We(Qt(s)),me(Gt(s)),Pe(s.reactions_guidance??""),Ce(_e(s,"timeout_seconds")),ot(_e(s,"max_budget_usd")),Xe(_e(s,"model")),it(Jt(s,"permission_mode",ht.map(o=>o.value))),l(_e(s,"effort")),F(_e(s,"finalize_nudges")),T(null),A(vt(s.tags).join(", ")),Ue(""),P(s.managed_agent_id??""),N(s.delivery_target??null),jt(!!(c||Xt(s))))},[s,t,c]);const os=ke?he:At(V),{data:is}=Is(w||null),{data:rs}=qs(w||null,{enabled:!!w}),ct=on(is??null,rs?.catalog??[]),cs=hn(f),lt=H.trim().length>0,Ye=!c&&E==="code"?"":ne,ls=!c&&E==="agent"?void 0:H.trim()||void 0,_t=(c||E==="code")&&lt,Nt=xn(Ye,ct,f,_t),ds=J||Ye.trim()!==""?Nt:null,kt=gn(Ye,ct),bt=!c&&E!=="agent",us=C==="device"&&!w.trim(),St=!!V.trim()&&!us&&!Nt&&(!bt||lt)&&!K,ms=cs&&!_t&&kt.length===0,hs=()=>{if(!St)return;let o;if(ye==="fields"){const Ne=Ht({entityType:Te,entityPath:De,fields:fe});if(Ne.error){B(Ne.error);return}o=Ne.keyingConfig,B(null)}else{if(ve.trim())try{const Ne=JSON.parse(ve);if(typeof Ne!="object"||Array.isArray(Ne)){B("Keying config must be a JSON object.");return}o=Ne}catch{B("Invalid JSON. Please check the syntax.");return}B(null)}const O=xt(nt,"Timeout");if(O.error){T(O.error);return}if(O.value!==void 0&&(!Number.isInteger(O.value)||O.value<1)){T("Timeout must be a whole number greater than 0.");return}const z=xt(at,"Budget");if(z.error){T(z.error);return}if(z.value!==void 0&&z.value<0){T("Budget cannot be negative.");return}const L=xt(v,"Finalize nudges");if(L.error){T(L.error);return}if(L.value!==void 0&&(!Number.isInteger(L.value)||L.value<0||L.value>5)){T("Finalize nudges must be a whole number from 0 to 5.");return}const Ee={...O.value!==void 0?{timeout_seconds:O.value}:{},...z.value!==void 0?{max_budget_usd:z.value}:{},...ze.trim()?{model:ze.trim()}:{},...Ve?{permission_mode:Ve}:{},...Le.trim()?{effort:Le.trim()}:{},...L.value!==void 0?{finalize_nudges:L.value}:{}},U=Object.keys(Ee).length>0||c?Ee:void 0;T(null);const xs=je.trim()?je.split(",").map(Ne=>Ne.trim()).filter(Boolean):void 0;r({slug:os,name:V.trim(),description:M.trim()||void 0,prompt:Ye,skills:kt,entity_id:p,sources:Fe,reaction_script:ls,keying_config:o,reactions_guidance:Be.trim()||void 0,execution_config:U,tags:xs,outputs:s?.outputs,change_notes:Re.trim()||void 0,managed_agent_id:C==="manual"?null:w.trim()||null,device_worker_id:C==="device"&&te.trim()||null,agent_kind:C==="device"&&G.trim()||null,delivery_target:q})},wt=e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{htmlFor:"scratch-reaction",children:["Reaction Script"," ",bt?e.jsx("span",{className:"text-destructive",children:"*"}):e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(optional)"})]}),e.jsx(ft,{value:H,onChange:pe,language:"typescript",placeholder:"export default async function reaction(ctx) { ... }",minHeight:"120px"}),c?null:e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Runs deterministically on every completed window, after agent extraction. Declare an ",e.jsx("code",{children:"input"})," export to set the window's extraction contract."]})]});return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs(k,{htmlFor:"scratch-name",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),!c&&e.jsx("button",{type:"button",onClick:()=>be(!ke),className:"text-xs text-muted-foreground hover:text-foreground",children:ke?"Use automatic slug":"Customize slug"})]}),e.jsx(oe,{id:"scratch-name",value:V,onChange:o=>Y(o.target.value),placeholder:"e.g., Escalation signals"}),!c&&ke?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-slug",children:"Slug"}),e.jsx(oe,{id:"scratch-slug",value:he,onChange:o=>xe(o.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),placeholder:At(V)||"custom-slug"})]}):null]})}),c?null:e.jsxs("fieldset",{className:"space-y-2",children:[e.jsx("legend",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"How does this run?"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Wt.map(o=>e.jsx("button",{type:"button","aria-pressed":E===o.value,onClick:()=>Ae(o.value),className:R("rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors",E===o.value?"bg-secondary text-secondary-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:o.label},o.value))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Wt.find(o=>o.value===E)?.hint})]}),c||E!=="code"?e.jsx(Pn,{value:ne,onChange:o=>{ae(!0),Z(o)},library:ct,pinned:Se,required:ms,error:ds,owner:h??"",agentId:w,sources:c?Fe:void 0,onAddSources:c?we:void 0}):null,!c&&E!=="agent"?wt:null,c?e.jsx(Rn,{sources:Fe,onChange:we,disabled:d}):null,e.jsx("div",{className:"space-y-4",children:x}),e.jsx(Tn,{organizationId:n,agentId:C==="agent"?w.trim():"",value:q,onChange:N,disabled:d,automationName:V,onPendingChange:X}),K?e.jsx("p",{className:"text-xs text-destructive",children:"Confirm the digest destination above before saving — an unconfirmed destination is not sent."}):null,e.jsxs(Q,{type:"button",variant:"ghost",className:"w-full justify-between px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-expanded":rt,"aria-controls":"automation-advanced-settings",onClick:()=>jt(o=>!o),children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ks,{className:"h-4 w-4"}),"Advanced settings"]}),e.jsx(es,{className:R("h-4 w-4 transition-transform",rt&&"rotate-180")})]}),e.jsxs("div",{id:"automation-advanced-settings",className:R("space-y-4",!rt&&"hidden"),children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-description",children:"Description"}),e.jsx(oe,{id:"scratch-description",value:M,onChange:o=>ge(o.target.value),placeholder:"What this automation does"})]}),!t&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Entity scope"}),e.jsx($n,{organizationId:n,value:p,onChange:W}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Limit this automation to one workspace entity."})]}),c?wt:null,e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(k,{children:"Output fields"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Key fields become stable entity keys."})]}),e.jsx(Q,{type:"button",variant:"outline",size:"sm",onClick:()=>{if(ye==="fields"){const o=Ht({entityType:Te,entityPath:De,fields:fe});if(o.error){B(o.error);return}Oe(o.keyingConfig?JSON.stringify(o.keyingConfig,null,2):""),Me("json")}else Me("fields");B(null)},children:ye==="fields"?"Edit JSON":"Use fields"})]}),ye==="fields"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-output-entity-type",children:"Output entity type"}),e.jsx(st,{contentClassName:"w-[320px]",searchPlaceholder:"Search or type a new type…",emptyText:"Type a name to create a new entity type.",trigger:o=>e.jsxs(Q,{type:"button",variant:"outline",role:"combobox","aria-expanded":o,id:"scratch-output-entity-type",className:"w-full justify-between font-mono text-sm font-normal",children:[e.jsx("span",{className:R("truncate",!Te&&"text-muted-foreground"),children:Te||"Select entity type"}),e.jsx(yt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:(o,O)=>{const z=He(O),L=$.filter(U=>!U.backing_sql),Ee=L.some(U=>U.slug===z);return e.jsxs(e.Fragment,{children:[L.map(U=>e.jsxs(Ke,{value:`${U.name??U.slug} ${U.slug}`,onSelect:()=>{ue(U.slug),B(null),o()},className:"cursor-pointer",children:[e.jsx(tt,{className:R("mr-2 h-4 w-4",Te===U.slug?"opacity-100":"opacity-0")}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-mono text-sm",children:U.slug}),U.name&&U.name!==U.slug&&e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:U.name})]})]},U.slug)),z&&!Ee&&e.jsxs(Ke,{value:O,onSelect:()=>{ue(z),B(null),o()},className:"cursor-pointer",children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),e.jsxs("span",{className:"text-sm",children:["Create"," ",e.jsx("span",{className:"font-mono",children:z})]})]})]})}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-output-path",children:"Output path"}),e.jsx(oe,{id:"scratch-output-path",value:De,onChange:o=>{We(o.target.value),B(null)},placeholder:"$.items[*]",className:"font-mono text-sm"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(k,{children:"Fields"}),e.jsxs(Q,{type:"button",variant:"outline",size:"sm",onClick:()=>{me(o=>[...o,as()]),B(null)},children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),"Add field"]})]}),fe.length===0?e.jsx("div",{className:R(Ie,"px-3 py-2 text-sm text-muted-foreground"),children:"No output fields configured."}):e.jsx("div",{className:"space-y-2",children:fe.map(o=>e.jsxs("div",{className:R(Ie,"grid gap-2 p-3 sm:grid-cols-[minmax(0,1fr)_128px_minmax(0,240px)_auto]"),children:[e.jsx(oe,{value:o.name,onChange:O=>{const z=He(O.target.value);me(L=>L.map(Ee=>Ee.id===o.id?{...Ee,name:z}:Ee)),B(null)},placeholder:"severity","aria-label":"Output field name",className:"font-mono text-sm"}),e.jsxs(ie,{value:o.type,onValueChange:O=>{me(z=>z.map(L=>L.id===o.id?{...L,type:O}:L))},children:[e.jsx(re,{"aria-label":"Output field type",children:e.jsx(ce,{})}),e.jsx(le,{children:qn.map(O=>e.jsx(D,{value:O,children:O},O))})]}),e.jsx("div",{className:"grid grid-cols-2 rounded-md border border-input bg-background p-1",children:Kn.map(O=>e.jsx("button",{type:"button",onClick:()=>{me(z=>z.map(L=>L.id===o.id?{...L,role:O.value}:L)),B(null)},className:R("rounded-sm px-2 py-1 text-xs transition-colors",o.role===O.value?"bg-muted/70 text-foreground":"text-muted-foreground hover:text-foreground"),children:O.label},O.value))}),e.jsx(Q,{type:"button",variant:"ghost",size:"icon",onClick:()=>{me(O=>O.filter(z=>z.id!==o.id)),B(null)},"aria-label":"Remove output field",children:e.jsx(ts,{className:"h-4 w-4"})})]},o.id))})]}),de&&e.jsx("p",{className:"text-xs text-destructive",children:de})]}):e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-keying-config",children:"Keying Config (JSON)"}),e.jsx(ft,{value:ve,onChange:o=>{Oe(o),B(null)},language:"json",placeholder:'{ "entity_type": "topic", "entity_path": "$.items[*]", "key_fields": ["name"], "key_output_field": "entity_key" }',minHeight:"60px"}),de&&e.jsx("p",{className:"text-xs text-destructive",children:de})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-reactions-guidance",children:"Reactions Guidance"}),e.jsx(Ws,{id:"scratch-reactions-guidance",value:Be,onChange:o=>Pe(o.target.value),placeholder:"Guidance text for the reaction system (e.g., when to alert, severity thresholds)...",className:"font-mono text-xs min-h-[80px]"})]}),e.jsxs("div",{className:"space-y-4",children:[zn("Run settings","Choose where the automation runs and the budget it can use."),!_&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-runs-on",children:"Runs on"}),e.jsxs(ie,{value:C,onValueChange:o=>g(o),children:[e.jsx(re,{id:"scratch-runs-on",className:"text-sm",children:e.jsx(ce,{})}),e.jsxs(le,{children:[e.jsx(D,{value:"agent",children:"Managed agent"}),e.jsx(D,{value:"device",children:"On a device"}),e.jsx(D,{value:"manual",children:"Manual-only"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C==="agent"?"Automated runs dispatch to a managed Lobu agent.":C==="device"?"Automated runs are claimed and executed locally by a device worker (Mac app, remote worker).":"No executor — this automation runs only when started manually by a connected client."})]}),!_&&C!=="manual"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{htmlFor:"scratch-agent-id",children:["Agent",C==="device"&&e.jsx("span",{className:"text-destructive",children:" *"})]}),I?e.jsxs(ie,{value:w||"__unselected__",onValueChange:o=>{P(o==="__unselected__"?"":o)},children:[e.jsx(re,{id:"scratch-agent-id",className:"font-mono text-sm",children:e.jsx(ce,{placeholder:"Select a Lobu agent"})}),e.jsx(le,{children:j.map(o=>e.jsxs(D,{value:o.agentId,children:[o.name," (",o.agentId,")"]},o.agentId))})]}):e.jsx(oe,{id:"scratch-agent-id",value:w,onChange:o=>{P(o.target.value)},placeholder:"e.g., agent-123",className:"font-mono text-sm"}),C==="device"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"The device run uses this agent's memory and tools, acting as the agent's owner."})]}),!_&&C==="device"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-device-id",children:"Device"}),e.jsxs(ie,{value:te||"__unselected__",onValueChange:o=>b(o==="__unselected__"?"":o),children:[e.jsx(re,{id:"scratch-device-id",className:"font-mono text-sm",children:e.jsx(ce,{placeholder:"Select a device worker"})}),e.jsx(le,{children:y.map(o=>e.jsx(D,{value:o.id,children:o.label||o.platform||o.id},o.id))})]})]}),!_&&C==="device"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-device-agent-kind",children:"Runs as"}),e.jsxs(ie,{value:G||"__default__",onValueChange:o=>se(o==="__default__"?"":o),children:[e.jsx(re,{id:"scratch-device-agent-kind",className:"text-sm",children:e.jsx(ce,{placeholder:"Device default"})}),e.jsxs(le,{children:[e.jsx(D,{value:"__default__",children:"Device default"}),In.map(o=>e.jsx(D,{value:o.value,children:o.label},o.value))]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Device default uses that device's preferred local agent. Availability is checked again when a run is claimed, so a run stays queued if its selected runtime is no longer available."})]}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Model"}),e.jsx(an,{value:ze,onChange:o=>{Xe(o),T(null)},placeholder:"Use agent default"})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-timeout",children:"Timeout seconds"}),e.jsx(oe,{id:"scratch-timeout",type:"number",min:1,max:86400,value:nt,onChange:o=>{Ce(o.target.value),T(null)},placeholder:"600"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-permission-mode",children:"Permission mode"}),e.jsxs(ie,{value:Ve||"__default__",onValueChange:o=>{it(o==="__default__"?"":o),T(null)},children:[e.jsx(re,{id:"scratch-permission-mode",children:e.jsx(ce,{placeholder:"Default"})}),e.jsxs(le,{children:[e.jsx(D,{value:"__default__",children:"Default"}),ht.map(o=>e.jsx(D,{value:o.value,children:o.label},o.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-effort",children:"Effort"}),e.jsx(oe,{id:"scratch-effort",value:Le,onChange:o=>{l(o.target.value),T(null)},placeholder:"Default","aria-describedby":"scratch-effort-help"}),e.jsx("p",{id:"scratch-effort-help",className:"text-xs text-muted-foreground",children:"For device runs, use a value supported by the selected CLI and model. Leave empty for its default."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-finalize-nudges",children:"Finalize nudges"}),e.jsx(oe,{id:"scratch-finalize-nudges",type:"number",min:0,max:5,value:v,onChange:o=>{F(o.target.value),T(null)},placeholder:"Default"})]})]}),ee&&e.jsx("p",{className:"text-xs text-destructive",children:ee})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-tags",children:"Tags"}),e.jsx(oe,{id:"scratch-tags",value:je,onChange:o=>A(o.target.value),placeholder:"ops, support, risk"})]}),c&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-change-notes",children:"Change notes"}),e.jsx(oe,{id:"scratch-change-notes",value:Re,onChange:o=>Ue(o.target.value),placeholder:"What changed in this version?"})]})]})]}),u&&!de&&!ee&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:u}),e.jsx(pt,{onCancel:a,children:e.jsx(Q,{onClick:hs,disabled:!St||d||S,children:d?e.jsxs(e.Fragment,{children:[e.jsx(Bs,{size:"lg",className:"mr-2"}),c?"Saving...":"Creating..."]}):c?"Save Automation":m})})]})}function Un(n,t){const s=n??null,r=t??null;return s===null||r===null?s===r:s.connection_id===r.connection_id&&s.channel_id===r.channel_id}function Qn(n){const t=n.detail??{};return{name:n.name,slug:t.slug,description:t.description??n.description??void 0,prompt:t.prompt,triggers:t.triggers,sources:t.sources,keying_config:t.keying_config,reactions_guidance:t.reactions_guidance,reaction_script:t.reaction_script,model_config:t.model_config,execution_config:t.execution_config,tags:t.tags,outputs:t.outputs}}function aa({startFromScratch:n=!1,onClose:t,hideCancel:s=!1,hideHeader:r=!1,organizationId:d,entityId:u,entityName:c,prefillAgentId:a,onSuccess:x,editingAutomation:m,catalogPrefill:S,onDraft:f,triggerFields:I,submitLabel:h,submitDisabled:j,createFields:y,onPrefillTriggers:w}){const P=zs(),_=Vs(),q=Us(),N=Qs(),K=!!m,[X,te]=i.useState(n?"scratch":"template"),[b,C]=i.useState(void 0),[g,G]=i.useState(void 0),{data:se=[],isLoading:$}=Gs(),[V,Y]=i.useState(""),he=i.useMemo(()=>a?{managed_agent_id:a}:void 0,[a]),xe=i.useMemo(()=>se.map(p=>({key:p.id,name:p.name,description:p.description??"",badges:p.detail?.tags??[]})),[se]),ke=i.useMemo(()=>xe.filter(p=>p.name.toLowerCase().includes(V.toLowerCase())||p.description.toLowerCase().includes(V.toLowerCase())),[xe,V]),be=p=>{const W=se.find(pe=>pe.id===p.key);if(!W)return;const H=Qn(W);G(a?{...H,managed_agent_id:a}:H),w?.(H.triggers??[]),te("scratch")},M=()=>{P.reset(),_.reset(),te("template"),C(void 0),G(void 0),t()},ge=K?y?.triggers??m.triggers??[]:y?.triggers??g?.triggers??S?.triggers??[],ne=async p=>{try{if(f){await f(p);return}if(K){const W=y?.triggers??m.triggers??[],H=m.reaction_script??"",pe=p.reaction_script??"";pe&&pe!==H&&await q.mutateAsync({automation_id:m.automation_id,reaction_script:pe}),await _.mutateAsync({automation_id:m.automation_id,name:p.name,description:p.description,prompt:p.prompt,sources:p.sources,set_as_current:!0,triggers:W,keying_config:p.keying_config,reactions_guidance:p.reactions_guidance,change_notes:p.change_notes}),!pe&&H&&await q.mutateAsync({automation_id:m.automation_id,reaction_script:""});const E={};p.model_config!==void 0&&(E.model_config=p.model_config),p.execution_config!==void 0&&(E.execution_config=p.execution_config),p.tags!==void 0&&(E.tags=p.tags),p.delivery_target!==void 0&&!Un(p.delivery_target,m.delivery_target)&&(E.delivery_target=p.delivery_target),p.managed_agent_id!==void 0&&(E.managed_agent_id=p.managed_agent_id||null),p.agent_kind!==void 0&&(E.agent_kind=p.agent_kind||null),p.device_worker_id!==void 0&&(E.device_worker_id=p.device_worker_id||null),Object.keys(E).length>0&&await N.mutateAsync({automation_id:m.automation_id,...E}),M(),x?.(m.automation_id)}else{const W=y?.triggers??g?.triggers??S?.triggers??[],H=await P.mutateAsync({...p,managed_agent_id:p.managed_agent_id??void 0,device_worker_id:p.device_worker_id??void 0,agent_kind:p.agent_kind??void 0,delivery_target:p.delivery_target??void 0,triggers:W});M(),H.automation_id&&x?.(H.automation_id)}}catch{}},Z=K?_:P;let J="Add an automation";K?J="Edit automation configuration (saves as a new version)":c&&(J=`Add an automation for ${c}`);const ae=m?{entity_id:m.entity_id,name:m.name,slug:m.slug,description:m.description,prompt:m.prompt,sources:m.sources,reaction_script:m.reaction_script,device_worker_id:m.device_worker_id??void 0,agent_kind:m.agent_kind??void 0,keying_config:m.keying_config,reactions_guidance:m.reactions_guidance,model_config:m.model_config,execution_config:m.execution_config,tags:m.tags,managed_agent_id:m.managed_agent_id??void 0,delivery_target:m.delivery_target??void 0}:void 0,Se=K?"Edit Automation":"Create Automation",Fe=e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h1",{className:"text-2xl font-semibold leading-tight",children:Se}),e.jsx("p",{className:"text-sm text-muted-foreground",children:J})]}),we=e.jsxs("div",{className:"py-6 space-y-6",children:[!K&&e.jsxs("div",{className:"flex flex-wrap justify-start gap-2",children:[e.jsx(gt,{active:X==="template",onClick:()=>te("template"),icon:e.jsx(Js,{className:"h-4 w-4"}),label:"From templates"}),e.jsx(gt,{active:X==="scratch",onClick:()=>{te("scratch"),C(void 0),G(void 0)},icon:e.jsx(Je,{className:"h-4 w-4"}),label:"From scratch"}),e.jsx(gt,{active:X==="clone",onClick:()=>te("clone"),icon:e.jsx(Hs,{className:"h-4 w-4"}),label:"Clone existing"})]}),!K&&X==="template"?e.jsxs(e.Fragment,{children:[$?e.jsx(Xs,{}):e.jsx(Ys,{items:ke,searchQuery:V,onSearchChange:Y,onSelect:be,searchPlaceholder:"Search templates...",searchAriaLabel:"Search automation templates",emptyMessage:xe.length===0?"No automation templates available.":void 0}),r&&!s?e.jsx(pt,{onCancel:M}):null]}):!K&&X==="clone"&&!b?e.jsxs(e.Fragment,{children:[e.jsx(Gn,{organizationId:d,onSelect:p=>{C(p),w?.(p.triggers??[]),te("scratch")}}),r&&!s?e.jsx(pt,{onCancel:M}):null]}):e.jsx(Vn,{organizationId:d,entityId:u,prefill:ae??b??g??S??he,onSubmit:ne,isSubmitting:Z.isPending,error:Z.error?Z.error.message:null,isEditing:K,onCancel:s?void 0:M,triggerFields:I,submitLabel:h,submitDisabled:j,triggers:ge})]});return e.jsxs("div",{className:"flex flex-col",children:[r?null:Fe,we]})}function gt({active:n,onClick:t,icon:s,label:r}){return e.jsxs("button",{type:"button",onClick:t,className:R("flex items-center gap-2 rounded-md border px-3 py-2 text-sm transition-colors",n?"border-primary bg-primary/5 text-primary":"border-border text-muted-foreground hover:border-muted-foreground/30 hover:text-foreground"),children:[s,r]})}function Gn({organizationId:n,onSelect:t}){const{data:s,isLoading:r}=Zs(n),[d,u]=i.useState(""),c=(s||[]).filter(a=>a.name?.toLowerCase().includes(d.toLowerCase()));return r?e.jsx(en,{label:"automations",variant:"list-picker",rows:4}):!s||s.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"No existing automations to clone."}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{type:"text",value:d,onChange:a=>u(a.target.value),placeholder:"Search automations...",className:"w-full rounded-md border px-3 py-2 text-sm bg-background"}),e.jsxs("div",{className:"space-y-2 max-h-[400px] overflow-y-auto",children:[c.map(a=>e.jsxs("button",{type:"button",onClick:()=>t({name:`${a.name} (copy)`,slug:`${a.slug||a.automation_id}-copy`,prompt:a.prompt,keying_config:a.keying_config,triggers:a.triggers,sources:a.sources,outputs:a.outputs}),className:"w-full text-left rounded-md border p-3 hover:border-primary/50 hover:bg-primary/5 transition-colors",children:[e.jsx("p",{className:"text-sm font-medium",children:a.name}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[a.entity_name||"Space-level"," · v",a.version??"?"]})]},a.automation_id)),c.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No automations match your search."})]})]})}export{na as A,aa as C};
3
- //# sourceMappingURL=create-automation-form-Bpy92SM5.js.map
@@ -1,2 +0,0 @@
1
- import{iA as e,j as t,hq as r}from"./index-9YuSRymd.js";function a(){const{owner:n,connectorKey:o}=e.useParams();return t.jsx(r,{owner:n,initialConnectorKey:o})}export{a as component};
2
- //# sourceMappingURL=create._connectorKey-D6Kc-YQ3.js.map
@@ -1,2 +0,0 @@
1
- import{cx as r,h6 as l,W as i,dD as u,ch as c,J as d}from"./index-9YuSRymd.js";function o(e,n=""){return`${d}/api/${e}/deployments${n}`}const y=50;function f(e){const{slug:n}=r();return l({queryKey:["deployments-feed",n,e?.resourceKind,e?.resourceId],queryFn:async({pageParam:t})=>{const a=new URLSearchParams({limit:String(y)});t!==null&&a.set("before_id",String(t)),e&&(a.set("resource_kind",e.resourceKind),a.set("resource_id",e.resourceId));const s=await i(o(n,`?${a.toString()}`),{credentials:"include"});return s.status===404?{items:[],has_more:!1}:(await u(s,"Failed to fetch deployments"),await s.json())},initialPageParam:null,getNextPageParam:t=>t.has_more?t.items[t.items.length-1]?.id:void 0,enabled:!!n,staleTime:15e3,retry:!1})}function h(e){const{slug:n}=r();return c({queryKey:["deployment-detail",n,e],queryFn:async()=>{const t=await i(o(n,`/${e}`),{credentials:"include"});return t.status===404?null:(await u(t,"Failed to fetch deployment"),await t.json())},enabled:!!n&&!!e,staleTime:15e3,retry:!1})}function g(e){const{slug:n}=r();return c({queryKey:["deployment-change-detail",n,e],queryFn:async()=>{const t=await i(o(n,`/changes/${e}`),{credentials:"include"});return t.status===404?null:(await u(t,"Failed to fetch change"),(await t.json()).change)},enabled:!!n&&!!e,staleTime:15e3,retry:!1})}export{g as a,h as b,f as u};
2
- //# sourceMappingURL=deployments-C5hvipQh.js.map
@@ -1,2 +0,0 @@
1
- import{j as t,O as o}from"./index-9YuSRymd.js";const n=()=>t.jsx(o,{});export{n as component};
2
- //# sourceMappingURL=deployments-CPpFAd_w.js.map
@@ -1,2 +0,0 @@
1
- import{j as a,bz as x,bM as p,aR as m,hn as o,B as f,bd as c,L as i,ho as h,P as r}from"./index-9YuSRymd.js";import{u as g}from"./deployments-C5hvipQh.js";function y(e){return e==="partial_failure"?a.jsx(r,{variant:"destructive",children:"Partial failure"}):e==="succeeded"?a.jsx(r,{variant:"secondary",children:"Succeeded"}):null}function j(e){switch(e){case"created":return a.jsx(r,{variant:"default",children:"Created"});case"updated":return a.jsx(r,{variant:"secondary",children:"Updated"});case"deleted":return a.jsx(r,{variant:"destructive",children:"Deleted"});default:return null}}function N(e){if(!e)return null;const t=[e.create?`${e.create} created`:null,e.update?`${e.update} updated`:null,e.delete?`${e.delete} deleted`:null].filter(n=>n!==null);return t.length>0?t.join(" · "):"no changes"}const u="flex items-start gap-3 px-3 py-2.5 transition-colors hover:bg-accent/50";function B({owner:e}){const t=g(),n=t.data?.pages.flatMap(s=>s.items)??[];return t.isLoading?a.jsx("div",{className:"max-w-3xl",children:a.jsx(x,{label:"deployments"})}):t.isError?a.jsx(p,{label:"deployments"}):n.length===0?a.jsx(m,{icon:o,title:"No deployments yet",description:"lobu apply runs and settings edits will appear here as an audit trail."}):a.jsxs("div",{className:"max-w-3xl space-y-3",children:[a.jsx("div",{className:"overflow-hidden rounded-lg border",children:n.map((s,l)=>{const d=l===n.length-1;return s.type==="deployment"?a.jsx(b,{item:s,owner:e,isLast:d},s.id):a.jsx(v,{item:s,owner:e,isLast:d},s.id)})}),t.hasNextPage?a.jsx(f,{variant:"outline",size:"sm",className:"h-8 text-xs",disabled:t.isFetchingNextPage,onClick:()=>t.fetchNextPage(),children:t.isFetchingNextPage?"Loading...":"Load more"}):null]})}function b({item:e,owner:t,isLast:n}){const l=[N(e.counts),e.createdBy?`by ${e.createdBy}`:null,c(e.createdAt)].filter(Boolean).join(" · ");return a.jsxs(i,{to:"/$owner/connectors/deployments/$deploymentId",params:{owner:t,deploymentId:e.applyId??String(e.id)},className:`${u} ${n?"":"border-b"}`,children:[a.jsx(o,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"truncate text-sm font-medium",children:"Deployment"}),y(e.status),e.gitSha?a.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:e.gitSha.slice(0,7)}):null]}),a.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:l})]})]})}function v({item:e,owner:t,isLast:n}){const s=[e.actorSource?`via ${e.actorSource}`:null,e.createdBy?`by ${e.createdBy}`:null,c(e.createdAt)].filter(Boolean).join(" · ");return a.jsxs(i,{to:"/$owner/connectors/deployments/$deploymentId",params:{owner:t,deploymentId:`change-${e.id}`},className:`${u} ${n?"":"border-b"}`,children:[a.jsx(h,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsxs("span",{className:"truncate text-sm font-medium",children:[e.resourceKind??"config",e.resourceId?a.jsxs("span",{className:"text-muted-foreground",children:[" ",e.resourceId]}):null]}),j(e.op)]}),a.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:s})]})]})}export{B as D,j as c,y as d};
2
- //# sourceMappingURL=deployments-body-DGII20dQ.js.map
@@ -1,2 +0,0 @@
1
- import{aJ as U,id as ne,ie as V,r as v,j as e,ig as L,B as b,a2 as z,ih as C,d7 as Y,av as te,hL as I,S as A,aV as B,ef as ae,eg as ie,dF as ce,eh as oe,ii as re,U as le,o as de,aA as me,ij as ue,ik as xe,il as he,aB as pe,aw as fe,aC as P,aU as q,L as E,im as ge,io as je,aP as ve,ip as ye,iq as be,ht as Ne,b8 as ke,g9 as _e,ir as K,I as we,a$ as Ce,b9 as Se,ga as $e,gb as O,bd as De,is as F,ai as Pe}from"./index-9YuSRymd.js";import{c as G,C as Le,R as ze}from"./device-pin-tombstone-2U0UMu3_.js";import{R as Ie}from"./runs-panel-C0_DNTcq.js";import{S as Ae,g as Re}from"./runs-table-B1APZv7d.js";import{c as Ee}from"./connection-label-BobuYiAG.js";import{w as M}from"./workspace-label-o_QfBuCM.js";import"./connector-scope-lists-CRFEpSvk.js";import"./filter-editors-Bwhqj7lY.js";function Me(s,n,o){const h=new Set(s.capabilities??[]),m=new Set(s.connectors.filter(t=>t.organization_slug===o).map(t=>t.connector_key)),r=new Set(J(s,o).map(t=>t.connector_key));return n.filter(t=>U(t)&&!!t.required_capability&&h.has(t.required_capability)&&!m.has(t.key)&&!r.has(t.key))}function J(s,n){return s.organization_slug===n?s.update_required:[]}function Be(s,n,o){const h=s.organization_slug;if(!h||h===o)return[];const m=new Set(n.map(t=>t.key)),r=new Set(s.connectors.filter(t=>t.organization_slug===o).map(t=>t.connector_key));return s.connectors.filter(t=>t.organization_slug!==h||m.has(t.connector_key)||r.has(t.connector_key)?!1:(r.add(t.connector_key),!0))}function Te({device:s,organizationId:n,ownerSlug:o,connectable:h,unavailable:m}){const r=ne(),t=V(),[u,p]=v.useState(null),[g,a]=v.useState(null),[f,N]=v.useState(null),[j,d]=v.useState([]),x=s.organization_id===n,y=async i=>{p(null),N(null),a(i.key);try{x||await t.mutateAsync({deviceWorkerId:s.id,organizationId:n});const w=await r.mutateAsync({connector_key:i.key,device_worker_id:s.id}),S=w.connection_id??w.connection?.id;if(S===void 0)throw new Error(w.instructions??"The connection was not created.");d($=>[...$.filter(D=>D.connectorKey!==i.key),{connectorKey:i.key,name:i.name,connectionId:S,instructions:w.status==="setup_required"?w.instructions:void 0}])}catch(w){N({key:i.key,message:w instanceof Error?w.message:"Could not connect."})}finally{a(null)}},k=new Set(j.map(i=>i.connectorKey)),l=J(s,o),c=h.filter(i=>!k.has(i.key));return e.jsxs("div",{className:"mt-4 space-y-3",children:[j.map(i=>e.jsx(qe,{outcome:i,device:s,organizationId:n},i.connectorKey)),c.length>0?e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium",children:"Supported by this device"}),e.jsxs("p",{className:"mb-2 text-xs text-muted-foreground",children:["Not connected in this workspace yet.",x?null:" Connecting one moves the device here; you will be asked to confirm first."]}),e.jsx("div",{className:"divide-y border-y",children:c.map(i=>e.jsxs("div",{className:"space-y-2 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"min-w-0 flex-1 text-sm font-medium",children:[i.name,i.required_capability&&L[i.required_capability]&&L[i.required_capability]!==i.name?e.jsx("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:L[i.required_capability]}):null]}),e.jsxs(b,{size:"sm",variant:"outline","aria-label":`Connect ${i.name}`,disabled:g!==null,onClick:()=>x?void y(i):p(i.key),children:[g===i.key?e.jsx(z,{className:"mr-1.5"}):null,"Connect"]})]}),u===i.key?e.jsx(Q,{device:s,ownerSlug:o,title:"Move device to this workspace",intro:`${C(s)} lives in ${s.organization_name??"another workspace"}. A device serves one workspace at a time, so it has to move here before it can be connected.`,confirmLabel:"Move here and connect",onConfirm:()=>void y(i),onCancel:()=>p(null)}):null,f?.key===i.key?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:f.message}):null]},i.key))})]}):null,l.length>0?e.jsxs("div",{role:"status",children:[e.jsx("p",{className:"text-xs font-medium",children:"Update Lobu on this device"}),e.jsx("ul",{className:"mt-1 space-y-1 text-xs text-muted-foreground",children:l.map(i=>e.jsx("li",{children:`${i.display_name} — this device has ${i.device_version}, this workspace uses ${i.workspace_version}`},i.connector_key))})]}):null,m.length>0?e.jsx("ul",{className:"space-y-1 text-xs text-muted-foreground",children:m.map(i=>e.jsx("li",{children:`${i.display_name} — set up on this device in ${s.organization_name??"its home workspace"}, not available in this workspace yet`},i.connector_key))}):null]})}function Q({device:s,ownerSlug:n,title:o,intro:h,aftermath:m,confirmLabel:r,pending:t=!1,onConfirm:u,onCancel:p}){const g=s.connector_count,a=s.connectors.filter(f=>f.organization_slug===n).length;return e.jsxs("div",{role:"alertdialog","aria-label":o,className:"space-y-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs",children:[e.jsx("p",{children:h}),e.jsxs("p",{className:"text-muted-foreground",children:[g>0?`Moving pauses and unpins all ${g} connection${g===1?"":"s"} pinned to it${a>0?`, including ${a} in this workspace`:""}. They stay paused until you reconnect them.`:"It has no pinned connections, so nothing is paused.",m?` ${m}`:null]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(b,{size:"sm",disabled:t,onClick:u,children:[t?e.jsx(z,{className:"mr-1.5"}):null,r]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:t,onClick:p,children:"Cancel"})]})]})}function qe({outcome:s,device:n,organizationId:o}){const{data:h=[],isLoading:m}=Y(o,{connectionIds:[s.connectionId]}),r=h.find(p=>p.id===s.connectionId),t=C(n);if(m)return e.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:["Checking ",s.name,"…"]});const u=[];if(!r)u.push(`${s.name} was created but could not be loaded yet.`);else if(r.status!=="active"){const p=G(r);u.push(`${s.name} is ${r.status}${p?`: ${p}`:"."}`)}return s.instructions&&u.push(s.instructions),n.online||u.push(`${t} is offline. ${s.name} runs once it reconnects.`),e.jsx("div",{role:"status",className:"rounded-lg border px-3 py-2 text-sm",children:u.length===0?e.jsxs("p",{children:[s.name," is ready on ",t,"."]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"font-medium",children:[s.name," connected, not ready yet"]}),e.jsx("ul",{className:"mt-1 list-disc pl-4 text-xs text-muted-foreground",children:u.map(p=>e.jsx("li",{children:p},p))})]})})}function H({device:s,organizationId:n,ownerSlug:o,selectedConnection:h,openSettings:m}){const{data:r=[],isLoading:t,isError:u,refetch:p}=te(n),g=new Map(r.map(d=>[d.key,d])),a=new Map,f=[];for(const d of s.connectors){if(d.organization_slug!==o)continue;const x=g.get(d.connector_key);if(!x||!U(x)){f.push(d);continue}const y=x.required_capability??`connector:${x.key}`,k=a.get(y)??{key:y,name:x.name,connections:[]};k.name=L[y]??x.name,k.connections.push(d),a.set(y,k)}const N=Me(s,r,o),j=Be(s,r,o);return e.jsxs(e.Fragment,{children:[e.jsxs(I,{title:"Capabilities",children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Manage the native connections available to this workspace."}),s.online?null:e.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"This device is offline. You can edit its settings; actions and sync need it to reconnect."}),!n||t?e.jsx(A,{className:"h-24 w-full"}):u?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load capability settings."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void p(),children:"Retry"})]}):a.size===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No native connections on this device in this workspace."}):e.jsx("div",{className:"divide-y border-y",children:[...a.values()].map(d=>e.jsx(W,{group:d,deviceId:s.id,organizationId:n,ownerSlug:o,definitionsByKey:g,selectedConnection:h,openSettings:m},d.key))}),n&&!t&&!u?e.jsx(Te,{device:s,organizationId:n,ownerSlug:o,connectable:N,unavailable:j}):null,B(s)==="macos"?e.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"Manage macOS permissions in the Lobu app on this device."}):null]}),n&&f.length>0&&!t&&!u?e.jsxs(I,{title:"Apps and sources",count:String(f.length),children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Apps and sources that use this device."}),e.jsx("div",{className:"divide-y border-y",children:[...new Set(f.map(d=>d.connector_key))].map(d=>e.jsx(W,{group:{key:d,name:g.get(d)?.name??d,connections:f.filter(x=>x.connector_key===d)},deviceId:s.id,organizationId:n,ownerSlug:o,definitionsByKey:g,selectedConnection:h,openSettings:m},d))})]}):null]})}function W({group:s,deviceId:n,organizationId:o,ownerSlug:h,definitionsByKey:m,selectedConnection:r,openSettings:t}){const u=s.connections.some(a=>a.connection_id===r),[p,g]=v.useState(u);return v.useEffect(()=>{u&&r!==void 0&&g(!0)},[u,r]),e.jsxs(ae,{open:p,onOpenChange:g,children:[e.jsxs(ie,{className:"group flex w-full items-center gap-3 py-3 text-left",children:[e.jsx(ce,{className:"size-3.5 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-90"}),e.jsx("span",{className:"min-w-0 flex-1 text-sm font-medium",children:s.name}),e.jsx("span",{className:"text-right text-xs text-muted-foreground",children:s.connections.some(a=>a.status==="error"||a.status==="revoked")?"Needs attention":s.connections.length>1?`${s.connections.length} connections`:"Configured"})]}),e.jsx(oe,{className:"pb-4 pl-6",children:e.jsx("div",{className:"space-y-5",children:s.connections.map(a=>e.jsx(Ke,{summary:a,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m.get(a.connector_key),openSettings:a.connection_id===r&&t},a.connection_id))})})]})}function Ke({summary:s,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m,openSettings:r}){const{data:t=[],isLoading:u,isError:p,refetch:g}=Y(o,{connectionIds:[s.connection_id]}),a=t.find(j=>j.id===s.connection_id&&j.device_worker_id===n),f=m?.name??s.connector_key,N=a?G(a):null;return e.jsxs("section",{id:`connection-${s.connection_id}`,"aria-label":f,className:"scroll-mt-24",children:[a?e.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-3 text-xs text-muted-foreground",children:[e.jsx("span",{children:Ee(a)}),e.jsx("span",{children:a.status})]}):null,u||!o?e.jsx(A,{className:"h-24 w-full"}):p?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load this connection."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void g(),children:"Retry"})]}):a?e.jsxs(e.Fragment,{children:[N?e.jsx("p",{role:"alert",className:"mb-4 text-sm text-destructive",children:N}):null,e.jsx("div",{className:"mb-4",children:e.jsx(re,{connection:a})}),e.jsx(Le,{connection:a,connectorDef:m,ownerSlug:h,openSettings:r,showActivity:!1,showShare:!1,embedded:!0})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection is no longer available on this device."})]})}function Oe({device:s,ownerSlug:n}){const o=v.useId(),{data:h=[]}=le(),m=V(),[r,t]=v.useState(!1),[u,p]=v.useState(null),[g,a]=v.useState(null),f=h.filter(l=>l.is_member).map(l=>({id:l.id,name:l.name,isPersonal:l.is_personal===!0})),N=f.find(l=>l.id===s.organization_id),j=N?M(N):s.organization_name??"No workspace",d=f.filter(l=>l.id!==s.organization_id),x=d.find(l=>l.id===u)??null,y=()=>{t(!1),p(null)},k=async l=>{a(null);try{await m.mutateAsync({deviceWorkerId:s.id,organizationId:l}),y()}catch(c){a(c instanceof Error?c.message:"Could not move the device.")}};return e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Workspace: "}),j]}),!r&&d.length>0?e.jsx(b,{size:"sm",variant:"outline",onClick:()=>{a(null),t(!0)},children:"Change workspace"}):null]}),r?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("label",{htmlFor:o,className:"text-xs text-muted-foreground",children:"Move to"}),e.jsxs("select",{id:o,value:u??"",disabled:m.isPending,onChange:l=>p(l.target.value||null),className:"h-8 rounded-md border border-input bg-background px-2 text-sm",children:[e.jsx("option",{value:"",children:"Choose a workspace"}),d.map(l=>e.jsx("option",{value:l.id,children:M(l)},l.id))]}),x?null:e.jsx(b,{size:"sm",variant:"ghost",onClick:y,children:"Cancel"})]}):null,x?e.jsx(Q,{device:s,ownerSlug:n,title:`Move device to ${x.name}`,intro:`Move ${C(s)} from ${j} to ${M(x)}?`,aftermath:`It is set up fresh in ${x.name}, with its connections there private to you until you share them.`,confirmLabel:"Move device",pending:m.isPending,onConfirm:()=>void k(x.id),onCancel:y}):null,g?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:g}):null]})}function Fe({ownerSlug:s,deviceId:n,organizationId:o,selectedConnection:h,openSettings:m}){const r=de(),{data:t=[],isLoading:u,isError:p,refetch:g}=me(),a=ue(),f=xe(),[N,j]=v.useState(!1),[d,x]=v.useState(!1),[y,k]=v.useState(""),l=he(t,n),c=l&&pe(l,s)?l:void 0,i=c?.id??n,{data:w=[]}=fe(o,{profileKind:"browser_session"}),S=v.useMemo(()=>w.filter(_=>_.device_worker_id===i&&_.status!=="revoked"),[w,i]),$=c?.label?.trim()??"";if(v.useEffect(()=>{d||k($)},[$,d]),u)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-6 w-6 rounded"}),e.jsx(A,{className:"h-5 w-40"})]}),e.jsx(ze,{})]});if(p)return e.jsx(P,{children:e.jsxs("div",{role:"alert",className:"space-y-2",children:[e.jsx("p",{children:"Could not load this device."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void g(),children:"Retry"})]})});if(!c&&l&&o)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{platform:B(l),className:"h-5 w-5"}),e.jsx("h1",{className:"text-base font-semibold",children:C(l)})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This device lives in"," ",l.organization_name??"another workspace",", not this workspace."]}),e.jsx(H,{device:l,organizationId:o,ownerSlug:s})]});if(!c)return e.jsxs(P,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This device isn't in this workspace, so its details aren't available."}),e.jsx(E,{to:"/$owner/connectors",params:{owner:s},search:{},className:"text-sm text-primary hover:underline",children:"Back to connectors"})]});const D=ge(c),R=D?je(s,D,ve()):void 0,X=B(c),Z=ye(c.app_version),ee=be(c,Z),T=()=>{const _=y.trim(),se=c.label?.trim()??"";if(_===se){x(!1);return}f.mutate({deviceWorkerId:c.id,label:_.length===0?null:_},{onSuccess:()=>x(!1)})};return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(Ne,{header:e.jsx(_e,{breadcrumb:e.jsx($e,{crumbs:[e.jsx(E,{to:"/$owner/connectors",params:{owner:s},search:{},className:O,children:"Connectors"},"connectors"),...R?[e.jsx(E,{to:"/$owner/connectors/app/$appId",params:{owner:s,appId:R.id},className:O,children:R.name},"app")]:[]]}),icon:e.jsx(q,{platform:X,className:"h-5 w-5"}),title:d?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(we,{"aria-label":"Device name",value:y,onChange:_=>k(_.target.value),placeholder:C({...c,label:null}),maxLength:80,className:"h-9 max-w-sm text-base font-semibold",autoFocus:!0,onKeyDown:_=>{_.key==="Enter"?(_.preventDefault(),N||T()):_.key==="Escape"&&(j(!1),k(c.label?.trim()??""),x(!1))}}),N?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg bg-destructive/10 px-3 py-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Forgets this device"," ",c.connector_count>0?`and un-pins ${c.connector_count} connector${c.connector_count===1?"":"s"} across every workspace, not just this one.`:"with no pinned connections."]}),e.jsxs(b,{variant:"destructive",size:"sm",disabled:a.isPending,onClick:()=>a.mutate(c.id,{onSuccess:()=>{j(!1),r({to:"/$owner/connectors",params:{owner:s},search:{}})}}),children:[a.isPending?e.jsx(z,{className:"mr-1.5"}):null,a.isPending?"Removing...":"Confirm remove"]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:a.isPending,onClick:()=>j(!1),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(b,{size:"sm",onClick:T,disabled:f.isPending,children:[f.isPending?e.jsx(z,{className:"mr-1.5"}):null,f.isPending?"Saving...":"Save"]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:f.isPending,onClick:()=>{k(c.label?.trim()??""),x(!1)},children:"Cancel"}),e.jsxs(b,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive",disabled:f.isPending||a.isPending,onClick:()=>j(!0),children:[e.jsx(Ce,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove device"]})]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:[C(c),e.jsx(b,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground","aria-label":"Edit device",onClick:()=>{j(!1),k(c.label?.trim()??""),x(!0)},children:e.jsx(Se,{className:"h-3.5 w-3.5"})})]}),badge:e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{className:`size-1.5 rounded-full ${c.online?"bg-emerald-500":"bg-muted-foreground/50"}`}),c.online?c.connector_error_count>0?"Needs attention":"Online":"Offline"]}),meta:ee||void 0,caption:`Last seen ${K(new Date(c.last_seen_at),{addSuffix:!0})}${c.last_sync_at?` · Last sync ${K(new Date(c.last_sync_at),{addSuffix:!0})}`:""}`}),children:[e.jsx(Oe,{device:c,ownerSlug:s}),c.connector_error_count>0?e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-600",children:[e.jsx(ke,{className:"h-3.5 w-3.5 shrink-0"}),c.connector_error_count," connector",c.connector_error_count===1?"":"s"," pinned to this device ",c.connector_error_count===1?"is":"are"," erroring."]}):null,e.jsx(H,{device:c,organizationId:o,ownerSlug:s,selectedConnection:h,openSettings:m}),S.length>0?e.jsx(I,{title:"Browser auth profiles",children:e.jsx(He,{profiles:S})}):null,e.jsx(I,{title:"Runs",children:e.jsx(Ie,{scope:{deviceId:i},ownerSlug:s})})]})})}function He({profiles:s}){return s.length===0?null:e.jsx("div",{className:"rounded-lg border",children:e.jsx("ul",{className:"divide-y",children:s.map(n=>e.jsxs("li",{className:"space-y-2 px-3 py-2.5 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:n.display_name}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:n.connector_key??"Any connector"}),n.browser_kind?e.jsxs("span",{children:["· ",n.browser_kind]}):null,n.captured_at?e.jsxs("span",{title:n.captured_at,children:["· captured ",De(n.captured_at)]}):null,typeof n.cookie_count=="number"?e.jsxs("span",{children:["· ",n.cookie_count," cookie",n.cookie_count===1?"":"s"]}):null]})]}),e.jsx(Ae,{status:n.is_expired?"error":Re(n.status),showDot:!0,children:n.is_expired?"expired":n.status})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Refresh the session using the connector’s authorization instructions."})]},n.id))})})}function Ze(){const{owner:s,deviceId:n}=F.useParams(),{connection:o,settings:h}=F.useSearch();return e.jsx(Pe,{owner:s,children:({ownerSlug:m,organizationId:r})=>e.jsx(Fe,{ownerSlug:m,deviceId:n,organizationId:r,selectedConnection:o,openSettings:h})})}export{Ze as component};
2
- //# sourceMappingURL=device._deviceId-Bn37UpWH.js.map
@@ -1,2 +0,0 @@
1
- import{o as x,bh as C,j as e,bp as _,bq as m,br as S,bs as b,bt as c,eR as u}from"./index-9YuSRymd.js";import{c as w}from"./connection-label-BobuYiAG.js";const h="__connection_picker_create_new__";function y({connections:s,value:r,onValueChange:n,connectorKey:a,disabled:p,placeholder:d="Choose a connection",includeWorkspaceEvents:i=!1,ariaLabel:g="Connection"}){const f=x(),l=C().org?.slug,o=a?s.filter(t=>t.connector_key===a):s,j=t=>{if(t===h){if(!l)return;f({to:"/$owner/connectors/create",params:{owner:l},search:a?{connector:a}:{}});return}n(t)};return e.jsxs(_,{value:r,onValueChange:j,disabled:p,children:[e.jsx(m,{"aria-label":g,children:e.jsx(S,{placeholder:d})}),e.jsxs(b,{children:[i?e.jsxs(e.Fragment,{children:[e.jsx(c,{value:"workspace",children:"Current workspace"}),o.length>0?e.jsx(u,{}):null]}):null,o.map(t=>e.jsx(c,{value:String(t.id),children:w(t)},t.id)),l?e.jsxs(e.Fragment,{children:[o.length>0||i?e.jsx(u,{}):null,e.jsx(c,{value:h,children:"Connect an app…"})]}):null]})]})}function v(s){const r=[];for(const n of s)r.push({id:n.id,name:n.name,entityType:n.entity_type}),n.children&&n.children.length>0&&r.push(...v(n.children));return r}export{y as C,v as f};
2
- //# sourceMappingURL=entity-options-Clz_WXK-.js.map
@@ -1,2 +0,0 @@
1
- import{d2 as pe,r as S,bQ as fe,fk as ge,dS as X,j as e,B as N,u as H,jb as ve,S as Y,fu as ne,jg as je,w as ye,o as ie,jh as be,bR as L,g as ke,dQ as re,e_ as _e,jc as Ne,ji as we,b9 as Se,c0 as J,fi as Re,f4 as Fe,gP as Ee,gQ as De,gR as Ce,gS as Le,gT as Pe,jj as Be,bU as Ie,z,I as Z,fN as Te,b8 as Ve,fl as Oe,dG as U,i as Ae,jk as Me,L as $e,gK as ze}from"./index-9YuSRymd.js";import{R as Ue}from"./record-activity-ZJntBfN_.js";import{n as Ke,c as K,g as He,D as We,S as Ge}from"./schema-value-normalization-CKdPjdPC.js";import{r as Qe}from"./record-field-peek-Brh1IQGy.js";import{S as qe,E as Xe}from"./entity-avatar-mdh7Kq5D.js";import{a as oe,V as ee,M as Ye,b as Je}from"./view-param-filters-B0quibBi.js";import{a as Ze}from"./source-record-panels-BdfOVPWn.js";import{l as et,L as tt,s as W,R as le,i as st,S as at}from"./events-feed-DO3IiJO2.js";import{a as nt}from"./record-session-Pbr5czGw.js";import"./filter-editors-Bwhqj7lY.js";import"./connection-label-BobuYiAG.js";import"./clients-BhNl1tVq.js";import"./client-rows-BYbsXGy9.js";import"./agent-loading-shells-B7v6Cffw.js";import"./member-scope-gate-DD4YBFn-.js";import"./card-jzhQrMDP.js";import"./app-bridge-BCm4muqj.js";import"./conversations-table-D_HOe1jN.js";function it(t,s){if(t===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in t)return t;if(typeof t=="function")return{shouldBlockFn:async()=>await t(),enableBeforeUnload:!0,withResolver:!1};const n=!!(t.condition??!0),i=t.blockerFn;return{shouldBlockFn:async()=>n&&i!==void 0?await i():n,enableBeforeUnload:n,withResolver:i===void 0}}function rt(t,s){const{shouldBlockFn:n,enableBeforeUnload:i=!0,disabled:a=!1,withResolver:c=!1}=it(t),o=pe(),{history:r}=o,[m,x]=S.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return S.useEffect(()=>{const p=async f=>{function l(j){const g=o.parseLocation(j),_=o.getMatchedRoutes(g.pathname);return _.foundRoute===void 0?{routeId:"__notFound__",fullPath:g.pathname,pathname:g.pathname,params:_.routeParams,search:o.options.parseSearch(j.search)}:{routeId:_.foundRoute.id,fullPath:_.foundRoute.fullPath,pathname:g.pathname,params:_.routeParams,search:o.options.parseSearch(j.search)}}const h=l(f.currentLocation),d=l(f.nextLocation);if(h.routeId==="__notFound__"&&d.routeId!=="__notFound__")return!1;const u=await n({action:f.action,current:h,next:d});if(!c)return u;if(!u)return!1;const b=await new Promise(j=>{x({status:"blocked",current:h,next:d,action:f.action,proceed:()=>j(!1),reset:()=>j(!0)})});return x({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),b};return a?void 0:r.block({blockerFn:p,enableBeforeUnload:i})},[n,i,a,c,r,o]),m}function $(t,s){return X(K(t))===X(K(s))}function ot(t,s){const n={};for(const i of new Set([...Object.keys(t),...Object.keys(s)]))$(t[i],s[i])||(n[i]=K(t[i])??null);return Object.keys(n).length>0?n:void 0}function lt(t,s){return[...new Set([...Object.keys(t),...Object.keys(s)])].filter(n=>{try{return!$(t[n],s[n])}catch{return!0}})}function te(t,s){return{name:t.name,slug:t.slug,metadata:Ke(t.metadata??{},s)}}function ct(t,s,n){const i=new Set(n),a={},c={},o=new Set([...Object.keys(t.values.metadata),...Object.keys(t.baseline.metadata),...Object.keys(s.metadata)]);for(const r of o){const m=i.has(r),x=m?t.values.metadata[r]:t.baseline.metadata[r],p=$(x,s.metadata[r])?x:s.metadata[r];p!==void 0&&(a[r]=p);let f=!1;if(!m)try{f=!$(t.values.metadata[r],t.baseline.metadata[r])}catch{f=!0}const l=f?t.values.metadata[r]:p;l!==void 0&&(c[r]=l)}return{baseline:{name:s.name,slug:s.slug,metadata:a},values:{name:s.name,slug:s.slug,metadata:c}}}function dt({entity:t,schema:s,orgContext:n}){const i=S.useMemo(()=>te(t,s),[t,s]),a=fe(t.id,i,s),c=ge(n),{values:o,baseline:r,commit:m}=a,x=S.useMemo(()=>lt(o.metadata,r.metadata),[o.metadata,r.metadata]),p=o.name!==r.name||o.slug!==r.slug,f=S.useCallback((h,d)=>a.setValues(u=>({...u,metadata:{...u.metadata,[h]:d}})),[a.setValues]),l=async({note:h}={})=>{if(!a.canSubmit)return null;const d=ot(o.metadata,r.metadata),u=o.name.trim()!==r.name.trim();if(!d&&!p)return null;const b=await c.mutateAsync({entityId:t.id,name:u?o.name.trim():void 0,slug:o.slug,metadata:d,field_note:d&&h?.trim()||void 0}),j=te(b.entity,s);return m(g=>ct(g,j,Object.keys(d??{})),j),{held:b.blocked_fields??[],approvalUrl:b.approval_url}};return{values:o,baseline:r,revision:a.revision,setValues:a.setValues,setMetadataField:f,reset:a.reset,save:l,saving:c.isPending,dirtyKeys:x,identityDirty:p,isDirty:p||x.length>0,canSubmit:a.canSubmit,hasConflict:a.hasConflict,hasInvalidInput:a.hasInvalidInput}}const ut=3,mt=50;function ce(t){const s=S.useRef(null);return S.useEffect(()=>{t&&(s.current?.scrollIntoView?.({block:"start"}),s.current?.focus())},[t]),s}function I({headingRef:t,children:s}){return e.jsx("h3",{ref:t,tabIndex:-1,className:"text-xs font-medium uppercase tracking-wide text-muted-foreground outline-none",children:s})}function ht({entityId:t,entityName:s,ownerSlug:n,orgContext:i,focus:a,collapsed:c=!1}){const o=H(),r=ce(a),{data:m,isLoading:x,isError:p,refetch:f}=ve(t,i,{limit:mt});if(x)return e.jsxs("section",{className:"space-y-2","aria-busy":"true",children:[e.jsx(I,{headingRef:r,children:"Linked"}),e.jsx(Y,{className:"h-4 w-24"}),e.jsx(Y,{className:"h-6 w-full rounded-md"})]});if(p||!m)return e.jsxs("section",{className:"space-y-2",children:[e.jsx(I,{headingRef:r,children:"Linked"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Could not load this record's links."," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>void f(),children:"Retry"})]})]});if(m.countsByType.length===0)return a?e.jsxs("section",{className:"space-y-2",children:[e.jsx(I,{headingRef:r,children:"Linked"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No links to other records yet."})]}):null;if(c){const l=m.countsByType.flatMap(h=>{const d=h.count===1?m.rows.find(b=>b.relationship_type_slug===h.relationship_type_slug):void 0,u=d?et(d,t):void 0;return[h.relationship_type_name,u?.self?"this record":u?.name??String(h.count)]});return e.jsxs("section",{className:"space-y-1","aria-label":"Linked records",children:[e.jsx(I,{headingRef:r,children:"Linked"}),e.jsx("p",{"data-testid":"linked-summary",className:"truncate text-sm text-muted-foreground",children:l.join(" · ")})]})}return e.jsxs("section",{className:"space-y-3","aria-label":"Linked records",children:[e.jsx(I,{headingRef:r,children:"Linked"}),m.countsByType.map(l=>{const h=m.rows.filter(u=>u.relationship_type_slug===l.relationship_type_slug).slice(0,ut),d=l.count>h.length;return e.jsxs("div",{className:"grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)] items-baseline gap-x-3 text-sm",children:[e.jsxs("p",{className:"text-muted-foreground",children:[l.relationship_type_name,d?e.jsxs("span",{className:"tabular-nums text-muted-foreground/70",children:[" ","· ",l.count]}):null]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[h.map(u=>e.jsx(tt,{row:u,entityId:t,ownerSlug:n,orgContext:i},u.id)),d&&o?e.jsxs(N,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-primary hover:text-primary",onClick:()=>o.open({href:"",key:`record-links:${t}:${l.relationship_type_slug}`,title:`${l.relationship_type_name} · ${l.count}`,recordLinks:{entityId:t,entityName:s,ownerSlug:n,orgContext:i,relationshipType:l.relationship_type_slug,label:l.relationship_type_name}}),children:["Show all ",l.count]}):null]})]},l.relationship_type_slug)})]})}function xt({record:t,ownerSlug:s,orgContext:n,focus:i}){const[a,c]=S.useState(i),o=ce(i);return e.jsxs("section",{className:"space-y-2",children:[e.jsx(I,{headingRef:o,children:"Linked"}),a?e.jsx(Ze,{record:t,ownerSlug:s,orgContext:n}):e.jsx(N,{type:"button",variant:"outline",size:"sm",className:"h-7",onClick:()=>c(!0),children:"Find linked records"})]})}const pt="$name";function de({outcome:t,schema:s}){if(!t||t.held.length===0)return null;const n=s?.properties??{},i=t.held.map(a=>a===pt?"Name":He(a,n[a]??{}));return e.jsxs("div",{role:"status",className:"rounded-md bg-amber-500/10 px-3 py-2 text-sm text-amber-700 dark:text-amber-300",children:[i.join(", ")," ",i.length===1?"needs":"need"," approval before ",i.length===1?"it changes":"they change",".",t.approvalUrl?e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:t.approvalUrl,className:"underline",children:"Review"})]}):null]})}const ft=320,gt={},vt=()=>{};function jt({view:t,orgSlug:s,recordUrl:n,scope:i}){const a=H(),c=`${n}${ne(t.key)}`,o=a?()=>a.open({href:c,title:t.name}):void 0;return e.jsxs("section",{className:"min-w-0 rounded-lg border","data-testid":"view-card","data-view":t.key,children:[e.jsxs("header",{className:"flex items-start justify-between gap-3 px-4 pt-3 pb-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"truncate text-sm font-medium",children:t.name}),t.description?e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:t.description}):null]}),o?e.jsxs(N,{type:"button",variant:"ghost",size:"sm",className:"h-7 shrink-0 gap-1.5 px-2 text-muted-foreground hover:text-foreground",onClick:o,"aria-label":`Open ${t.name}`,children:[e.jsx(je,{className:"h-3.5 w-3.5"}),"Open"]}):null]}),e.jsx("div",{className:"px-4 pb-3",children:e.jsx(oe,{orgSlug:s,viewKey:t.key,scope:i,params:gt,onParamsChange:vt,contentHash:t.content_hash,title:t.name,minHeight:64,displayMode:"inline",maxHeight:ft,onRequestDisplayMode:o?r=>{r==="fullscreen"&&o()}:void 0})})]})}function yt({recordUrl:t,dirty:s,onDiscard:n}){const i=rt({disabled:!s,enableBeforeUnload:s,withResolver:!0,shouldBlockFn:({next:c})=>c.pathname!==t&&!c.pathname.startsWith(`${t}${ne("")}`)}),a=i.status==="blocked";return e.jsx(Ee,{open:a,onOpenChange:c=>{!c&&a&&i.reset()},children:e.jsxs(De,{className:"max-w-sm",children:[e.jsxs(Ce,{children:[e.jsx(Le,{children:"Discard unsaved changes?"}),e.jsx(Pe,{children:"This record has edits that are not saved. Leaving discards them."})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{type:"button",variant:"ghost",onClick:()=>a&&i.reset(),children:"Keep editing"}),e.jsx(N,{type:"button",variant:"destructive",onClick:()=>{a&&(n(),i.proceed())},children:"Discard"})]})]})})}const se=6;function bt({entity:t,ownerSlug:s,orgContext:n,recordUrl:i,schema:a,entityTypeName:c,isTypeLoading:o,record:r,canEdit:m,editing:x,onEditingChange:p,outcome:f,onSaved:l,formId:h,fieldLimit:d,onDeleted:u}){const b=x&&m,j=H(),g={entity:{id:t.id,name:t.name,entity_type:t.entity_type},ownerSlug:s,orgContext:n,schema:a,record:r,editing:b};nt(g);const _=j?.item?.recordField,D={ownerSlug:s,orgContext:n,controls:t.field_controls,dirtyKeys:r.dirtyKeys,openField:j?C=>j.open(Qe(g,C.key)):void 0,openFieldKey:_?.entityId===t.id?_.field:void 0},R=e.jsx(yt,{recordUrl:i,dirty:b&&r.isDirty,onDiscard:()=>{r.reset(),p(!1)}});if(o)return e.jsx(Fe,{rows:6});if(b)return e.jsxs(e.Fragment,{children:[R,e.jsx(kt,{formId:h,entity:t,entityTypeName:c,schema:a,record:r,orgContext:n,renderControl:(C,F,E)=>st(F)?e.jsx(at,{field:{key:C,prop:F},value:E,context:D}):void 0,onSaved:l,onDeleted:u,onDone:()=>p(!1)})]});const w=W(r.revision);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(de,{outcome:f,schema:a}),e.jsx(le,{fields:d===void 0?w:w.slice(0,d),values:r.values.metadata,context:D})]})}function kt({formId:t,entity:s,entityTypeName:n,schema:i,record:a,orgContext:c,renderControl:o,onSaved:r,onDeleted:m,onDone:x}){const p=Be(),f=s.field_controls,{name:l,slug:h,metadata:d}=a.values,u=v=>a.setValues(y=>({...y,name:v})),b=v=>a.setValues(y=>({...y,slug:v})),j=v=>a.setValues(y=>({...y,metadata:v})),[g,_]=L(s.id,""),[D,R]=L(s.id,null),[w,C]=L(s.id,null),[F,E]=L(s.id,!1),[V,T]=L(s.id,null),O=a.dirtyKeys.length>0,P=async v=>{if(v.preventDefault(),!!a.canSubmit){if(R(null),!l.trim()){R("Name is required");return}try{const y=await a.save({note:g});C(y),r(y),_(""),y?.held.length||x()}catch(y){R(y instanceof Error?y.message:"Failed to update entity")}}},B=async()=>{T(null);try{await p.mutateAsync({entityId:s.id}),E(!1),m?.()}catch(v){T(v instanceof Error?v.message:"Failed to delete entity")}},A=[s.total_content>0&&`${s.total_content} content item${s.total_content===1?"":"s"}`,s.automations_count>0&&`${s.automations_count} Automation${s.automations_count===1?"":"s"}`,s.active_connections>0&&`${s.active_connections} connector${s.active_connections===1?"":"s"}`].filter(Boolean).join(", ");return e.jsxs("form",{id:t,onSubmit:P,className:"space-y-4",children:[e.jsx(Ie,{visible:a.hasConflict,onReload:a.reset}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(z,{htmlFor:"sidebar-name",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(Z,{id:"sidebar-name",value:l,onChange:v=>u(v.target.value)})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(z,{htmlFor:"sidebar-slug",children:"URL Slug"}),e.jsx(Z,{id:"sidebar-slug",value:h,onChange:v=>b(v.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""))})]}),a.revision&&Object.keys(a.revision).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(qe,{}),e.jsx(We,{schema:a.revision,values:d,onValuesChange:j,fieldControls:f,orgContext:c,renderControl:o})]}),O&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(z,{htmlFor:"sidebar-correction-note",children:"Correction note (optional)"}),e.jsx(Te,{id:"sidebar-correction-note",value:g,onChange:v=>_(v.target.value),placeholder:"Why are you changing these fields? Helps Automations respect the correction.",rows:2})]}),D&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:D}),e.jsx(de,{outcome:w,schema:i}),F?e.jsxs("div",{className:"space-y-3 rounded-lg border border-destructive/40 bg-destructive/5 p-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5 text-sm",children:[e.jsx(Ve,{className:"h-4 w-4 shrink-0 text-destructive mt-0.5"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-medium text-foreground",children:['Delete "',s.name,'"?']}),A&&e.jsxs("p",{className:"text-muted-foreground",children:["Removes ",A,". This cannot be easily undone."]})]})]}),V&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-2.5 py-1.5 text-sm text-destructive",children:V}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:()=>{E(!1),T(null)},children:"Cancel"}),e.jsx(N,{type:"button",variant:"destructive",size:"sm",onClick:B,disabled:p.isPending,children:p.isPending?"Deleting...":`Delete ${n||"entity"}`})]})]}):e.jsx("div",{className:"pt-2",children:e.jsx(N,{type:"button",variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>E(!0),children:"Delete"})})]})}function ue(t,s){const n=new Set(t.measure_columns??[]),i=s?.properties??{};return Object.keys(t.metadata??{}).filter(a=>a!=="id"&&a!=="slug"&&a!=="name"&&i[a]?.const===void 0).map(a=>({key:a,prop:i[a]??{},label:i[a]?.["x-table-label"]??(n.has(a)?a:Re(a.replace(/_/g," "))),numeric:n.has(a)}))}function _t({entity:t,schema:s,ownerSlug:n,fieldLimit:i}){const a=ue(t,s);return e.jsxs("div",{children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Managed by the source"}),e.jsx(le,{fields:i===void 0?a:a.slice(0,i),values:t.metadata??{},context:{ownerSlug:n}})]})}const Nt=720,ae="owletto:record-details-expanded";function wt(){const[t,s]=S.useState(()=>{try{return window.localStorage.getItem(ae)==="1"}catch{return!1}});return[t,i=>{s(i);try{window.localStorage.setItem(ae,i?"1":"0")}catch{}}]}function St({schema:t,metadata:s}){const n=W(t).filter(({key:i,prop:a})=>a["x-table-column"]===!0&&!a["x-image"]&&s[i]!==void 0&&s[i]!==null&&s[i]!=="");return n.length===0?null:e.jsx("p",{"data-testid":"record-summary",className:"-mt-2 truncate text-sm text-muted-foreground tabular-nums",children:n.map(({key:i,prop:a},c)=>e.jsxs("span",{children:[c>0?" · ":null,e.jsx(Ge,{value:s[i],prop:a})]},i))})}function Rt({namespace:t,entity:s,recordUrl:n,viewKey:i,title:a,onDeleted:c}){const o=ye({strict:!1}),r=ie(),m=S.useRef(null),x=be(m,Nt),[p,f]=wt(),[l,h]=L(s.id,!1),d={slug:t.slug,organizationId:t.id},u=ke(d),{data:b,isLoading:j}=re(s.entity_type,d),g=b?.metadata_schema,{isAdmin:_,isLoading:D}=_e(d.organizationId),R=_&&!D&&!s.is_derived,w=dt({entity:s,schema:g,orgContext:d}),[C,F]=L(s.id,null),E=`record-form-${s.id}`,V=l&&R,T=u.data??[],O=Ne(T,{type:s.entity_type,id:s.id}),P=we(O,i),B=!i&&o.tab==="relationships",A=k=>void r({to:".",search:k,replace:!0}),v={type:s.entity_type,entity:s.is_derived?s.slug:s.id},y=x&&!p&&!l&&!B,G=s.is_derived?ue(s,g).length:W(g).length,Q=y?se:void 0,q=e.jsxs("div",{className:"space-y-6",children:[s.is_derived?e.jsxs(e.Fragment,{children:[e.jsx(_t,{entity:s,schema:g,ownerSlug:t.slug,fieldLimit:Q}),e.jsx(xt,{record:{type:s.entity_type,key:s.slug},ownerSlug:t.slug,orgContext:d,focus:B})]}):e.jsxs(e.Fragment,{children:[e.jsx(bt,{entity:s,ownerSlug:t.slug,orgContext:d,recordUrl:n,schema:g,entityTypeName:b?.name,isTypeLoading:j,record:w,canEdit:R,editing:l,onEditingChange:h,outcome:C,onSaved:F,formId:E,fieldLimit:Q,onDeleted:c}),e.jsx(ht,{entityId:s.id,entityName:s.name,ownerSlug:t.slug,orgContext:d,focus:B,collapsed:y})]}),x&&!l&&!B?e.jsx(N,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-primary hover:text-primary","aria-expanded":!y,onClick:()=>f(y),children:y?G>se?`Show all ${G} fields`:"Show all details":"Show fewer"}):null]}),me=k=>e.jsx("div",{ref:m,className:"min-w-0 space-y-4",children:x?e.jsxs(e.Fragment,{children:[e.jsx(St,{schema:g,metadata:s.metadata??{}}),e.jsx("section",{"aria-label":"Details","data-testid":"record-details",children:q}),k]}):e.jsxs("div",{className:"grid grid-cols-[18rem_minmax(0,1fr)] gap-6",children:[e.jsx("aside",{className:"sticky top-12 max-h-[calc(100dvh-7rem)] min-w-0 self-start overflow-y-auto overscroll-contain pr-2 pb-16",children:q}),k]})}),he=V?e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:()=>{w.reset(),F(null),h(!1)},children:"Cancel"}),e.jsx(N,{type:"submit",form:E,size:"sm",disabled:!w.canSubmit||!w.isDirty||w.saving||!w.values.name.trim(),children:w.saving?"Saving...":"Save"})]}):R&&!j?e.jsxs(N,{type:"button",variant:"ghost",size:"sm",className:"h-8 shrink-0 gap-1.5 px-2 text-muted-foreground hover:text-foreground",onClick:()=>{F(null),h(!0)},children:[e.jsx(Se,{className:"h-3.5 w-3.5"}),"Edit"]}):null,M=k=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-testid":"record-header",className:"sticky top-0 z-30 -mx-4 flex h-12 items-center justify-between gap-3 bg-background px-4 lg:-mx-6 lg:px-6",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-2",children:a}),he]}),k]});if(i&&u.data===void 0)return M(u.isError?e.jsx(ee,{onRetry:()=>void u.refetch()}):null);if(P.kind==="missing")return M(e.jsx(Ye,{viewKey:P.key,backTo:n,backLabel:`Back to ${s.name}`}));if(P.kind==="view"){const{view:k}=P;return M(e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsx(Je,{decls:k.params,params:J(o),onParamsChange:xe=>void r({to:".",search:xe})}),e.jsx(oe,{orgSlug:t.slug,viewKey:k.key,scope:v,params:J(o),onParamsChange:A,contentHash:k.content_hash,title:k.name,minHeight:320})]}))}return M(me(e.jsxs("div",{className:"min-w-0 space-y-4",children:[u.isError&&e.jsx(ee,{onRetry:()=>void u.refetch()}),O.map(k=>e.jsx(jt,{view:k,orgSlug:t.slug,recordUrl:n,scope:v},k.key)),e.jsxs("section",{"aria-labelledby":"record-activity-heading",className:"min-w-0",children:[e.jsx("h2",{id:"record-activity-heading",className:"mb-2 text-sm font-medium text-muted-foreground",children:"Activity"}),e.jsx(Ue,{entity:s,organizationId:t.id,ownerSlug:t.slug})]})]})))}function Ft(t){return t?.trim()?t:void 0}function Gt({namespace:t,path:s,entity:n,viewKey:i}){const a=ie(),{data:c}=re(n.entity_type,{slug:t.slug}),o=Ft(c?.icon),r=s.map(l=>({entity_type:l.entity_type,slug:l.slug})),m=`/${t.slug}/${Oe(n.entity_type)}`,x=U(t.slug,r),p=s.length>1?U(t.slug,r.slice(0,-1)):m,f=Ae().session?.user.id;return S.useEffect(()=>{f&&Me(f,t.slug,{id:n.id,name:n.name,entityType:n.entity_type,url:x})},[f,t.slug,n.id,n.name,n.entity_type,x]),e.jsxs("div",{className:"mx-auto flex min-h-0 w-full max-w-7xl flex-1 flex-col gap-4 px-4 pt-2.5 pb-8 lg:px-6",children:[e.jsx("div",{children:e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:e.jsx(N,{asChild:!0,variant:"ghost",size:"sm",className:"-ml-2 h-7 w-fit px-2 text-muted-foreground hover:text-foreground",children:e.jsxs($e,{to:p,children:[e.jsx(ze,{className:"mr-1 h-4 w-4"}),"Back"]})})})}),e.jsx(Rt,{namespace:t,entity:n,recordUrl:x,viewKey:i,title:e.jsxs(e.Fragment,{children:[e.jsx(Xe,{metadata:n.metadata,metadataSchema:c?.metadata_schema,name:n.name,typeIcon:o,className:"h-6 w-6 shrink-0"}),e.jsx("h2",{className:"truncate text-lg font-semibold leading-tight",children:n.name})]}),onDeleted:()=>{const l=s.slice(0,-1);l.length>0?a({to:U(t.slug,l)}):a({to:m})}})]})}export{Gt as EntityPage};
2
- //# sourceMappingURL=entity-page-D3e4iPle.js.map