@lobu/runtime-server 21.0.0 → 21.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 (182) hide show
  1. package/dist/catalogs/automations.json +0 -8
  2. package/dist/component.json +1 -1
  3. package/dist/connectors/github.ts +269 -194
  4. package/dist/connectors/google_calendar.ts +36 -132
  5. package/dist/connectors/jira.ts +13 -4
  6. package/dist/connectors/producthunt.ts +3 -1
  7. package/dist/connectors/reddit.ts +34 -4
  8. package/dist/db/migrations/20260928120000_classification_consolidation.sql +51 -0
  9. package/dist/dependencies.bun.lock +11 -11
  10. package/dist/owletto/dist/assets/_-00GgOtdu.js +1 -0
  11. package/dist/owletto/dist/assets/{_-DrcppoWh.js → _-XlUwOWCI.js} +2 -2
  12. package/dist/owletto/dist/assets/{_agentId-HNcmgH56.js → _agentId-B2DrawIk.js} +1 -1
  13. package/dist/owletto/dist/assets/_agentId-CS0AcWH2.js +1 -0
  14. package/dist/owletto/dist/assets/{_automationId-BCfrLnUS.js → _automationId-BLnqLtUv.js} +1 -1
  15. package/dist/owletto/dist/assets/{_connectorKey._connectionId-126-iG9w.js → _connectorKey._connectionId-DcUWoZ-C.js} +1 -1
  16. package/dist/owletto/dist/assets/{_connectorKey.index-CywE9A3N.js → _connectorKey.index-C_yKycN_.js} +1 -1
  17. package/dist/owletto/dist/assets/{_conversationId-CNETA_rY.js → _conversationId-CpuEvflw.js} +1 -1
  18. package/dist/owletto/dist/assets/{_deploymentId-CAVpXf8s.js → _deploymentId-BL9tnDFl.js} +1 -1
  19. package/dist/owletto/dist/assets/_name-DlxjWkKk.js +1 -0
  20. package/dist/owletto/dist/assets/{_owner-D2eh4R90.js → _owner-Cg50UU6m.js} +1 -1
  21. package/dist/owletto/dist/assets/_shape-BWZW4mj8.js +1 -0
  22. package/dist/owletto/dist/assets/_skillKey-B25fO0_O.js +1 -0
  23. package/dist/owletto/dist/assets/{_slug-DoIaJBbh.js → _slug-DbD-wv2m.js} +1 -1
  24. package/dist/owletto/dist/assets/_viewKey-BcTEvQ3N.js +1 -0
  25. package/dist/owletto/dist/assets/_viewKey-W4RjiUWL.js +1 -0
  26. package/dist/owletto/dist/assets/_viewKey-iGPCKSda.js +1 -0
  27. package/dist/owletto/dist/assets/{accept-invitation-BWRiEUsd.js → accept-invitation-BmQKbQem.js} +1 -1
  28. package/dist/owletto/dist/assets/{activity-route-view-rVdTeVXN.js → activity-route-view-BvtAoGVt.js} +1 -1
  29. package/dist/owletto/dist/assets/{agent-card-controls-JubkhcHt.js → agent-card-controls-bhTMPoVi.js} +1 -1
  30. package/dist/owletto/dist/assets/{agent-client-setup-list-Btcy4Cu1.js → agent-client-setup-list-BBbq_2B1.js} +1 -1
  31. package/dist/owletto/dist/assets/{agent-connect-pages-Chfqn8iL.js → agent-connect-pages-DkDlFVY5.js} +1 -1
  32. package/dist/owletto/dist/assets/{agent-editor-form-BrOkwfg8.js → agent-editor-form-DwHD9j1Y.js} +1 -1
  33. package/dist/owletto/dist/assets/{agent-guardrails-route-CHM7JbIl.js → agent-guardrails-route-0PsTrqMC.js} +1 -1
  34. package/dist/owletto/dist/assets/{agent-loading-shells-DsiGx1fn.js → agent-loading-shells-BQLjzMPy.js} +1 -1
  35. package/dist/owletto/dist/assets/{agent-permissions-matrix-L_gFvSu1.js → agent-permissions-matrix-B-Q5rmuB.js} +1 -1
  36. package/dist/owletto/dist/assets/{agent-skill-context-D7tOJ8Pb.js → agent-skill-context-s42Q4Wjo.js} +1 -1
  37. package/dist/owletto/dist/assets/{agent-skills-route-AylS-B9v.js → agent-skills-route-Cwq1QrhW.js} +1 -1
  38. package/dist/owletto/dist/assets/{agent-subpage-shell-B7tCQ9zd.js → agent-subpage-shell-DtzoRy6N.js} +1 -1
  39. package/dist/owletto/dist/assets/{agent-thread-DOYh7WLW.js → agent-thread-D7AGGjRV.js} +1 -1
  40. package/dist/owletto/dist/assets/agents-BqCKU4CT.js +1 -0
  41. package/dist/owletto/dist/assets/{agents-workbench-DOwn78eL.js → agents-workbench-Cl7FO7b3.js} +1 -1
  42. package/dist/owletto/dist/assets/{app._appId-fJ_RRn1Z.js → app._appId-CqYz3AOO.js} +1 -1
  43. package/dist/owletto/dist/assets/{automation-detail-content-CMprQht5.js → automation-detail-content-CKSywvzE.js} +1 -1
  44. package/dist/owletto/dist/assets/automations-BqCKU4CT.js +1 -0
  45. package/dist/owletto/dist/assets/{calendar-BbD1N97u.js → calendar-CHXehtu0.js} +1 -1
  46. package/dist/owletto/dist/assets/{callback-PELM84Lh.js → callback-DZ3YyXeV.js} +1 -1
  47. package/dist/owletto/dist/assets/{card-DpLjEqIc.js → card-4Ull9W6d.js} +1 -1
  48. package/dist/owletto/dist/assets/{claim-BLLvLOBM.js → claim-BGLCPLXq.js} +1 -1
  49. package/dist/owletto/dist/assets/{clients-Bd8WpHSV.js → clients-C7ubnFsS.js} +1 -1
  50. package/dist/owletto/dist/assets/{code-editor-DGJQDoHD.js → code-editor-BHiWR94J.js} +1 -1
  51. package/dist/owletto/dist/assets/connect-BNatqg6j.js +1 -0
  52. package/dist/owletto/dist/assets/connect._clientId-BGG2IqiQ.js +1 -0
  53. package/dist/owletto/dist/assets/{connected._clientId-BYGmFRCF.js → connected._clientId-7RU89sVW.js} +1 -1
  54. package/dist/owletto/dist/assets/{connection-B0O8OZuK.js → connection-CTaUGXl6.js} +1 -1
  55. package/dist/owletto/dist/assets/{connection-feed-detail-DZjtoEfm.js → connection-feed-detail-B1xieiEh.js} +1 -1
  56. package/dist/owletto/dist/assets/{connector-provenance-D_g9gGXU.js → connector-provenance-DRdUEmQ1.js} +1 -1
  57. package/dist/owletto/dist/assets/{connectors-BiMMm_QQ.js → connectors-NBwCLuZg.js} +1 -1
  58. package/dist/owletto/dist/assets/{consent-CIzW-960.js → consent-fmhPPlpi.js} +1 -1
  59. package/dist/owletto/dist/assets/{core.esm-Ds4Nuq9d.js → core.esm-C-eNiUAl.js} +1 -1
  60. package/dist/owletto/dist/assets/{create-BvCaqhwK.js → create-8bBbQJGY.js} +1 -1
  61. package/dist/owletto/dist/assets/create-Cl6cfNAp.js +1 -0
  62. package/dist/owletto/dist/assets/create-DrVso8O7.js +1 -0
  63. package/dist/owletto/dist/assets/create-automation-form-De8J-JD5.js +2 -0
  64. package/dist/owletto/dist/assets/{create._connectorKey--qDi1h6S.js → create._connectorKey-CHAotlsF.js} +1 -1
  65. package/dist/owletto/dist/assets/{cronstrue-h8_zIyZD.js → cronstrue-C5yTgk5z.js} +1 -1
  66. package/dist/owletto/dist/assets/deployments-C7M3fV5K.js +1 -0
  67. package/dist/owletto/dist/assets/{deployments-ICDss7yS.js → deployments-D1gbQwsy.js} +1 -1
  68. package/dist/owletto/dist/assets/{deployments-body-DulCUAMt.js → deployments-body-DycIGlnL.js} +1 -1
  69. package/dist/owletto/dist/assets/{device-kTL2l_cz.js → device-DyPnQkhO.js} +1 -1
  70. package/dist/owletto/dist/assets/{device-pin-tombstone-BmD4pv_e.js → device-pin-tombstone-CwJitllC.js} +1 -1
  71. package/dist/owletto/dist/assets/{device-rows-BqudjhFu.js → device-rows-BBhW1C7Y.js} +1 -1
  72. package/dist/owletto/dist/assets/{device._deviceId-CsLJJ6jv.js → device._deviceId-XswfXHOc.js} +1 -1
  73. package/dist/owletto/dist/assets/{entity-options-ErxYvMDH.js → entity-options-utGBmFX0.js} +1 -1
  74. package/dist/owletto/dist/assets/{entity-page-CYRAwUGO.js → entity-page-BxwuqqWk.js} +1 -1
  75. package/dist/owletto/dist/assets/{entity-type-page-BlAizGlz.js → entity-type-page-BrWqk6so.js} +1 -1
  76. package/dist/owletto/dist/assets/{event-page-DTXPxc-E.js → event-page-LIm4EDmJ.js} +1 -1
  77. package/dist/owletto/dist/assets/{events-feed-L3c-LLiJ.js → events-feed-C4L8mQV7.js} +1 -1
  78. package/dist/owletto/dist/assets/{full-page-spinner-BxcYpJXx.js → full-page-spinner-DsU-Cb3L.js} +1 -1
  79. package/dist/owletto/dist/assets/guardrails-CGFWCfbQ.js +1 -0
  80. package/dist/owletto/dist/assets/identity-uPYpPogR.js +1 -0
  81. package/dist/owletto/dist/assets/{index-13rywWam.js → index-1YrrvVJ4.js} +1 -1
  82. package/dist/owletto/dist/assets/index-BKMafTe4.js +1 -0
  83. package/dist/owletto/dist/assets/index-BsL1-C2-.js +1 -0
  84. package/dist/owletto/dist/assets/index-C58oW727.js +1 -0
  85. package/dist/owletto/dist/assets/{index--lEHrFE4.js → index-CQ4s6nzy.js} +1 -1
  86. package/dist/owletto/dist/assets/{index-DAv5S2aK.js → index-CpWKAAGX.js} +1 -1
  87. package/dist/owletto/dist/assets/{index-QcHQZI87.js → index-D2dcENg2.js} +1 -1
  88. package/dist/owletto/dist/assets/{index-CheCJomo.js → index-DCK0KhMM.js} +1 -1
  89. package/dist/owletto/dist/assets/{index-BRvT0VV9.js → index-DXqiRON3.js} +1 -1
  90. package/dist/owletto/dist/assets/index-DgEc5IvT.js +1 -0
  91. package/dist/owletto/dist/assets/{index-DdGjY1Hb.js → index-DtRfQcRH.js} +1530 -1530
  92. package/dist/owletto/dist/assets/index-DvhM9tuI.js +1 -0
  93. package/dist/owletto/dist/assets/{index-CFkj9iR_.js → index-DwtfHCHB.js} +1 -1
  94. package/dist/owletto/dist/assets/index-DyYFZjh-.js +1 -0
  95. package/dist/owletto/dist/assets/{index-B_-MLsof.js → index-nOYvNROJ.js} +1 -1
  96. package/dist/owletto/dist/assets/index-oDoJENMF.js +1 -0
  97. package/dist/owletto/dist/assets/index-rPdUEOa3.js +1 -0
  98. package/dist/owletto/dist/assets/{json-diff-BV2STDGj.js → json-diff-DYeX-xLk.js} +1 -1
  99. package/dist/owletto/dist/assets/{list-skeleton-CT5n4ND_.js → list-skeleton-s4GPSJ8J.js} +1 -1
  100. package/dist/owletto/dist/assets/{login-DKsgABYt.js → login-Di5VF2F_.js} +1 -1
  101. package/dist/owletto/dist/assets/{logout-D_CP-emw.js → logout-BuaQGSnw.js} +1 -1
  102. package/dist/owletto/dist/assets/{member-scope-gate-BTgmlfFJ.js → member-scope-gate-CJqJZk7T.js} +1 -1
  103. package/dist/owletto/dist/assets/{memory-browse-page-FHaJC3ML.js → memory-browse-page-Bibfs2sK.js} +1 -1
  104. package/dist/owletto/dist/assets/{missing-view-Bve6pJP-.js → missing-view-CD4DOaG8.js} +1 -1
  105. package/dist/owletto/dist/assets/{model-selector-BLCEahny.js → model-selector-XC5CI2Et.js} +1 -1
  106. package/dist/owletto/dist/assets/models--8mTFOLz.js +1 -0
  107. package/dist/owletto/dist/assets/{new-CirOK0Sw.js → new-BzkA1sq2.js} +1 -1
  108. package/dist/owletto/dist/assets/{new-DzapH2sV.js → new-C3f0BShb.js} +1 -1
  109. package/dist/owletto/dist/assets/{new-BAIGSdfp.js → new-DA5LF6iB.js} +1 -1
  110. package/dist/owletto/dist/assets/{oauth-workspace-access-BF7jaswv.js → oauth-workspace-access-D6epOq0R.js} +1 -1
  111. package/dist/owletto/dist/assets/{organization-D9RPsWG-.js → organization-DOtBRqDQ.js} +1 -1
  112. package/dist/owletto/dist/assets/{permissions-BlRONw-u.js → permissions-D8uJHINS.js} +1 -1
  113. package/dist/owletto/dist/assets/{proposal-review-shell-uskeFIUr.js → proposal-review-shell-C3K-JXjb.js} +1 -1
  114. package/dist/owletto/dist/assets/{recent-CmJ4Is6V.js → recent-CFcWceBl.js} +1 -1
  115. package/dist/owletto/dist/assets/{renderer-Dyf4t8kR.js → renderer-1nRJFMGx.js} +1 -1
  116. package/dist/owletto/dist/assets/{reset-password-BVIeE1Zm.js → reset-password-9RTWhBEb.js} +1 -1
  117. package/dist/owletto/dist/assets/{runs-CzBeUzlQ.js → runs-_yVh6PPB.js} +1 -1
  118. package/dist/owletto/dist/assets/{runs-panel-D7l1uLGm.js → runs-panel-B2852xus.js} +1 -1
  119. package/dist/owletto/dist/assets/{runs-table-dATyiBg2.js → runs-table--dnFQatY.js} +1 -1
  120. package/dist/owletto/dist/assets/{schema-value-normalization-DgMkyVVE.js → schema-value-normalization-BspxVEGy.js} +1 -1
  121. package/dist/owletto/dist/assets/{settings-Co1wj_m6.js → settings-9lDASETT.js} +1 -1
  122. package/dist/owletto/dist/assets/settings-DQo_ZS2P.js +1 -0
  123. package/dist/owletto/dist/assets/skills-a5xQ4RE9.js +1 -0
  124. package/dist/owletto/dist/assets/{switch-DDkPrV3p.js → switch-CxDXvPGE.js} +1 -1
  125. package/dist/owletto/dist/assets/{use-applied-views-DELwQQh7.js → use-applied-views-DvMT3wap.js} +1 -1
  126. package/dist/owletto/dist/assets/{use-mention-search-CGA3AaKm.js → use-mention-search-CeTEE3oE.js} +1 -1
  127. package/dist/owletto/dist/assets/{view-frame-DDr-Xtet.js → view-frame-HoBawpT2.js} +1 -1
  128. package/dist/owletto/dist/index.html +1 -1
  129. package/dist/providers.json +0 -1
  130. package/dist/server-main.bundle.mjs +2365 -3969
  131. package/npm-shrinkwrap.json +41 -41
  132. package/package.json +1 -1
  133. package/vendor/connector-sdk/dist/connector-types.d.ts +0 -2
  134. package/vendor/connector-sdk/package.json +1 -1
  135. package/vendor/core/dist/contracts/tools/manage-auth-profiles.d.ts +14 -0
  136. package/vendor/core/dist/contracts/tools/manage-auth-profiles.js +12 -1
  137. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +0 -10
  138. package/vendor/core/dist/contracts/tools/manage-automations.js +0 -33
  139. package/vendor/core/dist/contracts/tools/manage-classifiers.d.ts +4 -34
  140. package/vendor/core/dist/contracts/tools/manage-classifiers.js +13 -44
  141. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +0 -9
  142. package/vendor/core/dist/contracts/tools/manage-entity.js +0 -6
  143. package/vendor/core/dist/contracts/tools/view-attach.d.ts +20 -0
  144. package/vendor/core/dist/contracts/tools/view-attach.js +45 -0
  145. package/vendor/core/dist/contracts/worker/protocol.d.ts +17 -0
  146. package/vendor/core/dist/contracts/worker/protocol.js +12 -1
  147. package/vendor/core/dist/index.d.ts +1 -1
  148. package/vendor/core/dist/provider-config-types.d.ts +0 -9
  149. package/vendor/core/dist/sdk-compat.d.ts +1 -1
  150. package/vendor/core/package.json +6 -1
  151. package/vendor/views/dist/api.d.ts +9 -4
  152. package/vendor/views/dist/api.js +6 -2
  153. package/vendor/views/package.json +1 -1
  154. package/dist/owletto/dist/assets/_-CwFknmeA.js +0 -1
  155. package/dist/owletto/dist/assets/_agentId-Cr57JKYx.js +0 -1
  156. package/dist/owletto/dist/assets/_name-BP7OlVxL.js +0 -1
  157. package/dist/owletto/dist/assets/_shape-BqV8tSfw.js +0 -1
  158. package/dist/owletto/dist/assets/_skillKey-2xTjhL_C.js +0 -1
  159. package/dist/owletto/dist/assets/_viewKey-8ePnWEg-.js +0 -1
  160. package/dist/owletto/dist/assets/_viewKey-D8rjUFLV.js +0 -1
  161. package/dist/owletto/dist/assets/_viewKey-DhVOkzYd.js +0 -1
  162. package/dist/owletto/dist/assets/agents-0ncYwbz6.js +0 -1
  163. package/dist/owletto/dist/assets/automations-0ncYwbz6.js +0 -1
  164. package/dist/owletto/dist/assets/connect-Cx49f4J0.js +0 -1
  165. package/dist/owletto/dist/assets/connect._clientId-BDFBqKSA.js +0 -1
  166. package/dist/owletto/dist/assets/create--fsxroj2.js +0 -1
  167. package/dist/owletto/dist/assets/create-BqL-ahEf.js +0 -1
  168. package/dist/owletto/dist/assets/create-automation-form-DN2w080o.js +0 -2
  169. package/dist/owletto/dist/assets/deployments-BROg1Te8.js +0 -1
  170. package/dist/owletto/dist/assets/guardrails-Dh4adTXY.js +0 -1
  171. package/dist/owletto/dist/assets/identity-B8lKn0je.js +0 -1
  172. package/dist/owletto/dist/assets/index-BUp24ZJr.js +0 -1
  173. package/dist/owletto/dist/assets/index-Bq-q4Y7E.js +0 -1
  174. package/dist/owletto/dist/assets/index-CgBgOElA.js +0 -1
  175. package/dist/owletto/dist/assets/index-CpiW66xK.js +0 -1
  176. package/dist/owletto/dist/assets/index-DBi2Xr3i.js +0 -1
  177. package/dist/owletto/dist/assets/index-DHOha5OJ.js +0 -1
  178. package/dist/owletto/dist/assets/index-Dkyl7l6E.js +0 -1
  179. package/dist/owletto/dist/assets/index-kq4537-S.js +0 -1
  180. package/dist/owletto/dist/assets/models-C4N7LQAW.js +0 -1
  181. package/dist/owletto/dist/assets/settings-BK1GHmzb.js +0 -1
  182. package/dist/owletto/dist/assets/skills-DF53JcYt.js +0 -1
@@ -1 +1 @@
1
- import{cr as ae,gf as T,ap as O,aq as A,ai as ie,j as s,al as Q,cG as le,cH as ce,cI as ue,as as ye,c0 as re,aG as oe,r as S,c1 as he,c2 as je,cC as de,L as Z,cw as z,Z as ve,cv as be,P as ke}from"./index-DdGjY1Hb.js";const $={auto:0,approval:1,deny:2,disabled:2};function ee(t,n){return`${ie}/api/${t}/agent/${encodeURIComponent(n)}/permissions`}function fe(t,n){return["agent-permissions",typeof t=="string"?t:t?.slug??null,n]}function Ne(t,n,r){return ae({queryKey:fe(t,n),enabled:(r?.enabled??!0)&&!!n,queryFn:async()=>{const e=T(t??void 0),o=await O(ee(e.slug,n),{credentials:"include"});if(!o.ok)throw await A(o);return await o.json()},staleTime:3e4})}async function we(t,n,r){const e=T(t),o=await O(ee(e.slug,n),{method:"PUT",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(r)});if(!o.ok)throw await A(o);const l=await o.json();if(!l.policy)throw new Error("Agent permission update did not return a policy.");return l.policy}async function Ee(t,n,r){const e=T(t),o=new URLSearchParams;o.set("resource_class",r.resource_class),r.entity_type_slug&&o.set("entity_type_slug",r.entity_type_slug),r.operation_key&&o.set("operation_key",r.operation_key),r.target_agent_id&&o.set("target_agent_id",r.target_agent_id);const l=await O(`${ee(e.slug,n)}?${o.toString()}`,{method:"DELETE",credentials:"include"});if(!l.ok)throw await A(l);return(await l.json()).deleted===!0}function te(t){return`${ie}/api/${t}/write-permissions`}function me(t){return["write-permissions",typeof t=="string"?t:t?.slug??null]}function Se(t,n){return ae({queryKey:me(t),enabled:n?.enabled??!0,queryFn:async()=>{const r=T(t??void 0),e=await O(te(r.slug),{credentials:"include"});if(!e.ok)throw await A(e);return await e.json()},staleTime:3e4})}async function $e(t,n){const r=T(t),e=await O(te(r.slug),{method:"PUT",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(n)});if(!e.ok)throw await A(e);const o=await e.json();if(!o.policy)throw new Error("Org write permission update did not return a policy.");return o.policy}async function Te(t,n){const r=T(t),e=new URLSearchParams;e.set("resource_class",n.resource_class),n.entity_type_slug&&e.set("entity_type_slug",n.entity_type_slug),n.operation_key&&e.set("operation_key",n.operation_key),n.target_agent_id&&e.set("target_agent_id",n.target_agent_id);const o=await O(`${te(r.slug)}?${e.toString()}`,{method:"DELETE",credentials:"include"});if(!o.ok)throw await A(o);return(await o.json()).deleted===!0}const U={entity:["read","create","update","delete"],agent_config:["read","create","update","delete"],connector_action:["execute"],entity_schema:["create_type","update_type","delete_type","create_relationship_type","update_relationship_type","delete_relationship_type"]},Oe={entity:{read:"auto",create:"auto",update:"auto",delete:"approval"},agent_config:{read:"auto",create:"approval",update:"approval",delete:"deny"},connector_action:{execute:"auto"},entity_schema:{create_type:"auto",update_type:"auto",delete_type:"auto",create_relationship_type:"auto",update_relationship_type:"auto",delete_relationship_type:"auto"}};function Ae(t,n){return(t==="entity"||t==="agent_config")&&n==="read"?["auto","deny"]:Ce[t]}const Ce={entity:["auto","approval","deny"],agent_config:["auto","approval","deny"],connector_action:["auto","approval","deny","disabled"],entity_schema:["auto","approval","deny"]},pe={auto:"Auto",approval:"Approval",deny:"Deny",disabled:"Disabled"},Re={auto:"Auto-approve",approval:"Requires approval",deny:"Deny",disabled:"Disabled"};function H(t,n){return t.effects?.[n]}function Fe(t,n){return $[t]<$[n]}function q(t,n){return $[t]!==$[n]?$[t]>$[n]?t:n:t==="deny"||n==="deny"?"deny":t}function ne(t,n,r,e,o=null,l=null){let c=null;for(const a of t){if(a.resource_class!==n||a.field_path!==null||a.entity_id!==null||a.entity_type_slug!==null&&a.entity_type_slug!==e||a.operation_key!==null&&a.operation_key!==o||a.target_agent_id!==null&&a.target_agent_id!==l)continue;const m=H(a,r);m&&(c=c===null?m:q(c,m))}return c??Oe[n]?.[r]??"deny"}function se(t,n,r,e,o=null,l=null){return t.some(c=>c.resource_class!==n||c.field_path!==null||c.entity_id!==null||c.entity_type_slug!==null&&c.entity_type_slug!==e||c.operation_key!==null&&c.operation_key!==o||c.target_agent_id!==null&&c.target_agent_id!==l?!1:H(c,r)!==void 0)}function Le(t,n,r){const e=W(t,n,null);return e?H(e,r)!==void 0:!1}function W(t,n,r,e=null,o=null){return t.find(l=>l.resource_class===n&&(l.entity_type_slug??null)===r&&(l.operation_key??null)===e&&(l.target_agent_id??null)===o)}function Pe(t,n,r,e=null,o=null){const l=W(t.agent,n,r,e,o),c={};if(!l?.effects)return c;for(const a of U[n]){const m=l.effects[a];m&&(c[a]=m)}return c}function h(t,n,r,e,o=null,l=null){const c=ne(t.floor,n,r,e,o,l),a=se(t.floor,n,r,e,o,l),m=e!==null||o!==null||l!==null?W(t.agent,n,e,o,l):void 0,j=W(t.agent,n,null);let p=null;for(const v of[j,m]){const x=v&&H(v,r);x&&(p=p===null?x:q(p,x))}return p===null?c:a?q(p,c):p}function Me(t){const{option:n,floor:r}=t;return Fe(n,r)?{disabled:!0,reason:`Below org floor (${Re[r]})`}:{disabled:!1}}function De(t){const n=new Set;for(const e of t.agent)e.resource_class==="entity"&&e.entity_type_slug&&n.add(e.entity_type_slug);for(const e of t.floor)e.resource_class==="entity"&&e.entity_type_slug&&e.field_path===null&&e.entity_id===null&&n.add(e.entity_type_slug);const r=new Map(t.entity_types.map(e=>[e.slug,e]));return[...n].map(e=>r.get(e)??{slug:e,name:e})}function Be(t,n){return t.agent.some(r=>r.resource_class==="entity"&&r.entity_type_slug===n)}function Qe(t,n){let r=0;for(const e of U.entity){const o=h(t,"entity",e,null);h(t,"entity",e,n)!==o&&(r+=1)}return r}function qe(t){const n=new Set;for(const e of t.agent)e.resource_class==="connector_action"&&e.operation_key&&n.add(e.operation_key);for(const e of t.floor)e.resource_class==="connector_action"&&e.operation_key&&n.add(e.operation_key);const r=new Map(t.connector_operations.map(e=>[e.operation_key,e]));return[...n].map(e=>r.get(e)??{operation_key:e,name:e,connector_key:e.split("::")[0]??e,connector_name:e.split("::")[0]??e})}function We(t,n){return t.agent.some(r=>r.resource_class==="connector_action"&&r.operation_key===n)}function Ue(t,n){const r=h(t,"connector_action","execute",null),e=h(t,"connector_action","execute",null,n);return r!==e}function He(t){const n=new Set;for(const e of t.agent)e.resource_class==="agent_config"&&e.target_agent_id&&n.add(e.target_agent_id);for(const e of t.floor)e.resource_class==="agent_config"&&e.target_agent_id&&n.add(e.target_agent_id);const r=new Map(t.agents.map(e=>[e.id,e]));return[...n].map(e=>r.get(e)??{id:e,name:e})}function Ge(t,n){return t.agent.some(r=>r.resource_class==="agent_config"&&r.target_agent_id===n)}function Je(t,n){let r=0;for(const e of U.agent_config){const o=h(t,"agent_config",e,null);h(t,"agent_config",e,null,null,n)!==o&&(r+=1)}return r}const Ke={auto:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",approval:"bg-amber-500/15 text-amber-600 dark:text-amber-400",deny:"bg-red-500/15 text-red-600 dark:text-red-400",disabled:"bg-muted text-foreground"},Xe={auto:"Auto",approval:"Ask",deny:"Deny",disabled:"Off"};function Ze({options:t,value:n,floor:r,onChange:e,disabled:o,ariaLabel:l,compact:c}){return s.jsx("div",{role:"radiogroup","aria-label":l,className:Q("inline-flex shrink-0 items-stretch gap-0.5 rounded-lg border border-border bg-muted/40 p-0.5"),children:t.map(a=>{const m=Me({option:a,floor:r}),j=a===n,p=m.disabled&&!j,v=c?Xe[a]:pe[a],x=s.jsx("button",{type:"button",role:"radio","aria-checked":j,disabled:o||p,onClick:()=>{!j&&!p&&!o&&e(a)},className:Q("inline-flex shrink-0 items-center justify-center whitespace-nowrap font-medium transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",c?"min-w-[3rem] rounded-md px-2.5 py-1.5 text-xs leading-none":"min-w-[3.25rem] rounded-md px-3 py-1.5 text-sm leading-none",j?Q(Ke[a],""):"text-muted-foreground hover:bg-background/60 hover:text-foreground",p&&"cursor-not-allowed opacity-40",o&&!p&&"cursor-not-allowed opacity-60"),children:v},a);return p&&m.reason?s.jsxs(le,{children:[s.jsx(ce,{asChild:!0,children:s.jsx("span",{className:"inline-flex shrink-0",children:x})}),s.jsx(ue,{children:m.reason})]},a):x})})}const ze=[{resourceClass:"entity",title:"Entities",sub:"Defaults for every type · exceptions below"},{resourceClass:"connector_action",title:"Connector writes",sub:"Write ops only · reads follow the connection"},{resourceClass:"agent_config",title:"Agents",sub:"Read peers · create / edit / delete · exceptions below"}];function Ve(t,n,r,e,o=null,l=null){const c=ne(t.floor,n,r,e,o,l),a=se(t.floor,n,r,e,o,l)?c:"auto";return(e!==null||o!==null||l!==null)&&Le(t.agent,n,r)?q(a,h(t,n,r,null)):a}function B({response:t,resourceClass:n,action:r,entityTypeSlug:e,operationKey:o=null,targetAgentId:l=null,dimmed:c,pending:a,onSave:m}){const j=ne(t.floor,n,r,e,o,l),p=se(t.floor,n,r,e,o,l),v=h(t,n,r,e,o,l),x=Ve(t,n,r,e,o,l),w=Ae(n,r),y=e??o??l??"default",E=s.jsx("div",{className:Q("inline-flex shrink-0",c&&"opacity-45"),children:s.jsx(Ze,{options:w,value:v,floor:x,disabled:a,compact:!0,ariaLabel:`${y} ${r}`,onChange:m})});return p?s.jsxs(le,{children:[s.jsx(ce,{asChild:!0,children:s.jsx("span",{className:"inline-flex shrink-0",children:E})}),s.jsxs(ue,{children:["Org floor ",pe[j]," — can only go stricter"]})]}):E}function Ye(t,n){const r=o=>o.resource_class===n.resource_class&&(o.entity_type_slug??null)===(n.entity_type_slug??null)&&(o.operation_key??null)===(n.operation_key??null)&&(o.target_agent_id??null)===(n.target_agent_id??null),e=t.map(o=>r(o)?n:o);return e.some(r)?e:[...e,n]}function Ie(t,n,r,e,o,l,c){const a=Pe(t,n,r,e,o);return a[l]=c,a}const V="font-medium text-foreground hover:text-primary hover:underline";function et({type:t}){return s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(de,{icon:t.icon,className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"font-medium",children:t.name}),s.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:t.slug})]})}function Y({label:t,disabled:n,hint:r,searchPlaceholder:e,emptyText:o,children:l}){return n?s.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:[t,r?` ${r}`:""]}):s.jsx(be,{contentClassName:"w-[min(100vw-2rem,22rem)]",searchPlaceholder:e,emptyText:o,trigger:c=>s.jsxs("button",{type:"button","aria-expanded":c,className:"flex w-full items-center gap-1.5 px-3 py-1.5 text-left text-xs text-primary hover:bg-muted/50",children:[s.jsx(ke,{className:"h-3 w-3"}),t]}),children:c=>l(c)})}function I({pending:t,onClick:n,label:r}){return s.jsx("button",{type:"button",disabled:t,onClick:n,"aria-label":r,className:"rounded p-0.5 text-muted-foreground hover:bg-red-500/10 hover:text-red-600 disabled:opacity-50 dark:hover:text-red-400",children:s.jsx(ve,{className:"h-3 w-3"})})}function R(t,n){const c=`repeat(${t}, minmax(${10.25}rem, 1fr))`;return{gridTemplateColumns:n?`minmax(${5.5}rem, 8rem) ${c} ${1.5}rem`:`minmax(${5.5}rem, 8rem) ${c}`,minWidth:`${5.5+t*10.25+1.5+2}rem`}}function nt({owner:t,agentId:n,variant:r="agent"}){const e=r==="org-floor",o=ye(),l=Ne(t,n??"",{enabled:!e&&!!n}),c=Se(t,{enabled:e}),{data:a,isLoading:m,isError:j,error:p}=e?c:l,v=e?me(t):fe(t,n??""),x=re({mutationFn:u=>e?$e(t,u):we(t,n??"",u),onSuccess:u=>{o.setQueryData(v,f=>f&&{...f,agent:Ye(f.agent,u)}),o.invalidateQueries({queryKey:v}),e&&o.invalidateQueries({queryKey:["agent-permissions"]})},onError:u=>{oe.error(u instanceof Error?u.message:"Failed to save permission")}}),w=re({mutationFn:u=>e?Te(t,u):Ee(t,n??"",u),onSuccess:()=>{o.invalidateQueries({queryKey:v}),e&&o.invalidateQueries({queryKey:["agent-permissions"]})},onError:u=>{oe.error(u instanceof Error?u.message:"Failed to remove override")}}),y=x.isPending||w.isPending,E=S.useMemo(()=>a?De(a):[],[a]),G=S.useMemo(()=>{if(!a)return[];const u=new Set(E.map(f=>f.slug));return a.entity_types.filter(f=>!u.has(f.slug))},[a,E]),J=S.useMemo(()=>a?qe(a):[],[a]),K=S.useMemo(()=>{if(!a)return[];const u=new Set(J.map(f=>f.operation_key));return a.connector_operations.filter(f=>!u.has(f.operation_key))},[a,J]),F=S.useMemo(()=>a?He(a):[],[a]),L=S.useMemo(()=>{if(!a)return[];const u=new Set(F.map(f=>f.id));return a.agents.filter(f=>(e||f.id!==n)&&!u.has(f.id))},[a,F,n,e]);if(m)return s.jsx(he,{label:"permissions",variant:"cards",cards:2});if(j||!a)return s.jsx(je,{label:p instanceof Error?p.message:"permissions"});const g=a,P=(u,f,M,D,b=null,k=null)=>{const i=Ie(g,u,f,b,k,M,D);x.mutate({resource_class:u,effects:i,entity_type_slug:f,operation_key:b,target_agent_id:k})},ge=g.entity_types.length===0?"— none yet":G.length===0?"— all covered":null,_e=g.connector_operations.length===0?"— none installed":K.length===0?"— all covered":null,xe=L.length===0&&F.length===0?"— no other agents":L.length===0?"— all covered":null;return s.jsx("div",{className:"space-y-2",children:ze.map(u=>{const f=u.resourceClass==="entity",M=u.resourceClass==="connector_action",D=u.resourceClass==="agent_config",b=U[u.resourceClass],k=b.length;return s.jsxs("section",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-baseline gap-2 px-0.5",children:[s.jsx("h3",{className:"text-sm font-semibold text-foreground",children:u.title}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:u.sub})]}),s.jsxs("div",{className:"",children:[s.jsxs("div",{className:"grid items-center gap-x-3 rounded-md bg-muted/50 px-3 py-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",style:R(k,!0),children:[s.jsx("span",{}),b.map(i=>s.jsx("span",{className:"text-center",children:i},i)),s.jsx("span",{})]}),s.jsxs("div",{className:"grid items-center gap-x-3 px-3 py-1.5",style:R(k,!0),children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:"Default"}),b.map(i=>s.jsx("div",{className:"flex min-w-0 justify-center overflow-visible",children:s.jsx(B,{response:g,resourceClass:u.resourceClass,action:i,entityTypeSlug:null,pending:y,onSave:d=>P(u.resourceClass,null,i,d)})},i)),s.jsx("span",{})]}),f?E.map(i=>{const d=Be(g,i.slug),N=Qe(g,i.slug);return s.jsxs("div",{className:"grid items-center gap-x-3 px-3 py-1.5",style:R(k,!0),children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(de,{icon:i.icon,className:"h-3.5 w-3.5 shrink-0"}),s.jsx(Z,{to:"/$owner/entity-types/$slug",params:{owner:t,slug:i.slug},className:V,title:`Open ${i.name}`,children:s.jsx("span",{className:"truncate text-sm",children:i.name})}),d?N>0?s.jsxs("span",{className:"shrink-0 text-[10px] text-amber-600 dark:text-amber-400",children:[N,"≠"]}):null:s.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:"floor"})]}),b.map(_=>{const C=h(g,"entity",_,i.slug)===h(g,"entity",_,null);return s.jsx("div",{className:"flex min-w-0 justify-center",children:s.jsx(B,{response:g,resourceClass:"entity",action:_,entityTypeSlug:i.slug,dimmed:C,pending:y,onSave:X=>P("entity",i.slug,_,X)})},_)}),d?s.jsx(I,{pending:y,label:`Remove ${i.name} exception`,onClick:()=>w.mutate({resource_class:"entity",entity_type_slug:i.slug})}):s.jsx("span",{})]},i.slug)}):null,M?J.map(i=>{const d=We(g,i.operation_key),N=Ue(g,i.operation_key);return s.jsxs("div",{className:"grid items-center gap-x-3 px-3 py-1.5",style:R(k,!0),children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-0",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(Z,{to:"/$owner/connectors/$connectorKey",params:{owner:t,connectorKey:i.connector_key},className:V,title:`Open ${i.connector_name}`,children:s.jsx("span",{className:"truncate font-mono text-sm",children:i.name})}),i.destructive?s.jsx("span",{className:"shrink-0 text-[10px] text-amber-600 dark:text-amber-400",children:"!"}):null,d?N?s.jsx("span",{className:"shrink-0 text-[10px] text-amber-600 dark:text-amber-400",children:"≠"}):null:s.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:"floor"})]}),s.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:i.connector_name})]}),b.map(_=>s.jsx("div",{className:"flex min-w-0 justify-center",children:s.jsx(B,{response:g,resourceClass:"connector_action",action:_,entityTypeSlug:null,operationKey:i.operation_key,dimmed:!N,pending:y,onSave:C=>P("connector_action",null,_,C,i.operation_key)})},_)),d?s.jsx(I,{pending:y,label:`Remove ${i.name} exception`,onClick:()=>w.mutate({resource_class:"connector_action",operation_key:i.operation_key})}):s.jsx("span",{})]},i.operation_key)}):null,D?F.map(i=>{const d=Ge(g,i.id),N=Je(g,i.id);return s.jsxs("div",{className:"grid items-center gap-x-3 px-3 py-1.5",style:R(k,!0),children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(Z,{to:"/$owner/agents/$agentId/settings",params:{owner:t,agentId:i.id},search:{run_id:void 0},className:V,title:`Open ${i.name}`,children:s.jsx("span",{className:"truncate text-sm",children:i.name})}),d?N>0?s.jsxs("span",{className:"shrink-0 text-[10px] text-amber-600 dark:text-amber-400",children:[N,"≠"]}):null:s.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:"floor"})]}),b.map(_=>{if(_==="create")return s.jsx("div",{className:"text-center text-[10px] text-muted-foreground",children:"—"},_);const C=h(g,"agent_config",_,null,null,i.id)===h(g,"agent_config",_,null);return s.jsx("div",{className:"flex min-w-0 justify-center",children:s.jsx(B,{response:g,resourceClass:"agent_config",action:_,entityTypeSlug:null,targetAgentId:i.id,dimmed:C,pending:y,onSave:X=>P("agent_config",null,_,X,null,i.id)})},_)}),d?s.jsx(I,{pending:y,label:`Remove ${i.name} exception`,onClick:()=>w.mutate({resource_class:"agent_config",target_agent_id:i.id})}):s.jsx("span",{})]},i.id)}):null,s.jsxs("div",{className:"border-t",children:[f?s.jsx(Y,{label:"Add type",disabled:y||G.length===0,hint:ge,searchPlaceholder:"Search types…",emptyText:"No matching types.",children:i=>G.map(d=>s.jsx(z,{value:`${d.name} ${d.slug}`,onSelect:()=>{x.mutate({resource_class:"entity",effects:{},entity_type_slug:d.slug}),i()},className:"cursor-pointer",children:s.jsx(et,{type:d})},d.slug))}):null,M?s.jsx(Y,{label:"Add operation",disabled:y||K.length===0,hint:_e,searchPlaceholder:"Search ops…",emptyText:"No matching ops.",children:i=>K.map(d=>s.jsx(z,{value:`${d.name} ${d.connector_name} ${d.operation_key}`,onSelect:()=>{x.mutate({resource_class:"connector_action",effects:{},operation_key:d.operation_key}),i()},className:"cursor-pointer",children:s.jsxs("span",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:"truncate text-sm font-medium",children:d.name}),s.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:d.connector_name})]})},d.operation_key))}):null,D?s.jsx(Y,{label:"Add agent",disabled:y||L.length===0,hint:xe,searchPlaceholder:"Search agents…",emptyText:"No matching agents.",children:i=>L.map(d=>s.jsxs(z,{value:`${d.name} ${d.id}`,onSelect:()=>{x.mutate({resource_class:"agent_config",effects:{},target_agent_id:d.id}),i()},className:"cursor-pointer",children:[s.jsx("span",{className:"font-medium",children:d.name}),s.jsx("span",{className:"ml-1.5 font-mono text-[10px] text-muted-foreground",children:d.id})]},d.id))}):null]})]})]},u.resourceClass)})})}export{nt as A,Oe as C,Ze as P,$e as a,Te as d,Ae as e,me as o,Se as u};
1
+ import{cr as ae,gf as T,ap as O,aq as A,ai as ie,j as s,al as Q,cG as le,cH as ce,cI as ue,as as ye,c0 as re,aG as oe,r as S,c1 as he,c2 as je,cC as de,L as Z,cw as z,Z as ve,cv as be,P as ke}from"./index-DtRfQcRH.js";const $={auto:0,approval:1,deny:2,disabled:2};function ee(t,n){return`${ie}/api/${t}/agent/${encodeURIComponent(n)}/permissions`}function fe(t,n){return["agent-permissions",typeof t=="string"?t:t?.slug??null,n]}function Ne(t,n,r){return ae({queryKey:fe(t,n),enabled:(r?.enabled??!0)&&!!n,queryFn:async()=>{const e=T(t??void 0),o=await O(ee(e.slug,n),{credentials:"include"});if(!o.ok)throw await A(o);return await o.json()},staleTime:3e4})}async function we(t,n,r){const e=T(t),o=await O(ee(e.slug,n),{method:"PUT",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(r)});if(!o.ok)throw await A(o);const l=await o.json();if(!l.policy)throw new Error("Agent permission update did not return a policy.");return l.policy}async function Ee(t,n,r){const e=T(t),o=new URLSearchParams;o.set("resource_class",r.resource_class),r.entity_type_slug&&o.set("entity_type_slug",r.entity_type_slug),r.operation_key&&o.set("operation_key",r.operation_key),r.target_agent_id&&o.set("target_agent_id",r.target_agent_id);const l=await O(`${ee(e.slug,n)}?${o.toString()}`,{method:"DELETE",credentials:"include"});if(!l.ok)throw await A(l);return(await l.json()).deleted===!0}function te(t){return`${ie}/api/${t}/write-permissions`}function me(t){return["write-permissions",typeof t=="string"?t:t?.slug??null]}function Se(t,n){return ae({queryKey:me(t),enabled:n?.enabled??!0,queryFn:async()=>{const r=T(t??void 0),e=await O(te(r.slug),{credentials:"include"});if(!e.ok)throw await A(e);return await e.json()},staleTime:3e4})}async function $e(t,n){const r=T(t),e=await O(te(r.slug),{method:"PUT",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(n)});if(!e.ok)throw await A(e);const o=await e.json();if(!o.policy)throw new Error("Org write permission update did not return a policy.");return o.policy}async function Te(t,n){const r=T(t),e=new URLSearchParams;e.set("resource_class",n.resource_class),n.entity_type_slug&&e.set("entity_type_slug",n.entity_type_slug),n.operation_key&&e.set("operation_key",n.operation_key),n.target_agent_id&&e.set("target_agent_id",n.target_agent_id);const o=await O(`${te(r.slug)}?${e.toString()}`,{method:"DELETE",credentials:"include"});if(!o.ok)throw await A(o);return(await o.json()).deleted===!0}const U={entity:["read","create","update","delete"],agent_config:["read","create","update","delete"],connector_action:["execute"],entity_schema:["create_type","update_type","delete_type","create_relationship_type","update_relationship_type","delete_relationship_type"]},Oe={entity:{read:"auto",create:"auto",update:"auto",delete:"approval"},agent_config:{read:"auto",create:"approval",update:"approval",delete:"deny"},connector_action:{execute:"auto"},entity_schema:{create_type:"auto",update_type:"auto",delete_type:"auto",create_relationship_type:"auto",update_relationship_type:"auto",delete_relationship_type:"auto"}};function Ae(t,n){return(t==="entity"||t==="agent_config")&&n==="read"?["auto","deny"]:Ce[t]}const Ce={entity:["auto","approval","deny"],agent_config:["auto","approval","deny"],connector_action:["auto","approval","deny","disabled"],entity_schema:["auto","approval","deny"]},pe={auto:"Auto",approval:"Approval",deny:"Deny",disabled:"Disabled"},Re={auto:"Auto-approve",approval:"Requires approval",deny:"Deny",disabled:"Disabled"};function H(t,n){return t.effects?.[n]}function Fe(t,n){return $[t]<$[n]}function q(t,n){return $[t]!==$[n]?$[t]>$[n]?t:n:t==="deny"||n==="deny"?"deny":t}function ne(t,n,r,e,o=null,l=null){let c=null;for(const a of t){if(a.resource_class!==n||a.field_path!==null||a.entity_id!==null||a.entity_type_slug!==null&&a.entity_type_slug!==e||a.operation_key!==null&&a.operation_key!==o||a.target_agent_id!==null&&a.target_agent_id!==l)continue;const m=H(a,r);m&&(c=c===null?m:q(c,m))}return c??Oe[n]?.[r]??"deny"}function se(t,n,r,e,o=null,l=null){return t.some(c=>c.resource_class!==n||c.field_path!==null||c.entity_id!==null||c.entity_type_slug!==null&&c.entity_type_slug!==e||c.operation_key!==null&&c.operation_key!==o||c.target_agent_id!==null&&c.target_agent_id!==l?!1:H(c,r)!==void 0)}function Le(t,n,r){const e=W(t,n,null);return e?H(e,r)!==void 0:!1}function W(t,n,r,e=null,o=null){return t.find(l=>l.resource_class===n&&(l.entity_type_slug??null)===r&&(l.operation_key??null)===e&&(l.target_agent_id??null)===o)}function Pe(t,n,r,e=null,o=null){const l=W(t.agent,n,r,e,o),c={};if(!l?.effects)return c;for(const a of U[n]){const m=l.effects[a];m&&(c[a]=m)}return c}function h(t,n,r,e,o=null,l=null){const c=ne(t.floor,n,r,e,o,l),a=se(t.floor,n,r,e,o,l),m=e!==null||o!==null||l!==null?W(t.agent,n,e,o,l):void 0,j=W(t.agent,n,null);let p=null;for(const v of[j,m]){const x=v&&H(v,r);x&&(p=p===null?x:q(p,x))}return p===null?c:a?q(p,c):p}function Me(t){const{option:n,floor:r}=t;return Fe(n,r)?{disabled:!0,reason:`Below org floor (${Re[r]})`}:{disabled:!1}}function De(t){const n=new Set;for(const e of t.agent)e.resource_class==="entity"&&e.entity_type_slug&&n.add(e.entity_type_slug);for(const e of t.floor)e.resource_class==="entity"&&e.entity_type_slug&&e.field_path===null&&e.entity_id===null&&n.add(e.entity_type_slug);const r=new Map(t.entity_types.map(e=>[e.slug,e]));return[...n].map(e=>r.get(e)??{slug:e,name:e})}function Be(t,n){return t.agent.some(r=>r.resource_class==="entity"&&r.entity_type_slug===n)}function Qe(t,n){let r=0;for(const e of U.entity){const o=h(t,"entity",e,null);h(t,"entity",e,n)!==o&&(r+=1)}return r}function qe(t){const n=new Set;for(const e of t.agent)e.resource_class==="connector_action"&&e.operation_key&&n.add(e.operation_key);for(const e of t.floor)e.resource_class==="connector_action"&&e.operation_key&&n.add(e.operation_key);const r=new Map(t.connector_operations.map(e=>[e.operation_key,e]));return[...n].map(e=>r.get(e)??{operation_key:e,name:e,connector_key:e.split("::")[0]??e,connector_name:e.split("::")[0]??e})}function We(t,n){return t.agent.some(r=>r.resource_class==="connector_action"&&r.operation_key===n)}function Ue(t,n){const r=h(t,"connector_action","execute",null),e=h(t,"connector_action","execute",null,n);return r!==e}function He(t){const n=new Set;for(const e of t.agent)e.resource_class==="agent_config"&&e.target_agent_id&&n.add(e.target_agent_id);for(const e of t.floor)e.resource_class==="agent_config"&&e.target_agent_id&&n.add(e.target_agent_id);const r=new Map(t.agents.map(e=>[e.id,e]));return[...n].map(e=>r.get(e)??{id:e,name:e})}function Ge(t,n){return t.agent.some(r=>r.resource_class==="agent_config"&&r.target_agent_id===n)}function Je(t,n){let r=0;for(const e of U.agent_config){const o=h(t,"agent_config",e,null);h(t,"agent_config",e,null,null,n)!==o&&(r+=1)}return r}const Ke={auto:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",approval:"bg-amber-500/15 text-amber-600 dark:text-amber-400",deny:"bg-red-500/15 text-red-600 dark:text-red-400",disabled:"bg-muted text-foreground"},Xe={auto:"Auto",approval:"Ask",deny:"Deny",disabled:"Off"};function Ze({options:t,value:n,floor:r,onChange:e,disabled:o,ariaLabel:l,compact:c}){return s.jsx("div",{role:"radiogroup","aria-label":l,className:Q("inline-flex shrink-0 items-stretch gap-0.5 rounded-lg border border-border bg-muted/40 p-0.5"),children:t.map(a=>{const m=Me({option:a,floor:r}),j=a===n,p=m.disabled&&!j,v=c?Xe[a]:pe[a],x=s.jsx("button",{type:"button",role:"radio","aria-checked":j,disabled:o||p,onClick:()=>{!j&&!p&&!o&&e(a)},className:Q("inline-flex shrink-0 items-center justify-center whitespace-nowrap font-medium transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",c?"min-w-[3rem] rounded-md px-2.5 py-1.5 text-xs leading-none":"min-w-[3.25rem] rounded-md px-3 py-1.5 text-sm leading-none",j?Q(Ke[a],""):"text-muted-foreground hover:bg-background/60 hover:text-foreground",p&&"cursor-not-allowed opacity-40",o&&!p&&"cursor-not-allowed opacity-60"),children:v},a);return p&&m.reason?s.jsxs(le,{children:[s.jsx(ce,{asChild:!0,children:s.jsx("span",{className:"inline-flex shrink-0",children:x})}),s.jsx(ue,{children:m.reason})]},a):x})})}const ze=[{resourceClass:"entity",title:"Entities",sub:"Defaults for every type · exceptions below"},{resourceClass:"connector_action",title:"Connector writes",sub:"Write ops only · reads follow the connection"},{resourceClass:"agent_config",title:"Agents",sub:"Read peers · create / edit / delete · exceptions below"}];function Ve(t,n,r,e,o=null,l=null){const c=ne(t.floor,n,r,e,o,l),a=se(t.floor,n,r,e,o,l)?c:"auto";return(e!==null||o!==null||l!==null)&&Le(t.agent,n,r)?q(a,h(t,n,r,null)):a}function B({response:t,resourceClass:n,action:r,entityTypeSlug:e,operationKey:o=null,targetAgentId:l=null,dimmed:c,pending:a,onSave:m}){const j=ne(t.floor,n,r,e,o,l),p=se(t.floor,n,r,e,o,l),v=h(t,n,r,e,o,l),x=Ve(t,n,r,e,o,l),w=Ae(n,r),y=e??o??l??"default",E=s.jsx("div",{className:Q("inline-flex shrink-0",c&&"opacity-45"),children:s.jsx(Ze,{options:w,value:v,floor:x,disabled:a,compact:!0,ariaLabel:`${y} ${r}`,onChange:m})});return p?s.jsxs(le,{children:[s.jsx(ce,{asChild:!0,children:s.jsx("span",{className:"inline-flex shrink-0",children:E})}),s.jsxs(ue,{children:["Org floor ",pe[j]," — can only go stricter"]})]}):E}function Ye(t,n){const r=o=>o.resource_class===n.resource_class&&(o.entity_type_slug??null)===(n.entity_type_slug??null)&&(o.operation_key??null)===(n.operation_key??null)&&(o.target_agent_id??null)===(n.target_agent_id??null),e=t.map(o=>r(o)?n:o);return e.some(r)?e:[...e,n]}function Ie(t,n,r,e,o,l,c){const a=Pe(t,n,r,e,o);return a[l]=c,a}const V="font-medium text-foreground hover:text-primary hover:underline";function et({type:t}){return s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(de,{icon:t.icon,className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"font-medium",children:t.name}),s.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:t.slug})]})}function Y({label:t,disabled:n,hint:r,searchPlaceholder:e,emptyText:o,children:l}){return n?s.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:[t,r?` ${r}`:""]}):s.jsx(be,{contentClassName:"w-[min(100vw-2rem,22rem)]",searchPlaceholder:e,emptyText:o,trigger:c=>s.jsxs("button",{type:"button","aria-expanded":c,className:"flex w-full items-center gap-1.5 px-3 py-1.5 text-left text-xs text-primary hover:bg-muted/50",children:[s.jsx(ke,{className:"h-3 w-3"}),t]}),children:c=>l(c)})}function I({pending:t,onClick:n,label:r}){return s.jsx("button",{type:"button",disabled:t,onClick:n,"aria-label":r,className:"rounded p-0.5 text-muted-foreground hover:bg-red-500/10 hover:text-red-600 disabled:opacity-50 dark:hover:text-red-400",children:s.jsx(ve,{className:"h-3 w-3"})})}function R(t,n){const c=`repeat(${t}, minmax(${10.25}rem, 1fr))`;return{gridTemplateColumns:n?`minmax(${5.5}rem, 8rem) ${c} ${1.5}rem`:`minmax(${5.5}rem, 8rem) ${c}`,minWidth:`${5.5+t*10.25+1.5+2}rem`}}function nt({owner:t,agentId:n,variant:r="agent"}){const e=r==="org-floor",o=ye(),l=Ne(t,n??"",{enabled:!e&&!!n}),c=Se(t,{enabled:e}),{data:a,isLoading:m,isError:j,error:p}=e?c:l,v=e?me(t):fe(t,n??""),x=re({mutationFn:u=>e?$e(t,u):we(t,n??"",u),onSuccess:u=>{o.setQueryData(v,f=>f&&{...f,agent:Ye(f.agent,u)}),o.invalidateQueries({queryKey:v}),e&&o.invalidateQueries({queryKey:["agent-permissions"]})},onError:u=>{oe.error(u instanceof Error?u.message:"Failed to save permission")}}),w=re({mutationFn:u=>e?Te(t,u):Ee(t,n??"",u),onSuccess:()=>{o.invalidateQueries({queryKey:v}),e&&o.invalidateQueries({queryKey:["agent-permissions"]})},onError:u=>{oe.error(u instanceof Error?u.message:"Failed to remove override")}}),y=x.isPending||w.isPending,E=S.useMemo(()=>a?De(a):[],[a]),G=S.useMemo(()=>{if(!a)return[];const u=new Set(E.map(f=>f.slug));return a.entity_types.filter(f=>!u.has(f.slug))},[a,E]),J=S.useMemo(()=>a?qe(a):[],[a]),K=S.useMemo(()=>{if(!a)return[];const u=new Set(J.map(f=>f.operation_key));return a.connector_operations.filter(f=>!u.has(f.operation_key))},[a,J]),F=S.useMemo(()=>a?He(a):[],[a]),L=S.useMemo(()=>{if(!a)return[];const u=new Set(F.map(f=>f.id));return a.agents.filter(f=>(e||f.id!==n)&&!u.has(f.id))},[a,F,n,e]);if(m)return s.jsx(he,{label:"permissions",variant:"cards",cards:2});if(j||!a)return s.jsx(je,{label:p instanceof Error?p.message:"permissions"});const g=a,P=(u,f,M,D,b=null,k=null)=>{const i=Ie(g,u,f,b,k,M,D);x.mutate({resource_class:u,effects:i,entity_type_slug:f,operation_key:b,target_agent_id:k})},ge=g.entity_types.length===0?"— none yet":G.length===0?"— all covered":null,_e=g.connector_operations.length===0?"— none installed":K.length===0?"— all covered":null,xe=L.length===0&&F.length===0?"— no other agents":L.length===0?"— all covered":null;return s.jsx("div",{className:"space-y-2",children:ze.map(u=>{const f=u.resourceClass==="entity",M=u.resourceClass==="connector_action",D=u.resourceClass==="agent_config",b=U[u.resourceClass],k=b.length;return s.jsxs("section",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-baseline gap-2 px-0.5",children:[s.jsx("h3",{className:"text-sm font-semibold text-foreground",children:u.title}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:u.sub})]}),s.jsxs("div",{className:"",children:[s.jsxs("div",{className:"grid items-center gap-x-3 rounded-md bg-muted/50 px-3 py-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",style:R(k,!0),children:[s.jsx("span",{}),b.map(i=>s.jsx("span",{className:"text-center",children:i},i)),s.jsx("span",{})]}),s.jsxs("div",{className:"grid items-center gap-x-3 px-3 py-1.5",style:R(k,!0),children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:"Default"}),b.map(i=>s.jsx("div",{className:"flex min-w-0 justify-center overflow-visible",children:s.jsx(B,{response:g,resourceClass:u.resourceClass,action:i,entityTypeSlug:null,pending:y,onSave:d=>P(u.resourceClass,null,i,d)})},i)),s.jsx("span",{})]}),f?E.map(i=>{const d=Be(g,i.slug),N=Qe(g,i.slug);return s.jsxs("div",{className:"grid items-center gap-x-3 px-3 py-1.5",style:R(k,!0),children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(de,{icon:i.icon,className:"h-3.5 w-3.5 shrink-0"}),s.jsx(Z,{to:"/$owner/entity-types/$slug",params:{owner:t,slug:i.slug},className:V,title:`Open ${i.name}`,children:s.jsx("span",{className:"truncate text-sm",children:i.name})}),d?N>0?s.jsxs("span",{className:"shrink-0 text-[10px] text-amber-600 dark:text-amber-400",children:[N,"≠"]}):null:s.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:"floor"})]}),b.map(_=>{const C=h(g,"entity",_,i.slug)===h(g,"entity",_,null);return s.jsx("div",{className:"flex min-w-0 justify-center",children:s.jsx(B,{response:g,resourceClass:"entity",action:_,entityTypeSlug:i.slug,dimmed:C,pending:y,onSave:X=>P("entity",i.slug,_,X)})},_)}),d?s.jsx(I,{pending:y,label:`Remove ${i.name} exception`,onClick:()=>w.mutate({resource_class:"entity",entity_type_slug:i.slug})}):s.jsx("span",{})]},i.slug)}):null,M?J.map(i=>{const d=We(g,i.operation_key),N=Ue(g,i.operation_key);return s.jsxs("div",{className:"grid items-center gap-x-3 px-3 py-1.5",style:R(k,!0),children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-0",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(Z,{to:"/$owner/connectors/$connectorKey",params:{owner:t,connectorKey:i.connector_key},className:V,title:`Open ${i.connector_name}`,children:s.jsx("span",{className:"truncate font-mono text-sm",children:i.name})}),i.destructive?s.jsx("span",{className:"shrink-0 text-[10px] text-amber-600 dark:text-amber-400",children:"!"}):null,d?N?s.jsx("span",{className:"shrink-0 text-[10px] text-amber-600 dark:text-amber-400",children:"≠"}):null:s.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:"floor"})]}),s.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:i.connector_name})]}),b.map(_=>s.jsx("div",{className:"flex min-w-0 justify-center",children:s.jsx(B,{response:g,resourceClass:"connector_action",action:_,entityTypeSlug:null,operationKey:i.operation_key,dimmed:!N,pending:y,onSave:C=>P("connector_action",null,_,C,i.operation_key)})},_)),d?s.jsx(I,{pending:y,label:`Remove ${i.name} exception`,onClick:()=>w.mutate({resource_class:"connector_action",operation_key:i.operation_key})}):s.jsx("span",{})]},i.operation_key)}):null,D?F.map(i=>{const d=Ge(g,i.id),N=Je(g,i.id);return s.jsxs("div",{className:"grid items-center gap-x-3 px-3 py-1.5",style:R(k,!0),children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(Z,{to:"/$owner/agents/$agentId/settings",params:{owner:t,agentId:i.id},search:{run_id:void 0},className:V,title:`Open ${i.name}`,children:s.jsx("span",{className:"truncate text-sm",children:i.name})}),d?N>0?s.jsxs("span",{className:"shrink-0 text-[10px] text-amber-600 dark:text-amber-400",children:[N,"≠"]}):null:s.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:"floor"})]}),b.map(_=>{if(_==="create")return s.jsx("div",{className:"text-center text-[10px] text-muted-foreground",children:"—"},_);const C=h(g,"agent_config",_,null,null,i.id)===h(g,"agent_config",_,null);return s.jsx("div",{className:"flex min-w-0 justify-center",children:s.jsx(B,{response:g,resourceClass:"agent_config",action:_,entityTypeSlug:null,targetAgentId:i.id,dimmed:C,pending:y,onSave:X=>P("agent_config",null,_,X,null,i.id)})},_)}),d?s.jsx(I,{pending:y,label:`Remove ${i.name} exception`,onClick:()=>w.mutate({resource_class:"agent_config",target_agent_id:i.id})}):s.jsx("span",{})]},i.id)}):null,s.jsxs("div",{className:"border-t",children:[f?s.jsx(Y,{label:"Add type",disabled:y||G.length===0,hint:ge,searchPlaceholder:"Search types…",emptyText:"No matching types.",children:i=>G.map(d=>s.jsx(z,{value:`${d.name} ${d.slug}`,onSelect:()=>{x.mutate({resource_class:"entity",effects:{},entity_type_slug:d.slug}),i()},className:"cursor-pointer",children:s.jsx(et,{type:d})},d.slug))}):null,M?s.jsx(Y,{label:"Add operation",disabled:y||K.length===0,hint:_e,searchPlaceholder:"Search ops…",emptyText:"No matching ops.",children:i=>K.map(d=>s.jsx(z,{value:`${d.name} ${d.connector_name} ${d.operation_key}`,onSelect:()=>{x.mutate({resource_class:"connector_action",effects:{},operation_key:d.operation_key}),i()},className:"cursor-pointer",children:s.jsxs("span",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:"truncate text-sm font-medium",children:d.name}),s.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:d.connector_name})]})},d.operation_key))}):null,D?s.jsx(Y,{label:"Add agent",disabled:y||L.length===0,hint:xe,searchPlaceholder:"Search agents…",emptyText:"No matching agents.",children:i=>L.map(d=>s.jsxs(z,{value:`${d.name} ${d.id}`,onSelect:()=>{x.mutate({resource_class:"agent_config",effects:{},target_agent_id:d.id}),i()},className:"cursor-pointer",children:[s.jsx("span",{className:"font-medium",children:d.name}),s.jsx("span",{className:"ml-1.5 font-mono text-[10px] text-muted-foreground",children:d.id})]},d.id))}):null]})]})]},u.resourceClass)})})}export{nt as A,Oe as C,Ze as P,$e as a,Te as d,Ae as e,me as o,Se as u};
@@ -1 +1 @@
1
- import{r as p,aO as B,dQ as ge,dR as pe,gt as be,aG as F,j as ve}from"./index-DdGjY1Hb.js";import{K as E,d as me,g as he,e as xe,s as Ce,f as Ie,h as Se,i as Y,b as ke,c as ye,j as we,k as Re,C as H,l as Ae}from"./core.esm-Ds4Nuq9d.js";import{s as De,b as Ee}from"./skill-editor-D_W3QlRz.js";function G(e,n,t){const r=e.slice();return r.splice(t<0?r.length+t:t,0,r.splice(n,1)[0]),r}function Le(e,n){return e.reduce((t,r,s)=>{const u=n.get(r);return u&&(t[s]=u),t},Array(e.length))}function P(e){return e!==null&&e>=0}function Te(e,n){if(e===n)return!0;if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function Oe(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const V=e=>{let{rects:n,activeIndex:t,overIndex:r,index:s}=e;const u=G(n,r,t),o=n[s],a=u[s];return!a||!o?null:{x:a.left-o.left,y:a.top-o.top,scaleX:a.width/o.width,scaleY:a.height/o.height}},M={scaleX:1,scaleY:1},We=e=>{var n;let{activeIndex:t,activeNodeRect:r,index:s,rects:u,overIndex:o}=e;const a=(n=u[t])!=null?n:r;if(!a)return null;if(s===t){const f=u[o];return f?{x:0,y:t<o?f.top+f.height-(a.top+a.height):f.top-a.top,...M}:null}const m=Ne(u,s,t);return s>t&&s<=o?{x:0,y:-a.height-m,...M}:s<t&&s>=o?{x:0,y:a.height+m,...M}:{x:0,y:0,...M}};function Ne(e,n,t){const r=e[n],s=e[n-1],u=e[n+1];return r?t<n?s?r.top-(s.top+s.height):u?u.top-(r.top+r.height):0:u?u.top-(r.top+r.height):s?r.top-(s.top+s.height):0:0}const W="Sortable",Q=B.createContext({activeIndex:-1,containerId:W,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:V,disabled:{draggable:!1,droppable:!1}});function Qe(e){let{children:n,id:t,items:r,strategy:s=V,disabled:u=!1}=e;const{active:o,dragOverlay:a,droppableRects:m,over:f,measureDroppableContainers:i}=Ie(),l=Se(W,t),b=a.rect!==null,h=p.useMemo(()=>r.map(d=>typeof d=="object"&&"id"in d?d.id:d),[r]),k=o!=null,w=o?h.indexOf(o.id):-1,C=f?h.indexOf(f.id):-1,R=p.useRef(h),I=!Te(h,R.current),S=C!==-1&&w===-1||I,c=Oe(u);Y(()=>{I&&k&&i(h)},[I,h,k,i]),p.useEffect(()=>{R.current=h},[h]);const g=p.useMemo(()=>({activeIndex:w,containerId:l,disabled:c,disableTransforms:S,items:h,overIndex:C,useDragOverlay:b,sortedRects:Le(h,m),strategy:s}),[w,l,c.draggable,c.droppable,S,h,C,m,b,s]);return B.createElement(Q.Provider,{value:g},n)}const Pe=e=>{let{id:n,items:t,activeIndex:r,overIndex:s}=e;return G(t,r,s).indexOf(n)},Me=e=>{let{containerId:n,isSorting:t,wasDragging:r,index:s,items:u,newIndex:o,previousItems:a,previousContainerId:m,transition:f}=e;return!f||!r||a!==u&&s===o?!1:t?!0:o!==s&&n===m},je={duration:200,easing:"ease"},J="transform",$e=H.Transition.toString({property:J,duration:0,easing:"linear"}),ze={roleDescription:"sortable"};function Fe(e){let{disabled:n,index:t,node:r,rect:s}=e;const[u,o]=p.useState(null),a=p.useRef(t);return Y(()=>{if(!n&&t!==a.current&&r.current){const m=s.current;if(m){const f=Ae(r.current,{ignoreTransform:!0}),i={x:m.left-f.left,y:m.top-f.top,scaleX:m.width/f.width,scaleY:m.height/f.height};(i.x||i.y)&&o(i)}}t!==a.current&&(a.current=t)},[n,t,r,s]),p.useEffect(()=>{u&&o(null)},[u]),u}function Je(e){let{animateLayoutChanges:n=Me,attributes:t,disabled:r,data:s,getNewIndex:u=Pe,id:o,strategy:a,resizeObserverConfig:m,transition:f=je}=e;const{items:i,containerId:l,activeIndex:b,disabled:h,disableTransforms:k,sortedRects:w,overIndex:C,useDragOverlay:R,strategy:I}=p.useContext(Q),S=Ge(r,h),c=i.indexOf(o),g=p.useMemo(()=>({sortable:{containerId:l,index:c,items:i},...s}),[l,s,c,i]),d=p.useMemo(()=>i.slice(i.indexOf(o)),[i,o]),{rect:v,node:y,isOver:A,setNodeRef:L}=ke({id:o,data:g,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:d,...m}}),{active:D,activatorEvent:te,activeNodeRect:ne,attributes:re,setNodeRef:K,listeners:se,isDragging:$,over:oe,setActivatorNodeRef:ae,transform:ie}=ye({id:o,data:g,attributes:{...ze,...t},disabled:S.draggable}),le=we(L,K),T=!!D,U=T&&!k&&P(b)&&P(C),X=!R&&$,_=X&&U?ie:null,ce=U?_??(a??I)({rects:w,activeNodeRect:ne,activeIndex:b,overIndex:C,index:c}):null,N=P(b)&&P(C)?u({id:o,items:i,activeIndex:b,overIndex:C}):c,O=D?.id,x=p.useRef({activeId:O,items:i,newIndex:N,containerId:l}),ue=i!==x.current.items,q=n({active:D,containerId:l,isDragging:$,isSorting:T,id:o,index:c,items:i,newIndex:x.current.newIndex,previousItems:x.current.items,previousContainerId:x.current.containerId,transition:f,wasDragging:x.current.activeId!=null}),z=Fe({disabled:!q,index:c,node:y,rect:v});return p.useEffect(()=>{T&&x.current.newIndex!==N&&(x.current.newIndex=N),l!==x.current.containerId&&(x.current.containerId=l),i!==x.current.items&&(x.current.items=i)},[T,N,l,i]),p.useEffect(()=>{if(O===x.current.activeId)return;if(O!=null&&x.current.activeId==null){x.current.activeId=O;return}const fe=setTimeout(()=>{x.current.activeId=O},50);return()=>clearTimeout(fe)},[O]),{active:D,activeIndex:b,attributes:re,data:g,rect:v,index:c,newIndex:N,items:i,isOver:A,isSorting:T,isDragging:$,listeners:se,node:y,overIndex:C,over:oe,setNodeRef:le,setActivatorNodeRef:ae,setDroppableNodeRef:L,setDraggableNodeRef:K,transform:z??ce,transition:de()};function de(){if(z||ue&&x.current.newIndex===c)return $e;if(!(X&&!Re(te)||!f)&&(T||q))return H.Transition.toString({...f,property:J})}}function Ge(e,n){var t,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(t=e?.draggable)!=null?t:n.draggable,droppable:(r=e?.droppable)!=null?r:n.droppable}}function j(e){if(!e)return!1;const n=e.data.current;return!!(n&&"sortable"in n&&typeof n.sortable=="object"&&"containerId"in n.sortable&&"items"in n.sortable&&"index"in n.sortable)}const Ke=[E.Down,E.Right,E.Up,E.Left],Ze=(e,n)=>{let{context:{active:t,collisionRect:r,droppableRects:s,droppableContainers:u,over:o,scrollableAncestors:a}}=n;if(Ke.includes(e.code)){if(e.preventDefault(),!t||!r)return;const m=[];u.getEnabled().forEach(l=>{if(!l||l!=null&&l.disabled)return;const b=s.get(l.id);if(b)switch(e.code){case E.Down:r.top<b.top&&m.push(l);break;case E.Up:r.top>b.top&&m.push(l);break;case E.Left:r.left>b.left&&m.push(l);break;case E.Right:r.left<b.left&&m.push(l);break}});const f=me({collisionRect:r,droppableRects:s,droppableContainers:m});let i=he(f,"id");if(i===o?.id&&f.length>1&&(i=f[1].id),i!=null){const l=u.get(t.id),b=u.get(i),h=b?s.get(b.id):null,k=b?.node.current;if(k&&h&&l&&b){const C=xe(k).some((d,v)=>a[v]!==d),R=Z(l,b),I=Ue(l,b),S=C||!R?{x:0,y:0}:{x:I?r.width-h.width:0,y:I?r.height-h.height:0},c={x:h.left,y:h.top};return S.x&&S.y?c:Ce(c,S)}}}};function Z(e,n){return!j(e)||!j(n)?!1:e.data.current.sortable.containerId===n.data.current.sortable.containerId}function Ue(e,n){return!j(e)||!j(n)||!Z(e,n)?!1:e.data.current.sortable.index<n.data.current.sortable.index}function Xe(e){return{skillsConfig:De(e)}}function _e(e){return e.repo.startsWith("system/")?["System"]:[]}function et(e,n){return e.filter(t=>!t.hidden&&!n.has(t.repo)).map(t=>({key:t.repo,name:t.name,description:t.description||t.instructions||"Add this skill to give the agent tools and capabilities.",badges:_e(t)}))}function tt(e,n){const t=n.trim().toLowerCase();return t?e.filter(r=>r.name.toLowerCase().includes(t)||r.description.toLowerCase().includes(t)||r.key.toLowerCase().includes(t)):e}function qe(e){const n=e.instructions?.trim();return{repo:e.repo,skillId:e.skillId,name:e.name,description:e.description,instructions:n,content:n||e.name,enabled:!0,system:e.repo.startsWith("system/")}}const ee=p.createContext(null);function nt({agentId:e,children:n}){const{data:t,isLoading:r}=ge(e),{data:s,isLoading:u}=pe(e),o=be(e),a=p.useMemo(()=>t?Ee(t,s?.catalog??[]):[],[t,s]),[m,f]=p.useState(null),i=m??a,l=p.useCallback(async(c,g)=>{if(!t)return F.error("Still loading agent settings — try again in a moment"),!1;try{const d=Xe(c);return await o.mutateAsync(d),F.success(g),!0}catch(d){return F.error(d instanceof Error?d.message:"Failed to save skills"),!1}},[t,o]),b=p.useCallback(c=>{const g=s?.catalog.find(d=>d.repo===c);g&&f(d=>{const v=d??a;return v.some(y=>y.repo===c)?v:[...v,qe(g)]})},[a,s?.catalog]),h=p.useCallback(c=>{const g=c.name.trim();if(!g)return null;const d=`custom/${g.toLowerCase().replace(/[^a-z0-9-]/g,"-")}`,v=c.instructions.trim();return f(y=>{const A=y??a;return A.some(L=>L.repo===d)?A:[...A,{repo:d,skillId:g,name:g,instructions:v||void 0,content:v||g,enabled:!0}]}),d},[a]),k=p.useCallback((c,g)=>{f(d=>(d??a).map(v=>v.repo===c?{...v,...g}:v))},[a]),w=p.useCallback((c,g)=>{f(d=>{const v=d??a,y=v.findIndex(D=>D.repo===c),A=v.findIndex(D=>D.repo===g);if(y<0||A<0||y===A)return v;const L=G(v,y,A);return l(L,"Skill order updated"),L})},[l,a]),C=p.useCallback(async c=>{const g=i.filter(d=>d.repo!==c);return f(g),l(g,"Skill removed")},[l,i]),R=p.useCallback(async(c,g)=>{const d=i.map(v=>v.repo===c?{...v,enabled:g}:v);return f(d),l(d,g?"Skill enabled":"Skill disabled")},[l,i]),I=p.useCallback(async()=>{await l(i,"Skills saved")},[l,i]),S=p.useMemo(()=>({agentId:e,skillRows:i,catalog:s,isLoading:r||u,isSaving:o.isPending,addSkillFromCatalog:b,addCustomSkill:h,updateSkillRow:k,reorderSkills:w,removeSkillAndSave:C,setSkillEnabledAndSave:R,saveSkills:I}),[h,b,e,u,r,w,C,R,I,i,s,o.isPending,k]);return ve.jsx(ee.Provider,{value:S,children:n})}function rt(){const e=p.useContext(ee);if(!e)throw new Error("useAgentSkillEditor must be used within AgentSkillEditorProvider");return e}export{nt as A,Qe as S,Ze as a,et as b,Je as c,tt as f,_e as s,rt as u,We as v};
1
+ import{r as p,aO as B,dQ as ge,dR as pe,gt as be,aG as F,j as ve}from"./index-DtRfQcRH.js";import{K as E,d as me,g as he,e as xe,s as Ce,f as Ie,h as Se,i as Y,b as ke,c as ye,j as we,k as Re,C as H,l as Ae}from"./core.esm-C-eNiUAl.js";import{s as De,b as Ee}from"./skill-editor-D_W3QlRz.js";function G(e,n,t){const r=e.slice();return r.splice(t<0?r.length+t:t,0,r.splice(n,1)[0]),r}function Le(e,n){return e.reduce((t,r,s)=>{const u=n.get(r);return u&&(t[s]=u),t},Array(e.length))}function P(e){return e!==null&&e>=0}function Te(e,n){if(e===n)return!0;if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function Oe(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const V=e=>{let{rects:n,activeIndex:t,overIndex:r,index:s}=e;const u=G(n,r,t),o=n[s],a=u[s];return!a||!o?null:{x:a.left-o.left,y:a.top-o.top,scaleX:a.width/o.width,scaleY:a.height/o.height}},M={scaleX:1,scaleY:1},We=e=>{var n;let{activeIndex:t,activeNodeRect:r,index:s,rects:u,overIndex:o}=e;const a=(n=u[t])!=null?n:r;if(!a)return null;if(s===t){const f=u[o];return f?{x:0,y:t<o?f.top+f.height-(a.top+a.height):f.top-a.top,...M}:null}const m=Ne(u,s,t);return s>t&&s<=o?{x:0,y:-a.height-m,...M}:s<t&&s>=o?{x:0,y:a.height+m,...M}:{x:0,y:0,...M}};function Ne(e,n,t){const r=e[n],s=e[n-1],u=e[n+1];return r?t<n?s?r.top-(s.top+s.height):u?u.top-(r.top+r.height):0:u?u.top-(r.top+r.height):s?r.top-(s.top+s.height):0:0}const W="Sortable",Q=B.createContext({activeIndex:-1,containerId:W,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:V,disabled:{draggable:!1,droppable:!1}});function Qe(e){let{children:n,id:t,items:r,strategy:s=V,disabled:u=!1}=e;const{active:o,dragOverlay:a,droppableRects:m,over:f,measureDroppableContainers:i}=Ie(),l=Se(W,t),b=a.rect!==null,h=p.useMemo(()=>r.map(d=>typeof d=="object"&&"id"in d?d.id:d),[r]),k=o!=null,w=o?h.indexOf(o.id):-1,C=f?h.indexOf(f.id):-1,R=p.useRef(h),I=!Te(h,R.current),S=C!==-1&&w===-1||I,c=Oe(u);Y(()=>{I&&k&&i(h)},[I,h,k,i]),p.useEffect(()=>{R.current=h},[h]);const g=p.useMemo(()=>({activeIndex:w,containerId:l,disabled:c,disableTransforms:S,items:h,overIndex:C,useDragOverlay:b,sortedRects:Le(h,m),strategy:s}),[w,l,c.draggable,c.droppable,S,h,C,m,b,s]);return B.createElement(Q.Provider,{value:g},n)}const Pe=e=>{let{id:n,items:t,activeIndex:r,overIndex:s}=e;return G(t,r,s).indexOf(n)},Me=e=>{let{containerId:n,isSorting:t,wasDragging:r,index:s,items:u,newIndex:o,previousItems:a,previousContainerId:m,transition:f}=e;return!f||!r||a!==u&&s===o?!1:t?!0:o!==s&&n===m},je={duration:200,easing:"ease"},J="transform",$e=H.Transition.toString({property:J,duration:0,easing:"linear"}),ze={roleDescription:"sortable"};function Fe(e){let{disabled:n,index:t,node:r,rect:s}=e;const[u,o]=p.useState(null),a=p.useRef(t);return Y(()=>{if(!n&&t!==a.current&&r.current){const m=s.current;if(m){const f=Ae(r.current,{ignoreTransform:!0}),i={x:m.left-f.left,y:m.top-f.top,scaleX:m.width/f.width,scaleY:m.height/f.height};(i.x||i.y)&&o(i)}}t!==a.current&&(a.current=t)},[n,t,r,s]),p.useEffect(()=>{u&&o(null)},[u]),u}function Je(e){let{animateLayoutChanges:n=Me,attributes:t,disabled:r,data:s,getNewIndex:u=Pe,id:o,strategy:a,resizeObserverConfig:m,transition:f=je}=e;const{items:i,containerId:l,activeIndex:b,disabled:h,disableTransforms:k,sortedRects:w,overIndex:C,useDragOverlay:R,strategy:I}=p.useContext(Q),S=Ge(r,h),c=i.indexOf(o),g=p.useMemo(()=>({sortable:{containerId:l,index:c,items:i},...s}),[l,s,c,i]),d=p.useMemo(()=>i.slice(i.indexOf(o)),[i,o]),{rect:v,node:y,isOver:A,setNodeRef:L}=ke({id:o,data:g,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:d,...m}}),{active:D,activatorEvent:te,activeNodeRect:ne,attributes:re,setNodeRef:K,listeners:se,isDragging:$,over:oe,setActivatorNodeRef:ae,transform:ie}=ye({id:o,data:g,attributes:{...ze,...t},disabled:S.draggable}),le=we(L,K),T=!!D,U=T&&!k&&P(b)&&P(C),X=!R&&$,_=X&&U?ie:null,ce=U?_??(a??I)({rects:w,activeNodeRect:ne,activeIndex:b,overIndex:C,index:c}):null,N=P(b)&&P(C)?u({id:o,items:i,activeIndex:b,overIndex:C}):c,O=D?.id,x=p.useRef({activeId:O,items:i,newIndex:N,containerId:l}),ue=i!==x.current.items,q=n({active:D,containerId:l,isDragging:$,isSorting:T,id:o,index:c,items:i,newIndex:x.current.newIndex,previousItems:x.current.items,previousContainerId:x.current.containerId,transition:f,wasDragging:x.current.activeId!=null}),z=Fe({disabled:!q,index:c,node:y,rect:v});return p.useEffect(()=>{T&&x.current.newIndex!==N&&(x.current.newIndex=N),l!==x.current.containerId&&(x.current.containerId=l),i!==x.current.items&&(x.current.items=i)},[T,N,l,i]),p.useEffect(()=>{if(O===x.current.activeId)return;if(O!=null&&x.current.activeId==null){x.current.activeId=O;return}const fe=setTimeout(()=>{x.current.activeId=O},50);return()=>clearTimeout(fe)},[O]),{active:D,activeIndex:b,attributes:re,data:g,rect:v,index:c,newIndex:N,items:i,isOver:A,isSorting:T,isDragging:$,listeners:se,node:y,overIndex:C,over:oe,setNodeRef:le,setActivatorNodeRef:ae,setDroppableNodeRef:L,setDraggableNodeRef:K,transform:z??ce,transition:de()};function de(){if(z||ue&&x.current.newIndex===c)return $e;if(!(X&&!Re(te)||!f)&&(T||q))return H.Transition.toString({...f,property:J})}}function Ge(e,n){var t,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(t=e?.draggable)!=null?t:n.draggable,droppable:(r=e?.droppable)!=null?r:n.droppable}}function j(e){if(!e)return!1;const n=e.data.current;return!!(n&&"sortable"in n&&typeof n.sortable=="object"&&"containerId"in n.sortable&&"items"in n.sortable&&"index"in n.sortable)}const Ke=[E.Down,E.Right,E.Up,E.Left],Ze=(e,n)=>{let{context:{active:t,collisionRect:r,droppableRects:s,droppableContainers:u,over:o,scrollableAncestors:a}}=n;if(Ke.includes(e.code)){if(e.preventDefault(),!t||!r)return;const m=[];u.getEnabled().forEach(l=>{if(!l||l!=null&&l.disabled)return;const b=s.get(l.id);if(b)switch(e.code){case E.Down:r.top<b.top&&m.push(l);break;case E.Up:r.top>b.top&&m.push(l);break;case E.Left:r.left>b.left&&m.push(l);break;case E.Right:r.left<b.left&&m.push(l);break}});const f=me({collisionRect:r,droppableRects:s,droppableContainers:m});let i=he(f,"id");if(i===o?.id&&f.length>1&&(i=f[1].id),i!=null){const l=u.get(t.id),b=u.get(i),h=b?s.get(b.id):null,k=b?.node.current;if(k&&h&&l&&b){const C=xe(k).some((d,v)=>a[v]!==d),R=Z(l,b),I=Ue(l,b),S=C||!R?{x:0,y:0}:{x:I?r.width-h.width:0,y:I?r.height-h.height:0},c={x:h.left,y:h.top};return S.x&&S.y?c:Ce(c,S)}}}};function Z(e,n){return!j(e)||!j(n)?!1:e.data.current.sortable.containerId===n.data.current.sortable.containerId}function Ue(e,n){return!j(e)||!j(n)||!Z(e,n)?!1:e.data.current.sortable.index<n.data.current.sortable.index}function Xe(e){return{skillsConfig:De(e)}}function _e(e){return e.repo.startsWith("system/")?["System"]:[]}function et(e,n){return e.filter(t=>!t.hidden&&!n.has(t.repo)).map(t=>({key:t.repo,name:t.name,description:t.description||t.instructions||"Add this skill to give the agent tools and capabilities.",badges:_e(t)}))}function tt(e,n){const t=n.trim().toLowerCase();return t?e.filter(r=>r.name.toLowerCase().includes(t)||r.description.toLowerCase().includes(t)||r.key.toLowerCase().includes(t)):e}function qe(e){const n=e.instructions?.trim();return{repo:e.repo,skillId:e.skillId,name:e.name,description:e.description,instructions:n,content:n||e.name,enabled:!0,system:e.repo.startsWith("system/")}}const ee=p.createContext(null);function nt({agentId:e,children:n}){const{data:t,isLoading:r}=ge(e),{data:s,isLoading:u}=pe(e),o=be(e),a=p.useMemo(()=>t?Ee(t,s?.catalog??[]):[],[t,s]),[m,f]=p.useState(null),i=m??a,l=p.useCallback(async(c,g)=>{if(!t)return F.error("Still loading agent settings — try again in a moment"),!1;try{const d=Xe(c);return await o.mutateAsync(d),F.success(g),!0}catch(d){return F.error(d instanceof Error?d.message:"Failed to save skills"),!1}},[t,o]),b=p.useCallback(c=>{const g=s?.catalog.find(d=>d.repo===c);g&&f(d=>{const v=d??a;return v.some(y=>y.repo===c)?v:[...v,qe(g)]})},[a,s?.catalog]),h=p.useCallback(c=>{const g=c.name.trim();if(!g)return null;const d=`custom/${g.toLowerCase().replace(/[^a-z0-9-]/g,"-")}`,v=c.instructions.trim();return f(y=>{const A=y??a;return A.some(L=>L.repo===d)?A:[...A,{repo:d,skillId:g,name:g,instructions:v||void 0,content:v||g,enabled:!0}]}),d},[a]),k=p.useCallback((c,g)=>{f(d=>(d??a).map(v=>v.repo===c?{...v,...g}:v))},[a]),w=p.useCallback((c,g)=>{f(d=>{const v=d??a,y=v.findIndex(D=>D.repo===c),A=v.findIndex(D=>D.repo===g);if(y<0||A<0||y===A)return v;const L=G(v,y,A);return l(L,"Skill order updated"),L})},[l,a]),C=p.useCallback(async c=>{const g=i.filter(d=>d.repo!==c);return f(g),l(g,"Skill removed")},[l,i]),R=p.useCallback(async(c,g)=>{const d=i.map(v=>v.repo===c?{...v,enabled:g}:v);return f(d),l(d,g?"Skill enabled":"Skill disabled")},[l,i]),I=p.useCallback(async()=>{await l(i,"Skills saved")},[l,i]),S=p.useMemo(()=>({agentId:e,skillRows:i,catalog:s,isLoading:r||u,isSaving:o.isPending,addSkillFromCatalog:b,addCustomSkill:h,updateSkillRow:k,reorderSkills:w,removeSkillAndSave:C,setSkillEnabledAndSave:R,saveSkills:I}),[h,b,e,u,r,w,C,R,I,i,s,o.isPending,k]);return ve.jsx(ee.Provider,{value:S,children:n})}function rt(){const e=p.useContext(ee);if(!e)throw new Error("useAgentSkillEditor must be used within AgentSkillEditorProvider");return e}export{nt as A,Qe as S,Ze as a,et as b,Je as c,tt as f,_e as s,rt as u,We as v};
@@ -1 +1 @@
1
- import{a4 as w,r as u,j as e,P as F,ac as C,ad as K,dS as P,dT as z,B as N,al as E,aV as G,d$ as H,e0 as Q,bq as V,gA as Y,fL as q,hS as X}from"./index-DdGjY1Hb.js";import{a as J,A as U}from"./agent-subpage-shell-B7tCQ9zd.js";import{u as $,b as W,f as Z,s as ee,a as se,S as te,v as ae,c as le}from"./agent-skill-context-D7tOJ8Pb.js";import{f as ne}from"./agent-loading-shells-DsiGx1fn.js";import{u as ie,a as I,m as oe,P as re,D as ce,n as de,C as me}from"./core.esm-Ds4Nuq9d.js";import{A as ue}from"./agent-card-controls-JubkhcHt.js";const T=":";function A(s){const t=s.indexOf("/");return t<0?s:`${s.slice(0,t)}${T}${s.slice(t+1)}`}function B(s){const t=s.indexOf(T);return t<0?s:`${s.slice(0,t)}/${s.slice(t+1)}`}function ge({owner:s,agentId:t,onBack:a,backLabel:n="Skills"}){const o=w(),[i,g]=u.useState(""),[k,h]=u.useState(!1),[r,p]=u.useState(""),[m,v]=u.useState(""),{skillRows:c,catalog:x,isLoading:S,addSkillFromCatalog:y,addCustomSkill:b}=$(),l=u.useMemo(()=>new Set(c.map(d=>d.repo)),[c]),f=u.useMemo(()=>W(x?.catalog??[],l),[x?.catalog,l]),j=u.useMemo(()=>Z(f,i),[f,i]),R=d=>{y(d),o({to:"/$owner/agents/$agentId/skills/$skillKey",params:{owner:s,agentId:t,skillKey:A(d)}})},O=()=>{const d=b({name:r,instructions:m});d&&o({to:"/$owner/agents/$agentId/skills/$skillKey",params:{owner:s,agentId:t,skillKey:A(d)}})},_=a?e.jsx(J,{title:"Add a skill",description:"Skills bundle instructions, tools, and knowledge an agent can reuse. Pick one from the catalog or create your own.",onBack:a,backLabel:n}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Add a skill"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Skills bundle instructions, tools, and knowledge an agent can reuse. Pick one from the catalog or create your own."})]});return e.jsxs("div",{className:"space-y-6",children:[_,e.jsx("div",{className:E(G,"w-full"),children:k?e.jsxs("div",{className:"space-y-3 p-3",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"custom-skill-name",children:"Name"}),e.jsx(K,{id:"custom-skill-name",value:r,onChange:d=>p(d.target.value),placeholder:"my-skill"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"custom-skill-instructions",children:"Instructions"}),e.jsx(P,{id:"custom-skill-instructions",value:m,onChange:d=>v(d.target.value),placeholder:"Instructions for the agent when this skill is active...",rows:3})]})]}),e.jsx(z,{onCancel:()=>h(!1),children:e.jsx(N,{type:"button",size:"sm",onClick:O,disabled:!r.trim(),children:"Add custom skill"})})]}):e.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 p-3 text-left text-muted-foreground transition-colors hover:text-foreground",onClick:()=>h(!0),children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted",children:e.jsx(F,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Create custom skill"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define instructions and packages"})]})]})}),S?e.jsx(H,{}):e.jsx(Q,{items:j,searchQuery:i,onSearchChange:g,onSelect:d=>R(d.key),searchPlaceholder:"Search skills...",searchAriaLabel:"Search skills",emptyMessage:i.trim()?`No skills match "${i}"`:f.length===0?"All catalog skills are already configured":"No skills available"})]})}function xe({row:s}){const{isSaving:t,updateSkillRow:a}=$(),n=s.system===!0;return e.jsx("div",{className:"space-y-6",children:n?e.jsx("p",{className:"text-sm text-muted-foreground",children:"System skill metadata is managed by Lobu. You can enable or disable it and change its position in the skill list."}):e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"skill-name",children:"Name"}),e.jsx(K,{id:"skill-name",value:s.name,onChange:o=>a(s.repo,{name:o.target.value}),disabled:t})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"skill-instructions",children:"Instructions"}),e.jsx(P,{id:"skill-instructions",value:s.instructions??"",onChange:o=>{const i=o.target.value;a(s.repo,{instructions:i,content:i.trim()||s.name})},rows:4,disabled:t})]})]})})}function he({owner:s,agentId:t,skillKey:a}){const n=w(),[o,i]=u.useState(!1),g=B(a),{skillRows:k,catalog:h,isSaving:r,saveSkills:p,removeSkillAndSave:m,addSkillFromCatalog:v}=$(),c=k.find(b=>b.repo===g)??null,x=h?.catalog.find(b=>b.repo===g);u.useEffect(()=>{!c&&x&&v(g)},[v,x,g,c]);const S=async()=>{await m(g)&&(i(!1),n({to:"/$owner/agents/$agentId/skills",params:{owner:s,agentId:t}}))};if(!c)return x?null:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Skill not found."});const y=!c.system;return e.jsxs("div",{className:"space-y-6",children:[e.jsx(xe,{row:c}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-end",children:[y?o?e.jsxs(e.Fragment,{children:[e.jsx(N,{type:"button",variant:"destructive",onClick:()=>void S(),disabled:r,children:r?"Removing...":"Remove skill"}),e.jsx(N,{type:"button",variant:"outline",onClick:()=>i(!1),disabled:r,children:"Cancel"})]}):e.jsxs(N,{type:"button",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>i(!0),disabled:r,children:["Remove ",c.name]}):null,e.jsx(N,{type:"button",onClick:()=>void p(),disabled:r||o,children:r?"Saving...":"Save changes"})]})]})}function fe(s){return s.map(t=>{const a=ee(t).map(String);return{id:t.repo,repo:t.repo,name:t.name,description:t.description,badges:a,enabled:t.enabled}})}const D="Skills bundle instructions, tools, and knowledge an agent can reuse. Add one from the catalog or write your own; drag to set which the agent reaches for first.";function M({owner:s,agentId:t,expandedRepo:a}){const n=w(),{skillRows:o,catalog:i,isLoading:g,isSaving:k,reorderSkills:h,setSkillEnabledAndSave:r,addSkillFromCatalog:p}=$();u.useEffect(()=>{a&&(o.some(l=>l.repo===a)||i?.catalog.some(l=>l.repo===a)&&p(a))},[a,o,i,p]);const m=u.useMemo(()=>fe(o),[o]),v=u.useMemo(()=>m.map(l=>l.repo),[m]),c=ie(I(re,{activationConstraint:{distance:8}}),I(oe,{coordinateGetter:se})),x=()=>{n({to:"/$owner/agents/$agentId/skills/create",params:{owner:s,agentId:t}})},S=e.jsxs(N,{type:"button",onClick:x,children:[e.jsx(F,{className:"mr-1.5 h-4 w-4"}),"Add skill"]}),y=l=>{if(l===a){n({to:"/$owner/agents/$agentId/skills",params:{owner:s,agentId:t}});return}n({to:"/$owner/agents/$agentId/skills/$skillKey",params:{owner:s,agentId:t,skillKey:A(l)}})},b=l=>{const{active:f,over:j}=l;!j||f.id===j.id||h(String(f.id),String(j.id))};return g?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:D}),e.jsx(ne,{rows:2})]}):m.length===0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:D}),e.jsx(V,{icon:Y,title:"No skills yet",description:"Add a system skill from the catalog or create a custom skill for this agent.",actionLabel:"Add skill",onAction:x})]}):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:"min-w-0 flex-1 text-sm text-muted-foreground",children:D}),S]}),e.jsx(ce,{sensors:c,collisionDetection:de,onDragEnd:b,children:e.jsx(te,{items:v,strategy:ae,children:e.jsx("div",{className:"overflow-hidden rounded-lg border",children:m.map((l,f)=>{const j=l.repo===a;return e.jsx(ke,{card:l,rank:f+1,disabled:k,expanded:j,isLast:f===m.length-1,onToggle:()=>y(l.repo),onToggleEnabled:R=>void r(l.repo,R),toggleDisabled:k,children:j?e.jsx(he,{owner:s,agentId:t,skillKey:A(l.repo)}):null},l.id)})})})})]})}function ke({card:s,rank:t,disabled:a,expanded:n,isLast:o,onToggle:i,onToggleEnabled:g,toggleDisabled:k,children:h}){const r=a||n,{attributes:p,listeners:m,setNodeRef:v,transform:c,transition:x,isDragging:S}=le({id:s.repo,disabled:r}),y={transform:me.Transform.toString(c),transition:x};return e.jsxs("div",{ref:v,style:y,className:E("bg-background",!o||n?"border-b":"",S&&"z-10 bg-card opacity-80 "),children:[e.jsxs("div",{className:"flex items-stretch gap-1 pr-3",children:[e.jsx("button",{type:"button",className:"flex shrink-0 cursor-grab touch-none items-center px-2 text-muted-foreground hover:text-foreground active:cursor-grabbing disabled:cursor-not-allowed disabled:opacity-50","aria-label":`Reorder ${s.name}`,disabled:r,...p,...m,children:e.jsx(q,{className:"h-4 w-4"})}),e.jsxs("button",{type:"button",className:E("flex min-w-0 flex-1 items-center gap-3 py-2.5 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",!s.enabled&&!n&&"opacity-70"),onClick:i,"aria-expanded":n,children:[e.jsx("span",{className:"w-4 shrink-0 text-center text-xs tabular-nums text-muted-foreground",children:t}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:s.name}),s.description?e.jsx("p",{className:"line-clamp-1 text-xs text-muted-foreground",children:s.description}):null,e.jsx(X,{badges:s.badges})]})]}),e.jsx(ue,{enabled:s.enabled,name:s.name,expanded:n,onToggleEnabled:g,toggleDisabled:k,onToggle:i})]}),n&&h?e.jsx("div",{className:"border-t border-border px-4 py-4",children:h}):null]})}function L({owner:s,agentId:t,children:a,showBack:n}){return e.jsx(U,{owner:s,agentId:t,showBack:n,backLabel:"Skills",backTo:"/$owner/agents/$agentId/skills",children:a})}function Ne({owner:s,agentId:t}){return e.jsx(L,{owner:s,agentId:t,children:e.jsx(M,{owner:s,agentId:t})})}function Ce({owner:s,agentId:t}){const a=w();return e.jsx(L,{owner:s,agentId:t,children:e.jsx(ge,{owner:s,agentId:t,onBack:()=>{a({to:"/$owner/agents/$agentId/skills",params:{owner:s,agentId:t}})}})})}function Ae({owner:s,agentId:t,skillKey:a}){return e.jsx(L,{owner:s,agentId:t,children:e.jsx(M,{owner:s,agentId:t,expandedRepo:B(a)})})}export{Ne as A,Ce as a,Ae as b};
1
+ import{a4 as w,r as u,j as e,P as F,ac as C,ad as K,dS as P,dT as z,B as N,al as E,aV as G,d$ as H,e0 as Q,bq as V,gA as Y,fL as q,hS as X}from"./index-DtRfQcRH.js";import{a as J,A as U}from"./agent-subpage-shell-DtzoRy6N.js";import{u as $,b as W,f as Z,s as ee,a as se,S as te,v as ae,c as le}from"./agent-skill-context-s42Q4Wjo.js";import{f as ne}from"./agent-loading-shells-BQLjzMPy.js";import{u as ie,a as I,m as oe,P as re,D as ce,n as de,C as me}from"./core.esm-C-eNiUAl.js";import{A as ue}from"./agent-card-controls-bhTMPoVi.js";const T=":";function A(s){const t=s.indexOf("/");return t<0?s:`${s.slice(0,t)}${T}${s.slice(t+1)}`}function B(s){const t=s.indexOf(T);return t<0?s:`${s.slice(0,t)}/${s.slice(t+1)}`}function ge({owner:s,agentId:t,onBack:a,backLabel:n="Skills"}){const o=w(),[i,g]=u.useState(""),[k,h]=u.useState(!1),[r,p]=u.useState(""),[m,v]=u.useState(""),{skillRows:c,catalog:x,isLoading:S,addSkillFromCatalog:y,addCustomSkill:b}=$(),l=u.useMemo(()=>new Set(c.map(d=>d.repo)),[c]),f=u.useMemo(()=>W(x?.catalog??[],l),[x?.catalog,l]),j=u.useMemo(()=>Z(f,i),[f,i]),R=d=>{y(d),o({to:"/$owner/agents/$agentId/skills/$skillKey",params:{owner:s,agentId:t,skillKey:A(d)}})},O=()=>{const d=b({name:r,instructions:m});d&&o({to:"/$owner/agents/$agentId/skills/$skillKey",params:{owner:s,agentId:t,skillKey:A(d)}})},_=a?e.jsx(J,{title:"Add a skill",description:"Skills bundle instructions, tools, and knowledge an agent can reuse. Pick one from the catalog or create your own.",onBack:a,backLabel:n}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Add a skill"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Skills bundle instructions, tools, and knowledge an agent can reuse. Pick one from the catalog or create your own."})]});return e.jsxs("div",{className:"space-y-6",children:[_,e.jsx("div",{className:E(G,"w-full"),children:k?e.jsxs("div",{className:"space-y-3 p-3",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"custom-skill-name",children:"Name"}),e.jsx(K,{id:"custom-skill-name",value:r,onChange:d=>p(d.target.value),placeholder:"my-skill"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"custom-skill-instructions",children:"Instructions"}),e.jsx(P,{id:"custom-skill-instructions",value:m,onChange:d=>v(d.target.value),placeholder:"Instructions for the agent when this skill is active...",rows:3})]})]}),e.jsx(z,{onCancel:()=>h(!1),children:e.jsx(N,{type:"button",size:"sm",onClick:O,disabled:!r.trim(),children:"Add custom skill"})})]}):e.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 p-3 text-left text-muted-foreground transition-colors hover:text-foreground",onClick:()=>h(!0),children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted",children:e.jsx(F,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Create custom skill"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define instructions and packages"})]})]})}),S?e.jsx(H,{}):e.jsx(Q,{items:j,searchQuery:i,onSearchChange:g,onSelect:d=>R(d.key),searchPlaceholder:"Search skills...",searchAriaLabel:"Search skills",emptyMessage:i.trim()?`No skills match "${i}"`:f.length===0?"All catalog skills are already configured":"No skills available"})]})}function xe({row:s}){const{isSaving:t,updateSkillRow:a}=$(),n=s.system===!0;return e.jsx("div",{className:"space-y-6",children:n?e.jsx("p",{className:"text-sm text-muted-foreground",children:"System skill metadata is managed by Lobu. You can enable or disable it and change its position in the skill list."}):e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"skill-name",children:"Name"}),e.jsx(K,{id:"skill-name",value:s.name,onChange:o=>a(s.repo,{name:o.target.value}),disabled:t})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"skill-instructions",children:"Instructions"}),e.jsx(P,{id:"skill-instructions",value:s.instructions??"",onChange:o=>{const i=o.target.value;a(s.repo,{instructions:i,content:i.trim()||s.name})},rows:4,disabled:t})]})]})})}function he({owner:s,agentId:t,skillKey:a}){const n=w(),[o,i]=u.useState(!1),g=B(a),{skillRows:k,catalog:h,isSaving:r,saveSkills:p,removeSkillAndSave:m,addSkillFromCatalog:v}=$(),c=k.find(b=>b.repo===g)??null,x=h?.catalog.find(b=>b.repo===g);u.useEffect(()=>{!c&&x&&v(g)},[v,x,g,c]);const S=async()=>{await m(g)&&(i(!1),n({to:"/$owner/agents/$agentId/skills",params:{owner:s,agentId:t}}))};if(!c)return x?null:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Skill not found."});const y=!c.system;return e.jsxs("div",{className:"space-y-6",children:[e.jsx(xe,{row:c}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-end",children:[y?o?e.jsxs(e.Fragment,{children:[e.jsx(N,{type:"button",variant:"destructive",onClick:()=>void S(),disabled:r,children:r?"Removing...":"Remove skill"}),e.jsx(N,{type:"button",variant:"outline",onClick:()=>i(!1),disabled:r,children:"Cancel"})]}):e.jsxs(N,{type:"button",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>i(!0),disabled:r,children:["Remove ",c.name]}):null,e.jsx(N,{type:"button",onClick:()=>void p(),disabled:r||o,children:r?"Saving...":"Save changes"})]})]})}function fe(s){return s.map(t=>{const a=ee(t).map(String);return{id:t.repo,repo:t.repo,name:t.name,description:t.description,badges:a,enabled:t.enabled}})}const D="Skills bundle instructions, tools, and knowledge an agent can reuse. Add one from the catalog or write your own; drag to set which the agent reaches for first.";function M({owner:s,agentId:t,expandedRepo:a}){const n=w(),{skillRows:o,catalog:i,isLoading:g,isSaving:k,reorderSkills:h,setSkillEnabledAndSave:r,addSkillFromCatalog:p}=$();u.useEffect(()=>{a&&(o.some(l=>l.repo===a)||i?.catalog.some(l=>l.repo===a)&&p(a))},[a,o,i,p]);const m=u.useMemo(()=>fe(o),[o]),v=u.useMemo(()=>m.map(l=>l.repo),[m]),c=ie(I(re,{activationConstraint:{distance:8}}),I(oe,{coordinateGetter:se})),x=()=>{n({to:"/$owner/agents/$agentId/skills/create",params:{owner:s,agentId:t}})},S=e.jsxs(N,{type:"button",onClick:x,children:[e.jsx(F,{className:"mr-1.5 h-4 w-4"}),"Add skill"]}),y=l=>{if(l===a){n({to:"/$owner/agents/$agentId/skills",params:{owner:s,agentId:t}});return}n({to:"/$owner/agents/$agentId/skills/$skillKey",params:{owner:s,agentId:t,skillKey:A(l)}})},b=l=>{const{active:f,over:j}=l;!j||f.id===j.id||h(String(f.id),String(j.id))};return g?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:D}),e.jsx(ne,{rows:2})]}):m.length===0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:D}),e.jsx(V,{icon:Y,title:"No skills yet",description:"Add a system skill from the catalog or create a custom skill for this agent.",actionLabel:"Add skill",onAction:x})]}):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:"min-w-0 flex-1 text-sm text-muted-foreground",children:D}),S]}),e.jsx(ce,{sensors:c,collisionDetection:de,onDragEnd:b,children:e.jsx(te,{items:v,strategy:ae,children:e.jsx("div",{className:"overflow-hidden rounded-lg border",children:m.map((l,f)=>{const j=l.repo===a;return e.jsx(ke,{card:l,rank:f+1,disabled:k,expanded:j,isLast:f===m.length-1,onToggle:()=>y(l.repo),onToggleEnabled:R=>void r(l.repo,R),toggleDisabled:k,children:j?e.jsx(he,{owner:s,agentId:t,skillKey:A(l.repo)}):null},l.id)})})})})]})}function ke({card:s,rank:t,disabled:a,expanded:n,isLast:o,onToggle:i,onToggleEnabled:g,toggleDisabled:k,children:h}){const r=a||n,{attributes:p,listeners:m,setNodeRef:v,transform:c,transition:x,isDragging:S}=le({id:s.repo,disabled:r}),y={transform:me.Transform.toString(c),transition:x};return e.jsxs("div",{ref:v,style:y,className:E("bg-background",!o||n?"border-b":"",S&&"z-10 bg-card opacity-80 "),children:[e.jsxs("div",{className:"flex items-stretch gap-1 pr-3",children:[e.jsx("button",{type:"button",className:"flex shrink-0 cursor-grab touch-none items-center px-2 text-muted-foreground hover:text-foreground active:cursor-grabbing disabled:cursor-not-allowed disabled:opacity-50","aria-label":`Reorder ${s.name}`,disabled:r,...p,...m,children:e.jsx(q,{className:"h-4 w-4"})}),e.jsxs("button",{type:"button",className:E("flex min-w-0 flex-1 items-center gap-3 py-2.5 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",!s.enabled&&!n&&"opacity-70"),onClick:i,"aria-expanded":n,children:[e.jsx("span",{className:"w-4 shrink-0 text-center text-xs tabular-nums text-muted-foreground",children:t}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:s.name}),s.description?e.jsx("p",{className:"line-clamp-1 text-xs text-muted-foreground",children:s.description}):null,e.jsx(X,{badges:s.badges})]})]}),e.jsx(ue,{enabled:s.enabled,name:s.name,expanded:n,onToggleEnabled:g,toggleDisabled:k,onToggle:i})]}),n&&h?e.jsx("div",{className:"border-t border-border px-4 py-4",children:h}):null]})}function L({owner:s,agentId:t,children:a,showBack:n}){return e.jsx(U,{owner:s,agentId:t,showBack:n,backLabel:"Skills",backTo:"/$owner/agents/$agentId/skills",children:a})}function Ne({owner:s,agentId:t}){return e.jsx(L,{owner:s,agentId:t,children:e.jsx(M,{owner:s,agentId:t})})}function Ce({owner:s,agentId:t}){const a=w();return e.jsx(L,{owner:s,agentId:t,children:e.jsx(ge,{owner:s,agentId:t,onBack:()=>{a({to:"/$owner/agents/$agentId/skills",params:{owner:s,agentId:t}})}})})}function Ae({owner:s,agentId:t,skillKey:a}){return e.jsx(L,{owner:s,agentId:t,children:e.jsx(M,{owner:s,agentId:t,expandedRepo:B(a)})})}export{Ne as A,Ce as a,Ae as b};
@@ -1 +1 @@
1
- import{a4 as m,j as e,al as h,B as n,ez as i}from"./index-DdGjY1Hb.js";function p({owner:t,agentId:a,children:s,showBack:r,backLabel:o,backTo:x,title:c,className:u}){const d=m(),l=()=>{d({to:x,params:{owner:t,agentId:a}})};return e.jsx("div",{className:h("mx-auto w-full max-w-3xl pb-8",u),children:c?e.jsxs(e.Fragment,{children:[e.jsx(j,{title:c,onBack:l,backLabel:o}),s]}):r?e.jsx(g,{onBack:l,backLabel:o,children:s}):s})}function g({onBack:t,backLabel:a,children:s}){return e.jsxs("div",{className:"relative",children:[e.jsx(n,{type:"button",variant:"ghost",size:"icon",className:"absolute right-full top-0 mr-1 size-8 text-muted-foreground hover:text-foreground","aria-label":`Back to ${a}`,onClick:t,children:e.jsx(i,{className:"h-4 w-4"})}),s]})}function j({title:t,onBack:a,backLabel:s,action:r}){return e.jsx("div",{className:"sticky top-0 z-10 mb-2 bg-background py-2",children:e.jsxs("div",{className:"relative flex items-center justify-center gap-1",children:[e.jsx(n,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground","aria-label":`Back to ${s}`,onClick:a,children:e.jsx(i,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate text-base font-semibold",children:t}),r?e.jsx("div",{className:"absolute right-0",children:r}):null]})})}function v({title:t,description:a,onBack:s,backLabel:r}){return e.jsxs("div",{className:"mb-2 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(n,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground","aria-label":`Back to ${r}`,onClick:s,children:e.jsx(i,{className:"h-4 w-4"})}),e.jsx("h1",{className:"text-xl font-semibold",children:t})]}),e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:a})]})}export{p as A,v as a};
1
+ import{a4 as m,j as e,al as h,B as n,ez as i}from"./index-DtRfQcRH.js";function p({owner:t,agentId:a,children:s,showBack:r,backLabel:o,backTo:x,title:c,className:u}){const d=m(),l=()=>{d({to:x,params:{owner:t,agentId:a}})};return e.jsx("div",{className:h("mx-auto w-full max-w-3xl pb-8",u),children:c?e.jsxs(e.Fragment,{children:[e.jsx(j,{title:c,onBack:l,backLabel:o}),s]}):r?e.jsx(g,{onBack:l,backLabel:o,children:s}):s})}function g({onBack:t,backLabel:a,children:s}){return e.jsxs("div",{className:"relative",children:[e.jsx(n,{type:"button",variant:"ghost",size:"icon",className:"absolute right-full top-0 mr-1 size-8 text-muted-foreground hover:text-foreground","aria-label":`Back to ${a}`,onClick:t,children:e.jsx(i,{className:"h-4 w-4"})}),s]})}function j({title:t,onBack:a,backLabel:s,action:r}){return e.jsx("div",{className:"sticky top-0 z-10 mb-2 bg-background py-2",children:e.jsxs("div",{className:"relative flex items-center justify-center gap-1",children:[e.jsx(n,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground","aria-label":`Back to ${s}`,onClick:a,children:e.jsx(i,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate text-base font-semibold",children:t}),r?e.jsx("div",{className:"absolute right-0",children:r}):null]})})}function v({title:t,description:a,onBack:s,backLabel:r}){return e.jsxs("div",{className:"mb-2 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(n,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground","aria-label":`Back to ${r}`,onClick:s,children:e.jsx(i,{className:"h-4 w-4"})}),e.jsx("h1",{className:"text-xl font-semibold",children:t})]}),e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:a})]})}export{p as A,v as a};
@@ -1,4 +1,4 @@
1
- import{j as s,r as l,el as qt,as as Kt,em as Gt,dQ as Jt,ap as ze,ai as Be,aq as st,cc as Qt,en as lt,eo as Xt,L as xt,al as U,cL as Yt,cU as wt,cW as Zt,ep as en,cm as tn,cX as nn,eq as rn,B as ce,er as on,es as sn,et as We,Z as ln,s as an,cV as cn,aV as Ne,eu as un,cj as dn,ck as pn,ev as fn,cn as mn,bM as hn,ew as gn,ex as vn,e8 as yn,bJ as bn,du as xn,dv as wn}from"./index-DdGjY1Hb.js";import{D as Rn,E as Sn}from"./app-bridge-BH3g2mKG.js";import{A as Tn,a as jn,b as Cn,c as Xe,d as Rt,e as Nn}from"./agent-loading-shells-DsiGx1fn.js";import{t as An}from"./pending-seed-CPbfgnLX.js";import{h as En,t as kn,R as _n,i as In,u as On,b as Pn,f as Ln}from"./use-mention-search-CGA3AaKm.js";const St=l.createContext(null);function Mn({extension:e,children:t}){return s.jsx(St.Provider,{value:e??null,children:t})}function Ye(){return l.useContext(St)}var Ze=(e=>(e.PROVIDER_QUOTA_EXHAUSTED="PROVIDER_QUOTA_EXHAUSTED",e.PROVIDER_AUTH="PROVIDER_AUTH",e.PROVIDER_UNKNOWN_MODEL="PROVIDER_UNKNOWN_MODEL",e.PROVIDER_BASE_URL_UNRESOLVED="PROVIDER_BASE_URL_UNRESOLVED",e.NO_MODEL_CONFIGURED="NO_MODEL_CONFIGURED",e.WORKER_UNRESPONSIVE="WORKER_UNRESPONSIVE",e.WORKER_DIED="WORKER_DIED",e.WORKER_STARTUP_FAILED="WORKER_STARTUP_FAILED",e.PROVIDER_TOOL_CALL_FAILED="PROVIDER_TOOL_CALL_FAILED",e.SESSION_TIMEOUT="SESSION_TIMEOUT",e))(Ze||{});const $n={PROVIDER_QUOTA_EXHAUSTED:{cta:"provider-management",ctaLabel:"Manage provider"},PROVIDER_AUTH:{cta:"provider-management",ctaLabel:"Reconnect provider"},PROVIDER_UNKNOWN_MODEL:{cta:"agent-settings",ctaLabel:"Choose model"},PROVIDER_BASE_URL_UNRESOLVED:{cta:"provider-management",ctaLabel:"Manage provider"},PROVIDER_TOOL_CALL_FAILED:{message:"The model provider rejected its own tool call and ended the turn. This is usually temporary — please try again.",cta:"none"},NO_MODEL_CONFIGURED:{message:"No model is configured for this agent. Choose a model in agent settings.",cta:"agent-settings",ctaLabel:"Choose a model"},WORKER_UNRESPONSIVE:{message:"The agent didn't finish responding in time. This is usually temporary — please try again.",cta:"none"},WORKER_DIED:{message:"The agent stopped unexpectedly before it could reply. This is usually temporary — please try again.",cta:"none"},WORKER_STARTUP_FAILED:{message:"The agent couldn't start, so your request wasn't processed. Please try again in a moment.",cta:"none"},SESSION_TIMEOUT:{cta:"none",silent:!0}};function Un(e){if(typeof e=="string")return Object.values(Ze).includes(e)?e:void 0}const Dn=Object.freeze(Object.defineProperty({__proto__:null,AGENT_ERRORS:$n,AgentErrorCode:Ze,toAgentErrorCode:Un},Symbol.toStringTag,{value:"Module"})),{AGENT_ERRORS:Fn,toAgentErrorCode:Vn}=Dn;function it(e,t){if(!t)return null;try{const n=new URL(t);return n.protocol!=="http:"&&n.protocol!=="https:"?null:new URL(e,`${n.origin}/`).toString()}catch{return null}}function Tt(e,t){const n=Vn(e);if(!n)return null;const r=Fn[n];if(r.cta==="none"||!t.workspaceSlug)return null;const o=encodeURIComponent(t.workspaceSlug);if(r.cta==="provider-connect"||r.cta==="provider-management"){const a=t.provider?`/${o}/connectors/${encodeURIComponent(`${qt}${t.provider}`)}`:`/${o}/connectors`,c=it(a,t.webOrigin);if(!c)return null;const u=new URL(c);return t.provider&&t.model&&u.searchParams.set("model",t.model),{label:r.ctaLabel??"Connect a provider",href:u.toString()}}if(!t.agentId)return null;const i=it(`/${o}/agents/${encodeURIComponent(t.agentId)}/settings`,t.webOrigin);return i?{label:r.ctaLabel??"Open settings",href:i}:null}function jt(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.subscribable;if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t;if(typeof n.connector_key!="string"||!n.connector_key||typeof n.resource_type!="string"||!n.resource_type||typeof n.resource_ref!="string"||!n.resource_ref||typeof n.label!="string"||!n.label)return null;const r=Array.isArray(n.suggested_event_keys)?n.suggested_event_keys.filter(o=>typeof o=="string"&&!!o):void 0;return{connector_key:n.connector_key,resource_type:n.resource_type,resource_ref:n.resource_ref,label:n.label,...r?.length?{suggested_event_keys:r}:{}}}const at=new Set(["localhost","127.0.0.1","::1","[::1]"]);function Bn(e){return e?.trim().toLowerCase().replace(/^\.+|\.+$/g,"")||null}function ct(e,t){const n=Bn(t);if(!n)return!1;const r=e.toLowerCase().replace(/\.$/,"");return r===n||r.endsWith(`.${n}`)}function ut(e,t,n){try{const r=new URL(t),o=new URL(e,t),i=at.has(o.hostname)&&at.has(r.hostname),a=o.protocol===r.protocol&&(o.protocol==="https:"||o.protocol==="http:")&&ct(o.hostname,n)&&ct(r.hostname,n);return o.origin!==r.origin&&(i||a)&&(o.protocol=r.protocol,o.host=r.host),o.origin===r.origin&&o.pathname.startsWith("/api/v1/agents")&&(o.pathname=`/lobu${o.pathname}`),o.toString()}catch{return e}}const Hn=/\.(png|jpe?g|gif|webp|avif|bmp|svg)$/i,Ct=new Set(["suggest_actions"]),Me="Thinking…";function zn(e){const{textOut:t,statusLine:n,errorText:r,toolCalls:o}=e,i=[];n===Me&&i.push({type:"reasoning"}),r&&i.push({type:"error",text:r});let a=t;return n&&n!==Me&&(a=t?`${t}
1
+ import{j as s,r as l,el as qt,as as Kt,em as Gt,dQ as Jt,ap as ze,ai as Be,aq as st,cc as Qt,en as lt,eo as Xt,L as xt,al as U,cL as Yt,cU as wt,cW as Zt,ep as en,cm as tn,cX as nn,eq as rn,B as ce,er as on,es as sn,et as We,Z as ln,s as an,cV as cn,aV as Ne,eu as un,cj as dn,ck as pn,ev as fn,cn as mn,bM as hn,ew as gn,ex as vn,e8 as yn,bJ as bn,du as xn,dv as wn}from"./index-DtRfQcRH.js";import{D as Rn,E as Sn}from"./app-bridge-BH3g2mKG.js";import{A as Tn,a as jn,b as Cn,c as Xe,d as Rt,e as Nn}from"./agent-loading-shells-BQLjzMPy.js";import{t as An}from"./pending-seed-CPbfgnLX.js";import{h as En,t as kn,R as _n,i as In,u as On,b as Pn,f as Ln}from"./use-mention-search-CeTEE3oE.js";const St=l.createContext(null);function Mn({extension:e,children:t}){return s.jsx(St.Provider,{value:e??null,children:t})}function Ye(){return l.useContext(St)}var Ze=(e=>(e.PROVIDER_QUOTA_EXHAUSTED="PROVIDER_QUOTA_EXHAUSTED",e.PROVIDER_AUTH="PROVIDER_AUTH",e.PROVIDER_UNKNOWN_MODEL="PROVIDER_UNKNOWN_MODEL",e.PROVIDER_BASE_URL_UNRESOLVED="PROVIDER_BASE_URL_UNRESOLVED",e.NO_MODEL_CONFIGURED="NO_MODEL_CONFIGURED",e.WORKER_UNRESPONSIVE="WORKER_UNRESPONSIVE",e.WORKER_DIED="WORKER_DIED",e.WORKER_STARTUP_FAILED="WORKER_STARTUP_FAILED",e.PROVIDER_TOOL_CALL_FAILED="PROVIDER_TOOL_CALL_FAILED",e.SESSION_TIMEOUT="SESSION_TIMEOUT",e))(Ze||{});const $n={PROVIDER_QUOTA_EXHAUSTED:{cta:"provider-management",ctaLabel:"Manage provider"},PROVIDER_AUTH:{cta:"provider-management",ctaLabel:"Reconnect provider"},PROVIDER_UNKNOWN_MODEL:{cta:"agent-settings",ctaLabel:"Choose model"},PROVIDER_BASE_URL_UNRESOLVED:{cta:"provider-management",ctaLabel:"Manage provider"},PROVIDER_TOOL_CALL_FAILED:{message:"The model provider rejected its own tool call and ended the turn. This is usually temporary — please try again.",cta:"none"},NO_MODEL_CONFIGURED:{message:"No model is configured for this agent. Choose a model in agent settings.",cta:"agent-settings",ctaLabel:"Choose a model"},WORKER_UNRESPONSIVE:{message:"The agent didn't finish responding in time. This is usually temporary — please try again.",cta:"none"},WORKER_DIED:{message:"The agent stopped unexpectedly before it could reply. This is usually temporary — please try again.",cta:"none"},WORKER_STARTUP_FAILED:{message:"The agent couldn't start, so your request wasn't processed. Please try again in a moment.",cta:"none"},SESSION_TIMEOUT:{cta:"none",silent:!0}};function Un(e){if(typeof e=="string")return Object.values(Ze).includes(e)?e:void 0}const Dn=Object.freeze(Object.defineProperty({__proto__:null,AGENT_ERRORS:$n,AgentErrorCode:Ze,toAgentErrorCode:Un},Symbol.toStringTag,{value:"Module"})),{AGENT_ERRORS:Fn,toAgentErrorCode:Vn}=Dn;function it(e,t){if(!t)return null;try{const n=new URL(t);return n.protocol!=="http:"&&n.protocol!=="https:"?null:new URL(e,`${n.origin}/`).toString()}catch{return null}}function Tt(e,t){const n=Vn(e);if(!n)return null;const r=Fn[n];if(r.cta==="none"||!t.workspaceSlug)return null;const o=encodeURIComponent(t.workspaceSlug);if(r.cta==="provider-connect"||r.cta==="provider-management"){const a=t.provider?`/${o}/connectors/${encodeURIComponent(`${qt}${t.provider}`)}`:`/${o}/connectors`,c=it(a,t.webOrigin);if(!c)return null;const u=new URL(c);return t.provider&&t.model&&u.searchParams.set("model",t.model),{label:r.ctaLabel??"Connect a provider",href:u.toString()}}if(!t.agentId)return null;const i=it(`/${o}/agents/${encodeURIComponent(t.agentId)}/settings`,t.webOrigin);return i?{label:r.ctaLabel??"Open settings",href:i}:null}function jt(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.subscribable;if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t;if(typeof n.connector_key!="string"||!n.connector_key||typeof n.resource_type!="string"||!n.resource_type||typeof n.resource_ref!="string"||!n.resource_ref||typeof n.label!="string"||!n.label)return null;const r=Array.isArray(n.suggested_event_keys)?n.suggested_event_keys.filter(o=>typeof o=="string"&&!!o):void 0;return{connector_key:n.connector_key,resource_type:n.resource_type,resource_ref:n.resource_ref,label:n.label,...r?.length?{suggested_event_keys:r}:{}}}const at=new Set(["localhost","127.0.0.1","::1","[::1]"]);function Bn(e){return e?.trim().toLowerCase().replace(/^\.+|\.+$/g,"")||null}function ct(e,t){const n=Bn(t);if(!n)return!1;const r=e.toLowerCase().replace(/\.$/,"");return r===n||r.endsWith(`.${n}`)}function ut(e,t,n){try{const r=new URL(t),o=new URL(e,t),i=at.has(o.hostname)&&at.has(r.hostname),a=o.protocol===r.protocol&&(o.protocol==="https:"||o.protocol==="http:")&&ct(o.hostname,n)&&ct(r.hostname,n);return o.origin!==r.origin&&(i||a)&&(o.protocol=r.protocol,o.host=r.host),o.origin===r.origin&&o.pathname.startsWith("/api/v1/agents")&&(o.pathname=`/lobu${o.pathname}`),o.toString()}catch{return e}}const Hn=/\.(png|jpe?g|gif|webp|avif|bmp|svg)$/i,Ct=new Set(["suggest_actions"]),Me="Thinking…";function zn(e){const{textOut:t,statusLine:n,errorText:r,toolCalls:o}=e,i=[];n===Me&&i.push({type:"reasoning"}),r&&i.push({type:"error",text:r});let a=t;return n&&n!==Me&&(a=t?`${t}
2
2
 
3
3
  ${n}`:n),a&&i.push({type:"text",text:a}),i.push(...o),i}const et=l.createContext(null);function Ae(){const e=l.useContext(et);if(!e)throw new Error("useLobuChat must be used within <LobuChatProvider>");return e}function $o({messages:e,children:t}){const n=l.useMemo(()=>({messages:e,running:!1,append:()=>{},cancel:()=>{},pendingAttachments:[],addAttachments:()=>{},removeAttachment:()=>{},agentId:null,conversationId:"",workspaceSlug:null,currentSuggestions:null}),[e]);return s.jsx(et.Provider,{value:n,children:t})}const Nt=/\[([^\]]*)\]\((\S*?\/api\/v1\/files\/[^)\s]+)\)/g;function dt(e){return e.replace(/<lobu_internal_context>[\s\S]*?<\/lobu_internal_context>\n*/g,"").replace(Nt,"").replace(/\n{3,}/g,`
4
4
 
@@ -0,0 +1 @@
1
+ import{j as t,a2 as o}from"./index-DtRfQcRH.js";const n=()=>t.jsx(o,{});export{n as component};
@@ -1 +1 @@
1
- import{j as s,gw as $,gx as N,cm as L,al as x,gy as M,gz as I,a4 as b,a5 as S,v as j,w,bz as k,r as D,a2 as O,gA as W,gB as P,c7 as E,gC as R,gD as z,a3 as y,g as F,L as G,p as H}from"./index-DdGjY1Hb.js";import{A as U}from"./agent-editor-form-BrOkwfg8.js";import{P as _}from"./proposal-review-shell-uskeFIUr.js";function B({identity:e,sections:n,activeSection:t,activeItem:o,onSectionSelect:r,sectionLabel:c,highlightSection:l=!0,className:g}){const a=o??n.find(i=>i.key===t)??n[0];if(!a)return null;const d=a.icon;return s.jsx("div",{className:x("flex shrink-0 flex-col items-center px-4 lg:px-6",g),children:s.jsxs("div",{className:"flex min-w-0 max-w-full flex-wrap items-center justify-center gap-x-3 gap-y-2",children:[e,s.jsxs($,{children:[s.jsx(N,{asChild:!0,children:s.jsxs("button",{type:"button",className:x("inline-flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1 text-sm transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring",l?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted/60 hover:text-foreground"),"aria-label":c,children:[s.jsx(d,{className:"h-3.5 w-3.5 shrink-0"}),a.label,s.jsx(L,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),s.jsx(M,{align:"center",className:"min-w-[11rem]",children:n.map(({key:i,label:u,icon:m})=>s.jsxs(I,{className:x(i===t&&"bg-accent font-medium"),onSelect:()=>r(i),children:[s.jsx(m,{className:"h-4 w-4"}),s.jsx("span",{children:u})]},i))})]})]})})}const p=[{key:"skills",label:"Skills",icon:W},{key:"guardrails",label:"Guardrails",icon:P},{key:"permissions",label:"Permissions",icon:E,adminOnly:!0},{key:"models",label:"Models",icon:R},{key:"settings",label:"Settings",icon:z}];function T(e){return p.filter(n=>!n.adminOnly||e)}function q(e,n){if(n===`${e}/conversations`||n.startsWith(`${e}/conversations/`))return null;for(const{key:t}of p)if(n===`${e}/${t}`||n.startsWith(`${e}/${t}/`))return t;return n===`${e}/identity`||n===`${e}/identity/`?"settings":null}function J(e){return e.trim().charAt(0).toUpperCase()||"?"}function K({owner:e,agentId:n,agentName:t,activeDest:o}){const r=b(),{orgContext:c}=y(),{isAdmin:l}=F(c.organizationId),g=T(!!l),a=o??"settings",d=p.find(i=>i.key===a);return s.jsx(B,{identity:s.jsxs(G,{to:"/$owner/agents/$agentId/settings",params:{owner:e,agentId:n},search:{run_id:void 0},className:"flex min-w-0 items-center gap-2 rounded-md outline-none transition-colors hover:opacity-90 focus-visible:ring-2 focus-visible:ring-ring",title:"Agent settings",children:[s.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-semibold text-foreground",children:J(t)}),s.jsx("h1",{className:"min-w-0 truncate text-base font-semibold tracking-tight",children:t})]}),sections:g,activeSection:a,activeItem:d,sectionLabel:"Agent section",highlightSection:o!==null,onSectionSelect:i=>{r({to:`/$owner/agents/$agentId/${i}`,params:{owner:e,agentId:n}})}})}function Z({owner:e,agentId:n}){const t=b(),{pathname:o}=S(),{isAuthenticated:r}=j(),{isMember:c}=w(),l=r&&c,{data:g=[],isLoading:a}=k({enabled:l}),d=g.find(C=>C.agentId===n)??null,i=!d&&!a&&l,u=`/${e}/agents/${n}`,m=`${u}/conversations`,f=o===m||o.startsWith(`${m}/`),h=q(u,o);D.useEffect(()=>{i&&t({to:"/$owner",params:{owner:e},replace:!0})},[i,t,e]);const A=d?.name??"Agent";return s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-hidden py-4 md:py-6",children:[s.jsx(K,{owner:e,agentId:n,agentName:A,activeDest:h}),s.jsx("div",{className:x("flex min-h-0 min-w-0 flex-1 flex-col px-4 lg:px-6",f?"overflow-hidden":"overflow-y-auto"),children:s.jsx(O,{})})]})}function Q({agent:e,tab:n,runId:t}){return s.jsx("div",{className:"mx-auto w-full max-w-3xl pb-6",children:s.jsx(_,{resource:{kind:"agent",agentId:e.agentId},runId:t,children:({reviewMode:o,proposal:r,controlsDisabled:c})=>s.jsx(U,{mode:{kind:"edit",agent:e},section:n,reviewMode:o,reviewProposal:r,reviewControlsDisabled:c},e.agentId)})})}function ee({owner:e,agentId:n,tab:t,runId:o}){const{orgContext:r,hasOrgContext:c}=y(),{isLoading:l}=H(`/${e}`,r),{isAuthenticated:g}=j(),{isMember:a,isLoading:d}=w(),i=g&&a,{data:u=[],isLoading:m}=k({enabled:i}),v=i?!c||l||m||d:l||d,f=u.find(h=>h.agentId===n)??null;return v||!f?null:s.jsx(Q,{agent:f,tab:t,runId:o})}export{Z as A,ee as a};
1
+ import{j as s,gw as $,gx as N,cm as L,al as x,gy as M,gz as I,a4 as b,a5 as S,v as j,w,bz as k,r as D,a2 as O,gA as W,gB as P,c7 as E,gC as R,gD as z,a3 as y,g as F,L as G,p as H}from"./index-DtRfQcRH.js";import{A as U}from"./agent-editor-form-DwHD9j1Y.js";import{P as _}from"./proposal-review-shell-C3K-JXjb.js";function B({identity:e,sections:n,activeSection:t,activeItem:o,onSectionSelect:r,sectionLabel:c,highlightSection:l=!0,className:g}){const a=o??n.find(i=>i.key===t)??n[0];if(!a)return null;const d=a.icon;return s.jsx("div",{className:x("flex shrink-0 flex-col items-center px-4 lg:px-6",g),children:s.jsxs("div",{className:"flex min-w-0 max-w-full flex-wrap items-center justify-center gap-x-3 gap-y-2",children:[e,s.jsxs($,{children:[s.jsx(N,{asChild:!0,children:s.jsxs("button",{type:"button",className:x("inline-flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1 text-sm transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring",l?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted/60 hover:text-foreground"),"aria-label":c,children:[s.jsx(d,{className:"h-3.5 w-3.5 shrink-0"}),a.label,s.jsx(L,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),s.jsx(M,{align:"center",className:"min-w-[11rem]",children:n.map(({key:i,label:u,icon:m})=>s.jsxs(I,{className:x(i===t&&"bg-accent font-medium"),onSelect:()=>r(i),children:[s.jsx(m,{className:"h-4 w-4"}),s.jsx("span",{children:u})]},i))})]})]})})}const p=[{key:"skills",label:"Skills",icon:W},{key:"guardrails",label:"Guardrails",icon:P},{key:"permissions",label:"Permissions",icon:E,adminOnly:!0},{key:"models",label:"Models",icon:R},{key:"settings",label:"Settings",icon:z}];function T(e){return p.filter(n=>!n.adminOnly||e)}function q(e,n){if(n===`${e}/conversations`||n.startsWith(`${e}/conversations/`))return null;for(const{key:t}of p)if(n===`${e}/${t}`||n.startsWith(`${e}/${t}/`))return t;return n===`${e}/identity`||n===`${e}/identity/`?"settings":null}function J(e){return e.trim().charAt(0).toUpperCase()||"?"}function K({owner:e,agentId:n,agentName:t,activeDest:o}){const r=b(),{orgContext:c}=y(),{isAdmin:l}=F(c.organizationId),g=T(!!l),a=o??"settings",d=p.find(i=>i.key===a);return s.jsx(B,{identity:s.jsxs(G,{to:"/$owner/agents/$agentId/settings",params:{owner:e,agentId:n},search:{run_id:void 0},className:"flex min-w-0 items-center gap-2 rounded-md outline-none transition-colors hover:opacity-90 focus-visible:ring-2 focus-visible:ring-ring",title:"Agent settings",children:[s.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-semibold text-foreground",children:J(t)}),s.jsx("h1",{className:"min-w-0 truncate text-base font-semibold tracking-tight",children:t})]}),sections:g,activeSection:a,activeItem:d,sectionLabel:"Agent section",highlightSection:o!==null,onSectionSelect:i=>{r({to:`/$owner/agents/$agentId/${i}`,params:{owner:e,agentId:n}})}})}function Z({owner:e,agentId:n}){const t=b(),{pathname:o}=S(),{isAuthenticated:r}=j(),{isMember:c}=w(),l=r&&c,{data:g=[],isLoading:a}=k({enabled:l}),d=g.find(C=>C.agentId===n)??null,i=!d&&!a&&l,u=`/${e}/agents/${n}`,m=`${u}/conversations`,f=o===m||o.startsWith(`${m}/`),h=q(u,o);D.useEffect(()=>{i&&t({to:"/$owner",params:{owner:e},replace:!0})},[i,t,e]);const A=d?.name??"Agent";return s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-hidden py-4 md:py-6",children:[s.jsx(K,{owner:e,agentId:n,agentName:A,activeDest:h}),s.jsx("div",{className:x("flex min-h-0 min-w-0 flex-1 flex-col px-4 lg:px-6",f?"overflow-hidden":"overflow-y-auto"),children:s.jsx(O,{})})]})}function Q({agent:e,tab:n,runId:t}){return s.jsx("div",{className:"mx-auto w-full max-w-3xl pb-6",children:s.jsx(_,{resource:{kind:"agent",agentId:e.agentId},runId:t,children:({reviewMode:o,proposal:r,controlsDisabled:c})=>s.jsx(U,{mode:{kind:"edit",agent:e},section:n,reviewMode:o,reviewProposal:r,reviewControlsDisabled:c},e.agentId)})})}function ee({owner:e,agentId:n,tab:t,runId:o}){const{orgContext:r,hasOrgContext:c}=y(),{isLoading:l}=H(`/${e}`,r),{isAuthenticated:g}=j(),{isMember:a,isLoading:d}=w(),i=g&&a,{data:u=[],isLoading:m}=k({enabled:i}),v=i?!c||l||m||d:l||d,f=u.find(h=>h.agentId===n)??null;return v||!f?null:s.jsx(Q,{agent:f,tab:t,runId:o})}export{Z as A,ee as a};
@@ -1 +1 @@
1
- import{r as l,hF as p,bo as u,bf as f,bu as m,j as e,bg as g,L as i,h0 as j,eH as x,bt as b,ci as N,gg as v,gh as w,gi as y,Y as C,B as k,aR as P,d_ as D,hG as A,aY as B}from"./index-DdGjY1Hb.js";import{d as R}from"./device-rows-BqudjhFu.js";function I({ownerSlug:s,appId:n}){const t=l.useMemo(()=>p(s,n,u()),[s,n]),{data:a=[]}=f(),o=l.useMemo(()=>{const r=t?.devicePlatforms;return r?.length?a.filter(c=>{const d=m(c);return d!=null&&r.includes(d)}):[]},[t,a]);if(!t)return e.jsxs(g,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"There is no app by that name."}),e.jsx(i,{to:"/$owner/connectors",params:{owner:s},search:{},className:"text-sm text-primary hover:underline",children:"Back to connectors"})]});const h=(t.devicePlatforms?.length??0)>0;return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(j,{header:e.jsx(v,{breadcrumb:e.jsx(w,{crumbs:[e.jsx(i,{to:"/$owner/connectors",params:{owner:s},search:{},className:y,children:"Connectors"},"connectors")]}),icon:e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border text-muted-foreground",children:t.icon}),title:t.name,caption:t.description}),children:[e.jsx(x,{title:"Set up",children:e.jsx("div",{className:"space-y-3",children:t.steps.map(r=>e.jsx(_,{step:r},r.label))})}),h?e.jsx(x,{title:"Devices",count:o.length>0?String(o.length):void 0,children:o.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Nothing yet. Finish the steps above and it appears here, and on the connectors list."}):e.jsx("div",{className:"overflow-hidden rounded-lg border",children:o.map((r,c)=>e.jsxs(i,{to:"/$owner/connectors/device/$deviceId",params:{owner:s,deviceId:r.id},className:L(c,o.length),children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",children:e.jsx(b,{platform:m(r)})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:N(r)}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:R(r)})]})]},r.id))})}):null]})})}function L(s,n){return`flex items-center gap-3 px-3 py-2.5 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground ${s===n-1?"":"border-b"}`}function _({step:s}){const[n,t]=l.useState(!1);if(s.href)return e.jsxs("a",{href:s.href,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-xs font-medium text-primary hover:bg-accent/50",children:[s.label,e.jsx(C,{className:"h-3 w-3"})]});const a=s.command??"";return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.label}),e.jsxs("div",{className:"flex items-start gap-2 rounded-lg border bg-muted/40 p-2.5",children:[e.jsx("pre",{className:"min-w-0 flex-1 overflow-x-auto font-mono text-xs leading-relaxed",children:a}),e.jsxs(k,{variant:"ghost",size:"sm",className:"h-6 shrink-0 px-1.5 text-xs",onClick:()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(a).then(()=>{t(!0),setTimeout(()=>t(!1),1500)})},children:[n?e.jsx(P,{className:"h-3.5 w-3.5"}):e.jsx(D,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"sr-only",children:"Copy"})]})]})]})}function S(){const{owner:s,appId:n}=A.useParams();return e.jsx(B,{owner:s,children:({ownerSlug:t})=>e.jsx(I,{ownerSlug:t,appId:n})})}export{S as component};
1
+ import{r as l,hF as p,bo as u,bf as f,bu as m,j as e,bg as g,L as i,h0 as j,eH as x,bt as b,ci as N,gg as v,gh as w,gi as y,Y as C,B as k,aR as P,d_ as D,hG as A,aY as B}from"./index-DtRfQcRH.js";import{d as R}from"./device-rows-BBhW1C7Y.js";function I({ownerSlug:s,appId:n}){const t=l.useMemo(()=>p(s,n,u()),[s,n]),{data:a=[]}=f(),o=l.useMemo(()=>{const r=t?.devicePlatforms;return r?.length?a.filter(c=>{const d=m(c);return d!=null&&r.includes(d)}):[]},[t,a]);if(!t)return e.jsxs(g,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"There is no app by that name."}),e.jsx(i,{to:"/$owner/connectors",params:{owner:s},search:{},className:"text-sm text-primary hover:underline",children:"Back to connectors"})]});const h=(t.devicePlatforms?.length??0)>0;return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(j,{header:e.jsx(v,{breadcrumb:e.jsx(w,{crumbs:[e.jsx(i,{to:"/$owner/connectors",params:{owner:s},search:{},className:y,children:"Connectors"},"connectors")]}),icon:e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border text-muted-foreground",children:t.icon}),title:t.name,caption:t.description}),children:[e.jsx(x,{title:"Set up",children:e.jsx("div",{className:"space-y-3",children:t.steps.map(r=>e.jsx(_,{step:r},r.label))})}),h?e.jsx(x,{title:"Devices",count:o.length>0?String(o.length):void 0,children:o.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Nothing yet. Finish the steps above and it appears here, and on the connectors list."}):e.jsx("div",{className:"overflow-hidden rounded-lg border",children:o.map((r,c)=>e.jsxs(i,{to:"/$owner/connectors/device/$deviceId",params:{owner:s,deviceId:r.id},className:L(c,o.length),children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",children:e.jsx(b,{platform:m(r)})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:N(r)}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:R(r)})]})]},r.id))})}):null]})})}function L(s,n){return`flex items-center gap-3 px-3 py-2.5 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground ${s===n-1?"":"border-b"}`}function _({step:s}){const[n,t]=l.useState(!1);if(s.href)return e.jsxs("a",{href:s.href,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-xs font-medium text-primary hover:bg-accent/50",children:[s.label,e.jsx(C,{className:"h-3 w-3"})]});const a=s.command??"";return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.label}),e.jsxs("div",{className:"flex items-start gap-2 rounded-lg border bg-muted/40 p-2.5",children:[e.jsx("pre",{className:"min-w-0 flex-1 overflow-x-auto font-mono text-xs leading-relaxed",children:a}),e.jsxs(k,{variant:"ghost",size:"sm",className:"h-6 shrink-0 px-1.5 text-xs",onClick:()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(a).then(()=>{t(!0),setTimeout(()=>t(!1),1500)})},children:[n?e.jsx(P,{className:"h-3.5 w-3.5"}):e.jsx(D,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"sr-only",children:"Copy"})]})]})]})}function S(){const{owner:s,appId:n}=A.useParams();return e.jsx(B,{owner:s,children:({ownerSlug:t})=>e.jsx(I,{ownerSlug:t,appId:n})})}export{S as component};
@@ -1 +1 @@
1
- import{r as j,j as e,S as A,ds as O,dt as L,du as D,dv as M,dw as B,dx as F,t as U,dy as H,M as S,a3 as J,p as K,v as V,w as W,dz as z,dA as w,B as P,L as T,dB as $,al as X,aV as Y,dC as G}from"./index-DdGjY1Hb.js";import{C as q,A as Q}from"./create-automation-form-DN2w080o.js";import{P as Z}from"./proposal-review-shell-uskeFIUr.js";import{J as R}from"./json-diff-BV2STDGj.js";import{u as ee,a as te}from"./deployments-ICDss7yS.js";import{A as ne}from"./agent-loading-shells-DsiGx1fn.js";import{b as se,a as oe,s as ae,h as re,R as ie,A as le}from"./agent-thread-DOYh7WLW.js";import{E as ue}from"./events-feed-L3c-LLiJ.js";const ce=20;function C({automationId:t}){const n=ee({resourceKind:"automation",resourceId:t}),[o,r]=j.useState(null),u=te(o!=null?String(o):null),d=(n.data?.pages.length??0)>=ce&&!!n.hasNextPage,s=!!n.isFetchNextPageError;j.useEffect(()=>{!d&&n.hasNextPage&&!n.isFetchingNextPage&&!n.isError&&!s&&n.fetchNextPage()},[d,n.fetchNextPage,n.hasNextPage,n.isFetchingNextPage,n.isError,s]);const g=j.useMemo(()=>(n.data?.pages??[]).flatMap(c=>c.items).filter(c=>c.type==="change"&&c.resourceKind==="automation"&&c.resourceId===String(t)),[n.data,t]),i=!!n.hasNextPage&&!d,p=typeof n.refetch=="function",m=typeof n.fetchNextPage=="function";return n.isLoading?e.jsx(A,{className:"h-20 w-full rounded-lg"}):n.isError&&!s?e.jsxs("section",{className:"space-y-2","aria-label":"Automation definition history","data-testid":"automation-definition-history",children:[e.jsx("h3",{className:"font-medium text-sm",children:"Definition history"}),e.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"automation-definition-history-error",children:"Definition history unavailable."}),p?e.jsx("button",{type:"button",className:"text-sm underline","data-testid":"automation-definition-history-retry",onClick:()=>void n.refetch(),children:"Retry"}):null]}):e.jsxs("section",{className:"space-y-2","aria-label":"Automation definition history","data-testid":"automation-definition-history",children:[e.jsx("h3",{className:"font-medium text-sm",children:"Definition history"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Runtime and delivery configuration changes with actor and before/after. Content versions (prompt, sources) are listed separately."}),g.length===0&&!i?e.jsx("p",{className:"py-4 text-sm text-muted-foreground","data-testid":"automation-definition-history-empty",children:"No definition changes recorded yet."}):e.jsx("ul",{className:"space-y-1","data-testid":"automation-definition-history-list",children:g.map(a=>{if(a.type!=="change")return null;const l=a.createdBy??a.agentId??a.actorSource??"unknown";return e.jsx("li",{children:e.jsxs("button",{type:"button",className:"flex w-full flex-wrap items-center justify-between gap-2 rounded-lg border border-border/60 px-3 py-2 text-left text-sm hover:bg-muted/50",onClick:()=>r(c=>c===a.id?null:a.id),"data-testid":`automation-definition-history-item-${a.id}`,children:[e.jsx("span",{className:"font-medium",children:a.action??a.op??"change"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:(a.changedFields??[]).join(", ")}),e.jsx("span",{className:"text-xs text-muted-foreground",children:l}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(a.createdAt).toLocaleString()})]})},a.id)})}),i?e.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"automation-definition-history-loading-more",children:"Loading more history…"}):null,d?e.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"automation-definition-history-capped",children:"Showing recent definition changes"}):null,s?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"automation-definition-history-page-error",children:"Couldn't load more history."}),m?e.jsx("button",{type:"button",className:"text-xs underline","data-testid":"automation-definition-history-retry-next",onClick:()=>void n.fetchNextPage(),children:"Retry"}):null]}):null,o!=null?e.jsx("div",{"data-testid":"automation-definition-history-detail",children:u.isLoading?e.jsx(A,{className:"h-24 w-full rounded-lg"}):u.isError?e.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"automation-definition-history-detail-error",children:"Change detail unavailable."}):u.data?e.jsx(R,{before:u.data.before,after:u.data.after}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Change detail unavailable."})}):null]})}const E=Symbol("trusted-automation-interaction");function _(t){return Object.defineProperty(t,E,{value:!0}),t}function de(t){return{title:`${t} 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 ${t} proposals?`,tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved all ${t} proposals.`},{id:"reject-all",label:"Keep all separate",variant:"outline",icon:"x",confirm:!0,confirmPrompt:`Reject all ${t} proposals?`,tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected all ${t} proposals.`}]}}const me=new Set(["entity-merge-approval","automation-approval-batch","entity-merge-result"]);function N(t){return new Promise(n=>{t({onSettled:(o,r)=>n(!!r)})})}function I(t){try{return new URL(t,window.location.origin).origin===window.location.origin}catch{return!1}}function pe(){const t=O(),n=L(),o=D(),r=M(),u=B();return j.useMemo(()=>({toolNames:me,resolve:(h,d)=>{if(!d||typeof d!="object"||d[E]!==!0)return null;const s=d;if(h==="automation-approval-batch"){const m=typeof s.runId=="number"&&Number.isSafeInteger(s.runId)&&s.runId>0?s.runId:null,a=typeof s.count=="number"&&Number.isSafeInteger(s.count)&&s.count>1?s.count:null,l=Array.isArray(s.runIds)?s.runIds.filter(c=>typeof c=="number"&&Number.isSafeInteger(c)&&c>0):[];return m===null||a===null||l.length!==a||new Set(l).size!==a?null:{view:de(a),handlers:{manage_operations:c=>c.action!=="approve"&&c.action!=="reject"?Promise.resolve(!0):N(y=>c.action==="approve"?t.mutate({run_id:m,run_ids:l},y):n.mutate({run_id:m,run_ids:l},y))}}}if(h==="entity-merge-approval"){const m=typeof s.runId=="number"&&Number.isSafeInteger(s.runId)&&s.runId>0?s.runId:null;if(m===null||s.action!=="merge"||s.resourceKind!=="entity")return null;const a=se(s),l=(s.status??"pending")==="pending";return{view:a.view,handlers:{open_review_link:c=>{const y=typeof c.url=="string"?c.url:"";return!a.reviewUrls.has(y)||!I(y)?Promise.resolve(!0):(window.open(y,"_blank","noopener,noreferrer"),Promise.resolve(!1))},...l?{manage_operations:c=>c.action==="approve"?N(y=>o.mutate({run_id:m},y)):c.action==="reject"?N(y=>r.mutate({run_id:m},y)):Promise.resolve(!0)}:{}}}}if(h!=="entity-merge-result")return null;const g=s.loser&&typeof s.loser=="object"?s.loser:null,i=typeof g?.id=="number"?g.id:null;if(i===null)return null;const p=oe(s);return{view:p.view,handlers:{open_review_link:m=>{const a=typeof m.url=="string"?m.url:"";return!p.reviewUrls.has(a)||!I(a)?Promise.resolve(!0):(window.open(a,"_blank","noopener,noreferrer"),Promise.resolve(!1))},manage_entity:()=>N(m=>u.mutate({entityId:i},m))}}}}),[o,t,r,n,u])}function fe(t){const n=[];return t.forEach((o,r)=>{n.push({id:`sep:${o.runId}`,role:"system",parts:[{type:"text",text:ge(o,r)}],createdAt:o.completedAt?new Date(o.completedAt).getTime():void 0});for(const u of o.messages)n.push({...u,id:`r${o.runId}:${u.id}`})}),n}function ge(t,n){const o=(t.pendingActionCount??0)>0?`Waiting for you (${t.pendingActionCount})`:t.status==="completed"?"Completed":t.status??"Completed",r=(t.autoAppliedCount??0)>0?` · ${t.autoAppliedCount} applied automatically`:"",u=t.completedAt?new Date(t.completedAt).toLocaleString():null;return u?`Run ${n+1} · ${o}${r} · ${u}`:`Run ${n+1} · ${o}${r}`}const he=/(?:^|\n)Run this Automation now/;function xe(t){return t.role==="user"&&t.parts.some(n=>n.type==="text"&&he.test(n.text))}function ye(t){return`history-interaction:${t.runId}:${t.eventId??"error"}`}function ve({agentId:t,automationId:n,ownerSlug:o,runId:r}){const{data:u,isLoading:h}=F(t,n,{orgSlug:o}),d=pe(),s=U(),g=j.useCallback(p=>{s?.open({href:`/${o}/automations/${n}?run_id=${p}`,title:`Automation run #${p}`,runId:p})},[s,o,t,n]),i=j.useMemo(()=>{const p=u?.runs??[],a=(r!=null?p.filter(l=>l.runId===r):p).slice().reverse();return fe(a.map(l=>{const c=l.messages.map(f=>ae(f,{showToolCalls:!0})).filter(f=>f!==null&&!xe(f));l.task?.trim()&&c.unshift({id:"task",role:"user",parts:[{type:"text",text:l.task.trim()}]});for(const f of l.automaticActions??[]){const v=x=>H(o,[...x.parentEntityType&&x.parentSlug?[{entity_type:x.parentEntityType,slug:x.parentSlug}]:[],{entity_type:x.entityType,slug:x.slug}]);c.push({id:`automatic-action:${f.operationId}`,role:"assistant",parts:[{type:"tool-call",toolCallId:`automatic-action-${f.operationId}`,toolName:"entity-merge-result",args:_({...f,loserHref:v(f.loser),winnerHref:v(f.winner)})}]})}const y=l.actions??[],b=y.filter(f=>f.status==="pending");if(b.length>1){const f=b.map(v=>v.runId).sort((v,x)=>v-x);c.push({id:"approval-batch",role:"assistant",parts:[{type:"tool-call",toolCallId:`approval-batch-${l.runId}`,toolName:"automation-approval-batch",args:_({runId:l.runId,count:b.length,runIds:f})}]})}for(const f of y){const v=re([f],{workspaceSlug:o,agentId:t,webOrigin:typeof window>"u"?null:window.location.origin});v&&c.push({...v,id:ye(f),parts:v.parts.map(x=>x.type==="tool-call"&&x.toolName==="tool-approval"&&f.action==="merge"&&f.resourceKind==="entity"?{...x,toolName:"entity-merge-approval",args:_({...x.args})}:x)})}return{runId:l.runId,completedAt:l.completedAt,status:l.status,pendingActionCount:l.pendingActionCount,autoAppliedCount:l.autoAppliedCount,messages:c}}))},[t,u,o,r]);return h?e.jsx(ne,{readOnly:!0}):i.length===0?e.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)."}):e.jsx("div",{className:"flex h-[calc(100dvh-12rem)] min-h-[24rem] min-w-0 flex-1 flex-col",children:e.jsx(ie,{messages:i,children:e.jsx(le,{readOnly:!0,readerPositionMode:"runs",interactionExtension:d,onRunSelect:r==null&&s?g:void 0})})})}function k(t){const{orgContext:n,hasOrgContext:o}=J(),{data:r,isLoading:u}=K(`/${t}`,n),{isAuthenticated:h}=V(),{isMember:d,isLoading:s}=W(),g=h&&d,i=r?.workspace,p=g?!o||u||s:u||s;return{organizationId:i?.id??"",isLoading:p}}function Re(t){return k(t)}function je({owner:t,automationId:n,organizationId:o}){const{data:r,isLoading:u}=z(n,o),h=r?.length??0,d=h>w,s=Math.min(h,w),g=new Set(r?.map(l=>l.entity_type).filter(Boolean)??[]),i=!d&&g.size===1?[...g][0]:null;if(u)return e.jsx(A,{className:"h-10 w-full rounded-lg"});if(s===0)return null;const p=d?`${w}+`:String(s),m=i!=null?`${p} ${i} ${s===1?"entity":"entities"} built by this automation`:`${p} ${s===1?"entity":"entities"} built by this automation`,a=i!=null?G(t,i):{to:"/$owner/data",params:{owner:t},search:{}};return e.jsxs("div",{className:X(Y,"flex flex-wrap items-center justify-between gap-2 px-3 py-2.5 text-sm"),children:[e.jsx("span",{className:"text-muted-foreground",children:m}),e.jsx(P,{asChild:!0,variant:"ghost",size:"sm",className:"h-7 gap-1",children:e.jsxs(T,{to:a.to,params:a.params,search:a.search,children:["View in Memory",e.jsx($,{className:"h-3.5 w-3.5"})]})})]})}function Ne({owner:t,automationId:n,organizationId:o}){const r=Number(n),u=j.useMemo(()=>({producedByAutomationId:r}),[r]);return Number.isFinite(r)?e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-medium text-sm",children:"Produced by this Automation"}),e.jsx(P,{asChild:!0,variant:"ghost",size:"sm",className:"h-7 gap-1",children:e.jsxs(T,{to:"/$owner/events",params:{owner:t},search:{produced_by:String(r)},children:["Open in Activity",e.jsx($,{className:"h-3.5 w-3.5"})]})})]}),e.jsx(ue,{organizationId:o,ownerSlug:t,filters:u,emptyState:e.jsx("p",{className:"py-6 text-sm text-muted-foreground",children:"This Automation hasn't written anything yet. Events it creates, entities it changes and notifications it sends will appear here."})})]}):null}function Ae({agentId:t,owner:n,automationId:o,organizationId:r}){return e.jsxs("div",{className:"space-y-4",children:[r?e.jsx(je,{owner:n,automationId:o,organizationId:r}):null,t?e.jsx(ve,{agentId:t,automationId:o,ownerSlug:n}):e.jsx("p",{className:"rounded-lg border border-border/60 px-3 py-2.5 text-sm text-muted-foreground",children:"Runs execute on the automation's executor, so there is no agent transcript to show. What it produced is below."}),r?e.jsx(Ne,{owner:n,automationId:o,organizationId:r}):null]})}function be({agentId:t,automationId:n,runId:o,organizationId:r,onDone:u}){const[h,d]=j.useState({ready:!1,triggers:[]}),s=j.useCallback(a=>{d(l=>JSON.stringify(l)===JSON.stringify(a)?l:a)},[]),g=S(n,void 0,r,{includeVersions:!0}),i=g.data?.automation,p=e.jsx("div",{className:"flex flex-col gap-4",children:[0,1,2].map(a=>e.jsx(A,{className:"h-16 w-full rounded-lg"},a))}),m=g.isLoading?p:i?e.jsx(q,{organizationId:r,prefillAgentId:t??void 0,editingAutomation:{automation_id:i.automation_id,name:i.automation_name,slug:i.slug,description:i.description,prompt:i.prompt,sources:i.sources,reaction_script:i.reaction_script,managed_agent_id:i.managed_agent_id,device_worker_id:i.device_worker_id,agent_kind:i.agent_kind,delivery_target:i.delivery_target??void 0,execution_config:i.execution_config??void 0,classifiers:i.classifiers,keying_config:i.keying_config,reactions_guidance:i.reactions_guidance,triggers:i.triggers},createFields:{triggers:h.triggers},triggerFields:e.jsx(Q,{organizationId:r,initialTriggers:i.triggers??[],onChange:s},JSON.stringify(i.triggers??[])),hideHeader:!0,hideCancel:!0,submitDisabled:!h.ready,onClose:u,onSuccess:u}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automation not found. It may have been removed."});return t?e.jsxs("div",{className:"space-y-6",children:[e.jsx(Z,{resource:{kind:"automation",agentId:t,automationId:n},runId:o,onDone:u,children:({reviewMode:a,proposal:l})=>a==="active"?e.jsx(R,{before:l?.current??null,after:{...l?.current??{},...l?.proposedAfter??{}}}):a==="loading"?p:a==="error"?null:m}),e.jsx(C,{automationId:n})]}):e.jsxs("div",{className:"space-y-6",children:[m,e.jsx(C,{automationId:n})]})}function Ee({owner:t,agentId:n,automationId:o,view:r,runId:u,onDone:h}){const{organizationId:d}=k(t),s=S(o,void 0,d),g=n??s.data?.automation?.managed_agent_id??null;return u||r==="definition"?e.jsx(be,{agentId:g,automationId:o,runId:u,organizationId:d,onDone:h}):e.jsx(Ae,{agentId:g,owner:t,automationId:o,organizationId:d})}export{ve as A,Ee as a,Re as u};
1
+ import{r as j,j as e,S as A,ds as O,dt as L,du as D,dv as M,dw as B,dx as F,t as U,dy as H,M as S,a3 as J,p as K,v as V,w as W,dz as z,dA as w,B as P,L as T,dB as $,al as X,aV as Y,dC as G}from"./index-DtRfQcRH.js";import{C as q,A as Q}from"./create-automation-form-De8J-JD5.js";import{P as Z}from"./proposal-review-shell-C3K-JXjb.js";import{J as R}from"./json-diff-DYeX-xLk.js";import{u as ee,a as te}from"./deployments-D1gbQwsy.js";import{A as ne}from"./agent-loading-shells-BQLjzMPy.js";import{b as oe,a as se,s as ae,h as re,R as ie,A as le}from"./agent-thread-D7AGGjRV.js";import{E as ue}from"./events-feed-C4L8mQV7.js";const ce=20;function C({automationId:t}){const n=ee({resourceKind:"automation",resourceId:t}),[s,r]=j.useState(null),u=te(s!=null?String(s):null),d=(n.data?.pages.length??0)>=ce&&!!n.hasNextPage,o=!!n.isFetchNextPageError;j.useEffect(()=>{!d&&n.hasNextPage&&!n.isFetchingNextPage&&!n.isError&&!o&&n.fetchNextPage()},[d,n.fetchNextPage,n.hasNextPage,n.isFetchingNextPage,n.isError,o]);const f=j.useMemo(()=>(n.data?.pages??[]).flatMap(c=>c.items).filter(c=>c.type==="change"&&c.resourceKind==="automation"&&c.resourceId===String(t)),[n.data,t]),i=!!n.hasNextPage&&!d,p=typeof n.refetch=="function",m=typeof n.fetchNextPage=="function";return n.isLoading?e.jsx(A,{className:"h-20 w-full rounded-lg"}):n.isError&&!o?e.jsxs("section",{className:"space-y-2","aria-label":"Automation definition history","data-testid":"automation-definition-history",children:[e.jsx("h3",{className:"font-medium text-sm",children:"Definition history"}),e.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"automation-definition-history-error",children:"Definition history unavailable."}),p?e.jsx("button",{type:"button",className:"text-sm underline","data-testid":"automation-definition-history-retry",onClick:()=>void n.refetch(),children:"Retry"}):null]}):e.jsxs("section",{className:"space-y-2","aria-label":"Automation definition history","data-testid":"automation-definition-history",children:[e.jsx("h3",{className:"font-medium text-sm",children:"Definition history"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Runtime and delivery configuration changes with actor and before/after. Content versions (prompt, sources) are listed separately."}),f.length===0&&!i?e.jsx("p",{className:"py-4 text-sm text-muted-foreground","data-testid":"automation-definition-history-empty",children:"No definition changes recorded yet."}):e.jsx("ul",{className:"space-y-1","data-testid":"automation-definition-history-list",children:f.map(a=>{if(a.type!=="change")return null;const l=a.createdBy??a.agentId??a.actorSource??"unknown";return e.jsx("li",{children:e.jsxs("button",{type:"button",className:"flex w-full flex-wrap items-center justify-between gap-2 rounded-lg border border-border/60 px-3 py-2 text-left text-sm hover:bg-muted/50",onClick:()=>r(c=>c===a.id?null:a.id),"data-testid":`automation-definition-history-item-${a.id}`,children:[e.jsx("span",{className:"font-medium",children:a.action??a.op??"change"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:(a.changedFields??[]).join(", ")}),e.jsx("span",{className:"text-xs text-muted-foreground",children:l}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(a.createdAt).toLocaleString()})]})},a.id)})}),i?e.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"automation-definition-history-loading-more",children:"Loading more history…"}):null,d?e.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"automation-definition-history-capped",children:"Showing recent definition changes"}):null,o?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"automation-definition-history-page-error",children:"Couldn't load more history."}),m?e.jsx("button",{type:"button",className:"text-xs underline","data-testid":"automation-definition-history-retry-next",onClick:()=>void n.fetchNextPage(),children:"Retry"}):null]}):null,s!=null?e.jsx("div",{"data-testid":"automation-definition-history-detail",children:u.isLoading?e.jsx(A,{className:"h-24 w-full rounded-lg"}):u.isError?e.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"automation-definition-history-detail-error",children:"Change detail unavailable."}):u.data?e.jsx(R,{before:u.data.before,after:u.data.after}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Change detail unavailable."})}):null]})}const E=Symbol("trusted-automation-interaction");function _(t){return Object.defineProperty(t,E,{value:!0}),t}function de(t){return{title:`${t} 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 ${t} proposals?`,tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved all ${t} proposals.`},{id:"reject-all",label:"Keep all separate",variant:"outline",icon:"x",confirm:!0,confirmPrompt:`Reject all ${t} proposals?`,tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected all ${t} proposals.`}]}}const me=new Set(["entity-merge-approval","automation-approval-batch","entity-merge-result"]);function N(t){return new Promise(n=>{t({onSettled:(s,r)=>n(!!r)})})}function I(t){try{return new URL(t,window.location.origin).origin===window.location.origin}catch{return!1}}function pe(){const t=O(),n=L(),s=D(),r=M(),u=B();return j.useMemo(()=>({toolNames:me,resolve:(h,d)=>{if(!d||typeof d!="object"||d[E]!==!0)return null;const o=d;if(h==="automation-approval-batch"){const m=typeof o.runId=="number"&&Number.isSafeInteger(o.runId)&&o.runId>0?o.runId:null,a=typeof o.count=="number"&&Number.isSafeInteger(o.count)&&o.count>1?o.count:null,l=Array.isArray(o.runIds)?o.runIds.filter(c=>typeof c=="number"&&Number.isSafeInteger(c)&&c>0):[];return m===null||a===null||l.length!==a||new Set(l).size!==a?null:{view:de(a),handlers:{manage_operations:c=>c.action!=="approve"&&c.action!=="reject"?Promise.resolve(!0):N(y=>c.action==="approve"?t.mutate({run_id:m,run_ids:l},y):n.mutate({run_id:m,run_ids:l},y))}}}if(h==="entity-merge-approval"){const m=typeof o.runId=="number"&&Number.isSafeInteger(o.runId)&&o.runId>0?o.runId:null;if(m===null||o.action!=="merge"||o.resourceKind!=="entity")return null;const a=oe(o),l=(o.status??"pending")==="pending";return{view:a.view,handlers:{open_review_link:c=>{const y=typeof c.url=="string"?c.url:"";return!a.reviewUrls.has(y)||!I(y)?Promise.resolve(!0):(window.open(y,"_blank","noopener,noreferrer"),Promise.resolve(!1))},...l?{manage_operations:c=>c.action==="approve"?N(y=>s.mutate({run_id:m},y)):c.action==="reject"?N(y=>r.mutate({run_id:m},y)):Promise.resolve(!0)}:{}}}}if(h!=="entity-merge-result")return null;const f=o.loser&&typeof o.loser=="object"?o.loser:null,i=typeof f?.id=="number"?f.id:null;if(i===null)return null;const p=se(o);return{view:p.view,handlers:{open_review_link:m=>{const a=typeof m.url=="string"?m.url:"";return!p.reviewUrls.has(a)||!I(a)?Promise.resolve(!0):(window.open(a,"_blank","noopener,noreferrer"),Promise.resolve(!1))},manage_entity:()=>N(m=>u.mutate({entityId:i},m))}}}}),[s,t,r,n,u])}function ge(t){const n=[];return t.forEach((s,r)=>{n.push({id:`sep:${s.runId}`,role:"system",parts:[{type:"text",text:fe(s,r)}],createdAt:s.completedAt?new Date(s.completedAt).getTime():void 0});for(const u of s.messages)n.push({...u,id:`r${s.runId}:${u.id}`})}),n}function fe(t,n){const s=(t.pendingActionCount??0)>0?`Waiting for you (${t.pendingActionCount})`:t.status==="completed"?"Completed":t.status??"Completed",r=(t.autoAppliedCount??0)>0?` · ${t.autoAppliedCount} applied automatically`:"",u=t.completedAt?new Date(t.completedAt).toLocaleString():null;return u?`Run ${n+1} · ${s}${r} · ${u}`:`Run ${n+1} · ${s}${r}`}const he=/(?:^|\n)Run this Automation now/;function xe(t){return t.role==="user"&&t.parts.some(n=>n.type==="text"&&he.test(n.text))}function ye(t){return`history-interaction:${t.runId}:${t.eventId??"error"}`}function ve({agentId:t,automationId:n,ownerSlug:s,runId:r}){const{data:u,isLoading:h}=F(t,n,{orgSlug:s}),d=pe(),o=U(),f=j.useCallback(p=>{o?.open({href:`/${s}/automations/${n}?run_id=${p}`,title:`Automation run #${p}`,runId:p})},[o,s,t,n]),i=j.useMemo(()=>{const p=u?.runs??[],a=(r!=null?p.filter(l=>l.runId===r):p).slice().reverse();return ge(a.map(l=>{const c=l.messages.map(g=>ae(g,{showToolCalls:!0})).filter(g=>g!==null&&!xe(g));l.task?.trim()&&c.unshift({id:"task",role:"user",parts:[{type:"text",text:l.task.trim()}]});for(const g of l.automaticActions??[]){const v=x=>H(s,[...x.parentEntityType&&x.parentSlug?[{entity_type:x.parentEntityType,slug:x.parentSlug}]:[],{entity_type:x.entityType,slug:x.slug}]);c.push({id:`automatic-action:${g.operationId}`,role:"assistant",parts:[{type:"tool-call",toolCallId:`automatic-action-${g.operationId}`,toolName:"entity-merge-result",args:_({...g,loserHref:v(g.loser),winnerHref:v(g.winner)})}]})}const y=l.actions??[],b=y.filter(g=>g.status==="pending");if(b.length>1){const g=b.map(v=>v.runId).sort((v,x)=>v-x);c.push({id:"approval-batch",role:"assistant",parts:[{type:"tool-call",toolCallId:`approval-batch-${l.runId}`,toolName:"automation-approval-batch",args:_({runId:l.runId,count:b.length,runIds:g})}]})}for(const g of y){const v=re([g],{workspaceSlug:s,agentId:t,webOrigin:typeof window>"u"?null:window.location.origin});v&&c.push({...v,id:ye(g),parts:v.parts.map(x=>x.type==="tool-call"&&x.toolName==="tool-approval"&&g.action==="merge"&&g.resourceKind==="entity"?{...x,toolName:"entity-merge-approval",args:_({...x.args})}:x)})}return{runId:l.runId,completedAt:l.completedAt,status:l.status,pendingActionCount:l.pendingActionCount,autoAppliedCount:l.autoAppliedCount,messages:c}}))},[t,u,s,r]);return h?e.jsx(ne,{readOnly:!0}):i.length===0?e.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)."}):e.jsx("div",{className:"flex h-[calc(100dvh-12rem)] min-h-[24rem] min-w-0 flex-1 flex-col",children:e.jsx(ie,{messages:i,children:e.jsx(le,{readOnly:!0,readerPositionMode:"runs",interactionExtension:d,onRunSelect:r==null&&o?f:void 0})})})}function k(t){const{orgContext:n,hasOrgContext:s}=J(),{data:r,isLoading:u}=K(`/${t}`,n),{isAuthenticated:h}=V(),{isMember:d,isLoading:o}=W(),f=h&&d,i=r?.workspace,p=f?!s||u||o:u||o;return{organizationId:i?.id??"",isLoading:p}}function Re(t){return k(t)}function je({owner:t,automationId:n,organizationId:s}){const{data:r,isLoading:u}=z(n,s),h=r?.length??0,d=h>w,o=Math.min(h,w),f=new Set(r?.map(l=>l.entity_type).filter(Boolean)??[]),i=!d&&f.size===1?[...f][0]:null;if(u)return e.jsx(A,{className:"h-10 w-full rounded-lg"});if(o===0)return null;const p=d?`${w}+`:String(o),m=i!=null?`${p} ${i} ${o===1?"entity":"entities"} built by this automation`:`${p} ${o===1?"entity":"entities"} built by this automation`,a=i!=null?G(t,i):{to:"/$owner/data",params:{owner:t},search:{}};return e.jsxs("div",{className:X(Y,"flex flex-wrap items-center justify-between gap-2 px-3 py-2.5 text-sm"),children:[e.jsx("span",{className:"text-muted-foreground",children:m}),e.jsx(P,{asChild:!0,variant:"ghost",size:"sm",className:"h-7 gap-1",children:e.jsxs(T,{to:a.to,params:a.params,search:a.search,children:["View in Memory",e.jsx($,{className:"h-3.5 w-3.5"})]})})]})}function Ne({owner:t,automationId:n,organizationId:s}){const r=Number(n),u=j.useMemo(()=>({producedByAutomationId:r}),[r]);return Number.isFinite(r)?e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-medium text-sm",children:"Produced by this Automation"}),e.jsx(P,{asChild:!0,variant:"ghost",size:"sm",className:"h-7 gap-1",children:e.jsxs(T,{to:"/$owner/events",params:{owner:t},search:{produced_by:String(r)},children:["Open in Activity",e.jsx($,{className:"h-3.5 w-3.5"})]})})]}),e.jsx(ue,{organizationId:s,ownerSlug:t,filters:u,emptyState:e.jsx("p",{className:"py-6 text-sm text-muted-foreground",children:"This Automation hasn't written anything yet. Events it creates, entities it changes and notifications it sends will appear here."})})]}):null}function Ae({agentId:t,owner:n,automationId:s,organizationId:r}){return e.jsxs("div",{className:"space-y-4",children:[r?e.jsx(je,{owner:n,automationId:s,organizationId:r}):null,t?e.jsx(ve,{agentId:t,automationId:s,ownerSlug:n}):e.jsx("p",{className:"rounded-lg border border-border/60 px-3 py-2.5 text-sm text-muted-foreground",children:"Runs execute on the automation's executor, so there is no agent transcript to show. What it produced is below."}),r?e.jsx(Ne,{owner:n,automationId:s,organizationId:r}):null]})}function be({agentId:t,automationId:n,runId:s,organizationId:r,onDone:u}){const[h,d]=j.useState({ready:!1,triggers:[]}),o=j.useCallback(a=>{d(l=>JSON.stringify(l)===JSON.stringify(a)?l:a)},[]),f=S(n,void 0,r,{includeVersions:!0}),i=f.data?.automation,p=e.jsx("div",{className:"flex flex-col gap-4",children:[0,1,2].map(a=>e.jsx(A,{className:"h-16 w-full rounded-lg"},a))}),m=f.isLoading?p:i?e.jsx(q,{organizationId:r,prefillAgentId:t??void 0,editingAutomation:{automation_id:i.automation_id,name:i.automation_name,slug:i.slug,description:i.description,prompt:i.prompt,sources:i.sources,reaction_script:i.reaction_script,managed_agent_id:i.managed_agent_id,device_worker_id:i.device_worker_id,agent_kind:i.agent_kind,delivery_target:i.delivery_target??void 0,execution_config:i.execution_config??void 0,keying_config:i.keying_config,reactions_guidance:i.reactions_guidance,triggers:i.triggers},createFields:{triggers:h.triggers},triggerFields:e.jsx(Q,{organizationId:r,initialTriggers:i.triggers??[],onChange:o},JSON.stringify(i.triggers??[])),hideHeader:!0,hideCancel:!0,submitDisabled:!h.ready,onClose:u,onSuccess:u}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automation not found. It may have been removed."});return t?e.jsxs("div",{className:"space-y-6",children:[e.jsx(Z,{resource:{kind:"automation",agentId:t,automationId:n},runId:s,onDone:u,children:({reviewMode:a,proposal:l})=>a==="active"?e.jsx(R,{before:l?.current??null,after:{...l?.current??{},...l?.proposedAfter??{}}}):a==="loading"?p:a==="error"?null:m}),e.jsx(C,{automationId:n})]}):e.jsxs("div",{className:"space-y-6",children:[m,e.jsx(C,{automationId:n})]})}function Ee({owner:t,agentId:n,automationId:s,view:r,runId:u,onDone:h}){const{organizationId:d}=k(t),o=S(s,void 0,d),f=n??o.data?.automation?.managed_agent_id??null;return u||r==="definition"?e.jsx(be,{agentId:f,automationId:s,runId:u,organizationId:d,onDone:h}):e.jsx(Ae,{agentId:f,owner:t,automationId:s,organizationId:d})}export{ve as A,Ee as a,Re as u};
@@ -0,0 +1 @@
1
+ import{j as t,a2 as o}from"./index-DtRfQcRH.js";const n=()=>t.jsx(o,{});export{n as component};