@lobu/runtime-server 24.0.0 → 24.1.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 (168) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/connectors/x-dm-adapter.js +65 -30
  3. package/dist/db/migrations/20261021010000_views_compile_config_hash.sql +16 -0
  4. package/dist/dependencies.bun.lock +1 -1
  5. package/dist/owletto/dist/assets/{_-CC8cTmRg.js → _-BorucF19.js} +3 -3
  6. package/dist/owletto/dist/assets/_-CkGyNi0G.js +2 -0
  7. package/dist/owletto/dist/assets/_agentId-BrhcaxUk.js +2 -0
  8. package/dist/owletto/dist/assets/{_agentId-DWUFSrVp.js → _agentId-DgRrCE2B.js} +2 -2
  9. package/dist/owletto/dist/assets/{_automationId-BnHqdXOC.js → _automationId-DSrZIYcs.js} +2 -2
  10. package/dist/owletto/dist/assets/{_connectorKey._connectionId-CefXIqy2.js → _connectorKey._connectionId-DWxv1uoi.js} +2 -2
  11. package/dist/owletto/dist/assets/{_connectorKey.index-C1QPGf9E.js → _connectorKey.index-BTP5ijdT.js} +2 -2
  12. package/dist/owletto/dist/assets/{_conversationId-DinuPCUp.js → _conversationId-98Y3RuRO.js} +2 -2
  13. package/dist/owletto/dist/assets/{_deploymentId-BeyzVjRm.js → _deploymentId-B1UWPY0i.js} +2 -2
  14. package/dist/owletto/dist/assets/{_eventId-3L_qeL_l.js → _eventId-BAnr8g8z.js} +2 -2
  15. package/dist/owletto/dist/assets/_name-BUfFO_A0.js +2 -0
  16. package/dist/owletto/dist/assets/{_owner-DbrKma4e.js → _owner-C79BwQ0I.js} +3 -3
  17. package/dist/owletto/dist/assets/_shape-Ep6JpyFX.js +2 -0
  18. package/dist/owletto/dist/assets/_skillKey-B24alBfT.js +2 -0
  19. package/dist/owletto/dist/assets/{_slug-ndDr_CUg.js → _slug-DbPdDc-5.js} +2 -2
  20. package/dist/owletto/dist/assets/_viewKey-DDUxjjFD.js +2 -0
  21. package/dist/owletto/dist/assets/_viewKey-hdpq3RoX.js +2 -0
  22. package/dist/owletto/dist/assets/{accept-invitation-CRKbM2Xy.js → accept-invitation-UXU5Fx2G.js} +2 -2
  23. package/dist/owletto/dist/assets/{activity-route-view-CFLNukhD.js → activity-route-view-D7ORHntE.js} +2 -2
  24. package/dist/owletto/dist/assets/{agent-card-controls-Be1Okb2C.js → agent-card-controls-CplnPhbv.js} +2 -2
  25. package/dist/owletto/dist/assets/{agent-client-setup-list-BA8dU_C6.js → agent-client-setup-list-BlXB4SE5.js} +2 -2
  26. package/dist/owletto/dist/assets/{agent-connect-pages-CAV-yXus.js → agent-connect-pages-BmknviTI.js} +2 -2
  27. package/dist/owletto/dist/assets/{agent-editor-form-Bi6WvYX-.js → agent-editor-form-DsSoeQeF.js} +2 -2
  28. package/dist/owletto/dist/assets/{agent-guardrails-route-DMOjG1D4.js → agent-guardrails-route-TdvvIc_J.js} +2 -2
  29. package/dist/owletto/dist/assets/{agent-loading-shells-De_2d8Lr.js → agent-loading-shells-B7v6Cffw.js} +2 -2
  30. package/dist/owletto/dist/assets/{agent-permissions-matrix-gZWl6mAe.js → agent-permissions-matrix-BkZu1LYE.js} +2 -2
  31. package/dist/owletto/dist/assets/{agent-skill-context-JLaTamGR.js → agent-skill-context-DFucg4c4.js} +2 -2
  32. package/dist/owletto/dist/assets/{agent-skills-route-DcK41PWj.js → agent-skills-route-B3vvvZZe.js} +2 -2
  33. package/dist/owletto/dist/assets/{agent-subpage-shell-BBJoyTuC.js → agent-subpage-shell-CZJvnjNC.js} +2 -2
  34. package/dist/owletto/dist/assets/agent-thread-D38STyeu.js +6 -0
  35. package/dist/owletto/dist/assets/agents-DAOln24A.js +2 -0
  36. package/dist/owletto/dist/assets/{agents-workbench-CqaKGggb.js → agents-workbench-DJ67GZ93.js} +2 -2
  37. package/dist/owletto/dist/assets/{app._appId-Cl1fTuIt.js → app._appId-Cp78oEZ9.js} +2 -2
  38. package/dist/owletto/dist/assets/{automation-detail-content-BMLL4lxO.js → automation-detail-content-DSwbRpbx.js} +2 -2
  39. package/dist/owletto/dist/assets/automations-DAOln24A.js +2 -0
  40. package/dist/owletto/dist/assets/{callback-DTKKsfkz.js → callback-CBexCo3F.js} +2 -2
  41. package/dist/owletto/dist/assets/{card-yU0TmNRH.js → card-jzhQrMDP.js} +2 -2
  42. package/dist/owletto/dist/assets/{claim-DJfTvlT2.js → claim-B-wq745Q.js} +2 -2
  43. package/dist/owletto/dist/assets/{client-rows--FrZfJol.js → client-rows-BYbsXGy9.js} +2 -2
  44. package/dist/owletto/dist/assets/{clients-L4K1UT8c.js → clients-BhNl1tVq.js} +2 -2
  45. package/dist/owletto/dist/assets/{code-editor-U54Gwjit.js → code-editor-CEqoCky-.js} +2 -2
  46. package/dist/owletto/dist/assets/connect-wx-qqLir.js +2 -0
  47. package/dist/owletto/dist/assets/connect._clientId-kk0_4Svo.js +2 -0
  48. package/dist/owletto/dist/assets/connected._clientId-QR8o-7M5.js +2 -0
  49. package/dist/owletto/dist/assets/{connected._clientId.activity-DTpSW1Xy.js → connected._clientId.activity-BqprYeOX.js} +2 -2
  50. package/dist/owletto/dist/assets/{connected._clientId.index-h9X5H1x8.js → connected._clientId.index-DhRoSzBr.js} +2 -2
  51. package/dist/owletto/dist/assets/{connection-ByvKkyFm.js → connection-CNm2ukrI.js} +2 -2
  52. package/dist/owletto/dist/assets/{connection-feed-detail-DWM9lTao.js → connection-feed-detail-WcGCA6qY.js} +2 -2
  53. package/dist/owletto/dist/assets/{connections-browser-CEwYrYqt.js → connections-browser-CrtnAs0Q.js} +2 -2
  54. package/dist/owletto/dist/assets/{connector-provenance-BocTm__v.js → connector-provenance-D-ECOlMJ.js} +2 -2
  55. package/dist/owletto/dist/assets/{connector-scope-lists-OYDOydtz.js → connector-scope-lists-CRFEpSvk.js} +2 -2
  56. package/dist/owletto/dist/assets/{connectors-CyZpcE5f.js → connectors-CH4KBZyT.js} +2 -2
  57. package/dist/owletto/dist/assets/{consent-DdfINrVp.js → consent-C9ZpHb7V.js} +2 -2
  58. package/dist/owletto/dist/assets/{conversations-table-BSznfdYt.js → conversations-table-D_HOe1jN.js} +2 -2
  59. package/dist/owletto/dist/assets/{core.esm-Dr7tcIB-.js → core.esm-BupT3V0i.js} +2 -2
  60. package/dist/owletto/dist/assets/create-C4lptGWj.js +2 -0
  61. package/dist/owletto/dist/assets/{create-CBGwASon.js → create-CCjZxIkK.js} +2 -2
  62. package/dist/owletto/dist/assets/create-DkgUQAbB.js +2 -0
  63. package/dist/owletto/dist/assets/{create-automation-form-9T5WnoUs.js → create-automation-form-Bpy92SM5.js} +2 -2
  64. package/dist/owletto/dist/assets/create._connectorKey-D6Kc-YQ3.js +2 -0
  65. package/dist/owletto/dist/assets/{cronstrue-BWFEyy_P.js → cronstrue-CWImw-kf.js} +2 -2
  66. package/dist/owletto/dist/assets/{deployments-wG_8QzOF.js → deployments-C5hvipQh.js} +2 -2
  67. package/dist/owletto/dist/assets/deployments-CPpFAd_w.js +2 -0
  68. package/dist/owletto/dist/assets/{deployments-body-2xKS8gRo.js → deployments-body-DGII20dQ.js} +2 -2
  69. package/dist/owletto/dist/assets/{device-6z-xgsoW.js → device-D-7WBe9E.js} +2 -2
  70. package/dist/owletto/dist/assets/{device-pin-tombstone-Cwq88RMU.js → device-pin-tombstone-2U0UMu3_.js} +2 -2
  71. package/dist/owletto/dist/assets/{device._deviceId-BDerBfD9.js → device._deviceId-Bn37UpWH.js} +2 -2
  72. package/dist/owletto/dist/assets/{entity-avatar-Cc1CuI-0.js → entity-avatar-mdh7Kq5D.js} +2 -2
  73. package/dist/owletto/dist/assets/{entity-options-DHdMC1Lx.js → entity-options-Clz_WXK-.js} +2 -2
  74. package/dist/owletto/dist/assets/{entity-page--OkXmlNP.js → entity-page-D3e4iPle.js} +2 -2
  75. package/dist/owletto/dist/assets/{entity-type-page-89RoK_-P.js → entity-type-page-DebN1vCM.js} +2 -2
  76. package/dist/owletto/dist/assets/{event-detail-D4YZRtrA.js → event-detail-DV_zfWnC.js} +2 -2
  77. package/dist/owletto/dist/assets/events-feed-DO3IiJO2.js +2 -0
  78. package/dist/owletto/dist/assets/{filter-editors-B1_QUpg_.js → filter-editors-Bwhqj7lY.js} +2 -2
  79. package/dist/owletto/dist/assets/{full-page-spinner-Cqih-8IW.js → full-page-spinner-BVbcpW3R.js} +2 -2
  80. package/dist/owletto/dist/assets/guardrails-BiJollCA.js +2 -0
  81. package/dist/owletto/dist/assets/identity-HCFWtdaI.js +2 -0
  82. package/dist/owletto/dist/assets/index-8wxsyxqt.js +2 -0
  83. package/dist/owletto/dist/assets/{index-DYCqXaMf.js → index-9YuSRymd.js} +4 -4
  84. package/dist/owletto/dist/assets/index-B3c-0eZG.js +2 -0
  85. package/dist/owletto/dist/assets/{index-TgRS2v_F.js → index-B64PGxQm.js} +2 -2
  86. package/dist/owletto/dist/assets/{index-DfyDUpuI.js → index-BTlx9K_t.js} +2 -2
  87. package/dist/owletto/dist/assets/index-BX0EA_oB.js +2 -0
  88. package/dist/owletto/dist/assets/index-CdJJaQDX.js +2 -0
  89. package/dist/owletto/dist/assets/index-CfT_W8Vo.js +2 -0
  90. package/dist/owletto/dist/assets/{index-DYzWV5_z.js → index-CxF2XXzl.js} +2 -2
  91. package/dist/owletto/dist/assets/index-D3WHeGql.js +2 -0
  92. package/dist/owletto/dist/assets/{index-ZNlrDc_f.js → index-D7gHOpfg.js} +2 -2
  93. package/dist/owletto/dist/assets/{index-DKPwCasf.js → index-DB1iWI_a.js} +2 -2
  94. package/dist/owletto/dist/assets/index-DMNzF8Lf.js +2 -0
  95. package/dist/owletto/dist/assets/index-DyB3IzOA.js +2 -0
  96. package/dist/owletto/dist/assets/{index-DAOyXG1X.js → index-fgAJydgX.js} +2 -2
  97. package/dist/owletto/dist/assets/{json-diff-DFvYINBT.js → json-diff-DIN5Jhfx.js} +2 -2
  98. package/dist/owletto/dist/assets/{list-skeleton-DFsEqLU1.js → list-skeleton-CepswBka.js} +2 -2
  99. package/dist/owletto/dist/assets/{login-DO0j-AYr.js → login-DxGYyE4n.js} +2 -2
  100. package/dist/owletto/dist/assets/{logout-BmNwoAf7.js → logout-Bkzc7J44.js} +2 -2
  101. package/dist/owletto/dist/assets/{member-scope-gate-B2LrMWBU.js → member-scope-gate-DD4YBFn-.js} +2 -2
  102. package/dist/owletto/dist/assets/{memory-browse-page-Cjpl8EbB.js → memory-browse-page-D_UlBa27.js} +2 -2
  103. package/dist/owletto/dist/assets/{model-selector-TQcA93xm.js → model-selector-CDrAjH31.js} +2 -2
  104. package/dist/owletto/dist/assets/models-BAVeysNq.js +2 -0
  105. package/dist/owletto/dist/assets/{new-BMrFy5Qa.js → new-C2av0diq.js} +2 -2
  106. package/dist/owletto/dist/assets/{new-ByBhteWA.js → new-ktz9Cs_P.js} +2 -2
  107. package/dist/owletto/dist/assets/{new-DWp3deoW.js → new-snm1ctHn.js} +2 -2
  108. package/dist/owletto/dist/assets/{oauth-workspace-access-D_5uESuz.js → oauth-workspace-access-lZNZ9gul.js} +2 -2
  109. package/dist/owletto/dist/assets/{organization-DTFoYP4V.js → organization-Cb0W823y.js} +2 -2
  110. package/dist/owletto/dist/assets/{peek-pane-content-DF5iGC3c.js → peek-pane-content-BNR9ImQY.js} +2 -2
  111. package/dist/owletto/dist/assets/{permissions-C_auqxfP.js → permissions-Dv39zWKt.js} +2 -2
  112. package/dist/owletto/dist/assets/{proposal-review-shell-DsNiavG_.js → proposal-review-shell-CFhOqCLf.js} +2 -2
  113. package/dist/owletto/dist/assets/public-shell-ready-DqX8AXfw.js +2 -0
  114. package/dist/owletto/dist/assets/{recent-3d99S2IE.js → recent-QhnLDU1_.js} +2 -2
  115. package/dist/owletto/dist/assets/{record-activity-C9KfBkXb.js → record-activity-ZJntBfN_.js} +2 -2
  116. package/dist/owletto/dist/assets/{record-field-peek-BBZcRuGT.js → record-field-peek-Brh1IQGy.js} +2 -2
  117. package/dist/owletto/dist/assets/{record-session-BizRugWs.js → record-session-Pbr5czGw.js} +2 -2
  118. package/dist/owletto/dist/assets/{reset-password-DqfcSn8M.js → reset-password-CzZw6RcC.js} +2 -2
  119. package/dist/owletto/dist/assets/{runs-panel-T1ZxTVz6.js → runs-panel-C0_DNTcq.js} +2 -2
  120. package/dist/owletto/dist/assets/{runs-table-D_8QlCCN.js → runs-table-B1APZv7d.js} +2 -2
  121. package/dist/owletto/dist/assets/{schema-value-normalization-CylKX3PK.js → schema-value-normalization-CKdPjdPC.js} +2 -2
  122. package/dist/owletto/dist/assets/settings-CgZ5Z7wD.js +2 -0
  123. package/dist/owletto/dist/assets/{settings-B_ClYztB.js → settings-VDNiffKU.js} +2 -2
  124. package/dist/owletto/dist/assets/skills-DgDGscm5.js +2 -0
  125. package/dist/owletto/dist/assets/{source-record-panels-Cg249m1S.js → source-record-panels-BdfOVPWn.js} +2 -2
  126. package/dist/owletto/dist/assets/{use-mention-search-BYbFvHbJ.js → use-mention-search-Dcunv4L0.js} +2 -2
  127. package/dist/owletto/dist/assets/{view-param-filters-DMSqkN2J.js → view-param-filters-B0quibBi.js} +2 -2
  128. package/dist/owletto/dist/index.html +1 -1
  129. package/dist/server-main.bundle.mjs +354 -142
  130. package/npm-shrinkwrap.json +8 -8
  131. package/package.json +1 -1
  132. package/vendor/connector-sdk/package.json +1 -1
  133. package/vendor/core/dist/contracts/tools/view-runtime.d.ts +74 -0
  134. package/vendor/core/dist/contracts/tools/view-runtime.js +86 -0
  135. package/vendor/core/package.json +6 -1
  136. package/vendor/views/package.json +1 -1
  137. package/dist/owletto/dist/assets/_-ksFp4zVf.js +0 -2
  138. package/dist/owletto/dist/assets/_agentId-MENLoohA.js +0 -2
  139. package/dist/owletto/dist/assets/_name-Dgedji78.js +0 -2
  140. package/dist/owletto/dist/assets/_shape-DtVfRFz_.js +0 -2
  141. package/dist/owletto/dist/assets/_skillKey-CqLHzm7L.js +0 -2
  142. package/dist/owletto/dist/assets/_viewKey-3CH5w8mr.js +0 -2
  143. package/dist/owletto/dist/assets/_viewKey-DHQY9A8u.js +0 -2
  144. package/dist/owletto/dist/assets/agent-thread-Buz3naVF.js +0 -6
  145. package/dist/owletto/dist/assets/agents-C-ReckCa.js +0 -2
  146. package/dist/owletto/dist/assets/automations-C-ReckCa.js +0 -2
  147. package/dist/owletto/dist/assets/connect-4zqtnDHb.js +0 -2
  148. package/dist/owletto/dist/assets/connect._clientId-Dj0SqgbE.js +0 -2
  149. package/dist/owletto/dist/assets/connected._clientId-sgtocSvf.js +0 -2
  150. package/dist/owletto/dist/assets/create-Cf5hp6Z8.js +0 -2
  151. package/dist/owletto/dist/assets/create-CwThQtd3.js +0 -2
  152. package/dist/owletto/dist/assets/create._connectorKey-sNHQHNpg.js +0 -2
  153. package/dist/owletto/dist/assets/deployments-DHh9dyzv.js +0 -2
  154. package/dist/owletto/dist/assets/events-feed-DsrkV2ix.js +0 -2
  155. package/dist/owletto/dist/assets/guardrails-B8Rs1be3.js +0 -2
  156. package/dist/owletto/dist/assets/identity-B0nH4yiC.js +0 -2
  157. package/dist/owletto/dist/assets/index-4TSkcsth.js +0 -2
  158. package/dist/owletto/dist/assets/index-BgkhXElB.js +0 -2
  159. package/dist/owletto/dist/assets/index-CoW4Bz3w.js +0 -2
  160. package/dist/owletto/dist/assets/index-Codw-Qqi.js +0 -2
  161. package/dist/owletto/dist/assets/index-DMyXd3bJ.js +0 -2
  162. package/dist/owletto/dist/assets/index-DYYZLcJ0.js +0 -2
  163. package/dist/owletto/dist/assets/index-Da6CrGEu.js +0 -2
  164. package/dist/owletto/dist/assets/index-DneshLbf.js +0 -2
  165. package/dist/owletto/dist/assets/models-D7aED5Sa.js +0 -2
  166. package/dist/owletto/dist/assets/public-shell-ready-B2NUI89V.js +0 -2
  167. package/dist/owletto/dist/assets/settings-DgX1-xo7.js +0 -2
  168. package/dist/owletto/dist/assets/skills-Drw5tcZw.js +0 -2
@@ -1,2 +1,2 @@
1
- import{ax as g,ay as y,j as s,eE as N,cF as m,dy as p,Q as f,B as w,eG as b}from"./index-DYCqXaMf.js";function M(o,r){const l=new Map(r.map(e=>[e.slug,e])),i=new Map,d=e=>{const a=e.model?.trim();if(!a)return;const t=`${e.slug}/${a}`;i.has(t)||i.set(t,{value:t,provider:e.provider,model:a,isDefault:e.isDefault})};for(const e of o){const a=l.get(e.kind)??l.get(e.slug),t={slug:e.slug,provider:e.displayName||e.slug,isDefault:e.isDefault};d({...t,model:e.capabilities.text?.model}),d({...t,model:a?.defaultModel});for(const x of a?.models??[])d({...t,model:x})}for(const e of r){if(!e.systemAvailable)continue;const a={slug:e.slug,provider:e.displayName||e.slug,isDefault:!1};d({...a,model:e.defaultModel});for(const t of e.models)d({...a,model:t})}return[...i.values()]}function _(o,r){const l=o.trim();return l.length>0&&l!=="auto"&&!r.some(i=>i.value===l)}function S({value:o,onChange:r,placeholder:l,disabled:i,className:d}){const{data:e=[]}=g(),{data:a=[]}=y(),t=M(e,a),x=t.find(c=>c.value===o),h=o==="auto"?"auto":x?.value??o;return s.jsx(N,{contentClassName:"w-[--radix-popover-trigger-width] min-w-[280px]",searchPlaceholder:"Search or type a model ref…",emptyText:"Type a full provider/model ref to use it.",trigger:c=>s.jsxs(w,{type:"button",variant:"outline",role:"combobox","aria-expanded":c,disabled:i,className:f("w-full justify-between font-normal",o?"":"text-muted-foreground",d),children:[s.jsx("span",{className:"truncate",children:o?h:l}),s.jsx(b,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:(c,j)=>{const u=j.trim(),v=_(u,t);return s.jsxs(s.Fragment,{children:[s.jsxs(m,{value:"__inherit__ use default inherit",onSelect:()=>{r(""),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===""?"opacity-100":"opacity-0")}),s.jsx("span",{className:"text-muted-foreground",children:l})]}),s.jsxs(m,{value:"auto newest latest",onSelect:()=>{r("auto"),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o==="auto"?"opacity-100":"opacity-0")}),s.jsxs("span",{children:["auto"," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:"(newest for the provider)"})]})]}),t.map(n=>s.jsxs(m,{value:`${n.provider} ${n.model} ${n.value}`,onSelect:()=>{r(n.value),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===n.value?"opacity-100":"opacity-0")}),s.jsxs("span",{className:"truncate",children:[n.provider," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:n.model}),n.isDefault?s.jsx("span",{className:"ml-1.5 text-muted-foreground text-xs",children:"· org default"}):null]})]},n.value)),v?s.jsxs(m,{value:`__custom__ ${u}`,onSelect:()=>{r(u),c()},className:"cursor-pointer",children:[s.jsx(p,{className:"mr-2 h-4 w-4 opacity-0"}),s.jsxs("span",{children:["Use ",s.jsx("span",{className:"font-mono text-xs",children:u})]})]}):null]})}})}export{S as M,M as b,_ as s};
2
- //# sourceMappingURL=model-selector-TQcA93xm.js.map
1
+ import{ax as g,ay as y,j as s,eE as N,cF as m,dy as p,Q as f,B as w,eG as b}from"./index-9YuSRymd.js";function M(o,r){const l=new Map(r.map(e=>[e.slug,e])),i=new Map,d=e=>{const a=e.model?.trim();if(!a)return;const t=`${e.slug}/${a}`;i.has(t)||i.set(t,{value:t,provider:e.provider,model:a,isDefault:e.isDefault})};for(const e of o){const a=l.get(e.kind)??l.get(e.slug),t={slug:e.slug,provider:e.displayName||e.slug,isDefault:e.isDefault};d({...t,model:e.capabilities.text?.model}),d({...t,model:a?.defaultModel});for(const x of a?.models??[])d({...t,model:x})}for(const e of r){if(!e.systemAvailable)continue;const a={slug:e.slug,provider:e.displayName||e.slug,isDefault:!1};d({...a,model:e.defaultModel});for(const t of e.models)d({...a,model:t})}return[...i.values()]}function _(o,r){const l=o.trim();return l.length>0&&l!=="auto"&&!r.some(i=>i.value===l)}function S({value:o,onChange:r,placeholder:l,disabled:i,className:d}){const{data:e=[]}=g(),{data:a=[]}=y(),t=M(e,a),x=t.find(c=>c.value===o),h=o==="auto"?"auto":x?.value??o;return s.jsx(N,{contentClassName:"w-[--radix-popover-trigger-width] min-w-[280px]",searchPlaceholder:"Search or type a model ref…",emptyText:"Type a full provider/model ref to use it.",trigger:c=>s.jsxs(w,{type:"button",variant:"outline",role:"combobox","aria-expanded":c,disabled:i,className:f("w-full justify-between font-normal",o?"":"text-muted-foreground",d),children:[s.jsx("span",{className:"truncate",children:o?h:l}),s.jsx(b,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:(c,j)=>{const u=j.trim(),v=_(u,t);return s.jsxs(s.Fragment,{children:[s.jsxs(m,{value:"__inherit__ use default inherit",onSelect:()=>{r(""),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===""?"opacity-100":"opacity-0")}),s.jsx("span",{className:"text-muted-foreground",children:l})]}),s.jsxs(m,{value:"auto newest latest",onSelect:()=>{r("auto"),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o==="auto"?"opacity-100":"opacity-0")}),s.jsxs("span",{children:["auto"," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:"(newest for the provider)"})]})]}),t.map(n=>s.jsxs(m,{value:`${n.provider} ${n.model} ${n.value}`,onSelect:()=>{r(n.value),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===n.value?"opacity-100":"opacity-0")}),s.jsxs("span",{className:"truncate",children:[n.provider," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:n.model}),n.isDefault?s.jsx("span",{className:"ml-1.5 text-muted-foreground text-xs",children:"· org default"}):null]})]},n.value)),v?s.jsxs(m,{value:`__custom__ ${u}`,onSelect:()=>{r(u),c()},className:"cursor-pointer",children:[s.jsx(p,{className:"mr-2 h-4 w-4 opacity-0"}),s.jsxs("span",{children:["Use ",s.jsx("span",{className:"font-mono text-xs",children:u})]})]}):null]})}})}export{S as M,M as b,_ as s};
2
+ //# sourceMappingURL=model-selector-CDrAjH31.js.map
@@ -0,0 +1,2 @@
1
+ import{iN as e,j as r}from"./index-9YuSRymd.js";import{a as n}from"./agents-workbench-DJ67GZ93.js";import"./agent-editor-form-DsSoeQeF.js";import"./model-selector-CDrAjH31.js";import"./proposal-review-shell-CFhOqCLf.js";function u(){const{owner:o,agentId:t}=e.useParams();return r.jsx(n,{owner:o,agentId:t,tab:"models"})}export{u as component};
2
+ //# sourceMappingURL=models-BAVeysNq.js.map
@@ -1,2 +1,2 @@
1
- import{h7 as r,o as p,$ as x,i as h,bh as b,a_ as f,j as a,aC as w,g9 as A,ag as L,ga as C,L as j,gb as S,f4 as N,aR as k,bS as y}from"./index-DYCqXaMf.js";import{A as E}from"./agent-editor-form-Bi6WvYX-.js";import"./model-selector-TQcA93xm.js";const _="flex min-h-0 flex-1 flex-col gap-3 px-4 pt-2.5 pb-8 lg:px-6";function $(){const{owner:e}=r.useParams(),t=r.useSearch(),o=p(),i=x(),{isAuthenticated:c}=h(),{isMember:g,isLoading:m}=b(),n=c&&g,{data:u=[],isLoading:l}=f({enabled:n});return a.jsx("div",{className:_,children:a.jsxs(w,{className:"flex flex-1 flex-col gap-6",children:[a.jsx(A,{breadcrumb:a.jsx(C,{crumbs:[a.jsx(j,{to:"/$owner/agents",params:{owner:e},className:S,children:"Agents"},"agents")]}),icon:a.jsx(L.agents.icon,{className:"h-6 w-6"}),title:"Build a managed agent",caption:"Create an agent that Lobu runs and manages for this workspace."}),m||n&&l?a.jsx(N,{rows:1}):n?a.jsx(E,{mode:{kind:"create"},existingAgentIds:u.map(s=>s.agentId),onCreated:async s=>{const d=["agents",e];if(await i.refetchQueries({queryKey:d,exact:!0}),t.platform&&t.listen){await o({to:"/$owner/automations/new",params:{owner:e},search:{...t,agent:s}});return}await o({to:"/$owner/agents/$agentId/settings",params:{owner:e,agentId:s},search:{run_id:void 0}})}}):a.jsx(k,{icon:y,title:"Workspace membership required",description:"Only workspace members can build managed agents."})]})})}export{$ as component};
2
- //# sourceMappingURL=new-BMrFy5Qa.js.map
1
+ import{h7 as r,o as p,$ as x,i as h,bh as b,a_ as f,j as a,aC as w,g9 as A,ag as L,ga as C,L as j,gb as S,f4 as N,aR as k,bS as y}from"./index-9YuSRymd.js";import{A as E}from"./agent-editor-form-DsSoeQeF.js";import"./model-selector-CDrAjH31.js";const _="flex min-h-0 flex-1 flex-col gap-3 px-4 pt-2.5 pb-8 lg:px-6";function $(){const{owner:e}=r.useParams(),t=r.useSearch(),o=p(),i=x(),{isAuthenticated:c}=h(),{isMember:g,isLoading:m}=b(),n=c&&g,{data:u=[],isLoading:l}=f({enabled:n});return a.jsx("div",{className:_,children:a.jsxs(w,{className:"flex flex-1 flex-col gap-6",children:[a.jsx(A,{breadcrumb:a.jsx(C,{crumbs:[a.jsx(j,{to:"/$owner/agents",params:{owner:e},className:S,children:"Agents"},"agents")]}),icon:a.jsx(L.agents.icon,{className:"h-6 w-6"}),title:"Build a managed agent",caption:"Create an agent that Lobu runs and manages for this workspace."}),m||n&&l?a.jsx(N,{rows:1}):n?a.jsx(E,{mode:{kind:"create"},existingAgentIds:u.map(s=>s.agentId),onCreated:async s=>{const d=["agents",e];if(await i.refetchQueries({queryKey:d,exact:!0}),t.platform&&t.listen){await o({to:"/$owner/automations/new",params:{owner:e},search:{...t,agent:s}});return}await o({to:"/$owner/agents/$agentId/settings",params:{owner:e,agentId:s},search:{run_id:void 0}})}}):a.jsx(k,{icon:y,title:"Workspace membership required",description:"Only workspace members can build managed agents."})]})})}export{$ as component};
2
+ //# sourceMappingURL=new-C2av0diq.js.map
@@ -1,2 +1,2 @@
1
- import{o as R,i as F,y as E,r,j as e,z as v,I as S,B as L,E as N,F as U}from"./index-DYCqXaMf.js";import{C as I,a as A,b as T,c as k}from"./card-yU0TmNRH.js";import{F as B}from"./full-page-spinner-Cqih-8IW.js";function c(l){return l.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function H(){const l=R(),{session:u,isReady:d}=F(),{slug:n,name:i}=E.useSearch(),[m,y]=r.useState(i||n||""),[g,h]=r.useState(n||(i?c(i):"")),[b,C]=r.useState(!!n),[x,o]=r.useState(null),[f,p]=r.useState(!1),j=r.useRef(!1);if(r.useEffect(()=>{if(!d||u||j.current)return;j.current=!0;const a=new URL("/orgs/new",window.location.origin);n&&a.searchParams.set("slug",n),i&&a.searchParams.set("name",i);const s=new URL("/auth/login",window.location.origin);s.searchParams.set("callbackUrl",`${a.pathname}${a.search}`),window.location.assign(s.toString())},[d,u,n,i]),!d||!u)return e.jsx(B,{});const P=a=>{const s=U(a);if(s.kind==="cross-host"){window.location.assign(s.href);return}l({to:s.to})},z=async a=>{a.preventDefault(),o(null);const s=m.trim(),w=(g.trim()||c(s)).trim();if(!s){o("Name is required");return}if(!w){o("Slug is required");return}p(!0);try{const t=await N.create({name:s,slug:w});if(t.error){o(t.error.message||"Failed to create organization");return}t.data&&(await N.setActive({organizationId:t.data.id}),P(t.data.slug))}catch(t){o(t instanceof Error?t.message:"An error occurred")}finally{p(!1)}};return e.jsx("div",{className:"container mx-auto max-w-md px-4 py-10",children:e.jsxs(I,{children:[e.jsx(A,{children:e.jsx(T,{children:"Create organization"})}),e.jsx(k,{children:e.jsxs("form",{onSubmit:z,className:"space-y-4",children:[x&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:x}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{htmlFor:"org-name",children:["Name",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"org-name",value:m,onChange:a=>{y(a.target.value),b||h(c(a.target.value))},placeholder:"Acme Inc.",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{htmlFor:"org-slug",children:["Slug",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"org-slug",value:g,onChange:a=>{C(!0),h(c(a.target.value))},placeholder:"acme"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used in URLs and as the org id in ",e.jsx("code",{children:"lobu.toml"}),". Lowercase letters, numbers, and hyphens."]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(L,{type:"submit",disabled:f,children:f?"Creating…":"Create organization"})})]})})]})})}export{H as component};
2
- //# sourceMappingURL=new-ByBhteWA.js.map
1
+ import{o as R,i as F,y as E,r,j as e,z as v,I as S,B as L,E as N,F as U}from"./index-9YuSRymd.js";import{C as I,a as A,b as T,c as k}from"./card-jzhQrMDP.js";import{F as B}from"./full-page-spinner-BVbcpW3R.js";function c(l){return l.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function H(){const l=R(),{session:u,isReady:d}=F(),{slug:n,name:i}=E.useSearch(),[m,y]=r.useState(i||n||""),[g,h]=r.useState(n||(i?c(i):"")),[b,C]=r.useState(!!n),[x,o]=r.useState(null),[f,p]=r.useState(!1),j=r.useRef(!1);if(r.useEffect(()=>{if(!d||u||j.current)return;j.current=!0;const a=new URL("/orgs/new",window.location.origin);n&&a.searchParams.set("slug",n),i&&a.searchParams.set("name",i);const s=new URL("/auth/login",window.location.origin);s.searchParams.set("callbackUrl",`${a.pathname}${a.search}`),window.location.assign(s.toString())},[d,u,n,i]),!d||!u)return e.jsx(B,{});const P=a=>{const s=U(a);if(s.kind==="cross-host"){window.location.assign(s.href);return}l({to:s.to})},z=async a=>{a.preventDefault(),o(null);const s=m.trim(),w=(g.trim()||c(s)).trim();if(!s){o("Name is required");return}if(!w){o("Slug is required");return}p(!0);try{const t=await N.create({name:s,slug:w});if(t.error){o(t.error.message||"Failed to create organization");return}t.data&&(await N.setActive({organizationId:t.data.id}),P(t.data.slug))}catch(t){o(t instanceof Error?t.message:"An error occurred")}finally{p(!1)}};return e.jsx("div",{className:"container mx-auto max-w-md px-4 py-10",children:e.jsxs(I,{children:[e.jsx(A,{children:e.jsx(T,{children:"Create organization"})}),e.jsx(k,{children:e.jsxs("form",{onSubmit:z,className:"space-y-4",children:[x&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:x}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{htmlFor:"org-name",children:["Name",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"org-name",value:m,onChange:a=>{y(a.target.value),b||h(c(a.target.value))},placeholder:"Acme Inc.",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{htmlFor:"org-slug",children:["Slug",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"org-slug",value:g,onChange:a=>{C(!0),h(c(a.target.value))},placeholder:"acme"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used in URLs and as the org id in ",e.jsx("code",{children:"lobu.toml"}),". Lowercase letters, numbers, and hyphens."]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(L,{type:"submit",disabled:f,children:f?"Creating…":"Create organization"})})]})})]})})}export{H as component};
2
+ //# sourceMappingURL=new-ktz9Cs_P.js.map
@@ -1,2 +1,2 @@
1
- import{o as p,bh as j,d7 as N,r as x,j as e,B as w,gK as b,bb as y,L as _,S as f,gL as v,ai as C}from"./index-DYCqXaMf.js";import{C as k,A}from"./create-automation-form-9T5WnoUs.js";import"./cronstrue-BWFEyy_P.js";import"./entity-options-DHdMC1Lx.js";import"./connection-label-BobuYiAG.js";import"./model-selector-TQcA93xm.js";import"./skill-editor-D_W3QlRz.js";import"./code-editor-U54Gwjit.js";import"./index-CDz3-ieP.js";import"./index-Vcq4gwWv.js";import"./use-mention-search-BYbFvHbJ.js";function S(s){return s.includes(":")?s.slice(s.indexOf(":")+1):s}function T({prefillAgentId:s,onCancel:t,initialTriggers:m}){const{org:g}=j(),[o,i]=x.useState({ready:!1,triggers:[]}),[a,l]=x.useState(),h=x.useCallback(n=>{i(u=>JSON.stringify(u)===JSON.stringify(n)?u:n)},[]),c=a??m;return e.jsx(k,{startFromScratch:!!m,organizationId:g?.id??"",prefillAgentId:s,onClose:t,onPrefillTriggers:n=>l(n.length>0?n:void 0),onSuccess:t,hideHeader:!0,hideCancel:!0,submitLabel:"Create Automation",submitDisabled:!o.ready,createFields:{triggers:o.triggers},triggerFields:e.jsx(A,{organizationId:g?.id??null,initialTriggers:c,onChange:h},JSON.stringify(c??"new"))})}function L({owner:s,prefilled:t}){const m=p(),{org:g}=j(),o=N(g?.id??null,{status:"active",limit:500}),i=!!(t?.platform&&(t.listen||t.resource)),a=x.useMemo(()=>{if(!t?.platform||!t.listen&&!t.resource)return;const c=o.data??[],n=t.connection?c.find(r=>r.slug===t.connection):(()=>{const r=c.filter(d=>d.connector_key!==t.platform?!1:t.resource?!0:d.facets.chat&&(d.external_tenant_id??"")===(t.team??""));return r.length===1?r[0]:void 0})();if(t.connection&&!n)return;const u=t.events?.split(",").map(r=>r.trim()).filter(Boolean)??[];return[{kind:"event",source:"connector",connector_key:t.platform,...n?{connection_id:n.id}:{},event_types:u.length>0?u:t.listen?["message.created"]:[],match:t.resource?{resource_ref:t.resource,...t.resource_type?{resource_type:t.resource_type}:{}}:{channel_id:S(t.listen??"")},execution:"turn",active_run:t.listen?"steer":"queue",output:t.listen?"reply_to_source":"silent",skip_if_unchanged:!t.listen}]},[o.data,t]),l=()=>void m({to:"/$owner/automations",params:{owner:s}}),h=a?t?.resource?`React to changes on ${t.label??t.resource}.`:`React to messages in ${t?.label??t?.listen}.`:i&&!o.isLoading?"Choose the matching connection and event, then define the reaction.":"Start from a template, from scratch, or clone an existing Automation.";return e.jsx("div",{className:"flex flex-1 flex-col gap-6 px-4 pt-2.5 pb-8 lg:px-6",children:e.jsxs("div",{className:"mx-auto flex w-full min-w-0 max-w-3xl flex-col gap-4",children:[e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3",children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsxs(w,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1.5 text-muted-foreground hover:text-foreground",onClick:l,children:[e.jsx(b,{className:"h-3.5 w-3.5"}),"Automations"]}),e.jsxs("h1",{className:"flex min-w-0 items-center gap-2 truncate font-display text-xl font-semibold",children:[e.jsx(y,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),"New automation"]})]})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:h}),t?.listen&&a?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Choose an agent below, or"," ",e.jsx(_,{to:"/$owner/agents/new",params:{owner:s},search:t,className:"underline underline-offset-4",children:"create an agent"})," ","and return to this conversation setup."]}):null,i&&o.isLoading?e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{className:"h-10 w-full"}),e.jsx(f,{className:"h-32 w-full"})]}):i&&t?.connection&&!a?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"This connection is no longer available. Reopen setup from your conversation."}):e.jsx(T,{prefillAgentId:t?.agent,onCancel:l,initialTriggers:a})]})})}function W(){const{owner:s}=v.useParams(),t=v.useSearch();return e.jsx(C,{owner:s,children:()=>e.jsx(L,{owner:s,prefilled:t})})}export{W as component};
2
- //# sourceMappingURL=new-DWp3deoW.js.map
1
+ import{o as p,bh as j,d7 as N,r as x,j as e,B as w,gK as b,bb as y,L as _,S as f,gL as v,ai as C}from"./index-9YuSRymd.js";import{C as k,A}from"./create-automation-form-Bpy92SM5.js";import"./cronstrue-CWImw-kf.js";import"./entity-options-Clz_WXK-.js";import"./connection-label-BobuYiAG.js";import"./model-selector-CDrAjH31.js";import"./skill-editor-D_W3QlRz.js";import"./code-editor-CEqoCky-.js";import"./index-CDz3-ieP.js";import"./index-Vcq4gwWv.js";import"./use-mention-search-Dcunv4L0.js";function S(s){return s.includes(":")?s.slice(s.indexOf(":")+1):s}function T({prefillAgentId:s,onCancel:t,initialTriggers:m}){const{org:g}=j(),[o,i]=x.useState({ready:!1,triggers:[]}),[a,l]=x.useState(),h=x.useCallback(n=>{i(u=>JSON.stringify(u)===JSON.stringify(n)?u:n)},[]),c=a??m;return e.jsx(k,{startFromScratch:!!m,organizationId:g?.id??"",prefillAgentId:s,onClose:t,onPrefillTriggers:n=>l(n.length>0?n:void 0),onSuccess:t,hideHeader:!0,hideCancel:!0,submitLabel:"Create Automation",submitDisabled:!o.ready,createFields:{triggers:o.triggers},triggerFields:e.jsx(A,{organizationId:g?.id??null,initialTriggers:c,onChange:h},JSON.stringify(c??"new"))})}function L({owner:s,prefilled:t}){const m=p(),{org:g}=j(),o=N(g?.id??null,{status:"active",limit:500}),i=!!(t?.platform&&(t.listen||t.resource)),a=x.useMemo(()=>{if(!t?.platform||!t.listen&&!t.resource)return;const c=o.data??[],n=t.connection?c.find(r=>r.slug===t.connection):(()=>{const r=c.filter(d=>d.connector_key!==t.platform?!1:t.resource?!0:d.facets.chat&&(d.external_tenant_id??"")===(t.team??""));return r.length===1?r[0]:void 0})();if(t.connection&&!n)return;const u=t.events?.split(",").map(r=>r.trim()).filter(Boolean)??[];return[{kind:"event",source:"connector",connector_key:t.platform,...n?{connection_id:n.id}:{},event_types:u.length>0?u:t.listen?["message.created"]:[],match:t.resource?{resource_ref:t.resource,...t.resource_type?{resource_type:t.resource_type}:{}}:{channel_id:S(t.listen??"")},execution:"turn",active_run:t.listen?"steer":"queue",output:t.listen?"reply_to_source":"silent",skip_if_unchanged:!t.listen}]},[o.data,t]),l=()=>void m({to:"/$owner/automations",params:{owner:s}}),h=a?t?.resource?`React to changes on ${t.label??t.resource}.`:`React to messages in ${t?.label??t?.listen}.`:i&&!o.isLoading?"Choose the matching connection and event, then define the reaction.":"Start from a template, from scratch, or clone an existing Automation.";return e.jsx("div",{className:"flex flex-1 flex-col gap-6 px-4 pt-2.5 pb-8 lg:px-6",children:e.jsxs("div",{className:"mx-auto flex w-full min-w-0 max-w-3xl flex-col gap-4",children:[e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3",children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsxs(w,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1.5 text-muted-foreground hover:text-foreground",onClick:l,children:[e.jsx(b,{className:"h-3.5 w-3.5"}),"Automations"]}),e.jsxs("h1",{className:"flex min-w-0 items-center gap-2 truncate font-display text-xl font-semibold",children:[e.jsx(y,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),"New automation"]})]})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:h}),t?.listen&&a?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Choose an agent below, or"," ",e.jsx(_,{to:"/$owner/agents/new",params:{owner:s},search:t,className:"underline underline-offset-4",children:"create an agent"})," ","and return to this conversation setup."]}):null,i&&o.isLoading?e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{className:"h-10 w-full"}),e.jsx(f,{className:"h-32 w-full"})]}):i&&t?.connection&&!a?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"This connection is no longer available. Reopen setup from your conversation."}):e.jsx(T,{prefillAgentId:t?.agent,onCancel:l,initialTriggers:a})]})})}function W(){const{owner:s}=v.useParams(),t=v.useSearch();return e.jsx(C,{owner:s,children:()=>e.jsx(L,{owner:s,prefilled:t})})}export{W as component};
2
+ //# sourceMappingURL=new-snm1ctHn.js.map
@@ -1,2 +1,2 @@
1
- import{j as e,P as y,Q as $,T as E,B as R,r as u,U as z}from"./index-DYCqXaMf.js";const W=["mcp:read","mcp:write","mcp:admin"],P=[{value:"read",title:"Read only",description:"Search and view authorized workspace data."},{value:"write",title:"Read and make changes",description:"Includes read access. Create and update authorized workspace data."},{value:"admin",title:"Administer workspaces",description:"Includes read and write access. Manage administrator-only settings.",risk:"high"}],S={read:0,write:1,admin:2};function I(s){return s.includes("mcp:admin")?"admin":s.includes("mcp:write")?"write":s.includes("mcp:read")?"read":null}function D(s,a){const r=s.filter(x=>!W.includes(x));if(!a)return r;const i=I(s);return!i||S[a]>S[i]?r:["mcp:read",...a==="write"||a==="admin"?["mcp:write"]:[],...a==="admin"?["mcp:admin"]:[],...r]}function H({idPrefix:s,clientName:a,requestedScopes:r,accessLevel:i,onAccessLevelChange:x,sensitiveScopesAcknowledged:v=!1,onSensitiveScopesAcknowledgedChange:g,disabled:b=!1}){const k=I(r),f=r.includes("profile:read"),p=r.includes("device_worker:run"),o=r.includes("connections:token"),j=p||o,c=r.filter(n=>!W.includes(n)&&n!=="profile:read"&&n!=="device_worker:run"&&n!=="connections:token");return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{"aria-labelledby":`${s}-application`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-application`,className:"text-sm font-medium",children:"Application"}),e.jsx("div",{className:"rounded-lg border p-4",children:e.jsx("span",{className:"text-sm font-semibold text-foreground",children:a||"Unnamed application"})})]}),k&&e.jsxs("fieldset",{className:"space-y-2",disabled:b,children:[e.jsx("legend",{className:"text-sm font-medium",children:"Access level"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose the maximum access this application should receive."}),e.jsx("div",{className:"space-y-2",children:P.filter(n=>S[n.value]<=S[k]).map(n=>{const l=`${s}-access-${n.value}`,h=i===n.value;return e.jsxs("label",{htmlFor:l,className:$("flex cursor-pointer items-start gap-3 rounded-md border p-3 transition-colors",h&&"border-primary bg-primary/5"),children:[e.jsx("input",{id:l,type:"radio",name:`${s}-access-level`,value:n.value,checked:h,onChange:()=>x(n.value),className:"mt-1 h-4 w-4 accent-primary"}),e.jsxs("span",{className:"min-w-0 space-y-0.5",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:[n.title,n.risk==="high"&&e.jsx(y,{variant:"destructive",children:"High risk"})]}),e.jsx("span",{className:"block text-sm text-muted-foreground",children:n.description})]})]},n.value)})})]}),f&&e.jsxs("section",{"aria-labelledby":`${s}-profile`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-profile`,className:"text-sm font-medium",children:"Account information"}),e.jsxs("div",{className:"rounded-md border p-3",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:["Basic profile",e.jsx(y,{variant:"secondary",children:"Included"})]}),e.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:"See your basic Lobu identity and the names and slugs of workspaces you belong to."})]})]}),c.length>0&&e.jsxs("section",{"aria-labelledby":`${s}-additional`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-additional`,className:"text-sm font-medium",children:"Additional permissions"}),e.jsx("ul",{className:"space-y-2",children:c.map(n=>e.jsx("li",{className:"rounded-md border p-3 font-mono text-xs text-foreground",children:n},n))})]}),j&&e.jsxs("section",{className:"space-y-3 rounded-md border border-destructive/40 bg-destructive/5 p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Device capabilities"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"These capabilities are fixed by the device request and cannot be reduced here."})]}),e.jsxs("ul",{className:"space-y-2",children:[p&&e.jsxs("li",{className:"rounded-md bg-background/70 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Operate this device"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Run jobs and Automations through capabilities advertised by this device."})]}),o&&e.jsxs("li",{className:"rounded-md bg-background/70 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Use connected services"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Request short-lived access for services you connected to Lobu."})]})]}),e.jsxs("div",{className:"flex items-start gap-3 rounded-md border bg-background p-3",children:[e.jsx(E,{id:`${s}-sensitive-acknowledgement`,checked:v,disabled:b,onCheckedChange:n=>g?.(n===!0),className:"mt-0.5"}),e.jsx("label",{htmlFor:`${s}-sensitive-acknowledgement`,className:"cursor-pointer text-sm font-medium text-foreground",children:"I initiated this request and confirmed that the device code matches."})]})]})]})}function T({idPrefix:s,orgList:a,selectedOrgIds:r,onWorkspaceAccessChange:i,onSelectedOrgChange:x,orgsLoading:v,orgsError:g,onRetry:b,disabled:k=!1,deviceHomeOrgId:f=null,allowMultiple:p}){const o=`${s}-workspace-access-legend`,j=r.length===a.length;return v?e.jsxs("section",{"aria-labelledby":o,className:"space-y-2",children:[e.jsx("p",{id:o,className:"text-sm font-medium",children:"Workspace access"}),e.jsx("p",{role:"status","aria-live":"polite",className:"text-sm text-muted-foreground",children:"Loading your workspaces..."})]}):g?e.jsxs("section",{"aria-labelledby":o,className:"space-y-2",children:[e.jsx("p",{id:o,className:"text-sm font-medium",children:"Workspace access"}),e.jsxs("div",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[e.jsx("p",{children:"Workspaces could not be loaded. Approval is unavailable until they load."}),e.jsx(R,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:b,children:"Retry"})]})]}):a.length===0?e.jsxs("section",{"aria-labelledby":o,className:"space-y-2",children:[e.jsx("p",{id:o,className:"text-sm font-medium",children:"Workspace access"}),e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:"No member workspaces are available for this connection."})]}):e.jsxs("fieldset",{className:"space-y-3",disabled:k,children:[e.jsx("legend",{id:o,className:"sr-only",children:"Workspace access"}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Workspaces"}),e.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:p?"Choose where this application can operate.":"Choose one workspace this application can access."})]}),p&&!j&&e.jsxs(R,{type:"button",variant:"outline",size:"sm",onClick:()=>i("all_current"),children:["Select all ",a.length]})]}),f&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p?"The device workspace is always included. Additional workspaces grant MCP access only.":"MCP access follows the device workspace."}),e.jsx("div",{className:"space-y-2",children:a.map(c=>{const n=`${s}-workspace-${c.id}`,l=c.id===f,h=r.includes(c.id);return e.jsxs("div",{className:$("flex items-start gap-3 rounded-md border p-3 transition-colors",h&&"border-primary/40 bg-primary/5"),children:[e.jsx(E,{id:n,checked:h,disabled:k||l||f!==null&&!p,onCheckedChange:N=>x(c.id,N===!0),className:"mt-0.5"}),e.jsxs("label",{htmlFor:n,className:"min-w-0 flex-1 cursor-pointer space-y-0.5",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:[c.name,c.isPersonal&&e.jsx(y,{variant:"outline",children:"Personal"}),l&&e.jsx(y,{variant:"secondary",children:"Device workspace"})]}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:c.slug})]})]},c.id)})}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-muted-foreground",children:[e.jsxs("p",{"aria-live":"polite",children:[r.length," of ",a.length," workspaces selected."]}),j&&e.jsx(y,{variant:"secondary",children:"All currently available"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Workspaces you join later are not added automatically."}),r.length===0&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"Choose at least one workspace."})]})}function q(s,a){u.useEffect(()=>{if(a||s)return;const r=new URL("/auth/login",window.location.origin);r.searchParams.set("callbackUrl",window.location.href),window.location.href=r.toString()},[s,a])}function F(s,a){return s.length===a.length&&s.every((r,i)=>r===a[i])}function V(s={}){const{requireDeviceHome:a=!1,deviceHomeOrgId:r=null,allowMultiple:i=!0}=s,{data:x,error:v,isPending:g,refetch:b}=z(),[k,f]=u.useState("selected"),[p,o]=u.useState([]),j=u.useRef(!1),c=u.useMemo(()=>x?x.filter(t=>t.is_member).map(t=>({id:t.id,name:t.name,slug:t.slug,isPersonal:t.is_personal===!0})):[],[x]),n=c.find(t=>t.isPersonal)?.id??null,l=a?r&&c.some(t=>t.id===r)?r:n:null,h=u.useRef(c);h.current=c;const N=v instanceof Error?v.message:v?"Unable to load workspaces":null;u.useEffect(()=>{if(g||N)return;const t=c.map(d=>d.id),m=new Set(t);o(d=>{const C=j.current?d.filter(A=>m.has(A)):[n??t[0]].filter(A=>!!A);return j.current=!0,F(d,C)?d:C})},[c,N,g,n]);const L=u.useCallback(t=>{if(t==="all_current"){if(!i)return;o(h.current.map(m=>m.id))}f(t)},[i]),M=u.useCallback((t,m)=>{h.current.some(d=>d.id===t)&&(a&&(t===l||!i)||(f("selected"),o(d=>m?i?d.includes(t)?d:[...d,t]:[t]:d.filter(C=>C!==t))))},[i,l,a]),w=u.useMemo(()=>{if(a&&l&&!i)return[l];const t=new Set(p);return a&&l&&t.add(l),c.filter(m=>t.has(m.id)).map(m=>m.id)},[i,p,l,c,a]),_=u.useCallback(()=>{const t=h.current,m=t.find(d=>d.isPersonal)?.id??t[0]?.id;j.current=t.length>0,f("selected"),o(m?[m]:[])},[]),O=!g&&!N&&c.length>0&&w.length>0&&(i||w.length===1)&&(!a||l!==null&&w.includes(l)),U=u.useCallback(()=>{b()},[b]);return{orgList:c,workspaceAccess:k,setWorkspaceAccess:L,selectedOrgIds:w,toggleSelectedOrgId:M,resetWorkspaceSelection:_,personalOrgId:n,deviceHomeOrgId:l,orgsLoading:g,orgsError:N,retryOrgs:U,workspaceSelectionReady:O}}function K(s){if(!s)return null;try{return new URL(s).pathname.match(/^\/mcp\/([^/]+)$/)?.[1]?.trim()||null}catch{return null}}export{H as A,T as W,I as a,q as b,K as g,D as s,V as u};
2
- //# sourceMappingURL=oauth-workspace-access-D_5uESuz.js.map
1
+ import{j as e,P as y,Q as $,T as E,B as R,r as u,U as z}from"./index-9YuSRymd.js";const W=["mcp:read","mcp:write","mcp:admin"],P=[{value:"read",title:"Read only",description:"Search and view authorized workspace data."},{value:"write",title:"Read and make changes",description:"Includes read access. Create and update authorized workspace data."},{value:"admin",title:"Administer workspaces",description:"Includes read and write access. Manage administrator-only settings.",risk:"high"}],S={read:0,write:1,admin:2};function I(s){return s.includes("mcp:admin")?"admin":s.includes("mcp:write")?"write":s.includes("mcp:read")?"read":null}function D(s,a){const r=s.filter(x=>!W.includes(x));if(!a)return r;const i=I(s);return!i||S[a]>S[i]?r:["mcp:read",...a==="write"||a==="admin"?["mcp:write"]:[],...a==="admin"?["mcp:admin"]:[],...r]}function H({idPrefix:s,clientName:a,requestedScopes:r,accessLevel:i,onAccessLevelChange:x,sensitiveScopesAcknowledged:v=!1,onSensitiveScopesAcknowledgedChange:g,disabled:b=!1}){const k=I(r),f=r.includes("profile:read"),p=r.includes("device_worker:run"),o=r.includes("connections:token"),j=p||o,c=r.filter(n=>!W.includes(n)&&n!=="profile:read"&&n!=="device_worker:run"&&n!=="connections:token");return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{"aria-labelledby":`${s}-application`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-application`,className:"text-sm font-medium",children:"Application"}),e.jsx("div",{className:"rounded-lg border p-4",children:e.jsx("span",{className:"text-sm font-semibold text-foreground",children:a||"Unnamed application"})})]}),k&&e.jsxs("fieldset",{className:"space-y-2",disabled:b,children:[e.jsx("legend",{className:"text-sm font-medium",children:"Access level"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose the maximum access this application should receive."}),e.jsx("div",{className:"space-y-2",children:P.filter(n=>S[n.value]<=S[k]).map(n=>{const l=`${s}-access-${n.value}`,h=i===n.value;return e.jsxs("label",{htmlFor:l,className:$("flex cursor-pointer items-start gap-3 rounded-md border p-3 transition-colors",h&&"border-primary bg-primary/5"),children:[e.jsx("input",{id:l,type:"radio",name:`${s}-access-level`,value:n.value,checked:h,onChange:()=>x(n.value),className:"mt-1 h-4 w-4 accent-primary"}),e.jsxs("span",{className:"min-w-0 space-y-0.5",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:[n.title,n.risk==="high"&&e.jsx(y,{variant:"destructive",children:"High risk"})]}),e.jsx("span",{className:"block text-sm text-muted-foreground",children:n.description})]})]},n.value)})})]}),f&&e.jsxs("section",{"aria-labelledby":`${s}-profile`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-profile`,className:"text-sm font-medium",children:"Account information"}),e.jsxs("div",{className:"rounded-md border p-3",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:["Basic profile",e.jsx(y,{variant:"secondary",children:"Included"})]}),e.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:"See your basic Lobu identity and the names and slugs of workspaces you belong to."})]})]}),c.length>0&&e.jsxs("section",{"aria-labelledby":`${s}-additional`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-additional`,className:"text-sm font-medium",children:"Additional permissions"}),e.jsx("ul",{className:"space-y-2",children:c.map(n=>e.jsx("li",{className:"rounded-md border p-3 font-mono text-xs text-foreground",children:n},n))})]}),j&&e.jsxs("section",{className:"space-y-3 rounded-md border border-destructive/40 bg-destructive/5 p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Device capabilities"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"These capabilities are fixed by the device request and cannot be reduced here."})]}),e.jsxs("ul",{className:"space-y-2",children:[p&&e.jsxs("li",{className:"rounded-md bg-background/70 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Operate this device"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Run jobs and Automations through capabilities advertised by this device."})]}),o&&e.jsxs("li",{className:"rounded-md bg-background/70 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Use connected services"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Request short-lived access for services you connected to Lobu."})]})]}),e.jsxs("div",{className:"flex items-start gap-3 rounded-md border bg-background p-3",children:[e.jsx(E,{id:`${s}-sensitive-acknowledgement`,checked:v,disabled:b,onCheckedChange:n=>g?.(n===!0),className:"mt-0.5"}),e.jsx("label",{htmlFor:`${s}-sensitive-acknowledgement`,className:"cursor-pointer text-sm font-medium text-foreground",children:"I initiated this request and confirmed that the device code matches."})]})]})]})}function T({idPrefix:s,orgList:a,selectedOrgIds:r,onWorkspaceAccessChange:i,onSelectedOrgChange:x,orgsLoading:v,orgsError:g,onRetry:b,disabled:k=!1,deviceHomeOrgId:f=null,allowMultiple:p}){const o=`${s}-workspace-access-legend`,j=r.length===a.length;return v?e.jsxs("section",{"aria-labelledby":o,className:"space-y-2",children:[e.jsx("p",{id:o,className:"text-sm font-medium",children:"Workspace access"}),e.jsx("p",{role:"status","aria-live":"polite",className:"text-sm text-muted-foreground",children:"Loading your workspaces..."})]}):g?e.jsxs("section",{"aria-labelledby":o,className:"space-y-2",children:[e.jsx("p",{id:o,className:"text-sm font-medium",children:"Workspace access"}),e.jsxs("div",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[e.jsx("p",{children:"Workspaces could not be loaded. Approval is unavailable until they load."}),e.jsx(R,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:b,children:"Retry"})]})]}):a.length===0?e.jsxs("section",{"aria-labelledby":o,className:"space-y-2",children:[e.jsx("p",{id:o,className:"text-sm font-medium",children:"Workspace access"}),e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:"No member workspaces are available for this connection."})]}):e.jsxs("fieldset",{className:"space-y-3",disabled:k,children:[e.jsx("legend",{id:o,className:"sr-only",children:"Workspace access"}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Workspaces"}),e.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:p?"Choose where this application can operate.":"Choose one workspace this application can access."})]}),p&&!j&&e.jsxs(R,{type:"button",variant:"outline",size:"sm",onClick:()=>i("all_current"),children:["Select all ",a.length]})]}),f&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p?"The device workspace is always included. Additional workspaces grant MCP access only.":"MCP access follows the device workspace."}),e.jsx("div",{className:"space-y-2",children:a.map(c=>{const n=`${s}-workspace-${c.id}`,l=c.id===f,h=r.includes(c.id);return e.jsxs("div",{className:$("flex items-start gap-3 rounded-md border p-3 transition-colors",h&&"border-primary/40 bg-primary/5"),children:[e.jsx(E,{id:n,checked:h,disabled:k||l||f!==null&&!p,onCheckedChange:N=>x(c.id,N===!0),className:"mt-0.5"}),e.jsxs("label",{htmlFor:n,className:"min-w-0 flex-1 cursor-pointer space-y-0.5",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:[c.name,c.isPersonal&&e.jsx(y,{variant:"outline",children:"Personal"}),l&&e.jsx(y,{variant:"secondary",children:"Device workspace"})]}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:c.slug})]})]},c.id)})}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-muted-foreground",children:[e.jsxs("p",{"aria-live":"polite",children:[r.length," of ",a.length," workspaces selected."]}),j&&e.jsx(y,{variant:"secondary",children:"All currently available"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Workspaces you join later are not added automatically."}),r.length===0&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"Choose at least one workspace."})]})}function q(s,a){u.useEffect(()=>{if(a||s)return;const r=new URL("/auth/login",window.location.origin);r.searchParams.set("callbackUrl",window.location.href),window.location.href=r.toString()},[s,a])}function F(s,a){return s.length===a.length&&s.every((r,i)=>r===a[i])}function V(s={}){const{requireDeviceHome:a=!1,deviceHomeOrgId:r=null,allowMultiple:i=!0}=s,{data:x,error:v,isPending:g,refetch:b}=z(),[k,f]=u.useState("selected"),[p,o]=u.useState([]),j=u.useRef(!1),c=u.useMemo(()=>x?x.filter(t=>t.is_member).map(t=>({id:t.id,name:t.name,slug:t.slug,isPersonal:t.is_personal===!0})):[],[x]),n=c.find(t=>t.isPersonal)?.id??null,l=a?r&&c.some(t=>t.id===r)?r:n:null,h=u.useRef(c);h.current=c;const N=v instanceof Error?v.message:v?"Unable to load workspaces":null;u.useEffect(()=>{if(g||N)return;const t=c.map(d=>d.id),m=new Set(t);o(d=>{const C=j.current?d.filter(A=>m.has(A)):[n??t[0]].filter(A=>!!A);return j.current=!0,F(d,C)?d:C})},[c,N,g,n]);const L=u.useCallback(t=>{if(t==="all_current"){if(!i)return;o(h.current.map(m=>m.id))}f(t)},[i]),M=u.useCallback((t,m)=>{h.current.some(d=>d.id===t)&&(a&&(t===l||!i)||(f("selected"),o(d=>m?i?d.includes(t)?d:[...d,t]:[t]:d.filter(C=>C!==t))))},[i,l,a]),w=u.useMemo(()=>{if(a&&l&&!i)return[l];const t=new Set(p);return a&&l&&t.add(l),c.filter(m=>t.has(m.id)).map(m=>m.id)},[i,p,l,c,a]),_=u.useCallback(()=>{const t=h.current,m=t.find(d=>d.isPersonal)?.id??t[0]?.id;j.current=t.length>0,f("selected"),o(m?[m]:[])},[]),O=!g&&!N&&c.length>0&&w.length>0&&(i||w.length===1)&&(!a||l!==null&&w.includes(l)),U=u.useCallback(()=>{b()},[b]);return{orgList:c,workspaceAccess:k,setWorkspaceAccess:L,selectedOrgIds:w,toggleSelectedOrgId:M,resetWorkspaceSelection:_,personalOrgId:n,deviceHomeOrgId:l,orgsLoading:g,orgsError:N,retryOrgs:U,workspaceSelectionReady:O}}function K(s){if(!s)return null;try{return new URL(s).pathname.match(/^\/mcp\/([^/]+)$/)?.[1]?.trim()||null}catch{return null}}export{H as A,T as W,I as a,q as b,K as g,D as s,V as u};
2
+ //# sourceMappingURL=oauth-workspace-access-lZNZ9gul.js.map
@@ -1,2 +1,2 @@
1
- import{$ as pe,r as v,bu as Fe,bv as qe,bw as Be,bx as Ke,by as ye,j as e,bz as Z,B as N,bA as Me,aR as Ue,bB as Ve,bC as He,bD as Ye,bE as Ge,bF as Je,bG as Ze,bH as Xe,bI as be,bJ as X,bK as et,bL as tt,bM as st,bN as de,bO as nt,bP as it,o as at,U as Ie,n as ot,bQ as rt,bR as J,k as ct,z as ve,I as je,bS as lt,bT as dt,bU as ut,a2 as Ne,a$ as mt,E as re,bV as pt,bW as Ce,bX as _e,bY as ht,F as gt,bZ as ke,b_ as xt}from"./index-DYCqXaMf.js";import{P as ue,a as De,A as ft}from"./agent-permissions-matrix-gZWl6mAe.js";import{C as Se,a as Ae,b as we,c as ze}from"./card-yU0TmNRH.js";const Oe=["auto","approval","deny"],yt={matched_rule:"Matching policy rules apply.",default_approval:"No rule matches; approval is required.",unresolved_principal:"The requesting agent or Automation could not be identified.",parent_approval:"Approval is inherited from the parent action.",unavailable_operation:"This action is unavailable on the connection."},Le={read:"Reads",write:"Writes",destructive:"Destructive writes",non_destructive:"Non-destructive writes",unknown:"Unclassified writes"};function me(t){return{operation_key:t.operation_key??null,connector_key:t.connector_key??null,connection_id:t.connection_id??null,operation_category:t.operation_category??null}}const ce=t=>JSON.stringify(me(t)),Pe=t=>({...t,effect:t.effects.execute??"approval"});function F({label:t,value:i,onChange:a,children:o,disabled:m}){return e.jsxs("label",{className:"flex min-w-0 flex-col gap-1 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:t}),e.jsx("select",{"aria-label":t,value:i,onChange:d=>a(d.target.value),disabled:m,className:"h-9 w-full rounded-lg border bg-background px-2 text-foreground",children:o})]})}function bt(t,i){const a=i.connections?.find(o=>o.id===t.connection_id);return t.connection_id?`Connection: ${a?.display_name||a?.connector_key||"Unavailable"} (#${t.connection_id})`:t.connector_key?`Connector: ${i.connectors?.find(o=>o.key===t.connector_key)?.name||t.connector_key}`:"All connectors"}function vt(t,i){return t.operation_key?i.connector_operations.find(a=>a.operation_key===t.operation_key)?.name||t.operation_key:t.operation_category?Le[t.operation_category]:"All actions"}function le(t,i){return`${bt(t,i)} · ${vt(t,i)}`}function $e(t){return t.connection_id?`connection:${t.connection_id}`:t.connector_key?`connector:${t.connector_key}`:"all"}function Ee({catalog:t}){return e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"all",children:"All connectors"}),e.jsx("optgroup",{label:"Connectors",children:t.connectors?.map(i=>e.jsx("option",{value:`connector:${i.key}`,children:i.name},i.key))}),e.jsx("optgroup",{label:"Connections",children:t.connections?.map(i=>e.jsxs("option",{value:`connection:${i.id}`,children:[i.display_name||i.connector_key," (#",i.id,")"]},i.id))})]})}function jt({label:t,ariaLabel:i,disabled:a,onRemove:o}){const[m,d]=v.useState(!1);return m?e.jsxs("div",{className:"flex gap-1",children:[e.jsx(N,{type:"button",variant:"destructive",size:"sm",disabled:a,"aria-label":"Confirm removal",onClick:async()=>{await o()&&d(!1)},children:"Confirm"}),e.jsx(N,{type:"button",variant:"ghost",size:"sm",disabled:a,onClick:()=>d(!1),children:"Cancel"})]}):e.jsx(N,{type:"button",variant:"ghost",size:"sm",disabled:a,"aria-label":i,onClick:()=>d(!0),children:t})}function Nt({owner:t,connector:i,connection:a,agent:o}){const m=pe(),[d,j]=v.useState(o??""),S=Fe(t),r=S.data,u=r?.agents.some(s=>s.id===d)?d:"",n=qe(t,u),g=Be(t,!u),[C,W]=v.useState(a?`connection:${a}`:i?`connector:${i}`:"all"),[Y,Q]=v.useState(C),[I,A]=v.useState(!1),[O,q]=v.useState(""),[_,B]=v.useState("all"),[$,K]=v.useState("approval"),[p,D]=v.useState(!1),[M,E]=v.useState(null),[U,ee]=v.useState(a?String(a):""),[T,G]=v.useState(""),P=r?.connections?.some(s=>String(s.id)===U)?U:"",k=Ke(t,P?Number(P):void 0,T,u||void 0);async function V(s,b){D(!0),E(null);try{if(u){const l={resource_class:"connector_action",...me(s)};b?await Ye(t,u,{...l,effects:{execute:b}}):await Ge(t,u,l)||E("This rule was already removed. The list has been refreshed.")}else{const l=g.data;if(!l)return;const L=l.rules.filter(Qe=>ce(Qe)!==ce(s));b&&L.push({...me(s),effect:b});const oe=await Je(t,{revision:l.revision,rules:L});m.setQueryData(Ze(t),oe)}return await Promise.all(["write-permissions","agent-permissions","available-operations","connector-operations","policy-explanation"].map(l=>m.invalidateQueries({queryKey:[l]}))),s}catch(l){l instanceof ye&&l.status===409?(E("Policies changed in another session. Review the refreshed rules before saving again."),await g.refetch()):E(l instanceof Error?l.message:"Could not save policy.")}finally{D(!1)}}const f=S.error||(u?n.error:g.error);if(f instanceof ye&&f.status===403)return e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Only organization owners and admins can manage policies."});if(f)return e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Could not load policies. ",String(f)]});if(!r||(u?!n.data:!g.data))return e.jsx(Z,{label:"policies",rows:2});const c=s=>s==="all"||r.connectors?.some(b=>`connector:${b.key}`===s)||r.connections?.some(b=>`connection:${b.id}`===s)?s:"all",h=c(C),x=c(Y),w=r.connections?.find(s=>`connection:${s.id}`===x),y=w?.connector_key??(x.startsWith("connector:")?x.slice(10):void 0),R=s=>x==="all"||$e(s)==="all"?!0:s.connection_id?w?s.connection_id===w.id:r.connections?.some(b=>b.id===s.connection_id&&b.connector_key===y):s.connector_key===y;function te(s){return u?s.principal_kind==="agent"&&s.principal_id===u:!s.principal_kind}const z=h.startsWith("connector:")?h.slice(10):h.startsWith("connection:")?r.connections?.find(s=>s.id===Number(h.slice(11)))?.connector_key:void 0,H=r.connector_operations.filter(s=>!z||s.connector_key===z),se=r.connections?.find(s=>s.id===Number(P))?.connector_key,ne=r.connector_operations.filter(s=>s.connector_key===se),ie=u?(n.data?.agent??[]).filter(s=>s.resource_class==="connector_action").map(Pe):g.data?.rules??[],ge=(n.data?.floor??[]).filter(s=>s.resource_class==="connector_action"&&R(s)).map(Pe),We={connector_key:h.startsWith("connector:")?h.slice(10):h==="all"&&_==="specific"?H.find(s=>s.operation_key===O)?.connector_key??null:null,connection_id:h.startsWith("connection:")?Number(h.slice(11)):null,operation_key:_==="specific"?O:null,operation_category:_.startsWith("category:")?_.slice(9):null},ae=ie.filter(R);function xe(){W(x),B("all"),q(""),K("approval"),A(!0)}const fe=(s,b=!1)=>e.jsx("div",{className:"divide-y rounded-lg border",children:s.map(l=>{const L=!b&&te(l);return e.jsxs(De,{controls:e.jsxs(e.Fragment,{children:[e.jsx(ue,{options:Oe,value:l.effect,floor:"auto",compact:!0,disabled:p||!L,ariaLabel:`Policy for ${le(l,r)}`,onChange:oe=>void V(l,oe)}),L&&e.jsx(jt,{label:"Remove",disabled:p,ariaLabel:`Remove rule: ${le(l,r)}`,onRemove:()=>V(l)})]}),children:[e.jsx("p",{className:"text-sm break-words",children:le(l,r)}),!L&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.principal_kind==="agent"&&!l.principal_id?"All agents":"Inherited restriction"})]},JSON.stringify([l.principal_kind,l.principal_id,ce(l)]))})});return e.jsxs("div",{className:"space-y-4",children:[(x!==Y||u!==d)&&e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"The requested scope is unavailable. Showing organization rules; install the connector or choose an available scope."}),e.jsxs("div",{className:"space-y-1 text-sm text-muted-foreground",children:[e.jsx("p",{children:"Auto runs immediately. Ask waits for human approval. Block prevents execution and hides the action from agents. Authentication and guardrails still apply."}),e.jsxs("details",{className:"space-y-2",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-foreground",children:"How rules combine"}),e.jsx("p",{children:"A rule overrides another when it is narrower in target or actions and at least as narrow in the other. When rules are narrower in different ways, or use different categories, the stricter choice wins: Block, then Ask, then Auto. With no matching rule, the result is Ask. Impact categories apply only to writes."}),e.jsx("p",{children:"A connection-wide Auto does not override an organization-wide destructive Block. Add a destructive rule for that connection to make an exception."}),e.jsx("p",{children:"Agents and their Automations can only tighten organization policy. Internal browser steps inherit the parent approval; an explicit browser Block still wins."})]})]}),e.jsxs(F,{label:"Policy owner",value:u,onChange:j,disabled:p,children:[e.jsx("option",{value:"",children:"Organization"}),r.agents.map(s=>e.jsxs("option",{value:s.id,children:["Agent: ",s.name]},s.id))]}),u&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Auto adds no restriction for this agent. It inherits organization policy and cannot bypass Ask or Block."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u?"Without a matching restriction, this agent inherits organization policy.":"Without a matching rule, actions require approval (Ask)."}),e.jsx(F,{label:"Show rules for",value:x,onChange:Q,disabled:p,children:e.jsx(Ee,{catalog:r})}),u&&ge.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Inherited organization rules"}),fe(ge,!0)]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:u?"Saved restrictions":"Saved rules"}),!I&&ae.length>0&&e.jsx(N,{variant:"outline",size:"sm",disabled:p,onClick:xe,children:"Add rule"})]}),I&&e.jsxs("form",{className:"space-y-3 border-t pt-4",onSubmit:s=>{s.preventDefault(),!p&&(_!=="specific"||O)&&V(We,$).then(b=>{b&&(A(!1),Q($e(b)))})},children:[e.jsx("h3",{className:"text-sm font-medium",children:"Add rule"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(F,{label:"Applies to",value:h,onChange:s=>{W(s),B("all"),q("")},disabled:p,children:e.jsx(Ee,{catalog:r})}),e.jsxs(F,{label:"Actions",value:_,onChange:B,disabled:p,children:[e.jsx("option",{value:"all",children:"All actions"}),e.jsx("optgroup",{label:"Categories",children:r.operation_categories?.map(s=>e.jsx("option",{value:`category:${s}`,children:Le[s]},s))}),e.jsx("option",{value:"specific",children:"Specific action"})]})]}),_==="specific"&&e.jsxs(F,{label:"Specific action",value:O,onChange:q,disabled:p,children:[e.jsx("option",{value:"",children:"Choose action"}),H.map(s=>e.jsxs("option",{value:s.operation_key,children:[s.connector_name,": ",s.name]},s.operation_key))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx(ue,{options:Oe,value:$,floor:"auto",compact:!0,disabled:p,ariaLabel:"New rule decision",onChange:K}),e.jsx(Me,{onCancel:()=>A(!1),cancelDisabled:p,children:e.jsx(N,{type:"submit",disabled:p||_==="specific"&&!O,children:p?"Saving…":"Save rule"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saving an existing scope replaces its decision. Removing a rule reveals the next matching rule."})]}),ae.length?fe(ae):!I&&e.jsx(Ue,{icon:Ve,title:"No saved rules in this scope",description:"Add a rule for all actions, a category, or a specific action.",actionLabel:"Add rule",onAction:xe})]}),M&&e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:M}),e.jsxs("details",{className:"space-y-3 border-t pt-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"Check an action"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs(F,{label:"Check connection",value:P,onChange:s=>{ee(s),G("")},children:[e.jsx("option",{value:"",children:"Choose connection"}),r.connections?.map(s=>e.jsxs("option",{value:String(s.id),children:[s.display_name||s.connector_key," (#",s.id,")"]},s.id))]}),e.jsxs(F,{label:"Check action",value:T,onChange:G,disabled:!P,children:[e.jsx("option",{value:"",children:"Choose action"}),ne.map(s=>e.jsx("option",{value:s.operation_key.slice(s.connector_key.length+2),children:s.name},s.operation_key))]})]}),k.error?e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Could not check policy. ",String(k.error)]}):e.jsx("p",{"aria-live":"polite",className:"text-sm",children:T?k.isPending?"Checking…":k.data?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:He[k.data.effect]})," ·"," ",yt[k.data.reason]??"The server evaluated this action.",k.data.rule_ids.length>0?` · Rules ${k.data.rule_ids.map(s=>`#${s}`).join(", ")}`:""]}):"":""})]})]})}const Ct=[{action:"create_type",label:"Create entity types",description:"Add a new type and its initial fields."},{action:"update_type",label:"Edit entity types",description:"Change fields, write rules, event kinds, or type metadata."},{action:"delete_type",label:"Delete entity types",description:"Remove an entity-type definition."}],_t=[{action:"create_relationship_type",label:"Create relationship types",description:"Add a new kind of link between entity types."},{action:"update_relationship_type",label:"Edit relationship types",description:"Change a definition, or which types it may connect."},{action:"delete_relationship_type",label:"Delete relationship types",description:"Remove a relationship-type definition."}];function he(t){return t.resource_class==="entity_schema"&&t.principal_kind===null&&t.entity_type_slug===null&&t.operation_key===null&&t.target_agent_id===null}function kt(t){return t.agent.find(he)}function St(t,i){return{...t,agent:[...t.agent.filter(a=>!he(a)),i]}}function At(t){return{...t,agent:t.agent.filter(i=>!he(i))}}function wt({label:t,description:i,action:a,value:o,pending:m,onChange:d}){return e.jsxs(De,{controls:e.jsx(ue,{options:it("entity_schema",a),value:o,floor:"auto",disabled:m,compact:!0,ariaLabel:t,onChange:d}),children:[e.jsx("p",{children:t}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:i})]})}function Te({title:t,actions:i,effects:a,pending:o,onChange:m}){return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:t}),e.jsx("div",{className:"divide-y overflow-hidden rounded-lg border",children:i.map(({action:d,label:j,description:S})=>e.jsx(wt,{action:d,label:j,description:S,value:a[d]??de.entity_schema[d]??"deny",pending:o,onChange:r=>m(d,r)},d))})]})}function zt({owner:t}){const i=pe(),a=Xe(t),o=Fe(t),m=be({mutationFn:n=>et(t,{resource_class:"entity_schema",effects:n}),onSuccess:n=>{i.setQueryData(a,g=>g&&St(g,n)),i.invalidateQueries({queryKey:a})},onError:n=>{X.error(n instanceof Error?n.message:"Failed to save schema policy")}}),d=be({mutationFn:()=>tt(t,{resource_class:"entity_schema"}),onSuccess:()=>{i.setQueryData(a,n=>n&&At(n)),i.invalidateQueries({queryKey:a})},onError:n=>{X.error(n instanceof Error?n.message:"Failed to reset schema policy")}});if(o.isLoading)return e.jsx(Z,{label:"schema policy",variant:"cards",cards:1});if(o.isError||!o.data)return e.jsx(st,{label:"schema policy"});const j=kt(o.data),S=j?.effects??de.entity_schema,r=m.isPending||d.isPending,u=(n,g)=>{m.mutate({...j?.effects??de.entity_schema,[n]:g})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:j?"Custom policy":"Workspace defaults"}),j?e.jsxs(N,{type:"button",variant:"outline",size:"sm",disabled:r,onClick:()=>d.mutate(),children:[e.jsx(nt,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove custom policy"]}):null]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Te,{title:"Entity types",actions:Ct,effects:S,pending:r,onChange:u}),e.jsx(Te,{title:"Relationship types",actions:_t,effects:S,pending:r,onChange:u})]})]})}function Re(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ot(t,i,a){const o=t.split("/");return o[1]===i?(o[1]=a,o.join("/")||"/"):`/${a}`}function Pt({owner:t,connector:i,connection:a,agent:o}){const m=at(),d=pe(),{data:j,error:S}=Ie(),{activeOrg:r,urlOrgSlug:u}=ot(),n=(j??[]).find(c=>c.slug===t&&c.is_member)??null,g=n?.id??t,C=rt(g,{name:n?.name??"",slug:n?.slug??"",visibility:n?.visibility??"private"}),[W,Y]=C.field("name"),[Q,I]=C.field("slug"),[A,O]=C.field("visibility"),[q,_]=J(g,!!n),[B,$]=J(g,!1),[K,p]=J(g,null),[D,M]=v.useState(!1),[E,U]=v.useState(!1),[ee,T]=J(g,!1);if(ct(S)&&j===void 0)return e.jsxs(Se,{role:"alert",children:[e.jsx(Ae,{children:e.jsx(we,{children:"Couldn't load organizations"})}),e.jsx(ze,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Please try again in a moment."})})]});if(j===void 0)return e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsx(Z,{label:"organization",variant:"cards",cards:1}),e.jsx(Z,{label:"visibility",variant:"panel"})]});if(!n)return e.jsxs(Se,{children:[e.jsx(Ae,{children:e.jsx(we,{children:"Organization not found"})}),e.jsx(ze,{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You aren't a member of an organization at"," ",e.jsx("span",{className:"font-mono",children:t}),", or it has been deleted."]})})]});const G=c=>{const h=gt(c);if(h.kind==="cross-host"){window.location.assign(h.href);return}m({to:h.to})},P=c=>{if(c==="public"&&n.visibility!=="public"){$(!0);return}O(c),$(!1)},k=async()=>{if(!C.canSubmit)return;const c=W.trim();if(!c){p("Name is required");return}const h=Q.trim()||Re(c);if(!h){p("Slug is required");return}M(!0),p(null);try{const x=c!==n.name||h!==n.slug,w=A!==n.visibility;let y=n.slug;if(x){const z=await re.update({organizationId:n.id,data:{name:c,slug:h}});if(z.error){p(z.error.message||"Failed to update organization");return}y=z.data?.slug??h}w&&(y=(await pt(y,A)).slug),(x||w)&&(C.accept(C.values,{name:c,slug:y,visibility:A}),await d.invalidateQueries({queryKey:["organizations"]}),X.success("Organization updated"));const R=r?.id===n.id||u===n.slug,te=y!==n.slug;if(R&&te){const z=Ce(),H=_e();if(z===n.slug&&H){const ne=ht(window.location.pathname,n.slug)||"/",ie=`${window.location.protocol}//${y}.${H}${ne}${window.location.search}${window.location.hash}`;window.location.assign(ie);return}const se=Ot(window.location.pathname,n.slug,y);m({to:`${se}${window.location.search}${window.location.hash}`});return}}catch(x){p(x instanceof Error?x.message:"Failed to update organization")}finally{M(!1)}},V=async()=>{U(!0),p(null);try{const c=await re.delete({organizationId:n.id});if(c.error){p(c.error.message||"Failed to delete organization");return}await d.invalidateQueries({queryKey:["organizations"]}),X.success("Organization deleted");const x=(j??[]).filter(y=>y.is_member).find(y=>y.id!==n.id)??null,w=r?.id===n.id||u===n.slug;if(w&&x){await re.setActive({organizationId:x.id}),G(x.slug);return}if(w){const y=Ce(),R=_e();if(y===n.slug&&R){window.location.assign(`${window.location.protocol}//app.${R}/`);return}m({to:"/"});return}m({to:"/"})}catch(c){p(c instanceof Error?c.message:"Failed to delete organization")}finally{U(!1),T(!1)}},f=D||E;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Identity"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"org-name",children:"Name"}),e.jsx(je,{id:"org-name",value:W,onChange:c=>{Y(c.target.value),q||I(Re(c.target.value))},placeholder:"e.g. My Team",disabled:f})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"org-slug",children:"Slug"}),e.jsx(je,{id:"org-slug",value:Q,onChange:c=>{_(!0),I(c.target.value)},placeholder:"e.g. my-team",disabled:f}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Changing the slug rewrites this workspace's URL. Existing links to"," ",e.jsxs("span",{className:"font-mono",children:["/",n.slug]})," redirect for a grace period."]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Workspace visibility"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Choose who can browse this workspace and its public pages."})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("button",{type:"button",onClick:()=>P("private"),disabled:f,className:`flex items-start gap-3 rounded-lg border p-3 text-left transition-colors ${A==="private"?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[e.jsx(lt,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Private"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only members can access this workspace."})]})]}),e.jsxs("button",{type:"button",onClick:()=>P("public"),disabled:f,className:`flex items-start gap-3 rounded-lg border p-3 text-left transition-colors ${A==="public"?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[e.jsx(dt,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Public"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Anyone can browse public pages for this workspace."})]})]})]}),B&&e.jsxs("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm",children:[e.jsx("p",{className:"text-foreground",children:"Make this workspace public? Catalog-style content may become visible outside the membership."}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(N,{type:"button",size:"sm",onClick:()=>{O("public"),$(!1)},disabled:f,children:"Confirm public"}),e.jsx(N,{type:"button",size:"sm",variant:"ghost",onClick:()=>$(!1),disabled:f,children:"Cancel"})]})]})]}),K&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:K}),e.jsx(ut,{visible:C.hasConflict,onReload:C.reset}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{variant:"outline",onClick:()=>void m({to:`/${t}`}),disabled:f,children:"Cancel"}),e.jsxs(N,{onClick:k,disabled:f||!C.canSubmit,children:[D?e.jsx(Ne,{size:"lg",className:"mr-1.5"}):null,D?"Saving...":"Save changes"]})]}),e.jsxs("section",{id:"policies",className:"scroll-mt-6 space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Policies"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Control connector actions across the organization. Changes to existing rules save automatically."})]}),e.jsx(Nt,{owner:t,connector:i,connection:a,agent:o},`${t}:${o??""}:${i??""}:${a??""}`)]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Agent write defaults"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the defaults agents inherit for entities and agents. Changes save automatically; agents can only tighten them."})]}),e.jsx(ft,{owner:t,variant:"org-floor"})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Schema governance"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Control structural changes by agents and connected AI clients. Changes save automatically."})]}),e.jsx(zt,{owner:t})]}),e.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:n.is_personal?"Personal workspace":"Delete this organization"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n.is_personal?"Your personal workspace can't be deleted — your devices and personal connections are bound to it.":"Permanently removes the organization and all members' workspace access. This cannot be undone."}),!n.is_personal&&e.jsx("div",{className:"mt-3",children:ee?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(N,{variant:"destructive",size:"sm",onClick:V,disabled:f,children:[E?e.jsx(Ne,{className:"mr-1.5"}):null,"Confirm delete"]}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>T(!1),disabled:f,children:"Cancel"})]}):e.jsxs(N,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>T(!0),disabled:f,children:[e.jsx(mt,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete organization"]})})]})]})}function Rt(){const{owner:t}=ke.useParams(),i=ke.useSearch(),{data:a}=Ie(),o=(a??[]).find(m=>m.slug===t&&m.is_member)?.name;return e.jsxs("div",{className:"mx-auto flex w-full max-w-4xl flex-1 flex-col gap-6 px-4 pt-2.5 pb-8 lg:px-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xt,{className:"h-7 w-7"}),e.jsx("h1",{className:"text-3xl font-semibold leading-tight",children:"Organization settings"})]}),o?e.jsx("p",{className:"text-base font-medium text-foreground",children:o}):null]}),e.jsx(Pt,{owner:t,...i})]})}export{Rt as component};
2
- //# sourceMappingURL=organization-DTFoYP4V.js.map
1
+ import{$ as pe,r as v,bu as Fe,bv as qe,bw as Be,bx as Ke,by as ye,j as e,bz as Z,B as N,bA as Me,aR as Ue,bB as Ve,bC as He,bD as Ye,bE as Ge,bF as Je,bG as Ze,bH as Xe,bI as be,bJ as X,bK as et,bL as tt,bM as st,bN as de,bO as nt,bP as it,o as at,U as Ie,n as ot,bQ as rt,bR as J,k as ct,z as ve,I as je,bS as lt,bT as dt,bU as ut,a2 as Ne,a$ as mt,E as re,bV as pt,bW as Ce,bX as _e,bY as ht,F as gt,bZ as ke,b_ as xt}from"./index-9YuSRymd.js";import{P as ue,a as De,A as ft}from"./agent-permissions-matrix-BkZu1LYE.js";import{C as Se,a as Ae,b as we,c as ze}from"./card-jzhQrMDP.js";const Oe=["auto","approval","deny"],yt={matched_rule:"Matching policy rules apply.",default_approval:"No rule matches; approval is required.",unresolved_principal:"The requesting agent or Automation could not be identified.",parent_approval:"Approval is inherited from the parent action.",unavailable_operation:"This action is unavailable on the connection."},Le={read:"Reads",write:"Writes",destructive:"Destructive writes",non_destructive:"Non-destructive writes",unknown:"Unclassified writes"};function me(t){return{operation_key:t.operation_key??null,connector_key:t.connector_key??null,connection_id:t.connection_id??null,operation_category:t.operation_category??null}}const ce=t=>JSON.stringify(me(t)),Pe=t=>({...t,effect:t.effects.execute??"approval"});function F({label:t,value:i,onChange:a,children:o,disabled:m}){return e.jsxs("label",{className:"flex min-w-0 flex-col gap-1 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:t}),e.jsx("select",{"aria-label":t,value:i,onChange:d=>a(d.target.value),disabled:m,className:"h-9 w-full rounded-lg border bg-background px-2 text-foreground",children:o})]})}function bt(t,i){const a=i.connections?.find(o=>o.id===t.connection_id);return t.connection_id?`Connection: ${a?.display_name||a?.connector_key||"Unavailable"} (#${t.connection_id})`:t.connector_key?`Connector: ${i.connectors?.find(o=>o.key===t.connector_key)?.name||t.connector_key}`:"All connectors"}function vt(t,i){return t.operation_key?i.connector_operations.find(a=>a.operation_key===t.operation_key)?.name||t.operation_key:t.operation_category?Le[t.operation_category]:"All actions"}function le(t,i){return`${bt(t,i)} · ${vt(t,i)}`}function $e(t){return t.connection_id?`connection:${t.connection_id}`:t.connector_key?`connector:${t.connector_key}`:"all"}function Ee({catalog:t}){return e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"all",children:"All connectors"}),e.jsx("optgroup",{label:"Connectors",children:t.connectors?.map(i=>e.jsx("option",{value:`connector:${i.key}`,children:i.name},i.key))}),e.jsx("optgroup",{label:"Connections",children:t.connections?.map(i=>e.jsxs("option",{value:`connection:${i.id}`,children:[i.display_name||i.connector_key," (#",i.id,")"]},i.id))})]})}function jt({label:t,ariaLabel:i,disabled:a,onRemove:o}){const[m,d]=v.useState(!1);return m?e.jsxs("div",{className:"flex gap-1",children:[e.jsx(N,{type:"button",variant:"destructive",size:"sm",disabled:a,"aria-label":"Confirm removal",onClick:async()=>{await o()&&d(!1)},children:"Confirm"}),e.jsx(N,{type:"button",variant:"ghost",size:"sm",disabled:a,onClick:()=>d(!1),children:"Cancel"})]}):e.jsx(N,{type:"button",variant:"ghost",size:"sm",disabled:a,"aria-label":i,onClick:()=>d(!0),children:t})}function Nt({owner:t,connector:i,connection:a,agent:o}){const m=pe(),[d,j]=v.useState(o??""),S=Fe(t),r=S.data,u=r?.agents.some(s=>s.id===d)?d:"",n=qe(t,u),g=Be(t,!u),[C,W]=v.useState(a?`connection:${a}`:i?`connector:${i}`:"all"),[Y,Q]=v.useState(C),[I,A]=v.useState(!1),[O,q]=v.useState(""),[_,B]=v.useState("all"),[$,K]=v.useState("approval"),[p,D]=v.useState(!1),[M,E]=v.useState(null),[U,ee]=v.useState(a?String(a):""),[T,G]=v.useState(""),P=r?.connections?.some(s=>String(s.id)===U)?U:"",k=Ke(t,P?Number(P):void 0,T,u||void 0);async function V(s,b){D(!0),E(null);try{if(u){const l={resource_class:"connector_action",...me(s)};b?await Ye(t,u,{...l,effects:{execute:b}}):await Ge(t,u,l)||E("This rule was already removed. The list has been refreshed.")}else{const l=g.data;if(!l)return;const L=l.rules.filter(Qe=>ce(Qe)!==ce(s));b&&L.push({...me(s),effect:b});const oe=await Je(t,{revision:l.revision,rules:L});m.setQueryData(Ze(t),oe)}return await Promise.all(["write-permissions","agent-permissions","available-operations","connector-operations","policy-explanation"].map(l=>m.invalidateQueries({queryKey:[l]}))),s}catch(l){l instanceof ye&&l.status===409?(E("Policies changed in another session. Review the refreshed rules before saving again."),await g.refetch()):E(l instanceof Error?l.message:"Could not save policy.")}finally{D(!1)}}const f=S.error||(u?n.error:g.error);if(f instanceof ye&&f.status===403)return e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Only organization owners and admins can manage policies."});if(f)return e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Could not load policies. ",String(f)]});if(!r||(u?!n.data:!g.data))return e.jsx(Z,{label:"policies",rows:2});const c=s=>s==="all"||r.connectors?.some(b=>`connector:${b.key}`===s)||r.connections?.some(b=>`connection:${b.id}`===s)?s:"all",h=c(C),x=c(Y),w=r.connections?.find(s=>`connection:${s.id}`===x),y=w?.connector_key??(x.startsWith("connector:")?x.slice(10):void 0),R=s=>x==="all"||$e(s)==="all"?!0:s.connection_id?w?s.connection_id===w.id:r.connections?.some(b=>b.id===s.connection_id&&b.connector_key===y):s.connector_key===y;function te(s){return u?s.principal_kind==="agent"&&s.principal_id===u:!s.principal_kind}const z=h.startsWith("connector:")?h.slice(10):h.startsWith("connection:")?r.connections?.find(s=>s.id===Number(h.slice(11)))?.connector_key:void 0,H=r.connector_operations.filter(s=>!z||s.connector_key===z),se=r.connections?.find(s=>s.id===Number(P))?.connector_key,ne=r.connector_operations.filter(s=>s.connector_key===se),ie=u?(n.data?.agent??[]).filter(s=>s.resource_class==="connector_action").map(Pe):g.data?.rules??[],ge=(n.data?.floor??[]).filter(s=>s.resource_class==="connector_action"&&R(s)).map(Pe),We={connector_key:h.startsWith("connector:")?h.slice(10):h==="all"&&_==="specific"?H.find(s=>s.operation_key===O)?.connector_key??null:null,connection_id:h.startsWith("connection:")?Number(h.slice(11)):null,operation_key:_==="specific"?O:null,operation_category:_.startsWith("category:")?_.slice(9):null},ae=ie.filter(R);function xe(){W(x),B("all"),q(""),K("approval"),A(!0)}const fe=(s,b=!1)=>e.jsx("div",{className:"divide-y rounded-lg border",children:s.map(l=>{const L=!b&&te(l);return e.jsxs(De,{controls:e.jsxs(e.Fragment,{children:[e.jsx(ue,{options:Oe,value:l.effect,floor:"auto",compact:!0,disabled:p||!L,ariaLabel:`Policy for ${le(l,r)}`,onChange:oe=>void V(l,oe)}),L&&e.jsx(jt,{label:"Remove",disabled:p,ariaLabel:`Remove rule: ${le(l,r)}`,onRemove:()=>V(l)})]}),children:[e.jsx("p",{className:"text-sm break-words",children:le(l,r)}),!L&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.principal_kind==="agent"&&!l.principal_id?"All agents":"Inherited restriction"})]},JSON.stringify([l.principal_kind,l.principal_id,ce(l)]))})});return e.jsxs("div",{className:"space-y-4",children:[(x!==Y||u!==d)&&e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"The requested scope is unavailable. Showing organization rules; install the connector or choose an available scope."}),e.jsxs("div",{className:"space-y-1 text-sm text-muted-foreground",children:[e.jsx("p",{children:"Auto runs immediately. Ask waits for human approval. Block prevents execution and hides the action from agents. Authentication and guardrails still apply."}),e.jsxs("details",{className:"space-y-2",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-foreground",children:"How rules combine"}),e.jsx("p",{children:"A rule overrides another when it is narrower in target or actions and at least as narrow in the other. When rules are narrower in different ways, or use different categories, the stricter choice wins: Block, then Ask, then Auto. With no matching rule, the result is Ask. Impact categories apply only to writes."}),e.jsx("p",{children:"A connection-wide Auto does not override an organization-wide destructive Block. Add a destructive rule for that connection to make an exception."}),e.jsx("p",{children:"Agents and their Automations can only tighten organization policy. Internal browser steps inherit the parent approval; an explicit browser Block still wins."})]})]}),e.jsxs(F,{label:"Policy owner",value:u,onChange:j,disabled:p,children:[e.jsx("option",{value:"",children:"Organization"}),r.agents.map(s=>e.jsxs("option",{value:s.id,children:["Agent: ",s.name]},s.id))]}),u&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Auto adds no restriction for this agent. It inherits organization policy and cannot bypass Ask or Block."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u?"Without a matching restriction, this agent inherits organization policy.":"Without a matching rule, actions require approval (Ask)."}),e.jsx(F,{label:"Show rules for",value:x,onChange:Q,disabled:p,children:e.jsx(Ee,{catalog:r})}),u&&ge.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Inherited organization rules"}),fe(ge,!0)]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:u?"Saved restrictions":"Saved rules"}),!I&&ae.length>0&&e.jsx(N,{variant:"outline",size:"sm",disabled:p,onClick:xe,children:"Add rule"})]}),I&&e.jsxs("form",{className:"space-y-3 border-t pt-4",onSubmit:s=>{s.preventDefault(),!p&&(_!=="specific"||O)&&V(We,$).then(b=>{b&&(A(!1),Q($e(b)))})},children:[e.jsx("h3",{className:"text-sm font-medium",children:"Add rule"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(F,{label:"Applies to",value:h,onChange:s=>{W(s),B("all"),q("")},disabled:p,children:e.jsx(Ee,{catalog:r})}),e.jsxs(F,{label:"Actions",value:_,onChange:B,disabled:p,children:[e.jsx("option",{value:"all",children:"All actions"}),e.jsx("optgroup",{label:"Categories",children:r.operation_categories?.map(s=>e.jsx("option",{value:`category:${s}`,children:Le[s]},s))}),e.jsx("option",{value:"specific",children:"Specific action"})]})]}),_==="specific"&&e.jsxs(F,{label:"Specific action",value:O,onChange:q,disabled:p,children:[e.jsx("option",{value:"",children:"Choose action"}),H.map(s=>e.jsxs("option",{value:s.operation_key,children:[s.connector_name,": ",s.name]},s.operation_key))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx(ue,{options:Oe,value:$,floor:"auto",compact:!0,disabled:p,ariaLabel:"New rule decision",onChange:K}),e.jsx(Me,{onCancel:()=>A(!1),cancelDisabled:p,children:e.jsx(N,{type:"submit",disabled:p||_==="specific"&&!O,children:p?"Saving…":"Save rule"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saving an existing scope replaces its decision. Removing a rule reveals the next matching rule."})]}),ae.length?fe(ae):!I&&e.jsx(Ue,{icon:Ve,title:"No saved rules in this scope",description:"Add a rule for all actions, a category, or a specific action.",actionLabel:"Add rule",onAction:xe})]}),M&&e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:M}),e.jsxs("details",{className:"space-y-3 border-t pt-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"Check an action"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs(F,{label:"Check connection",value:P,onChange:s=>{ee(s),G("")},children:[e.jsx("option",{value:"",children:"Choose connection"}),r.connections?.map(s=>e.jsxs("option",{value:String(s.id),children:[s.display_name||s.connector_key," (#",s.id,")"]},s.id))]}),e.jsxs(F,{label:"Check action",value:T,onChange:G,disabled:!P,children:[e.jsx("option",{value:"",children:"Choose action"}),ne.map(s=>e.jsx("option",{value:s.operation_key.slice(s.connector_key.length+2),children:s.name},s.operation_key))]})]}),k.error?e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Could not check policy. ",String(k.error)]}):e.jsx("p",{"aria-live":"polite",className:"text-sm",children:T?k.isPending?"Checking…":k.data?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:He[k.data.effect]})," ·"," ",yt[k.data.reason]??"The server evaluated this action.",k.data.rule_ids.length>0?` · Rules ${k.data.rule_ids.map(s=>`#${s}`).join(", ")}`:""]}):"":""})]})]})}const Ct=[{action:"create_type",label:"Create entity types",description:"Add a new type and its initial fields."},{action:"update_type",label:"Edit entity types",description:"Change fields, write rules, event kinds, or type metadata."},{action:"delete_type",label:"Delete entity types",description:"Remove an entity-type definition."}],_t=[{action:"create_relationship_type",label:"Create relationship types",description:"Add a new kind of link between entity types."},{action:"update_relationship_type",label:"Edit relationship types",description:"Change a definition, or which types it may connect."},{action:"delete_relationship_type",label:"Delete relationship types",description:"Remove a relationship-type definition."}];function he(t){return t.resource_class==="entity_schema"&&t.principal_kind===null&&t.entity_type_slug===null&&t.operation_key===null&&t.target_agent_id===null}function kt(t){return t.agent.find(he)}function St(t,i){return{...t,agent:[...t.agent.filter(a=>!he(a)),i]}}function At(t){return{...t,agent:t.agent.filter(i=>!he(i))}}function wt({label:t,description:i,action:a,value:o,pending:m,onChange:d}){return e.jsxs(De,{controls:e.jsx(ue,{options:it("entity_schema",a),value:o,floor:"auto",disabled:m,compact:!0,ariaLabel:t,onChange:d}),children:[e.jsx("p",{children:t}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:i})]})}function Te({title:t,actions:i,effects:a,pending:o,onChange:m}){return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:t}),e.jsx("div",{className:"divide-y overflow-hidden rounded-lg border",children:i.map(({action:d,label:j,description:S})=>e.jsx(wt,{action:d,label:j,description:S,value:a[d]??de.entity_schema[d]??"deny",pending:o,onChange:r=>m(d,r)},d))})]})}function zt({owner:t}){const i=pe(),a=Xe(t),o=Fe(t),m=be({mutationFn:n=>et(t,{resource_class:"entity_schema",effects:n}),onSuccess:n=>{i.setQueryData(a,g=>g&&St(g,n)),i.invalidateQueries({queryKey:a})},onError:n=>{X.error(n instanceof Error?n.message:"Failed to save schema policy")}}),d=be({mutationFn:()=>tt(t,{resource_class:"entity_schema"}),onSuccess:()=>{i.setQueryData(a,n=>n&&At(n)),i.invalidateQueries({queryKey:a})},onError:n=>{X.error(n instanceof Error?n.message:"Failed to reset schema policy")}});if(o.isLoading)return e.jsx(Z,{label:"schema policy",variant:"cards",cards:1});if(o.isError||!o.data)return e.jsx(st,{label:"schema policy"});const j=kt(o.data),S=j?.effects??de.entity_schema,r=m.isPending||d.isPending,u=(n,g)=>{m.mutate({...j?.effects??de.entity_schema,[n]:g})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:j?"Custom policy":"Workspace defaults"}),j?e.jsxs(N,{type:"button",variant:"outline",size:"sm",disabled:r,onClick:()=>d.mutate(),children:[e.jsx(nt,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove custom policy"]}):null]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Te,{title:"Entity types",actions:Ct,effects:S,pending:r,onChange:u}),e.jsx(Te,{title:"Relationship types",actions:_t,effects:S,pending:r,onChange:u})]})]})}function Re(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ot(t,i,a){const o=t.split("/");return o[1]===i?(o[1]=a,o.join("/")||"/"):`/${a}`}function Pt({owner:t,connector:i,connection:a,agent:o}){const m=at(),d=pe(),{data:j,error:S}=Ie(),{activeOrg:r,urlOrgSlug:u}=ot(),n=(j??[]).find(c=>c.slug===t&&c.is_member)??null,g=n?.id??t,C=rt(g,{name:n?.name??"",slug:n?.slug??"",visibility:n?.visibility??"private"}),[W,Y]=C.field("name"),[Q,I]=C.field("slug"),[A,O]=C.field("visibility"),[q,_]=J(g,!!n),[B,$]=J(g,!1),[K,p]=J(g,null),[D,M]=v.useState(!1),[E,U]=v.useState(!1),[ee,T]=J(g,!1);if(ct(S)&&j===void 0)return e.jsxs(Se,{role:"alert",children:[e.jsx(Ae,{children:e.jsx(we,{children:"Couldn't load organizations"})}),e.jsx(ze,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Please try again in a moment."})})]});if(j===void 0)return e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsx(Z,{label:"organization",variant:"cards",cards:1}),e.jsx(Z,{label:"visibility",variant:"panel"})]});if(!n)return e.jsxs(Se,{children:[e.jsx(Ae,{children:e.jsx(we,{children:"Organization not found"})}),e.jsx(ze,{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You aren't a member of an organization at"," ",e.jsx("span",{className:"font-mono",children:t}),", or it has been deleted."]})})]});const G=c=>{const h=gt(c);if(h.kind==="cross-host"){window.location.assign(h.href);return}m({to:h.to})},P=c=>{if(c==="public"&&n.visibility!=="public"){$(!0);return}O(c),$(!1)},k=async()=>{if(!C.canSubmit)return;const c=W.trim();if(!c){p("Name is required");return}const h=Q.trim()||Re(c);if(!h){p("Slug is required");return}M(!0),p(null);try{const x=c!==n.name||h!==n.slug,w=A!==n.visibility;let y=n.slug;if(x){const z=await re.update({organizationId:n.id,data:{name:c,slug:h}});if(z.error){p(z.error.message||"Failed to update organization");return}y=z.data?.slug??h}w&&(y=(await pt(y,A)).slug),(x||w)&&(C.accept(C.values,{name:c,slug:y,visibility:A}),await d.invalidateQueries({queryKey:["organizations"]}),X.success("Organization updated"));const R=r?.id===n.id||u===n.slug,te=y!==n.slug;if(R&&te){const z=Ce(),H=_e();if(z===n.slug&&H){const ne=ht(window.location.pathname,n.slug)||"/",ie=`${window.location.protocol}//${y}.${H}${ne}${window.location.search}${window.location.hash}`;window.location.assign(ie);return}const se=Ot(window.location.pathname,n.slug,y);m({to:`${se}${window.location.search}${window.location.hash}`});return}}catch(x){p(x instanceof Error?x.message:"Failed to update organization")}finally{M(!1)}},V=async()=>{U(!0),p(null);try{const c=await re.delete({organizationId:n.id});if(c.error){p(c.error.message||"Failed to delete organization");return}await d.invalidateQueries({queryKey:["organizations"]}),X.success("Organization deleted");const x=(j??[]).filter(y=>y.is_member).find(y=>y.id!==n.id)??null,w=r?.id===n.id||u===n.slug;if(w&&x){await re.setActive({organizationId:x.id}),G(x.slug);return}if(w){const y=Ce(),R=_e();if(y===n.slug&&R){window.location.assign(`${window.location.protocol}//app.${R}/`);return}m({to:"/"});return}m({to:"/"})}catch(c){p(c instanceof Error?c.message:"Failed to delete organization")}finally{U(!1),T(!1)}},f=D||E;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Identity"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"org-name",children:"Name"}),e.jsx(je,{id:"org-name",value:W,onChange:c=>{Y(c.target.value),q||I(Re(c.target.value))},placeholder:"e.g. My Team",disabled:f})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"org-slug",children:"Slug"}),e.jsx(je,{id:"org-slug",value:Q,onChange:c=>{_(!0),I(c.target.value)},placeholder:"e.g. my-team",disabled:f}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Changing the slug rewrites this workspace's URL. Existing links to"," ",e.jsxs("span",{className:"font-mono",children:["/",n.slug]})," redirect for a grace period."]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Workspace visibility"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Choose who can browse this workspace and its public pages."})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("button",{type:"button",onClick:()=>P("private"),disabled:f,className:`flex items-start gap-3 rounded-lg border p-3 text-left transition-colors ${A==="private"?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[e.jsx(lt,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Private"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only members can access this workspace."})]})]}),e.jsxs("button",{type:"button",onClick:()=>P("public"),disabled:f,className:`flex items-start gap-3 rounded-lg border p-3 text-left transition-colors ${A==="public"?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[e.jsx(dt,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Public"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Anyone can browse public pages for this workspace."})]})]})]}),B&&e.jsxs("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm",children:[e.jsx("p",{className:"text-foreground",children:"Make this workspace public? Catalog-style content may become visible outside the membership."}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(N,{type:"button",size:"sm",onClick:()=>{O("public"),$(!1)},disabled:f,children:"Confirm public"}),e.jsx(N,{type:"button",size:"sm",variant:"ghost",onClick:()=>$(!1),disabled:f,children:"Cancel"})]})]})]}),K&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:K}),e.jsx(ut,{visible:C.hasConflict,onReload:C.reset}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{variant:"outline",onClick:()=>void m({to:`/${t}`}),disabled:f,children:"Cancel"}),e.jsxs(N,{onClick:k,disabled:f||!C.canSubmit,children:[D?e.jsx(Ne,{size:"lg",className:"mr-1.5"}):null,D?"Saving...":"Save changes"]})]}),e.jsxs("section",{id:"policies",className:"scroll-mt-6 space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Policies"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Control connector actions across the organization. Changes to existing rules save automatically."})]}),e.jsx(Nt,{owner:t,connector:i,connection:a,agent:o},`${t}:${o??""}:${i??""}:${a??""}`)]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Agent write defaults"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the defaults agents inherit for entities and agents. Changes save automatically; agents can only tighten them."})]}),e.jsx(ft,{owner:t,variant:"org-floor"})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Schema governance"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Control structural changes by agents and connected AI clients. Changes save automatically."})]}),e.jsx(zt,{owner:t})]}),e.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:n.is_personal?"Personal workspace":"Delete this organization"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n.is_personal?"Your personal workspace can't be deleted — your devices and personal connections are bound to it.":"Permanently removes the organization and all members' workspace access. This cannot be undone."}),!n.is_personal&&e.jsx("div",{className:"mt-3",children:ee?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(N,{variant:"destructive",size:"sm",onClick:V,disabled:f,children:[E?e.jsx(Ne,{className:"mr-1.5"}):null,"Confirm delete"]}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>T(!1),disabled:f,children:"Cancel"})]}):e.jsxs(N,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>T(!0),disabled:f,children:[e.jsx(mt,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete organization"]})})]})]})}function Rt(){const{owner:t}=ke.useParams(),i=ke.useSearch(),{data:a}=Ie(),o=(a??[]).find(m=>m.slug===t&&m.is_member)?.name;return e.jsxs("div",{className:"mx-auto flex w-full max-w-4xl flex-1 flex-col gap-6 px-4 pt-2.5 pb-8 lg:px-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xt,{className:"h-7 w-7"}),e.jsx("h1",{className:"text-3xl font-semibold leading-tight",children:"Organization settings"})]}),o?e.jsx("p",{className:"text-base font-medium text-foreground",children:o}):null]}),e.jsx(Pt,{owner:t,...i})]})}export{Rt as component};
2
+ //# sourceMappingURL=organization-Cb0W823y.js.map
@@ -1,2 +1,2 @@
1
- import{j3 as z,j4 as M,r as h,h3 as B,u as L,j as t,di as F,av as K,d7 as H,S as g,iv as V,B as j,j5 as U,j6 as N,j7 as q,j8 as C,j9 as R,ja as G,cP as W,h as S,ao as $,cs as T,a2 as I,ai as Q,jb as Z,g as J,jc as X,f as Y,dV as ee,jd as te,bd as se,je as ne,e3 as re,cz as oe,jf as ie,e7 as ae,b9 as ce}from"./index-DYCqXaMf.js";import{u as de,A as le}from"./automation-detail-content-BMLL4lxO.js";import{A as ue}from"./agent-loading-shells-De_2d8Lr.js";import{s as pe,h as me,R as xe,A as he}from"./agent-thread-Buz3naVF.js";import{C as fe,b as ge,A as je}from"./connection-feed-detail-DWM9lTao.js";import{f as ye}from"./connector-scope-lists-OYDOydtz.js";import{a as ve}from"./connections-browser-CEwYrYqt.js";import{S as Ne}from"./source-record-panels-Cg249m1S.js";import{E as O,L as we,l as ke,d as be}from"./events-feed-DsrkV2ix.js";import{E as Ae}from"./event-detail-D4YZRtrA.js";import{R as Ce}from"./record-field-peek-BBZcRuGT.js";import{a as Se}from"./view-param-filters-DMSqkN2J.js";import"./create-automation-form-9T5WnoUs.js";import"./cronstrue-BWFEyy_P.js";import"./entity-options-DHdMC1Lx.js";import"./connection-label-BobuYiAG.js";import"./model-selector-TQcA93xm.js";import"./skill-editor-D_W3QlRz.js";import"./code-editor-U54Gwjit.js";import"./index-CDz3-ieP.js";import"./index-Vcq4gwWv.js";import"./use-mention-search-BYbFvHbJ.js";import"./proposal-review-shell-DsNiavG_.js";import"./json-diff-DFvYINBT.js";import"./deployments-wG_8QzOF.js";import"./app-bridge-BCm4muqj.js";import"./runs-table-D_8QlCCN.js";import"./conversations-table-BSznfdYt.js";import"./clients-L4K1UT8c.js";import"./schema-value-normalization-CylKX3PK.js";import"./card-yU0TmNRH.js";import"./record-session-BizRugWs.js";import"./filter-editors-B1_QUpg_.js";const E=Symbol("trusted-automation-interaction");function Ie(e){return Object.defineProperty(e,E,{value:!0}),e}function Pe(e){return{title:`${e} items waiting for you`,icon:"entity",impact:{level:"normal"},tone:"default",blocks:[{type:"text",value:"Review the individual proposals below, or decide the whole run at once.",muted:!0}],actions:[{id:"approve-all",label:"Approve all",variant:"primary",icon:"check",confirm:!0,confirmPrompt:`Approve all ${e} proposals?`,tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved all ${e} proposals.`},{id:"reject-all",label:"Reject all",variant:"outline",icon:"x",confirm:!0,confirmPrompt:`Reject all ${e} proposals?`,tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected all ${e} proposals.`}]}}const _e=new Set(["automation-approval-batch"]);function Le(e){return new Promise(s=>{e({onSettled:(o,n)=>s(!!n)})})}function Re(){const e=z(),s=M();return h.useMemo(()=>({toolNames:_e,resolve:(o,n)=>{if(!n||typeof n!="object"||n[E]!==!0)return null;const r=n;if(o==="automation-approval-batch"){const i=typeof r.runId=="number"&&Number.isSafeInteger(r.runId)&&r.runId>0?r.runId:null,a=typeof r.count=="number"&&Number.isSafeInteger(r.count)&&r.count>1?r.count:null,c=Array.isArray(r.runIds)?r.runIds.filter(d=>typeof d=="number"&&Number.isSafeInteger(d)&&d>0):[];return i===null||a===null||c.length!==a||new Set(c).size!==a?null:{view:Pe(a),handlers:{manage_operations:d=>d.action!=="approve"&&d.action!=="reject"?Promise.resolve(!0):Le(p=>d.action==="approve"?e.mutate({run_id:i,run_ids:c},p):s.mutate({run_id:i,run_ids:c},p))}}}return null}}),[e,s])}function $e(e){const s=[];return e.forEach((o,n)=>{s.push({id:`sep:${o.runId}`,role:"system",parts:[{type:"text",text:Te(o,n)}],createdAt:o.completedAt?new Date(o.completedAt).getTime():void 0});for(const r of o.messages)s.push({...r,id:`r${o.runId}:${r.id}`})}),s}function Te(e,s){const o=(e.pendingActionCount??0)>0?`Waiting for you (${e.pendingActionCount})`:e.status==="completed"?"Completed":e.status??"Completed",n=(e.autoAppliedCount??0)>0?` · ${e.autoAppliedCount} applied automatically`:"",r=e.completedAt?new Date(e.completedAt).toLocaleString():null;return r?`Run ${s+1} · ${o}${n} · ${r}`:`Run ${s+1} · ${o}${n}`}const Oe=/(?:^|\n)Run this Automation now/;function Ee(e){return e.role==="user"&&e.parts.some(s=>s.type==="text"&&Oe.test(s.text))}function De(e){return`history-interaction:${e.runId}:${e.eventId??"error"}`}function ze({agentId:e,automationId:s,ownerSlug:o,runId:n}){const{data:r,isLoading:i}=B(e,s,{orgSlug:o,...n!=null?{runId:n}:{}}),a=Re(),c=L(),d=h.useCallback(l=>{c?.open({href:`/${o}/automations/${s}?run_id=${l}`,title:`Automation run #${l}`,runId:l})},[c,o,s]),p=h.useMemo(()=>{const l=r?.runs??[],y=(n!=null?l.filter(u=>u.runId===n):l).slice().reverse();return $e(y.map(u=>{const x=u.messages.map(m=>pe(m,{showToolCalls:!0})).filter(m=>m!==null&&!Ee(m));u.task?.trim()&&x.unshift({id:"task",role:"user",parts:[{type:"text",text:u.task.trim()}]});const v=u.actions??[],k=v.filter(m=>m.status==="pending");if(k.length>1){const m=k.map(f=>f.runId).sort((f,D)=>f-D);x.push({id:"approval-batch",role:"assistant",parts:[{type:"tool-call",toolCallId:`approval-batch-${u.runId}`,toolName:"automation-approval-batch",args:Ie({runId:u.runId,count:k.length,runIds:m})}]})}for(const m of v){const f=me([m],{workspaceSlug:o,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin});f&&x.push({...f,id:De(m)})}return{runId:u.runId,completedAt:u.completedAt,status:u.status,pendingActionCount:u.pendingActionCount,autoAppliedCount:u.autoAppliedCount,messages:x}}))},[e,r,o,n]);return i?t.jsx(ue,{readOnly:!0}):p.length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No run transcripts yet. Recent runs will show here when the Automation fires (failed runs appear with their prompt even without a full transcript)."}):t.jsx("div",{className:"flex h-[calc(100dvh-12rem)] min-h-[24rem] min-w-0 flex-1 flex-col",children:t.jsx(xe,{messages:p,workspaceSlug:o,children:t.jsx(he,{readOnly:!0,readerPositionMode:"runs",interactionExtension:a,onRunSelect:n==null&&c?d:void 0})})})}function Me(e){if(!e||typeof e!="object")return[];const s=e.properties;if(!s)return[];const o=Array.isArray(e.required)?new Set(e.required.map(String)):new Set;return Object.entries(s).map(([n,r])=>({name:n,type:String(r.type??"any"),required:o.has(n),description:typeof r.description=="string"?r.description:void 0}))}function Be({fields:e}){return e.length===0?t.jsx("p",{className:"text-xs text-muted-foreground",children:"No fields."}):t.jsx("ul",{className:"space-y-2",children:e.map(s=>t.jsxs("li",{className:"space-y-0.5",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2",children:[t.jsx("code",{className:"text-xs font-medium text-foreground",children:s.name}),t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/70",children:s.type}),s.required?t.jsx("span",{className:"text-[10px] font-medium text-amber-600 dark:text-amber-400",children:"required"}):null]}),s.description?t.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}):null]},s.name))})}function w({item:e,hideHeading:s=!1}){const o=e.schemaSections;return o?t.jsxs("article",{className:s?"space-y-4":"space-y-4 px-5 py-5",children:[!s&&t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(F,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),t.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[t.jsx("h2",{className:"text-base font-medium text-foreground",children:e.title}),o.description?t.jsx("p",{className:"text-xs text-muted-foreground",children:o.description}):null]})]}),o.sections.map(n=>{const r=Me(n.schema);return t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:n.title}),n.description?t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:n.description}):null]}),t.jsx(Be,{fields:r})]},n.title)})]}):null}function Fe({panel:e}){const s=K(e.organizationId),o=e.section==="connections"||!!e.connectionId,n=H(e.organizationId,{connectorKey:e.connectorKey,connectionIds:e.connectionId?[e.connectionId]:void 0,enabled:o}),r=s.data?.find(a=>a.key===e.connectorKey),i=n.data?.find(a=>a.id===e.connectionId&&a.connector_key===e.connectorKey);return s.isLoading||o&&n.isLoading?t.jsx("div",{className:"p-5",children:t.jsx(g,{className:"h-28 w-full"})}):s.isError||o&&n.isError?t.jsx("p",{role:"alert",className:"p-5 text-sm",children:"Could not load this connector. Close the pane and try again."}):e.connectionId&&!i||!r&&!i&&e.section!=="connections"?t.jsx("p",{className:"p-5 text-sm",children:"This connection is no longer available."}):t.jsx("div",{className:"p-5",children:e.section==="connections"?t.jsx(ve,{connections:n.data??[],connector:r,connectorKey:e.connectorKey,ownerSlug:e.ownerSlug}):i?t.jsx(Ve,{connection:i,connector:r,panel:e}):r?e.section==="feeds"?t.jsx(Ke,{connector:r}):r.installed===!1?t.jsx(He,{connector:r,ownerSlug:e.ownerSlug}):t.jsx(qe,{connector:r,ownerSlug:e.ownerSlug}):null},`${e.connectorKey}:${e.connectionId??"connector"}:${e.section}`)}function Ke({connector:e}){const s=Object.entries(e.feeds_schema??{}).map(([o,n])=>{const r=n;return{id:o,name:r.name??o,description:r.description,feed:r}});return t.jsx(N,{entries:s,label:"feed types",renderDetail:({name:o,feed:n})=>t.jsx(w,{item:{href:"",title:o,schemaSections:q(n)},hideHeading:!0})})}function He({connector:e,ownerSlug:s}){const o=Object.entries(e.actions_schema??{}).map(([n,r])=>{const i=r;return{id:n,name:i.name??n,description:i.description,action:i}});return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Policy depends on connection."," ",t.jsx(C,{ownerSlug:s,connectorKey:e.key})]}),t.jsx(N,{entries:o,label:"actions",renderDetail:({name:n,action:r})=>t.jsx(w,{hideHeading:!0,item:{href:"",title:n,schemaSections:R(r)}})})]})}function Ve({connection:e,connector:s,panel:o}){const[n,r]=h.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsx("div",{hidden:n,children:o.section==="feeds"?t.jsx(Ue,{connection:e,connector:s,ownerSlug:o.ownerSlug}):t.jsx(V,{connection:e,ownerSlug:o.ownerSlug,inPeek:!0,onReviewPermissions:s?()=>r(!0):void 0})}),n&&s&&t.jsxs("div",{className:"space-y-4",children:[t.jsx(j,{variant:"ghost",size:"sm",onClick:()=>r(!1),children:"Back to actions"}),t.jsx("h2",{className:"text-base font-semibold",children:"Provider permissions"}),t.jsx(U,{connection:e,connectorDef:s})]})]})}function Ue({connection:e,connector:s,ownerSlug:o}){const{data:n=[],isLoading:r,isError:i}=W(e.id),[a,c]=h.useState(!1),d=e.facets?.chat??!1;if(r)return t.jsx(g,{className:"h-28 w-full"});if(i)return t.jsx("p",{role:"alert",children:"Could not load sources. Close the pane and try again."});const p=n.map(l=>({id:String(l.id),name:l.display_name||l.feed_key,status:ye(l)??(l.operations.includes("sync")?"Sync enabled":"Live access"),feed:l}));return t.jsxs(t.Fragment,{children:[t.jsx("div",{hidden:a,children:t.jsx(N,{entries:p,label:d?"channels":"feeds",action:Object.keys(s?.feeds_schema??{}).length>0?t.jsx(j,{size:"sm",variant:"outline",onClick:()=>c(!0),children:d?"Add channel":"Add feed"}):void 0,renderDetail:({feed:l})=>l.store==="channel_messages"?t.jsx(fe,{feed:l,hideHeader:!0}):t.jsx(ge,{feed:l,connectorDef:s,ownerSlug:o})})}),a&&s&&t.jsxs("div",{className:"space-y-4",children:[t.jsx("h2",{className:"text-base font-semibold",children:d?"Add channel":"Add feed"}),t.jsx(je,{organizationId:e.organization_id,connections:[e],connectorDefinitions:[s],onClose:()=>c(!1)})]})]})}function qe({connector:e,ownerSlug:s}){const{data:o=[],isLoading:n,isError:r}=G(e.key);if(n)return t.jsx(g,{className:"h-28 w-full"});if(r)return t.jsx("p",{role:"alert",children:"Could not load actions. Close the pane and try again."});const i=e.actions_schema??{},a=o.map(c=>({id:c.operation_key,name:c.name??c.operation_key,description:c.description,operation:c}));return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Policy depends on connection. Click an action to inspect its inputs."," ",t.jsx(C,{ownerSlug:s,connectorKey:e.key})]}),t.jsx(N,{entries:a,label:"actions",renderControl:()=>t.jsx(C,{ownerSlug:s,connectorKey:e.key}),renderDetail:({operation:c,name:d})=>i[c.operation_key]?t.jsx(w,{hideHeading:!0,item:{href:"",title:d,schemaSections:R(i[c.operation_key])}}):t.jsx("p",{className:"text-sm text-muted-foreground",children:"No input fields."})})]})}function Ge({owner:e,path:s}){const{data:o,isLoading:n}=S(e,{slug:e}),r=o?.workspace,i=r?.type==="organization"?r.id:null,a=i?{slug:e}:void 0,{data:c,isLoading:d}=$(`/${e}/${T(s)}`,a),p=c?.entity,l=p?.id;return n||d?t.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[t.jsx(I,{className:"mr-2"})," Loading…"]}):i?l==null?t.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't find this record. It may have been deleted, or it may live in a workspace you can't access."}):p?.is_derived?t.jsx(Ne,{record:{type:p.entity_type,key:p.slug},orgContext:a}):t.jsx("div",{className:"px-4 py-4",children:t.jsx(O,{organizationId:i,ownerSlug:e,entityId:l,filters:{sortBy:"date",sortOrder:"desc"},emptyState:t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing has happened to this record yet."})})}):t.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."})}function We({owner:e,eventId:s,viewKey:o}){const n=L(),r=(i,a)=>t.jsx(Ae,{owner:a,organizationId:i,eventId:s,viewKey:o,dense:!0,onSelectView:n?c=>n.retarget(c):void 0},`${a}/${s}/${o??""}`);return t.jsx("div",{className:"px-4 py-4",children:e==="me"?r(null,e):t.jsx(Q,{owner:e,children:({organizationId:i,ownerSlug:a})=>i?r(i,a):t.jsx("div",{className:"h-40 animate-pulse rounded-md bg-muted/40"})})})}function b({owner:e,runId:s,runIds:o,contentIds:n}){const{data:r,isLoading:i}=S(e==="me"?null:e,{slug:e}),a=r?.workspace,c=e!=="me"&&a?.type==="organization"?a.id:null,d=h.useMemo(()=>{if(e==="me")return n?.length?{contentIds:n,sortBy:"date",sortOrder:"desc"}:void 0;const l=o??(s!=null?[s]:void 0);if(!(!l?.length&&!n?.length))return{...l?.length?{runIds:l}:{},...n?.length?{contentIds:n}:{}}},[e,n,s,o]),p=d!=null;return e!=="me"&&i?t.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[t.jsx(I,{className:"mr-2"})," Loading…"]}):e!=="me"&&c==null?t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."}):p?t.jsx("div",{className:"px-4 py-4",children:t.jsx(O,{presentation:"detail",organizationId:c,ownerSlug:e,filters:d,emptyState:t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"No matching events yet."})})}):t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing to preview."})}const A=25;function Qe({target:e}){const[s,o]=h.useState(0),{data:n,isLoading:r,isError:i,refetch:a}=Z(e.entityId,e.orgContext,{relationshipType:e.relationshipType,limit:A,offset:s}),c=n?.total??0;return t.jsxs("div",{className:"space-y-3 px-5 py-4",children:[t.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.label," · ",e.entityName,n?` · ${c} current ${c===1?"link":"links"}`:""]}),r?t.jsxs("div",{className:"space-y-2",children:[t.jsx(g,{className:"h-6 w-full"}),t.jsx(g,{className:"h-6 w-full"})]}):i||!n?t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Could not load these links."," ",t.jsx("button",{type:"button",className:"underline",onClick:()=>void a(),children:"Retry"})]}):n.rows.length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No links on this page."}):t.jsx("ul",{className:"divide-y divide-border",children:n.rows.map(d=>t.jsxs("li",{className:"flex items-center justify-between gap-3 py-1.5",children:[t.jsx(we,{row:d,entityId:e.entityId,ownerSlug:e.ownerSlug,orgContext:e.orgContext}),t.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ke(d,e.entityId).type})]},d.id))}),n&&(s>0||n.hasMore)?t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(j,{type:"button",variant:"outline",size:"sm",disabled:s===0,onClick:()=>o(Math.max(0,s-A)),children:"Previous"}),t.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground",children:[s+1,"–",s+n.rows.length," of ",c]}),t.jsx(j,{type:"button",variant:"outline",size:"sm",disabled:!n.hasMore,onClick:()=>o(s+A),children:"Next"})]}):null]})}function Ze({owner:e,path:s,viewKey:o}){const[n,r]=h.useState({}),{data:i,isLoading:a}=S(e,{slug:e}),c=i?.workspace,d=c?.type==="organization"?c.id:null,p=d?{slug:e,organizationId:d}:void 0,{data:l,isLoading:P}=$(`/${e}/${T(s)}`,p),y=J(p??{slug:e}),u=l?.entity;if(a||P||y.isLoading)return t.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[t.jsx(I,{className:"mr-2"})," Loading…"]});const x=u?X(y.data??[],{type:u.entity_type,id:u.id}).find(v=>v.key===o):void 0;return!d||!u||!x?t.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"This view isn't attached to this record any more."}):t.jsx("div",{className:"px-4 py-4",children:t.jsx(Se,{orgSlug:e,viewKey:x.key,scope:{type:u.entity_type,entity:u.is_derived?u.slug:u.id},params:n,onParamsChange:r,contentHash:x.content_hash,title:x.name,minHeight:320})})}function Rt({item:e}){if(e.connectorPanel)return t.jsx(Fe,{panel:e.connectorPanel});if(e.schemaSections)return t.jsx(w,{item:e});if(e.recordField)return t.jsx(Ce,{target:e.recordField});if(e.recordPeer)return t.jsx(be,{target:e.recordPeer});if(e.recordLinks)return t.jsx(Qe,{target:e.recordLinks});if(typeof e.browserUrl=="string"&&e.browserUrl.length>0)return t.jsx(_,{item:e});const s=e.href?Y(e.href):null;return s?s.kind==="memory"?"runId"in s?t.jsx(b,{owner:s.owner,runId:s.runId}):"runIds"in s?t.jsx(b,{owner:s.owner,runIds:s.runIds}):t.jsx(b,{owner:s.owner,contentIds:s.contentIds}):s.kind==="entity"?t.jsx(Ge,{owner:s.owner,path:s.path}):s.kind==="record-view"?t.jsx(Ze,{owner:s.owner,path:s.path,viewKey:s.viewKey}):s.kind==="event"?t.jsx(We,{owner:s.owner,eventId:s.eventId,viewKey:s.viewKey}):e.runId?t.jsx(Je,{owner:s.owner,automationId:s.automationId,runId:e.runId}):t.jsx(Xe,{owner:s.owner,automationId:s.automationId,initialView:s.view??"activity",runId:s.runId}):t.jsx(_,{item:e})}function _({item:e}){const s=e.body,o=e.notificationType??"generic",n=e.createdAt,r=e.browserUrl??null,i=e.browserHandoff??null;return t.jsxs("article",{className:"space-y-4 px-5 py-5",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(ee,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-0.5 text-xs text-muted-foreground",children:[t.jsx("span",{children:te(o)}),n?t.jsx("span",{children:se(n)}):null]})]}),s?t.jsx("div",{className:"text-sm leading-6 text-foreground/90",children:t.jsx(ne,{text:s,linkPolicy:o==="action_approval_needed"?"app-links":"strip"})}):t.jsx("p",{className:"text-sm text-muted-foreground",children:"No additional details were provided."}),e.owner&&e.sourceAttribution?t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground/80",children:"Generated from"}),t.jsx(re,{owner:e.owner,source:e.sourceAttribution,className:"text-xs"})]}):null,r?t.jsx("div",{className:"space-y-2",children:i?.state==="expired"?t.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:i.error_message??"This draft expired before the page was opened."}):i?.state==="completed"||i?.state==="preparing"?t.jsx("p",{className:"text-sm text-muted-foreground",children:i.state==="preparing"?"Preparing draft — keep your browser tab open.":"Draft prepared — review and post in your browser."}):t.jsxs(j,{type:"button",size:"sm",className:"h-8 text-sm",onClick:()=>{ie(r)},children:[t.jsx(oe,{className:"mr-1.5 h-3.5 w-3.5"}),"Open post"]})}):null]})}function Je({owner:e,automationId:s,runId:o}){const{organizationId:n}=de(e),r=ae(s,void 0,n),i=r.data?.automation?.managed_agent_id??null;return i?t.jsx(ze,{agentId:i,automationId:s,ownerSlug:e,runId:o}):r.isLoading?t.jsx(g,{className:"h-24 w-full rounded-lg"}):t.jsx("p",{className:"text-sm text-muted-foreground",children:"This run has no agent transcript."})}function Xe({owner:e,automationId:s,initialView:o,runId:n}){const[r,i]=h.useState(o),a=r==="definition";return t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"flex justify-end",children:t.jsx(j,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1.5 text-muted-foreground hover:text-foreground",onClick:()=>i(a?"activity":"definition"),children:a?"Done":t.jsxs(t.Fragment,{children:[t.jsx(ce,{className:"h-3.5 w-3.5"}),"Edit"]})})}),t.jsx(le,{owner:e,agentId:null,automationId:s,view:r,runId:n,onDone:()=>i("activity")})]})}export{Rt as PeekPaneContent};
2
- //# sourceMappingURL=peek-pane-content-DF5iGC3c.js.map
1
+ import{j3 as z,j4 as M,r as h,h3 as B,u as L,j as t,di as F,av as K,d7 as H,S as g,iv as V,B as j,j5 as U,j6 as N,j7 as q,j8 as C,j9 as R,ja as G,cP as W,h as S,ao as $,cs as T,a2 as I,ai as Q,jb as Z,g as J,jc as X,f as Y,dV as ee,jd as te,bd as se,je as ne,e3 as re,cz as oe,jf as ie,e7 as ae,b9 as ce}from"./index-9YuSRymd.js";import{u as de,A as le}from"./automation-detail-content-DSwbRpbx.js";import{A as ue}from"./agent-loading-shells-B7v6Cffw.js";import{s as pe,h as me,R as xe,A as he}from"./agent-thread-D38STyeu.js";import{C as fe,b as ge,A as je}from"./connection-feed-detail-WcGCA6qY.js";import{f as ye}from"./connector-scope-lists-CRFEpSvk.js";import{a as ve}from"./connections-browser-CrtnAs0Q.js";import{S as Ne}from"./source-record-panels-BdfOVPWn.js";import{E as O,L as we,l as ke,d as be}from"./events-feed-DO3IiJO2.js";import{E as Ae}from"./event-detail-DV_zfWnC.js";import{R as Ce}from"./record-field-peek-Brh1IQGy.js";import{a as Se}from"./view-param-filters-B0quibBi.js";import"./create-automation-form-Bpy92SM5.js";import"./cronstrue-CWImw-kf.js";import"./entity-options-Clz_WXK-.js";import"./connection-label-BobuYiAG.js";import"./model-selector-CDrAjH31.js";import"./skill-editor-D_W3QlRz.js";import"./code-editor-CEqoCky-.js";import"./index-CDz3-ieP.js";import"./index-Vcq4gwWv.js";import"./use-mention-search-Dcunv4L0.js";import"./proposal-review-shell-CFhOqCLf.js";import"./json-diff-DIN5Jhfx.js";import"./deployments-C5hvipQh.js";import"./app-bridge-BCm4muqj.js";import"./runs-table-B1APZv7d.js";import"./conversations-table-D_HOe1jN.js";import"./clients-BhNl1tVq.js";import"./schema-value-normalization-CKdPjdPC.js";import"./card-jzhQrMDP.js";import"./record-session-Pbr5czGw.js";import"./filter-editors-Bwhqj7lY.js";const E=Symbol("trusted-automation-interaction");function Ie(e){return Object.defineProperty(e,E,{value:!0}),e}function Pe(e){return{title:`${e} items waiting for you`,icon:"entity",impact:{level:"normal"},tone:"default",blocks:[{type:"text",value:"Review the individual proposals below, or decide the whole run at once.",muted:!0}],actions:[{id:"approve-all",label:"Approve all",variant:"primary",icon:"check",confirm:!0,confirmPrompt:`Approve all ${e} proposals?`,tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved all ${e} proposals.`},{id:"reject-all",label:"Reject all",variant:"outline",icon:"x",confirm:!0,confirmPrompt:`Reject all ${e} proposals?`,tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected all ${e} proposals.`}]}}const _e=new Set(["automation-approval-batch"]);function Le(e){return new Promise(s=>{e({onSettled:(o,n)=>s(!!n)})})}function Re(){const e=z(),s=M();return h.useMemo(()=>({toolNames:_e,resolve:(o,n)=>{if(!n||typeof n!="object"||n[E]!==!0)return null;const r=n;if(o==="automation-approval-batch"){const i=typeof r.runId=="number"&&Number.isSafeInteger(r.runId)&&r.runId>0?r.runId:null,a=typeof r.count=="number"&&Number.isSafeInteger(r.count)&&r.count>1?r.count:null,c=Array.isArray(r.runIds)?r.runIds.filter(d=>typeof d=="number"&&Number.isSafeInteger(d)&&d>0):[];return i===null||a===null||c.length!==a||new Set(c).size!==a?null:{view:Pe(a),handlers:{manage_operations:d=>d.action!=="approve"&&d.action!=="reject"?Promise.resolve(!0):Le(p=>d.action==="approve"?e.mutate({run_id:i,run_ids:c},p):s.mutate({run_id:i,run_ids:c},p))}}}return null}}),[e,s])}function $e(e){const s=[];return e.forEach((o,n)=>{s.push({id:`sep:${o.runId}`,role:"system",parts:[{type:"text",text:Te(o,n)}],createdAt:o.completedAt?new Date(o.completedAt).getTime():void 0});for(const r of o.messages)s.push({...r,id:`r${o.runId}:${r.id}`})}),s}function Te(e,s){const o=(e.pendingActionCount??0)>0?`Waiting for you (${e.pendingActionCount})`:e.status==="completed"?"Completed":e.status??"Completed",n=(e.autoAppliedCount??0)>0?` · ${e.autoAppliedCount} applied automatically`:"",r=e.completedAt?new Date(e.completedAt).toLocaleString():null;return r?`Run ${s+1} · ${o}${n} · ${r}`:`Run ${s+1} · ${o}${n}`}const Oe=/(?:^|\n)Run this Automation now/;function Ee(e){return e.role==="user"&&e.parts.some(s=>s.type==="text"&&Oe.test(s.text))}function De(e){return`history-interaction:${e.runId}:${e.eventId??"error"}`}function ze({agentId:e,automationId:s,ownerSlug:o,runId:n}){const{data:r,isLoading:i}=B(e,s,{orgSlug:o,...n!=null?{runId:n}:{}}),a=Re(),c=L(),d=h.useCallback(l=>{c?.open({href:`/${o}/automations/${s}?run_id=${l}`,title:`Automation run #${l}`,runId:l})},[c,o,s]),p=h.useMemo(()=>{const l=r?.runs??[],y=(n!=null?l.filter(u=>u.runId===n):l).slice().reverse();return $e(y.map(u=>{const x=u.messages.map(m=>pe(m,{showToolCalls:!0})).filter(m=>m!==null&&!Ee(m));u.task?.trim()&&x.unshift({id:"task",role:"user",parts:[{type:"text",text:u.task.trim()}]});const v=u.actions??[],k=v.filter(m=>m.status==="pending");if(k.length>1){const m=k.map(f=>f.runId).sort((f,D)=>f-D);x.push({id:"approval-batch",role:"assistant",parts:[{type:"tool-call",toolCallId:`approval-batch-${u.runId}`,toolName:"automation-approval-batch",args:Ie({runId:u.runId,count:k.length,runIds:m})}]})}for(const m of v){const f=me([m],{workspaceSlug:o,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin});f&&x.push({...f,id:De(m)})}return{runId:u.runId,completedAt:u.completedAt,status:u.status,pendingActionCount:u.pendingActionCount,autoAppliedCount:u.autoAppliedCount,messages:x}}))},[e,r,o,n]);return i?t.jsx(ue,{readOnly:!0}):p.length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No run transcripts yet. Recent runs will show here when the Automation fires (failed runs appear with their prompt even without a full transcript)."}):t.jsx("div",{className:"flex h-[calc(100dvh-12rem)] min-h-[24rem] min-w-0 flex-1 flex-col",children:t.jsx(xe,{messages:p,workspaceSlug:o,children:t.jsx(he,{readOnly:!0,readerPositionMode:"runs",interactionExtension:a,onRunSelect:n==null&&c?d:void 0})})})}function Me(e){if(!e||typeof e!="object")return[];const s=e.properties;if(!s)return[];const o=Array.isArray(e.required)?new Set(e.required.map(String)):new Set;return Object.entries(s).map(([n,r])=>({name:n,type:String(r.type??"any"),required:o.has(n),description:typeof r.description=="string"?r.description:void 0}))}function Be({fields:e}){return e.length===0?t.jsx("p",{className:"text-xs text-muted-foreground",children:"No fields."}):t.jsx("ul",{className:"space-y-2",children:e.map(s=>t.jsxs("li",{className:"space-y-0.5",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2",children:[t.jsx("code",{className:"text-xs font-medium text-foreground",children:s.name}),t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/70",children:s.type}),s.required?t.jsx("span",{className:"text-[10px] font-medium text-amber-600 dark:text-amber-400",children:"required"}):null]}),s.description?t.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}):null]},s.name))})}function w({item:e,hideHeading:s=!1}){const o=e.schemaSections;return o?t.jsxs("article",{className:s?"space-y-4":"space-y-4 px-5 py-5",children:[!s&&t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(F,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),t.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[t.jsx("h2",{className:"text-base font-medium text-foreground",children:e.title}),o.description?t.jsx("p",{className:"text-xs text-muted-foreground",children:o.description}):null]})]}),o.sections.map(n=>{const r=Me(n.schema);return t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:n.title}),n.description?t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:n.description}):null]}),t.jsx(Be,{fields:r})]},n.title)})]}):null}function Fe({panel:e}){const s=K(e.organizationId),o=e.section==="connections"||!!e.connectionId,n=H(e.organizationId,{connectorKey:e.connectorKey,connectionIds:e.connectionId?[e.connectionId]:void 0,enabled:o}),r=s.data?.find(a=>a.key===e.connectorKey),i=n.data?.find(a=>a.id===e.connectionId&&a.connector_key===e.connectorKey);return s.isLoading||o&&n.isLoading?t.jsx("div",{className:"p-5",children:t.jsx(g,{className:"h-28 w-full"})}):s.isError||o&&n.isError?t.jsx("p",{role:"alert",className:"p-5 text-sm",children:"Could not load this connector. Close the pane and try again."}):e.connectionId&&!i||!r&&!i&&e.section!=="connections"?t.jsx("p",{className:"p-5 text-sm",children:"This connection is no longer available."}):t.jsx("div",{className:"p-5",children:e.section==="connections"?t.jsx(ve,{connections:n.data??[],connector:r,connectorKey:e.connectorKey,ownerSlug:e.ownerSlug}):i?t.jsx(Ve,{connection:i,connector:r,panel:e}):r?e.section==="feeds"?t.jsx(Ke,{connector:r}):r.installed===!1?t.jsx(He,{connector:r,ownerSlug:e.ownerSlug}):t.jsx(qe,{connector:r,ownerSlug:e.ownerSlug}):null},`${e.connectorKey}:${e.connectionId??"connector"}:${e.section}`)}function Ke({connector:e}){const s=Object.entries(e.feeds_schema??{}).map(([o,n])=>{const r=n;return{id:o,name:r.name??o,description:r.description,feed:r}});return t.jsx(N,{entries:s,label:"feed types",renderDetail:({name:o,feed:n})=>t.jsx(w,{item:{href:"",title:o,schemaSections:q(n)},hideHeading:!0})})}function He({connector:e,ownerSlug:s}){const o=Object.entries(e.actions_schema??{}).map(([n,r])=>{const i=r;return{id:n,name:i.name??n,description:i.description,action:i}});return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Policy depends on connection."," ",t.jsx(C,{ownerSlug:s,connectorKey:e.key})]}),t.jsx(N,{entries:o,label:"actions",renderDetail:({name:n,action:r})=>t.jsx(w,{hideHeading:!0,item:{href:"",title:n,schemaSections:R(r)}})})]})}function Ve({connection:e,connector:s,panel:o}){const[n,r]=h.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsx("div",{hidden:n,children:o.section==="feeds"?t.jsx(Ue,{connection:e,connector:s,ownerSlug:o.ownerSlug}):t.jsx(V,{connection:e,ownerSlug:o.ownerSlug,inPeek:!0,onReviewPermissions:s?()=>r(!0):void 0})}),n&&s&&t.jsxs("div",{className:"space-y-4",children:[t.jsx(j,{variant:"ghost",size:"sm",onClick:()=>r(!1),children:"Back to actions"}),t.jsx("h2",{className:"text-base font-semibold",children:"Provider permissions"}),t.jsx(U,{connection:e,connectorDef:s})]})]})}function Ue({connection:e,connector:s,ownerSlug:o}){const{data:n=[],isLoading:r,isError:i}=W(e.id),[a,c]=h.useState(!1),d=e.facets?.chat??!1;if(r)return t.jsx(g,{className:"h-28 w-full"});if(i)return t.jsx("p",{role:"alert",children:"Could not load sources. Close the pane and try again."});const p=n.map(l=>({id:String(l.id),name:l.display_name||l.feed_key,status:ye(l)??(l.operations.includes("sync")?"Sync enabled":"Live access"),feed:l}));return t.jsxs(t.Fragment,{children:[t.jsx("div",{hidden:a,children:t.jsx(N,{entries:p,label:d?"channels":"feeds",action:Object.keys(s?.feeds_schema??{}).length>0?t.jsx(j,{size:"sm",variant:"outline",onClick:()=>c(!0),children:d?"Add channel":"Add feed"}):void 0,renderDetail:({feed:l})=>l.store==="channel_messages"?t.jsx(fe,{feed:l,hideHeader:!0}):t.jsx(ge,{feed:l,connectorDef:s,ownerSlug:o})})}),a&&s&&t.jsxs("div",{className:"space-y-4",children:[t.jsx("h2",{className:"text-base font-semibold",children:d?"Add channel":"Add feed"}),t.jsx(je,{organizationId:e.organization_id,connections:[e],connectorDefinitions:[s],onClose:()=>c(!1)})]})]})}function qe({connector:e,ownerSlug:s}){const{data:o=[],isLoading:n,isError:r}=G(e.key);if(n)return t.jsx(g,{className:"h-28 w-full"});if(r)return t.jsx("p",{role:"alert",children:"Could not load actions. Close the pane and try again."});const i=e.actions_schema??{},a=o.map(c=>({id:c.operation_key,name:c.name??c.operation_key,description:c.description,operation:c}));return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Policy depends on connection. Click an action to inspect its inputs."," ",t.jsx(C,{ownerSlug:s,connectorKey:e.key})]}),t.jsx(N,{entries:a,label:"actions",renderControl:()=>t.jsx(C,{ownerSlug:s,connectorKey:e.key}),renderDetail:({operation:c,name:d})=>i[c.operation_key]?t.jsx(w,{hideHeading:!0,item:{href:"",title:d,schemaSections:R(i[c.operation_key])}}):t.jsx("p",{className:"text-sm text-muted-foreground",children:"No input fields."})})]})}function Ge({owner:e,path:s}){const{data:o,isLoading:n}=S(e,{slug:e}),r=o?.workspace,i=r?.type==="organization"?r.id:null,a=i?{slug:e}:void 0,{data:c,isLoading:d}=$(`/${e}/${T(s)}`,a),p=c?.entity,l=p?.id;return n||d?t.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[t.jsx(I,{className:"mr-2"})," Loading…"]}):i?l==null?t.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't find this record. It may have been deleted, or it may live in a workspace you can't access."}):p?.is_derived?t.jsx(Ne,{record:{type:p.entity_type,key:p.slug},orgContext:a}):t.jsx("div",{className:"px-4 py-4",children:t.jsx(O,{organizationId:i,ownerSlug:e,entityId:l,filters:{sortBy:"date",sortOrder:"desc"},emptyState:t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing has happened to this record yet."})})}):t.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."})}function We({owner:e,eventId:s,viewKey:o}){const n=L(),r=(i,a)=>t.jsx(Ae,{owner:a,organizationId:i,eventId:s,viewKey:o,dense:!0,onSelectView:n?c=>n.retarget(c):void 0},`${a}/${s}/${o??""}`);return t.jsx("div",{className:"px-4 py-4",children:e==="me"?r(null,e):t.jsx(Q,{owner:e,children:({organizationId:i,ownerSlug:a})=>i?r(i,a):t.jsx("div",{className:"h-40 animate-pulse rounded-md bg-muted/40"})})})}function b({owner:e,runId:s,runIds:o,contentIds:n}){const{data:r,isLoading:i}=S(e==="me"?null:e,{slug:e}),a=r?.workspace,c=e!=="me"&&a?.type==="organization"?a.id:null,d=h.useMemo(()=>{if(e==="me")return n?.length?{contentIds:n,sortBy:"date",sortOrder:"desc"}:void 0;const l=o??(s!=null?[s]:void 0);if(!(!l?.length&&!n?.length))return{...l?.length?{runIds:l}:{},...n?.length?{contentIds:n}:{}}},[e,n,s,o]),p=d!=null;return e!=="me"&&i?t.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[t.jsx(I,{className:"mr-2"})," Loading…"]}):e!=="me"&&c==null?t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."}):p?t.jsx("div",{className:"px-4 py-4",children:t.jsx(O,{presentation:"detail",organizationId:c,ownerSlug:e,filters:d,emptyState:t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"No matching events yet."})})}):t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing to preview."})}const A=25;function Qe({target:e}){const[s,o]=h.useState(0),{data:n,isLoading:r,isError:i,refetch:a}=Z(e.entityId,e.orgContext,{relationshipType:e.relationshipType,limit:A,offset:s}),c=n?.total??0;return t.jsxs("div",{className:"space-y-3 px-5 py-4",children:[t.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.label," · ",e.entityName,n?` · ${c} current ${c===1?"link":"links"}`:""]}),r?t.jsxs("div",{className:"space-y-2",children:[t.jsx(g,{className:"h-6 w-full"}),t.jsx(g,{className:"h-6 w-full"})]}):i||!n?t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Could not load these links."," ",t.jsx("button",{type:"button",className:"underline",onClick:()=>void a(),children:"Retry"})]}):n.rows.length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No links on this page."}):t.jsx("ul",{className:"divide-y divide-border",children:n.rows.map(d=>t.jsxs("li",{className:"flex items-center justify-between gap-3 py-1.5",children:[t.jsx(we,{row:d,entityId:e.entityId,ownerSlug:e.ownerSlug,orgContext:e.orgContext}),t.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ke(d,e.entityId).type})]},d.id))}),n&&(s>0||n.hasMore)?t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(j,{type:"button",variant:"outline",size:"sm",disabled:s===0,onClick:()=>o(Math.max(0,s-A)),children:"Previous"}),t.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground",children:[s+1,"–",s+n.rows.length," of ",c]}),t.jsx(j,{type:"button",variant:"outline",size:"sm",disabled:!n.hasMore,onClick:()=>o(s+A),children:"Next"})]}):null]})}function Ze({owner:e,path:s,viewKey:o}){const[n,r]=h.useState({}),{data:i,isLoading:a}=S(e,{slug:e}),c=i?.workspace,d=c?.type==="organization"?c.id:null,p=d?{slug:e,organizationId:d}:void 0,{data:l,isLoading:P}=$(`/${e}/${T(s)}`,p),y=J(p??{slug:e}),u=l?.entity;if(a||P||y.isLoading)return t.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[t.jsx(I,{className:"mr-2"})," Loading…"]});const x=u?X(y.data??[],{type:u.entity_type,id:u.id}).find(v=>v.key===o):void 0;return!d||!u||!x?t.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"This view isn't attached to this record any more."}):t.jsx("div",{className:"px-4 py-4",children:t.jsx(Se,{orgSlug:e,viewKey:x.key,scope:{type:u.entity_type,entity:u.is_derived?u.slug:u.id},params:n,onParamsChange:r,contentHash:x.content_hash,title:x.name,minHeight:320})})}function Rt({item:e}){if(e.connectorPanel)return t.jsx(Fe,{panel:e.connectorPanel});if(e.schemaSections)return t.jsx(w,{item:e});if(e.recordField)return t.jsx(Ce,{target:e.recordField});if(e.recordPeer)return t.jsx(be,{target:e.recordPeer});if(e.recordLinks)return t.jsx(Qe,{target:e.recordLinks});if(typeof e.browserUrl=="string"&&e.browserUrl.length>0)return t.jsx(_,{item:e});const s=e.href?Y(e.href):null;return s?s.kind==="memory"?"runId"in s?t.jsx(b,{owner:s.owner,runId:s.runId}):"runIds"in s?t.jsx(b,{owner:s.owner,runIds:s.runIds}):t.jsx(b,{owner:s.owner,contentIds:s.contentIds}):s.kind==="entity"?t.jsx(Ge,{owner:s.owner,path:s.path}):s.kind==="record-view"?t.jsx(Ze,{owner:s.owner,path:s.path,viewKey:s.viewKey}):s.kind==="event"?t.jsx(We,{owner:s.owner,eventId:s.eventId,viewKey:s.viewKey}):e.runId?t.jsx(Je,{owner:s.owner,automationId:s.automationId,runId:e.runId}):t.jsx(Xe,{owner:s.owner,automationId:s.automationId,initialView:s.view??"activity",runId:s.runId}):t.jsx(_,{item:e})}function _({item:e}){const s=e.body,o=e.notificationType??"generic",n=e.createdAt,r=e.browserUrl??null,i=e.browserHandoff??null;return t.jsxs("article",{className:"space-y-4 px-5 py-5",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(ee,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-0.5 text-xs text-muted-foreground",children:[t.jsx("span",{children:te(o)}),n?t.jsx("span",{children:se(n)}):null]})]}),s?t.jsx("div",{className:"text-sm leading-6 text-foreground/90",children:t.jsx(ne,{text:s,linkPolicy:o==="action_approval_needed"?"app-links":"strip"})}):t.jsx("p",{className:"text-sm text-muted-foreground",children:"No additional details were provided."}),e.owner&&e.sourceAttribution?t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground/80",children:"Generated from"}),t.jsx(re,{owner:e.owner,source:e.sourceAttribution,className:"text-xs"})]}):null,r?t.jsx("div",{className:"space-y-2",children:i?.state==="expired"?t.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:i.error_message??"This draft expired before the page was opened."}):i?.state==="completed"||i?.state==="preparing"?t.jsx("p",{className:"text-sm text-muted-foreground",children:i.state==="preparing"?"Preparing draft — keep your browser tab open.":"Draft prepared — review and post in your browser."}):t.jsxs(j,{type:"button",size:"sm",className:"h-8 text-sm",onClick:()=>{ie(r)},children:[t.jsx(oe,{className:"mr-1.5 h-3.5 w-3.5"}),"Open post"]})}):null]})}function Je({owner:e,automationId:s,runId:o}){const{organizationId:n}=de(e),r=ae(s,void 0,n),i=r.data?.automation?.managed_agent_id??null;return i?t.jsx(ze,{agentId:i,automationId:s,ownerSlug:e,runId:o}):r.isLoading?t.jsx(g,{className:"h-24 w-full rounded-lg"}):t.jsx("p",{className:"text-sm text-muted-foreground",children:"This run has no agent transcript."})}function Xe({owner:e,automationId:s,initialView:o,runId:n}){const[r,i]=h.useState(o),a=r==="definition";return t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"flex justify-end",children:t.jsx(j,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1.5 text-muted-foreground hover:text-foreground",onClick:()=>i(a?"activity":"definition"),children:a?"Done":t.jsxs(t.Fragment,{children:[t.jsx(ce,{className:"h-3.5 w-3.5"}),"Edit"]})})}),t.jsx(le,{owner:e,agentId:null,automationId:s,view:r,runId:n,onDone:()=>i("activity")})]})}export{Rt as PeekPaneContent};
2
+ //# sourceMappingURL=peek-pane-content-BNR9ImQY.js.map
@@ -1,2 +1,2 @@
1
- import{n as i,e_ as r,j as e,iM as m}from"./index-DYCqXaMf.js";import{A as c}from"./agent-permissions-matrix-gZWl6mAe.js";import{A as l}from"./agent-subpage-shell-BBJoyTuC.js";function x({owner:s,agentId:t}){const{orgContext:n}=i(),{isAdmin:a,isLoading:o}=r(n.organizationId);return e.jsx(l,{owner:s,agentId:t,backLabel:"Permissions",backTo:"/$owner/agents/$agentId/permissions",children:a?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"Control which data, agent settings, and connector actions this agent may use automatically, with approval, or not at all."}),e.jsx("div",{className:"overflow-x-auto",children:e.jsx(c,{owner:s,agentId:t})})]}):o?null:e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"Only organization admins can view or change agent permissions."})})}function p(){const{owner:s,agentId:t}=m.useParams();return e.jsx(x,{owner:s,agentId:t})}export{p as component};
2
- //# sourceMappingURL=permissions-C_auqxfP.js.map
1
+ import{n as i,e_ as r,j as e,iM as m}from"./index-9YuSRymd.js";import{A as c}from"./agent-permissions-matrix-BkZu1LYE.js";import{A as l}from"./agent-subpage-shell-CZJvnjNC.js";function x({owner:s,agentId:t}){const{orgContext:n}=i(),{isAdmin:a,isLoading:o}=r(n.organizationId);return e.jsx(l,{owner:s,agentId:t,backLabel:"Permissions",backTo:"/$owner/agents/$agentId/permissions",children:a?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"Control which data, agent settings, and connector actions this agent may use automatically, with approval, or not at all."}),e.jsx("div",{className:"overflow-x-auto",children:e.jsx(c,{owner:s,agentId:t})})]}):o?null:e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"Only organization admins can view or change agent permissions."})})}function p(){const{owner:s,agentId:t}=m.useParams();return e.jsx(x,{owner:s,agentId:t})}export{p as component};
2
+ //# sourceMappingURL=permissions-Dv39zWKt.js.map
@@ -1,2 +1,2 @@
1
- import{h4 as R,h5 as f,gw as y,gx as N,r as k,j as e,b8 as C,B as d,z as P,fN as A}from"./index-DYCqXaMf.js";function T({resource:p,runId:t,children:h,onDone:l}){const c=!!t,{data:a,isLoading:E,isError:u,refetch:v}=R(p,c?t:void 0),s=f({isReview:c,isError:u,status:a?.status}),x=a?.status==="pending"?a.proposal:null,n=y(),i=N(),[g,j]=k.useState(""),o=n.isPending||i.isPending,m=s==="active"||s==="loading"||s==="error",b=()=>{t&&n.mutate({run_id:t},{onSuccess:()=>l?.()})},w=()=>{if(!t)return;const r=g.trim();i.mutate({run_id:t,...r?{reason:r}:{}},{onSuccess:()=>l?.()})};return e.jsxs("div",{className:"grid content-start gap-4",children:[s==="active"?e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-950 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("p",{children:["Review the change the builder agent proposed. The values below show the proposed change — ",e.jsx("strong",{children:"Approve"})," to apply, or"," ",e.jsx("strong",{children:"Reject"}),"."]})]})}):null,s==="gone"?e.jsx("div",{className:"rounded-lg border bg-muted/30 p-3 text-sm text-muted-foreground",children:"This change is no longer pending (it may have been approved or rejected already)."}):null,s==="error"?e.jsx("div",{className:"rounded-lg border border-destructive/40 bg-destructive/5 p-3 text-sm",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("p",{className:"text-destructive",children:"Couldn't load the proposed change to review. Editing is disabled until it loads — retry, or reopen the link."}),e.jsx(d,{type:"button",variant:"outline",size:"sm",onClick:()=>void v(),children:"Retry"})]})}):null,h({reviewMode:s,proposal:x,controlsDisabled:m}),s==="active"?e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(P,{htmlFor:"review-reject-reason",children:"Reason (optional)"}),e.jsx(A,{id:"review-reject-reason",rows:2,value:g,onChange:r=>j(r.target.value),placeholder:"Why you're rejecting — shared back to the requester.",disabled:o})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:justify-end",children:[e.jsx(d,{type:"button",variant:"outline",onClick:w,disabled:o,children:i.isPending?"Rejecting...":"Reject"}),e.jsx(d,{type:"button",onClick:b,disabled:o,children:n.isPending?"Approving...":"Approve"})]})]}):null]})}export{T as P};
2
- //# sourceMappingURL=proposal-review-shell-DsNiavG_.js.map
1
+ import{h4 as R,h5 as f,gw as y,gx as N,r as k,j as e,b8 as C,B as d,z as P,fN as A}from"./index-9YuSRymd.js";function T({resource:p,runId:t,children:h,onDone:l}){const c=!!t,{data:a,isLoading:E,isError:u,refetch:v}=R(p,c?t:void 0),s=f({isReview:c,isError:u,status:a?.status}),x=a?.status==="pending"?a.proposal:null,n=y(),i=N(),[g,j]=k.useState(""),o=n.isPending||i.isPending,m=s==="active"||s==="loading"||s==="error",b=()=>{t&&n.mutate({run_id:t},{onSuccess:()=>l?.()})},w=()=>{if(!t)return;const r=g.trim();i.mutate({run_id:t,...r?{reason:r}:{}},{onSuccess:()=>l?.()})};return e.jsxs("div",{className:"grid content-start gap-4",children:[s==="active"?e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-950 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("p",{children:["Review the change the builder agent proposed. The values below show the proposed change — ",e.jsx("strong",{children:"Approve"})," to apply, or"," ",e.jsx("strong",{children:"Reject"}),"."]})]})}):null,s==="gone"?e.jsx("div",{className:"rounded-lg border bg-muted/30 p-3 text-sm text-muted-foreground",children:"This change is no longer pending (it may have been approved or rejected already)."}):null,s==="error"?e.jsx("div",{className:"rounded-lg border border-destructive/40 bg-destructive/5 p-3 text-sm",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("p",{className:"text-destructive",children:"Couldn't load the proposed change to review. Editing is disabled until it loads — retry, or reopen the link."}),e.jsx(d,{type:"button",variant:"outline",size:"sm",onClick:()=>void v(),children:"Retry"})]})}):null,h({reviewMode:s,proposal:x,controlsDisabled:m}),s==="active"?e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(P,{htmlFor:"review-reject-reason",children:"Reason (optional)"}),e.jsx(A,{id:"review-reject-reason",rows:2,value:g,onChange:r=>j(r.target.value),placeholder:"Why you're rejecting — shared back to the requester.",disabled:o})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:justify-end",children:[e.jsx(d,{type:"button",variant:"outline",onClick:w,disabled:o,children:i.isPending?"Rejecting...":"Reject"}),e.jsx(d,{type:"button",onClick:b,disabled:o,children:n.isPending?"Approving...":"Approve"})]})]}):null]})}export{T as P};
2
+ //# sourceMappingURL=proposal-review-shell-CFhOqCLf.js.map
@@ -0,0 +1,2 @@
1
+ import{r as e,dn as l}from"./index-9YuSRymd.js";function a(){return e.useEffect(()=>{l()},[]),null}export{a as P};
2
+ //# sourceMappingURL=public-shell-ready-DqX8AXfw.js.map
@@ -1,2 +1,2 @@
1
- import{ag as t,j as e,ah as o,ai as d,aj as m,ak as h}from"./index-DYCqXaMf.js";function p({section:s,icon:a,title:i,description:n,action:l}){const c=s?t[s]:null,x=s!==void 0?t[s].icon:a,r=i??c?.label??"";return e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{className:"h-7 w-7 shrink-0","aria-hidden":!0}),e.jsx("h1",{className:"font-display text-3xl font-semibold leading-tight",children:r})]}),n?e.jsx("p",{className:"text-sm text-muted-foreground",children:n}):null]}),l?e.jsx("div",{className:"shrink-0",children:l}):null]})}function u(){const{owner:s}=o.useParams();return e.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-3 px-4 pt-2.5 pb-8 lg:px-6",children:e.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:e.jsx(d,{owner:s,children:a=>e.jsxs("div",{className:"mx-auto flex min-h-0 w-full min-w-0 max-w-3xl flex-1 flex-col gap-4",children:[e.jsx(p,{icon:m,title:"Recent",description:"Chats, connected apps, and Automations you used last."}),e.jsx(h,{owner:a.ownerSlug,tone:"page",empty:"message"})]})})})})}export{u as component};
2
- //# sourceMappingURL=recent-3d99S2IE.js.map
1
+ import{ag as t,j as e,ah as o,ai as d,aj as m,ak as h}from"./index-9YuSRymd.js";function p({section:s,icon:a,title:i,description:n,action:l}){const c=s?t[s]:null,x=s!==void 0?t[s].icon:a,r=i??c?.label??"";return e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{className:"h-7 w-7 shrink-0","aria-hidden":!0}),e.jsx("h1",{className:"font-display text-3xl font-semibold leading-tight",children:r})]}),n?e.jsx("p",{className:"text-sm text-muted-foreground",children:n}):null]}),l?e.jsx("div",{className:"shrink-0",children:l}):null]})}function u(){const{owner:s}=o.useParams();return e.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-3 px-4 pt-2.5 pb-8 lg:px-6",children:e.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:e.jsx(d,{owner:s,children:a=>e.jsxs("div",{className:"mx-auto flex min-h-0 w-full min-w-0 max-w-3xl flex-1 flex-col gap-4",children:[e.jsx(p,{icon:m,title:"Recent",description:"Chats, connected apps, and Automations you used last."}),e.jsx(h,{owner:a.ownerSlug,tone:"page",empty:"message"})]})})})})}export{u as component};
2
+ //# sourceMappingURL=recent-QhnLDU1_.js.map