@lobu/runtime-server 22.0.0 → 23.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/dist/catalogs/connectors.json +1353 -181
  2. package/dist/catalogs/skills.json +1 -1
  3. package/dist/component.json +1 -1
  4. package/dist/connectors/README.md +14 -1
  5. package/dist/connectors/google_gmail.ts +1 -0
  6. package/dist/connectors/jira-helpers.ts +313 -0
  7. package/dist/connectors/jira.ts +29 -221
  8. package/dist/connectors/linkedin-browser-script.ts +13 -0
  9. package/dist/connectors/linkedin-draft-page.js +104 -0
  10. package/dist/connectors/linkedin-drafts.ts +73 -0
  11. package/dist/connectors/linkedin-identity.ts +32 -0
  12. package/dist/connectors/linkedin-inbox-adapter.js +1185 -0
  13. package/dist/connectors/linkedin-inbox.ts +156 -0
  14. package/dist/connectors/linkedin-like.ts +114 -0
  15. package/dist/connectors/linkedin-takeout.ts +577 -0
  16. package/dist/connectors/linkedin.ts +3998 -0
  17. package/dist/connectors/takeout-utils.ts +240 -0
  18. package/dist/connectors/tiktok-inbox-page.js +9 -9
  19. package/dist/connectors/tiktok-web-page.js +21 -15
  20. package/dist/connectors/tiktok_web.ts +63 -30
  21. package/dist/connectors/whatsapp-web-adapter.js +64 -564
  22. package/dist/connectors/whatsapp-web-helpers.ts +30 -444
  23. package/dist/connectors/whatsapp-web-identity.ts +20 -6
  24. package/dist/connectors/whatsapp_web.ts +45 -645
  25. package/dist/connectors/x-dm-adapter.js +556 -0
  26. package/dist/connectors/x-identity.ts +31 -2
  27. package/dist/connectors/x.ts +266 -120
  28. package/dist/db/migrations/20261017120000_drop_feeds_kind_virtual.sql +26 -0
  29. package/dist/db/migrations/20261017130000_drop_retired_dead_code_columns.sql +46 -0
  30. package/dist/dependencies.bun.lock +41 -41
  31. package/dist/guest.bundle.js +288 -148
  32. package/dist/owletto/dist/assets/_-3J-IrxWk.js +2 -0
  33. package/dist/owletto/dist/assets/{_-CEPl6gU4.js → _-DYUE3ix4.js} +3 -3
  34. package/dist/owletto/dist/assets/_agentId-Bn2IAjIy.js +2 -0
  35. package/dist/owletto/dist/assets/{_agentId-CBC_SadO.js → _agentId-Cam7Z0N7.js} +2 -2
  36. package/dist/owletto/dist/assets/{_automationId-YTTNksw6.js → _automationId-CXEiKVZJ.js} +2 -2
  37. package/dist/owletto/dist/assets/{_connectorKey._connectionId-fK0h7RAp.js → _connectorKey._connectionId-CS85l61t.js} +2 -2
  38. package/dist/owletto/dist/assets/{_connectorKey.index-C7TPS598.js → _connectorKey.index-clVDIyW0.js} +2 -2
  39. package/dist/owletto/dist/assets/{_conversationId-CEhxlTIo.js → _conversationId-Ci2k-BuN.js} +2 -2
  40. package/dist/owletto/dist/assets/{_deploymentId-BQfYN1U2.js → _deploymentId-BuUzGtVL.js} +2 -2
  41. package/dist/owletto/dist/assets/{_eventId-Cl8GSdjg.js → _eventId-B0662F8h.js} +2 -2
  42. package/dist/owletto/dist/assets/_name-CwWePlOl.js +2 -0
  43. package/dist/owletto/dist/assets/{_owner-cUtGHqSw.js → _owner-dTWkrKsK.js} +3 -3
  44. package/dist/owletto/dist/assets/_shape-BtS3y4M9.js +2 -0
  45. package/dist/owletto/dist/assets/_skillKey-Dc9m-nlR.js +2 -0
  46. package/dist/owletto/dist/assets/{_slug-CU1PuHB9.js → _slug-DQHutM41.js} +2 -2
  47. package/dist/owletto/dist/assets/_viewKey-B30ik8ma.js +2 -0
  48. package/dist/owletto/dist/assets/_viewKey-CUHypQnF.js +2 -0
  49. package/dist/owletto/dist/assets/{accept-invitation-D3OgJG4i.js → accept-invitation-w17IFTtf.js} +2 -2
  50. package/dist/owletto/dist/assets/{activity-route-view-DQglkhXU.js → activity-route-view-CMqYiiKM.js} +2 -2
  51. package/dist/owletto/dist/assets/{agent-card-controls-DzRs4Ix9.js → agent-card-controls-mnTN2AZt.js} +2 -2
  52. package/dist/owletto/dist/assets/{agent-client-setup-list-B2SvH7xD.js → agent-client-setup-list-Bg3hBfUV.js} +2 -2
  53. package/dist/owletto/dist/assets/{agent-connect-pages-B6uKvT_X.js → agent-connect-pages-B_vrqLVc.js} +2 -2
  54. package/dist/owletto/dist/assets/{agent-editor-form-oUnIYHd7.js → agent-editor-form-hTs7eO_U.js} +2 -2
  55. package/dist/owletto/dist/assets/{agent-guardrails-route-BaV1VpDh.js → agent-guardrails-route-BOrCXcAl.js} +2 -2
  56. package/dist/owletto/dist/assets/{agent-loading-shells-CtZJM2Gc.js → agent-loading-shells-Dqcvky-k.js} +2 -2
  57. package/dist/owletto/dist/assets/{agent-permissions-matrix-Ds48KFK9.js → agent-permissions-matrix-BOo_4r_4.js} +2 -2
  58. package/dist/owletto/dist/assets/{agent-skill-context-DPk5r08w.js → agent-skill-context-CCdvtlmH.js} +2 -2
  59. package/dist/owletto/dist/assets/{agent-skills-route-DYpB5H1J.js → agent-skills-route-BUxIswuq.js} +2 -2
  60. package/dist/owletto/dist/assets/{agent-subpage-shell-B3K_jPYR.js → agent-subpage-shell-D92imvSt.js} +2 -2
  61. package/dist/owletto/dist/assets/agent-thread-BJOijbT0.js +6 -0
  62. package/dist/owletto/dist/assets/agents-9XjpDj_S.js +2 -0
  63. package/dist/owletto/dist/assets/{agents-workbench-CMyk4PI7.js → agents-workbench-Bt5QCYQ7.js} +2 -2
  64. package/dist/owletto/dist/assets/{app._appId-DH1Qutz6.js → app._appId-CKv7_squ.js} +2 -2
  65. package/dist/owletto/dist/assets/{automation-detail-content-CEDNboId.js → automation-detail-content-vUwVumXf.js} +2 -2
  66. package/dist/owletto/dist/assets/automations-9XjpDj_S.js +2 -0
  67. package/dist/owletto/dist/assets/{callback-CU-hb8JB.js → callback-BRgcL8gz.js} +2 -2
  68. package/dist/owletto/dist/assets/{card-DIF8SF9b.js → card-Djgp00r_.js} +2 -2
  69. package/dist/owletto/dist/assets/{claim-DELEa-gH.js → claim-BYUZnyMp.js} +2 -2
  70. package/dist/owletto/dist/assets/{clients-CpG676mg.js → clients-D3Zbjxin.js} +2 -2
  71. package/dist/owletto/dist/assets/{code-editor-V27Z4o3P.js → code-editor-DHeyRGZI.js} +2 -2
  72. package/dist/owletto/dist/assets/connect-CfsFsy9P.js +2 -0
  73. package/dist/owletto/dist/assets/connect._clientId-DkiC8xos.js +2 -0
  74. package/dist/owletto/dist/assets/connected._clientId-CIXrGOsT.js +2 -0
  75. package/dist/owletto/dist/assets/{connected._clientId.activity-DQWcUqKM.js → connected._clientId.activity-Ckdz6I0y.js} +2 -2
  76. package/dist/owletto/dist/assets/{connected._clientId.index-BC3R303A.js → connected._clientId.index-CNxafNeo.js} +2 -2
  77. package/dist/owletto/dist/assets/{connection-DySpRE9x.js → connection-C3XXFEqh.js} +2 -2
  78. package/dist/owletto/dist/assets/{connection-feed-detail-C_D68j6d.js → connection-feed-detail-CIJJLDP8.js} +2 -2
  79. package/dist/owletto/dist/assets/{connections-browser-Cnv2iBbZ.js → connections-browser-CKZjzRz6.js} +2 -2
  80. package/dist/owletto/dist/assets/{connector-provenance-CNXtzYg5.js → connector-provenance-8-d8hl10.js} +2 -2
  81. package/dist/owletto/dist/assets/{connector-scope-lists-BKDetNDc.js → connector-scope-lists-CadPVsI3.js} +2 -2
  82. package/dist/owletto/dist/assets/{connectors-BJnk1z_2.js → connectors-lvLJ30lo.js} +2 -2
  83. package/dist/owletto/dist/assets/{consent-BVzxrAO9.js → consent-CdSvVCgx.js} +2 -2
  84. package/dist/owletto/dist/assets/{conversations-table-DfZGICl7.js → conversations-table-BdXoZAfc.js} +2 -2
  85. package/dist/owletto/dist/assets/{core.esm-DiTpULFl.js → core.esm-CYvgWCuv.js} +2 -2
  86. package/dist/owletto/dist/assets/create-0xW9eXxG.js +2 -0
  87. package/dist/owletto/dist/assets/{create-JRFM8mMf.js → create-B0qhrrX4.js} +2 -2
  88. package/dist/owletto/dist/assets/create-CAfF-yI1.js +2 -0
  89. package/dist/owletto/dist/assets/create-automation-form-CtSSeYj3.js +3 -0
  90. package/dist/owletto/dist/assets/create._connectorKey-i6xxkWKV.js +2 -0
  91. package/dist/owletto/dist/assets/{cronstrue-DPXl0qA2.js → cronstrue-n4qGUraE.js} +2 -2
  92. package/dist/owletto/dist/assets/deployments-4Itm35Xc.js +2 -0
  93. package/dist/owletto/dist/assets/{deployments-DCQdFdwG.js → deployments-RvUdVkj3.js} +2 -2
  94. package/dist/owletto/dist/assets/{deployments-body-D6TAWs_6.js → deployments-body-BMp7UsMo.js} +2 -2
  95. package/dist/owletto/dist/assets/{device-CntqYW65.js → device-CPU6CjkJ.js} +2 -2
  96. package/dist/owletto/dist/assets/{device-pin-tombstone-Bz4JHHMK.js → device-pin-tombstone-CrjG7gPo.js} +2 -2
  97. package/dist/owletto/dist/assets/{device._deviceId-D4plO3GM.js → device._deviceId-Cs3ZmXWo.js} +2 -2
  98. package/dist/owletto/dist/assets/{entity-options-UJs64GdQ.js → entity-options-uXjgT7y9.js} +2 -2
  99. package/dist/owletto/dist/assets/{entity-page-Djz6T50J.js → entity-page-Dc0LGr5U.js} +2 -2
  100. package/dist/owletto/dist/assets/{entity-type-page-OznRag6A.js → entity-type-page-CwZxa0BR.js} +2 -2
  101. package/dist/owletto/dist/assets/{event-detail-04qOUGIP.js → event-detail-ve2d6Gbb.js} +2 -2
  102. package/dist/owletto/dist/assets/{events-feed-fucGZSJR.js → events-feed-BtvhZF1f.js} +2 -2
  103. package/dist/owletto/dist/assets/{filter-editors-DCQgGLyR.js → filter-editors-Cj-v6NtH.js} +2 -2
  104. package/dist/owletto/dist/assets/{full-page-spinner-KpV2FS2u.js → full-page-spinner-DqpH99np.js} +2 -2
  105. package/dist/owletto/dist/assets/guardrails-HFo2Ut8B.js +2 -0
  106. package/dist/owletto/dist/assets/identity-BigVSBCl.js +2 -0
  107. package/dist/owletto/dist/assets/{index-BEvyBdOU.js → index-B9uPN6FC.js} +2 -2
  108. package/dist/owletto/dist/assets/{index-BNh2cidi.js → index-BQVliQW1.js} +2 -2
  109. package/dist/owletto/dist/assets/index-BfedB4Rc.js +2 -0
  110. package/dist/owletto/dist/assets/index-CUw3aKBI.js +2 -0
  111. package/dist/owletto/dist/assets/index-CXhxUkv3.js +2 -0
  112. package/dist/owletto/dist/assets/{index-_oPeVpL_.js → index-Cr5hwh-C.js} +66 -66
  113. package/dist/owletto/dist/assets/index-CzkTV4ZQ.js +2 -0
  114. package/dist/owletto/dist/assets/index-DKSx8JN_.js +2 -0
  115. package/dist/owletto/dist/assets/{index-D3s8rhG9.js → index-DVk7Ug0d.js} +2 -2
  116. package/dist/owletto/dist/assets/index-DmZuKGf8.js +2 -0
  117. package/dist/owletto/dist/assets/{index-DCdkwg9H.js → index-Hio-HRfo.js} +2 -2
  118. package/dist/owletto/dist/assets/{index-BJXkc60S.js → index-ICgKp3YK.js} +2 -2
  119. package/dist/owletto/dist/assets/index-cPcroOH0.js +2 -0
  120. package/dist/owletto/dist/assets/{index-BOzuAbvi.js → index-n7sTbNv4.js} +2 -2
  121. package/dist/owletto/dist/assets/index-xiFpcWKv.js +2 -0
  122. package/dist/owletto/dist/assets/{json-diff-D_Ym3Uku.js → json-diff-DBoag_OS.js} +2 -2
  123. package/dist/owletto/dist/assets/{list-skeleton-Bl0OS39L.js → list-skeleton-C_GuoxAH.js} +2 -2
  124. package/dist/owletto/dist/assets/{login-QHdxqX-4.js → login-Ci6ixHuL.js} +2 -2
  125. package/dist/owletto/dist/assets/{logout-DUccApuZ.js → logout-CLGgeZB7.js} +2 -2
  126. package/dist/owletto/dist/assets/{member-scope-gate-CFbrq1by.js → member-scope-gate-B44INDPY.js} +2 -2
  127. package/dist/owletto/dist/assets/{memory-browse-page-IrIXuZTF.js → memory-browse-page-DyQiRvzl.js} +2 -2
  128. package/dist/owletto/dist/assets/{model-selector-CB1BDvlW.js → model-selector-dAbDgJvx.js} +2 -2
  129. package/dist/owletto/dist/assets/models-DpVP7ZwX.js +2 -0
  130. package/dist/owletto/dist/assets/{new-BWo8_Pms.js → new-BUb7AnEW.js} +2 -2
  131. package/dist/owletto/dist/assets/{new-B5UsLiy6.js → new-BkdULx2r.js} +2 -2
  132. package/dist/owletto/dist/assets/{new-DpmDXmFI.js → new-CHOr-EcI.js} +2 -2
  133. package/dist/owletto/dist/assets/{oauth-workspace-access-PGyTnW2K.js → oauth-workspace-access-BxsjwgdH.js} +2 -2
  134. package/dist/owletto/dist/assets/{organization-BH8PYlVu.js → organization-gxGeDjIV.js} +2 -2
  135. package/dist/owletto/dist/assets/{peek-pane-content-B2AFNTzP.js → peek-pane-content-CHoQHe2H.js} +2 -2
  136. package/dist/owletto/dist/assets/{permissions-CwN_YP3u.js → permissions-aPHaKLec.js} +2 -2
  137. package/dist/owletto/dist/assets/{proposal-review-shell-DKKGu4Ww.js → proposal-review-shell-UcZr87_Q.js} +2 -2
  138. package/dist/owletto/dist/assets/public-shell-ready-DcnlADmj.js +2 -0
  139. package/dist/owletto/dist/assets/{recent-DqdZE_TI.js → recent-D-65Pgu-.js} +2 -2
  140. package/dist/owletto/dist/assets/{record-activity-CvgZyCmw.js → record-activity-CBXH6v1d.js} +2 -2
  141. package/dist/owletto/dist/assets/{renderer-BL6VcwQH.js → renderer-mEDnVW0O.js} +2 -2
  142. package/dist/owletto/dist/assets/{reset-password-DAvBYkiI.js → reset-password-uX_V6bip.js} +2 -2
  143. package/dist/owletto/dist/assets/{runs-BWtc5rmc.js → runs-C0rCgGwX.js} +2 -2
  144. package/dist/owletto/dist/assets/runs-panel-Du1JMjg5.js +2 -0
  145. package/dist/owletto/dist/assets/{runs-table-DxIiqrSk.js → runs-table-syPJ6r6T.js} +2 -2
  146. package/dist/owletto/dist/assets/{settings-Crxlwps-.js → settings-9NkNA1G1.js} +2 -2
  147. package/dist/owletto/dist/assets/settings-E-10sLQX.js +2 -0
  148. package/dist/owletto/dist/assets/skills-D2Ri9b4f.js +2 -0
  149. package/dist/owletto/dist/assets/{source-record-panels-CRIPMWfN.js → source-record-panels-CPyzlfD1.js} +2 -2
  150. package/dist/owletto/dist/assets/{status-dot-C5KDvvm9.js → status-dot-B-EWMgq6.js} +2 -2
  151. package/dist/owletto/dist/assets/{tabs-B4Er9hJj.js → tabs-DqIIkCX-.js} +2 -2
  152. package/dist/owletto/dist/assets/{use-mention-search-DqEykWl_.js → use-mention-search-By8RZyKW.js} +2 -2
  153. package/dist/owletto/dist/assets/{view-param-filters-Cylutoy1.js → view-param-filters-CqLZQrnO.js} +2 -2
  154. package/dist/owletto/dist/index.html +1 -1
  155. package/dist/server-main.bundle.mjs +11447 -10762
  156. package/npm-shrinkwrap.json +160 -160
  157. package/package.json +1 -1
  158. package/vendor/connector-sdk/dist/browser-handoff-banner.d.ts +39 -0
  159. package/vendor/connector-sdk/dist/browser-handoff-banner.js +175 -0
  160. package/vendor/connector-sdk/dist/browser-source-read.d.ts +52 -0
  161. package/vendor/connector-sdk/dist/browser-source-read.js +107 -0
  162. package/vendor/connector-sdk/dist/connector-types.d.ts +10 -0
  163. package/vendor/connector-sdk/dist/index.d.ts +3 -0
  164. package/vendor/connector-sdk/dist/index.js +2 -0
  165. package/vendor/connector-sdk/package.json +9 -1
  166. package/vendor/core/dist/capabilities.d.ts +1 -1
  167. package/vendor/core/dist/capabilities.js +0 -1
  168. package/vendor/core/dist/connector-query-errors.d.ts +32 -0
  169. package/vendor/core/dist/connector-query-errors.js +41 -1
  170. package/vendor/core/dist/contracts/tools/manage-conversations.js +2 -2
  171. package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +14 -0
  172. package/vendor/core/dist/contracts/tools/manage-feeds.js +17 -0
  173. package/vendor/core/dist/contracts/worker/protocol.d.ts +8 -131
  174. package/vendor/core/dist/contracts/worker/protocol.js +9 -61
  175. package/vendor/core/dist/device-pin-tombstones.d.ts +44 -0
  176. package/vendor/core/dist/device-pin-tombstones.js +57 -0
  177. package/vendor/core/dist/index.d.ts +2 -1
  178. package/vendor/core/dist/index.js +1 -0
  179. package/vendor/core/dist/logger.js +10 -25
  180. package/vendor/core/dist/utils/diagnostic-scrubber.js +258 -21
  181. package/vendor/core/dist/worker/wire.d.ts +0 -10
  182. package/vendor/core/package.json +6 -6
  183. package/vendor/views/package.json +1 -1
  184. package/dist/owletto/dist/assets/_-C_zNZben.js +0 -2
  185. package/dist/owletto/dist/assets/_agentId-QQW91cHX.js +0 -2
  186. package/dist/owletto/dist/assets/_name-t3oBJ6Zf.js +0 -2
  187. package/dist/owletto/dist/assets/_shape-bo2lMVCu.js +0 -2
  188. package/dist/owletto/dist/assets/_skillKey-Dwm4Q4wI.js +0 -2
  189. package/dist/owletto/dist/assets/_viewKey-Bh6E_NxA.js +0 -2
  190. package/dist/owletto/dist/assets/_viewKey-D4jKl-Zf.js +0 -2
  191. package/dist/owletto/dist/assets/agent-thread-C8UaUTWc.js +0 -6
  192. package/dist/owletto/dist/assets/agents-F4mGI2oF.js +0 -2
  193. package/dist/owletto/dist/assets/automations-F4mGI2oF.js +0 -2
  194. package/dist/owletto/dist/assets/connect-B2YL6qIK.js +0 -2
  195. package/dist/owletto/dist/assets/connect._clientId-B6LDmDRV.js +0 -2
  196. package/dist/owletto/dist/assets/connected._clientId-D_HaKoI1.js +0 -2
  197. package/dist/owletto/dist/assets/create-CUqO6Kfk.js +0 -2
  198. package/dist/owletto/dist/assets/create-automation-form-_4vUkrls.js +0 -3
  199. package/dist/owletto/dist/assets/create-iHcxV0xd.js +0 -2
  200. package/dist/owletto/dist/assets/create._connectorKey-CCYLEicg.js +0 -2
  201. package/dist/owletto/dist/assets/deployments-ihkhK1zV.js +0 -2
  202. package/dist/owletto/dist/assets/guardrails-molekzAF.js +0 -2
  203. package/dist/owletto/dist/assets/identity-BJcaG66g.js +0 -2
  204. package/dist/owletto/dist/assets/index-B04ON9Jv.js +0 -2
  205. package/dist/owletto/dist/assets/index-BOsK-K-2.js +0 -2
  206. package/dist/owletto/dist/assets/index-Bk1x7A67.js +0 -2
  207. package/dist/owletto/dist/assets/index-CFnx5huL.js +0 -2
  208. package/dist/owletto/dist/assets/index-Dbd1jusf.js +0 -2
  209. package/dist/owletto/dist/assets/index-DqZuqC08.js +0 -2
  210. package/dist/owletto/dist/assets/index-Dr-Xg_xO.js +0 -2
  211. package/dist/owletto/dist/assets/index-KPOvMVa-.js +0 -2
  212. package/dist/owletto/dist/assets/models-DnMb3n-Z.js +0 -2
  213. package/dist/owletto/dist/assets/public-shell-ready-7KYnww6e.js +0 -2
  214. package/dist/owletto/dist/assets/runs-panel-BO3h5RkS.js +0 -2
  215. package/dist/owletto/dist/assets/settings-4Ev-0iNL.js +0 -2
  216. package/dist/owletto/dist/assets/skills-D0X430X8.js +0 -2
  217. package/vendor/core/dist/contracts/worker/device-chat.d.ts +0 -4
  218. package/vendor/core/dist/contracts/worker/device-chat.js +0 -26
@@ -1,2 +1,2 @@
1
- import{H as m,j as e,aB as b,fL as N,af as A,fM as L,L as p,fN as w,f as k,r as C,h3 as S,hl as x,B as y,A as I,bi as f,dd as M,gD as P}from"./index-_oPeVpL_.js";import{A as R,f as $,b as B}from"./agent-client-setup-list-B2SvH7xD.js";import{u as T}from"./clients-CpG676mg.js";import{g as _,c as U}from"./client-rows-EJSKR6z1.js";function E(t){const n=t?`/mcp/${t}`:"/mcp";if(!m)return`http://localhost:8787${n}`;try{const s=new URL(m);return s.pathname=n,s.toString()}catch{return`${m}${n}`}}const u="flex min-h-0 flex-1 flex-col gap-3 px-4 pt-4 pb-8 lg:px-6";function D(t,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 ${t===n-1?"":"border-b"}`}function v({owner:t}){return e.jsx(L,{crumbs:[e.jsx(p,{to:"/$owner/agents",params:{owner:t},className:w,children:"Agents"},"agents")]})}function W({owner:t}){return e.jsx("div",{className:u,children:e.jsxs(b,{className:"flex flex-1 flex-col gap-6",children:[e.jsx(N,{breadcrumb:e.jsx(v,{owner:t}),icon:e.jsx(A.agents.icon,{className:"h-6 w-6"}),title:"Connect an agent",caption:"Choose the agent you already use. Install directly where supported, or copy a setup prompt into the agent."}),e.jsx(R,{owner:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Local Automation delivery is separate and is not enabled by connecting an agent."})]})})}function j({text:t,label:n}){const[s,l]=C.useState(!1);return e.jsxs(y,{type:"button",variant:"outline",size:"sm",className:"h-8 text-xs",onClick:()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(t).then(()=>{l(!0),setTimeout(()=>l(!1),1500)})},children:[s?e.jsx(M,{className:"mr-1.5 h-3.5 w-3.5"}):e.jsx(P,{className:"mr-1.5 h-3.5 w-3.5"}),s?"Copied":n]})}function q({owner:t,clientId:n}){const s=$(n),{data:l}=k(t,{slug:t}),{data:h=[]}=T(null,{refetchInterval:2500}),r=C.useMemo(()=>_(h).filter(a=>a.connected),[h]);if(!s)return e.jsx("div",{className:u,children:e.jsxs(b,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"There is no agent client by that name."}),e.jsx(p,{to:"/$owner/agents/connect",params:{owner:t},className:"text-sm text-primary hover:underline",children:"Back to agent clients"})]})});const o=E(t),c=B({workspaceName:l?.workspace?.name??t,owner:t,mcpUrl:o,clientLabel:s.id==="other"?void 0:s.label,terminalLogin:s.terminalLogin}),i=s.setupMode==="agent-prompt",g=i?c:s.installText?.(o)??c;return e.jsx("div",{className:u,children:e.jsxs(S,{header:e.jsx(N,{breadcrumb:e.jsx(v,{owner:t}),icon:e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",children:e.jsx(f,{name:s.label})}),title:s.label,caption:s.description}),children:[e.jsx(x,{title:"Set up",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.installTitle}),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 whitespace-pre-wrap font-mono text-xs leading-relaxed",children:g}),e.jsx(j,{text:g,label:i?"Copy setup prompt":"Copy"})]})]}),e.jsx("ol",{className:"space-y-1 text-xs text-muted-foreground",children:s.steps(o).map((a,d)=>e.jsxs("li",{children:[d+1,". ",a]},a))}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[i?null:e.jsx(j,{text:c,label:"Copy setup prompt"}),s.guideLinks.map(a=>e.jsx(y,{asChild:!0,variant:"ghost",size:"sm",className:"h-8 text-xs",children:e.jsxs("a",{href:a.href,target:"_blank",rel:"noreferrer",children:[a.label,e.jsx(I,{className:"ml-1.5 h-3.5 w-3.5"})]})},a.href))]})]})}),e.jsx(x,{title:"Connected agents",count:r.length>0?String(r.length):void 0,children:r.length===0?e.jsx("div",{className:"rounded-lg border border-dashed px-3 py-2.5 text-xs text-muted-foreground",children:"Nothing yet. Finish setup and make an authenticated Lobu MCP request; the agent appears here automatically."}):e.jsx("div",{className:"overflow-hidden rounded-lg border",children:r.map((a,d)=>e.jsxs(p,{to:"/$owner/agents/connected/$clientId",params:{owner:t,clientId:a.clientId},className:D(d,r.length),children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",children:e.jsx(f,{name:a.title})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:a.title}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:U(a)})]})]},a.key))})}),e.jsx(x,{title:"Manual MCP details",children:e.jsxs("dl",{className:"grid grid-cols-[5rem_1fr] gap-x-3 gap-y-1 rounded-lg border bg-muted/40 p-3 text-xs",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Name"}),e.jsx("dd",{className:"font-mono",children:"lobu"}),e.jsx("dt",{className:"text-muted-foreground",children:"MCP URL"}),e.jsx("dd",{className:"break-all font-mono",children:o})]})})]})})}export{W as A,q as a};
2
- //# sourceMappingURL=agent-connect-pages-B6uKvT_X.js.map
1
+ import{H as m,j as e,aB as b,fL as N,af as A,fM as L,L as p,fN as w,f as k,r as C,h0 as S,hi as x,B as y,A as I,bi as f,dd as M,gA as P}from"./index-Cr5hwh-C.js";import{A as R,f as $,b as B}from"./agent-client-setup-list-Bg3hBfUV.js";import{u as T}from"./clients-D3Zbjxin.js";import{g as _,c as U}from"./client-rows-EJSKR6z1.js";function E(t){const n=t?`/mcp/${t}`:"/mcp";if(!m)return`http://localhost:8787${n}`;try{const s=new URL(m);return s.pathname=n,s.toString()}catch{return`${m}${n}`}}const u="flex min-h-0 flex-1 flex-col gap-3 px-4 pt-4 pb-8 lg:px-6";function D(t,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 ${t===n-1?"":"border-b"}`}function v({owner:t}){return e.jsx(L,{crumbs:[e.jsx(p,{to:"/$owner/agents",params:{owner:t},className:w,children:"Agents"},"agents")]})}function W({owner:t}){return e.jsx("div",{className:u,children:e.jsxs(b,{className:"flex flex-1 flex-col gap-6",children:[e.jsx(N,{breadcrumb:e.jsx(v,{owner:t}),icon:e.jsx(A.agents.icon,{className:"h-6 w-6"}),title:"Connect an agent",caption:"Choose the agent you already use. Install directly where supported, or copy a setup prompt into the agent."}),e.jsx(R,{owner:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Local Automation delivery is separate and is not enabled by connecting an agent."})]})})}function j({text:t,label:n}){const[s,l]=C.useState(!1);return e.jsxs(y,{type:"button",variant:"outline",size:"sm",className:"h-8 text-xs",onClick:()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(t).then(()=>{l(!0),setTimeout(()=>l(!1),1500)})},children:[s?e.jsx(M,{className:"mr-1.5 h-3.5 w-3.5"}):e.jsx(P,{className:"mr-1.5 h-3.5 w-3.5"}),s?"Copied":n]})}function q({owner:t,clientId:n}){const s=$(n),{data:l}=k(t,{slug:t}),{data:h=[]}=T(null,{refetchInterval:2500}),r=C.useMemo(()=>_(h).filter(a=>a.connected),[h]);if(!s)return e.jsx("div",{className:u,children:e.jsxs(b,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"There is no agent client by that name."}),e.jsx(p,{to:"/$owner/agents/connect",params:{owner:t},className:"text-sm text-primary hover:underline",children:"Back to agent clients"})]})});const o=E(t),c=B({workspaceName:l?.workspace?.name??t,owner:t,mcpUrl:o,clientLabel:s.id==="other"?void 0:s.label,terminalLogin:s.terminalLogin}),i=s.setupMode==="agent-prompt",g=i?c:s.installText?.(o)??c;return e.jsx("div",{className:u,children:e.jsxs(S,{header:e.jsx(N,{breadcrumb:e.jsx(v,{owner:t}),icon:e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",children:e.jsx(f,{name:s.label})}),title:s.label,caption:s.description}),children:[e.jsx(x,{title:"Set up",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.installTitle}),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 whitespace-pre-wrap font-mono text-xs leading-relaxed",children:g}),e.jsx(j,{text:g,label:i?"Copy setup prompt":"Copy"})]})]}),e.jsx("ol",{className:"space-y-1 text-xs text-muted-foreground",children:s.steps(o).map((a,d)=>e.jsxs("li",{children:[d+1,". ",a]},a))}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[i?null:e.jsx(j,{text:c,label:"Copy setup prompt"}),s.guideLinks.map(a=>e.jsx(y,{asChild:!0,variant:"ghost",size:"sm",className:"h-8 text-xs",children:e.jsxs("a",{href:a.href,target:"_blank",rel:"noreferrer",children:[a.label,e.jsx(I,{className:"ml-1.5 h-3.5 w-3.5"})]})},a.href))]})]})}),e.jsx(x,{title:"Connected agents",count:r.length>0?String(r.length):void 0,children:r.length===0?e.jsx("div",{className:"rounded-lg border border-dashed px-3 py-2.5 text-xs text-muted-foreground",children:"Nothing yet. Finish setup and make an authenticated Lobu MCP request; the agent appears here automatically."}):e.jsx("div",{className:"overflow-hidden rounded-lg border",children:r.map((a,d)=>e.jsxs(p,{to:"/$owner/agents/connected/$clientId",params:{owner:t,clientId:a.clientId},className:D(d,r.length),children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",children:e.jsx(f,{name:a.title})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:a.title}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:U(a)})]})]},a.key))})}),e.jsx(x,{title:"Manual MCP details",children:e.jsxs("dl",{className:"grid grid-cols-[5rem_1fr] gap-x-3 gap-y-1 rounded-lg border bg-muted/40 p-3 text-xs",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Name"}),e.jsx("dd",{className:"font-mono",children:"lobu"}),e.jsx("dt",{className:"text-muted-foreground",children:"MCP URL"}),e.jsx("dd",{className:"break-all font-mono",children:o})]})})]})})}export{W as A,q as a};
2
+ //# sourceMappingURL=agent-connect-pages-B_vrqLVc.js.map
@@ -1,2 +1,2 @@
1
- import{aw as he,ax as xe,j as e,B as f,cC as pe,e1 as fe,a_ as ve,P as be,fe as je,ck as U,dd as V,cy as we,gK as ye,gL as Ne,gM as Ce,gN as Me,fV as Se,gO as ke,bO as Ie,bP as Ae,ay as Pe,r as q,bH as E,ex as H,bS as Fe,y as b,f3 as $,I as De,Q as Te,bn as $e,bo as Re,bp as _e,bq as Ee,br as K}from"./index-_oPeVpL_.js";import{b as Le,s as Oe}from"./model-selector-CB1BDvlW.js";function Be(t){const a=t.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").replace(/-{2,}/g,"-");return(a?/^[a-z]/.test(a)&&a.length>=3?a:`agent-${a}`:"agent").slice(0,60).replace(/-+$/g,"")||"agent"}function ze(t,a){const m=new Set(a),h=Be(t);let x=h,u=2;for(;m.has(x);){const g=`-${u}`;x=`${h.slice(0,Math.max(1,60-g.length)).replace(/-+$/g,"")||"agent"}${g}`,u+=1}return x}const Ue="__unresolved__";function W(t){return t.endsWith(`/${Ue}`)}function G(t){const a=t.indexOf("/");return a===-1?{slug:t,model:""}:{slug:t.slice(0,a),model:t.slice(a+1)}}function Ve(t,a){const{slug:m,model:h}=G(t);return{provider:a.find(g=>g.value===t)?.provider??a.find(g=>G(g.value).slug===m)?.provider??m,model:h}}function qe({value:t,onChange:a,disabled:m}){const{data:h=[]}=he(),{data:x=[]}=xe(),u=Le(h,x),g=(s,o)=>{const n=s+o;if(n<0||n>=t.length)return;const c=[...t];[c[s],c[n]]=[c[n],c[s]],a(c)},C=s=>{a(t.filter((o,n)=>n!==s))},M=s=>{t.includes(s)||a([...t,s])},d=u.filter(s=>!t.includes(s.value)&&!W(s.value));return e.jsxs("div",{className:"grid gap-2",children:[t.length===0?e.jsx("p",{className:"rounded-lg border border-dashed bg-muted/20 px-3 py-4 text-center text-[11px] text-muted-foreground",children:"No models pinned — this agent uses the org default."}):e.jsx("ul",{className:"grid gap-1.5",children:t.map((s,o)=>{const n=W(s),{provider:c,model:i}=Ve(s,u);return e.jsxs("li",{className:be("flex items-center gap-2 rounded-lg border bg-muted/20 px-3 py-2",n&&"opacity-60"),children:[e.jsxs("div",{className:"grid min-w-0 flex-1 gap-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-sm",children:c}),o===0?e.jsx("span",{className:"shrink-0 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary",children:"Default"}):null]}),e.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:n?"no model selected":i})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx(f,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7","aria-label":"Move up",disabled:m||o===0,onClick:()=>g(o,-1),children:e.jsx(pe,{className:"h-4 w-4"})}),e.jsx(f,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7","aria-label":"Move down",disabled:m||o===t.length-1,onClick:()=>g(o,1),children:e.jsx(fe,{className:"h-4 w-4"})}),e.jsx(f,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive","aria-label":"Remove model",disabled:m,onClick:()=>C(o),children:e.jsx(ve,{className:"h-4 w-4"})})]})]},s)})}),e.jsx(je,{contentClassName:"w-[--radix-popover-trigger-width] min-w-[280px]",searchPlaceholder:"Search or type a model ref…",emptyText:"Type a full provider/model ref to use it.",trigger:s=>e.jsxs(f,{type:"button",variant:"outline",role:"combobox","aria-expanded":s,disabled:m,className:"w-full justify-start font-normal text-muted-foreground",children:[e.jsx(we,{className:"mr-2 h-4 w-4 shrink-0"}),"Add model"]}),children:(s,o)=>{const n=o.trim(),c=Oe(n,u)&&!t.includes(n);return e.jsxs(e.Fragment,{children:[d.map(i=>e.jsxs(U,{value:`${i.provider} ${i.model} ${i.value}`,onSelect:()=>{M(i.value),s()},className:"cursor-pointer",children:[e.jsx(V,{className:"mr-2 h-4 w-4 opacity-0"}),e.jsxs("span",{className:"truncate",children:[i.provider," ",e.jsx("span",{className:"text-muted-foreground text-xs",children:i.model}),i.isDefault?e.jsx("span",{className:"ml-1.5 text-muted-foreground text-xs",children:"· org default"}):null]})]},i.value)),c?e.jsxs(U,{value:`__custom__ ${n}`,onSelect:()=>{M(n),s()},className:"cursor-pointer",children:[e.jsx(V,{className:"mr-2 h-4 w-4 opacity-0"}),e.jsxs("span",{children:["Use ",e.jsx("span",{className:"font-mono text-xs",children:n})]})]}):null]})}})]})}function Ge({mode:t,section:a="identity",existingAgentIds:m=[],onCreated:h,onCancel:x,onDone:u,reviewMode:g="none",reviewProposal:C=null,reviewControlsDisabled:M=!1}){const d=t.kind==="create",s=t.kind==="edit"?t.agent:null,o=!d&&a!=="platforms"&&a!=="skills"&&!!s,n=ye(),c=Ne(s?.agentId??""),i=Ce(s?.agentId??""),S=Me(s?.agentId??""),{data:p,isLoading:L}=Se(s?.agentId,{enabled:o}),O=!d&&g==="active"?C:null,R=O?ke(O.proposal):void 0,w=p,B=s?.agentId??"create",r=Ie(B,{name:R?.name??s?.name??"",description:R?.description??s?.description??"",identityMd:R?.identityMd??p?.identityMd??"",soulMd:p?.soulMd??"",userMd:p?.userMd??"",models:w?.models??w?.settings?.models??[],showToolCalls:w?.showToolCalls??w?.settings?.showToolCalls??!1,sandboxId:w?.sandboxId??w?.settings?.sandboxId??"builtin"}),[j,Q]=r.field("name"),[y,Y]=r.field("description"),[k,J]=r.field("identityMd"),[I,X]=r.field("soulMd"),[A,Z]=r.field("userMd"),[P,ee]=r.field("models"),[F,se]=r.field("showToolCalls"),[N,te]=r.field("sandboxId"),[ae,D]=Ae(B,!1),{data:ne}=Pe({enabled:a==="models"&&!d}),le=q.useCallback(async l=>{if(l.preventDefault(),!!r.canSubmit){if(d){const T=await n.mutateAsync({agentId:ze(j,m),name:j.trim(),description:y.trim()||void 0});h?await h(T.agentId):u?.();return}if(s){if(!p){E.error("Still loading agent settings — try again in a moment");return}try{await Promise.all([c.mutateAsync({name:j.trim()||s.name,description:y.trim()||void 0}),S.mutateAsync({identityMd:k.trim(),soulMd:I.trim(),userMd:A.trim(),models:P,authProfiles:p.authProfiles??[],skillsConfig:p.skillsConfig,showToolCalls:F,sandboxId:N==="builtin"?void 0:N})]),r.accept(r.values,{name:j.trim()||s.name,description:y.trim()||s.description||"",identityMd:k.trim(),soulMd:I.trim(),userMd:A.trim(),models:P,showToolCalls:F,sandboxId:N}),E.success("Agent saved"),u?.()}catch(T){E.error(T instanceof Error?T.message:"Failed to save agent")}}}},[p,n,y,r.accept,r.values,r.canSubmit,N,m,k,d,P,j,h,u,s,F,I,c,S,A]),ie=q.useCallback(async()=>{s&&(await i.mutateAsync(),D(!1),u?.())},[i,u,s,D]),_=n.isPending||c.isPending||i.isPending||S.isPending,re=d||!!p;if(o&&L)return e.jsx(H,{rows:6});const v=_||M,de=g==="none"||g==="gone",oe=j.trim().length>0&&re,ce=d||a==="settings",me=!d&&(a==="identity"||a==="settings"),ue=!d&&a==="settings",ge=!d&&a==="settings",z=!d&&a==="models";return e.jsxs("form",{onSubmit:le,className:"flex min-h-0 flex-col",children:[e.jsx(Fe,{visible:r.hasConflict,onReload:r.reset}),e.jsxs("div",{className:"grid content-start gap-4 py-2",children:[me?L?e.jsx(H,{rows:4}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"identity-md",children:"Identity"}),e.jsx($,{id:"identity-md",rows:6,value:k,onChange:l=>J(l.target.value),disabled:v,placeholder:"You are a market intelligence agent. Track competitors, analyze launches and signals, and surface concise, decision-ready insights."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"soul-md",children:"Soul"}),e.jsx($,{id:"soul-md",rows:6,value:I,onChange:l=>X(l.target.value),disabled:v,placeholder:"Be rigorous, skeptical of weak signals, and calm under ambiguity. Prefer crisp summaries, explicit evidence, and clear confidence levels."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"user-md",children:"User prompt"}),e.jsx($,{id:"user-md",rows:6,value:A,onChange:l=>Z(l.target.value),disabled:v,placeholder:"Monitor the market for notable competitor moves, pricing changes, launches, partnerships, and customer sentiment shifts. Summarize what changed, why it matters, and what to watch next."})]})]}):null,ce?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(b,{htmlFor:"agent-name",children:["Name ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(De,{id:"agent-name",placeholder:"Support Bot",value:j,onChange:l=>Q(l.target.value),disabled:v,required:!0}),d?e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"The agent ID will be generated automatically from the name."}):null]}),d?null:e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"agent-description",children:"Description"}),e.jsx($,{id:"agent-description",placeholder:"Handles customer support and triage across channels.",value:y,onChange:l=>Y(l.target.value),disabled:v,rows:3})]})]}):null,ge?e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/20 p-3",children:[e.jsx(Te,{id:"show-tool-calls",checked:F,onCheckedChange:l=>se(l===!0),disabled:v,className:"mt-0.5"}),e.jsxs("div",{className:"grid gap-0.5",children:[e.jsx(b,{htmlFor:"show-tool-calls",className:"cursor-pointer",children:"Show tool calls in chat"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Render the agent's tool invocations (name, arguments, and result) as cards in the web chat. Off by default."})]})]}):null,z?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"Models"}),e.jsx(qe,{value:P,onChange:ee,disabled:v}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Ordered list; the first is the default. Only these models may be used — a request for anything else falls back to the first available one. Leave empty to use the org default."})]}):null,z?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"agent-sandbox",children:"Run in sandbox"}),e.jsxs($e,{value:N,onValueChange:te,disabled:v,children:[e.jsx(Re,{id:"agent-sandbox",className:"w-full",children:e.jsx(_e,{placeholder:"Built-in"})}),e.jsxs(Ee,{children:[e.jsx(K,{value:"builtin",children:"Built-in (default)"}),(ne?.sandboxes??[]).map(l=>e.jsxs(K,{value:l.id,children:[l.name," (",l.providerKind,")",l.connected?"":" — no credential"]},l.id))]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Where this agent's commands execute. Built-in runs in-process; sandboxes run on a connected provider. Manage sandboxes under Connect › Runtime."})]}):null]}),de?e.jsxs("div",{className:"mt-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[ue?ae?e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(f,{type:"button",variant:"destructive",onClick:()=>void ie(),disabled:i.isPending,children:i.isPending?"Deleting...":"Delete agent"}),e.jsx(f,{type:"button",variant:"outline",onClick:()=>D(!1),disabled:i.isPending,children:"Cancel"})]}):e.jsx(f,{type:"button",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>D(!0),disabled:i.isPending,children:"Delete agent"}):e.jsx("span",{}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[x?e.jsx(f,{type:"button",variant:"outline",onClick:x,disabled:_,children:"Cancel"}):null,e.jsx(f,{type:"submit",disabled:!r.canSubmit||!oe||_,children:d?n.isPending?"Creating...":"Create agent":c.isPending||S.isPending?"Saving...":"Save changes"})]})]}):null]})}export{Ge as A};
2
- //# sourceMappingURL=agent-editor-form-oUnIYHd7.js.map
1
+ import{aw as he,ax as xe,j as e,B as f,cC as pe,e1 as fe,a_ as ve,P as be,fe as je,ck as U,dd as V,cy as we,gH as ye,gI as Ne,gJ as Ce,gK as Me,fV as Se,gL as ke,bO as Ie,bP as Ae,ay as Pe,r as q,bH as E,ex as H,bS as Fe,y as b,f3 as $,I as De,Q as Te,bn as $e,bo as Re,bp as _e,bq as Ee,br as K}from"./index-Cr5hwh-C.js";import{b as Le,s as Be}from"./model-selector-dAbDgJvx.js";function Oe(t){const a=t.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").replace(/-{2,}/g,"-");return(a?/^[a-z]/.test(a)&&a.length>=3?a:`agent-${a}`:"agent").slice(0,60).replace(/-+$/g,"")||"agent"}function ze(t,a){const m=new Set(a),h=Oe(t);let x=h,u=2;for(;m.has(x);){const g=`-${u}`;x=`${h.slice(0,Math.max(1,60-g.length)).replace(/-+$/g,"")||"agent"}${g}`,u+=1}return x}const Ue="__unresolved__";function W(t){return t.endsWith(`/${Ue}`)}function G(t){const a=t.indexOf("/");return a===-1?{slug:t,model:""}:{slug:t.slice(0,a),model:t.slice(a+1)}}function Ve(t,a){const{slug:m,model:h}=G(t);return{provider:a.find(g=>g.value===t)?.provider??a.find(g=>G(g.value).slug===m)?.provider??m,model:h}}function qe({value:t,onChange:a,disabled:m}){const{data:h=[]}=he(),{data:x=[]}=xe(),u=Le(h,x),g=(s,o)=>{const n=s+o;if(n<0||n>=t.length)return;const c=[...t];[c[s],c[n]]=[c[n],c[s]],a(c)},C=s=>{a(t.filter((o,n)=>n!==s))},M=s=>{t.includes(s)||a([...t,s])},d=u.filter(s=>!t.includes(s.value)&&!W(s.value));return e.jsxs("div",{className:"grid gap-2",children:[t.length===0?e.jsx("p",{className:"rounded-lg border border-dashed bg-muted/20 px-3 py-4 text-center text-[11px] text-muted-foreground",children:"No models pinned — this agent uses the org default."}):e.jsx("ul",{className:"grid gap-1.5",children:t.map((s,o)=>{const n=W(s),{provider:c,model:i}=Ve(s,u);return e.jsxs("li",{className:be("flex items-center gap-2 rounded-lg border bg-muted/20 px-3 py-2",n&&"opacity-60"),children:[e.jsxs("div",{className:"grid min-w-0 flex-1 gap-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-sm",children:c}),o===0?e.jsx("span",{className:"shrink-0 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary",children:"Default"}):null]}),e.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:n?"no model selected":i})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx(f,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7","aria-label":"Move up",disabled:m||o===0,onClick:()=>g(o,-1),children:e.jsx(pe,{className:"h-4 w-4"})}),e.jsx(f,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7","aria-label":"Move down",disabled:m||o===t.length-1,onClick:()=>g(o,1),children:e.jsx(fe,{className:"h-4 w-4"})}),e.jsx(f,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive","aria-label":"Remove model",disabled:m,onClick:()=>C(o),children:e.jsx(ve,{className:"h-4 w-4"})})]})]},s)})}),e.jsx(je,{contentClassName:"w-[--radix-popover-trigger-width] min-w-[280px]",searchPlaceholder:"Search or type a model ref…",emptyText:"Type a full provider/model ref to use it.",trigger:s=>e.jsxs(f,{type:"button",variant:"outline",role:"combobox","aria-expanded":s,disabled:m,className:"w-full justify-start font-normal text-muted-foreground",children:[e.jsx(we,{className:"mr-2 h-4 w-4 shrink-0"}),"Add model"]}),children:(s,o)=>{const n=o.trim(),c=Be(n,u)&&!t.includes(n);return e.jsxs(e.Fragment,{children:[d.map(i=>e.jsxs(U,{value:`${i.provider} ${i.model} ${i.value}`,onSelect:()=>{M(i.value),s()},className:"cursor-pointer",children:[e.jsx(V,{className:"mr-2 h-4 w-4 opacity-0"}),e.jsxs("span",{className:"truncate",children:[i.provider," ",e.jsx("span",{className:"text-muted-foreground text-xs",children:i.model}),i.isDefault?e.jsx("span",{className:"ml-1.5 text-muted-foreground text-xs",children:"· org default"}):null]})]},i.value)),c?e.jsxs(U,{value:`__custom__ ${n}`,onSelect:()=>{M(n),s()},className:"cursor-pointer",children:[e.jsx(V,{className:"mr-2 h-4 w-4 opacity-0"}),e.jsxs("span",{children:["Use ",e.jsx("span",{className:"font-mono text-xs",children:n})]})]}):null]})}})]})}function Ge({mode:t,section:a="identity",existingAgentIds:m=[],onCreated:h,onCancel:x,onDone:u,reviewMode:g="none",reviewProposal:C=null,reviewControlsDisabled:M=!1}){const d=t.kind==="create",s=t.kind==="edit"?t.agent:null,o=!d&&a!=="platforms"&&a!=="skills"&&!!s,n=ye(),c=Ne(s?.agentId??""),i=Ce(s?.agentId??""),S=Me(s?.agentId??""),{data:p,isLoading:L}=Se(s?.agentId,{enabled:o}),B=!d&&g==="active"?C:null,R=B?ke(B.proposal):void 0,w=p,O=s?.agentId??"create",r=Ie(O,{name:R?.name??s?.name??"",description:R?.description??s?.description??"",identityMd:R?.identityMd??p?.identityMd??"",soulMd:p?.soulMd??"",userMd:p?.userMd??"",models:w?.models??w?.settings?.models??[],showToolCalls:w?.showToolCalls??w?.settings?.showToolCalls??!1,sandboxId:w?.sandboxId??w?.settings?.sandboxId??"builtin"}),[j,J]=r.field("name"),[y,Q]=r.field("description"),[k,Y]=r.field("identityMd"),[I,X]=r.field("soulMd"),[A,Z]=r.field("userMd"),[P,ee]=r.field("models"),[F,se]=r.field("showToolCalls"),[N,te]=r.field("sandboxId"),[ae,D]=Ae(O,!1),{data:ne}=Pe({enabled:a==="models"&&!d}),le=q.useCallback(async l=>{if(l.preventDefault(),!!r.canSubmit){if(d){const T=await n.mutateAsync({agentId:ze(j,m),name:j.trim(),description:y.trim()||void 0});h?await h(T.agentId):u?.();return}if(s){if(!p){E.error("Still loading agent settings — try again in a moment");return}try{await Promise.all([c.mutateAsync({name:j.trim()||s.name,description:y.trim()||void 0}),S.mutateAsync({identityMd:k.trim(),soulMd:I.trim(),userMd:A.trim(),models:P,authProfiles:p.authProfiles??[],skillsConfig:p.skillsConfig,showToolCalls:F,sandboxId:N==="builtin"?void 0:N})]),r.accept(r.values,{name:j.trim()||s.name,description:y.trim()||s.description||"",identityMd:k.trim(),soulMd:I.trim(),userMd:A.trim(),models:P,showToolCalls:F,sandboxId:N}),E.success("Agent saved"),u?.()}catch(T){E.error(T instanceof Error?T.message:"Failed to save agent")}}}},[p,n,y,r.accept,r.values,r.canSubmit,N,m,k,d,P,j,h,u,s,F,I,c,S,A]),ie=q.useCallback(async()=>{s&&(await i.mutateAsync(),D(!1),u?.())},[i,u,s,D]),_=n.isPending||c.isPending||i.isPending||S.isPending,re=d||!!p;if(o&&L)return e.jsx(H,{rows:6});const v=_||M,de=g==="none"||g==="gone",oe=j.trim().length>0&&re,ce=d||a==="settings",me=!d&&(a==="identity"||a==="settings"),ue=!d&&a==="settings",ge=!d&&a==="settings",z=!d&&a==="models";return e.jsxs("form",{onSubmit:le,className:"flex min-h-0 flex-col",children:[e.jsx(Fe,{visible:r.hasConflict,onReload:r.reset}),e.jsxs("div",{className:"grid content-start gap-4 py-2",children:[me?L?e.jsx(H,{rows:4}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"identity-md",children:"Identity"}),e.jsx($,{id:"identity-md",rows:6,value:k,onChange:l=>Y(l.target.value),disabled:v,placeholder:"You are a market intelligence agent. Track competitors, analyze launches and signals, and surface concise, decision-ready insights."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"soul-md",children:"Soul"}),e.jsx($,{id:"soul-md",rows:6,value:I,onChange:l=>X(l.target.value),disabled:v,placeholder:"Be rigorous, skeptical of weak signals, and calm under ambiguity. Prefer crisp summaries, explicit evidence, and clear confidence levels."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"user-md",children:"User prompt"}),e.jsx($,{id:"user-md",rows:6,value:A,onChange:l=>Z(l.target.value),disabled:v,placeholder:"Monitor the market for notable competitor moves, pricing changes, launches, partnerships, and customer sentiment shifts. Summarize what changed, why it matters, and what to watch next."})]})]}):null,ce?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(b,{htmlFor:"agent-name",children:["Name ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(De,{id:"agent-name",placeholder:"Support Bot",value:j,onChange:l=>J(l.target.value),disabled:v,required:!0}),d?e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"The agent ID will be generated automatically from the name."}):null]}),d?null:e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"agent-description",children:"Description"}),e.jsx($,{id:"agent-description",placeholder:"Handles customer support and triage across channels.",value:y,onChange:l=>Q(l.target.value),disabled:v,rows:3})]})]}):null,ge?e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/20 p-3",children:[e.jsx(Te,{id:"show-tool-calls",checked:F,onCheckedChange:l=>se(l===!0),disabled:v,className:"mt-0.5"}),e.jsxs("div",{className:"grid gap-0.5",children:[e.jsx(b,{htmlFor:"show-tool-calls",className:"cursor-pointer",children:"Show tool calls in chat"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Render the agent's tool invocations (name, arguments, and result) as cards in the web chat. Off by default."})]})]}):null,z?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"Models"}),e.jsx(qe,{value:P,onChange:ee,disabled:v}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Ordered list; the first is the default. Only these models may be used — a request for anything else falls back to the first available one. Leave empty to use the org default."})]}):null,z?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{htmlFor:"agent-sandbox",children:"Run in sandbox"}),e.jsxs($e,{value:N,onValueChange:te,disabled:v,children:[e.jsx(Re,{id:"agent-sandbox",className:"w-full",children:e.jsx(_e,{placeholder:"Built-in"})}),e.jsxs(Ee,{children:[e.jsx(K,{value:"builtin",children:"Built-in (default)"}),(ne?.sandboxes??[]).map(l=>e.jsxs(K,{value:l.id,children:[l.name," (",l.providerKind,")",l.connected?"":" — no credential"]},l.id))]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Where this agent's commands execute. Built-in runs in-process; sandboxes run on a connected provider. Manage sandboxes under Connect › Runtime."})]}):null]}),de?e.jsxs("div",{className:"mt-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[ue?ae?e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(f,{type:"button",variant:"destructive",onClick:()=>void ie(),disabled:i.isPending,children:i.isPending?"Deleting...":"Delete agent"}),e.jsx(f,{type:"button",variant:"outline",onClick:()=>D(!1),disabled:i.isPending,children:"Cancel"})]}):e.jsx(f,{type:"button",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>D(!0),disabled:i.isPending,children:"Delete agent"}):e.jsx("span",{}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[x?e.jsx(f,{type:"button",variant:"outline",onClick:x,disabled:_,children:"Cancel"}):null,e.jsx(f,{type:"submit",disabled:!r.canSubmit||!oe||_,children:d?n.isPending?"Creating...":"Create agent":c.isPending||S.isPending?"Saving...":"Save changes"})]})]}):null]})}export{Ge as A};
2
+ //# sourceMappingURL=agent-editor-form-hTs7eO_U.js.map
@@ -1,2 +1,2 @@
1
- import{r as y,j as e,y as w,I as S,bn as Q,bo as X,bp as Y,bq as ee,br as ae,f3 as te,B as k,m as B,fV as A,iv as L,iw as U,gN as F,ex as se,bH as b,f$ as I,bx as ne,bK as re,aQ as D,g1 as ie,dZ as oe,d_ as le,d$ as M,e0 as E,e3 as de,e4 as $,M as ue,h_ as ce,bz as q,cy as me,P as R,it as ge}from"./index-_oPeVpL_.js";import{M as he}from"./model-selector-CB1BDvlW.js";import{a as xe,A as pe}from"./agent-subpage-shell-B3K_jPYR.js";import{f as fe}from"./agent-loading-shells-CtZJM2Gc.js";import{A as be}from"./agent-card-controls-DzRs4Ix9.js";const je=[{value:"input",label:"Input",hint:"the user message, before the agent runs"},{value:"output",label:"Output",hint:"the agent's reply, before the user sees it"},{value:"pre-tool",label:"Pre-tool",hint:"a tool call, before it executes"},{value:"egress",label:"Egress",hint:"an outbound request to a judged domain"}];function J({initial:a,judgeModelDefault:t,submitLabel:n,submitting:s,onSubmit:o,onCancel:r}){const[i,d]=y.useState(a?.name??""),[h,j]=y.useState(a?.stage??"input"),[p,N]=y.useState(a?.policy??""),[f,C]=y.useState(a?.model??""),[x,u]=y.useState((a?.tools??[]).join(", ")),[l,m]=y.useState((a?.domains??[]).join(", ")),g=a?.kind,v=g==="require-tool",K=c=>{c.preventDefault();const _=x.split(",").map(T=>T.trim()).filter(Boolean);o({name:i,stage:h,...g?{kind:g}:{},policy:p,model:f.trim()||void 0,tools:(v||h==="pre-tool")&&_.length>0?_:void 0,domains:h==="egress"&&l.trim()?l.split(",").map(T=>T.trim()).filter(Boolean):void 0,enabled:a?.enabled??!0})};return e.jsxs("form",{onSubmit:K,className:"space-y-5",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(w,{htmlFor:"guardrail-name",children:["Name ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"guardrail-name",value:i,onChange:c=>d(c.target.value),placeholder:"no-competitor-mentions",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Shown in the list and on every trip. Must be unique."})]}),v?null:e.jsxs("div",{className:"grid gap-2",children:[e.jsx(w,{htmlFor:"guardrail-stage",children:"Stage"}),e.jsxs(Q,{value:h,onValueChange:c=>j(c),disabled:s,children:[e.jsx(X,{id:"guardrail-stage",children:e.jsx(Y,{})}),e.jsx(ee,{children:je.map(c=>e.jsxs(ae,{value:c.value,children:[c.label," — ",c.hint]},c.value))})]})]}),v?e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(w,{htmlFor:"guardrail-required-tools",children:["Required tools ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"guardrail-required-tools",value:x,onChange:c=>u(c.target.value),placeholder:"suggest_actions",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Comma-separated. The turn trips if the agent finishes without calling every one of these. No judge model runs — this is a lookup against the tools the turn actually used."})]}):null,v?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(w,{htmlFor:"guardrail-policy",children:["Policy ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(te,{id:"guardrail-policy",rows:5,value:p,onChange:c=>N(c.target.value),placeholder:"Deny any response that names a competitor (Acme, Globex) or quotes their pricing.",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"A judge model reads this and the text at the chosen stage, then allows or denies. Write it as an instruction to a reviewer."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(w,{htmlFor:"guardrail-model",children:["Judge model",t?null:e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(he,{value:f,onChange:C,placeholder:t?`Default (${t})`:"Select a model",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t?"Optional. Leave blank to use the gateway's default judge model.":"Required: the gateway has no default judge model (EGRESS_JUDGE_MODEL is unset)."})]})]}),!v&&h==="pre-tool"?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(w,{htmlFor:"guardrail-tools",children:"Tool scope"}),e.jsx(S,{id:"guardrail-tools",value:x,onChange:c=>u(c.target.value),placeholder:"github.delete_repo, fs.delete",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Optional, comma-separated. Leave blank to judge every tool call."})]}):null,h==="egress"?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(w,{htmlFor:"guardrail-domains",children:"Domains"}),e.jsx(S,{id:"guardrail-domains",value:l,onChange:c=>m(c.target.value),placeholder:"api.github.com, .slack.com",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Comma-separated hostnames this judge gates — exact (api.github.com) or wildcard (.slack.com). Leave blank to route nothing."})]}):null,e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:justify-end",children:[r?e.jsx(k,{type:"button",variant:"outline",onClick:r,disabled:s,children:"Cancel"}):null,e.jsx(k,{type:"submit",disabled:s,children:s?"Saving…":n})]})]})}function z(a){return a.kind==="require-tool"}function H(a,t,n,s,o){const r=a.name.trim();return r?/^[a-zA-Z0-9][a-zA-Z0-9 _-]*$/.test(r)?n.includes(r)?`"${r}" is a built-in guardrail name — pick another.`:t.some(d=>d.name===r&&d.name!==o)?`A custom guardrail named "${r}" already exists.`:z(a)?a.stage!=="output"?"A required-tool guardrail only runs at the output stage.":a.tools?.some(d=>d.trim())?null:"List at least one tool that must be used.":a.policy.trim()?!s&&!a.model?.trim()?"Judge model is required — the gateway has no default (EGRESS_JUDGE_MODEL is unset).":null:"Policy is required.":"Name may use letters, numbers, spaces, hyphens, and underscores.":"Name is required."}function V(a){const t=z(a),s=(t||a.stage==="pre-tool")&&a.tools&&a.tools.length>0?a.tools.map(d=>d.trim()).filter(Boolean):void 0,o=a.stage==="egress"&&a.domains&&a.domains.length>0?a.domains.map(d=>d.trim()).filter(Boolean):void 0,r=a.model?.trim()||void 0,i=a.policy.trim();return{name:a.name.trim(),enabled:a.enabled,stage:a.stage,...t?{kind:"require-tool"}:{},...t?i?{policy:i}:{}:{policy:i},...r?{model:r}:{},...s&&s.length>0?{tools:s}:{},...o&&o.length>0?{domains:o}:{}}}function ve(a,t){return[...a,V(t)]}function ye(a,t,n){return a.map(s=>s.name===t?V(n):s)}function Ne(a,t){return a.filter(n=>n.name!==t)}function Ce(a,t,n){return a.map(s=>s.name===t?{...s,enabled:n}:s)}function we({owner:a,agentId:t}){const n=B(),{data:s,isLoading:o}=A(t),{data:r,isLoading:i}=L(t),{data:d=null,isLoading:h}=U(t),j=o||i||h,p=F(t),N=s?.guardrailsInline??[],f=(r??[]).map(u=>u.name),C=async u=>{if(!s){b.error("Still loading agent settings — try again in a moment");return}const l=H(u,N,f,d);if(l){b.error(l);return}try{await p.mutateAsync({guardrailsInline:ve(N,u)}),b.success("Guardrail created"),n({to:"/$owner/agents/$agentId/guardrails",params:{owner:a,agentId:t}})}catch(m){b.error(m instanceof Error?m.message:"Failed to create guardrail")}},x=()=>void n({to:"/$owner/agents/$agentId/guardrails",params:{owner:a,agentId:t}});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(xe,{title:"New custom guardrail",description:"A custom guardrail judges text at one stage against a policy you write.",backLabel:"Guardrails",onBack:x}),j?e.jsx(se,{rows:4}):e.jsx(J,{judgeModelDefault:d,submitLabel:"Create guardrail",submitting:p.isPending,onSubmit:C,onCancel:x})]})}function P(a,t){const n=new Set(a?.guardrails??[]),s=new Set(t.map(i=>i.name)),o=t.map(i=>({name:i.name,stages:i.stages,description:i.description,enabled:n.has(i.name),unknown:!1})),r=(a?.guardrails??[]).filter(i=>!s.has(i)).map(i=>({name:i,stages:[],enabled:!0,unknown:!0}));return[...o,...r]}function ke(a){return a.filter(t=>t.enabled||t.unknown).map(t=>t.name)}function Se(a,t,n){return ke(a.map(s=>s.name===t&&!s.unknown?{...s,enabled:n}:s))}const G={input:"Input",output:"Output","pre-tool":"Pre-tool",egress:"Egress"};function Ge(a){const t=new Date(a);return Number.isNaN(t.getTime())?a:ce(t,{addSuffix:!0})}function Ae({owner:a,agentId:t,name:n}){const{data:s}=A(t),{data:o}=L(t),r=y.useMemo(()=>P(s,o??[]).find(d=>d.name===n)??null,[s,o,n]),i=(s?.guardrailsInline??[]).find(d=>d.name===n);return i?e.jsx(Te,{owner:a,agentId:t,guardrail:i}):r?e.jsx(Le,{agentId:t,name:n,row:r}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Guardrail not found."})}function Le({agentId:a,name:t,row:n}){return e.jsxs("div",{className:"space-y-8",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:n.description??(n.stages.length>0?`Built-in. Short-circuits this agent's ${n.stages.map(s=>G[s].toLowerCase()).join(", ")} stage${n.stages.length>1?"s":""} when it matches.`:"Configured out of band — toggling is managed via lobu apply.")}),e.jsx(W,{agentId:a,guardrail:t})]})}function Te({owner:a,agentId:t,guardrail:n}){const s=B(),{data:o}=A(t),{data:r}=L(t),{data:i=null}=U(t),d=F(t),[h,j]=y.useState(!1),p=o?.guardrailsInline??[],N=(r??[]).map(u=>u.name),f=async(u,l)=>{if(!o)return b.error("Still loading agent settings — try again in a moment"),!1;try{return await d.mutateAsync({guardrailsInline:u}),b.success(l),!0}catch(m){return b.error(m instanceof Error?m.message:"Failed to save guardrail"),!1}},C=async u=>{const l=H(u,p,N,i,n.name);if(l){b.error(l);return}await f(ye(p,n.name,u),"Guardrail saved")&&u.name.trim()!==n.name&&s({to:"/$owner/agents/$agentId/guardrails/$name",params:{owner:a,agentId:t,name:encodeURIComponent(u.name.trim())}})},x=async()=>{await f(Ne(p,n.name),"Guardrail deleted")&&s({to:"/$owner/agents/$agentId/guardrails",params:{owner:a,agentId:t}})};return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:n.kind==="require-tool"?"Required tools":"Policy"}),e.jsx(J,{initial:n,judgeModelDefault:i,submitLabel:"Save changes",submitting:d.isPending,onSubmit:C})]}),e.jsx("div",{className:"flex justify-end",children:h?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{type:"button",variant:"destructive",onClick:()=>void x(),disabled:d.isPending,children:"Delete guardrail"}),e.jsx(k,{type:"button",variant:"outline",onClick:()=>j(!1),disabled:d.isPending,children:"Cancel"})]}):e.jsxs(k,{type:"button",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>j(!0),children:["Delete ",n.name]})}),e.jsx(W,{agentId:t,guardrail:n.name})]})}function W({agentId:a,guardrail:t}){const{data:n=[],isLoading:s,isError:o}=I(a,{guardrail:t});return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Recent catches"}),s?e.jsx(ne,{label:"catches",variant:"table",rows:4}):o?e.jsx(re,{label:"catches"}):n.length===0?e.jsx(D,{icon:ie,title:"No catches yet",description:"This guardrail hasn't short-circuited anything on this agent."}):e.jsx("div",{className:"overflow-hidden rounded-lg border",children:e.jsxs(oe,{children:[e.jsx(le,{children:e.jsxs(M,{children:[e.jsx(E,{className:"w-[180px]",children:"When"}),e.jsx(E,{className:"w-[120px]",children:"Stage"}),e.jsx(E,{children:"Reason"})]})}),e.jsx(de,{children:n.map(r=>e.jsxs(M,{children:[e.jsx($,{className:"text-xs text-muted-foreground",title:r.occurredAt,children:Ge(r.occurredAt)}),e.jsx($,{children:e.jsx(ue,{variant:"outline",className:"text-[10px]",children:G[r.stage]})}),e.jsx($,{className:"text-sm text-muted-foreground",children:r.reason??e.jsx("span",{className:"italic",children:"no reason recorded"})})]},r.id))})]})})]})}function Ee({description:a,action:t}){return e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("p",{className:"min-w-0 flex-1 text-center text-sm text-muted-foreground",children:a}),t?e.jsx("div",{className:"shrink-0",children:t}):null]})}function O(a,t){return a.get(t)??0}function $e(a,t,n){const s=a.map(r=>{const i=r.stages.map(d=>G[d]);return r.unknown&&i.push("Unknown"),{id:r.name,name:r.name,kind:"builtin",description:r.description,stages:r.stages,enabled:r.enabled,unknown:r.unknown,badges:i,tripCount:O(n,r.name)}}),o=t.map(r=>{const i=[G[r.stage],"Custom"];return{id:r.name,name:r.name,kind:"custom",description:r.policy,stages:[r.stage],enabled:r.enabled,unknown:!1,badges:i,tripCount:O(n,r.name)}});return[...s,...o]}function Re({owner:a,agentId:t,expandedName:n}){const s=B(),{data:o,isLoading:r}=A(t),{data:i,isLoading:d}=L(t),{data:h=[]}=I(t),j=F(t),p=async(l,m)=>{if(!o){b.error("Still loading agent settings — try again in a moment");return}try{if(l.kind==="custom")await j.mutateAsync({guardrailsInline:Ce(o.guardrailsInline??[],l.name,m)});else{const g=P(o,i??[]);await j.mutateAsync({guardrails:Se(g,l.name,m)})}b.success(m?"Guardrail enabled":"Guardrail disabled")}catch(g){b.error(g instanceof Error?g.message:"Failed to save guardrail")}},N=i===null,f=y.useMemo(()=>{const l=P(o,i??[]),m=o?.guardrailsInline??[],g=new Map;for(const v of h)g.set(v.guardrailName,(g.get(v.guardrailName)??0)+1);return $e(l,m,g)},[o,i,h]),C=l=>{if(l===n){s({to:"/$owner/agents/$agentId/guardrails",params:{owner:a,agentId:t}});return}s({to:"/$owner/agents/$agentId/guardrails/$name",params:{owner:a,agentId:t,name:encodeURIComponent(l)}})},x=()=>{s({to:"/$owner/agents/$agentId/guardrails/create",params:{owner:a,agentId:t}})},u=r||d;return!u&&f.length===0?e.jsx("div",{className:"space-y-6",children:N?e.jsx(D,{icon:q,title:"Guardrails catalog unavailable",description:"Guardrails will appear here once the gateway publishes its catalog.",actionLabel:"New guardrail",onAction:x}):e.jsx(D,{icon:q,title:"No guardrails yet",description:"Enable a built-in in lobu.toml or write a custom policy guardrail.",actionLabel:"New guardrail",onAction:x})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{description:"Each guardrail short-circuits this agent's input, output, or tool-call stages. Built-ins are toggle-only; add a custom guardrail to judge messages against a policy you write.",action:u?void 0:e.jsxs(k,{type:"button",onClick:x,children:[e.jsx(me,{className:"mr-1.5 h-4 w-4"}),"New guardrail"]})}),u?e.jsx(fe,{rows:3}):e.jsx("div",{className:"overflow-hidden rounded-lg border",children:f.map((l,m)=>{const g=l.name===n;return e.jsx(De,{card:l,expanded:g,isLast:m===f.length-1,onToggle:()=>C(l.name),onToggleEnabled:v=>void p(l,v),toggleDisabled:l.unknown||j.isPending,children:g?e.jsx(Ae,{owner:a,agentId:t,name:l.name}):null},l.id)})})]})}function De({card:a,expanded:t,isLast:n,onToggle:s,onToggleEnabled:o,toggleDisabled:r,children:i}){return e.jsxs("div",{className:R("bg-background",!n||t?"border-b":""),children:[e.jsxs("div",{className:"flex items-stretch gap-1 pr-3",children:[e.jsxs("button",{type:"button",onClick:s,"aria-expanded":t,className:R("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",!a.enabled&&!a.unknown&&!t&&"opacity-70"),children:[e.jsx(q,{className:"ml-2 h-4 w-4 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("span",{className:R("truncate text-sm text-foreground",a.unknown&&"font-mono text-xs"),children:a.name}),a.kind==="custom"&&a.description?e.jsx("p",{className:"line-clamp-1 text-xs text-muted-foreground",children:a.description}):e.jsx("p",{className:"text-xs text-muted-foreground",children:a.tripCount>0?`${a.tripCount} recent ${a.tripCount===1?"catch":"catches"}`:"No recent catches"}),e.jsx(ge,{badges:a.badges})]})]}),e.jsx(be,{enabled:a.enabled,name:a.name,expanded:t,onToggleEnabled:o,toggleDisabled:r,onToggle:s})]}),t&&i?e.jsx("div",{className:"border-t border-border px-4 py-4",children:i}):null]})}function Z({owner:a,agentId:t,children:n,showBack:s}){return e.jsx(pe,{owner:a,agentId:t,showBack:s,backLabel:"Guardrails",backTo:"/$owner/agents/$agentId/guardrails",children:n})}function qe({owner:a,agentId:t,expandedName:n}){return e.jsx(Z,{owner:a,agentId:t,children:e.jsx(Re,{owner:a,agentId:t,expandedName:n})})}function Oe({owner:a,agentId:t}){return e.jsx(Z,{owner:a,agentId:t,children:e.jsx(we,{owner:a,agentId:t})})}function Ue({owner:a,agentId:t,name:n}){return e.jsx(qe,{owner:a,agentId:t,expandedName:decodeURIComponent(n)})}export{qe as A,Oe as a,Ue as b};
2
- //# sourceMappingURL=agent-guardrails-route-BaV1VpDh.js.map
1
+ import{r as y,j as e,y as w,I as S,bn as Q,bo as X,bp as Y,bq as ee,br as ae,f3 as te,B as k,m as B,fV as A,is as L,it as U,gK as F,ex as se,bH as b,f$ as I,bx as ne,bK as re,aQ as D,g1 as ie,dZ as oe,d_ as le,d$ as M,e0 as E,e3 as de,e4 as $,M as ue,hX as ce,bz as q,cy as me,P as R,iq as ge}from"./index-Cr5hwh-C.js";import{M as he}from"./model-selector-dAbDgJvx.js";import{a as xe,A as pe}from"./agent-subpage-shell-D92imvSt.js";import{f as fe}from"./agent-loading-shells-Dqcvky-k.js";import{A as be}from"./agent-card-controls-mnTN2AZt.js";const je=[{value:"input",label:"Input",hint:"the user message, before the agent runs"},{value:"output",label:"Output",hint:"the agent's reply, before the user sees it"},{value:"pre-tool",label:"Pre-tool",hint:"a tool call, before it executes"},{value:"egress",label:"Egress",hint:"an outbound request to a judged domain"}];function J({initial:a,judgeModelDefault:t,submitLabel:n,submitting:s,onSubmit:o,onCancel:r}){const[i,d]=y.useState(a?.name??""),[h,j]=y.useState(a?.stage??"input"),[p,N]=y.useState(a?.policy??""),[f,C]=y.useState(a?.model??""),[x,u]=y.useState((a?.tools??[]).join(", ")),[l,m]=y.useState((a?.domains??[]).join(", ")),g=a?.kind,v=g==="require-tool",K=c=>{c.preventDefault();const _=x.split(",").map(T=>T.trim()).filter(Boolean);o({name:i,stage:h,...g?{kind:g}:{},policy:p,model:f.trim()||void 0,tools:(v||h==="pre-tool")&&_.length>0?_:void 0,domains:h==="egress"&&l.trim()?l.split(",").map(T=>T.trim()).filter(Boolean):void 0,enabled:a?.enabled??!0})};return e.jsxs("form",{onSubmit:K,className:"space-y-5",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(w,{htmlFor:"guardrail-name",children:["Name ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"guardrail-name",value:i,onChange:c=>d(c.target.value),placeholder:"no-competitor-mentions",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Shown in the list and on every trip. Must be unique."})]}),v?null:e.jsxs("div",{className:"grid gap-2",children:[e.jsx(w,{htmlFor:"guardrail-stage",children:"Stage"}),e.jsxs(Q,{value:h,onValueChange:c=>j(c),disabled:s,children:[e.jsx(X,{id:"guardrail-stage",children:e.jsx(Y,{})}),e.jsx(ee,{children:je.map(c=>e.jsxs(ae,{value:c.value,children:[c.label," — ",c.hint]},c.value))})]})]}),v?e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(w,{htmlFor:"guardrail-required-tools",children:["Required tools ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"guardrail-required-tools",value:x,onChange:c=>u(c.target.value),placeholder:"suggest_actions",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Comma-separated. The turn trips if the agent finishes without calling every one of these. No judge model runs — this is a lookup against the tools the turn actually used."})]}):null,v?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(w,{htmlFor:"guardrail-policy",children:["Policy ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(te,{id:"guardrail-policy",rows:5,value:p,onChange:c=>N(c.target.value),placeholder:"Deny any response that names a competitor (Acme, Globex) or quotes their pricing.",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"A judge model reads this and the text at the chosen stage, then allows or denies. Write it as an instruction to a reviewer."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(w,{htmlFor:"guardrail-model",children:["Judge model",t?null:e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(he,{value:f,onChange:C,placeholder:t?`Default (${t})`:"Select a model",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t?"Optional. Leave blank to use the gateway's default judge model.":"Required: the gateway has no default judge model (EGRESS_JUDGE_MODEL is unset)."})]})]}),!v&&h==="pre-tool"?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(w,{htmlFor:"guardrail-tools",children:"Tool scope"}),e.jsx(S,{id:"guardrail-tools",value:x,onChange:c=>u(c.target.value),placeholder:"github.delete_repo, fs.delete",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Optional, comma-separated. Leave blank to judge every tool call."})]}):null,h==="egress"?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(w,{htmlFor:"guardrail-domains",children:"Domains"}),e.jsx(S,{id:"guardrail-domains",value:l,onChange:c=>m(c.target.value),placeholder:"api.github.com, .slack.com",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Comma-separated hostnames this judge gates — exact (api.github.com) or wildcard (.slack.com). Leave blank to route nothing."})]}):null,e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:justify-end",children:[r?e.jsx(k,{type:"button",variant:"outline",onClick:r,disabled:s,children:"Cancel"}):null,e.jsx(k,{type:"submit",disabled:s,children:s?"Saving…":n})]})]})}function z(a){return a.kind==="require-tool"}function H(a,t,n,s,o){const r=a.name.trim();return r?/^[a-zA-Z0-9][a-zA-Z0-9 _-]*$/.test(r)?n.includes(r)?`"${r}" is a built-in guardrail name — pick another.`:t.some(d=>d.name===r&&d.name!==o)?`A custom guardrail named "${r}" already exists.`:z(a)?a.stage!=="output"?"A required-tool guardrail only runs at the output stage.":a.tools?.some(d=>d.trim())?null:"List at least one tool that must be used.":a.policy.trim()?!s&&!a.model?.trim()?"Judge model is required — the gateway has no default (EGRESS_JUDGE_MODEL is unset).":null:"Policy is required.":"Name may use letters, numbers, spaces, hyphens, and underscores.":"Name is required."}function V(a){const t=z(a),s=(t||a.stage==="pre-tool")&&a.tools&&a.tools.length>0?a.tools.map(d=>d.trim()).filter(Boolean):void 0,o=a.stage==="egress"&&a.domains&&a.domains.length>0?a.domains.map(d=>d.trim()).filter(Boolean):void 0,r=a.model?.trim()||void 0,i=a.policy.trim();return{name:a.name.trim(),enabled:a.enabled,stage:a.stage,...t?{kind:"require-tool"}:{},...t?i?{policy:i}:{}:{policy:i},...r?{model:r}:{},...s&&s.length>0?{tools:s}:{},...o&&o.length>0?{domains:o}:{}}}function ve(a,t){return[...a,V(t)]}function ye(a,t,n){return a.map(s=>s.name===t?V(n):s)}function Ne(a,t){return a.filter(n=>n.name!==t)}function Ce(a,t,n){return a.map(s=>s.name===t?{...s,enabled:n}:s)}function we({owner:a,agentId:t}){const n=B(),{data:s,isLoading:o}=A(t),{data:r,isLoading:i}=L(t),{data:d=null,isLoading:h}=U(t),j=o||i||h,p=F(t),N=s?.guardrailsInline??[],f=(r??[]).map(u=>u.name),C=async u=>{if(!s){b.error("Still loading agent settings — try again in a moment");return}const l=H(u,N,f,d);if(l){b.error(l);return}try{await p.mutateAsync({guardrailsInline:ve(N,u)}),b.success("Guardrail created"),n({to:"/$owner/agents/$agentId/guardrails",params:{owner:a,agentId:t}})}catch(m){b.error(m instanceof Error?m.message:"Failed to create guardrail")}},x=()=>void n({to:"/$owner/agents/$agentId/guardrails",params:{owner:a,agentId:t}});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(xe,{title:"New custom guardrail",description:"A custom guardrail judges text at one stage against a policy you write.",backLabel:"Guardrails",onBack:x}),j?e.jsx(se,{rows:4}):e.jsx(J,{judgeModelDefault:d,submitLabel:"Create guardrail",submitting:p.isPending,onSubmit:C,onCancel:x})]})}function P(a,t){const n=new Set(a?.guardrails??[]),s=new Set(t.map(i=>i.name)),o=t.map(i=>({name:i.name,stages:i.stages,description:i.description,enabled:n.has(i.name),unknown:!1})),r=(a?.guardrails??[]).filter(i=>!s.has(i)).map(i=>({name:i,stages:[],enabled:!0,unknown:!0}));return[...o,...r]}function ke(a){return a.filter(t=>t.enabled||t.unknown).map(t=>t.name)}function Se(a,t,n){return ke(a.map(s=>s.name===t&&!s.unknown?{...s,enabled:n}:s))}const G={input:"Input",output:"Output","pre-tool":"Pre-tool",egress:"Egress"};function Ge(a){const t=new Date(a);return Number.isNaN(t.getTime())?a:ce(t,{addSuffix:!0})}function Ae({owner:a,agentId:t,name:n}){const{data:s}=A(t),{data:o}=L(t),r=y.useMemo(()=>P(s,o??[]).find(d=>d.name===n)??null,[s,o,n]),i=(s?.guardrailsInline??[]).find(d=>d.name===n);return i?e.jsx(Te,{owner:a,agentId:t,guardrail:i}):r?e.jsx(Le,{agentId:t,name:n,row:r}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Guardrail not found."})}function Le({agentId:a,name:t,row:n}){return e.jsxs("div",{className:"space-y-8",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:n.description??(n.stages.length>0?`Built-in. Short-circuits this agent's ${n.stages.map(s=>G[s].toLowerCase()).join(", ")} stage${n.stages.length>1?"s":""} when it matches.`:"Configured out of band — toggling is managed via lobu apply.")}),e.jsx(W,{agentId:a,guardrail:t})]})}function Te({owner:a,agentId:t,guardrail:n}){const s=B(),{data:o}=A(t),{data:r}=L(t),{data:i=null}=U(t),d=F(t),[h,j]=y.useState(!1),p=o?.guardrailsInline??[],N=(r??[]).map(u=>u.name),f=async(u,l)=>{if(!o)return b.error("Still loading agent settings — try again in a moment"),!1;try{return await d.mutateAsync({guardrailsInline:u}),b.success(l),!0}catch(m){return b.error(m instanceof Error?m.message:"Failed to save guardrail"),!1}},C=async u=>{const l=H(u,p,N,i,n.name);if(l){b.error(l);return}await f(ye(p,n.name,u),"Guardrail saved")&&u.name.trim()!==n.name&&s({to:"/$owner/agents/$agentId/guardrails/$name",params:{owner:a,agentId:t,name:encodeURIComponent(u.name.trim())}})},x=async()=>{await f(Ne(p,n.name),"Guardrail deleted")&&s({to:"/$owner/agents/$agentId/guardrails",params:{owner:a,agentId:t}})};return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:n.kind==="require-tool"?"Required tools":"Policy"}),e.jsx(J,{initial:n,judgeModelDefault:i,submitLabel:"Save changes",submitting:d.isPending,onSubmit:C})]}),e.jsx("div",{className:"flex justify-end",children:h?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{type:"button",variant:"destructive",onClick:()=>void x(),disabled:d.isPending,children:"Delete guardrail"}),e.jsx(k,{type:"button",variant:"outline",onClick:()=>j(!1),disabled:d.isPending,children:"Cancel"})]}):e.jsxs(k,{type:"button",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>j(!0),children:["Delete ",n.name]})}),e.jsx(W,{agentId:t,guardrail:n.name})]})}function W({agentId:a,guardrail:t}){const{data:n=[],isLoading:s,isError:o}=I(a,{guardrail:t});return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Recent catches"}),s?e.jsx(ne,{label:"catches",variant:"table",rows:4}):o?e.jsx(re,{label:"catches"}):n.length===0?e.jsx(D,{icon:ie,title:"No catches yet",description:"This guardrail hasn't short-circuited anything on this agent."}):e.jsx("div",{className:"overflow-hidden rounded-lg border",children:e.jsxs(oe,{children:[e.jsx(le,{children:e.jsxs(M,{children:[e.jsx(E,{className:"w-[180px]",children:"When"}),e.jsx(E,{className:"w-[120px]",children:"Stage"}),e.jsx(E,{children:"Reason"})]})}),e.jsx(de,{children:n.map(r=>e.jsxs(M,{children:[e.jsx($,{className:"text-xs text-muted-foreground",title:r.occurredAt,children:Ge(r.occurredAt)}),e.jsx($,{children:e.jsx(ue,{variant:"outline",className:"text-[10px]",children:G[r.stage]})}),e.jsx($,{className:"text-sm text-muted-foreground",children:r.reason??e.jsx("span",{className:"italic",children:"no reason recorded"})})]},r.id))})]})})]})}function Ee({description:a,action:t}){return e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("p",{className:"min-w-0 flex-1 text-center text-sm text-muted-foreground",children:a}),t?e.jsx("div",{className:"shrink-0",children:t}):null]})}function O(a,t){return a.get(t)??0}function $e(a,t,n){const s=a.map(r=>{const i=r.stages.map(d=>G[d]);return r.unknown&&i.push("Unknown"),{id:r.name,name:r.name,kind:"builtin",description:r.description,stages:r.stages,enabled:r.enabled,unknown:r.unknown,badges:i,tripCount:O(n,r.name)}}),o=t.map(r=>{const i=[G[r.stage],"Custom"];return{id:r.name,name:r.name,kind:"custom",description:r.policy,stages:[r.stage],enabled:r.enabled,unknown:!1,badges:i,tripCount:O(n,r.name)}});return[...s,...o]}function Re({owner:a,agentId:t,expandedName:n}){const s=B(),{data:o,isLoading:r}=A(t),{data:i,isLoading:d}=L(t),{data:h=[]}=I(t),j=F(t),p=async(l,m)=>{if(!o){b.error("Still loading agent settings — try again in a moment");return}try{if(l.kind==="custom")await j.mutateAsync({guardrailsInline:Ce(o.guardrailsInline??[],l.name,m)});else{const g=P(o,i??[]);await j.mutateAsync({guardrails:Se(g,l.name,m)})}b.success(m?"Guardrail enabled":"Guardrail disabled")}catch(g){b.error(g instanceof Error?g.message:"Failed to save guardrail")}},N=i===null,f=y.useMemo(()=>{const l=P(o,i??[]),m=o?.guardrailsInline??[],g=new Map;for(const v of h)g.set(v.guardrailName,(g.get(v.guardrailName)??0)+1);return $e(l,m,g)},[o,i,h]),C=l=>{if(l===n){s({to:"/$owner/agents/$agentId/guardrails",params:{owner:a,agentId:t}});return}s({to:"/$owner/agents/$agentId/guardrails/$name",params:{owner:a,agentId:t,name:encodeURIComponent(l)}})},x=()=>{s({to:"/$owner/agents/$agentId/guardrails/create",params:{owner:a,agentId:t}})},u=r||d;return!u&&f.length===0?e.jsx("div",{className:"space-y-6",children:N?e.jsx(D,{icon:q,title:"Guardrails catalog unavailable",description:"Guardrails will appear here once the gateway publishes its catalog.",actionLabel:"New guardrail",onAction:x}):e.jsx(D,{icon:q,title:"No guardrails yet",description:"Enable a built-in in lobu.toml or write a custom policy guardrail.",actionLabel:"New guardrail",onAction:x})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{description:"Each guardrail short-circuits this agent's input, output, or tool-call stages. Built-ins are toggle-only; add a custom guardrail to judge messages against a policy you write.",action:u?void 0:e.jsxs(k,{type:"button",onClick:x,children:[e.jsx(me,{className:"mr-1.5 h-4 w-4"}),"New guardrail"]})}),u?e.jsx(fe,{rows:3}):e.jsx("div",{className:"overflow-hidden rounded-lg border",children:f.map((l,m)=>{const g=l.name===n;return e.jsx(De,{card:l,expanded:g,isLast:m===f.length-1,onToggle:()=>C(l.name),onToggleEnabled:v=>void p(l,v),toggleDisabled:l.unknown||j.isPending,children:g?e.jsx(Ae,{owner:a,agentId:t,name:l.name}):null},l.id)})})]})}function De({card:a,expanded:t,isLast:n,onToggle:s,onToggleEnabled:o,toggleDisabled:r,children:i}){return e.jsxs("div",{className:R("bg-background",!n||t?"border-b":""),children:[e.jsxs("div",{className:"flex items-stretch gap-1 pr-3",children:[e.jsxs("button",{type:"button",onClick:s,"aria-expanded":t,className:R("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",!a.enabled&&!a.unknown&&!t&&"opacity-70"),children:[e.jsx(q,{className:"ml-2 h-4 w-4 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("span",{className:R("truncate text-sm text-foreground",a.unknown&&"font-mono text-xs"),children:a.name}),a.kind==="custom"&&a.description?e.jsx("p",{className:"line-clamp-1 text-xs text-muted-foreground",children:a.description}):e.jsx("p",{className:"text-xs text-muted-foreground",children:a.tripCount>0?`${a.tripCount} recent ${a.tripCount===1?"catch":"catches"}`:"No recent catches"}),e.jsx(ge,{badges:a.badges})]})]}),e.jsx(be,{enabled:a.enabled,name:a.name,expanded:t,onToggleEnabled:o,toggleDisabled:r,onToggle:s})]}),t&&i?e.jsx("div",{className:"border-t border-border px-4 py-4",children:i}):null]})}function Z({owner:a,agentId:t,children:n,showBack:s}){return e.jsx(pe,{owner:a,agentId:t,showBack:s,backLabel:"Guardrails",backTo:"/$owner/agents/$agentId/guardrails",children:n})}function qe({owner:a,agentId:t,expandedName:n}){return e.jsx(Z,{owner:a,agentId:t,children:e.jsx(Re,{owner:a,agentId:t,expandedName:n})})}function Oe({owner:a,agentId:t}){return e.jsx(Z,{owner:a,agentId:t,children:e.jsx(we,{owner:a,agentId:t})})}function Ue({owner:a,agentId:t,name:n}){return e.jsx(qe,{owner:a,agentId:t,expandedName:decodeURIComponent(n)})}export{qe as A,Oe as a,Ue as b};
2
+ //# sourceMappingURL=agent-guardrails-route-BOrCXcAl.js.map
@@ -1,2 +1,2 @@
1
- import{j as e,S as s,P as n}from"./index-_oPeVpL_.js";const r="mx-auto w-full max-w-3xl px-4",d="gap-4",i="ml-8 self-end max-w-[80%]",o="mr-8 max-w-[90%]",c="mx-auto w-full max-w-3xl shrink-0 border-t border-border/50 bg-transparent px-4 pb-4 pt-3";function f({rows:l=3}){return e.jsx("div",{className:"space-y-2",role:"status","aria-label":"Loading list",children:Array.from({length:l}).map((a,x)=>e.jsx(s,{className:"h-16 w-full rounded-lg"},x))})}function t({readOnly:l=!1}){return e.jsxs("div",{role:"status","aria-label":l?"Loading run history":"Loading chat",className:l?"flex min-h-[24rem] min-w-0 flex-1 flex-col":"flex min-h-0 flex-1 flex-col",children:[e.jsx("div",{className:l?"flex flex-1 flex-col overflow-hidden":"flex min-h-0 flex-1 flex-col overflow-hidden",children:e.jsxs("div",{className:n(r,"flex flex-1 flex-col overflow-hidden",d),children:[e.jsx("div",{className:i,children:e.jsx(s,{className:"h-12 w-48 rounded-lg"})}),e.jsx("div",{className:o,children:e.jsx(s,{className:n(l?"h-20":"h-16","w-64 rounded-lg")})}),e.jsx("div",{className:i,children:e.jsx(s,{className:"h-10 w-36 rounded-lg"})}),l?e.jsx("div",{className:o,children:e.jsx(s,{className:"h-16 w-52 rounded-lg"})}):null]})}),l?null:e.jsx("div",{className:c,children:e.jsx(s,{className:"h-24 w-full rounded-lg"})})]})}function h(){return e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:e.jsx(t,{})})}function u(){return e.jsx("div",{className:"flex h-48 w-full items-end gap-2 px-2 pb-2",role:"status","aria-label":"Loading timeline",children:[40,65,45,80,55,70,50,85,60,75].map((l,a)=>e.jsx(s,{className:"flex-1 rounded-sm",style:{height:`${l}%`}},a))})}export{t as A,h as C,u as E,c as a,d as b,r as c,o as d,i as e,f};
2
- //# sourceMappingURL=agent-loading-shells-CtZJM2Gc.js.map
1
+ import{j as e,S as s,P as n}from"./index-Cr5hwh-C.js";const r="mx-auto w-full max-w-3xl px-4",d="gap-4",i="ml-8 self-end max-w-[80%]",o="mr-8 max-w-[90%]",c="mx-auto w-full max-w-3xl shrink-0 border-t border-border/50 bg-transparent px-4 pb-4 pt-3";function f({rows:l=3}){return e.jsx("div",{className:"space-y-2",role:"status","aria-label":"Loading list",children:Array.from({length:l}).map((a,x)=>e.jsx(s,{className:"h-16 w-full rounded-lg"},x))})}function t({readOnly:l=!1}){return e.jsxs("div",{role:"status","aria-label":l?"Loading run history":"Loading chat",className:l?"flex min-h-[24rem] min-w-0 flex-1 flex-col":"flex min-h-0 flex-1 flex-col",children:[e.jsx("div",{className:l?"flex flex-1 flex-col overflow-hidden":"flex min-h-0 flex-1 flex-col overflow-hidden",children:e.jsxs("div",{className:n(r,"flex flex-1 flex-col overflow-hidden",d),children:[e.jsx("div",{className:i,children:e.jsx(s,{className:"h-12 w-48 rounded-lg"})}),e.jsx("div",{className:o,children:e.jsx(s,{className:n(l?"h-20":"h-16","w-64 rounded-lg")})}),e.jsx("div",{className:i,children:e.jsx(s,{className:"h-10 w-36 rounded-lg"})}),l?e.jsx("div",{className:o,children:e.jsx(s,{className:"h-16 w-52 rounded-lg"})}):null]})}),l?null:e.jsx("div",{className:c,children:e.jsx(s,{className:"h-24 w-full rounded-lg"})})]})}function h(){return e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:e.jsx(t,{})})}function u(){return e.jsx("div",{className:"flex h-48 w-full items-end gap-2 px-2 pb-2",role:"status","aria-label":"Loading timeline",children:[40,65,45,80,55,70,50,85,60,75].map((l,a)=>e.jsx(s,{className:"flex-1 rounded-sm",style:{height:`${l}%`}},a))})}export{t as A,h as C,u as E,c as a,d as b,r as c,o as d,i as e,f};
2
+ //# sourceMappingURL=agent-loading-shells-Dqcvky-k.js.map
@@ -1,2 +1,2 @@
1
- import{j as e,bA as Q,P as k,dz as D,dA as K,dB as R,fu as U,Z as X,bt as Z,bs as V,bF as Y,fv as ee,bG as P,bH as F,bI as se,bB as ne,bJ as te,bC as re,r as A,fw as ae,fx as ie,bx as le,bK as oe,L as T,fy as de,fz as ce,cx as z,fA as ue,fB as me,fC as fe,fD as S,ck as L,X as ge,fE as q,fF as H,fe as xe,cy as he,fG as ye,fH as be,bN as pe,fI as ve}from"./index-_oPeVpL_.js";const je={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"};function Ne({options:n,value:t,floor:o,onChange:a,disabled:i,ariaLabel:m,compact:u}){return e.jsx("div",{role:"radiogroup","aria-label":m,className:k("inline-flex shrink-0 items-stretch gap-0.5 rounded-lg border border-border bg-muted/40 p-0.5"),children:n.map(l=>{const y=U({option:l,floor:o}),h=l===t,f=y.disabled&&!h,b=Q[l],g=e.jsx("button",{type:"button",role:"radio","aria-checked":h,disabled:i||f,onClick:()=>{!h&&!f&&!i&&a(l)},className:k("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",u?"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",h?k(je[l],""):"text-muted-foreground hover:bg-background/60 hover:text-foreground",f&&"cursor-not-allowed opacity-40",i&&!f&&"cursor-not-allowed opacity-60"),children:b},l);return f&&y.reason?e.jsxs(D,{children:[e.jsx(K,{asChild:!0,children:e.jsx("span",{className:"inline-flex shrink-0",children:g})}),e.jsx(R,{children:y.reason})]},l):g})})}function B({children:n,controls:t}){return e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2 px-3 py-2",children:[e.jsx("div",{className:"min-w-40 flex-1 text-sm",children:n}),e.jsx("div",{className:"flex shrink-0 items-center gap-2",children:t})]})}const _e=[{resourceClass:"entity",title:"Entities",sub:"Defaults for every entity type."},{resourceClass:"agent_config",title:"Agents",sub:"Defaults for reading and managing agents."}];function Ae(n,t,o,a,i=null){const m=q(n.floor,t,o,a,i),u=H(n.floor,t,o,a,i)?m:"auto";return(a!==null||i!==null)&&ye(n.agent,t,o)?be(u,S(n,t,o,null)):u}function ke({label:n,response:t,resourceClass:o,action:a,entityTypeSlug:i,targetAgentId:m=null,dimmed:u,pending:l,onSave:y}){const h=q(t.floor,o,a,i,m),f=H(t.floor,o,a,i,m),b=S(t,o,a,i,m),g=Ae(t,o,a,i,m),v=pe(o,a),p=e.jsx("div",{className:k("inline-flex shrink-0",u&&"opacity-45"),children:e.jsx(Ne,{options:v,value:b,floor:g,disabled:l,compact:!0,ariaLabel:n,onChange:y})});return f?e.jsxs(D,{children:[e.jsx(K,{asChild:!0,children:e.jsx("span",{className:"inline-flex shrink-0",children:p})}),e.jsxs(R,{children:["Org floor ",Q[h]," — can only go stricter"]})]}):p}function Se(n,t){const o=i=>i.resource_class===t.resource_class&&(i.entity_type_slug??null)===(t.entity_type_slug??null)&&(i.operation_key??null)===(t.operation_key??null)&&(i.target_agent_id??null)===(t.target_agent_id??null),a=n.map(i=>o(i)?t:i);return a.some(o)?a:[...a,t]}function Ce(n,t,o,a,i,m){const u=ve(n,t,o,a);return u[i]=m,u}const $="font-medium text-foreground hover:text-primary hover:underline";function Ee({type:n}){return e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(z,{icon:n.icon,className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"font-medium",children:n.name}),e.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:n.slug})]})}function M({label:n,disabled:t,hint:o,searchPlaceholder:a,emptyText:i,children:m}){return t?e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:[n,o?` ${o}`:""]}):e.jsx(xe,{contentClassName:"w-[min(100vw-2rem,22rem)]",searchPlaceholder:a,emptyText:i,trigger:u=>e.jsxs("button",{type:"button","aria-expanded":u,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:[e.jsx(he,{className:"h-3 w-3"}),n]}),children:u=>m(u)})}function we({pending:n,onClick:t,label:o}){return e.jsx("button",{type:"button",disabled:n,onClick:t,"aria-label":o,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:e.jsx(ge,{className:"h-3 w-3"})})}function $e({owner:n,agentId:t,variant:o="agent"}){const a=o==="org-floor",i=X(),m=Z(n,t??"",{enabled:!a&&!!t}),u=V(n,{enabled:a}),{data:l,isLoading:y,isError:h,error:f}=a?u:m,b=a?Y(n):ee(n,t??""),g=P({mutationFn:r=>a?se(n,r):ne(n,t??"",r),onSuccess:r=>{i.setQueryData(b,c=>c&&{...c,agent:Se(c.agent,r)}),i.invalidateQueries({queryKey:b}),a&&i.invalidateQueries({queryKey:["agent-permissions"]})},onError:r=>{F.error(r instanceof Error?r.message:"Failed to save permission")}}),v=P({mutationFn:r=>a?te(n,r):re(n,t??"",r),onSuccess:()=>{i.invalidateQueries({queryKey:b}),a&&i.invalidateQueries({queryKey:["agent-permissions"]})},onError:r=>{F.error(r instanceof Error?r.message:"Failed to remove override")}}),p=g.isPending||v.isPending,C=A.useMemo(()=>l?ae(l):[],[l]),E=A.useMemo(()=>{if(!l)return[];const r=new Set(C.map(c=>c.slug));return l.entity_types.filter(c=>!r.has(c.slug))},[l,C]),j=A.useMemo(()=>l?ie(l):[],[l]),N=A.useMemo(()=>{if(!l)return[];const r=new Set(j.map(c=>c.id));return l.agents.filter(c=>(a||c.id!==t)&&!r.has(c.id))},[l,j,t,a]);if(y)return e.jsx(le,{label:"permissions",variant:"cards",cards:2});if(h||!l)return e.jsx(oe,{label:f instanceof Error?f.message:"permissions"});const x=l,I=(r,c,w,_,s=null)=>{const d=Ce(x,r,c,s,w,_);g.mutate({resource_class:r,effects:d,entity_type_slug:c,target_agent_id:s})},W=x.entity_types.length===0?"— none yet":E.length===0?"— all covered":null,G=N.length===0&&j.length===0?"— no other agents":N.length===0?"— all covered":null;return e.jsxs("div",{className:"space-y-4",children:[a?null:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Manage connector rules and agent restrictions in"," ",e.jsx(T,{to:"/$owner/settings/organization",params:{owner:n},search:{agent:t},hash:"policies",className:$,children:"Organization policies"}),"."]}),_e.map(r=>{const c=r.resourceClass==="entity",w=r.resourceClass==="agent_config",_=[{key:"default",label:"Default",name:"Default",entityTypeSlug:null,targetAgentId:null,owned:!1,diffs:0},...c?C.map(s=>({key:`entity:${s.slug}`,name:s.name,label:e.jsx(T,{to:"/$owner/entity-types/$slug",params:{owner:n,slug:s.slug},className:$,title:`Open ${s.name}`,children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(z,{icon:s.icon,className:"h-3.5 w-3.5 shrink-0"}),s.name]})}),entityTypeSlug:s.slug,targetAgentId:null,owned:ce(x,s.slug),diffs:de(x,s.slug)})):j.map(s=>({key:`agent:${s.id}`,name:s.name,label:e.jsx(T,{to:"/$owner/agents/$agentId/settings",params:{owner:n,agentId:s.id},search:{run_id:void 0},className:$,title:`Open ${s.name}`,children:s.name}),entityTypeSlug:null,targetAgentId:s.id,owned:me(x,s.id),diffs:ue(x,s.id)}))];return e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-sm font-medium",children:r.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r.sub})]}),e.jsxs("div",{className:"divide-y overflow-hidden rounded-lg border",children:[_.map(s=>e.jsxs("div",{className:"divide-y",children:[_.length>1&&e.jsx("div",{className:"bg-muted/30",children:e.jsx(B,{controls:s.owned?e.jsx(we,{pending:p,label:`Remove ${s.name} exception`,onClick:()=>v.mutate({resource_class:r.resourceClass,entity_type_slug:s.entityTypeSlug,target_agent_id:s.targetAgentId})}):null,children:e.jsxs("div",{className:"flex items-center gap-2",children:[s.label,s.key!=="default"&&!s.owned?e.jsx("span",{className:"text-xs text-muted-foreground",children:"Organization minimum"}):s.diffs>0?e.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.diffs," ",s.diffs===1?"change":"changes"]}):null]})})}),e.jsx("div",{className:"divide-y",children:fe[r.resourceClass].filter(d=>!s.targetAgentId||d!=="create").map(d=>{const O=`${d.charAt(0).toUpperCase()+d.slice(1)} ${c?"entities":"agents"}`;return e.jsx(B,{controls:e.jsx(ke,{label:`${s.name}: ${O}`,response:x,resourceClass:r.resourceClass,action:d,entityTypeSlug:s.entityTypeSlug,targetAgentId:s.targetAgentId,dimmed:s.key!=="default"&&S(x,r.resourceClass,d,s.entityTypeSlug,s.targetAgentId)===S(x,r.resourceClass,d,null),pending:p,onSave:J=>I(r.resourceClass,s.entityTypeSlug,d,J,s.targetAgentId)}),children:O},d)})})]},s.key)),e.jsxs("div",{className:"border-t",children:[c?e.jsx(M,{label:"Add type",disabled:p||E.length===0,hint:W,searchPlaceholder:"Search types…",emptyText:"No matching types.",children:s=>E.map(d=>e.jsx(L,{value:`${d.name} ${d.slug}`,onSelect:()=>{g.mutate({resource_class:"entity",effects:{},entity_type_slug:d.slug}),s()},className:"cursor-pointer",children:e.jsx(Ee,{type:d})},d.slug))}):null,w?e.jsx(M,{label:"Add agent",disabled:p||N.length===0,hint:G,searchPlaceholder:"Search agents…",emptyText:"No matching agents.",children:s=>N.map(d=>e.jsxs(L,{value:`${d.name} ${d.id}`,onSelect:()=>{g.mutate({resource_class:"agent_config",effects:{},target_agent_id:d.id}),s()},className:"cursor-pointer",children:[e.jsx("span",{className:"font-medium",children:d.name}),e.jsx("span",{className:"ml-1.5 font-mono text-[10px] text-muted-foreground",children:d.id})]},d.id))}):null]})]})]},r.resourceClass)})]})}export{$e as A,Ne as P,B as a};
2
- //# sourceMappingURL=agent-permissions-matrix-Ds48KFK9.js.map
1
+ import{j as e,bA as Q,P as k,dz as D,dA as K,dB as R,fu as U,Z as X,bt as Z,bs as V,bF as Y,fv as ee,bG as P,bH as F,bI as se,bB as ne,bJ as te,bC as re,r as A,fw as ae,fx as ie,bx as le,bK as oe,L as T,fy as de,fz as ce,cx as z,fA as ue,fB as me,fC as fe,fD as S,ck as L,X as ge,fE as q,fF as H,fe as xe,cy as he,fG as ye,fH as be,bN as pe,fI as ve}from"./index-Cr5hwh-C.js";const je={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"};function Ne({options:n,value:t,floor:o,onChange:a,disabled:i,ariaLabel:m,compact:u}){return e.jsx("div",{role:"radiogroup","aria-label":m,className:k("inline-flex shrink-0 items-stretch gap-0.5 rounded-lg border border-border bg-muted/40 p-0.5"),children:n.map(l=>{const y=U({option:l,floor:o}),h=l===t,f=y.disabled&&!h,b=Q[l],g=e.jsx("button",{type:"button",role:"radio","aria-checked":h,disabled:i||f,onClick:()=>{!h&&!f&&!i&&a(l)},className:k("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",u?"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",h?k(je[l],""):"text-muted-foreground hover:bg-background/60 hover:text-foreground",f&&"cursor-not-allowed opacity-40",i&&!f&&"cursor-not-allowed opacity-60"),children:b},l);return f&&y.reason?e.jsxs(D,{children:[e.jsx(K,{asChild:!0,children:e.jsx("span",{className:"inline-flex shrink-0",children:g})}),e.jsx(R,{children:y.reason})]},l):g})})}function B({children:n,controls:t}){return e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2 px-3 py-2",children:[e.jsx("div",{className:"min-w-40 flex-1 text-sm",children:n}),e.jsx("div",{className:"flex shrink-0 items-center gap-2",children:t})]})}const _e=[{resourceClass:"entity",title:"Entities",sub:"Defaults for every entity type."},{resourceClass:"agent_config",title:"Agents",sub:"Defaults for reading and managing agents."}];function Ae(n,t,o,a,i=null){const m=q(n.floor,t,o,a,i),u=H(n.floor,t,o,a,i)?m:"auto";return(a!==null||i!==null)&&ye(n.agent,t,o)?be(u,S(n,t,o,null)):u}function ke({label:n,response:t,resourceClass:o,action:a,entityTypeSlug:i,targetAgentId:m=null,dimmed:u,pending:l,onSave:y}){const h=q(t.floor,o,a,i,m),f=H(t.floor,o,a,i,m),b=S(t,o,a,i,m),g=Ae(t,o,a,i,m),v=pe(o,a),p=e.jsx("div",{className:k("inline-flex shrink-0",u&&"opacity-45"),children:e.jsx(Ne,{options:v,value:b,floor:g,disabled:l,compact:!0,ariaLabel:n,onChange:y})});return f?e.jsxs(D,{children:[e.jsx(K,{asChild:!0,children:e.jsx("span",{className:"inline-flex shrink-0",children:p})}),e.jsxs(R,{children:["Org floor ",Q[h]," — can only go stricter"]})]}):p}function Se(n,t){const o=i=>i.resource_class===t.resource_class&&(i.entity_type_slug??null)===(t.entity_type_slug??null)&&(i.operation_key??null)===(t.operation_key??null)&&(i.target_agent_id??null)===(t.target_agent_id??null),a=n.map(i=>o(i)?t:i);return a.some(o)?a:[...a,t]}function Ce(n,t,o,a,i,m){const u=ve(n,t,o,a);return u[i]=m,u}const $="font-medium text-foreground hover:text-primary hover:underline";function Ee({type:n}){return e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(z,{icon:n.icon,className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"font-medium",children:n.name}),e.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:n.slug})]})}function M({label:n,disabled:t,hint:o,searchPlaceholder:a,emptyText:i,children:m}){return t?e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:[n,o?` ${o}`:""]}):e.jsx(xe,{contentClassName:"w-[min(100vw-2rem,22rem)]",searchPlaceholder:a,emptyText:i,trigger:u=>e.jsxs("button",{type:"button","aria-expanded":u,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:[e.jsx(he,{className:"h-3 w-3"}),n]}),children:u=>m(u)})}function we({pending:n,onClick:t,label:o}){return e.jsx("button",{type:"button",disabled:n,onClick:t,"aria-label":o,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:e.jsx(ge,{className:"h-3 w-3"})})}function $e({owner:n,agentId:t,variant:o="agent"}){const a=o==="org-floor",i=X(),m=Z(n,t??"",{enabled:!a&&!!t}),u=V(n,{enabled:a}),{data:l,isLoading:y,isError:h,error:f}=a?u:m,b=a?Y(n):ee(n,t??""),g=P({mutationFn:r=>a?se(n,r):ne(n,t??"",r),onSuccess:r=>{i.setQueryData(b,c=>c&&{...c,agent:Se(c.agent,r)}),i.invalidateQueries({queryKey:b}),a&&i.invalidateQueries({queryKey:["agent-permissions"]})},onError:r=>{F.error(r instanceof Error?r.message:"Failed to save permission")}}),v=P({mutationFn:r=>a?te(n,r):re(n,t??"",r),onSuccess:()=>{i.invalidateQueries({queryKey:b}),a&&i.invalidateQueries({queryKey:["agent-permissions"]})},onError:r=>{F.error(r instanceof Error?r.message:"Failed to remove override")}}),p=g.isPending||v.isPending,C=A.useMemo(()=>l?ae(l):[],[l]),E=A.useMemo(()=>{if(!l)return[];const r=new Set(C.map(c=>c.slug));return l.entity_types.filter(c=>!r.has(c.slug))},[l,C]),j=A.useMemo(()=>l?ie(l):[],[l]),N=A.useMemo(()=>{if(!l)return[];const r=new Set(j.map(c=>c.id));return l.agents.filter(c=>(a||c.id!==t)&&!r.has(c.id))},[l,j,t,a]);if(y)return e.jsx(le,{label:"permissions",variant:"cards",cards:2});if(h||!l)return e.jsx(oe,{label:f instanceof Error?f.message:"permissions"});const x=l,I=(r,c,w,_,s=null)=>{const d=Ce(x,r,c,s,w,_);g.mutate({resource_class:r,effects:d,entity_type_slug:c,target_agent_id:s})},W=x.entity_types.length===0?"— none yet":E.length===0?"— all covered":null,G=N.length===0&&j.length===0?"— no other agents":N.length===0?"— all covered":null;return e.jsxs("div",{className:"space-y-4",children:[a?null:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Manage connector rules and agent restrictions in"," ",e.jsx(T,{to:"/$owner/settings/organization",params:{owner:n},search:{agent:t},hash:"policies",className:$,children:"Organization policies"}),"."]}),_e.map(r=>{const c=r.resourceClass==="entity",w=r.resourceClass==="agent_config",_=[{key:"default",label:"Default",name:"Default",entityTypeSlug:null,targetAgentId:null,owned:!1,diffs:0},...c?C.map(s=>({key:`entity:${s.slug}`,name:s.name,label:e.jsx(T,{to:"/$owner/entity-types/$slug",params:{owner:n,slug:s.slug},className:$,title:`Open ${s.name}`,children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(z,{icon:s.icon,className:"h-3.5 w-3.5 shrink-0"}),s.name]})}),entityTypeSlug:s.slug,targetAgentId:null,owned:ce(x,s.slug),diffs:de(x,s.slug)})):j.map(s=>({key:`agent:${s.id}`,name:s.name,label:e.jsx(T,{to:"/$owner/agents/$agentId/settings",params:{owner:n,agentId:s.id},search:{run_id:void 0},className:$,title:`Open ${s.name}`,children:s.name}),entityTypeSlug:null,targetAgentId:s.id,owned:me(x,s.id),diffs:ue(x,s.id)}))];return e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-sm font-medium",children:r.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r.sub})]}),e.jsxs("div",{className:"divide-y overflow-hidden rounded-lg border",children:[_.map(s=>e.jsxs("div",{className:"divide-y",children:[_.length>1&&e.jsx("div",{className:"bg-muted/30",children:e.jsx(B,{controls:s.owned?e.jsx(we,{pending:p,label:`Remove ${s.name} exception`,onClick:()=>v.mutate({resource_class:r.resourceClass,entity_type_slug:s.entityTypeSlug,target_agent_id:s.targetAgentId})}):null,children:e.jsxs("div",{className:"flex items-center gap-2",children:[s.label,s.key!=="default"&&!s.owned?e.jsx("span",{className:"text-xs text-muted-foreground",children:"Organization minimum"}):s.diffs>0?e.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.diffs," ",s.diffs===1?"change":"changes"]}):null]})})}),e.jsx("div",{className:"divide-y",children:fe[r.resourceClass].filter(d=>!s.targetAgentId||d!=="create").map(d=>{const O=`${d.charAt(0).toUpperCase()+d.slice(1)} ${c?"entities":"agents"}`;return e.jsx(B,{controls:e.jsx(ke,{label:`${s.name}: ${O}`,response:x,resourceClass:r.resourceClass,action:d,entityTypeSlug:s.entityTypeSlug,targetAgentId:s.targetAgentId,dimmed:s.key!=="default"&&S(x,r.resourceClass,d,s.entityTypeSlug,s.targetAgentId)===S(x,r.resourceClass,d,null),pending:p,onSave:J=>I(r.resourceClass,s.entityTypeSlug,d,J,s.targetAgentId)}),children:O},d)})})]},s.key)),e.jsxs("div",{className:"border-t",children:[c?e.jsx(M,{label:"Add type",disabled:p||E.length===0,hint:W,searchPlaceholder:"Search types…",emptyText:"No matching types.",children:s=>E.map(d=>e.jsx(L,{value:`${d.name} ${d.slug}`,onSelect:()=>{g.mutate({resource_class:"entity",effects:{},entity_type_slug:d.slug}),s()},className:"cursor-pointer",children:e.jsx(Ee,{type:d})},d.slug))}):null,w?e.jsx(M,{label:"Add agent",disabled:p||N.length===0,hint:G,searchPlaceholder:"Search agents…",emptyText:"No matching agents.",children:s=>N.map(d=>e.jsxs(L,{value:`${d.name} ${d.id}`,onSelect:()=>{g.mutate({resource_class:"agent_config",effects:{},target_agent_id:d.id}),s()},className:"cursor-pointer",children:[e.jsx("span",{className:"font-medium",children:d.name}),e.jsx("span",{className:"ml-1.5 font-mono text-[10px] text-muted-foreground",children:d.id})]},d.id))}):null]})]})]},r.resourceClass)})]})}export{$e as A,Ne as P,B as a};
2
+ //# sourceMappingURL=agent-permissions-matrix-BOo_4r_4.js.map
@@ -1,2 +1,2 @@
1
- import{r as p,e5 as G,fV as ge,gu as pe,gN as be,bH as F,j as ve}from"./index-_oPeVpL_.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 H,b as ke,c as ye,j as we,k as Re,C as V,l as Ae}from"./core.esm-DiTpULFl.js";import{s as De,b as Ee}from"./skill-editor-D_W3QlRz.js";function K(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 Ne(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Y=e=>{let{rects:n,activeIndex:t,overIndex:r,index:s}=e;const u=K(n,r,t),o=n[s],i=u[s];return!i||!o?null:{x:i.left-o.left,y:i.top-o.top,scaleX:i.width/o.width,scaleY:i.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 i=(n=u[t])!=null?n:r;if(!i)return null;if(s===t){const f=u[o];return f?{x:0,y:t<o?f.top+f.height-(i.top+i.height):f.top-i.top,...M}:null}const m=Oe(u,s,t);return s>t&&s<=o?{x:0,y:-i.height-m,...M}:s<t&&s>=o?{x:0,y:i.height+m,...M}:{x:0,y:0,...M}};function Oe(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",J=G.createContext({activeIndex:-1,containerId:W,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Y,disabled:{draggable:!1,droppable:!1}});function Je(e){let{children:n,id:t,items:r,strategy:s=Y,disabled:u=!1}=e;const{active:o,dragOverlay:i,droppableRects:m,over:f,measureDroppableContainers:a}=Ie(),l=Se(W,t),b=i.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=Ne(u);H(()=>{I&&k&&a(h)},[I,h,k,a]),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 G.createElement(J.Provider,{value:g},n)}const Pe=e=>{let{id:n,items:t,activeIndex:r,overIndex:s}=e;return K(t,r,s).indexOf(n)},Me=e=>{let{containerId:n,isSorting:t,wasDragging:r,index:s,items:u,newIndex:o,previousItems:i,previousContainerId:m,transition:f}=e;return!f||!r||i!==u&&s===o?!1:t?!0:o!==s&&n===m},je={duration:200,easing:"ease"},Q="transform",$e=V.Transition.toString({property:Q,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),i=p.useRef(t);return H(()=>{if(!n&&t!==i.current&&r.current){const m=s.current;if(m){const f=Ae(r.current,{ignoreTransform:!0}),a={x:m.left-f.left,y:m.top-f.top,scaleX:m.width/f.width,scaleY:m.height/f.height};(a.x||a.y)&&o(a)}}t!==i.current&&(i.current=t)},[n,t,r,s]),p.useEffect(()=>{u&&o(null)},[u]),u}function Qe(e){let{animateLayoutChanges:n=Me,attributes:t,disabled:r,data:s,getNewIndex:u=Pe,id:o,strategy:i,resizeObserverConfig:m,transition:f=je}=e;const{items:a,containerId:l,activeIndex:b,disabled:h,disableTransforms:k,sortedRects:w,overIndex:C,useDragOverlay:R,strategy:I}=p.useContext(J),S=Ke(r,h),c=a.indexOf(o),g=p.useMemo(()=>({sortable:{containerId:l,index:c,items:a},...s}),[l,s,c,a]),d=p.useMemo(()=>a.slice(a.indexOf(o)),[a,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:U,listeners:se,isDragging:$,over:oe,setActivatorNodeRef:ie,transform:ae}=ye({id:o,data:g,attributes:{...ze,...t},disabled:S.draggable}),le=we(L,U),T=!!D,X=T&&!k&&P(b)&&P(C),_=!R&&$,q=_&&X?ae:null,ce=X?q??(i??I)({rects:w,activeNodeRect:ne,activeIndex:b,overIndex:C,index:c}):null,O=P(b)&&P(C)?u({id:o,items:a,activeIndex:b,overIndex:C}):c,N=D?.id,x=p.useRef({activeId:N,items:a,newIndex:O,containerId:l}),ue=a!==x.current.items,B=n({active:D,containerId:l,isDragging:$,isSorting:T,id:o,index:c,items:a,newIndex:x.current.newIndex,previousItems:x.current.items,previousContainerId:x.current.containerId,transition:f,wasDragging:x.current.activeId!=null}),z=Fe({disabled:!B,index:c,node:y,rect:v});return p.useEffect(()=>{T&&x.current.newIndex!==O&&(x.current.newIndex=O),l!==x.current.containerId&&(x.current.containerId=l),a!==x.current.items&&(x.current.items=a)},[T,O,l,a]),p.useEffect(()=>{if(N===x.current.activeId)return;if(N!=null&&x.current.activeId==null){x.current.activeId=N;return}const fe=setTimeout(()=>{x.current.activeId=N},50);return()=>clearTimeout(fe)},[N]),{active:D,activeIndex:b,attributes:re,data:g,rect:v,index:c,newIndex:O,items:a,isOver:A,isSorting:T,isDragging:$,listeners:se,node:y,overIndex:C,over:oe,setNodeRef:le,setActivatorNodeRef:ie,setDroppableNodeRef:L,setDraggableNodeRef:U,transform:z??ce,transition:de()};function de(){if(z||ue&&x.current.newIndex===c)return $e;if(!(_&&!Re(te)||!f)&&(T||B))return V.Transition.toString({...f,property:Q})}}function Ke(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 Ue=[E.Down,E.Right,E.Up,E.Left],Ze=(e,n)=>{let{context:{active:t,collisionRect:r,droppableRects:s,droppableContainers:u,over:o,scrollableAncestors:i}}=n;if(Ue.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 a=he(f,"id");if(a===o?.id&&f.length>1&&(a=f[1].id),a!=null){const l=u.get(t.id),b=u.get(a),h=b?s.get(b.id):null,k=b?.node.current;if(k&&h&&l&&b){const C=xe(k).some((d,v)=>i[v]!==d),R=Z(l,b),I=Xe(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 Xe(e,n){return!j(e)||!j(n)||!Z(e,n)?!1:e.data.current.sortable.index<n.data.current.sortable.index}function _e(e){return{skillsConfig:De(e)}}function qe(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:qe(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 Be(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),i=p.useMemo(()=>t?Ee(t,s?.catalog??[]):[],[t,s]),[m,f]=p.useState(null),a=m??i,l=p.useCallback(async(c,g)=>{if(!t)return F.error("Still loading agent settings — try again in a moment"),!1;try{const d=_e(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??i;return v.some(y=>y.repo===c)?v:[...v,Be(g)]})},[i,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??i;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},[i]),k=p.useCallback((c,g)=>{f(d=>(d??i).map(v=>v.repo===c?{...v,...g}:v))},[i]),w=p.useCallback((c,g)=>{f(d=>{const v=d??i,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=K(v,y,A);return l(L,"Skill order updated"),L})},[l,i]),C=p.useCallback(async c=>{const g=a.filter(d=>d.repo!==c);return f(g),l(g,"Skill removed")},[l,a]),R=p.useCallback(async(c,g)=>{const d=a.map(v=>v.repo===c?{...v,enabled:g}:v);return f(d),l(d,g?"Skill enabled":"Skill disabled")},[l,a]),I=p.useCallback(async()=>{await l(a,"Skills saved")},[l,a]),S=p.useMemo(()=>({agentId:e,skillRows:a,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,a,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,Je as S,Ze as a,et as b,Qe as c,tt as f,qe as s,rt as u,We as v};
2
- //# sourceMappingURL=agent-skill-context-DPk5r08w.js.map
1
+ import{r as p,e5 as G,fV as ge,gt as pe,gK as be,bH as F,j as ve}from"./index-Cr5hwh-C.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 H,b as ke,c as ye,j as we,k as Re,C as V,l as Ae}from"./core.esm-CYvgWCuv.js";import{s as De,b as Ee}from"./skill-editor-D_W3QlRz.js";function K(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 Ne(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Y=e=>{let{rects:n,activeIndex:t,overIndex:r,index:s}=e;const u=K(n,r,t),o=n[s],i=u[s];return!i||!o?null:{x:i.left-o.left,y:i.top-o.top,scaleX:i.width/o.width,scaleY:i.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 i=(n=u[t])!=null?n:r;if(!i)return null;if(s===t){const f=u[o];return f?{x:0,y:t<o?f.top+f.height-(i.top+i.height):f.top-i.top,...M}:null}const m=Oe(u,s,t);return s>t&&s<=o?{x:0,y:-i.height-m,...M}:s<t&&s>=o?{x:0,y:i.height+m,...M}:{x:0,y:0,...M}};function Oe(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",J=G.createContext({activeIndex:-1,containerId:W,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Y,disabled:{draggable:!1,droppable:!1}});function Je(e){let{children:n,id:t,items:r,strategy:s=Y,disabled:u=!1}=e;const{active:o,dragOverlay:i,droppableRects:m,over:f,measureDroppableContainers:a}=Ie(),l=Se(W,t),b=i.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=Ne(u);H(()=>{I&&k&&a(h)},[I,h,k,a]),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 G.createElement(J.Provider,{value:g},n)}const Pe=e=>{let{id:n,items:t,activeIndex:r,overIndex:s}=e;return K(t,r,s).indexOf(n)},Me=e=>{let{containerId:n,isSorting:t,wasDragging:r,index:s,items:u,newIndex:o,previousItems:i,previousContainerId:m,transition:f}=e;return!f||!r||i!==u&&s===o?!1:t?!0:o!==s&&n===m},je={duration:200,easing:"ease"},Q="transform",$e=V.Transition.toString({property:Q,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),i=p.useRef(t);return H(()=>{if(!n&&t!==i.current&&r.current){const m=s.current;if(m){const f=Ae(r.current,{ignoreTransform:!0}),a={x:m.left-f.left,y:m.top-f.top,scaleX:m.width/f.width,scaleY:m.height/f.height};(a.x||a.y)&&o(a)}}t!==i.current&&(i.current=t)},[n,t,r,s]),p.useEffect(()=>{u&&o(null)},[u]),u}function Qe(e){let{animateLayoutChanges:n=Me,attributes:t,disabled:r,data:s,getNewIndex:u=Pe,id:o,strategy:i,resizeObserverConfig:m,transition:f=je}=e;const{items:a,containerId:l,activeIndex:b,disabled:h,disableTransforms:k,sortedRects:w,overIndex:C,useDragOverlay:R,strategy:I}=p.useContext(J),S=Ke(r,h),c=a.indexOf(o),g=p.useMemo(()=>({sortable:{containerId:l,index:c,items:a},...s}),[l,s,c,a]),d=p.useMemo(()=>a.slice(a.indexOf(o)),[a,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:U,listeners:se,isDragging:$,over:oe,setActivatorNodeRef:ie,transform:ae}=ye({id:o,data:g,attributes:{...ze,...t},disabled:S.draggable}),le=we(L,U),T=!!D,X=T&&!k&&P(b)&&P(C),_=!R&&$,q=_&&X?ae:null,ce=X?q??(i??I)({rects:w,activeNodeRect:ne,activeIndex:b,overIndex:C,index:c}):null,O=P(b)&&P(C)?u({id:o,items:a,activeIndex:b,overIndex:C}):c,N=D?.id,x=p.useRef({activeId:N,items:a,newIndex:O,containerId:l}),ue=a!==x.current.items,B=n({active:D,containerId:l,isDragging:$,isSorting:T,id:o,index:c,items:a,newIndex:x.current.newIndex,previousItems:x.current.items,previousContainerId:x.current.containerId,transition:f,wasDragging:x.current.activeId!=null}),z=Fe({disabled:!B,index:c,node:y,rect:v});return p.useEffect(()=>{T&&x.current.newIndex!==O&&(x.current.newIndex=O),l!==x.current.containerId&&(x.current.containerId=l),a!==x.current.items&&(x.current.items=a)},[T,O,l,a]),p.useEffect(()=>{if(N===x.current.activeId)return;if(N!=null&&x.current.activeId==null){x.current.activeId=N;return}const fe=setTimeout(()=>{x.current.activeId=N},50);return()=>clearTimeout(fe)},[N]),{active:D,activeIndex:b,attributes:re,data:g,rect:v,index:c,newIndex:O,items:a,isOver:A,isSorting:T,isDragging:$,listeners:se,node:y,overIndex:C,over:oe,setNodeRef:le,setActivatorNodeRef:ie,setDroppableNodeRef:L,setDraggableNodeRef:U,transform:z??ce,transition:de()};function de(){if(z||ue&&x.current.newIndex===c)return $e;if(!(_&&!Re(te)||!f)&&(T||B))return V.Transition.toString({...f,property:Q})}}function Ke(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 Ue=[E.Down,E.Right,E.Up,E.Left],Ze=(e,n)=>{let{context:{active:t,collisionRect:r,droppableRects:s,droppableContainers:u,over:o,scrollableAncestors:i}}=n;if(Ue.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 a=he(f,"id");if(a===o?.id&&f.length>1&&(a=f[1].id),a!=null){const l=u.get(t.id),b=u.get(a),h=b?s.get(b.id):null,k=b?.node.current;if(k&&h&&l&&b){const C=xe(k).some((d,v)=>i[v]!==d),R=Z(l,b),I=Xe(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 Xe(e,n){return!j(e)||!j(n)||!Z(e,n)?!1:e.data.current.sortable.index<n.data.current.sortable.index}function _e(e){return{skillsConfig:De(e)}}function qe(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:qe(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 Be(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),i=p.useMemo(()=>t?Ee(t,s?.catalog??[]):[],[t,s]),[m,f]=p.useState(null),a=m??i,l=p.useCallback(async(c,g)=>{if(!t)return F.error("Still loading agent settings — try again in a moment"),!1;try{const d=_e(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??i;return v.some(y=>y.repo===c)?v:[...v,Be(g)]})},[i,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??i;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},[i]),k=p.useCallback((c,g)=>{f(d=>(d??i).map(v=>v.repo===c?{...v,...g}:v))},[i]),w=p.useCallback((c,g)=>{f(d=>{const v=d??i,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=K(v,y,A);return l(L,"Skill order updated"),L})},[l,i]),C=p.useCallback(async c=>{const g=a.filter(d=>d.repo!==c);return f(g),l(g,"Skill removed")},[l,a]),R=p.useCallback(async(c,g)=>{const d=a.map(v=>v.repo===c?{...v,enabled:g}:v);return f(d),l(d,g?"Skill enabled":"Skill disabled")},[l,a]),I=p.useCallback(async()=>{await l(a,"Skills saved")},[l,a]),S=p.useMemo(()=>({agentId:e,skillRows:a,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,a,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,Je as S,Ze as a,et as b,Qe as c,tt as f,qe as s,rt as u,We as v};
2
+ //# sourceMappingURL=agent-skill-context-CCdvtlmH.js.map
@@ -1,2 +1,2 @@
1
- import{m as A,r as u,j as e,cy as L,y as C,I as K,f3 as P,by as Q,B as N,P as D,ae as z,gE as G,gF as H,aQ as Y,gU as U,eM as V,it as X}from"./index-_oPeVpL_.js";import{a as q,A as J}from"./agent-subpage-shell-B3K_jPYR.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-DPk5r08w.js";import{f as ne}from"./agent-loading-shells-CtZJM2Gc.js";import{u as ie,a as F,m as oe,P as re,D as ce,n as de,C as me}from"./core.esm-DiTpULFl.js";import{A as ue}from"./agent-card-controls-DzRs4Ix9.js";const T=":";function w(s){const t=s.indexOf("/");return t<0?s:`${s.slice(0,t)}${T}${s.slice(t+1)}`}function M(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=A(),[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:w(d)}})},O=()=>{const d=b({name:r,instructions:m});d&&o({to:"/$owner/agents/$agentId/skills/$skillKey",params:{owner:s,agentId:t,skillKey:w(d)}})},_=a?e.jsx(q,{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:D(z,"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(Q,{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(L,{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(G,{}):e.jsx(H,{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=A(),[o,i]=u.useState(!1),g=M(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 E="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 B({owner:s,agentId:t,expandedRepo:a}){const n=A(),{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(F(re,{activationConstraint:{distance:8}}),F(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(L,{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:w(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:E}),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:E}),e.jsx(Y,{icon:U,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:E}),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:w(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:D("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(V,{className:"h-4 w-4"})}),e.jsxs("button",{type:"button",className:D("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 I({owner:s,agentId:t,children:a,showBack:n}){return e.jsx(J,{owner:s,agentId:t,showBack:n,backLabel:"Skills",backTo:"/$owner/agents/$agentId/skills",children:a})}function Ne({owner:s,agentId:t}){return e.jsx(I,{owner:s,agentId:t,children:e.jsx(B,{owner:s,agentId:t})})}function Ce({owner:s,agentId:t}){const a=A();return e.jsx(I,{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 we({owner:s,agentId:t,skillKey:a}){return e.jsx(I,{owner:s,agentId:t,children:e.jsx(B,{owner:s,agentId:t,expandedRepo:M(a)})})}export{Ne as A,Ce as a,we as b};
2
- //# sourceMappingURL=agent-skills-route-DYpB5H1J.js.map
1
+ import{m as A,r as u,j as e,cy as F,y as C,I as K,f3 as P,by as Q,B as N,P as E,ae as z,gB as G,gC as H,aQ as Y,gR as q,eM as V,iq as X}from"./index-Cr5hwh-C.js";import{a as J,A as U}from"./agent-subpage-shell-D92imvSt.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-CCdvtlmH.js";import{f as ne}from"./agent-loading-shells-Dqcvky-k.js";import{u as ie,a as L,m as oe,P as re,D as ce,n as de,C as me}from"./core.esm-CYvgWCuv.js";import{A as ue}from"./agent-card-controls-mnTN2AZt.js";const T=":";function w(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=A(),[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:w(d)}})},O=()=>{const d=b({name:r,instructions:m});d&&o({to:"/$owner/agents/$agentId/skills/$skillKey",params:{owner:s,agentId:t,skillKey:w(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(z,"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(Q,{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(G,{}):e.jsx(H,{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=A(),[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=A(),{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(L(re,{activationConstraint:{distance:8}}),L(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:w(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(Y,{icon:q,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:w(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(V,{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 I({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(I,{owner:s,agentId:t,children:e.jsx(M,{owner:s,agentId:t})})}function Ce({owner:s,agentId:t}){const a=A();return e.jsx(I,{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 we({owner:s,agentId:t,skillKey:a}){return e.jsx(I,{owner:s,agentId:t,children:e.jsx(M,{owner:s,agentId:t,expandedRepo:B(a)})})}export{Ne as A,Ce as a,we as b};
2
+ //# sourceMappingURL=agent-skills-route-BUxIswuq.js.map
@@ -1,2 +1,2 @@
1
- import{m,j as e,P as h,B as n,gj as i}from"./index-_oPeVpL_.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};
2
- //# sourceMappingURL=agent-subpage-shell-B3K_jPYR.js.map
1
+ import{m,j as e,P as h,B as n,gj as i}from"./index-Cr5hwh-C.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};
2
+ //# sourceMappingURL=agent-subpage-shell-D92imvSt.js.map
@@ -0,0 +1,6 @@
1
+ import{j as s,r as l,aD as Ut,Z as Ft,fU as Vt,fV as Bt,V as Je,H as Fe,W as Ze,bV as Ht,fW as et,fX as zt,fY as Wt,L as pt,P as M,fj as Kt,dO as mt,dP as qt,fZ as Gt,dv as Qt,dQ as Xt,f_ as Yt,ah as Jt,B as ue,e1 as Zt,f$ as en,g0 as Ve,X as tn,a1 as nn,cC as rn,ae as Te,g1 as on,d5 as sn,d7 as ln,g2 as an,d6 as cn,bb as un,g3 as dn,g4 as fn,ds as pn,b7 as mn,g5 as hn,g6 as gn}from"./index-Cr5hwh-C.js";import{D as bn,E as xn}from"./app-bridge-BCm4muqj.js";import{A as vn,a as yn,b as Rn,c as Ke,d as ht,e as wn}from"./agent-loading-shells-Dqcvky-k.js";import{h as Sn,t as Cn,R as jn,i as Tn,u as Nn,M as En,a as An}from"./use-mention-search-By8RZyKW.js";import{E as kn,c as In}from"./events-feed-BtvhZF1f.js";const gt=l.createContext(null);function _n({extension:e,children:t}){return s.jsx(gt.Provider,{value:e??null,children:t})}function qe(){return l.useContext(gt)}var Ge=(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))(Ge||{});const On={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 Pn(e){if(typeof e=="string")return Object.values(Ge).includes(e)?e:void 0}const Mn=Object.freeze(Object.defineProperty({__proto__:null,AGENT_ERRORS:On,AgentErrorCode:Ge,toAgentErrorCode:Pn},Symbol.toStringTag,{value:"Module"})),{AGENT_ERRORS:Ln,toAgentErrorCode:$n}=Mn;function tt(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 bt(e,t){const n=$n(e);if(!n)return null;const r=Ln[n];if(r.cta==="none"||!t.workspaceSlug)return null;const o=encodeURIComponent(t.workspaceSlug);if(r.cta==="provider-connect"||r.cta==="provider-management"){const i=t.provider?`/${o}/connectors/${encodeURIComponent(`${Ut}${t.provider}`)}`:`/${o}/connectors`,c=tt(i,t.webOrigin);if(!c)return null;const u=new URL(c);return t.provider&&t.model&&u.searchParams.set("model",t.model),{label:r.ctaLabel??"Connect a provider",href:u.toString()}}if(!t.agentId)return null;const a=tt(`/${o}/agents/${encodeURIComponent(t.agentId)}/settings`,t.webOrigin);return a?{label:r.ctaLabel??"Open settings",href:a}:null}function xt(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 nt=new Set(["localhost","127.0.0.1","::1","[::1]"]);function Dn(e){return e?.trim().toLowerCase().replace(/^\.+|\.+$/g,"")||null}function rt(e,t){const n=Dn(t);if(!n)return!1;const r=e.toLowerCase().replace(/\.$/,"");return r===n||r.endsWith(`.${n}`)}function ot(e,t,n){try{const r=new URL(t),o=new URL(e,t),a=nt.has(o.hostname)&&nt.has(r.hostname),i=o.protocol===r.protocol&&(o.protocol==="https:"||o.protocol==="http:")&&rt(o.hostname,n)&&rt(r.hostname,n);return o.origin!==r.origin&&(a||i)&&(o.protocol=r.protocol,o.host=r.host),o.origin===r.origin&&o.pathname.startsWith("/api/v1/agents")&&(o.pathname=`/lobu${o.pathname}`),o.toString()}catch{return e}}const Un=/\.(png|jpe?g|gif|webp|avif|bmp|svg)$/i,vt=new Set(["suggest_actions"]),Oe="Thinking…";function Fn(e){const{textOut:t,statusLine:n,errorText:r,toolCalls:o}=e,a=[];n===Oe&&a.push({type:"reasoning"}),r&&a.push({type:"error",text:r});let i=t;return n&&n!==Oe&&(i=t?`${t}
2
+
3
+ ${n}`:n),i&&a.push({type:"text",text:i}),a.push(...o),a}const Qe=l.createContext(null);function Ne(){const e=l.useContext(Qe);if(!e)throw new Error("useLobuChat must be used within <LobuChatProvider>");return e}function Io({messages:e,workspaceSlug:t=null,children:n}){const r=l.useMemo(()=>({messages:e,running:!1,append:()=>{},cancel:()=>{},pendingAttachments:[],addAttachments:()=>{},removeAttachment:()=>{},agentId:null,conversationId:"",workspaceSlug:t,currentSuggestions:null}),[e,t]);return s.jsx(Qe.Provider,{value:r,children:n})}const yt=/\[([^\]]*)\]\((\S*?\/api\/v1\/files\/[^)\s]+)\)/g;function st(e){return e.replace(/<lobu_internal_context>[\s\S]*?<\/lobu_internal_context>\n*/g,"").replace(yt,"").replace(/\n{3,}/g,`
4
+
5
+ `).trim()}function Vn(e){const t=[];for(const n of e.matchAll(yt)){const r=n[1]?.trim()||"file",o=n[2];o&&t.push({name:r,url:o})}return t}function Bn(e,t={}){if(typeof e=="string"){const r=st(e);return r?[{type:"text",text:r}]:[]}if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||typeof r!="object")continue;const o=r;if(o.type==="text"&&typeof o.text=="string"){const a=st(o.text);a&&n.push({type:"text",text:a})}else t.showToolCalls&&o.type==="toolCall"&&typeof o.name=="string"&&!vt.has(o.name)?n.push({type:"tool-call",toolCallId:o.id??`tc-${n.length}`,toolName:o.name,args:o.arguments??{},...o.result!==void 0?{result:o.result}:{}}):t.showToolCalls&&o.type==="tool_use"&&typeof o.name=="string"&&n.push({type:"tool-call",toolCallId:o.id??`tc-${n.length}`,toolName:o.name,args:o.input??{},...o.result!==void 0?{result:o.result}:{}})}return n}function Hn(e){const t=[],n=r=>{for(const{name:o,url:a}of Vn(r))t.push({id:`file-${t.length}`,name:o,url:a,isImage:Un.test(o)})};if(typeof e=="string")return n(e),t.length>0?t:void 0;if(Array.isArray(e)){for(const r of e){if(!r||typeof r!="object")continue;const o=r;if(o.type==="image"&&typeof o.data=="string"){const a=o.mimeType||"image/png";t.push({id:`img-${t.length}`,name:`image-${t.length+1}`,imageDataUrl:`data:${a};base64,${o.data}`,isImage:!0})}else o.type==="text"&&typeof o.text=="string"&&n(o.text)}return t.length>0?t:void 0}}function zn(e,t){if(e.type==="bashExecution"){const r=e.content??{},o=e.timestamp?new Date(e.timestamp).getTime():void 0;return{id:e.id,role:"user",parts:[{type:"bash",command:r.command??"",output:r.output??"",exitCode:r.exitCode,cancelled:r.cancelled??!1}],createdAt:o&&!Number.isNaN(o)?o:void 0}}if(e.type!=="message"||e.isVerbose||e.role!=="assistant"&&e.role!=="user"&&e.role!=="system")return null;const n=e.timestamp?new Date(e.timestamp).getTime():void 0;return{id:e.id,role:e.role,parts:Bn(e.content,t),attachments:Hn(e.content),createdAt:n&&!Number.isNaN(n)?n:void 0}}const Wn=[],Kn=[];function qn(e){let t=null;for(const n of e)n.type==="suggestion"&&(t=n.prompts.length>0?n.prompts:null);return t}function Gn(e,t){if(e.length===0)return null;const n=[];for(const r of e)if(r.type!=="suggestion"){if(r.type==="agent-error"){n.push({type:"error",text:String(r.error??"Agent reported an error.")});const o=bt(r.errorCode,{...t,provider:r.errorContext?.provider,model:r.errorContext?.model});o&&n.push({type:"tool-call",toolCallId:`error-run-${r.runId}`,toolName:"link-button",args:{label:o.label,url:o.href}});continue}n.push({type:"tool-call",toolCallId:`approval-event-${r.eventId}`,toolName:"tool-approval",args:{runId:r.runId,action:r.action,proposal:r.proposal,current:r.current,fields:r.fields??null,attribution:r.attribution??null,resourceKind:r.resourceKind??null,reason:r.reason??null,status:r.status??"pending",reviewedByName:r.reviewedByName??null}})}return n.length===0?null:{id:"history-interactions",role:"assistant",parts:n}}const Qn=3e4,Xn=3*Qn,Yn=15e3;function lt(e){try{return JSON.parse(e.data)}catch{return{content:e.data}}}const be=e=>`${e}-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;function at(e){const t=[],n=new Set;for(const r of e){if(!r||typeof r!="object")continue;const{title:o,message:a}=r;if(typeof o!="string"||typeof a!="string")continue;const i=o.trim(),c=a.trim();if(i.length===0||c.length===0)continue;const u=`${i}\0${c}`;n.has(u)||(n.add(u),t.push({title:i,message:c}))}return t.length>0?t:null}function _o({agentId:e,workspaceSlug:t,thread:n="agent-panel",loadHistory:r=!0,ephemeralContext:o,onFirstUserMessage:a,children:i,initialDraft:c}){const u=Ft(),d=l.useRef(null),f=l.useRef(null),v=l.useRef(!1),m=l.useRef(o),g=l.useRef(!1),R=l.useRef(null);m.current=o;const{data:I,isLoading:b}=Vt(e,n,{orgSlug:t,enabled:r&&!!e&&!!n}),T=I?.messages??Wn,W=I?.interactions??Kn,{data:B}=Bt(e,{enabled:!!e}),D=!!(B?.showToolCalls??B?.settings?.showToolCalls),[J,E]=l.useState([]),[U,Z]=l.useState(!1),[ne,H]=l.useState([]),[G,Q]=l.useState(null),y=l.useRef(!1);y.current=U;const j=l.useMemo(()=>T.map(w=>zn(w,{showToolCalls:D})).filter(w=>w!==null),[T,D]),A=l.useRef(!1);l.useEffect(()=>{if(A.current||b||y.current)return;A.current=!0;const w=Gn(W,{workspaceSlug:t,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin});E(w?[...j,w]:j),Q(qn(W))},[e,b,j,W,t]);const _=l.useCallback(()=>{u.invalidateQueries({queryKey:["agent-thread-messages",t,e,n]}),u.invalidateQueries({queryKey:["agent-threads",t,e]})},[u,t,e,n]),O=l.useCallback(async()=>{if(d.current)return d.current;if(f.current)return f.current;if(!e)throw new Error("No agent selected");const w=(async()=>{const P=await Je(`${Fe}/lobu/api/v1/agents`,{method:"POST",headers:{"Content-Type":"application/json",...t?{"x-lobu-org":t}:{}},credentials:"include",body:JSON.stringify({agentId:e,thread:n}),timeoutMs:2e4});if(!P.ok)throw await Ze(P);const K=await P.json(),F=Ht(),N={sessionId:K.agentId,sseUrl:ot(K.sseUrl,Fe,F),messagesUrl:ot(K.messagesUrl,Fe,F)};return d.current=N,N})();f.current=w;try{return await w}catch(P){throw d.current=null,P}finally{f.current=null}},[e,t,n]),ee=l.useCallback(async(w,P,K)=>{const F=new AbortController;R.current=F;const N=C=>{E(z=>z.map(V=>V.id===K?{...V,parts:C}:V))};let oe;try{oe=await O()}catch(C){N([{type:"text",text:`Error: ${C instanceof Error?C.message:"Could not start a session."}`}]);return}let L=await et(oe.sseUrl,{throwOnFailure:!0});const me=[];let se=null;const Re=()=>{const C=se;se=null,C?.()},ce=C=>{me.push(C),Re()};let he=!1,ge=null;const Ae=new Promise(C=>{ge=C});let fe=0,we=Date.now();const pe=C=>{we=Date.now();const z=Number(C.lastEventId);Number.isFinite(z)&&z>fe&&(fe=z)},ke=["output","status","complete","closed","agent-error","question","suggestion","link-button","tool-approval","tool_use"],Se=C=>{C.addEventListener("open",()=>{he=!0,ge?.()}),C.addEventListener("connected",V=>{pe(V),he||(he=!0,ge?.())}),C.addEventListener("ping",pe);const z=V=>p=>{pe(p);const x=p;typeof x.data=="string"&&ce({kind:V,payload:lt(x)})};for(const V of ke)C.addEventListener(V,z(V));C.addEventListener("error",V=>{const p=V;if(typeof p.data=="string"&&p.data){pe(V),ce({kind:"error",payload:lt(p)});return}C.readyState===EventSource.CLOSED&&ce({kind:"error",payload:{error:"Connection closed"}})})};Se(L);const Ie=async()=>{L.close();let C=oe.sseUrl;if(fe){const z=new URL(oe.sseUrl,window.location.origin);z.searchParams.set("since",String(fe)),C=z.toString()}L=await et(C,{throwOnFailure:!1}),Se(L),we=Date.now()};await Promise.race([Ae,new Promise(C=>setTimeout(C,1500))]);const Ce=()=>{L.close(),Re()};F.signal.addEventListener("abort",Ce,{once:!0});try{const C=m.current?.trim(),z=!!C&&!g.current;z&&(g.current=!0);let V;if(P.length>0){const h=new FormData;h.set("content",w),z&&C&&h.set("ephemeralContext",C);for(const k of P)h.append("files",k,k.name);V={method:"POST",credentials:"include",body:h,timeoutMs:12e4}}else{const h={content:w};z&&C&&(h.ephemeralContext=C),V={method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(h),timeoutMs:2e4}}const p=await Je(oe.messagesUrl,V);if(!p.ok)throw d.current=null,await Ze(p);let x="",S=Oe,q=null;const te=[],$=()=>Fn({textOut:x,statusLine:S,errorText:q,toolCalls:te});for(N($());!F.signal.aborted;){if(me.length===0){let k;const re=await Promise.race([new Promise(Ue=>{se=()=>Ue(!0)}),new Promise(Ue=>{k=setTimeout(()=>Ue(!1),Yn)})]);k&&clearTimeout(k),!re&&Date.now()-we>=Xn&&(await Ie(),_());continue}const h=me.shift();if(h){if(h.kind==="output")S=null,x+=String(h.payload.content??"");else if(h.kind==="status")S=Oe;else if(h.kind==="complete"){S=null;const k=h.payload.finalText;typeof k=="string"&&k.length>0&&(x=k);const re=h.payload.suggestions;re!==void 0&&Q(Array.isArray(re)?at(re):null),_(),N($());return}else if(h.kind==="closed"){d.current=null;const k=h.payload.reason;S=`Session ended${k?`: ${k}`:""}.`,_(),N($());return}else if(h.kind==="error"||h.kind==="agent-error"){S=null,q=typeof h.payload.error=="string"&&h.payload.error?h.payload.error:"Agent reported an error.";const k=h.payload.errorContext&&typeof h.payload.errorContext=="object"?h.payload.errorContext:void 0,re=bt(h.payload.errorCode,{workspaceSlug:t,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin,provider:typeof k?.provider=="string"?k.provider:void 0,model:typeof k?.model=="string"?k.model:void 0});re&&te.push({type:"tool-call",toolCallId:be("l"),toolName:"link-button",args:{label:re.label,url:re.href}}),_(),N($());return}else if(h.kind==="question")te.push({type:"tool-call",toolCallId:be("q"),toolName:"question",args:{question:h.payload.question??"",options:h.payload.options??[]}});else if(h.kind==="tool_use"){if(S=null,vt.has(h.payload.name??"")){N($());continue}const k=h.payload.result_summary,re=xt(k);if(!D&&!re){N($());continue}te.push({type:"tool-call",toolCallId:h.payload.toolCallId??be("t"),toolName:D?h.payload.name??"tool":"subscription-candidate",args:D?h.payload.input??{}:null,result:k,isError:h.payload.isError})}else if(h.kind==="suggestion"){const k=h.payload.prompts;k!==void 0&&(Q(Array.isArray(k)?at(k):null),N($()))}else if(h.kind==="link-button")te.push({type:"tool-call",toolCallId:be("l"),toolName:"link-button",args:{label:h.payload.label??"Open link",url:h.payload.url??""}});else if(h.kind==="tool-approval"){const k=h.payload.runId;if(typeof k!="number")continue;te.push({type:"tool-call",toolCallId:`run-${k}`,toolName:"tool-approval",args:{runId:k,action:h.payload.action??null,proposal:h.payload.proposal??null,current:h.payload.current??null,fields:h.payload.fields??null,attribution:h.payload.attribution??null,resourceKind:h.payload.resourceKind??null}})}N($())}}}catch(C){N([{type:"text",text:`Error: ${C instanceof Error?C.message:"Send failed."}`}])}finally{F.signal.removeEventListener("abort",Ce),L.close()}},[e,O,_,D,t]),X=l.useCallback(w=>{const P=w.trim(),K=ne.map(L=>L.file);if(!P&&K.length===0||y.current||!e)return;v.current||(v.current=!0,a?.(P||K[0]?.name||""));const F={id:be("u"),role:"user",parts:P?[{type:"text",text:P}]:[],attachments:ne.map(L=>({id:L.id,name:L.name,isImage:L.isImage,imageDataUrl:L.isImage?URL.createObjectURL(L.file):void 0})),createdAt:Date.now()},N=be("asst"),oe={id:N,role:"assistant",parts:[{type:"reasoning"}],createdAt:Date.now()};E(L=>[...L,F,oe]),H([]),Z(!0),y.current=!0,ee(P,K,N).finally(()=>{Z(!1),y.current=!1,R.current=null})},[e,a,ne,ee]),ie=l.useCallback(()=>{R.current?.abort()},[]),ae=l.useCallback(w=>{const P=Array.from(w);H(K=>[...K,...P.map(F=>({id:crypto.randomUUID(),name:F.name,file:F,isImage:F.type.startsWith("image/")}))])},[]),ye=l.useCallback(w=>{H(P=>P.filter(K=>K.id!==w))},[]),Y=l.useRef(!1);l.useEffect(()=>{if(Y.current)return;const w=zt(n);w&&(Y.current=!0,X(w))},[n,X]);const de=l.useMemo(()=>({messages:J,running:U,append:X,cancel:ie,pendingAttachments:ne,addAttachments:ae,removeAttachment:ye,initialDraft:c,agentId:e,conversationId:n,workspaceSlug:t,currentSuggestions:G}),[J,U,X,ie,ne,ae,ye,c,e,n,t,G]);return r&&b?s.jsx(vn,{}):s.jsx(Qe.Provider,{value:de,children:i})}const it="mx-0.5 inline-flex items-center gap-1 rounded-md bg-accent px-1.5 py-0.5 align-baseline font-medium text-[0.9em] text-accent-foreground no-underline";function Jn({refItem:e}){const t=jn[e.kind]??Wt;return Tn(e.path)?s.jsxs("span",{className:it,children:[s.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]}):s.jsxs(pt,{to:e.path,className:M(it,"hover:bg-accent/80"),children:[s.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]})}const Xe=({text:e,renderText:t})=>Sn(e)?s.jsx(s.Fragment,{children:Cn(e).map((n,r)=>n.type==="ref"?s.jsx(Jn,{refItem:n.ref},`r${r}`):s.jsx("span",{children:t(n.text)},`t${r}`))}):s.jsx(s.Fragment,{children:t(e)}),Zn=({label:e="Thinking"})=>s.jsx("span",{className:"aui-thinking-shimmer inline-block text-sm","aria-live":"polite","aria-busy":"true",children:e}),Rt=l.createContext(null),wt=()=>{const e=l.useContext(Rt);if(!e)throw new Error("ChainOfThought components must be used within ChainOfThought");return e},St=l.memo(({className:e,open:t,defaultOpen:n=!1,onOpenChange:r,children:o,...a})=>{const[i,c]=Kt({prop:t,defaultProp:n,onChange:r}),u=l.useMemo(()=>({isOpen:i,setIsOpen:c}),[i,c]);return s.jsx(Rt.Provider,{value:u,children:s.jsx("div",{className:M("not-prose max-w-prose space-y-4",e),...a,children:o})})}),Ct=l.memo(({className:e,children:t,...n})=>{const{isOpen:r,setIsOpen:o}=wt();return s.jsx(mt,{onOpenChange:o,open:r,children:s.jsxs(qt,{className:M("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:[s.jsx(Gt,{className:"size-4"}),s.jsx("span",{className:"flex-1 text-left",children:t??"Chain of Thought"}),s.jsx(Qt,{className:M("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),jt=l.memo(({className:e,icon:t=Yt,label:n,description:r,status:o="complete",children:a,...i})=>{const c={complete:"text-muted-foreground",active:"text-foreground",pending:"text-muted-foreground/50"};return s.jsxs("div",{className:M("flex gap-2 text-sm",c[o],"fade-in-0 slide-in-from-top-2 animate-in",e),...i,children:[s.jsxs("div",{className:"relative mt-0.5",children:[s.jsx(t,{className:"size-4"}),s.jsx("div",{className:"-mx-px absolute top-7 bottom-0 left-1/2 w-px bg-border"})]}),s.jsxs("div",{className:"flex-1 space-y-2 overflow-hidden",children:[s.jsx("div",{children:n}),r&&s.jsx("div",{className:"text-muted-foreground text-xs",children:r}),a]})]})}),Tt=l.memo(({className:e,children:t,...n})=>{const{isOpen:r}=wt();return s.jsx(mt,{open:r,children:s.jsx(Xt,{className:M("mt-2 space-y-3","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...n,children:t})})});St.displayName="ChainOfThought";Ct.displayName="ChainOfThoughtHeader";jt.displayName="ChainOfThoughtStep";Tt.displayName="ChainOfThoughtContent";function er(e){return{contentIds:e.filter(n=>Number.isSafeInteger(n)&&n>0),sortBy:"date",sortOrder:"asc"}}function tr({ownerSlug:e,eventIds:t}){const n=t.join(","),r=l.useMemo(()=>er(n.split(",").map(Number)),[n]);return r.contentIds.length===0?null:s.jsx(Jt,{owner:e,children:({organizationId:o,ownerSlug:a})=>o?s.jsx(kn,{organizationId:o,ownerSlug:a,filters:r,dense:!0,hideOriginator:!0}):null})}function nr({defaultTagName:e,props:t,render:n,state:r={},stateAttributesMapping:o}){let a=Be(rr(r,o),t);if(!n)return l.createElement(e,a);if(typeof n=="function")return n(a,r);if(!l.isValidElement(n))return null;let i=n.props,c={...Be(a,i),ref:Ee(a.ref,i.ref)};return l.cloneElement(n,c)}function Be(...e){let t={};for(let n of e){if(!n)continue;let r=n;for(let o of Object.keys(r)){let a=r[o];if(a===void 0)continue;let i=t[o];o==="className"?t[o]=[i,a].filter(Boolean).join(" "):o==="style"?t[o]={...i,...a}:o==="ref"?t[o]=Ee(i,a):sr(o)&&typeof i=="function"&&typeof a=="function"?t[o]=or(a,i):t[o]=a}}return t}function rr(e,t){let n={};for(let r of Object.keys(e)){let o=e[r],a=t?.[r]?.(o);if(a){Object.assign(n,a);continue}if(r==="slot"){n["data-slot"]=o;continue}let i=`data-${String(r).replace(/[A-Z]/g,c=>`-${c.toLowerCase()}`)}`;typeof o=="boolean"?n[i]=o?"":void 0:o!=null&&(n[i]=String(o))}return n}function or(e,t){return function(n){e(n),n.defaultPrevented||t(n)}}function sr(e){return/^on[A-Z]/.test(e)}function Ee(...e){let t=e.filter(Boolean);if(t.length!==0)return n=>{for(let r of t)typeof r=="function"?r(n):r&&(r.current=n)}}var lr=8,ar=64,ir=0,Pe=.5,cr=180,ur=new Set(["ArrowDown","ArrowUp","End","Home","PageDown","PageUp"," "]),Nt={start:!1,end:!1},dr=[],Me={currentAnchorId:null,visibleMessageIds:dr};function fr({content:e,scrollEdgeThreshold:t,spacer:n,viewport:r}){if(!r||!e)return Nt;let o=Ye({content:e,spacer:n,viewport:r});return{start:r.scrollTop>t,end:o-r.scrollTop-r.clientHeight>t}}function pr({content:e,scrollMargin:t,scrollPreviousItemPeek:n,spacer:r,viewport:o,visibleMessageIds:a}){if(!e||!o)return Me;let i=o.getBoundingClientRect(),c=i.top+t+n,u=typeof IntersectionObserver>"u",d=[],f=null;for(let v of je(e,r)){let m=v.dataset.messageId;if(!m)continue;let g=v.dataset.scrollAnchor==="true",R=g||u?v.getBoundingClientRect():null;(u&&R?R.bottom>c&&R.top<i.bottom:a.has(m))&&d.push(m),g&&R&&R.top<=c+Pe&&(f=m)}return d.length===0&&f===null?Me:{currentAnchorId:f,visibleMessageIds:d}}function je(e,t){return Array.from(e.children).filter(n=>n instanceof HTMLElement&&n!==t)}function mr(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r?.dataset.scrollAnchor==="true")return r}return null}function hr(e,t){for(let n of e)if(n.dataset.scrollAnchor==="true"&&!t.has(n))return n;return null}function gr(e,t){let n=0;for(let r=t;r<e.length;r++)if(e[r]?.dataset.scrollAnchor==="true"&&(n+=1,n>1))return!0;return!1}function br(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.dataset.scrollAnchor==="true")return n}return null}function xr({content:e,spacer:t,viewport:n}){let r=n.getBoundingClientRect();for(let o of je(e,t)){if(!o.dataset.messageId)continue;let a=o.getBoundingClientRect();if(a.bottom>r.top&&a.top<r.bottom)return o}return null}function vr({align:e,element:t,scrollMargin:n,spacer:r,viewport:o}){let a=Et(t,o),i=t.getBoundingClientRect().height,c=wr(r);if(e==="center"){let u=Math.max(0,o.clientHeight-c.start-c.end);return a-c.start-(u-i)/2-n}if(e==="end")return a-o.clientHeight+i+c.end+n;if(e==="nearest"){let u=a+i,d=o.scrollTop+c.start,f=o.scrollTop+o.clientHeight-c.end;return a>=d&&u<=f?o.scrollTop:a<d?a-c.start-n:u-o.clientHeight+c.end+n}return a-c.start-n}function Et(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function _e(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function yr({content:e,scrollTop:t,spacer:n,viewport:r}){let o=Ye({content:e,spacer:n,viewport:r});return t+r.clientHeight-o}function Ye({content:e,spacer:t,viewport:n}){let r=je(e,t),o=At(e),a=n.getBoundingClientRect(),i=n.scrollTop,c=o.start+o.end;for(let u of r){let d=u.getBoundingClientRect();c=Math.max(c,d.bottom-a.top+i+o.end)}return c}function Rr(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function At(e){let t=window.getComputedStyle(e);return{end:He(t.paddingBlockEnd||t.paddingBottom),start:He(t.paddingBlockStart||t.paddingTop)}}function wr(e){let t=e?.parentElement;return t?At(t):{end:0,start:0}}function Sr(e){if(!e)return 0;let t=window.getComputedStyle(e),n=t.rowGap==="normal"?t.gap:t.rowGap;return He(n)}function He(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Cr({refs:e,commitScrollState:t,scheduleStateCommit:n,scheduleVisibilitySync:r}){let{streamingTurnRef:o,autoScrollRef:a,autoscrollingRef:i,autoscrollingTimeoutRef:c,contentRef:u,defaultScrollPositionAppliedRef:d,itemCountRef:f,messageElementsRef:v,modeRef:m,pendingScrollToMessageRef:g,prependRestoreRef:R,scrollMarginRef:I,scrollPreviousItemPeekRef:b,spacerGapRef:T,spacerHeightRef:W,spacerRef:B,viewportRef:D}=e,J=l.useCallback(y=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null),i.current!==y&&(i.current=y,t()),y&&(c.current=window.setTimeout(()=>{c.current=null,i.current=!1,t()},cr))},[t]),E=l.useCallback(y=>{let j=B.current;if(!j)return;let A=Math.max(0,Math.ceil(y));W.current!==A&&(W.current=A,j.hidden=A===0,j.style.height=`${A}px`,j.style.marginTop=A>0?`${-T.current}px`:"")},[]),U=l.useCallback((y,{behavior:j="auto",autoscrolling:A=!1}={})=>{let _=D.current;if(!_)return;let O=Math.max(0,y);if(Math.abs(_.scrollTop-O)<=Pe){_.scrollTop=O,t();return}A&&J(!0),_.scrollTo({top:O,behavior:j}),n()},[t,n,J]),Z=l.useCallback(({behavior:y="auto"}={})=>D.current?(E(0),o.current=null,m.current="free-scrolling",U(0,{behavior:y}),r(),!0):!1,[r,U,E]),ne=l.useCallback(({behavior:y="auto"}={})=>{let j=D.current;return j?(E(0),o.current=null,m.current=a.current?"following-bottom":"free-scrolling",U(Rr(j),{autoscrolling:!0,behavior:y}),r(),!0):!1},[r,U,E]),H=l.useCallback((y,{align:j="start",behavior:A="auto",scrollMargin:_=I.current}={},{keepPreviousPeek:O=!1}={})=>{let ee=u.current,X=D.current;if(!ee||!X||!ee.contains(y))return!1;let ie=vr({align:j,element:y,scrollMargin:O?_+b.current:_,spacer:B.current,viewport:X}),ae=yr({content:ee,scrollTop:ie,spacer:B.current,viewport:X});return E(ae),R.current={element:y,viewportTop:_e(y,X)},m.current=O?"anchored-to-message":"settling-jump",o.current=O?y:null,U(ie,{behavior:A}),r(),!0},[r,U,E]),G=l.useCallback(()=>{let y=o.current;return!y||!y.isConnected||m.current!=="anchored-to-message"?!1:H(y,{align:"start"},{keepPreviousPeek:!0})},[H]),Q=l.useCallback((y,j)=>{let A=v.current.get(y);return A?(d.current=!0,H(A,j)?(g.current=null,!0):(g.current={messageId:y,options:j},!0)):f.current===0?(g.current={messageId:y,options:j},d.current=!0,!0):!1},[H]);return{flushPendingScrollToMessage:l.useCallback(()=>{let y=g.current;if(!y)return!1;let j=v.current.get(y.messageId);return!j||!H(j,y.options)?!1:(g.current=null,d.current=!0,!0)},[H]),reanchorToAnchoredMessage:G,scrollToElement:H,scrollToEnd:ne,scrollToMessage:Q,scrollToStart:Z}}function kt(e,t){let n=e,r=new Set;return{getSnapshot:()=>n,hasListeners:()=>r.size>0,setSnapshot:o=>{t(n,o)||(n=o,r.forEach(a=>a()))},subscribe:(o,a,i)=>{let c=r.size===0;return r.add(o),c&&a?.(),()=>{r.delete(o),r.size===0&&i?.()}}}}function jr(e,t){return kt(e,t)}function Tr(){return kt(Me,Er)}function Nr(e,t){return e.start===t.start&&e.end===t.end}function Er(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?!1:e.visibleMessageIds.every((n,r)=>n===t.visibleMessageIds[r])}function Ar({autoScroll:e,scrollEdgeThreshold:t,scrollMargin:n,scrollPreviousItemPeek:r}){let o=l.useRef(e),a=l.useRef(!1),i=l.useRef(null),c=l.useRef(!1),u=l.useRef(t),d=l.useRef(0),f=l.useRef(null),v=l.useRef(0),m=l.useRef(e?"following-bottom":"free-scrolling"),g=l.useRef(new Map),R=l.useRef(null),I=l.useRef(null),b=l.useRef(null),T=l.useRef(r),W=l.useRef(!0),B=l.useRef(null),D=l.useRef(n),J=l.useRef(null),E=l.useRef(0),U=l.useRef(0),Z=l.useRef(null),ne=l.useRef(null),H=l.useRef(null),G=l.useRef(null),Q=l.useRef(null),y=l.useRef(null),j=l.useRef(null),A=l.useRef(null),_=l.useRef(new Set),O=l.useRef(new WeakSet);return H.current===null&&(H.current=jr(Nt,Nr)),A.current===null&&(A.current=Tr()),o.current=e,u.current=t,D.current=n,T.current=r,{autoScrollRef:o,autoscrollingRef:a,autoscrollingTimeoutRef:G,streamingTurnRef:b,contentRef:i,defaultScrollPositionAppliedRef:c,firstItemRef:f,itemCountRef:d,lastScrollTopRef:v,messageElementsRef:g,modeRef:m,pendingScrollFrameRef:J,pendingScrollToMessageRef:R,prependRestoreRef:I,preserveScrollOnPrependRef:W,rootRef:B,scrollEdgeThresholdRef:u,scrollMarginRef:D,scrollPreviousItemPeekRef:T,spacerGapRef:E,spacerHeightRef:U,spacerRef:Z,stateFrameRef:ne,stateStore:H.current,viewportRef:Q,visibilityFrameRef:y,visibilityObserverRef:j,visibilityStore:A.current,visibleMessageIdsRef:_,handledScrollAnchorsRef:O}}function ct(e,t){return l.useCallback(n=>{e.current=n,n&&t()},[e,t])}function kr({autoScroll:e=!1,defaultScrollPosition:t="end",scrollEdgeThreshold:n=lr,scrollPreviousItemPeek:r=ar,scrollMargin:o=ir}){let a=Ar({autoScroll:e,scrollEdgeThreshold:n,scrollMargin:o,scrollPreviousItemPeek:r}),{streamingTurnRef:i,autoScrollRef:c,autoscrollingRef:u,autoscrollingTimeoutRef:d,contentRef:f,defaultScrollPositionAppliedRef:v,firstItemRef:m,itemCountRef:g,lastScrollTopRef:R,messageElementsRef:I,modeRef:b,pendingScrollFrameRef:T,pendingScrollToMessageRef:W,prependRestoreRef:B,preserveScrollOnPrependRef:D,rootRef:J,scrollEdgeThresholdRef:E,scrollMarginRef:U,scrollPreviousItemPeekRef:Z,spacerGapRef:ne,spacerHeightRef:H,spacerRef:G,stateFrameRef:Q,stateStore:y,viewportRef:j,visibilityFrameRef:A,visibilityObserverRef:_,visibilityStore:O,visibleMessageIdsRef:ee,handledScrollAnchorsRef:X}=a,ie=l.useRef(t);ie.current!==t&&(ie.current=t,v.current=!1);let ae=l.useCallback(p=>{let x=J.current,S=j.current,q=[p.start&&"start",p.end&&"end"].filter(Boolean).join(" "),te=u.current;for(let $ of[x,S])$&&(q?$.setAttribute("data-scrollable",q):$.removeAttribute("data-scrollable"),$.toggleAttribute("data-autoscrolling",te))},[]),ye=l.useCallback(p=>{let x=j.current?.scrollTop??0,S=x<R.current-Pe;R.current=x,c.current&&!p.end&&b.current!=="settling-jump"&&b.current!=="anchored-to-message"?b.current="following-bottom":b.current==="following-bottom"&&p.end&&S&&!u.current&&(b.current="free-scrolling")},[]),Y=l.useCallback(()=>{let p=fr({content:f.current,scrollEdgeThreshold:E.current,spacer:G.current,viewport:j.current});ye(p);let x=b.current==="following-bottom"?{...p,end:!1}:p;ae(x),y.setSnapshot(x)},[ye,y,ae]),de=l.useCallback(()=>{Q.current===null&&(Q.current=window.requestAnimationFrame(()=>{Q.current=null,Y()}))},[Y]),w=l.useCallback(()=>{O.hasListeners()&&A.current===null&&(A.current=window.requestAnimationFrame(()=>{A.current=null,O.hasListeners()&&O.setSnapshot(pr({content:f.current,scrollMargin:U.current,scrollPreviousItemPeek:Z.current,spacer:G.current,viewport:j.current,visibleMessageIds:ee.current}))}))},[O]),{flushPendingScrollToMessage:P,reanchorToAnchoredMessage:K,scrollToElement:F,scrollToEnd:N,scrollToMessage:oe,scrollToStart:L}=Cr({refs:a,commitScrollState:Y,scheduleStateCommit:de,scheduleVisibilitySync:w}),me=l.useCallback(()=>{let p=B.current,x=j.current;if(!p||!x||!p.element.isConnected)return!1;let S=_e(p.element,x)-p.viewportTop;return Math.abs(S)<=Pe?!1:(x.scrollTop+=S,p.viewportTop=_e(p.element,x),de(),w(),!0)},[de,w]),se=l.useCallback(()=>{let p=f.current,x=j.current;if(!p||!x){B.current=null;return}let S=xr({content:p,spacer:G.current,viewport:x});B.current=S?{element:S,viewportTop:_e(S,x)}:null},[]),Re=l.useCallback(()=>{T.current===null&&(T.current=window.requestAnimationFrame(()=>{T.current=null,P()&&se()}))},[se,P]),ce=l.useCallback(()=>{if(!t||v.current||g.current===0)return!1;let p=!1;if(t==="last-anchor"){let x=f.current,S=j.current,q=x&&S?br(je(x,G.current)):null;if(!x||!S||!q)p=N({behavior:"auto"});else{let te=Et(q,S);p=Ye({content:x,spacer:G.current,viewport:S})-te<=S.clientHeight?N({behavior:"auto"}):F(q,{align:"start"},{keepPreviousPeek:!0})}}else p=t==="end"?N({behavior:"auto"}):L({behavior:"auto"});return p?(v.current=!0,!0):!1},[t,F,N,L]),he=l.useCallback(()=>{let p=f.current;if(!p)return;let x=je(p,G.current),S=g.current,q=m.current;g.current=x.length,m.current=x[0]??null,(()=>{if(P())return;if(S===0){if(ce()||x.length>0&&c.current&&N({behavior:"auto"}))return;Y(),w();return}let te=q?x.indexOf(q):-1;if(D.current&&te>0){me();return}if(x.length>S){let $=mr(x,S);if($){if(c.current&&b.current==="following-bottom"&&gr(x,S)){N({behavior:"auto"});return}F($,{align:"start"},{keepPreviousPeek:!0}),X.current.add($);return}}if(x.length===S){let $=hr(x,X.current);if($){F($,{align:"start"},{keepPreviousPeek:!0}),X.current.add($);return}}b.current==="following-bottom"&&c.current?N({behavior:"auto"}):(Y(),w())})(),se()},[ce,se,Y,P,me,w,F,N]),ge=l.useCallback(()=>{if(b.current==="following-bottom"&&c.current){N({behavior:"auto"});return}let p=H.current;if(K()){c.current&&p>0&&H.current===0&&N({behavior:"auto"});return}de(),w()},[K,de,w,N]),Ae=l.useCallback(()=>{let p=j.current;if(!(!p||!O.hasListeners())){if(typeof IntersectionObserver>"u"){w();return}_.current||(_.current=new IntersectionObserver(x=>{for(let S of x){let q=S.target.dataset.messageId;q&&(S.isIntersecting?ee.current.add(q):ee.current.delete(q))}w()},{root:p,rootMargin:`${-(U.current+Z.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]})),I.current.forEach(x=>{_.current?.observe(x)}),w()}},[w,O]),fe=l.useCallback(()=>{A.current!==null&&(window.cancelAnimationFrame(A.current),A.current=null),_.current?.disconnect(),_.current=null,ee.current.clear(),O.setSnapshot(Me)},[O]),we=l.useCallback((p,x,S)=>{if(x){I.current.set(p,x),_.current?.observe(x),w(),W.current?.messageId===p&&Re();return}S&&I.current.get(p)===S&&(I.current.delete(p),ee.current.delete(p),_.current?.unobserve(S),w())},[Re,w]),pe=l.useCallback(()=>{(b.current==="following-bottom"||b.current==="anchored-to-message"||b.current==="settling-jump")&&(i.current=null,b.current="free-scrolling")},[]),ke=l.useCallback(()=>ae(y.getSnapshot()),[y,ae]),Se=ct(J,ke),Ie=ct(j,ke),Ce=l.useCallback(p=>{f.current=p},[]),C=l.useCallback(p=>{G.current=p,ne.current=Sr(p?.parentElement??null)},[]),z=l.useCallback(()=>{Y(),w(),se()},[se,Y,w]),V=l.useMemo(()=>({handleContentChange:he,handleResize:ge,observeVisibility:Ae,preserveScrollOnPrependRef:D,scrollToEnd:N,scrollToMessage:oe,scrollToStart:L,setContentElement:Ce,setRootElement:Se,setSpacerElement:C,setViewportElement:Ie,stateStore:y,syncAfterScroll:z,unobserveVisibility:fe,userScrollIntent:pe,viewportRef:j,visibilityStore:O}),[he,ge,Ae,N,oe,L,Ce,Se,C,Ie,y,z,fe,pe,O]);return l.useLayoutEffect(()=>{ce()},[ce]),l.useEffect(()=>()=>{Q.current!==null&&(window.cancelAnimationFrame(Q.current),Q.current=null),A.current!==null&&(window.cancelAnimationFrame(A.current),A.current=null),d.current!==null&&(window.clearTimeout(d.current),d.current=null),T.current!==null&&(window.cancelAnimationFrame(T.current),T.current=null),_.current?.disconnect(),_.current=null},[]),l.useLayoutEffect(()=>{if(e&&b.current==="following-bottom"&&g.current>0){N({behavior:"auto"});return}Y()},[e,Y,N]),{context:V,registerMessage:we}}function Ir(e){let t=l.useRef(e);return t.current=e,t}var It=l.createContext(null),_t=l.createContext(null);function xe(){let e=l.useContext(It);if(!e)throw new Error("useMessageScroller must be used within a MessageScroller.");return e}function _r(){let e=l.useContext(_t);if(!e)throw new Error("MessageScrollerItem must be used within a MessageScroller.");return e}function Ot(){let{scrollToEnd:e,scrollToMessage:t,scrollToStart:n}=xe();return l.useMemo(()=>({scrollToEnd:e,scrollToMessage:t,scrollToStart:n}),[e,t,n])}function Pt(){let{observeVisibility:e,unobserveVisibility:t,visibilityStore:n}=xe(),r=l.useCallback(o=>n.subscribe(o,e,t),[e,t,n]);return l.useSyncExternalStore(r,n.getSnapshot,n.getSnapshot)}function Or({autoScroll:e=!1,children:t,defaultScrollPosition:n="end",scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:a}){let{context:i,registerMessage:c}=kr({autoScroll:e,defaultScrollPosition:n,scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:a});return s.jsx(It.Provider,{value:i,children:s.jsx(_t.Provider,{value:c,children:t})})}function Pr({children:e,...t}){let{setRootElement:n}=xe();return s.jsx("div",{ref:n,...t,children:e})}function Mr({"aria-label":e,children:t,onKeyDown:n,onScroll:r,onTouchMove:o,onWheel:a,preserveScrollOnPrepend:i=!0,ref:c,role:u,tabIndex:d,...f}){let{handleResize:v,preserveScrollOnPrependRef:m,setViewportElement:g,syncAfterScroll:R,userScrollIntent:I,viewportRef:b}=xe();m.current=i;let T=l.useCallback(E=>{g(E),Ee(c)?.(E)},[c,g]);function W(E){R(),r?.(E)}function B(E){I(),a?.(E)}function D(E){I(),o?.(E)}function J(E){ur.has(E.key)&&I(),n?.(E)}return l.useEffect(()=>{let E=b.current;if(!E||typeof ResizeObserver>"u")return;let U=0,Z=new ResizeObserver(()=>{window.cancelAnimationFrame(U),U=window.requestAnimationFrame(v)});return Z.observe(E),()=>{window.cancelAnimationFrame(U),Z.disconnect()}},[v,b]),s.jsx("div",{ref:T,role:u??"region","aria-label":e??"Messages",tabIndex:d??0,onKeyDown:J,onScroll:W,onTouchMove:D,onWheel:B,...f,children:t})}function Lr({"aria-relevant":e,children:t,ref:n,role:r,spacerClassName:o,...a}){let{handleContentChange:i,handleResize:c,setContentElement:u,setSpacerElement:d}=xe(),f=l.useRef(null),v=l.useCallback(m=>{f.current=m,u(m),Ee(n)?.(m)},[n,u]);return l.useLayoutEffect(()=>{let m=f.current;if(!m||(i(),typeof MutationObserver>"u"))return;let g=new MutationObserver(()=>{i()});return g.observe(m,{childList:!0}),()=>g.disconnect()},[i]),l.useEffect(()=>{let m=f.current;if(!m||typeof ResizeObserver>"u")return;let g=0,R=new ResizeObserver(()=>{window.cancelAnimationFrame(g),g=window.requestAnimationFrame(c)});return R.observe(m),()=>{window.cancelAnimationFrame(g),R.disconnect()}},[c]),s.jsxs("div",{ref:v,role:r??"log","aria-relevant":e??"additions",...a,children:[t,s.jsx("div",{ref:d,"aria-hidden":"true","data-message-scroller-spacer":"",hidden:!0,className:o})]})}function $r({messageId:e,ref:t,scrollAnchor:n=!1,...r}){let o=_r(),a=l.useRef(null),i=l.useCallback(c=>{let u=a.current;a.current=c,e&&o(e,c,u),Ee(t)?.(c)},[e,t,o]);return s.jsx("div",{ref:i,"data-message-id":e,"data-scroll-anchor":n?"true":"false",...r})}function Dr({behavior:e="smooth",children:t,direction:n="end",onClick:r,render:o,tabIndex:a,type:i="button",...c}){let{scrollToEnd:u,scrollToStart:d,stateStore:f}=xe(),v=Ir(r),m=l.useCallback(b=>f.subscribe(b),[f]),g=l.useCallback(()=>{let b=f.getSnapshot();return n==="start"?b.start:b.end},[n,f]),R=l.useSyncExternalStore(m,g,g),I=l.useCallback(b=>{R&&(v.current?.(b),b.defaultPrevented||(b.currentTarget.blur(),n==="start"?d({behavior:e}):u({behavior:e})))},[e,n,R,v,u,d]);return nr({defaultTagName:"button",props:Be({type:i,inert:!R,tabIndex:R?a:-1,children:t??s.jsxs("span",{children:["Scroll to ",n]}),onClick:I},c),render:o,state:{active:R,direction:n},stateAttributesMapping:{active:b=>({"data-active":b?"true":"false"})}})}var ve={Provider:Or,Root:Pr,Viewport:Mr,Content:Lr,Item:$r,Button:Dr};const Ur=ve.Provider;function Fr({className:e,...t}){return s.jsx(ve.Root,{className:M("relative flex size-full min-h-0 flex-col overflow-hidden",e),...t})}function Vr({className:e,...t}){return s.jsx(ve.Viewport,{className:M("size-full min-h-0 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]",e),...t})}function Br({className:e,...t}){return s.jsx(ve.Content,{className:M("flex h-max min-h-full flex-col",e),...t})}function Hr({className:e,...t}){return s.jsx(ve.Item,{className:M("min-w-0 shrink-0",e),...t})}function zr({className:e,...t}){return s.jsx(ve.Button,{direction:"end",behavior:"smooth",render:({active:n,...r})=>n?s.jsx(ue,{...r,type:"button",variant:"outline",size:"icon",className:M("absolute right-4 bottom-4 z-20 rounded-full bg-background ",e),"aria-label":"Scroll to latest message",children:s.jsx(Zt,{})}):null,...t})}function Wr(e){if(!e)return"";const t=e.startsWith("?")?e.slice(1):e,n=new URLSearchParams(t);return n.get("message_id")?.trim()||n.get("message")?.trim()||""}function Kr(e){const t=e.scrollTarget.trim();return t?e.alreadyScrolledTo===t?{scroll:!1}:e.messageIds.includes(t)?{scroll:!0,id:t}:{scroll:!1}:{scroll:!1}}const qr="lobu-spa";function ut(e){return typeof e=="string"&&/^https?:\/\//i.test(e.trim())}function Le(e,t){return t.type==="tool-call"?`tc-${t.toolCallId}`:t.type==="reasoning"?`${e.id}-reasoning`:t.type==="bash"?`${e.id}-bash-${t.command.slice(0,24)}`:t.type==="error"?`${e.id}-error`:`${e.id}-text-${t.text.slice(0,24)}`}const Oo=({afterMessagesContent:e,readOnly:t=!1,readerPositionMode:n="messages",interactionExtension:r,onRunSelect:o})=>{const{messages:a,agentId:i,conversationId:c}=Ne(),{data:u=[]}=en(i,{conversationId:c});return s.jsx(_n,{extension:r,children:s.jsxs("div",{"data-agent-thread":!0,className:"flex min-h-0 flex-1 flex-col",children:[s.jsx(Gr,{messages:a,trips:u,mode:n,afterMessagesContent:e,onRunSelect:o}),t?null:s.jsx("div",{className:yn,children:s.jsx(Co,{})})]})})},Gr=({messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})=>s.jsx(Ur,{autoScroll:!0,defaultScrollPosition:n==="runs"?"last-anchor":"end",scrollPreviousItemPeek:48,children:s.jsx(Xr,{messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})});function Qr(e){if(!e.startsWith("sep:"))return null;const t=Number(e.slice(4));return Number.isFinite(t)&&t>0?t:null}const Xr=({messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})=>{const{currentAnchorId:a}=Pt(),{scrollToMessage:i}=Ot(),c=l.useRef(null);l.useEffect(()=>{if(e.length===0||typeof window>"u")return;const d=Kr({messageIds:e.map(f=>f.id),scrollTarget:Wr(window.location.search),alreadyScrolledTo:c.current});d.scroll&&(c.current=d.id,i(d.id,{align:"start",behavior:"smooth"}))},[e,i]);const u=d=>n==="runs"?d.id.startsWith("sep:"):d.role==="user";return s.jsxs(Fr,{children:[s.jsx(Vr,{"aria-label":n==="runs"?"Automation run history":"Conversation",children:s.jsxs(Br,{className:M(Ke,Rn),children:[e.map(d=>{const f=n==="runs"&&o?Qr(d.id):null;return s.jsx(Hr,{messageId:d.id,scrollAnchor:u(d),"aria-current":d.id===a?"location":void 0,className:M("flex flex-col",n==="runs"&&u(d)&&"border-l-2 border-transparent pl-2 transition-colors",n==="runs"&&d.id===a&&"border-primary"),children:f!=null?s.jsx(fo,{message:d,onClick:()=>o?.(f)}):s.jsx(to,{message:d})},d.id)}),t.map(d=>s.jsx(Jr,{trip:d},d.id)),s.jsx(eo,{}),r?s.jsx("div",{className:"mt-auto shrink-0 py-2",children:r}):null]})}),e.length>0?s.jsx(Yr,{messages:e,mode:n}):null,s.jsx(zr,{})]})},Yr=({messages:e,mode:t})=>{const{scrollToMessage:n}=Ot(),{currentAnchorId:r,visibleMessageIds:o}=Pt(),a=t==="runs"?e.flatMap(c=>c.parts).filter(c=>c.type==="tool-call"&&c.toolName==="tool-approval"&&c.args!==null&&typeof c.args=="object"&&c.args.status==="pending").length:0,i=e.flatMap(c=>{if(!(t==="runs"?c.id.startsWith("sep:"):c.role==="user"))return[];const d=c.parts.find(f=>f.type==="text");return[{id:c.id,label:d?.type==="text"?d.text:"Automation run"}]});return i.length===0?null:s.jsxs(sn,{children:[s.jsx(ln,{asChild:!0,children:s.jsxs(ue,{type:"button",variant:"outline",size:"icon",className:M("absolute top-1/2 right-4 z-20 -translate-y-1/2 rounded-full bg-background/95 ",a>0&&"w-auto px-3"),"aria-label":a>0?`Open transcript outline, ${a} ${a===1?"approval":"approvals"} waiting`:"Open transcript outline",children:[s.jsx(an,{}),a>0?s.jsxs("span",{className:"text-xs tabular-nums",children:[a," waiting"]}):null]})}),s.jsxs(cn,{side:"left",align:"center",className:"w-80 space-y-3 p-3",children:[s.jsxs("div",{className:"px-1",children:[s.jsx("p",{className:"text-sm font-medium",children:"Transcript outline"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:t==="runs"?"Track and jump between Automation runs.":"Track and jump between your messages."})]}),s.jsx("div",{className:"max-h-80 space-y-1 overflow-y-auto",children:i.map(c=>{const u=c.id===r,d=o.includes(c.id);return s.jsxs(ue,{type:"button",variant:u?"secondary":"ghost",className:"h-auto w-full justify-start gap-2 px-2 py-2 text-left text-xs font-normal","aria-current":u?"location":void 0,onClick:()=>n(c.id,{align:"start",behavior:"smooth"}),children:[s.jsx("span",{className:M("size-1.5 shrink-0 rounded-full bg-muted-foreground/30",d&&"bg-primary/60",u&&"bg-primary")}),s.jsx("span",{className:"line-clamp-2",children:c.label})]},c.id)})})]})]})},Jr=({trip:e})=>s.jsxs("div",{className:M(Ke,"flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive"),children:[s.jsx(on,{className:"mt-0.5 size-4 shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"font-medium",children:["Guardrail blocked: ",e.guardrailName," ",s.jsxs("span",{className:"font-normal opacity-70",children:["(",e.stage,")"]})]}),e.reason?s.jsx("div",{className:"mt-0.5 break-words opacity-80",children:e.reason}):null]})]}),Zr=({prompts:e,onPick:t,className:n})=>e.length===0?null:s.jsx("div",{className:M("flex flex-wrap gap-2",n),children:e.map(r=>s.jsx(ue,{type:"button",variant:"outline",size:"sm",className:"h-auto rounded-full whitespace-normal text-left",title:r.message,"aria-label":`${r.title}: ${r.message}`,onClick:()=>t(r.message),children:r.title},`${r.title}\0${r.message}`))}),eo=()=>{const{currentSuggestions:e,running:t,append:n}=Ne();return t||!e||e.length===0?null:s.jsx(Zr,{prompts:e,className:Ke,onPick:r=>n(r)})},to=({message:e})=>e.role==="user"?s.jsx(no,{message:e}):e.role==="system"?s.jsx(po,{message:e}):s.jsx(so,{message:e}),Mt=({attachment:e})=>{const t=e.isImage?e.imageDataUrl??e.url:void 0;if(t)return s.jsx("a",{href:e.url??t,target:"_blank",rel:"noreferrer",children:s.jsx("img",{src:t,alt:e.name,className:"max-h-64 rounded-lg border object-contain"})});const n=s.jsxs(s.Fragment,{children:[s.jsx(Ve,{className:"h-3 w-3 shrink-0"}),s.jsx("span",{className:"max-w-[14rem] truncate",children:e.name})]});return s.jsx("div",{className:"flex items-center gap-1.5 rounded-md border bg-background px-2 py-1 text-xs",children:e.url?s.jsx("a",{href:e.url,target:"_blank",rel:"noreferrer",className:"flex items-center gap-1.5 hover:underline",children:n}):n})},no=({message:e})=>{const t=e.parts.filter(n=>n.type==="bash");return t.length>0?s.jsx("div",{className:ht,children:s.jsx("div",{className:"space-y-2",children:t.map(n=>s.jsx(ro,{part:n},Le(e,n)))})}):s.jsx("div",{className:wn,children:s.jsxs("div",{className:M(Te,"px-3 py-2 text-sm"),children:[e.attachments&&e.attachments.length>0?s.jsx("div",{className:"mb-1.5 flex flex-wrap gap-1.5",children:e.attachments.map(n=>s.jsx(Mt,{attachment:n},n.id))}):null,e.parts.map(n=>n.type==="text"?s.jsx("div",{className:"whitespace-pre-wrap break-words",children:s.jsx(Xe,{text:n.text,renderText:r=>r})},Le(e,n)):null)]})})},ro=({part:e})=>{const t=e.cancelled||e.exitCode!==void 0&&e.exitCode!==0;return s.jsxs("div",{className:M(Te,"overflow-hidden text-xs"),children:[s.jsxs("div",{className:"flex items-center gap-1.5 border-border/60 border-b px-3 py-1.5",children:[s.jsx(un,{className:"size-3.5 shrink-0 text-muted-foreground"}),s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-foreground/90",children:e.command}),e.cancelled?s.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-medium text-[10px] text-muted-foreground",children:"cancelled"}):t?s.jsxs("span",{className:"rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-[10px] text-destructive",children:["exit ",e.exitCode]}):null]}),e.output.trim()?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-foreground/80",children:e.output}):null]})},Lt=new Set(["question","link-button","tool-approval"]),oo="subscription-candidate",so=({message:e})=>{const t=qe(),{agentId:n,workspaceSlug:r}=Ne(),o=u=>u.type==="tool-call"&&(Lt.has(u.toolName)||t?.toolNames.has(u.toolName)),a=e.parts.filter(u=>u.type==="tool-call"&&!o(u)&&u.toolName!==oo),i=e.parts.filter(u=>u.type!=="tool-call"||o(u)),c=e.parts.flatMap(u=>{if(u.type!=="tool-call")return[];const d=xt(u.result);return d?[d]:[]});return s.jsx("div",{className:ht,children:s.jsxs("div",{className:"space-y-2 text-sm",children:[a.length>0?s.jsx(io,{tools:a,workspaceSlug:r}):null,n&&r?c.map(u=>s.jsx(lo,{candidate:u,agentId:n,workspaceSlug:r},`${u.connector_key}:${u.resource_ref}`)):null,i.map(u=>s.jsx(uo,{part:u},Le(e,u))),e.attachments&&e.attachments.length>0?s.jsx("div",{className:"flex flex-wrap gap-2",children:e.attachments.map(u=>s.jsx(Mt,{attachment:u},u.id))}):null]})})},lo=({candidate:e,agentId:t,workspaceSlug:n})=>s.jsxs("div",{className:M(Te,"flex items-center justify-between gap-3 p-3"),children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"truncate text-sm font-medium",children:e.label}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Run this agent when the resource changes."})]}),s.jsx(ue,{asChild:!0,size:"sm",variant:"outline",className:"shrink-0",children:s.jsxs(pt,{to:"/$owner/automations/new",params:{owner:n},search:{agent:t,platform:e.connector_key,resource_type:e.resource_type,resource:e.resource_ref,events:e.suggested_event_keys?.join(","),label:e.label},children:[s.jsx(fn,{className:"mr-1.5 h-4 w-4"}),"Add automation"]})})]});function ao(e){try{return JSON.parse(e)}catch{return null}}function $t(e){if(Array.isArray(e)){const o=e.flatMap(a=>a?.type==="text"&&typeof a.text=="string"?$t(a.text)??[]:[]);return o.length>0?[...new Set(o)]:null}const t=typeof e=="string"&&e.trimStart().startsWith("{")?ao(e):e;if(!t||typeof t!="object")return null;const n=t.events_persisted;if(!Array.isArray(n))return null;const r=n.flatMap(o=>{const a=o&&typeof o=="object"?o.id:null;return typeof a=="number"&&Number.isSafeInteger(a)&&a>0?[a]:[]});return r.length>0?r:null}const io=({tools:e,workspaceSlug:t})=>s.jsxs(St,{defaultOpen:!1,children:[s.jsx(Ct,{children:e.length===1?e[0].toolName:`${e.length} tool calls`}),s.jsx(Tt,{children:e.map(n=>{const r=n.args!==void 0&&n.args!==null,o=n.result!==void 0&&n.result!==null,a=$t(n.result);return s.jsxs(jt,{icon:dn,label:s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"font-medium",children:n.toolName}),n.isError?s.jsx("span",{className:"rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-[10px] text-destructive",children:"error"}):null]}),status:n.isError?"active":"complete",children:[r?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:De(n.args)}):null,o?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:De(n.result)}):null,a&&t?s.jsx(tr,{ownerSlug:t,eventIds:a}):null]},n.toolCallId)})})]}),co=({text:e})=>{let t=e,n=null;const r=e.match(/\{[\s\S]*\}/);if(r)try{const a=JSON.parse(r[0])?.error?.message;typeof a=="string"&&a.trim()&&(t=a,n=e)}catch{}return s.jsxs("div",{className:"flex gap-2 rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2.5 text-sm",children:[s.jsx(mn,{className:"mt-0.5 size-4 shrink-0 text-destructive"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsx("p",{className:"text-foreground/80",children:t}),n&&s.jsxs("details",{className:"text-xs text-muted-foreground",children:[s.jsx("summary",{className:"cursor-pointer select-none hover:text-foreground",children:"Technical details"}),s.jsx("pre",{className:"mt-1 overflow-x-auto whitespace-pre-wrap break-all font-mono",children:n})]})]})]})},uo=({part:e})=>{const t=qe();return e.type==="reasoning"?s.jsx(Zn,{}):e.type==="error"?s.jsx(co,{text:e.text}):e.type==="text"?e.text.trim()?s.jsx(Xe,{text:e.text,renderText:n=>s.jsx(pn,{text:n})}):null:e.type!=="tool-call"?null:Lt.has(e.toolName)||t?.toolNames.has(e.toolName)?s.jsx(So,{toolName:e.toolName,args:e.args}):null},fo=({message:e,onClick:t})=>{const n=e.parts.find(r=>r.type==="text");return s.jsx("button",{type:"button",onClick:t,className:M(Te,"block w-full cursor-pointer whitespace-pre-wrap break-words px-3 py-2 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/50"),children:n?.type==="text"?n.text:"Automation run"})},po=({message:e})=>s.jsx("div",{className:"self-stretch",children:s.jsx("div",{className:M(Te,"px-3 py-2 text-xs text-muted-foreground"),children:e.parts.map(t=>t.type==="text"?s.jsx("div",{className:"whitespace-pre-wrap break-words",children:s.jsx(Xe,{text:t.text,renderText:n=>n})},Le(e,t)):null)})}),mo="/mcp-apps/interaction/index.html";function dt(e){return new Promise(t=>{e({onSettled:(n,r)=>t(!!r)})})}const ho=({src:e,title:t,renderPayload:n,onToolCall:r,onOpenLink:o})=>{const a=l.useRef(null),[i,c]=l.useState(48),u=l.useRef({renderPayload:n,onToolCall:r,onOpenLink:o});return u.current={renderPayload:n,onToolCall:r,onOpenLink:o},l.useEffect(()=>{const d=a.current;if(!d?.contentWindow)return;const f=new bn(null,{name:"Lobu",version:"1.0.0"},{openLinks:{},serverTools:{}},{hostContext:{theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"}});f.addEventListener("sizechange",({height:g})=>{typeof g=="number"&&c(Math.max(32,Math.ceil(g)))}),f.oncalltool=async({name:g,arguments:R})=>{const I=await u.current.onToolCall(g,R??{});return{isError:I,content:[{type:"text",text:I?"Action failed.":"Action completed."}]}},f.onopenlink=async({url:g})=>({isError:await u.current.onOpenLink(g)}),f.addEventListener("initialized",()=>{(async()=>(await f.sendToolInput({arguments:{}}),await f.sendToolResult({content:[],structuredContent:{...u.current.renderPayload,version:1,source:qr}})))()});const v=new xn(d.contentWindow,d.contentWindow);f.connect(v).catch(g=>{console.error("[mcp-app-host] failed to initialize",g)});const m=new MutationObserver(()=>{f.setHostContext({theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"})});return m.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{m.disconnect(),v.close()}},[]),s.jsx("iframe",{ref:a,title:t,src:e,sandbox:"allow-scripts",style:{width:"100%",height:i,border:"none",display:"block"}})},go=new Set(["action"]),bo=["name","description","identity_md"];function le(e){return e==null||e===""?"":typeof e=="string"?e:De(e)}function ft(e){return e===null?"(cleared)":e===void 0?"":typeof e=="string"?e===""?"":e:De(e)}function $e(e){return e.length>0?e[0].toUpperCase()+e.slice(1):e}const Dt=new Set(["delete","disconnect","remove","remove_rule","reset","revoke"]);function ze(e){return e&&Dt.has(e)?"warning":"default"}function We(e,t){return e&&Dt.has(e)?{level:"high",reason:t}:{level:"normal"}}function xo(e,t){const n=e.attribution==="automation"?"An Automation":"An agent",r=Object.keys(t),o=r.map(a=>({label:a,before:le(e.current?.[a]),after:le(t[a])}));return{title:`${n} proposes a change`,icon:"entity",impact:{level:"normal"},tone:"default",blocks:o.length>0?[{type:"diff",fields:o}]:[{type:"text",value:"No field changes.",muted:!0}],actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${r.join(", ")} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${r.join(", ")} was not applied.`}]}}function vo(e){const t=e.action??"change",n=e.proposal?.slug??e.proposal?.name??(e.proposal?.automation_id!=null?String(e.proposal.automation_id):void 0)??e.current?.slug??e.current?.name??"automation",r=[];e.action==="delete"&&r.push({type:"text",value:"This will archive the Automation.",muted:!0});const o=e.proposal??{},a=Object.keys(o).filter(i=>!go.has(i)&&o[i]!==void 0).map(i=>({label:i,...e.action==="update"&&e.current?.[i]!==void 0?{before:ft(e.current?.[i])}:{},after:ft(o[i])}));return r.push(a.length>0?{type:"diff",fields:a}:{type:"text",value:"No field changes.",muted:!0}),{title:`${$e(t)} Automation ${n}`,icon:"automation",impact:We(e.action,"This archives the Automation and stops future runs."),tone:ze(e.action),blocks:r,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${t} ${n} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${t} ${n} was not applied.`}]}}function yo(e){if(e.resourceKind==="automation")return vo(e);if(e.fields&&Object.keys(e.fields).length>0)return xo(e,e.fields);const t=e.resourceKind==="entity"||e.proposal?.entity_id!==void 0||e.current?.entity_type!==void 0||e.proposal?.entity_type!==void 0;if(t&&(e.action==="link"||e.action==="unlink"))return In({...e,action:e.action});if(t){const a=e.proposal?.name??e.current?.name??e.proposal?.entity_id??e.current?.id??"entity",i=e.action??"change",c=[];if(e.action==="delete")c.push({type:"text",value:"This will delete the entity.",muted:!0});else{const u=Object.keys(e.proposal??{}).filter(d=>!["entity_id","id"].includes(d)&&e.proposal?.[d]!==void 0&&le(e.proposal?.[d])!==le(e.current?.[d])).map(d=>({label:d,...e.action==="update"?{before:le(e.current?.[d])}:{},after:le(e.proposal?.[d])}));c.push(u.length>0?{type:"diff",fields:u}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${$e(i)} entity ${a}`,icon:"entity",impact:We(e.action,"This deletes the entity."),tone:ze(e.action),blocks:c,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${i} ${a} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${i} ${a} was not applied.`}]}}const n=e.proposal?.agent_id??e.current?.id??"agent",r=e.action??"change",o=[];if(e.action==="delete")o.push({type:"text",value:"This will permanently delete the agent.",muted:!0});else{const a=bo.filter(i=>e.proposal?.[i]!==void 0&&le(e.proposal?.[i])!==le(e.current?.[i])).map(i=>({label:i,...e.action==="update"?{before:le(e.current?.[i])}:{},after:le(e.proposal?.[i])}));o.push(a.length>0?{type:"diff",fields:a}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${$e(r)} agent ${n}`,icon:"agent",impact:We(e.action,"This permanently deletes the agent and its configuration."),tone:ze(e.action),blocks:o,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${r} ${n} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${r} ${n} was not applied.`}]}}function Ro(e){const t=Array.isArray(e.options)?e.options.filter(o=>typeof o=="string"):[],n=[{type:"text",value:e.question||"The agent has a question."}];t.length===0&&n.push({type:"text",value:"Reply below to answer.",muted:!0});const r=t.map(o=>({id:o,label:o,variant:"outline",tool:"answer_question",args:{answer:o},resolvedLabel:`Answered: ${o}`}));return{title:"Input needed",icon:"question",tone:"default",blocks:n,actions:r}}function wo(e,t){return{tone:"bare",actions:[{id:"open",label:e.label??"Open link",variant:"outline",icon:"external",terminal:!1,href:t}]}}const So=({toolName:e,args:t})=>{const n=hn(),r=gn(),{append:o}=Ne(),a=qe(),i=t??{},c=a?.resolve(e,t)??null;let u=c?.view??null;const d={...c?.handlers??{}},f=new Set;if(!c){if(e==="tool-approval"&&typeof i.runId=="number"&&Number.isSafeInteger(i.runId)&&i.runId>0){const v=i.runId,m=typeof i.status=="string"?i.status:"pending",g=m==="pending",R=yo(i),I=m==="confirmed"?"Approved":$e(m);u=g?R:{...R,title:`${R.title??"Approval"} · ${I}`,tone:m==="failed"?"warning":"default",blocks:[...R.blocks??[],{type:"text",value:typeof i.reviewedByName=="string"?`${m==="rejected"?"Rejected":"Approved"} by ${i.reviewedByName}.`:`${I}.`,muted:!0}],actions:(R.actions??[]).filter(b=>b.terminal===!1)},g&&(d.manage_operations=b=>{if(b.action==="approve")return dt(T=>n.mutate({run_id:v},T));if(b.action==="reject"){const T=typeof b.reason=="string"?b.reason:void 0;return dt(W=>r.mutate({run_id:v,...T?{reason:T}:{}},W))}return Promise.resolve(!0)})}else if(e==="question"){const v=Array.isArray(i.options)?i.options.filter(m=>typeof m=="string"):[];u=Ro(i),d.answer_question=m=>{const g=typeof m.answer=="string"?m.answer:"";return v.includes(g)?(o(g),Promise.resolve(!1)):Promise.resolve(!0)}}else if(e==="link-button"){if(!ut(i.url))return null;const v=i.url;f.add(v),u=wo(i,v)}}return u?s.jsx(ho,{src:mo,title:u.title??"Interaction",renderPayload:u,onToolCall:(v,m)=>d[v]?d[v](m):Promise.resolve(!0),onOpenLink:v=>!f.has(v)||!ut(v)?Promise.resolve(!0):(window.open(v,"_blank","noopener,noreferrer"),Promise.resolve(!1))}):null};function De(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}const Co=()=>{const{running:e,append:t,cancel:n,pendingAttachments:r,addAttachments:o,removeAttachment:a,initialDraft:i,currentSuggestions:c}=Ne(),u=jo({suggestions:e?null:c}),[d,f]=l.useState(i??""),v=l.useRef(null),m=l.useRef(null),g=Nn(An),R=l.useRef(i??"");l.useEffect(()=>{const T=i??"";if(T===R.current)return;const W=R.current;R.current=T,T!==""&&f(B=>B===""||B===W?T:B)},[i]);const I=l.useRef(d);I.current=d;const b=()=>{e||(t(I.current),f(""),m.current?.clear())};return s.jsxs("div",{className:"rounded-2xl border bg-background transition-colors focus-within:ring-1 focus-within:ring-ring",children:[r.length>0?s.jsx("div",{className:"flex flex-wrap gap-1.5 px-3 pt-3",children:r.map(T=>s.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border bg-muted/50 px-2 py-1 text-xs",children:[s.jsx(Ve,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"max-w-[12rem] truncate",children:T.name}),s.jsx("button",{type:"button",className:"text-muted-foreground transition-colors hover:text-foreground","aria-label":"Remove attachment",onClick:()=>a(T.id),children:s.jsx(tn,{className:"h-3 w-3"})})]},T.id))}):null,s.jsx(En,{value:d,onChange:f,onSubmit:b,searchRefs:g,handleRef:m,placeholder:u,className:"max-h-48 overflow-y-auto"}),s.jsxs("div",{className:"flex items-center justify-between px-3 pb-2",children:[s.jsx("input",{ref:v,type:"file",multiple:!0,className:"hidden",onChange:T=>{T.target.files&&o(T.target.files),T.target.value=""}}),s.jsxs(ue,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 rounded-full text-muted-foreground hover:text-foreground",onClick:()=>v.current?.click(),children:[s.jsx(Ve,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Attach files"})]}),e?s.jsxs(ue,{type:"button",size:"icon",variant:"secondary",className:"h-8 w-8 rounded-full",onClick:n,children:[s.jsx(nn,{size:"lg"}),s.jsx("span",{className:"sr-only",children:"Cancel"})]}):s.jsxs(ue,{type:"button",size:"icon",className:"h-8 w-8 rounded-full",onClick:b,children:[s.jsx(rn,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Send message"})]})]})]})};function jo({suggestions:e}){const t=e?.find(n=>n.message.trim().length>0)?.message;return t?`Recommended: ${t.trim()}`:"Chat… (@ to mention, / for commands)"}export{Oo as A,_o as L,Io as R,Gn as h,zn as s};
6
+ //# sourceMappingURL=agent-thread-BJOijbT0.js.map
@@ -0,0 +1,2 @@
1
+ import{j as t,O as o}from"./index-Cr5hwh-C.js";const n=()=>t.jsx(o,{});export{n as component};
2
+ //# sourceMappingURL=agents-9XjpDj_S.js.map