@lobu/runtime-server 21.0.0 → 21.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalogs/automations.json +0 -8
- package/dist/component.json +1 -1
- package/dist/connectors/github.ts +269 -194
- package/dist/connectors/google_calendar.ts +36 -132
- package/dist/connectors/jira.ts +13 -4
- package/dist/connectors/producthunt.ts +3 -1
- package/dist/connectors/reddit.ts +34 -4
- package/dist/db/migrations/20260928120000_classification_consolidation.sql +51 -0
- package/dist/dependencies.bun.lock +11 -11
- package/dist/owletto/dist/assets/_-00GgOtdu.js +1 -0
- package/dist/owletto/dist/assets/{_-DrcppoWh.js → _-XlUwOWCI.js} +2 -2
- package/dist/owletto/dist/assets/{_agentId-HNcmgH56.js → _agentId-B2DrawIk.js} +1 -1
- package/dist/owletto/dist/assets/_agentId-CS0AcWH2.js +1 -0
- package/dist/owletto/dist/assets/{_automationId-BCfrLnUS.js → _automationId-BLnqLtUv.js} +1 -1
- package/dist/owletto/dist/assets/{_connectorKey._connectionId-126-iG9w.js → _connectorKey._connectionId-DcUWoZ-C.js} +1 -1
- package/dist/owletto/dist/assets/{_connectorKey.index-CywE9A3N.js → _connectorKey.index-C_yKycN_.js} +1 -1
- package/dist/owletto/dist/assets/{_conversationId-CNETA_rY.js → _conversationId-CpuEvflw.js} +1 -1
- package/dist/owletto/dist/assets/{_deploymentId-CAVpXf8s.js → _deploymentId-BL9tnDFl.js} +1 -1
- package/dist/owletto/dist/assets/_name-DlxjWkKk.js +1 -0
- package/dist/owletto/dist/assets/{_owner-D2eh4R90.js → _owner-Cg50UU6m.js} +1 -1
- package/dist/owletto/dist/assets/_shape-BWZW4mj8.js +1 -0
- package/dist/owletto/dist/assets/_skillKey-B25fO0_O.js +1 -0
- package/dist/owletto/dist/assets/{_slug-DoIaJBbh.js → _slug-DbD-wv2m.js} +1 -1
- package/dist/owletto/dist/assets/_viewKey-BcTEvQ3N.js +1 -0
- package/dist/owletto/dist/assets/_viewKey-W4RjiUWL.js +1 -0
- package/dist/owletto/dist/assets/_viewKey-iGPCKSda.js +1 -0
- package/dist/owletto/dist/assets/{accept-invitation-BWRiEUsd.js → accept-invitation-BmQKbQem.js} +1 -1
- package/dist/owletto/dist/assets/{activity-route-view-rVdTeVXN.js → activity-route-view-BvtAoGVt.js} +1 -1
- package/dist/owletto/dist/assets/{agent-card-controls-JubkhcHt.js → agent-card-controls-bhTMPoVi.js} +1 -1
- package/dist/owletto/dist/assets/{agent-client-setup-list-Btcy4Cu1.js → agent-client-setup-list-BBbq_2B1.js} +1 -1
- package/dist/owletto/dist/assets/{agent-connect-pages-Chfqn8iL.js → agent-connect-pages-DkDlFVY5.js} +1 -1
- package/dist/owletto/dist/assets/{agent-editor-form-BrOkwfg8.js → agent-editor-form-DwHD9j1Y.js} +1 -1
- package/dist/owletto/dist/assets/{agent-guardrails-route-CHM7JbIl.js → agent-guardrails-route-0PsTrqMC.js} +1 -1
- package/dist/owletto/dist/assets/{agent-loading-shells-DsiGx1fn.js → agent-loading-shells-BQLjzMPy.js} +1 -1
- package/dist/owletto/dist/assets/{agent-permissions-matrix-L_gFvSu1.js → agent-permissions-matrix-B-Q5rmuB.js} +1 -1
- package/dist/owletto/dist/assets/{agent-skill-context-D7tOJ8Pb.js → agent-skill-context-s42Q4Wjo.js} +1 -1
- package/dist/owletto/dist/assets/{agent-skills-route-AylS-B9v.js → agent-skills-route-Cwq1QrhW.js} +1 -1
- package/dist/owletto/dist/assets/{agent-subpage-shell-B7tCQ9zd.js → agent-subpage-shell-DtzoRy6N.js} +1 -1
- package/dist/owletto/dist/assets/{agent-thread-DOYh7WLW.js → agent-thread-D7AGGjRV.js} +1 -1
- package/dist/owletto/dist/assets/agents-BqCKU4CT.js +1 -0
- package/dist/owletto/dist/assets/{agents-workbench-DOwn78eL.js → agents-workbench-Cl7FO7b3.js} +1 -1
- package/dist/owletto/dist/assets/{app._appId-fJ_RRn1Z.js → app._appId-CqYz3AOO.js} +1 -1
- package/dist/owletto/dist/assets/{automation-detail-content-CMprQht5.js → automation-detail-content-CKSywvzE.js} +1 -1
- package/dist/owletto/dist/assets/automations-BqCKU4CT.js +1 -0
- package/dist/owletto/dist/assets/{calendar-BbD1N97u.js → calendar-CHXehtu0.js} +1 -1
- package/dist/owletto/dist/assets/{callback-PELM84Lh.js → callback-DZ3YyXeV.js} +1 -1
- package/dist/owletto/dist/assets/{card-DpLjEqIc.js → card-4Ull9W6d.js} +1 -1
- package/dist/owletto/dist/assets/{claim-BLLvLOBM.js → claim-BGLCPLXq.js} +1 -1
- package/dist/owletto/dist/assets/{clients-Bd8WpHSV.js → clients-C7ubnFsS.js} +1 -1
- package/dist/owletto/dist/assets/{code-editor-DGJQDoHD.js → code-editor-BHiWR94J.js} +1 -1
- package/dist/owletto/dist/assets/connect-BNatqg6j.js +1 -0
- package/dist/owletto/dist/assets/connect._clientId-BGG2IqiQ.js +1 -0
- package/dist/owletto/dist/assets/{connected._clientId-BYGmFRCF.js → connected._clientId-7RU89sVW.js} +1 -1
- package/dist/owletto/dist/assets/{connection-B0O8OZuK.js → connection-CTaUGXl6.js} +1 -1
- package/dist/owletto/dist/assets/{connection-feed-detail-DZjtoEfm.js → connection-feed-detail-B1xieiEh.js} +1 -1
- package/dist/owletto/dist/assets/{connector-provenance-D_g9gGXU.js → connector-provenance-DRdUEmQ1.js} +1 -1
- package/dist/owletto/dist/assets/{connectors-BiMMm_QQ.js → connectors-NBwCLuZg.js} +1 -1
- package/dist/owletto/dist/assets/{consent-CIzW-960.js → consent-fmhPPlpi.js} +1 -1
- package/dist/owletto/dist/assets/{core.esm-Ds4Nuq9d.js → core.esm-C-eNiUAl.js} +1 -1
- package/dist/owletto/dist/assets/{create-BvCaqhwK.js → create-8bBbQJGY.js} +1 -1
- package/dist/owletto/dist/assets/create-Cl6cfNAp.js +1 -0
- package/dist/owletto/dist/assets/create-DrVso8O7.js +1 -0
- package/dist/owletto/dist/assets/create-automation-form-De8J-JD5.js +2 -0
- package/dist/owletto/dist/assets/{create._connectorKey--qDi1h6S.js → create._connectorKey-CHAotlsF.js} +1 -1
- package/dist/owletto/dist/assets/{cronstrue-h8_zIyZD.js → cronstrue-C5yTgk5z.js} +1 -1
- package/dist/owletto/dist/assets/deployments-C7M3fV5K.js +1 -0
- package/dist/owletto/dist/assets/{deployments-ICDss7yS.js → deployments-D1gbQwsy.js} +1 -1
- package/dist/owletto/dist/assets/{deployments-body-DulCUAMt.js → deployments-body-DycIGlnL.js} +1 -1
- package/dist/owletto/dist/assets/{device-kTL2l_cz.js → device-DyPnQkhO.js} +1 -1
- package/dist/owletto/dist/assets/{device-pin-tombstone-BmD4pv_e.js → device-pin-tombstone-CwJitllC.js} +1 -1
- package/dist/owletto/dist/assets/{device-rows-BqudjhFu.js → device-rows-BBhW1C7Y.js} +1 -1
- package/dist/owletto/dist/assets/{device._deviceId-CsLJJ6jv.js → device._deviceId-XswfXHOc.js} +1 -1
- package/dist/owletto/dist/assets/{entity-options-ErxYvMDH.js → entity-options-utGBmFX0.js} +1 -1
- package/dist/owletto/dist/assets/{entity-page-CYRAwUGO.js → entity-page-BxwuqqWk.js} +1 -1
- package/dist/owletto/dist/assets/{entity-type-page-BlAizGlz.js → entity-type-page-BrWqk6so.js} +1 -1
- package/dist/owletto/dist/assets/{event-page-DTXPxc-E.js → event-page-LIm4EDmJ.js} +1 -1
- package/dist/owletto/dist/assets/{events-feed-L3c-LLiJ.js → events-feed-C4L8mQV7.js} +1 -1
- package/dist/owletto/dist/assets/{full-page-spinner-BxcYpJXx.js → full-page-spinner-DsU-Cb3L.js} +1 -1
- package/dist/owletto/dist/assets/guardrails-CGFWCfbQ.js +1 -0
- package/dist/owletto/dist/assets/identity-uPYpPogR.js +1 -0
- package/dist/owletto/dist/assets/{index-13rywWam.js → index-1YrrvVJ4.js} +1 -1
- package/dist/owletto/dist/assets/index-BKMafTe4.js +1 -0
- package/dist/owletto/dist/assets/index-BsL1-C2-.js +1 -0
- package/dist/owletto/dist/assets/index-C58oW727.js +1 -0
- package/dist/owletto/dist/assets/{index--lEHrFE4.js → index-CQ4s6nzy.js} +1 -1
- package/dist/owletto/dist/assets/{index-DAv5S2aK.js → index-CpWKAAGX.js} +1 -1
- package/dist/owletto/dist/assets/{index-QcHQZI87.js → index-D2dcENg2.js} +1 -1
- package/dist/owletto/dist/assets/{index-CheCJomo.js → index-DCK0KhMM.js} +1 -1
- package/dist/owletto/dist/assets/{index-BRvT0VV9.js → index-DXqiRON3.js} +1 -1
- package/dist/owletto/dist/assets/index-DgEc5IvT.js +1 -0
- package/dist/owletto/dist/assets/{index-DdGjY1Hb.js → index-DtRfQcRH.js} +1530 -1530
- package/dist/owletto/dist/assets/index-DvhM9tuI.js +1 -0
- package/dist/owletto/dist/assets/{index-CFkj9iR_.js → index-DwtfHCHB.js} +1 -1
- package/dist/owletto/dist/assets/index-DyYFZjh-.js +1 -0
- package/dist/owletto/dist/assets/{index-B_-MLsof.js → index-nOYvNROJ.js} +1 -1
- package/dist/owletto/dist/assets/index-oDoJENMF.js +1 -0
- package/dist/owletto/dist/assets/index-rPdUEOa3.js +1 -0
- package/dist/owletto/dist/assets/{json-diff-BV2STDGj.js → json-diff-DYeX-xLk.js} +1 -1
- package/dist/owletto/dist/assets/{list-skeleton-CT5n4ND_.js → list-skeleton-s4GPSJ8J.js} +1 -1
- package/dist/owletto/dist/assets/{login-DKsgABYt.js → login-Di5VF2F_.js} +1 -1
- package/dist/owletto/dist/assets/{logout-D_CP-emw.js → logout-BuaQGSnw.js} +1 -1
- package/dist/owletto/dist/assets/{member-scope-gate-BTgmlfFJ.js → member-scope-gate-CJqJZk7T.js} +1 -1
- package/dist/owletto/dist/assets/{memory-browse-page-FHaJC3ML.js → memory-browse-page-Bibfs2sK.js} +1 -1
- package/dist/owletto/dist/assets/{missing-view-Bve6pJP-.js → missing-view-CD4DOaG8.js} +1 -1
- package/dist/owletto/dist/assets/{model-selector-BLCEahny.js → model-selector-XC5CI2Et.js} +1 -1
- package/dist/owletto/dist/assets/models--8mTFOLz.js +1 -0
- package/dist/owletto/dist/assets/{new-CirOK0Sw.js → new-BzkA1sq2.js} +1 -1
- package/dist/owletto/dist/assets/{new-DzapH2sV.js → new-C3f0BShb.js} +1 -1
- package/dist/owletto/dist/assets/{new-BAIGSdfp.js → new-DA5LF6iB.js} +1 -1
- package/dist/owletto/dist/assets/{oauth-workspace-access-BF7jaswv.js → oauth-workspace-access-D6epOq0R.js} +1 -1
- package/dist/owletto/dist/assets/{organization-D9RPsWG-.js → organization-DOtBRqDQ.js} +1 -1
- package/dist/owletto/dist/assets/{permissions-BlRONw-u.js → permissions-D8uJHINS.js} +1 -1
- package/dist/owletto/dist/assets/{proposal-review-shell-uskeFIUr.js → proposal-review-shell-C3K-JXjb.js} +1 -1
- package/dist/owletto/dist/assets/{recent-CmJ4Is6V.js → recent-CFcWceBl.js} +1 -1
- package/dist/owletto/dist/assets/{renderer-Dyf4t8kR.js → renderer-1nRJFMGx.js} +1 -1
- package/dist/owletto/dist/assets/{reset-password-BVIeE1Zm.js → reset-password-9RTWhBEb.js} +1 -1
- package/dist/owletto/dist/assets/{runs-CzBeUzlQ.js → runs-_yVh6PPB.js} +1 -1
- package/dist/owletto/dist/assets/{runs-panel-D7l1uLGm.js → runs-panel-B2852xus.js} +1 -1
- package/dist/owletto/dist/assets/{runs-table-dATyiBg2.js → runs-table--dnFQatY.js} +1 -1
- package/dist/owletto/dist/assets/{schema-value-normalization-DgMkyVVE.js → schema-value-normalization-BspxVEGy.js} +1 -1
- package/dist/owletto/dist/assets/{settings-Co1wj_m6.js → settings-9lDASETT.js} +1 -1
- package/dist/owletto/dist/assets/settings-DQo_ZS2P.js +1 -0
- package/dist/owletto/dist/assets/skills-a5xQ4RE9.js +1 -0
- package/dist/owletto/dist/assets/{switch-DDkPrV3p.js → switch-CxDXvPGE.js} +1 -1
- package/dist/owletto/dist/assets/{use-applied-views-DELwQQh7.js → use-applied-views-DvMT3wap.js} +1 -1
- package/dist/owletto/dist/assets/{use-mention-search-CGA3AaKm.js → use-mention-search-CeTEE3oE.js} +1 -1
- package/dist/owletto/dist/assets/{view-frame-DDr-Xtet.js → view-frame-HoBawpT2.js} +1 -1
- package/dist/owletto/dist/index.html +1 -1
- package/dist/providers.json +0 -1
- package/dist/server-main.bundle.mjs +2365 -3969
- package/npm-shrinkwrap.json +41 -41
- package/package.json +1 -1
- package/vendor/connector-sdk/dist/connector-types.d.ts +0 -2
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/dist/contracts/tools/manage-auth-profiles.d.ts +14 -0
- package/vendor/core/dist/contracts/tools/manage-auth-profiles.js +12 -1
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +0 -10
- package/vendor/core/dist/contracts/tools/manage-automations.js +0 -33
- package/vendor/core/dist/contracts/tools/manage-classifiers.d.ts +4 -34
- package/vendor/core/dist/contracts/tools/manage-classifiers.js +13 -44
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +0 -9
- package/vendor/core/dist/contracts/tools/manage-entity.js +0 -6
- package/vendor/core/dist/contracts/tools/view-attach.d.ts +20 -0
- package/vendor/core/dist/contracts/tools/view-attach.js +45 -0
- package/vendor/core/dist/contracts/worker/protocol.d.ts +17 -0
- package/vendor/core/dist/contracts/worker/protocol.js +12 -1
- package/vendor/core/dist/index.d.ts +1 -1
- package/vendor/core/dist/provider-config-types.d.ts +0 -9
- package/vendor/core/dist/sdk-compat.d.ts +1 -1
- package/vendor/core/package.json +6 -1
- package/vendor/views/dist/api.d.ts +9 -4
- package/vendor/views/dist/api.js +6 -2
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-CwFknmeA.js +0 -1
- package/dist/owletto/dist/assets/_agentId-Cr57JKYx.js +0 -1
- package/dist/owletto/dist/assets/_name-BP7OlVxL.js +0 -1
- package/dist/owletto/dist/assets/_shape-BqV8tSfw.js +0 -1
- package/dist/owletto/dist/assets/_skillKey-2xTjhL_C.js +0 -1
- package/dist/owletto/dist/assets/_viewKey-8ePnWEg-.js +0 -1
- package/dist/owletto/dist/assets/_viewKey-D8rjUFLV.js +0 -1
- package/dist/owletto/dist/assets/_viewKey-DhVOkzYd.js +0 -1
- package/dist/owletto/dist/assets/agents-0ncYwbz6.js +0 -1
- package/dist/owletto/dist/assets/automations-0ncYwbz6.js +0 -1
- package/dist/owletto/dist/assets/connect-Cx49f4J0.js +0 -1
- package/dist/owletto/dist/assets/connect._clientId-BDFBqKSA.js +0 -1
- package/dist/owletto/dist/assets/create--fsxroj2.js +0 -1
- package/dist/owletto/dist/assets/create-BqL-ahEf.js +0 -1
- package/dist/owletto/dist/assets/create-automation-form-DN2w080o.js +0 -2
- package/dist/owletto/dist/assets/deployments-BROg1Te8.js +0 -1
- package/dist/owletto/dist/assets/guardrails-Dh4adTXY.js +0 -1
- package/dist/owletto/dist/assets/identity-B8lKn0je.js +0 -1
- package/dist/owletto/dist/assets/index-BUp24ZJr.js +0 -1
- package/dist/owletto/dist/assets/index-Bq-q4Y7E.js +0 -1
- package/dist/owletto/dist/assets/index-CgBgOElA.js +0 -1
- package/dist/owletto/dist/assets/index-CpiW66xK.js +0 -1
- package/dist/owletto/dist/assets/index-DBi2Xr3i.js +0 -1
- package/dist/owletto/dist/assets/index-DHOha5OJ.js +0 -1
- package/dist/owletto/dist/assets/index-Dkyl7l6E.js +0 -1
- package/dist/owletto/dist/assets/index-kq4537-S.js +0 -1
- package/dist/owletto/dist/assets/models-C4N7LQAW.js +0 -1
- package/dist/owletto/dist/assets/settings-BK1GHmzb.js +0 -1
- package/dist/owletto/dist/assets/skills-DF53JcYt.js +0 -1
package/dist/owletto/dist/assets/{activity-route-view-rVdTeVXN.js → activity-route-view-BvtAoGVt.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a4 as me,O as Ft,bz as Be,bf as Gn,r as h,ci as Un,j as e,bR as qe,L as Y,B as U,Z as Te,al as O,cj as Pt,ck as Mt,cl as $t,bL as Rt,cm as ze,cn as Ot,co as Wn,cp as Hn,ba as Qn,a5 as st,cq as Yn,cr as Xn,cs as Zn,ct as qn,cu as Jn,J as es,cv as he,cw as q,am as Kt,cx as ts,ah as _e,a3 as Vt,cy as Bt,cz as ns,bV as Ce,cA as zt,cB as ss,aR as Ie,cC as Gt,P as Ut,cD as os,cE as as,cF as le,cf as rs,cG as is,cH as cs,cI as ls,bv as ds,n as us,cJ as ms,cK as He,cL as fs,cM as ye,aH as Ae,cN as Le,cO as ps,cP as hs,cQ as Wt,cR as xs,cS as gs,aK as vs,cT as ys,ad as bs,b$ as Qe,cU as Ht,S as Qt,cV as js,cW as Yt,cX as Xt,bX as ws,bY as Ns,bZ as Ss,b_ as ks,cY as Cs,aV as Zt,v as _s,w as qt,cZ as Jt,c_ as Ts,c$ as wt,d0 as Is,d1 as As,d2 as Ls,a as Ds,d3 as Es,d4 as Fs,d5 as en,d6 as Ps,d7 as Ms,d8 as $s,d9 as Rs,da as Os,db as Ks,c2 as Vs,dc as Bs,dd as tn,bq as Oe,I as Nt,b7 as zs,de as Gs,df as Us,dg as Ws,dh as Hs,di as Qs,dj as Ys,p as Xs,q as Zs,dk as qs,c1 as St,dl as Js,dm as eo,a_ as to,dn as no,bO as so,dp as oo,aY as ao}from"./index-DdGjY1Hb.js";import{A as ro}from"./device-automation-BIjs7DZJ.js";import{n as io}from"./agent-thread-storage-U6htL3ad.js";import{s as co}from"./pending-seed-CPbfgnLX.js";import{u as lo}from"./clients-Bd8WpHSV.js";import{g as uo}from"./client-rows-EJSKR6z1.js";import{c as Je}from"./connection-label-BobuYiAG.js";import{E as mo}from"./events-feed-L3c-LLiJ.js";import{C as fo}from"./calendar-BbD1N97u.js";import{L as po,u as ho}from"./renderer-Dyf4t8kR.js";import{E as xo}from"./agent-loading-shells-DsiGx1fn.js";import{M as go}from"./member-scope-gate-BTgmlfFJ.js";function Ke(t){return t.kind==="managed"?`managed:${t.agentId}`:`device:${t.executionTarget.deviceWorkerId}:${t.executionTarget.agentKind}`}function vo({ownerSlug:t}){const n=me(),o=Ft(),{data:s=[]}=Be(),{data:a=[]}=Gn(),[r,d]=h.useState(!1),[c,u]=h.useState(null),[i,m]=h.useState(""),[f,p]=h.useState(!1),v=h.useRef(null);h.useEffect(()=>{o&&r&&v.current?.focus()},[o,r]);const g=s.find(j=>j.system)??s[0]??null,x=h.useMemo(()=>{const j=s.map(T=>({kind:"managed",agentId:T.agentId,label:T.name})),L=g?a.filter(T=>T.online&&T.organization_slug===t&&T.capabilities.includes("automations.execute")&&(T.agent_kinds?.length??0)>0).flatMap(T=>(T.agent_kinds??[]).map(w=>({kind:"device",agentId:g.agentId,label:`${Un(T)} · ${ro[w]??w}`,executionTarget:{kind:"device",deviceWorkerId:T.id,agentKind:w}}))):[];return{managed:j,deviceTargets:L}},[s,g,a,t]),y=[...x.managed,...x.deviceTargets].find(j=>Ke(j)===c)??x.managed.find(j=>j.agentId===g?.agentId)??x.managed[0]??x.deviceTargets[0]??null,S=j=>{u(Ke(j)),p(!1)},C=()=>{const j=i.trim();if(!j||!y)return;const L=io();co(L,j,y.kind==="device"?y.executionTarget:void 0),m(""),n(Hn(t,y.agentId,L))};if(o&&!r){const j="flex h-14 w-14 items-center justify-center rounded-full border bg-background text-foreground transition-colors hover:bg-accent/60";return e.jsx("div",{className:"sticky bottom-0 z-20 mt-auto flex justify-center bg-gradient-to-t from-background via-background to-transparent pt-4 pb-1",children:y?e.jsx("button",{type:"button","aria-label":"Ask Lobu",className:j,onClick:()=>d(!0),children:e.jsx(qe,{className:"h-7 w-7"})}):e.jsx(Y,{to:"/$owner/agents",params:{owner:t},"aria-label":"Create an agent to start chatting",className:j,children:e.jsx(qe,{className:"h-7 w-7"})})})}return e.jsx("div",{className:"sticky bottom-0 z-20 mt-auto bg-gradient-to-t from-background via-background to-transparent pt-5",children:e.jsxs("div",{className:"relative rounded-2xl border bg-background transition-colors focus-within:ring-1 focus-within:ring-ring",children:[o?e.jsx(U,{type:"button",variant:"ghost",size:"icon","aria-label":"Collapse composer",className:"absolute top-1.5 right-1.5 size-7 shrink-0 text-muted-foreground hover:text-foreground",onClick:()=>d(!1),children:e.jsx(Te,{className:"h-4 w-4"})}):null,y?e.jsx("textarea",{value:i,onChange:j=>m(j.target.value),onKeyDown:j=>{j.key==="Enter"&&!j.shiftKey&&(j.preventDefault(),C())},placeholder:"Ask Lobu…",rows:2,ref:v,className:O("max-h-40 min-h-16 w-full resize-none bg-transparent px-4 pt-3 text-sm outline-none placeholder:text-muted-foreground",o&&"pr-10")}):e.jsx(Y,{to:"/$owner/agents",params:{owner:t},className:O("block min-h-16 px-4 pt-3 text-sm text-muted-foreground hover:text-foreground",o&&"pr-10"),children:"Create an agent to start chatting"}),e.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 pb-2",children:[e.jsxs(Pt,{open:f,onOpenChange:p,children:[e.jsx(Mt,{asChild:!0,children:e.jsxs(U,{type:"button",variant:"ghost",size:"sm",disabled:!y,className:"h-8 max-w-[70%] gap-1.5 px-2 text-xs text-muted-foreground",children:[y?.kind==="device"?e.jsx($t,{className:"h-3.5 w-3.5"}):e.jsx(Rt,{className:"h-3.5 w-3.5"}),e.jsxs("span",{className:"truncate",children:["Run with: ",y?.label??"No agent"]}),e.jsx(ze,{className:"h-3.5 w-3.5 shrink-0"})]})}),e.jsxs(Ot,{align:"start",className:"max-h-80 w-72 overflow-y-auto p-1.5",children:[e.jsx("p",{className:"px-2 py-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Lobu agents"}),x.managed.map(j=>e.jsx(kt,{target:j,selected:y,onSelect:S},j.agentId)),x.deviceTargets.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"my-1 h-px bg-border"}),e.jsx("p",{className:"px-2 py-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Devices"}),x.deviceTargets.map(j=>e.jsx(kt,{target:j,selected:y,onSelect:S},`${j.executionTarget.deviceWorkerId}:${j.executionTarget.agentKind}`))]}):null]})]}),e.jsxs(U,{type:"button",size:"icon",className:"h-8 w-8 rounded-full",disabled:!y||!i.trim(),onClick:C,children:[e.jsx(Wn,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Send message"})]})]})]})})}function kt({target:t,selected:n,onSelect:o}){const s=n?Ke(n)===Ke(t):!1;return e.jsxs("button",{type:"button",className:O("flex w-full items-center gap-2 rounded-md px-2 py-2 text-left text-sm hover:bg-accent",s&&"bg-accent"),onClick:()=>o(t),children:[t.kind==="device"?e.jsx($t,{className:"h-4 w-4 shrink-0"}):e.jsx(Rt,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:t.label})]})}const ot=h.createContext(null);function yo({organizationId:t,isWorkspaceLoading:n,children:o}){const{data:s=[],isLoading:a}=Qn(t);return e.jsx(ot.Provider,{value:{groups:s,isLoading:!!n||a},children:o})}function bo(){const t=h.useContext(ot);if(!t)throw new Error("useMemoryConnectorGroups must be used within MemoryConnectorGroupsProvider");return t}function jo(){return h.useContext(ot)}function wo(t){const{parse:n,serialize:o,filterKeys:s,clearClassifications:a=!0,merge:r}=t,d=me(),c=st(),u=h.useMemo(()=>{const f=Object.entries(c.search||{}).filter(v=>v[1]!==void 0&&v[1]!==null),p=new URLSearchParams(f);return n(p)},[c.search,n]),i=h.useCallback(f=>{const p=r?r(u,f):{...u,...f},v=o(p),g={};for(const[x,k]of Object.entries(c.search||{}))k!=null&&(g[x]=k);for(const x of s)delete g[x];if(a)for(const x of Object.keys(g))x.startsWith("clf_")&&delete g[x];for(const[x,k]of Object.entries(v))k!==void 0&&(g[x]=k);d({to:c.pathname,search:g,replace:!0})},[u,o,s,a,r,d,c]),m=h.useCallback(()=>{const f={};for(const[p,v]of Object.entries(c.search||{}))v!=null&&(s.includes(p)||a&&p.startsWith("clf_")||(f[p]=v));d({to:c.pathname,search:f,replace:!0})},[d,c.pathname,c.search,s,a]);return{filters:u,updateFilters:i,clearFilters:m}}function nn(t){const{slug:n}=Yn();return Xn({queryKey:["schedules",n,t],queryFn:async()=>((await Zn("manage_schedules",{action:"list",action_type:"wake_agent",include_paused:!0})).schedules??[]).filter(s=>s.action_args?.agent_id===t),enabled:!!n&&!!t,staleTime:3e4})}function No(t,n){if(t.length===0)return"";const o=t.map(s=>{const a=n.find(r=>r.id===s);return a?Je(a):null}).filter(s=>s!=null);return o.length===0?`Filtered by connection${t.length>1?"s":""} #${t.join(", #")}`:o.length===1?`From ${o[0]}`:`From ${o.join(", ")}`}function So(t,n){if(t.length===0)return"";const s=t.map(a=>{const r=n.find(u=>u.id===a);if(!r)return null;const d=r.connection_name?.trim()||r.connector_name||r.connector_key||`connection #${r.connection_id}`,c=r.display_name?.trim()||r.feed_key||`feed #${r.id}`;return`${d} · ${c}`}).filter(a=>a!=null);return s.length===0?`Filtered by feed${t.length>1?"s":""} #${t.join(", #")}`:s.length===1?`From ${s[0]}`:`From ${s.join("; ")}`}function ko(t,n){return{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:t,connectorKey:n.connector_key,connectionId:String(n.connection_id)},search:{feedId:n.id}}}function Co(t,n){return{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:t,connectorKey:n.connector_key,connectionId:String(n.id)}}}function _o(t,n){return{to:"/$owner/agents/connected/$clientId",params:{owner:t,clientId:n}}}function Ct(t,n){return{to:"/$owner/events",params:{owner:t},search:{agent:n}}}function To(t,n){return{to:"/$owner/automations/$automationId",params:{owner:t,automationId:n}}}function Io(t,n,o){return{to:"/$owner/events",params:{owner:t},search:{agent:n,schedule:o}}}function Ao({text:t,sourceLink:n,details:o,onClear:s}){return e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-border bg-muted/50 px-3 py-2 text-sm",children:[e.jsx(Jn,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),n?e.jsxs(Y,{to:n.to,params:n.params,search:n.search,className:"inline-flex min-w-0 items-center gap-1.5 font-medium text-foreground hover:underline",children:[e.jsx("span",{className:"truncate",children:t}),e.jsx(es,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]}):e.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:t}),o,e.jsx(U,{variant:"ghost",size:"icon",className:"ml-auto h-5 w-5 shrink-0",onClick:s,"aria-label":"Clear filter",children:e.jsx(Te,{className:"h-3.5 w-3.5"})})]})}function Lo({ownerSlug:t,clientIds:n,linkedUser:o,linkedUserEntitySlug:s}){const a=t&&s?qn(t,[{entity_type:"$member",slug:s}]):null;return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:n.length===1?"Client ID":"Client IDs"}),n.map(r=>e.jsx("code",{className:"break-all text-foreground",children:r},r))]}),o?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:["Granted by",a?e.jsx(Y,{to:a,className:"font-medium text-foreground hover:underline",children:o}):e.jsx("span",{className:"font-medium text-foreground",children:o})]}):null]})}function ke(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function $e(t,n,o){const s=new Set;for(const[a,r]of Object.entries(t.feeds_schema??{})){if(o&&!o.has(a))continue;const d=ke(ke(r)?.eventKinds);if(d)for(const[c,u]of Object.entries(d)){if(!n){s.add(c);continue}const i=ke(u)?.attributions;Array.isArray(i)&&i.some(m=>{const f=ke(ke(m)?.target);return typeof f?.entityType=="string"&&n.has(f.entityType)})&&s.add(c)}}return s}function Do({connectors:t,entityTypes:n,selectedPlatforms:o=[],selectedFeeds:s=[],selectedEntityTypes:a=[]}){const r=new Set,d=new Set(o),c=new Set(a),u=new Map;for(const i of s){const m=u.get(i.connectorKey)??new Set;m.add(i.feedKey),u.set(i.connectorKey,m)}if(u.size>0)for(const i of t){const m=u.get(i.key);if(m)for(const f of $e(i,void 0,m))r.add(f)}else if(d.size>0){for(const i of t)if(d.has(i.key))for(const m of $e(i))r.add(m)}else if(c.size>0){for(const i of n)if(c.has(i.slug))for(const m of Object.keys(i.event_kinds??{}))r.add(m);for(const i of t)for(const m of $e(i,c))r.add(m)}else{for(const i of n)for(const m of Object.keys(i.event_kinds??{}))r.add(m);for(const i of t)for(const m of $e(i))r.add(m)}return[...r].sort((i,m)=>i.localeCompare(m))}function Eo({connectors:t,selectedKeys:n,onToggle:o,label:s="Connectors",searchPlaceholder:a="Search connectors...",emptyText:r="No connectors found"}){return e.jsx(he,{contentClassName:"w-80",searchPlaceholder:a,emptyText:r,trigger:()=>e.jsxs(U,{variant:"outline",className:"h-9",children:[s,n.length>0&&e.jsx(_e,{variant:"secondary",className:"ml-2 h-5 px-1.5",children:n.length})]}),children:()=>t.map(d=>e.jsxs(q,{onSelect:()=>o(d.key),children:[e.jsx(Kt,{checked:n.includes(d.key),className:"mr-3"}),e.jsx(ts,{connector:d,className:"flex-1"}),typeof d.count=="number"&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:d.count.toLocaleString()})]},d.key))})}function Fo(t){const{orgContext:n}=Vt(),{data:o=[],isLoading:s}=Bt(n);return{visible:h.useMemo(()=>o.filter(r=>!ns(r)&&(!r.organization_slug||r.organization_slug===t)),[o,t]),isTypesLoading:s}}function be(){return st().search??{}}function Po({ownerSlug:t,typeScope:n,agentScope:o,connectionScope:s,feedScope:a,visibility:r="all"}){const d=be(),c=typeof d.type=="string"&&d.type.trim()?d.type.trim():void 0,u=n??(c?Ce(c):void 0),i=o??zt(d),m=s??ss(d),f=a??(typeof d.feed_ids=="string"?d.feed_ids:typeof d.feed_ids=="number"?String(d.feed_ids):void 0),p=k=>r==="all"||(r==="active"?k:!k),v=p(!!u),g=p(!!i),x=p(!!(m||f));return!v&&!g&&!x?null:e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[v?e.jsx(Mo,{ownerSlug:t,typeScope:u}):null,g?e.jsx($o,{ownerSlug:t,agentScope:i}):null,x?e.jsx(Ro,{ownerSlug:t,connectionScope:m,feedScope:f}):null]})}const De=h.forwardRef(function({open:n,label:o,value:s,disabled:a,disabledReason:r,...d},c){const u=e.jsxs(U,{ref:c,variant:"outline",disabled:a,"aria-expanded":n,className:"h-9 gap-1.5 rounded-md bg-muted px-3 py-2 text-sm font-normal",...d,children:[e.jsx("span",{className:"text-muted-foreground",children:o}),s?e.jsx("span",{className:"max-w-[10rem] truncate font-medium",children:s}):e.jsx("span",{className:"text-muted-foreground",children:"Any"}),e.jsx(ze,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]});return a&&r?e.jsxs(is,{children:[e.jsx(cs,{asChild:!0,children:e.jsx("span",{className:"inline-flex",children:u})}),e.jsx(ls,{children:r})]}):u});function Mo({ownerSlug:t,typeScope:n}){const o=me(),s=be(),{visible:a}=Fo(t),r=a.find(u=>u.slug===n),d=u=>{o(le(t,s,{entity:void 0,create:void 0,type:u}))},c=()=>{o(le(t,s,{type:void 0}))};return e.jsx(he,{contentClassName:"w-72",searchPlaceholder:"Search types...",emptyText:"No entity types",trigger:u=>e.jsx(De,{open:u,label:"Type",value:r?.name}),children:u=>e.jsxs(e.Fragment,{children:[n?e.jsx(q,{onSelect:()=>{c(),u()},className:"text-muted-foreground",children:"Clear type"}):null,a.map(i=>e.jsxs(q,{onSelect:()=>{d(i.slug),u()},className:"group gap-2",children:[e.jsx(Ie,{className:Ee(i.slug===n)}),e.jsx(Gt,{icon:i.icon,className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:i.name}),typeof i.entity_count=="number"?e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:i.entity_count}):null,e.jsx(at,{to:"/$owner/entity-types/$slug",params:{owner:t,slug:i.slug},label:i.name})]},i.id)),e.jsxs(q,{onSelect:()=>{o(os(t)),u()},className:"text-muted-foreground",children:[e.jsx(Ut,{className:"h-4 w-4 shrink-0"}),"Add entity type"]})]})})}function $o({ownerSlug:t,agentScope:n}){const o=me(),s=be(),{data:a=[]}=Be(),r=h.useMemo(()=>[...a].sort((i,m)=>i.name.localeCompare(m.name)),[a]),d=r.find(i=>i.agentId===n),c=i=>{o(le(t,s,_t(s,i)))},u=()=>{o(le(t,s,_t(s,void 0)))};return e.jsx(he,{contentClassName:"w-72",searchPlaceholder:"Search agents...",emptyText:"No agents",trigger:i=>e.jsx(De,{open:i,label:"Agent",value:d?.name}),children:i=>e.jsxs(e.Fragment,{children:[n?e.jsx(q,{onSelect:()=>{u(),i()},className:"text-muted-foreground",children:"Clear agent"}):null,r.map(m=>e.jsxs(q,{onSelect:()=>{c(m.agentId),i()},className:"gap-2",children:[e.jsx(Ie,{className:Ee(m.agentId===n)}),e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-muted text-[10px] font-medium",children:m.name.trim().charAt(0).toUpperCase()||"?"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:m.name})]},m.agentId))]})})}function _t(t,n){const o={agent:n,automation:void 0,schedule:void 0,platforms:void 0};return t.schedule!=null&&(o.run_ids=void 0),typeof t.platforms=="string"&&t.platforms.trim().length>0&&(o.connection_ids=void 0,o.feed_ids=void 0),o}function Ro({ownerSlug:t,connectionScope:n,feedScope:o}){const{groups:s}=bo(),a=h.useMemo(()=>new Set((n??"").split(",").map(u=>u.trim()).filter(Boolean)),[n]),r=as(s,a),d=s.find(u=>u.connector_key===r),c=a.size===1?Number([...a][0]):void 0;return e.jsxs(e.Fragment,{children:[e.jsx(Oo,{ownerSlug:t,groups:s,scopedGroup:d}),d?e.jsx(Ko,{ownerSlug:t,group:d,selectedIds:a}):null,c?e.jsx(Vo,{ownerSlug:t,connectionId:c,feedScope:o}):null]})}function Oo({ownerSlug:t,groups:n,scopedGroup:o}){const s=me(),a=be(),r=u=>{const i=u.connections.map(m=>String(m.id)).join(",");i&&s(le(t,a,{connection_ids:i,feed_ids:void 0}))},d=()=>{s(le(t,a,{connection_ids:void 0,feed_ids:void 0}))},c=o?.connector_name??o?.connector_key;return e.jsx(he,{contentClassName:"w-72",searchPlaceholder:"Search connectors...",emptyText:"No connectors",trigger:u=>e.jsx(De,{open:u,label:"Connector",value:c}),children:u=>e.jsxs(e.Fragment,{children:[o?e.jsx(q,{onSelect:()=>{d(),u()},className:"text-muted-foreground",children:"Clear connector"}):null,n.map(i=>{const m=i.connector_name??i.connector_key;return e.jsxs(q,{disabled:i.connections.length===0,onSelect:()=>{r(i),u()},className:"group gap-2",children:[e.jsx(Ie,{className:Ee(i.connector_key===o?.connector_key)}),e.jsx(ds,{plain:!0,name:m,faviconDomain:i.favicon_domain,className:"h-5 w-5 shrink-0 rounded-md text-[10px]"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:m}),i.connection_count>0?e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:i.connection_count}):null,e.jsx(at,{to:"/$owner/connectors/$connectorKey",params:{owner:t,connectorKey:i.connector_key},label:m})]},i.connector_key)}),e.jsx(Bo,{to:"/$owner/connectors/create",params:{owner:t},label:"Add connector",onSelect:u})]})})}function Ko({ownerSlug:t,group:n,selectedIds:o}){const s=me(),a=be(),r=o.size===1?n.connections.find(u=>o.has(String(u.id))):void 0,d=u=>{s(le(t,a,{connection_ids:String(u),feed_ids:void 0}))},c=r?Je({display_name:r.display_name,connector_name:n.connector_name,connector_key:n.connector_key}):"All connections";return e.jsx(he,{contentClassName:"w-72",searchPlaceholder:"Search connections...",emptyText:"No connections",trigger:u=>e.jsx(De,{open:u,label:"Connection",value:c}),children:u=>n.connections.map(i=>{const m=Je({display_name:i.display_name,connector_name:n.connector_name,connector_key:n.connector_key});return e.jsxs(q,{onSelect:()=>{d(i.id),u()},className:"group gap-2",children:[e.jsx(Ie,{className:Ee(o.has(String(i.id)))}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:m}),i.feed_count>0?e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:i.feed_count}):null,e.jsx(at,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:t,connectorKey:n.connector_key,connectionId:String(i.id)},label:m})]},i.id)})})}function Vo({ownerSlug:t,connectionId:n,feedScope:o}){const s=me(),a=be(),{data:r=[],isLoading:d}=us(n),c=h.useMemo(()=>new Set((o??"").split(",").map(f=>f.trim()).filter(Boolean)),[o]),u=c.size===1?r.find(f=>c.has(String(f.id))):void 0,i=f=>{s(le(t,a,{connection_ids:String(n),feed_ids:String(f.id)}))},m=()=>{s(le(t,a,{connection_ids:String(n),feed_ids:void 0}))};return e.jsx(he,{contentClassName:"w-72",searchPlaceholder:"Search feeds...",emptyText:d?"Loading feeds...":"No feeds",trigger:f=>e.jsx(De,{open:f,label:"Feed",value:u?Tt(u):void 0}),children:f=>e.jsxs(e.Fragment,{children:[c.size>0?e.jsx(q,{onSelect:()=>{m(),f()},className:"text-muted-foreground",children:"Clear feed"}):null,r.map(p=>e.jsxs(q,{onSelect:()=>{i(p),f()},className:"gap-2",children:[e.jsx(Ie,{className:Ee(c.has(String(p.id)))}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:Tt(p)})]},p.id))]})})}function Tt(t){return t.display_name?.trim()||t.feed_key}function at({to:t,params:n,label:o}){return e.jsx(Y,{to:t,params:n,onClick:s=>s.stopPropagation(),onPointerDown:s=>s.stopPropagation(),className:"shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity hover:text-foreground group-hover:opacity-100 focus-visible:opacity-100","aria-label":`Manage ${o}`,children:e.jsx(rs,{className:"h-3.5 w-3.5"})})}function Bo({to:t,params:n,label:o,onSelect:s}){return e.jsx(q,{asChild:!0,onSelect:s,className:"text-muted-foreground",children:e.jsxs(Y,{to:t,params:n,className:"flex items-center gap-2",children:[e.jsx(Ut,{className:"h-4 w-4 shrink-0"}),o]})})}function Ee(t){return t?"h-4 w-4 shrink-0 opacity-100":"h-4 w-4 shrink-0 opacity-0"}function zo({value:t,onChange:n,onClear:o,placeholder:s="Pick a date range",className:a,align:r="start"}){const d=t?.from!=null,c=d&&o!=null;return e.jsxs("div",{className:O("relative grid gap-2",a),children:[e.jsxs(Pt,{children:[e.jsx(Mt,{asChild:!0,children:e.jsxs(U,{id:"date",variant:"outline",className:O("relative w-full justify-start rounded-md bg-muted px-3 text-left font-normal",!d&&"text-muted-foreground",c&&"pr-8"),children:[e.jsx(ms,{className:"mr-2 h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:t?.from?t.to?e.jsxs(e.Fragment,{children:[He(t.from,"LLL dd, y")," -"," ",He(t.to,"LLL dd, y")]}):He(t.from,"LLL dd, y"):s})]})}),e.jsx(Ot,{className:"w-auto p-0",align:r,children:e.jsx(fo,{initialFocus:!0,mode:"range",defaultMonth:t?.from,selected:t,onSelect:n,numberOfMonths:2})})]}),c&&e.jsx("button",{type:"button","aria-label":"Clear date range",onClick:o,className:"absolute right-2 top-1/2 z-10 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground transition-colors hover:text-foreground",children:e.jsx(Te,{className:"h-3.5 w-3.5"})})]})}var sn=["PageUp","PageDown"],on=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],an={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},je="Slider",[et,Go,Uo]=ps(je),[rt]=vs(je,[Uo]),[Wo,Fe]=rt(je),it=h.forwardRef((t,n)=>{const{name:o,min:s=0,max:a=100,step:r=1,orientation:d="horizontal",disabled:c=!1,minStepsBetweenThumbs:u=0,defaultValue:i=[s],value:m,onValueChange:f=()=>{},onValueCommit:p=()=>{},inverted:v=!1,form:g,...x}=t,k=h.useRef(new Set),y=h.useRef(0),S=h.useRef(!1),j=d==="horizontal"?Ho:Qo,[L=[],T]=fs({prop:m,defaultProp:i,onChange:E=>{[...k.current][y.current]?.focus({preventScroll:!0,focusVisible:S.current}),S.current=!1,f(E)}}),w=h.useRef(L);function W(E){const $=qo(L,E);J(E,$)}function ae(E){J(E,y.current)}function re(){const E=w.current[y.current];L[y.current]!==E&&p(L)}function J(E,$,{commit:H}={commit:!1}){const ie=na(r),B=sa(Math.round((E-s)/r)*r+s,ie),A=Wt(B,[s,a]);T((M=[])=>{const z=Xo(M,A,$);if(ta(z,u*r)){y.current=z.indexOf(A);const G=String(z)!==String(M);return G&&H&&p(z),G?z:M}else return M})}return e.jsx(Wo,{scope:t.__scopeSlider,name:o,disabled:c,min:s,max:a,valueIndexToChangeRef:y,thumbs:k.current,values:L,orientation:d,form:g,children:e.jsx(et.Provider,{scope:t.__scopeSlider,children:e.jsx(et.Slot,{scope:t.__scopeSlider,children:e.jsx(j,{"aria-disabled":c,"data-disabled":c?"":void 0,...x,ref:n,onPointerDown:ye(x.onPointerDown,()=>{c||(w.current=L,S.current=!1)}),min:s,max:a,inverted:v,onSlideStart:c?void 0:W,onSlideMove:c?void 0:ae,onSlideEnd:c?void 0:re,onHomeKeyDown:()=>{c||(S.current=!0,J(s,0,{commit:!0}))},onEndKeyDown:()=>{c||(S.current=!0,J(a,L.length-1,{commit:!0}))},onStepKeyDown:({event:E,direction:$})=>{if(!c){S.current=!0;const B=sn.includes(E.key)||E.shiftKey&&on.includes(E.key)?10:1,A=y.current,M=L[A],z=r*B*$;J(M+z,A,{commit:!0})}}})})})})});it.displayName=je;var[rn,cn]=rt(je,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Ho=h.forwardRef((t,n)=>{const{min:o,max:s,dir:a,inverted:r,onSlideStart:d,onSlideMove:c,onSlideEnd:u,onStepKeyDown:i,...m}=t,[f,p]=h.useState(null),v=Le(n,C=>p(C)),g=h.useRef(void 0),x=hs(a),k=x==="ltr",y=k&&!r||!k&&r;function S(C){const j=g.current||f.getBoundingClientRect(),L=[0,j.width],w=ct(L,y?[o,s]:[s,o]);return g.current=j,w(C-j.left)}return e.jsx(rn,{scope:t.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:e.jsx(ln,{dir:x,"data-orientation":"horizontal",...m,ref:v,style:{...m.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:C=>{const j=S(C.clientX);d?.(j)},onSlideMove:C=>{const j=S(C.clientX);c?.(j)},onSlideEnd:()=>{g.current=void 0,u?.()},onStepKeyDown:C=>{const L=an[y?"from-left":"from-right"].includes(C.key);i?.({event:C,direction:L?-1:1})}})})}),Qo=h.forwardRef((t,n)=>{const{min:o,max:s,inverted:a,onSlideStart:r,onSlideMove:d,onSlideEnd:c,onStepKeyDown:u,...i}=t,m=h.useRef(null),f=Le(n,m),p=h.useRef(void 0),v=!a;function g(x){const k=p.current||m.current.getBoundingClientRect(),y=[0,k.height],C=ct(y,v?[s,o]:[o,s]);return p.current=k,C(x-k.top)}return e.jsx(rn,{scope:t.__scopeSlider,startEdge:v?"bottom":"top",endEdge:v?"top":"bottom",size:"height",direction:v?1:-1,children:e.jsx(ln,{"data-orientation":"vertical",...i,ref:f,style:{...i.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:x=>{const k=g(x.clientY);r?.(k)},onSlideMove:x=>{const k=g(x.clientY);d?.(k)},onSlideEnd:()=>{p.current=void 0,c?.()},onStepKeyDown:x=>{const y=an[v?"from-bottom":"from-top"].includes(x.key);u?.({event:x,direction:y?-1:1})}})})}),ln=h.forwardRef((t,n)=>{const{__scopeSlider:o,onSlideStart:s,onSlideMove:a,onSlideEnd:r,onHomeKeyDown:d,onEndKeyDown:c,onStepKeyDown:u,...i}=t,m=Fe(je,o);return e.jsx(Ae.span,{...i,ref:n,onKeyDown:ye(t.onKeyDown,f=>{f.key==="Home"?(d(f),f.preventDefault()):f.key==="End"?(c(f),f.preventDefault()):sn.concat(on).includes(f.key)&&(u(f),f.preventDefault())}),onPointerDown:ye(t.onPointerDown,f=>{const p=f.target;p.setPointerCapture(f.pointerId),f.preventDefault(),m.thumbs.has(p)?p.focus({preventScroll:!0,focusVisible:!1}):s(f)}),onPointerMove:ye(t.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&a(f)}),onPointerUp:ye(t.onPointerUp,f=>{const p=f.target;p.hasPointerCapture(f.pointerId)&&(p.releasePointerCapture(f.pointerId),r(f))})})}),dn="SliderTrack",un=h.forwardRef((t,n)=>{const{__scopeSlider:o,...s}=t,a=Fe(dn,o);return e.jsx(Ae.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...s,ref:n})});un.displayName=dn;var tt="SliderRange",mn=h.forwardRef((t,n)=>{const{__scopeSlider:o,...s}=t,a=Fe(tt,o),r=cn(tt,o),d=h.useRef(null),c=Le(n,d),u=a.values.length,i=a.values.map(p=>bn(p,a.min,a.max)),m=u>1?Math.min(...i):0,f=100-Math.max(...i);return e.jsx(Ae.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...s,ref:c,style:{...t.style,[r.startEdge]:m+"%",[r.endEdge]:f+"%"}})});mn.displayName=tt;var fn="SliderThumb",[Yo,pn]=rt(fn),hn="SliderThumbProvider";function xn(t){const{__scopeSlider:n,name:o,children:s,internal_do_not_use_render:a}=t,r=Fe(hn,n),d=Go(n),[c,u]=h.useState(null),i=h.useMemo(()=>c?d().findIndex(k=>k.ref.current===c):-1,[d,c]),m=xs(c),f=c?!!r.form||!!c.closest("form"):!0,p=r.values[i],v=o??(r.name?r.name+(r.values.length>1?"[]":""):void 0),g=p===void 0?0:bn(p,r.min,r.max);h.useEffect(()=>{if(c)return r.thumbs.add(c),()=>{r.thumbs.delete(c)}},[c,r.thumbs]);const x={value:p,name:v,form:r.form,isFormControl:f,index:i,thumb:c,onThumbChange:u,percent:g,size:m};return e.jsx(Yo,{scope:n,...x,children:oa(a)?a(x):s})}xn.displayName=hn;var Re="SliderThumbTrigger",gn=h.forwardRef((t,n)=>{const{__scopeSlider:o,...s}=t,a=Fe(Re,o),r=cn(Re,o),{index:d,value:c,percent:u,size:i,onThumbChange:m}=pn(Re,o),f=Le(n,x=>m(x)),p=Zo(d,a.values.length),v=i?.[r.size],g=v?Jo(v,u,r.direction):0;return e.jsx("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[r.startEdge]:`calc(${u}% + ${g}px)`},children:e.jsx(et.ItemSlot,{scope:o,children:e.jsx(Ae.span,{role:"slider","aria-label":t["aria-label"]||p,"aria-valuemin":a.min,"aria-valuenow":c,"aria-valuemax":a.max,"aria-orientation":a.orientation,"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,tabIndex:a.disabled?void 0:0,...s,ref:f,style:c===void 0?{display:"none"}:t.style,onFocus:ye(t.onFocus,()=>{a.valueIndexToChangeRef.current=d})})})})});gn.displayName=Re;var nt=h.forwardRef((t,n)=>{const{__scopeSlider:o,name:s,...a}=t;return e.jsx(xn,{__scopeSlider:o,name:s,internal_do_not_use_render:({index:r,isFormControl:d})=>e.jsxs(e.Fragment,{children:[e.jsx(gn,{...a,ref:n,__scopeSlider:o}),d?e.jsx(yn,{__scopeSlider:o},r):null]})})});nt.displayName=fn;var vn="SliderBubbleInput",yn=h.forwardRef(({__scopeSlider:t,...n},o)=>{const{value:s,name:a,form:r}=pn(vn,t),d=h.useRef(null),c=Le(d,o),u=gs(s);return h.useEffect(()=>{const i=d.current;if(!i)return;const m=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(m,"value").set;if(u!==s&&p){const v=new Event("input",{bubbles:!0});p.call(i,s),i.dispatchEvent(v)}},[u,s]),e.jsx(Ae.input,{style:{display:"none"},name:a,form:r,...n,ref:c,defaultValue:s})});yn.displayName=vn;function Xo(t=[],n,o){const s=[...t];return s[o]=n,s.sort((a,r)=>a-r)}function bn(t,n,o){const r=100/(o-n)*(t-n);return Wt(r,[0,100])}function Zo(t,n){return n>2?`Value ${t+1} of ${n}`:n===2?["Minimum","Maximum"][t]:void 0}function qo(t,n){if(t.length===1)return 0;const o=t.map(a=>Math.abs(a-n)),s=Math.min(...o);return o.indexOf(s)}function Jo(t,n,o){const s=t/2,r=ct([0,50],[0,s]);return(s-r(n)*o)*o}function ea(t){return t.slice(0,-1).map((n,o)=>t[o+1]-n)}function ta(t,n){if(n>0){const o=ea(t);return Math.min(...o)>=n}return!0}function ct(t,n){return o=>{if(t[0]===t[1]||n[0]===n[1])return n[0];const s=(n[1]-n[0])/(t[1]-t[0]);return n[0]+s*(o-t[0])}}function na(t){if(!Number.isFinite(t))return 0;const n=t.toString();if(n.includes("e")){const[s,a]=n.split("e"),r=s.split(".")[1]||"",d=Number(a);return Math.max(0,r.length-d)}const o=n.split(".")[1];return o?o.length:0}function sa(t,n){const o=Math.pow(10,n);return Math.round(t*o)/o}function oa(t){return typeof t=="function"}const jn=h.forwardRef(({className:t,...n},o)=>e.jsxs(it,{ref:o,className:O("relative flex w-full touch-none select-none items-center",t),...n,children:[e.jsx(un,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:e.jsx(mn,{className:"absolute h-full bg-primary"})}),e.jsx(nt,{className:"block h-4 w-4 rounded-full border border-primary/50 bg-background transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"}),n.value&&n.value.length>1&&e.jsx(nt,{className:"block h-4 w-4 rounded-full border border-primary/50 bg-background transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"})]}));jn.displayName=it.displayName;const aa=["notification"],ra=["note","summary","decision","observation","fact","change","preference","identity"],ia=[...aa,...ra],ca="date-desc",It=[{value:"date-desc",label:"Newest first"},{value:"date-asc",label:"Oldest first"},{value:"score-desc",label:"Highest score"},{value:"score-asc",label:"Lowest score"}],At=[{value:"all",label:"Any reviewer"},{value:"user",label:"Manual review"},{value:"system",label:"Auto-classified"},{value:"llm",label:"LLM-classified"}],Lt=[{value:"all",label:"Any status"},{value:"pending",label:"Pending approval"},{value:"approved",label:"Approved"},{value:"rejected",label:"Rejected"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}];function Ye(t,n){return e.jsxs("span",{className:"truncate",children:[e.jsxs("span",{className:"text-muted-foreground",children:[t,": "]}),n]})}function Ve(t){const n=t.replace(/[_-]+/g," ").trim();return n.length>0?`${n.charAt(0).toUpperCase()}${n.slice(1)}`:t}function la({options:t,selected:n,onChange:o}){return e.jsx(he,{contentClassName:"w-72",searchPlaceholder:"Search event kinds...",emptyText:"No event kinds found",trigger:s=>e.jsxs(U,{variant:"outline","aria-expanded":s,className:"h-9 rounded-md bg-muted px-3 py-2 font-normal",children:["Kind",n.length>0?e.jsx(_e,{variant:"secondary",className:"h-5 px-1.5",children:n.length}):null]}),children:()=>t.map(s=>{const a=n.includes(s);return e.jsxs(q,{value:`${Ve(s)} ${s}`,onSelect:()=>o(a?n.filter(r=>r!==s):[...n,s]),children:[e.jsx(Kt,{checked:a,className:"mr-1"}),Ve(s)]},s)})})}function wn({"aria-label":t,onClick:n}){return e.jsx("button",{type:"button","aria-label":t,onClick:o=>{o.preventDefault(),o.stopPropagation(),n()},className:"rounded-sm p-0.5 text-muted-foreground transition-colors hover:text-foreground",children:e.jsx(Te,{className:"h-3.5 w-3.5"})})}function Xe({value:t,onValueChange:n,onClear:o,showClear:s,triggerClassName:a,displayValue:r,children:d}){return e.jsxs("div",{className:"relative shrink-0",children:[e.jsxs(ws,{value:t,onValueChange:n,children:[e.jsx(Ns,{className:O("px-2.5",s&&"pr-9",a),children:e.jsx(Ss,{children:r})}),e.jsx(ks,{children:d})]}),s&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-8 flex items-center",children:e.jsx("div",{className:"pointer-events-auto",children:e.jsx(wn,{"aria-label":"Clear filter",onClick:o})})})]})}function da({filters:t,onFiltersChange:n,connectors:o,eventKinds:s=[],searchQuery:a,onSearchChange:r,hideSourceFilter:d=!1,ownerSlug:c,total:u,isListLoading:i=!1,hasCursorInUrl:m=!1,onGoToLatest:f,open:p,onOpenChange:v,leading:g}){const x=a.trim().length>0,[k,y]=h.useState(x),S=p??k,C=v??y,j=t.dateRange?{from:t.dateRange[0],to:t.dateRange[1]}:void 0,L=N=>{N?.from&&N?.to?n({dateRange:[N.from,N.to]}):n({dateRange:null})},T=N=>{const X=t.platforms||[],_=X.includes(N)?X.filter(ue=>ue!==N):[...X,N];n({platforms:_})},w=`${t.sortBy??"date"}-${t.sortOrder??"desc"}`,W=t.reviewStatus||"all",ae=t.interactionStatus||"all",re=!!(t.dateRange?.[0]&&t.dateRange?.[1]),J=(t.engagementRange?.[0]??0)!==0||(t.engagementRange?.[1]??100)!==100,E=(t.platforms?.length??0)>0,$=t.semanticTypes??[],H=$.length>0,ie=!!(t.reviewStatus&&t.reviewStatus!=="all"),B=!!(t.interactionStatus&&t.interactionStatus!=="all"),A=(x?1:0)+(re?1:0)+(E?1:0)+(H?1:0)+(ie?1:0)+(B?1:0)+(J?1:0),M=s.length>0?s:ia,z=[...new Set([...M,...$])].sort((N,X)=>Ve(N).localeCompare(Ve(X))),G=It.find(N=>N.value===w)?.label??"Newest first",ee=At.find(N=>N.value===W)?.label??"Any reviewer",Q=Lt.find(N=>N.value===ae)?.label??"Any status",ne=e.jsxs("div",{className:"relative w-52 shrink-0",children:[e.jsx(ys,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(bs,{placeholder:d?"Search events...":"Search...",value:a,onChange:N=>r(N.target.value),className:O("pl-9",x&&"pr-8")}),x&&e.jsx("div",{className:"absolute inset-y-0 right-2 flex items-center",children:e.jsx(wn,{"aria-label":"Clear search",onClick:()=>r("")})})]}),fe=e.jsx(Xe,{value:w,onValueChange:N=>{const[X,_]=N.split("-");n({sortBy:X,sortOrder:_})},onClear:()=>n({sortBy:void 0,sortOrder:void 0}),showClear:w!==ca,triggerClassName:"w-[168px]",displayValue:Ye("Sort",G),children:It.map(N=>e.jsx(Qe,{value:N.value,children:N.label},N.value))}),de=e.jsx(Xe,{value:W,onValueChange:N=>n({reviewStatus:N}),onClear:()=>n({reviewStatus:void 0}),showClear:W!=="all",triggerClassName:"w-[186px]",displayValue:Ye("Review",ee),children:At.map(N=>e.jsx(Qe,{value:N.value,children:N.label},N.value))}),xe=e.jsx(Xe,{value:ae,onValueChange:N=>n({interactionStatus:N==="all"?null:N}),onClear:()=>n({interactionStatus:null}),showClear:ae!=="all",triggerClassName:"w-[178px]",displayValue:Ye("Approval",Q),children:Lt.map(N=>e.jsx(Qe,{value:N.value,children:N.label},N.value))}),we=e.jsxs("div",{className:"w-72 space-y-2 px-1 py-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{children:"Engagement score"}),e.jsxs("span",{className:"text-muted-foreground",children:[t.engagementRange?.[0]??0," –"," ",t.engagementRange?.[1]??100]})]}),e.jsx(jn,{value:t.engagementRange||[0,100],onValueChange:N=>n({engagementRange:N}),min:0,max:100,step:5})]}),K=e.jsx(la,{options:z,selected:$,onChange:N=>n({semanticTypes:N.length>0?N:void 0})});return e.jsxs(Ht,{open:S,onOpenChange:C,className:"w-full",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2.5",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 text-sm text-muted-foreground",children:[g,i?e.jsx(Qt,{className:"h-4 w-20"}):u!=null&&u>0?e.jsx("span",{children:`${u.toLocaleString()} items`}):e.jsx("span",{}),!i&&u!=null&&u>0&&m&&f&&e.jsxs(U,{variant:"ghost",size:"sm",className:"h-7 gap-1",onClick:f,children:[e.jsx(js,{className:"h-3.5 w-3.5"}),"Back to latest"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[fe,e.jsx(Yt,{asChild:!0,children:e.jsxs(U,{variant:"outline",className:"h-9 rounded-md bg-muted px-3 py-2 font-normal",children:["Filters",A>0?e.jsx(_e,{variant:"secondary",className:"ml-1.5 h-5 px-1.5 text-[11px]",children:A}):null,e.jsx(ze,{className:O("ml-1 h-4 w-4 transition-transform",S&&"rotate-180")})]})})]})]}),e.jsx(Xt,{className:"pt-2.5",children:e.jsxs("div",{className:"flex flex-wrap items-start gap-2.5 border-t pt-3",children:[ne,d&&c?e.jsx(Po,{ownerSlug:c,visibility:"all"}):null,!d&&o.length>0?e.jsx(Eo,{connectors:o,selectedKeys:t.platforms||[],onToggle:T}):null,e.jsx(zo,{value:j,onChange:L,onClear:()=>n({dateRange:null}),placeholder:"Date range",className:"w-auto shrink-0"}),K,de,xe,we,A>0&&e.jsx(U,{type:"button",variant:"ghost",size:"sm",className:"h-9 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{r(""),n({dateRange:null,platforms:void 0,semanticTypes:void 0,reviewStatus:void 0,interactionStatus:null,engagementRange:void 0})},children:"Clear all"})]})})]})}function ua(t){const n=t instanceof Date?t:new Date(String(t));return Number.isNaN(n.getTime())?null:n}function Dt(t){return t.toISOString().split("T")[0]}function ma({entityId:t,organizationId:n,ownerSlug:o,selectedRange:s,onSelectRange:a}){const{data:r,isLoading:d,error:c}=Cs(n,{entityId:t},{slug:o}),u=h.useMemo(()=>{if(!r||r.length===0)return[];const p=r.map(y=>{const S=ua(y.date);return S?{date:S,count:y.count}:null}).filter(y=>y!==null).sort((y,S)=>y.date.getTime()-S.date.getTime());if(p.length===0)return[];const v=p[0].date;if((p[p.length-1].date.getTime()-v.getTime())/(1e3*60*60*24)>180){const y=new Map;for(const S of p){const C=new Date(S.date);C.setDate(S.date.getDate()-S.date.getDay());const j=Dt(C);y.set(j,(y.get(j)||0)+S.count)}return Array.from(y.entries()).map(([S,C])=>({date:S,count:C})).sort((S,C)=>new Date(S.date).getTime()-new Date(C.date).getTime())}return p.map(y=>({date:Dt(y.date),count:y.count}))},[r]),i=h.useCallback(p=>{if(p.name&&a){const v=new Date(p.name),g=new Date(v);g.setDate(g.getDate()+1),a(v,g)}},[a]),m=h.useCallback(p=>{if(a&&p.startValue!==void 0&&p.endValue!==void 0){const v=new Date(p.startValue),g=new Date(p.endValue);a(v,g)}},[a]),f=h.useMemo(()=>{if(u.length===0)return null;let p;if(s){const v=s[0].toISOString().split("T")[0],g=s[1].toISOString().split("T")[0];p=[[{xAxis:v},{xAxis:g}]]}return{tooltip:{trigger:"axis",axisPointer:{type:"line"},formatter:v=>{const g=v[0];return`${new Date(g.name).toLocaleDateString()}: ${g.value} items`}},grid:{left:50,right:20,top:20,bottom:60},xAxis:{type:"category",boundaryGap:!1,data:u.map(v=>v.date),axisLabel:{formatter:v=>{const g=new Date(v);return`${g.getMonth()+1}/${g.getDate()}`}}},yAxis:{type:"value",minInterval:1,splitLine:{lineStyle:{color:"rgba(0,0,0,0.05)"}}},dataZoom:[{type:"slider",start:0,end:100,height:20,bottom:10,borderColor:"transparent",backgroundColor:"rgba(0,0,0,0.02)",fillerColor:"rgba(99, 102, 241, 0.1)",handleStyle:{color:"#6366f1"}}],series:[{type:"line",smooth:!0,areaStyle:{opacity:.3,color:new po(0,0,0,1,[{offset:0,color:"rgba(99, 102, 241, 0.5)"},{offset:1,color:"rgba(99, 102, 241, 0.05)"}])},lineStyle:{width:2,color:"#6366f1"},itemStyle:{color:"#6366f1"},showSymbol:!1,data:u.map(v=>v.count),markLine:{silent:!0,symbol:"none",label:{position:"insideEndTop",formatter:"avg: {c}",fontSize:10,color:"#9ca3af"},lineStyle:{color:"#d1d5db",type:"dashed",width:1},data:[{type:"average",name:"Average"}]},markArea:p?{silent:!0,itemStyle:{color:"rgba(99, 102, 241, 0.1)"},data:p}:void 0}]}},[u,s]);return d||c?e.jsx("div",{className:O(Zt,"p-4"),children:e.jsx("div",{className:"flex h-48 w-full items-center justify-center",children:d?e.jsx(xo,{}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to load timeline"})})}):!f||u.length<2?null:e.jsx(fa,{option:f,onClick:i,onDataZoom:m})}function fa({option:t,onClick:n,onDataZoom:o}){const{chartRef:s,setOption:a}=ho({onClick:n,onDataZoom:o});return h.useEffect(()=>{a(t,!0)},[t,a]),e.jsx("div",{"data-testid":"events-timeline",className:O(Zt,"p-4 relative"),children:e.jsx("div",{ref:s,className:"h-48 w-full"})})}function pa({organizationId:t,ownerSlug:n,entityId:o,hideSourceFilter:s=!1,scopedEntityTypes:a,filterBarLeading:r}){const{isAuthenticated:d,isReady:c}=_s(),{isMember:u,isLoading:i}=qt(),m=c&&d&&u,f=c&&(!d||!i&&!u),p=me(),v=st(),g=Jt(v.search??{}),{filters:x,updateFilters:k,clearFilters:y}=wo({parse:zs,serialize:Us,filterKeys:Gs,merge:Ws}),[S,C]=h.useState(x.searchQuery||""),[j,L]=h.useState((x.searchQuery||"").trim().length>0),T=Ts(S,1e3),w=h.useMemo(()=>wt({...x,searchQuery:T.length>=3?T:void 0,...a?.length?{entityTypes:a}:{}}),[x,T,a]),W=k;h.useEffect(()=>{const l=T.length>=3?T:void 0;(x.searchQuery||void 0)!==l&&k({searchQuery:l})},[T,k,x.searchQuery]);const ae=()=>{C(""),y()},re=h.useMemo(()=>Is(wt({...x,searchQuery:T.length>=3?T:void 0})),[x,T]),J=o===void 0,{data:E=[]}=As(c&&m?t:null),{data:$=[]}=Ls(f?n:null),H=m?E:$,{data:ie=[]}=Bt(m&&t?{organizationId:t}:void 0),B=jo(),A=w.connectionIds,M=(A?.length??0)>0,{data:z=[]}=Ds(c&&m?t??"":"",{connectionIds:A??void 0,enabled:!B&&c&&m&&M}),G=w.feedIds,ee=(G?.length??0)>0,{data:Q=[]}=Es(c&&m?t:null,{feedIds:G??void 0,enabled:c&&m&&ee}),ne=h.useMemo(()=>B?B.groups.flatMap(l=>l.connections.map(b=>({id:b.id,display_name:b.display_name,connector_name:l.connector_name,connector_key:l.connector_key}))):z,[z,B]),fe=h.useMemo(()=>{const l=new Set(A??[]);return[...new Set([...w.platforms??[],...ne.filter(b=>l.has(b.id)).map(b=>b.connector_key)])]},[A,ne,w.platforms]),de=h.useMemo(()=>Q.map(l=>({connectorKey:l.connector_key,feedKey:l.feed_key})),[Q]),xe=h.useMemo(()=>M&&fe.length===0||ee&&de.length===0?[]:Do({connectors:H,entityTypes:ie,selectedPlatforms:fe,selectedFeeds:de,selectedEntityTypes:w.entityTypes}),[H,w.entityTypes,M,ee,fe,de,ie]),we=h.useMemo(()=>M?No(A??[],ne):null,[A,ne,M]),K=w.clientIds,N=(K?.length??0)>0,{data:X=[]}=lo(null,{enabled:c&&m&&N}),_=h.useMemo(()=>{if(!K)return[];const l=new Set(K);return uo(X).filter(b=>b.clientIds.some(I=>l.has(I)))},[K,X]),ue=h.useMemo(()=>{if(!N||!K)return null;const l=_.map(b=>b.title);return l.length>0?`From ${l.join(", ")}`:`Filtered by client${K.length>1?" registrations":""}`},[_,K,N]),Pe=_.length===1?_[0]:null,Nn=n&&Pe?_o(n,Pe.clientId):void 0,Me=w.mcpActivityId??null,{data:lt=[]}=Fs({enabled:c&&m&&N&&!!Me,clientIds:K??[],limit:100}),Sn=h.useMemo(()=>{if(!Me)return null;const l=lt.find(I=>I.activityId===Me);if(!l)return"Selected conversation";const b=l.title?.trim();return b?`Conversation “${b}”`:l.activityKind==="session"?"MCP session":`Conversation ${l.clientId}`},[Me,lt]),kn=h.useMemo(()=>ee?So(G??[],Q):null,[G,ee,Q]),F=w.agentId,{data:dt=[]}=Be({enabled:c&&!!F}),Cn=h.useMemo(()=>{if(!F||w.automationId!=null||g||(w.platforms?.length??0)>0)return null;const l=dt.find(b=>b.agentId===F);return l?`From agent ${l.name}`:`From agent ${F}`},[F,w.platforms,w.automationId,g,dt]),se=w.automationId,{data:ut=[]}=en(F??void 0,{includeDetails:!1}),_n=h.useMemo(()=>{if(se==null)return null;const l=ut.find(b=>String(b.automation_id)===String(se));return l?`From watch “${l.name}”`:`From Automation #${se}`},[ut,se]),{data:mt=[]}=nn(F??void 0),Tn=h.useMemo(()=>{if(!g||!F)return null;const l=mt.find(b=>b.id===g);return l?.description?.trim()?`From schedule “${l.description.trim()}”`:"From scheduled task"},[F,g,mt]),Ge=h.useMemo(()=>{if(!F||se!=null||g||(w.platforms?.length??0)===0)return null;const l=w.platforms?.[0];return l?`From ${l} listen`:null},[F,w.platforms,g,se]),ge=h.useMemo(()=>{if(!n)return{};const l={};if(ee&&G?.length===1){const b=Q.find(I=>I.id===G[0]);b&&(l.feedIds=ko(n,b))}if(M&&A?.length===1){const b=ne.find(I=>I.id===A[0]);b?.connector_key&&(l.connectionIds=Co(n,{id:b.id,connector_key:b.connector_key}))}return F&&se==null&&!g&&(w.platforms?.length??0)===0&&(l.agentId=Ct(n,F)),F&&se!=null&&(l.automationId=To(n,String(se))),F&&g&&(l.schedule=Io(n,F,g)),Ge&&F&&(l.listen=Ct(n,F)),l},[F,A,ne,G,M,ee,w.platforms,Ge,n,g,se,Q]),{data:In}=Ps(c&&m?t:null,o),{data:An}=Ms(f&&!J?n:null,o),ft=m?In:An,Ue=h.useMemo(()=>{const l=new Map;for(const b of ft||[]){const I=b.automation_name??"__global__";l.has(I)||l.set(I,{automationName:b.automation_name??null,classifiers:[]});const P=l.get(I),R=b.attribute_values||{},te=Object.keys(R);let oe=null;const D={};for(const[V,ce]of Object.entries(R))if(ce.parent)for(const[ve,Se]of Object.entries(ce.parent))oe=ve,D[Se]||(D[Se]=[]),D[Se].push(V);const Z=P.classifiers.find(V=>V.slug===b.slug);if(Z){const V=new Set([...Z.values,...te]);Z.values=[...V];for(const[ce,ve]of Object.entries(D)){Z.valuesByParentValue[ce]||(Z.valuesByParentValue[ce]=[]);const Se=new Set([...Z.valuesByParentValue[ce],...ve]);Z.valuesByParentValue[ce]=[...Se]}oe&&(Z.parentSlug=oe)}else P.classifiers.push({slug:b.slug,name:b.name,values:te,parentSlug:oe,valuesByParentValue:D})}for(const b of l.values())b.classifiers.sort((I,P)=>I.parentSlug===null&&P.parentSlug!==null?-1:I.parentSlug!==null&&P.parentSlug===null?1:0);return[...l.values()]},[ft]),Ln=h.useMemo(()=>{const l=new Map(H.map(I=>[I.key,I]));return[...new Set(l.keys())].map(I=>{const P=l.get(I);return{key:I,name:P?.name||I,description:P?.description,icon:P?.icon,faviconDomain:$s(P?.auth_schema)}}).sort((I,P)=>I.name.localeCompare(P.name))},[H]),Dn=Rs(c&&m?t:null,o,w,n),En=Os(f?n:null,o,w),Fn=f?En:Dn,{data:Ne,isLoading:Pn,error:Mn}=Fn,pt=Ne?.pages[0],ht=pt?.total??0,xt=pt?.classification_stats,$n=!!(w.beforeOccurredAt||w.afterOccurredAt),gt=Ks(w),vt=Ne?.pages[Ne.pages.length-1],pe=vt?.content[vt.content.length-1];h.useEffect(()=>{!gt||!pe||Ne?.pages.length===1||x.beforeOccurredAt===pe.occurred_at&&x.beforeId===pe.id||k({beforeOccurredAt:pe.occurred_at,beforeId:pe.id})},[pe?.id,gt,k,Ne?.pages.length,pe,x.beforeOccurredAt,x.beforeId]);const Rn=h.useCallback(()=>{W({beforeOccurredAt:void 0,beforeId:void 0,afterOccurredAt:void 0,afterId:void 0}),window.scrollTo({top:0,behavior:"smooth"})},[W]),[yt,On]=h.useState(new Set),Kn=l=>{const b=new Set(yt);b.has(l)?b.delete(l):b.add(l),On(b)},Vn=(l,b)=>{W({dateRange:[l,b]})},bt=(l,b)=>{const I=w.classificationFilters||{},P=I[l]||[],R=P.includes(b)?P.filter(oe=>oe!==b):[...P,b],te={...I};if(R.length>0)te[l]=R;else{delete te[l];for(const oe of Ue)for(const D of oe.classifiers)D.parentSlug===l&&delete te[D.slug]}W({classificationFilters:te})};if(Mn)return e.jsx(Vs,{label:"knowledge"});const We=!c||d&&i||Pn,Bn=!We&&ht===0&&!re,zn=d?m?"Activity is the workspace's live feed — every message, email, file, and record a connector pulls in lands here as an event. Connect your data to start collecting.":"Activity is the workspace's live feed of connector events. Join this workspace to add connectors and collect knowledge here.":"No public knowledge items are available yet",jt=!!(m&&n);return e.jsx(Bs,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:s?"sticky top-0 z-10 -mx-4 space-y-3 bg-background px-4 pb-3 lg:-mx-6 lg:px-6":void 0,children:e.jsx(da,{leading:r,open:j,onOpenChange:L,filters:w,onFiltersChange:W,connectors:Ln,eventKinds:xe,searchQuery:S,onSearchChange:C,hideSourceFilter:s,ownerSlug:n,total:ht,isListLoading:We,hasCursorInUrl:$n,onGoToLatest:Rn})}),[{key:"contentIds",label:l=>`Showing knowledge item #${l.join(", #")}`,ids:w.contentIds,clear:{contentIds:void 0}},{key:"runId",label:l=>`Filtered by Automation run #${l}`,id:w.runId,clear:{runId:void 0}},{key:"feedIds",text:kn,sourceLink:ge.feedIds,clear:{feedIds:void 0}},{key:"connectionIds",text:we,sourceLink:ge.connectionIds,clear:{connectionIds:void 0}},{key:"mcpActivityId",text:Sn,clear:{mcpActivityId:void 0}},{key:"clientIds",text:ue,sourceLink:Nn,details:K&&K.length>0?e.jsx(Lo,{ownerSlug:n,clientIds:K,linkedUser:Pe?.linkedUser,linkedUserEntitySlug:Pe?.linkedUserEntitySlug}):void 0,clear:{clientIds:void 0}},{key:"automationId",text:_n,sourceLink:ge.automationId,clear:{automationId:void 0}},{key:"schedule",text:Tn,sourceLink:ge.schedule,clear:{schedule:void 0,runIds:void 0}},{key:"listen",text:Ge,sourceLink:ge.listen,clear:{platforms:void 0,connectionIds:void 0}},{key:"agentId",text:Cn,sourceLink:ge.agentId,clear:{agentId:void 0,automationId:void 0,schedule:void 0,platforms:void 0}},{key:"runIds",label:l=>`Filtered by run${l.length>1?"s":""} #${l.join(", #")}`,ids:w.runIds,clear:{runIds:void 0,schedule:void 0}}].map(l=>{const b="text"in l&&l.text?l.text:"ids"in l&&l.ids&&l.ids.length>0?l.label(l.ids):"id"in l&&l.id!=null?l.label(l.id):null;return b?e.jsx(Ao,{text:b,sourceLink:"sourceLink"in l?l.sourceLink:void 0,details:"details"in l?l.details:void 0,onClear:()=>W(l.clear)},l.key):null}).filter(Boolean),j&&m&&o&&t&&e.jsx(ma,{entityId:o,organizationId:t,ownerSlug:n||"",selectedRange:w.dateRange||void 0,onSelectRange:Vn}),Ue.length>0&&e.jsx("div",{className:"space-y-2",children:Ue.map(l=>{const b=l.automationName??"__global__",I=l.classifiers.some(R=>(w.classificationFilters?.[R.slug]?.length||0)>0),P=yt.has(b)||I;return e.jsxs(Ht,{open:P,onOpenChange:()=>Kn(b),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Yt,{asChild:!0,children:e.jsx(U,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:P?e.jsx(ze,{className:"h-3.5 w-3.5"}):e.jsx(tn,{className:"h-3.5 w-3.5"})})}),l.automationName&&e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:l.automationName})]}),e.jsx(Xt,{className:"space-y-1.5 mt-1.5 ml-6",children:l.classifiers.filter(R=>R.parentSlug===null).map(R=>{const te=w.classificationFilters?.[R.slug]||[],oe=l.classifiers.filter(D=>D.parentSlug===R.slug);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:R.name}),R.values.map(D=>{const Z=te.includes(D),V=xt?.[R.slug]?.[D];return e.jsxs(_e,{variant:Z?"default":"outline",className:"cursor-pointer",onClick:()=>bt(R.slug,D),children:[D,V!=null&&e.jsx("span",{className:"ml-1 opacity-60",children:V})]},D)})]}),te.length>0&&oe.map(D=>{const Z=[...new Set(te.flatMap(V=>D.valuesByParentValue[V]||[]))];return Z.length===0?null:e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 ml-4 mt-1.5",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:D.name}),Z.map(V=>{const ce=w.classificationFilters?.[D.slug]?.includes(V),ve=xt?.[D.slug]?.[V];return e.jsxs(_e,{variant:ce?"default":"outline",className:"cursor-pointer",onClick:()=>bt(D.slug,V),children:[V,ve!=null&&e.jsx("span",{className:"ml-1 opacity-60",children:ve})]},V)})]},D.slug)})]},R.slug)})})]},b)})}),We?e.jsx("div",{className:"space-y-4",children:["skeleton-1","skeleton-2","skeleton-3","skeleton-4","skeleton-5"].map(l=>e.jsx(Qt,{className:"h-32 rounded-lg"},l))}):Bn?e.jsx(Oe,{icon:Nt,title:"No activity yet",description:zn,actionLabel:jt?"Add a connector":void 0,onAction:jt&&n?()=>void p({to:"/$owner/connectors/create",params:{owner:n}}):void 0}):e.jsx(mo,{organizationId:t,ownerSlug:n,entityId:o,filters:w,showEntityLinks:J,emptyState:e.jsx(Oe,{icon:Nt,title:"No results found",description:"Try adjusting your filters to find what you are looking for",actionLabel:re?"Clear filters":void 0,onAction:re?ae:void 0})})]})})}function ha(t){const n=Hs();return e.jsx(xa,{...t,context:n},`${t.ownerSlug}:${t.attentionLens}:${Qs(n)}`)}function xa({organizationId:t,ownerSlug:n,typeScope:o,entityScope:s,agentScope:a,automationScope:r,scheduleScope:d,attentionLens:c=!1,activityTab:u="events",context:i}){const[m,f]=h.useState(c?"relevant":"activity"),p=i?m!=="activity":c,{orgContext:v}=Vt(),{isMember:g,isLoading:x}=qt(),k=g&&!!t,y=Ft(),S=u==="sessions"&&y,{attentionItems:C}=Ys(n),j=C.length,L=i?e.jsx("fieldset",{"aria-label":"Activity view",className:O("flex min-w-0 max-w-full items-center gap-1",y&&"justify-center"),children:[["relevant","Relevant here"],["attention","Needs attention"],["activity","All activity"]].map(([_,ue])=>e.jsxs("button",{type:"button","aria-pressed":m===_,onClick:()=>f(_),className:"flex min-w-0 items-center justify-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground transition-colors aria-pressed:bg-muted aria-pressed:text-foreground hover:text-foreground",children:[ue,_==="attention"?e.jsx(Et,{count:j}):null]},_))}):e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Y,{to:"/$owner/events",params:{owner:n},search:_=>({..._??{}}),"aria-current":p?void 0:"page",className:O("rounded-md px-2.5 py-1 text-xs font-medium transition-colors",p?"text-muted-foreground hover:text-foreground":"bg-muted text-foreground"),children:"All activity"}),e.jsxs(Y,{to:"/$owner",params:{owner:n},search:_=>({..._??{}}),"aria-current":p?"page":void 0,className:O("flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs font-medium transition-colors",p?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"),children:["Needs attention",e.jsx(Et,{count:j})]})]}),{data:T=[]}=Be(),w=a?T.find(_=>_.agentId===a)?.name??a:void 0,{data:W=[]}=en(a,{includeDetails:!1}),ae=r?W.find(_=>_.automation_id===r)?.name??`Automation ${r}`:void 0,{data:re=[]}=nn(a),J=d?re.find(_=>_.id===d)?.description??"Schedule":void 0,E=o?Ce(o):void 0,{data:$,isLoading:H,error:ie}=Xs(s?`/${n}/${Zs(s)}`:p?`/${n}`:"",v),B=s?$?.entity:void 0,A=s?B?.entity_type??Ce(s.split("/").at(-2)??""):E,M=A==="$member",z=s!=null&&!H&&(ie!=null||$?.entity==null),{data:G}=qs(A??"",v),ee=x||H,Q=$?.counts,ne=Q?Q.connections>0||Q.agents>0||Q.clients>0:!1,fe=k&&!ee&&Q!=null&&!ne,de={},xe=a?{agent:a}:{},we=A?{type:A}:{},K=s?e.jsx(Ze,{icon:B?.entity_type?e.jsx(Gt,{icon:G?.icon,className:"h-4 w-4 shrink-0"}):null,typeSegment:A?{label:G?.name??Ce(A),search:we}:void 0,label:B?.name??s.split("/").slice(-1)[0],ownerSlug:n,clearSearch:{}}):r&&a?e.jsx(Ze,{typeSegment:{label:w??"Agent",search:de},label:ae??"Automation",ownerSlug:n,clearSearch:xe}):d&&a?e.jsx(Ze,{typeSegment:{label:w??"Agent",search:de},label:J??"Schedule",ownerSlug:n,clearSearch:xe}):null,N=!y&&!S&&!z,X=s&&H?e.jsx(St,{label:"Loading record…"}):z?e.jsx(Oe,{icon:Js,title:"Record not found",description:"This record no longer exists."}):e.jsx(pa,{organizationId:t,ownerSlug:n,filterBarLeading:N?L:void 0,hideSourceFilter:!0,entityId:B?.id,scopedEntityTypes:!s&&E?[E]:void 0});if(p){const _=ee?e.jsx(St,{label:"workspace setup",variant:"panel",className:"px-6 py-8"}):fe?e.jsx("div",{className:"px-6",children:e.jsx(Oe,{icon:no,title:"Nothing to catch up on — yet",description:"No notifications here. Add a connector to bring in data, or bring your agent to Lobu and give it something to work with.",children:e.jsxs("div",{className:"mt-4 flex flex-wrap justify-center gap-2",children:[e.jsx(U,{asChild:!0,children:e.jsxs(Y,{to:"/$owner/connectors/create",params:{owner:n},children:[e.jsx(so,{className:"mr-2 h-4 w-4"}),"Add a connector"]})}),e.jsx(U,{asChild:!0,variant:"outline",children:e.jsxs(Y,{to:"/$owner/agents",params:{owner:n},children:[e.jsx(qe,{className:"mr-2 h-4 w-4"}),"Connect agent"]})})]})})}):e.jsx("p",{className:"rounded-lg border bg-muted/20 px-3 py-6 text-center text-xs text-muted-foreground",children:"Nothing needs attention right now."});return e.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:e.jsx(eo,{context:i,relevant:m==="relevant",owner:n,emptyState:_,tabs:L})})}return e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:[N?null:e.jsxs("div",{className:O("sticky top-0 z-20 flex min-w-0 flex-wrap items-center gap-x-4 gap-y-2 bg-background pt-1",y?"justify-center":"justify-between"),children:[L,y?e.jsxs("div",{className:"flex items-center rounded-lg bg-muted/60 p-0.5 text-xs",children:[e.jsx(Y,{to:"/$owner/events",params:{owner:n},search:_=>{const ue={..._??{}};return delete ue.tab,ue},"aria-current":S?void 0:"page",className:O("rounded-md px-2.5 py-1 text-xs font-medium transition-colors",S?"text-muted-foreground hover:text-foreground":"bg-background text-foreground "),children:"Events"}),e.jsx(Y,{to:"/$owner/events",params:{owner:n},search:_=>({..._??{},tab:"sessions"}),"aria-current":S?"page":void 0,className:O("rounded-md px-2.5 py-1 text-xs font-medium transition-colors",S?"bg-background text-foreground ":"text-muted-foreground hover:text-foreground"),children:"Sessions"})]}):null]}),K&&!S?e.jsx("div",{className:"sticky top-0 z-20 flex min-w-0 flex-col gap-3 bg-background pt-1",children:K}):null,S?e.jsx(to,{owner:n,tone:"page",empty:"message"}):M?e.jsx(go,{children:X}):X]})}function Et({count:t}){return t===0?null:e.jsx("span",{role:"img","aria-label":`${t} item${t===1?"":"s"} need attention`,className:"rounded-full bg-blue-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-blue-600 dark:text-blue-400",children:t})}function Ze({icon:t,typeSegment:n,label:o,ownerSlug:s,clearSearch:a}){return e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 border-l border-border/60 pb-1 pl-3 text-sm",children:[t,n?e.jsxs(e.Fragment,{children:[e.jsx(Y,{to:"/$owner/events",params:{owner:s},search:n.search,className:"shrink-0 font-medium text-muted-foreground transition-colors hover:text-foreground hover:underline",children:n.label}),e.jsx(tn,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/60"})]}):null,e.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:o}),e.jsx(U,{asChild:!0,variant:"ghost",size:"sm",className:"h-6 gap-1 px-2",children:e.jsxs(Y,{to:"/$owner/events",params:{owner:s},search:a,children:[e.jsx(Te,{className:"h-3.5 w-3.5"}),"Clear"]})})]})}function Aa({owner:t,search:n,attentionLens:o,entityScope:s}){const a=typeof n.type=="string"&&n.type.trim()?Ce(n.type.trim()):void 0,r=zt(n),d=oo(n),c=Jt(n),u=n.tab==="sessions"?"sessions":"events";return e.jsx("div",{className:"flex flex-1 flex-col gap-6 px-4 py-6 lg:px-6",children:e.jsx(ao,{owner:t,children:i=>e.jsx(yo,{organizationId:i.organizationId,isWorkspaceLoading:i.isWorkspaceLoading,children:e.jsxs("div",{className:"mx-auto flex min-h-0 w-full min-w-0 max-w-3xl flex-1 flex-col",children:[e.jsx(ha,{organizationId:i.organizationId,ownerSlug:i.ownerSlug,typeScope:a,entityScope:s,agentScope:r,automationScope:d,scheduleScope:c,attentionLens:o,activityTab:u}),e.jsx(vo,{ownerSlug:i.ownerSlug})]})})})})}export{Aa as A};
|
|
1
|
+
import{a4 as me,O as Ft,bz as Be,bf as Gn,r as h,ci as Un,j as e,bR as qe,L as Y,B as U,Z as Te,al as O,cj as Pt,ck as Mt,cl as $t,bL as Rt,cm as ze,cn as Ot,co as Wn,cp as Hn,ba as Qn,a5 as st,cq as Yn,cr as Xn,cs as Zn,ct as qn,cu as Jn,J as es,cv as he,cw as q,am as Kt,cx as ts,ah as _e,a3 as Vt,cy as Bt,cz as ns,bV as Ce,cA as zt,cB as ss,aR as Ie,cC as Gt,P as Ut,cD as os,cE as as,cF as le,cf as rs,cG as is,cH as cs,cI as ls,bv as ds,n as us,cJ as ms,cK as He,cL as fs,cM as ye,aH as Ae,cN as Le,cO as ps,cP as hs,cQ as Wt,cR as xs,cS as gs,aK as vs,cT as ys,ad as bs,b$ as Qe,cU as Ht,S as Qt,cV as js,cW as Yt,cX as Xt,bX as ws,bY as Ns,bZ as Ss,b_ as ks,cY as Cs,aV as Zt,v as _s,w as qt,cZ as Jt,c_ as Ts,c$ as wt,d0 as Is,d1 as As,d2 as Ls,a as Ds,d3 as Es,d4 as Fs,d5 as en,d6 as Ps,d7 as Ms,d8 as $s,d9 as Rs,da as Os,db as Ks,c2 as Vs,dc as Bs,dd as tn,bq as Oe,I as Nt,b7 as zs,de as Gs,df as Us,dg as Ws,dh as Hs,di as Qs,dj as Ys,p as Xs,q as Zs,dk as qs,c1 as St,dl as Js,dm as eo,a_ as to,dn as no,bO as so,dp as oo,aY as ao}from"./index-DtRfQcRH.js";import{A as ro}from"./device-automation-BIjs7DZJ.js";import{n as io}from"./agent-thread-storage-U6htL3ad.js";import{s as co}from"./pending-seed-CPbfgnLX.js";import{u as lo}from"./clients-C7ubnFsS.js";import{g as uo}from"./client-rows-EJSKR6z1.js";import{c as Je}from"./connection-label-BobuYiAG.js";import{E as mo}from"./events-feed-C4L8mQV7.js";import{C as fo}from"./calendar-CHXehtu0.js";import{L as po,u as ho}from"./renderer-1nRJFMGx.js";import{E as xo}from"./agent-loading-shells-BQLjzMPy.js";import{M as go}from"./member-scope-gate-CJqJZk7T.js";function Ke(t){return t.kind==="managed"?`managed:${t.agentId}`:`device:${t.executionTarget.deviceWorkerId}:${t.executionTarget.agentKind}`}function vo({ownerSlug:t}){const n=me(),o=Ft(),{data:s=[]}=Be(),{data:a=[]}=Gn(),[r,d]=h.useState(!1),[c,u]=h.useState(null),[i,m]=h.useState(""),[f,p]=h.useState(!1),v=h.useRef(null);h.useEffect(()=>{o&&r&&v.current?.focus()},[o,r]);const g=s.find(j=>j.system)??s[0]??null,x=h.useMemo(()=>{const j=s.map(T=>({kind:"managed",agentId:T.agentId,label:T.name})),L=g?a.filter(T=>T.online&&T.organization_slug===t&&T.capabilities.includes("automations.execute")&&(T.agent_kinds?.length??0)>0).flatMap(T=>(T.agent_kinds??[]).map(w=>({kind:"device",agentId:g.agentId,label:`${Un(T)} · ${ro[w]??w}`,executionTarget:{kind:"device",deviceWorkerId:T.id,agentKind:w}}))):[];return{managed:j,deviceTargets:L}},[s,g,a,t]),y=[...x.managed,...x.deviceTargets].find(j=>Ke(j)===c)??x.managed.find(j=>j.agentId===g?.agentId)??x.managed[0]??x.deviceTargets[0]??null,S=j=>{u(Ke(j)),p(!1)},C=()=>{const j=i.trim();if(!j||!y)return;const L=io();co(L,j,y.kind==="device"?y.executionTarget:void 0),m(""),n(Hn(t,y.agentId,L))};if(o&&!r){const j="flex h-14 w-14 items-center justify-center rounded-full border bg-background text-foreground transition-colors hover:bg-accent/60";return e.jsx("div",{className:"sticky bottom-0 z-20 mt-auto flex justify-center bg-gradient-to-t from-background via-background to-transparent pt-4 pb-1",children:y?e.jsx("button",{type:"button","aria-label":"Ask Lobu",className:j,onClick:()=>d(!0),children:e.jsx(qe,{className:"h-7 w-7"})}):e.jsx(Y,{to:"/$owner/agents",params:{owner:t},"aria-label":"Create an agent to start chatting",className:j,children:e.jsx(qe,{className:"h-7 w-7"})})})}return e.jsx("div",{className:"sticky bottom-0 z-20 mt-auto bg-gradient-to-t from-background via-background to-transparent pt-5",children:e.jsxs("div",{className:"relative rounded-2xl border bg-background transition-colors focus-within:ring-1 focus-within:ring-ring",children:[o?e.jsx(U,{type:"button",variant:"ghost",size:"icon","aria-label":"Collapse composer",className:"absolute top-1.5 right-1.5 size-7 shrink-0 text-muted-foreground hover:text-foreground",onClick:()=>d(!1),children:e.jsx(Te,{className:"h-4 w-4"})}):null,y?e.jsx("textarea",{value:i,onChange:j=>m(j.target.value),onKeyDown:j=>{j.key==="Enter"&&!j.shiftKey&&(j.preventDefault(),C())},placeholder:"Ask Lobu…",rows:2,ref:v,className:O("max-h-40 min-h-16 w-full resize-none bg-transparent px-4 pt-3 text-sm outline-none placeholder:text-muted-foreground",o&&"pr-10")}):e.jsx(Y,{to:"/$owner/agents",params:{owner:t},className:O("block min-h-16 px-4 pt-3 text-sm text-muted-foreground hover:text-foreground",o&&"pr-10"),children:"Create an agent to start chatting"}),e.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 pb-2",children:[e.jsxs(Pt,{open:f,onOpenChange:p,children:[e.jsx(Mt,{asChild:!0,children:e.jsxs(U,{type:"button",variant:"ghost",size:"sm",disabled:!y,className:"h-8 max-w-[70%] gap-1.5 px-2 text-xs text-muted-foreground",children:[y?.kind==="device"?e.jsx($t,{className:"h-3.5 w-3.5"}):e.jsx(Rt,{className:"h-3.5 w-3.5"}),e.jsxs("span",{className:"truncate",children:["Run with: ",y?.label??"No agent"]}),e.jsx(ze,{className:"h-3.5 w-3.5 shrink-0"})]})}),e.jsxs(Ot,{align:"start",className:"max-h-80 w-72 overflow-y-auto p-1.5",children:[e.jsx("p",{className:"px-2 py-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Lobu agents"}),x.managed.map(j=>e.jsx(kt,{target:j,selected:y,onSelect:S},j.agentId)),x.deviceTargets.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"my-1 h-px bg-border"}),e.jsx("p",{className:"px-2 py-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Devices"}),x.deviceTargets.map(j=>e.jsx(kt,{target:j,selected:y,onSelect:S},`${j.executionTarget.deviceWorkerId}:${j.executionTarget.agentKind}`))]}):null]})]}),e.jsxs(U,{type:"button",size:"icon",className:"h-8 w-8 rounded-full",disabled:!y||!i.trim(),onClick:C,children:[e.jsx(Wn,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Send message"})]})]})]})})}function kt({target:t,selected:n,onSelect:o}){const s=n?Ke(n)===Ke(t):!1;return e.jsxs("button",{type:"button",className:O("flex w-full items-center gap-2 rounded-md px-2 py-2 text-left text-sm hover:bg-accent",s&&"bg-accent"),onClick:()=>o(t),children:[t.kind==="device"?e.jsx($t,{className:"h-4 w-4 shrink-0"}):e.jsx(Rt,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:t.label})]})}const ot=h.createContext(null);function yo({organizationId:t,isWorkspaceLoading:n,children:o}){const{data:s=[],isLoading:a}=Qn(t);return e.jsx(ot.Provider,{value:{groups:s,isLoading:!!n||a},children:o})}function bo(){const t=h.useContext(ot);if(!t)throw new Error("useMemoryConnectorGroups must be used within MemoryConnectorGroupsProvider");return t}function jo(){return h.useContext(ot)}function wo(t){const{parse:n,serialize:o,filterKeys:s,clearClassifications:a=!0,merge:r}=t,d=me(),c=st(),u=h.useMemo(()=>{const f=Object.entries(c.search||{}).filter(v=>v[1]!==void 0&&v[1]!==null),p=new URLSearchParams(f);return n(p)},[c.search,n]),i=h.useCallback(f=>{const p=r?r(u,f):{...u,...f},v=o(p),g={};for(const[x,k]of Object.entries(c.search||{}))k!=null&&(g[x]=k);for(const x of s)delete g[x];if(a)for(const x of Object.keys(g))x.startsWith("clf_")&&delete g[x];for(const[x,k]of Object.entries(v))k!==void 0&&(g[x]=k);d({to:c.pathname,search:g,replace:!0})},[u,o,s,a,r,d,c]),m=h.useCallback(()=>{const f={};for(const[p,v]of Object.entries(c.search||{}))v!=null&&(s.includes(p)||a&&p.startsWith("clf_")||(f[p]=v));d({to:c.pathname,search:f,replace:!0})},[d,c.pathname,c.search,s,a]);return{filters:u,updateFilters:i,clearFilters:m}}function nn(t){const{slug:n}=Yn();return Xn({queryKey:["schedules",n,t],queryFn:async()=>((await Zn("manage_schedules",{action:"list",action_type:"wake_agent",include_paused:!0})).schedules??[]).filter(s=>s.action_args?.agent_id===t),enabled:!!n&&!!t,staleTime:3e4})}function No(t,n){if(t.length===0)return"";const o=t.map(s=>{const a=n.find(r=>r.id===s);return a?Je(a):null}).filter(s=>s!=null);return o.length===0?`Filtered by connection${t.length>1?"s":""} #${t.join(", #")}`:o.length===1?`From ${o[0]}`:`From ${o.join(", ")}`}function So(t,n){if(t.length===0)return"";const s=t.map(a=>{const r=n.find(u=>u.id===a);if(!r)return null;const d=r.connection_name?.trim()||r.connector_name||r.connector_key||`connection #${r.connection_id}`,c=r.display_name?.trim()||r.feed_key||`feed #${r.id}`;return`${d} · ${c}`}).filter(a=>a!=null);return s.length===0?`Filtered by feed${t.length>1?"s":""} #${t.join(", #")}`:s.length===1?`From ${s[0]}`:`From ${s.join("; ")}`}function ko(t,n){return{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:t,connectorKey:n.connector_key,connectionId:String(n.connection_id)},search:{feedId:n.id}}}function Co(t,n){return{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:t,connectorKey:n.connector_key,connectionId:String(n.id)}}}function _o(t,n){return{to:"/$owner/agents/connected/$clientId",params:{owner:t,clientId:n}}}function Ct(t,n){return{to:"/$owner/events",params:{owner:t},search:{agent:n}}}function To(t,n){return{to:"/$owner/automations/$automationId",params:{owner:t,automationId:n}}}function Io(t,n,o){return{to:"/$owner/events",params:{owner:t},search:{agent:n,schedule:o}}}function Ao({text:t,sourceLink:n,details:o,onClear:s}){return e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-border bg-muted/50 px-3 py-2 text-sm",children:[e.jsx(Jn,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),n?e.jsxs(Y,{to:n.to,params:n.params,search:n.search,className:"inline-flex min-w-0 items-center gap-1.5 font-medium text-foreground hover:underline",children:[e.jsx("span",{className:"truncate",children:t}),e.jsx(es,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]}):e.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:t}),o,e.jsx(U,{variant:"ghost",size:"icon",className:"ml-auto h-5 w-5 shrink-0",onClick:s,"aria-label":"Clear filter",children:e.jsx(Te,{className:"h-3.5 w-3.5"})})]})}function Lo({ownerSlug:t,clientIds:n,linkedUser:o,linkedUserEntitySlug:s}){const a=t&&s?qn(t,[{entity_type:"$member",slug:s}]):null;return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:n.length===1?"Client ID":"Client IDs"}),n.map(r=>e.jsx("code",{className:"break-all text-foreground",children:r},r))]}),o?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:["Granted by",a?e.jsx(Y,{to:a,className:"font-medium text-foreground hover:underline",children:o}):e.jsx("span",{className:"font-medium text-foreground",children:o})]}):null]})}function ke(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function $e(t,n,o){const s=new Set;for(const[a,r]of Object.entries(t.feeds_schema??{})){if(o&&!o.has(a))continue;const d=ke(ke(r)?.eventKinds);if(d)for(const[c,u]of Object.entries(d)){if(!n){s.add(c);continue}const i=ke(u)?.attributions;Array.isArray(i)&&i.some(m=>{const f=ke(ke(m)?.target);return typeof f?.entityType=="string"&&n.has(f.entityType)})&&s.add(c)}}return s}function Do({connectors:t,entityTypes:n,selectedPlatforms:o=[],selectedFeeds:s=[],selectedEntityTypes:a=[]}){const r=new Set,d=new Set(o),c=new Set(a),u=new Map;for(const i of s){const m=u.get(i.connectorKey)??new Set;m.add(i.feedKey),u.set(i.connectorKey,m)}if(u.size>0)for(const i of t){const m=u.get(i.key);if(m)for(const f of $e(i,void 0,m))r.add(f)}else if(d.size>0){for(const i of t)if(d.has(i.key))for(const m of $e(i))r.add(m)}else if(c.size>0){for(const i of n)if(c.has(i.slug))for(const m of Object.keys(i.event_kinds??{}))r.add(m);for(const i of t)for(const m of $e(i,c))r.add(m)}else{for(const i of n)for(const m of Object.keys(i.event_kinds??{}))r.add(m);for(const i of t)for(const m of $e(i))r.add(m)}return[...r].sort((i,m)=>i.localeCompare(m))}function Eo({connectors:t,selectedKeys:n,onToggle:o,label:s="Connectors",searchPlaceholder:a="Search connectors...",emptyText:r="No connectors found"}){return e.jsx(he,{contentClassName:"w-80",searchPlaceholder:a,emptyText:r,trigger:()=>e.jsxs(U,{variant:"outline",className:"h-9",children:[s,n.length>0&&e.jsx(_e,{variant:"secondary",className:"ml-2 h-5 px-1.5",children:n.length})]}),children:()=>t.map(d=>e.jsxs(q,{onSelect:()=>o(d.key),children:[e.jsx(Kt,{checked:n.includes(d.key),className:"mr-3"}),e.jsx(ts,{connector:d,className:"flex-1"}),typeof d.count=="number"&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:d.count.toLocaleString()})]},d.key))})}function Fo(t){const{orgContext:n}=Vt(),{data:o=[],isLoading:s}=Bt(n);return{visible:h.useMemo(()=>o.filter(r=>!ns(r)&&(!r.organization_slug||r.organization_slug===t)),[o,t]),isTypesLoading:s}}function be(){return st().search??{}}function Po({ownerSlug:t,typeScope:n,agentScope:o,connectionScope:s,feedScope:a,visibility:r="all"}){const d=be(),c=typeof d.type=="string"&&d.type.trim()?d.type.trim():void 0,u=n??(c?Ce(c):void 0),i=o??zt(d),m=s??ss(d),f=a??(typeof d.feed_ids=="string"?d.feed_ids:typeof d.feed_ids=="number"?String(d.feed_ids):void 0),p=k=>r==="all"||(r==="active"?k:!k),v=p(!!u),g=p(!!i),x=p(!!(m||f));return!v&&!g&&!x?null:e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[v?e.jsx(Mo,{ownerSlug:t,typeScope:u}):null,g?e.jsx($o,{ownerSlug:t,agentScope:i}):null,x?e.jsx(Ro,{ownerSlug:t,connectionScope:m,feedScope:f}):null]})}const De=h.forwardRef(function({open:n,label:o,value:s,disabled:a,disabledReason:r,...d},c){const u=e.jsxs(U,{ref:c,variant:"outline",disabled:a,"aria-expanded":n,className:"h-9 gap-1.5 rounded-md bg-muted px-3 py-2 text-sm font-normal",...d,children:[e.jsx("span",{className:"text-muted-foreground",children:o}),s?e.jsx("span",{className:"max-w-[10rem] truncate font-medium",children:s}):e.jsx("span",{className:"text-muted-foreground",children:"Any"}),e.jsx(ze,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]});return a&&r?e.jsxs(is,{children:[e.jsx(cs,{asChild:!0,children:e.jsx("span",{className:"inline-flex",children:u})}),e.jsx(ls,{children:r})]}):u});function Mo({ownerSlug:t,typeScope:n}){const o=me(),s=be(),{visible:a}=Fo(t),r=a.find(u=>u.slug===n),d=u=>{o(le(t,s,{entity:void 0,create:void 0,type:u}))},c=()=>{o(le(t,s,{type:void 0}))};return e.jsx(he,{contentClassName:"w-72",searchPlaceholder:"Search types...",emptyText:"No entity types",trigger:u=>e.jsx(De,{open:u,label:"Type",value:r?.name}),children:u=>e.jsxs(e.Fragment,{children:[n?e.jsx(q,{onSelect:()=>{c(),u()},className:"text-muted-foreground",children:"Clear type"}):null,a.map(i=>e.jsxs(q,{onSelect:()=>{d(i.slug),u()},className:"group gap-2",children:[e.jsx(Ie,{className:Ee(i.slug===n)}),e.jsx(Gt,{icon:i.icon,className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:i.name}),typeof i.entity_count=="number"?e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:i.entity_count}):null,e.jsx(at,{to:"/$owner/entity-types/$slug",params:{owner:t,slug:i.slug},label:i.name})]},i.id)),e.jsxs(q,{onSelect:()=>{o(os(t)),u()},className:"text-muted-foreground",children:[e.jsx(Ut,{className:"h-4 w-4 shrink-0"}),"Add entity type"]})]})})}function $o({ownerSlug:t,agentScope:n}){const o=me(),s=be(),{data:a=[]}=Be(),r=h.useMemo(()=>[...a].sort((i,m)=>i.name.localeCompare(m.name)),[a]),d=r.find(i=>i.agentId===n),c=i=>{o(le(t,s,_t(s,i)))},u=()=>{o(le(t,s,_t(s,void 0)))};return e.jsx(he,{contentClassName:"w-72",searchPlaceholder:"Search agents...",emptyText:"No agents",trigger:i=>e.jsx(De,{open:i,label:"Agent",value:d?.name}),children:i=>e.jsxs(e.Fragment,{children:[n?e.jsx(q,{onSelect:()=>{u(),i()},className:"text-muted-foreground",children:"Clear agent"}):null,r.map(m=>e.jsxs(q,{onSelect:()=>{c(m.agentId),i()},className:"gap-2",children:[e.jsx(Ie,{className:Ee(m.agentId===n)}),e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-muted text-[10px] font-medium",children:m.name.trim().charAt(0).toUpperCase()||"?"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:m.name})]},m.agentId))]})})}function _t(t,n){const o={agent:n,automation:void 0,schedule:void 0,platforms:void 0};return t.schedule!=null&&(o.run_ids=void 0),typeof t.platforms=="string"&&t.platforms.trim().length>0&&(o.connection_ids=void 0,o.feed_ids=void 0),o}function Ro({ownerSlug:t,connectionScope:n,feedScope:o}){const{groups:s}=bo(),a=h.useMemo(()=>new Set((n??"").split(",").map(u=>u.trim()).filter(Boolean)),[n]),r=as(s,a),d=s.find(u=>u.connector_key===r),c=a.size===1?Number([...a][0]):void 0;return e.jsxs(e.Fragment,{children:[e.jsx(Oo,{ownerSlug:t,groups:s,scopedGroup:d}),d?e.jsx(Ko,{ownerSlug:t,group:d,selectedIds:a}):null,c?e.jsx(Vo,{ownerSlug:t,connectionId:c,feedScope:o}):null]})}function Oo({ownerSlug:t,groups:n,scopedGroup:o}){const s=me(),a=be(),r=u=>{const i=u.connections.map(m=>String(m.id)).join(",");i&&s(le(t,a,{connection_ids:i,feed_ids:void 0}))},d=()=>{s(le(t,a,{connection_ids:void 0,feed_ids:void 0}))},c=o?.connector_name??o?.connector_key;return e.jsx(he,{contentClassName:"w-72",searchPlaceholder:"Search connectors...",emptyText:"No connectors",trigger:u=>e.jsx(De,{open:u,label:"Connector",value:c}),children:u=>e.jsxs(e.Fragment,{children:[o?e.jsx(q,{onSelect:()=>{d(),u()},className:"text-muted-foreground",children:"Clear connector"}):null,n.map(i=>{const m=i.connector_name??i.connector_key;return e.jsxs(q,{disabled:i.connections.length===0,onSelect:()=>{r(i),u()},className:"group gap-2",children:[e.jsx(Ie,{className:Ee(i.connector_key===o?.connector_key)}),e.jsx(ds,{plain:!0,name:m,faviconDomain:i.favicon_domain,className:"h-5 w-5 shrink-0 rounded-md text-[10px]"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:m}),i.connection_count>0?e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:i.connection_count}):null,e.jsx(at,{to:"/$owner/connectors/$connectorKey",params:{owner:t,connectorKey:i.connector_key},label:m})]},i.connector_key)}),e.jsx(Bo,{to:"/$owner/connectors/create",params:{owner:t},label:"Add connector",onSelect:u})]})})}function Ko({ownerSlug:t,group:n,selectedIds:o}){const s=me(),a=be(),r=o.size===1?n.connections.find(u=>o.has(String(u.id))):void 0,d=u=>{s(le(t,a,{connection_ids:String(u),feed_ids:void 0}))},c=r?Je({display_name:r.display_name,connector_name:n.connector_name,connector_key:n.connector_key}):"All connections";return e.jsx(he,{contentClassName:"w-72",searchPlaceholder:"Search connections...",emptyText:"No connections",trigger:u=>e.jsx(De,{open:u,label:"Connection",value:c}),children:u=>n.connections.map(i=>{const m=Je({display_name:i.display_name,connector_name:n.connector_name,connector_key:n.connector_key});return e.jsxs(q,{onSelect:()=>{d(i.id),u()},className:"group gap-2",children:[e.jsx(Ie,{className:Ee(o.has(String(i.id)))}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:m}),i.feed_count>0?e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:i.feed_count}):null,e.jsx(at,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:t,connectorKey:n.connector_key,connectionId:String(i.id)},label:m})]},i.id)})})}function Vo({ownerSlug:t,connectionId:n,feedScope:o}){const s=me(),a=be(),{data:r=[],isLoading:d}=us(n),c=h.useMemo(()=>new Set((o??"").split(",").map(f=>f.trim()).filter(Boolean)),[o]),u=c.size===1?r.find(f=>c.has(String(f.id))):void 0,i=f=>{s(le(t,a,{connection_ids:String(n),feed_ids:String(f.id)}))},m=()=>{s(le(t,a,{connection_ids:String(n),feed_ids:void 0}))};return e.jsx(he,{contentClassName:"w-72",searchPlaceholder:"Search feeds...",emptyText:d?"Loading feeds...":"No feeds",trigger:f=>e.jsx(De,{open:f,label:"Feed",value:u?Tt(u):void 0}),children:f=>e.jsxs(e.Fragment,{children:[c.size>0?e.jsx(q,{onSelect:()=>{m(),f()},className:"text-muted-foreground",children:"Clear feed"}):null,r.map(p=>e.jsxs(q,{onSelect:()=>{i(p),f()},className:"gap-2",children:[e.jsx(Ie,{className:Ee(c.has(String(p.id)))}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:Tt(p)})]},p.id))]})})}function Tt(t){return t.display_name?.trim()||t.feed_key}function at({to:t,params:n,label:o}){return e.jsx(Y,{to:t,params:n,onClick:s=>s.stopPropagation(),onPointerDown:s=>s.stopPropagation(),className:"shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity hover:text-foreground group-hover:opacity-100 focus-visible:opacity-100","aria-label":`Manage ${o}`,children:e.jsx(rs,{className:"h-3.5 w-3.5"})})}function Bo({to:t,params:n,label:o,onSelect:s}){return e.jsx(q,{asChild:!0,onSelect:s,className:"text-muted-foreground",children:e.jsxs(Y,{to:t,params:n,className:"flex items-center gap-2",children:[e.jsx(Ut,{className:"h-4 w-4 shrink-0"}),o]})})}function Ee(t){return t?"h-4 w-4 shrink-0 opacity-100":"h-4 w-4 shrink-0 opacity-0"}function zo({value:t,onChange:n,onClear:o,placeholder:s="Pick a date range",className:a,align:r="start"}){const d=t?.from!=null,c=d&&o!=null;return e.jsxs("div",{className:O("relative grid gap-2",a),children:[e.jsxs(Pt,{children:[e.jsx(Mt,{asChild:!0,children:e.jsxs(U,{id:"date",variant:"outline",className:O("relative w-full justify-start rounded-md bg-muted px-3 text-left font-normal",!d&&"text-muted-foreground",c&&"pr-8"),children:[e.jsx(ms,{className:"mr-2 h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:t?.from?t.to?e.jsxs(e.Fragment,{children:[He(t.from,"LLL dd, y")," -"," ",He(t.to,"LLL dd, y")]}):He(t.from,"LLL dd, y"):s})]})}),e.jsx(Ot,{className:"w-auto p-0",align:r,children:e.jsx(fo,{initialFocus:!0,mode:"range",defaultMonth:t?.from,selected:t,onSelect:n,numberOfMonths:2})})]}),c&&e.jsx("button",{type:"button","aria-label":"Clear date range",onClick:o,className:"absolute right-2 top-1/2 z-10 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground transition-colors hover:text-foreground",children:e.jsx(Te,{className:"h-3.5 w-3.5"})})]})}var sn=["PageUp","PageDown"],on=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],an={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},je="Slider",[et,Go,Uo]=ps(je),[rt]=vs(je,[Uo]),[Wo,Fe]=rt(je),it=h.forwardRef((t,n)=>{const{name:o,min:s=0,max:a=100,step:r=1,orientation:d="horizontal",disabled:c=!1,minStepsBetweenThumbs:u=0,defaultValue:i=[s],value:m,onValueChange:f=()=>{},onValueCommit:p=()=>{},inverted:v=!1,form:g,...x}=t,k=h.useRef(new Set),y=h.useRef(0),S=h.useRef(!1),j=d==="horizontal"?Ho:Qo,[L=[],T]=fs({prop:m,defaultProp:i,onChange:E=>{[...k.current][y.current]?.focus({preventScroll:!0,focusVisible:S.current}),S.current=!1,f(E)}}),w=h.useRef(L);function W(E){const $=qo(L,E);J(E,$)}function ae(E){J(E,y.current)}function re(){const E=w.current[y.current];L[y.current]!==E&&p(L)}function J(E,$,{commit:H}={commit:!1}){const ie=na(r),B=sa(Math.round((E-s)/r)*r+s,ie),A=Wt(B,[s,a]);T((M=[])=>{const z=Xo(M,A,$);if(ta(z,u*r)){y.current=z.indexOf(A);const G=String(z)!==String(M);return G&&H&&p(z),G?z:M}else return M})}return e.jsx(Wo,{scope:t.__scopeSlider,name:o,disabled:c,min:s,max:a,valueIndexToChangeRef:y,thumbs:k.current,values:L,orientation:d,form:g,children:e.jsx(et.Provider,{scope:t.__scopeSlider,children:e.jsx(et.Slot,{scope:t.__scopeSlider,children:e.jsx(j,{"aria-disabled":c,"data-disabled":c?"":void 0,...x,ref:n,onPointerDown:ye(x.onPointerDown,()=>{c||(w.current=L,S.current=!1)}),min:s,max:a,inverted:v,onSlideStart:c?void 0:W,onSlideMove:c?void 0:ae,onSlideEnd:c?void 0:re,onHomeKeyDown:()=>{c||(S.current=!0,J(s,0,{commit:!0}))},onEndKeyDown:()=>{c||(S.current=!0,J(a,L.length-1,{commit:!0}))},onStepKeyDown:({event:E,direction:$})=>{if(!c){S.current=!0;const B=sn.includes(E.key)||E.shiftKey&&on.includes(E.key)?10:1,A=y.current,M=L[A],z=r*B*$;J(M+z,A,{commit:!0})}}})})})})});it.displayName=je;var[rn,cn]=rt(je,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Ho=h.forwardRef((t,n)=>{const{min:o,max:s,dir:a,inverted:r,onSlideStart:d,onSlideMove:c,onSlideEnd:u,onStepKeyDown:i,...m}=t,[f,p]=h.useState(null),v=Le(n,C=>p(C)),g=h.useRef(void 0),x=hs(a),k=x==="ltr",y=k&&!r||!k&&r;function S(C){const j=g.current||f.getBoundingClientRect(),L=[0,j.width],w=ct(L,y?[o,s]:[s,o]);return g.current=j,w(C-j.left)}return e.jsx(rn,{scope:t.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:e.jsx(ln,{dir:x,"data-orientation":"horizontal",...m,ref:v,style:{...m.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:C=>{const j=S(C.clientX);d?.(j)},onSlideMove:C=>{const j=S(C.clientX);c?.(j)},onSlideEnd:()=>{g.current=void 0,u?.()},onStepKeyDown:C=>{const L=an[y?"from-left":"from-right"].includes(C.key);i?.({event:C,direction:L?-1:1})}})})}),Qo=h.forwardRef((t,n)=>{const{min:o,max:s,inverted:a,onSlideStart:r,onSlideMove:d,onSlideEnd:c,onStepKeyDown:u,...i}=t,m=h.useRef(null),f=Le(n,m),p=h.useRef(void 0),v=!a;function g(x){const k=p.current||m.current.getBoundingClientRect(),y=[0,k.height],C=ct(y,v?[s,o]:[o,s]);return p.current=k,C(x-k.top)}return e.jsx(rn,{scope:t.__scopeSlider,startEdge:v?"bottom":"top",endEdge:v?"top":"bottom",size:"height",direction:v?1:-1,children:e.jsx(ln,{"data-orientation":"vertical",...i,ref:f,style:{...i.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:x=>{const k=g(x.clientY);r?.(k)},onSlideMove:x=>{const k=g(x.clientY);d?.(k)},onSlideEnd:()=>{p.current=void 0,c?.()},onStepKeyDown:x=>{const y=an[v?"from-bottom":"from-top"].includes(x.key);u?.({event:x,direction:y?-1:1})}})})}),ln=h.forwardRef((t,n)=>{const{__scopeSlider:o,onSlideStart:s,onSlideMove:a,onSlideEnd:r,onHomeKeyDown:d,onEndKeyDown:c,onStepKeyDown:u,...i}=t,m=Fe(je,o);return e.jsx(Ae.span,{...i,ref:n,onKeyDown:ye(t.onKeyDown,f=>{f.key==="Home"?(d(f),f.preventDefault()):f.key==="End"?(c(f),f.preventDefault()):sn.concat(on).includes(f.key)&&(u(f),f.preventDefault())}),onPointerDown:ye(t.onPointerDown,f=>{const p=f.target;p.setPointerCapture(f.pointerId),f.preventDefault(),m.thumbs.has(p)?p.focus({preventScroll:!0,focusVisible:!1}):s(f)}),onPointerMove:ye(t.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&a(f)}),onPointerUp:ye(t.onPointerUp,f=>{const p=f.target;p.hasPointerCapture(f.pointerId)&&(p.releasePointerCapture(f.pointerId),r(f))})})}),dn="SliderTrack",un=h.forwardRef((t,n)=>{const{__scopeSlider:o,...s}=t,a=Fe(dn,o);return e.jsx(Ae.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...s,ref:n})});un.displayName=dn;var tt="SliderRange",mn=h.forwardRef((t,n)=>{const{__scopeSlider:o,...s}=t,a=Fe(tt,o),r=cn(tt,o),d=h.useRef(null),c=Le(n,d),u=a.values.length,i=a.values.map(p=>bn(p,a.min,a.max)),m=u>1?Math.min(...i):0,f=100-Math.max(...i);return e.jsx(Ae.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...s,ref:c,style:{...t.style,[r.startEdge]:m+"%",[r.endEdge]:f+"%"}})});mn.displayName=tt;var fn="SliderThumb",[Yo,pn]=rt(fn),hn="SliderThumbProvider";function xn(t){const{__scopeSlider:n,name:o,children:s,internal_do_not_use_render:a}=t,r=Fe(hn,n),d=Go(n),[c,u]=h.useState(null),i=h.useMemo(()=>c?d().findIndex(k=>k.ref.current===c):-1,[d,c]),m=xs(c),f=c?!!r.form||!!c.closest("form"):!0,p=r.values[i],v=o??(r.name?r.name+(r.values.length>1?"[]":""):void 0),g=p===void 0?0:bn(p,r.min,r.max);h.useEffect(()=>{if(c)return r.thumbs.add(c),()=>{r.thumbs.delete(c)}},[c,r.thumbs]);const x={value:p,name:v,form:r.form,isFormControl:f,index:i,thumb:c,onThumbChange:u,percent:g,size:m};return e.jsx(Yo,{scope:n,...x,children:oa(a)?a(x):s})}xn.displayName=hn;var Re="SliderThumbTrigger",gn=h.forwardRef((t,n)=>{const{__scopeSlider:o,...s}=t,a=Fe(Re,o),r=cn(Re,o),{index:d,value:c,percent:u,size:i,onThumbChange:m}=pn(Re,o),f=Le(n,x=>m(x)),p=Zo(d,a.values.length),v=i?.[r.size],g=v?Jo(v,u,r.direction):0;return e.jsx("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[r.startEdge]:`calc(${u}% + ${g}px)`},children:e.jsx(et.ItemSlot,{scope:o,children:e.jsx(Ae.span,{role:"slider","aria-label":t["aria-label"]||p,"aria-valuemin":a.min,"aria-valuenow":c,"aria-valuemax":a.max,"aria-orientation":a.orientation,"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,tabIndex:a.disabled?void 0:0,...s,ref:f,style:c===void 0?{display:"none"}:t.style,onFocus:ye(t.onFocus,()=>{a.valueIndexToChangeRef.current=d})})})})});gn.displayName=Re;var nt=h.forwardRef((t,n)=>{const{__scopeSlider:o,name:s,...a}=t;return e.jsx(xn,{__scopeSlider:o,name:s,internal_do_not_use_render:({index:r,isFormControl:d})=>e.jsxs(e.Fragment,{children:[e.jsx(gn,{...a,ref:n,__scopeSlider:o}),d?e.jsx(yn,{__scopeSlider:o},r):null]})})});nt.displayName=fn;var vn="SliderBubbleInput",yn=h.forwardRef(({__scopeSlider:t,...n},o)=>{const{value:s,name:a,form:r}=pn(vn,t),d=h.useRef(null),c=Le(d,o),u=gs(s);return h.useEffect(()=>{const i=d.current;if(!i)return;const m=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(m,"value").set;if(u!==s&&p){const v=new Event("input",{bubbles:!0});p.call(i,s),i.dispatchEvent(v)}},[u,s]),e.jsx(Ae.input,{style:{display:"none"},name:a,form:r,...n,ref:c,defaultValue:s})});yn.displayName=vn;function Xo(t=[],n,o){const s=[...t];return s[o]=n,s.sort((a,r)=>a-r)}function bn(t,n,o){const r=100/(o-n)*(t-n);return Wt(r,[0,100])}function Zo(t,n){return n>2?`Value ${t+1} of ${n}`:n===2?["Minimum","Maximum"][t]:void 0}function qo(t,n){if(t.length===1)return 0;const o=t.map(a=>Math.abs(a-n)),s=Math.min(...o);return o.indexOf(s)}function Jo(t,n,o){const s=t/2,r=ct([0,50],[0,s]);return(s-r(n)*o)*o}function ea(t){return t.slice(0,-1).map((n,o)=>t[o+1]-n)}function ta(t,n){if(n>0){const o=ea(t);return Math.min(...o)>=n}return!0}function ct(t,n){return o=>{if(t[0]===t[1]||n[0]===n[1])return n[0];const s=(n[1]-n[0])/(t[1]-t[0]);return n[0]+s*(o-t[0])}}function na(t){if(!Number.isFinite(t))return 0;const n=t.toString();if(n.includes("e")){const[s,a]=n.split("e"),r=s.split(".")[1]||"",d=Number(a);return Math.max(0,r.length-d)}const o=n.split(".")[1];return o?o.length:0}function sa(t,n){const o=Math.pow(10,n);return Math.round(t*o)/o}function oa(t){return typeof t=="function"}const jn=h.forwardRef(({className:t,...n},o)=>e.jsxs(it,{ref:o,className:O("relative flex w-full touch-none select-none items-center",t),...n,children:[e.jsx(un,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:e.jsx(mn,{className:"absolute h-full bg-primary"})}),e.jsx(nt,{className:"block h-4 w-4 rounded-full border border-primary/50 bg-background transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"}),n.value&&n.value.length>1&&e.jsx(nt,{className:"block h-4 w-4 rounded-full border border-primary/50 bg-background transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"})]}));jn.displayName=it.displayName;const aa=["notification"],ra=["note","summary","decision","observation","fact","change","preference","identity"],ia=[...aa,...ra],ca="date-desc",It=[{value:"date-desc",label:"Newest first"},{value:"date-asc",label:"Oldest first"},{value:"score-desc",label:"Highest score"},{value:"score-asc",label:"Lowest score"}],At=[{value:"all",label:"Any reviewer"},{value:"user",label:"Manual review"},{value:"system",label:"Auto-classified"},{value:"llm",label:"LLM-classified"}],Lt=[{value:"all",label:"Any status"},{value:"pending",label:"Pending approval"},{value:"approved",label:"Approved"},{value:"rejected",label:"Rejected"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}];function Ye(t,n){return e.jsxs("span",{className:"truncate",children:[e.jsxs("span",{className:"text-muted-foreground",children:[t,": "]}),n]})}function Ve(t){const n=t.replace(/[_-]+/g," ").trim();return n.length>0?`${n.charAt(0).toUpperCase()}${n.slice(1)}`:t}function la({options:t,selected:n,onChange:o}){return e.jsx(he,{contentClassName:"w-72",searchPlaceholder:"Search event kinds...",emptyText:"No event kinds found",trigger:s=>e.jsxs(U,{variant:"outline","aria-expanded":s,className:"h-9 rounded-md bg-muted px-3 py-2 font-normal",children:["Kind",n.length>0?e.jsx(_e,{variant:"secondary",className:"h-5 px-1.5",children:n.length}):null]}),children:()=>t.map(s=>{const a=n.includes(s);return e.jsxs(q,{value:`${Ve(s)} ${s}`,onSelect:()=>o(a?n.filter(r=>r!==s):[...n,s]),children:[e.jsx(Kt,{checked:a,className:"mr-1"}),Ve(s)]},s)})})}function wn({"aria-label":t,onClick:n}){return e.jsx("button",{type:"button","aria-label":t,onClick:o=>{o.preventDefault(),o.stopPropagation(),n()},className:"rounded-sm p-0.5 text-muted-foreground transition-colors hover:text-foreground",children:e.jsx(Te,{className:"h-3.5 w-3.5"})})}function Xe({value:t,onValueChange:n,onClear:o,showClear:s,triggerClassName:a,displayValue:r,children:d}){return e.jsxs("div",{className:"relative shrink-0",children:[e.jsxs(ws,{value:t,onValueChange:n,children:[e.jsx(Ns,{className:O("px-2.5",s&&"pr-9",a),children:e.jsx(Ss,{children:r})}),e.jsx(ks,{children:d})]}),s&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-8 flex items-center",children:e.jsx("div",{className:"pointer-events-auto",children:e.jsx(wn,{"aria-label":"Clear filter",onClick:o})})})]})}function da({filters:t,onFiltersChange:n,connectors:o,eventKinds:s=[],searchQuery:a,onSearchChange:r,hideSourceFilter:d=!1,ownerSlug:c,total:u,isListLoading:i=!1,hasCursorInUrl:m=!1,onGoToLatest:f,open:p,onOpenChange:v,leading:g}){const x=a.trim().length>0,[k,y]=h.useState(x),S=p??k,C=v??y,j=t.dateRange?{from:t.dateRange[0],to:t.dateRange[1]}:void 0,L=N=>{N?.from&&N?.to?n({dateRange:[N.from,N.to]}):n({dateRange:null})},T=N=>{const X=t.platforms||[],_=X.includes(N)?X.filter(ue=>ue!==N):[...X,N];n({platforms:_})},w=`${t.sortBy??"date"}-${t.sortOrder??"desc"}`,W=t.reviewStatus||"all",ae=t.interactionStatus||"all",re=!!(t.dateRange?.[0]&&t.dateRange?.[1]),J=(t.engagementRange?.[0]??0)!==0||(t.engagementRange?.[1]??100)!==100,E=(t.platforms?.length??0)>0,$=t.semanticTypes??[],H=$.length>0,ie=!!(t.reviewStatus&&t.reviewStatus!=="all"),B=!!(t.interactionStatus&&t.interactionStatus!=="all"),A=(x?1:0)+(re?1:0)+(E?1:0)+(H?1:0)+(ie?1:0)+(B?1:0)+(J?1:0),M=s.length>0?s:ia,z=[...new Set([...M,...$])].sort((N,X)=>Ve(N).localeCompare(Ve(X))),G=It.find(N=>N.value===w)?.label??"Newest first",ee=At.find(N=>N.value===W)?.label??"Any reviewer",Q=Lt.find(N=>N.value===ae)?.label??"Any status",ne=e.jsxs("div",{className:"relative w-52 shrink-0",children:[e.jsx(ys,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(bs,{placeholder:d?"Search events...":"Search...",value:a,onChange:N=>r(N.target.value),className:O("pl-9",x&&"pr-8")}),x&&e.jsx("div",{className:"absolute inset-y-0 right-2 flex items-center",children:e.jsx(wn,{"aria-label":"Clear search",onClick:()=>r("")})})]}),fe=e.jsx(Xe,{value:w,onValueChange:N=>{const[X,_]=N.split("-");n({sortBy:X,sortOrder:_})},onClear:()=>n({sortBy:void 0,sortOrder:void 0}),showClear:w!==ca,triggerClassName:"w-[168px]",displayValue:Ye("Sort",G),children:It.map(N=>e.jsx(Qe,{value:N.value,children:N.label},N.value))}),de=e.jsx(Xe,{value:W,onValueChange:N=>n({reviewStatus:N}),onClear:()=>n({reviewStatus:void 0}),showClear:W!=="all",triggerClassName:"w-[186px]",displayValue:Ye("Review",ee),children:At.map(N=>e.jsx(Qe,{value:N.value,children:N.label},N.value))}),xe=e.jsx(Xe,{value:ae,onValueChange:N=>n({interactionStatus:N==="all"?null:N}),onClear:()=>n({interactionStatus:null}),showClear:ae!=="all",triggerClassName:"w-[178px]",displayValue:Ye("Approval",Q),children:Lt.map(N=>e.jsx(Qe,{value:N.value,children:N.label},N.value))}),we=e.jsxs("div",{className:"w-72 space-y-2 px-1 py-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{children:"Engagement score"}),e.jsxs("span",{className:"text-muted-foreground",children:[t.engagementRange?.[0]??0," –"," ",t.engagementRange?.[1]??100]})]}),e.jsx(jn,{value:t.engagementRange||[0,100],onValueChange:N=>n({engagementRange:N}),min:0,max:100,step:5})]}),K=e.jsx(la,{options:z,selected:$,onChange:N=>n({semanticTypes:N.length>0?N:void 0})});return e.jsxs(Ht,{open:S,onOpenChange:C,className:"w-full",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2.5",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 text-sm text-muted-foreground",children:[g,i?e.jsx(Qt,{className:"h-4 w-20"}):u!=null&&u>0?e.jsx("span",{children:`${u.toLocaleString()} items`}):e.jsx("span",{}),!i&&u!=null&&u>0&&m&&f&&e.jsxs(U,{variant:"ghost",size:"sm",className:"h-7 gap-1",onClick:f,children:[e.jsx(js,{className:"h-3.5 w-3.5"}),"Back to latest"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[fe,e.jsx(Yt,{asChild:!0,children:e.jsxs(U,{variant:"outline",className:"h-9 rounded-md bg-muted px-3 py-2 font-normal",children:["Filters",A>0?e.jsx(_e,{variant:"secondary",className:"ml-1.5 h-5 px-1.5 text-[11px]",children:A}):null,e.jsx(ze,{className:O("ml-1 h-4 w-4 transition-transform",S&&"rotate-180")})]})})]})]}),e.jsx(Xt,{className:"pt-2.5",children:e.jsxs("div",{className:"flex flex-wrap items-start gap-2.5 border-t pt-3",children:[ne,d&&c?e.jsx(Po,{ownerSlug:c,visibility:"all"}):null,!d&&o.length>0?e.jsx(Eo,{connectors:o,selectedKeys:t.platforms||[],onToggle:T}):null,e.jsx(zo,{value:j,onChange:L,onClear:()=>n({dateRange:null}),placeholder:"Date range",className:"w-auto shrink-0"}),K,de,xe,we,A>0&&e.jsx(U,{type:"button",variant:"ghost",size:"sm",className:"h-9 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{r(""),n({dateRange:null,platforms:void 0,semanticTypes:void 0,reviewStatus:void 0,interactionStatus:null,engagementRange:void 0})},children:"Clear all"})]})})]})}function ua(t){const n=t instanceof Date?t:new Date(String(t));return Number.isNaN(n.getTime())?null:n}function Dt(t){return t.toISOString().split("T")[0]}function ma({entityId:t,organizationId:n,ownerSlug:o,selectedRange:s,onSelectRange:a}){const{data:r,isLoading:d,error:c}=Cs(n,{entityId:t},{slug:o}),u=h.useMemo(()=>{if(!r||r.length===0)return[];const p=r.map(y=>{const S=ua(y.date);return S?{date:S,count:y.count}:null}).filter(y=>y!==null).sort((y,S)=>y.date.getTime()-S.date.getTime());if(p.length===0)return[];const v=p[0].date;if((p[p.length-1].date.getTime()-v.getTime())/(1e3*60*60*24)>180){const y=new Map;for(const S of p){const C=new Date(S.date);C.setDate(S.date.getDate()-S.date.getDay());const j=Dt(C);y.set(j,(y.get(j)||0)+S.count)}return Array.from(y.entries()).map(([S,C])=>({date:S,count:C})).sort((S,C)=>new Date(S.date).getTime()-new Date(C.date).getTime())}return p.map(y=>({date:Dt(y.date),count:y.count}))},[r]),i=h.useCallback(p=>{if(p.name&&a){const v=new Date(p.name),g=new Date(v);g.setDate(g.getDate()+1),a(v,g)}},[a]),m=h.useCallback(p=>{if(a&&p.startValue!==void 0&&p.endValue!==void 0){const v=new Date(p.startValue),g=new Date(p.endValue);a(v,g)}},[a]),f=h.useMemo(()=>{if(u.length===0)return null;let p;if(s){const v=s[0].toISOString().split("T")[0],g=s[1].toISOString().split("T")[0];p=[[{xAxis:v},{xAxis:g}]]}return{tooltip:{trigger:"axis",axisPointer:{type:"line"},formatter:v=>{const g=v[0];return`${new Date(g.name).toLocaleDateString()}: ${g.value} items`}},grid:{left:50,right:20,top:20,bottom:60},xAxis:{type:"category",boundaryGap:!1,data:u.map(v=>v.date),axisLabel:{formatter:v=>{const g=new Date(v);return`${g.getMonth()+1}/${g.getDate()}`}}},yAxis:{type:"value",minInterval:1,splitLine:{lineStyle:{color:"rgba(0,0,0,0.05)"}}},dataZoom:[{type:"slider",start:0,end:100,height:20,bottom:10,borderColor:"transparent",backgroundColor:"rgba(0,0,0,0.02)",fillerColor:"rgba(99, 102, 241, 0.1)",handleStyle:{color:"#6366f1"}}],series:[{type:"line",smooth:!0,areaStyle:{opacity:.3,color:new po(0,0,0,1,[{offset:0,color:"rgba(99, 102, 241, 0.5)"},{offset:1,color:"rgba(99, 102, 241, 0.05)"}])},lineStyle:{width:2,color:"#6366f1"},itemStyle:{color:"#6366f1"},showSymbol:!1,data:u.map(v=>v.count),markLine:{silent:!0,symbol:"none",label:{position:"insideEndTop",formatter:"avg: {c}",fontSize:10,color:"#9ca3af"},lineStyle:{color:"#d1d5db",type:"dashed",width:1},data:[{type:"average",name:"Average"}]},markArea:p?{silent:!0,itemStyle:{color:"rgba(99, 102, 241, 0.1)"},data:p}:void 0}]}},[u,s]);return d||c?e.jsx("div",{className:O(Zt,"p-4"),children:e.jsx("div",{className:"flex h-48 w-full items-center justify-center",children:d?e.jsx(xo,{}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to load timeline"})})}):!f||u.length<2?null:e.jsx(fa,{option:f,onClick:i,onDataZoom:m})}function fa({option:t,onClick:n,onDataZoom:o}){const{chartRef:s,setOption:a}=ho({onClick:n,onDataZoom:o});return h.useEffect(()=>{a(t,!0)},[t,a]),e.jsx("div",{"data-testid":"events-timeline",className:O(Zt,"p-4 relative"),children:e.jsx("div",{ref:s,className:"h-48 w-full"})})}function pa({organizationId:t,ownerSlug:n,entityId:o,hideSourceFilter:s=!1,scopedEntityTypes:a,filterBarLeading:r}){const{isAuthenticated:d,isReady:c}=_s(),{isMember:u,isLoading:i}=qt(),m=c&&d&&u,f=c&&(!d||!i&&!u),p=me(),v=st(),g=Jt(v.search??{}),{filters:x,updateFilters:k,clearFilters:y}=wo({parse:zs,serialize:Us,filterKeys:Gs,merge:Ws}),[S,C]=h.useState(x.searchQuery||""),[j,L]=h.useState((x.searchQuery||"").trim().length>0),T=Ts(S,1e3),w=h.useMemo(()=>wt({...x,searchQuery:T.length>=3?T:void 0,...a?.length?{entityTypes:a}:{}}),[x,T,a]),W=k;h.useEffect(()=>{const l=T.length>=3?T:void 0;(x.searchQuery||void 0)!==l&&k({searchQuery:l})},[T,k,x.searchQuery]);const ae=()=>{C(""),y()},re=h.useMemo(()=>Is(wt({...x,searchQuery:T.length>=3?T:void 0})),[x,T]),J=o===void 0,{data:E=[]}=As(c&&m?t:null),{data:$=[]}=Ls(f?n:null),H=m?E:$,{data:ie=[]}=Bt(m&&t?{organizationId:t}:void 0),B=jo(),A=w.connectionIds,M=(A?.length??0)>0,{data:z=[]}=Ds(c&&m?t??"":"",{connectionIds:A??void 0,enabled:!B&&c&&m&&M}),G=w.feedIds,ee=(G?.length??0)>0,{data:Q=[]}=Es(c&&m?t:null,{feedIds:G??void 0,enabled:c&&m&&ee}),ne=h.useMemo(()=>B?B.groups.flatMap(l=>l.connections.map(b=>({id:b.id,display_name:b.display_name,connector_name:l.connector_name,connector_key:l.connector_key}))):z,[z,B]),fe=h.useMemo(()=>{const l=new Set(A??[]);return[...new Set([...w.platforms??[],...ne.filter(b=>l.has(b.id)).map(b=>b.connector_key)])]},[A,ne,w.platforms]),de=h.useMemo(()=>Q.map(l=>({connectorKey:l.connector_key,feedKey:l.feed_key})),[Q]),xe=h.useMemo(()=>M&&fe.length===0||ee&&de.length===0?[]:Do({connectors:H,entityTypes:ie,selectedPlatforms:fe,selectedFeeds:de,selectedEntityTypes:w.entityTypes}),[H,w.entityTypes,M,ee,fe,de,ie]),we=h.useMemo(()=>M?No(A??[],ne):null,[A,ne,M]),K=w.clientIds,N=(K?.length??0)>0,{data:X=[]}=lo(null,{enabled:c&&m&&N}),_=h.useMemo(()=>{if(!K)return[];const l=new Set(K);return uo(X).filter(b=>b.clientIds.some(I=>l.has(I)))},[K,X]),ue=h.useMemo(()=>{if(!N||!K)return null;const l=_.map(b=>b.title);return l.length>0?`From ${l.join(", ")}`:`Filtered by client${K.length>1?" registrations":""}`},[_,K,N]),Pe=_.length===1?_[0]:null,Nn=n&&Pe?_o(n,Pe.clientId):void 0,Me=w.mcpActivityId??null,{data:lt=[]}=Fs({enabled:c&&m&&N&&!!Me,clientIds:K??[],limit:100}),Sn=h.useMemo(()=>{if(!Me)return null;const l=lt.find(I=>I.activityId===Me);if(!l)return"Selected conversation";const b=l.title?.trim();return b?`Conversation “${b}”`:l.activityKind==="session"?"MCP session":`Conversation ${l.clientId}`},[Me,lt]),kn=h.useMemo(()=>ee?So(G??[],Q):null,[G,ee,Q]),F=w.agentId,{data:dt=[]}=Be({enabled:c&&!!F}),Cn=h.useMemo(()=>{if(!F||w.automationId!=null||g||(w.platforms?.length??0)>0)return null;const l=dt.find(b=>b.agentId===F);return l?`From agent ${l.name}`:`From agent ${F}`},[F,w.platforms,w.automationId,g,dt]),se=w.automationId,{data:ut=[]}=en(F??void 0,{includeDetails:!1}),_n=h.useMemo(()=>{if(se==null)return null;const l=ut.find(b=>String(b.automation_id)===String(se));return l?`From watch “${l.name}”`:`From Automation #${se}`},[ut,se]),{data:mt=[]}=nn(F??void 0),Tn=h.useMemo(()=>{if(!g||!F)return null;const l=mt.find(b=>b.id===g);return l?.description?.trim()?`From schedule “${l.description.trim()}”`:"From scheduled task"},[F,g,mt]),Ge=h.useMemo(()=>{if(!F||se!=null||g||(w.platforms?.length??0)===0)return null;const l=w.platforms?.[0];return l?`From ${l} listen`:null},[F,w.platforms,g,se]),ge=h.useMemo(()=>{if(!n)return{};const l={};if(ee&&G?.length===1){const b=Q.find(I=>I.id===G[0]);b&&(l.feedIds=ko(n,b))}if(M&&A?.length===1){const b=ne.find(I=>I.id===A[0]);b?.connector_key&&(l.connectionIds=Co(n,{id:b.id,connector_key:b.connector_key}))}return F&&se==null&&!g&&(w.platforms?.length??0)===0&&(l.agentId=Ct(n,F)),F&&se!=null&&(l.automationId=To(n,String(se))),F&&g&&(l.schedule=Io(n,F,g)),Ge&&F&&(l.listen=Ct(n,F)),l},[F,A,ne,G,M,ee,w.platforms,Ge,n,g,se,Q]),{data:In}=Ps(c&&m?t:null,o),{data:An}=Ms(f&&!J?n:null,o),ft=m?In:An,Ue=h.useMemo(()=>{const l=new Map;for(const b of ft||[]){const I=b.automation_name??"__global__";l.has(I)||l.set(I,{automationName:b.automation_name??null,classifiers:[]});const P=l.get(I),R=b.attribute_values||{},te=Object.keys(R);let oe=null;const D={};for(const[V,ce]of Object.entries(R))if(ce.parent)for(const[ve,Se]of Object.entries(ce.parent))oe=ve,D[Se]||(D[Se]=[]),D[Se].push(V);const Z=P.classifiers.find(V=>V.slug===b.slug);if(Z){const V=new Set([...Z.values,...te]);Z.values=[...V];for(const[ce,ve]of Object.entries(D)){Z.valuesByParentValue[ce]||(Z.valuesByParentValue[ce]=[]);const Se=new Set([...Z.valuesByParentValue[ce],...ve]);Z.valuesByParentValue[ce]=[...Se]}oe&&(Z.parentSlug=oe)}else P.classifiers.push({slug:b.slug,name:b.name,values:te,parentSlug:oe,valuesByParentValue:D})}for(const b of l.values())b.classifiers.sort((I,P)=>I.parentSlug===null&&P.parentSlug!==null?-1:I.parentSlug!==null&&P.parentSlug===null?1:0);return[...l.values()]},[ft]),Ln=h.useMemo(()=>{const l=new Map(H.map(I=>[I.key,I]));return[...new Set(l.keys())].map(I=>{const P=l.get(I);return{key:I,name:P?.name||I,description:P?.description,icon:P?.icon,faviconDomain:$s(P?.auth_schema)}}).sort((I,P)=>I.name.localeCompare(P.name))},[H]),Dn=Rs(c&&m?t:null,o,w,n),En=Os(f?n:null,o,w),Fn=f?En:Dn,{data:Ne,isLoading:Pn,error:Mn}=Fn,pt=Ne?.pages[0],ht=pt?.total??0,xt=pt?.classification_stats,$n=!!(w.beforeOccurredAt||w.afterOccurredAt),gt=Ks(w),vt=Ne?.pages[Ne.pages.length-1],pe=vt?.content[vt.content.length-1];h.useEffect(()=>{!gt||!pe||Ne?.pages.length===1||x.beforeOccurredAt===pe.occurred_at&&x.beforeId===pe.id||k({beforeOccurredAt:pe.occurred_at,beforeId:pe.id})},[pe?.id,gt,k,Ne?.pages.length,pe,x.beforeOccurredAt,x.beforeId]);const Rn=h.useCallback(()=>{W({beforeOccurredAt:void 0,beforeId:void 0,afterOccurredAt:void 0,afterId:void 0}),window.scrollTo({top:0,behavior:"smooth"})},[W]),[yt,On]=h.useState(new Set),Kn=l=>{const b=new Set(yt);b.has(l)?b.delete(l):b.add(l),On(b)},Vn=(l,b)=>{W({dateRange:[l,b]})},bt=(l,b)=>{const I=w.classificationFilters||{},P=I[l]||[],R=P.includes(b)?P.filter(oe=>oe!==b):[...P,b],te={...I};if(R.length>0)te[l]=R;else{delete te[l];for(const oe of Ue)for(const D of oe.classifiers)D.parentSlug===l&&delete te[D.slug]}W({classificationFilters:te})};if(Mn)return e.jsx(Vs,{label:"knowledge"});const We=!c||d&&i||Pn,Bn=!We&&ht===0&&!re,zn=d?m?"Activity is the workspace's live feed — every message, email, file, and record a connector pulls in lands here as an event. Connect your data to start collecting.":"Activity is the workspace's live feed of connector events. Join this workspace to add connectors and collect knowledge here.":"No public knowledge items are available yet",jt=!!(m&&n);return e.jsx(Bs,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:s?"sticky top-0 z-10 -mx-4 space-y-3 bg-background px-4 pb-3 lg:-mx-6 lg:px-6":void 0,children:e.jsx(da,{leading:r,open:j,onOpenChange:L,filters:w,onFiltersChange:W,connectors:Ln,eventKinds:xe,searchQuery:S,onSearchChange:C,hideSourceFilter:s,ownerSlug:n,total:ht,isListLoading:We,hasCursorInUrl:$n,onGoToLatest:Rn})}),[{key:"contentIds",label:l=>`Showing knowledge item #${l.join(", #")}`,ids:w.contentIds,clear:{contentIds:void 0}},{key:"runId",label:l=>`Filtered by Automation run #${l}`,id:w.runId,clear:{runId:void 0}},{key:"feedIds",text:kn,sourceLink:ge.feedIds,clear:{feedIds:void 0}},{key:"connectionIds",text:we,sourceLink:ge.connectionIds,clear:{connectionIds:void 0}},{key:"mcpActivityId",text:Sn,clear:{mcpActivityId:void 0}},{key:"clientIds",text:ue,sourceLink:Nn,details:K&&K.length>0?e.jsx(Lo,{ownerSlug:n,clientIds:K,linkedUser:Pe?.linkedUser,linkedUserEntitySlug:Pe?.linkedUserEntitySlug}):void 0,clear:{clientIds:void 0}},{key:"automationId",text:_n,sourceLink:ge.automationId,clear:{automationId:void 0}},{key:"schedule",text:Tn,sourceLink:ge.schedule,clear:{schedule:void 0,runIds:void 0}},{key:"listen",text:Ge,sourceLink:ge.listen,clear:{platforms:void 0,connectionIds:void 0}},{key:"agentId",text:Cn,sourceLink:ge.agentId,clear:{agentId:void 0,automationId:void 0,schedule:void 0,platforms:void 0}},{key:"runIds",label:l=>`Filtered by run${l.length>1?"s":""} #${l.join(", #")}`,ids:w.runIds,clear:{runIds:void 0,schedule:void 0}}].map(l=>{const b="text"in l&&l.text?l.text:"ids"in l&&l.ids&&l.ids.length>0?l.label(l.ids):"id"in l&&l.id!=null?l.label(l.id):null;return b?e.jsx(Ao,{text:b,sourceLink:"sourceLink"in l?l.sourceLink:void 0,details:"details"in l?l.details:void 0,onClear:()=>W(l.clear)},l.key):null}).filter(Boolean),j&&m&&o&&t&&e.jsx(ma,{entityId:o,organizationId:t,ownerSlug:n||"",selectedRange:w.dateRange||void 0,onSelectRange:Vn}),Ue.length>0&&e.jsx("div",{className:"space-y-2",children:Ue.map(l=>{const b=l.automationName??"__global__",I=l.classifiers.some(R=>(w.classificationFilters?.[R.slug]?.length||0)>0),P=yt.has(b)||I;return e.jsxs(Ht,{open:P,onOpenChange:()=>Kn(b),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Yt,{asChild:!0,children:e.jsx(U,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:P?e.jsx(ze,{className:"h-3.5 w-3.5"}):e.jsx(tn,{className:"h-3.5 w-3.5"})})}),l.automationName&&e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:l.automationName})]}),e.jsx(Xt,{className:"space-y-1.5 mt-1.5 ml-6",children:l.classifiers.filter(R=>R.parentSlug===null).map(R=>{const te=w.classificationFilters?.[R.slug]||[],oe=l.classifiers.filter(D=>D.parentSlug===R.slug);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:R.name}),R.values.map(D=>{const Z=te.includes(D),V=xt?.[R.slug]?.[D];return e.jsxs(_e,{variant:Z?"default":"outline",className:"cursor-pointer",onClick:()=>bt(R.slug,D),children:[D,V!=null&&e.jsx("span",{className:"ml-1 opacity-60",children:V})]},D)})]}),te.length>0&&oe.map(D=>{const Z=[...new Set(te.flatMap(V=>D.valuesByParentValue[V]||[]))];return Z.length===0?null:e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 ml-4 mt-1.5",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:D.name}),Z.map(V=>{const ce=w.classificationFilters?.[D.slug]?.includes(V),ve=xt?.[D.slug]?.[V];return e.jsxs(_e,{variant:ce?"default":"outline",className:"cursor-pointer",onClick:()=>bt(D.slug,V),children:[V,ve!=null&&e.jsx("span",{className:"ml-1 opacity-60",children:ve})]},V)})]},D.slug)})]},R.slug)})})]},b)})}),We?e.jsx("div",{className:"space-y-4",children:["skeleton-1","skeleton-2","skeleton-3","skeleton-4","skeleton-5"].map(l=>e.jsx(Qt,{className:"h-32 rounded-lg"},l))}):Bn?e.jsx(Oe,{icon:Nt,title:"No activity yet",description:zn,actionLabel:jt?"Add a connector":void 0,onAction:jt&&n?()=>void p({to:"/$owner/connectors/create",params:{owner:n}}):void 0}):e.jsx(mo,{organizationId:t,ownerSlug:n,entityId:o,filters:w,showEntityLinks:J,emptyState:e.jsx(Oe,{icon:Nt,title:"No results found",description:"Try adjusting your filters to find what you are looking for",actionLabel:re?"Clear filters":void 0,onAction:re?ae:void 0})})]})})}function ha(t){const n=Hs();return e.jsx(xa,{...t,context:n},`${t.ownerSlug}:${t.attentionLens}:${Qs(n)}`)}function xa({organizationId:t,ownerSlug:n,typeScope:o,entityScope:s,agentScope:a,automationScope:r,scheduleScope:d,attentionLens:c=!1,activityTab:u="events",context:i}){const[m,f]=h.useState(c?"relevant":"activity"),p=i?m!=="activity":c,{orgContext:v}=Vt(),{isMember:g,isLoading:x}=qt(),k=g&&!!t,y=Ft(),S=u==="sessions"&&y,{attentionItems:C}=Ys(n),j=C.length,L=i?e.jsx("fieldset",{"aria-label":"Activity view",className:O("flex min-w-0 max-w-full items-center gap-1",y&&"justify-center"),children:[["relevant","Relevant here"],["attention","Needs attention"],["activity","All activity"]].map(([_,ue])=>e.jsxs("button",{type:"button","aria-pressed":m===_,onClick:()=>f(_),className:"flex min-w-0 items-center justify-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground transition-colors aria-pressed:bg-muted aria-pressed:text-foreground hover:text-foreground",children:[ue,_==="attention"?e.jsx(Et,{count:j}):null]},_))}):e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Y,{to:"/$owner/events",params:{owner:n},search:_=>({..._??{}}),"aria-current":p?void 0:"page",className:O("rounded-md px-2.5 py-1 text-xs font-medium transition-colors",p?"text-muted-foreground hover:text-foreground":"bg-muted text-foreground"),children:"All activity"}),e.jsxs(Y,{to:"/$owner",params:{owner:n},search:_=>({..._??{}}),"aria-current":p?"page":void 0,className:O("flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs font-medium transition-colors",p?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"),children:["Needs attention",e.jsx(Et,{count:j})]})]}),{data:T=[]}=Be(),w=a?T.find(_=>_.agentId===a)?.name??a:void 0,{data:W=[]}=en(a,{includeDetails:!1}),ae=r?W.find(_=>_.automation_id===r)?.name??`Automation ${r}`:void 0,{data:re=[]}=nn(a),J=d?re.find(_=>_.id===d)?.description??"Schedule":void 0,E=o?Ce(o):void 0,{data:$,isLoading:H,error:ie}=Xs(s?`/${n}/${Zs(s)}`:p?`/${n}`:"",v),B=s?$?.entity:void 0,A=s?B?.entity_type??Ce(s.split("/").at(-2)??""):E,M=A==="$member",z=s!=null&&!H&&(ie!=null||$?.entity==null),{data:G}=qs(A??"",v),ee=x||H,Q=$?.counts,ne=Q?Q.connections>0||Q.agents>0||Q.clients>0:!1,fe=k&&!ee&&Q!=null&&!ne,de={},xe=a?{agent:a}:{},we=A?{type:A}:{},K=s?e.jsx(Ze,{icon:B?.entity_type?e.jsx(Gt,{icon:G?.icon,className:"h-4 w-4 shrink-0"}):null,typeSegment:A?{label:G?.name??Ce(A),search:we}:void 0,label:B?.name??s.split("/").slice(-1)[0],ownerSlug:n,clearSearch:{}}):r&&a?e.jsx(Ze,{typeSegment:{label:w??"Agent",search:de},label:ae??"Automation",ownerSlug:n,clearSearch:xe}):d&&a?e.jsx(Ze,{typeSegment:{label:w??"Agent",search:de},label:J??"Schedule",ownerSlug:n,clearSearch:xe}):null,N=!y&&!S&&!z,X=s&&H?e.jsx(St,{label:"Loading record…"}):z?e.jsx(Oe,{icon:Js,title:"Record not found",description:"This record no longer exists."}):e.jsx(pa,{organizationId:t,ownerSlug:n,filterBarLeading:N?L:void 0,hideSourceFilter:!0,entityId:B?.id,scopedEntityTypes:!s&&E?[E]:void 0});if(p){const _=ee?e.jsx(St,{label:"workspace setup",variant:"panel",className:"px-6 py-8"}):fe?e.jsx("div",{className:"px-6",children:e.jsx(Oe,{icon:no,title:"Nothing to catch up on — yet",description:"No notifications here. Add a connector to bring in data, or bring your agent to Lobu and give it something to work with.",children:e.jsxs("div",{className:"mt-4 flex flex-wrap justify-center gap-2",children:[e.jsx(U,{asChild:!0,children:e.jsxs(Y,{to:"/$owner/connectors/create",params:{owner:n},children:[e.jsx(so,{className:"mr-2 h-4 w-4"}),"Add a connector"]})}),e.jsx(U,{asChild:!0,variant:"outline",children:e.jsxs(Y,{to:"/$owner/agents",params:{owner:n},children:[e.jsx(qe,{className:"mr-2 h-4 w-4"}),"Connect agent"]})})]})})}):e.jsx("p",{className:"rounded-lg border bg-muted/20 px-3 py-6 text-center text-xs text-muted-foreground",children:"Nothing needs attention right now."});return e.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:e.jsx(eo,{context:i,relevant:m==="relevant",owner:n,emptyState:_,tabs:L})})}return e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:[N?null:e.jsxs("div",{className:O("sticky top-0 z-20 flex min-w-0 flex-wrap items-center gap-x-4 gap-y-2 bg-background pt-1",y?"justify-center":"justify-between"),children:[L,y?e.jsxs("div",{className:"flex items-center rounded-lg bg-muted/60 p-0.5 text-xs",children:[e.jsx(Y,{to:"/$owner/events",params:{owner:n},search:_=>{const ue={..._??{}};return delete ue.tab,ue},"aria-current":S?void 0:"page",className:O("rounded-md px-2.5 py-1 text-xs font-medium transition-colors",S?"text-muted-foreground hover:text-foreground":"bg-background text-foreground "),children:"Events"}),e.jsx(Y,{to:"/$owner/events",params:{owner:n},search:_=>({..._??{},tab:"sessions"}),"aria-current":S?"page":void 0,className:O("rounded-md px-2.5 py-1 text-xs font-medium transition-colors",S?"bg-background text-foreground ":"text-muted-foreground hover:text-foreground"),children:"Sessions"})]}):null]}),K&&!S?e.jsx("div",{className:"sticky top-0 z-20 flex min-w-0 flex-col gap-3 bg-background pt-1",children:K}):null,S?e.jsx(to,{owner:n,tone:"page",empty:"message"}):M?e.jsx(go,{children:X}):X]})}function Et({count:t}){return t===0?null:e.jsx("span",{role:"img","aria-label":`${t} item${t===1?"":"s"} need attention`,className:"rounded-full bg-blue-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-blue-600 dark:text-blue-400",children:t})}function Ze({icon:t,typeSegment:n,label:o,ownerSlug:s,clearSearch:a}){return e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 border-l border-border/60 pb-1 pl-3 text-sm",children:[t,n?e.jsxs(e.Fragment,{children:[e.jsx(Y,{to:"/$owner/events",params:{owner:s},search:n.search,className:"shrink-0 font-medium text-muted-foreground transition-colors hover:text-foreground hover:underline",children:n.label}),e.jsx(tn,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/60"})]}):null,e.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:o}),e.jsx(U,{asChild:!0,variant:"ghost",size:"sm",className:"h-6 gap-1 px-2",children:e.jsxs(Y,{to:"/$owner/events",params:{owner:s},search:a,children:[e.jsx(Te,{className:"h-3.5 w-3.5"}),"Clear"]})})]})}function Aa({owner:t,search:n,attentionLens:o,entityScope:s}){const a=typeof n.type=="string"&&n.type.trim()?Ce(n.type.trim()):void 0,r=zt(n),d=oo(n),c=Jt(n),u=n.tab==="sessions"?"sessions":"events";return e.jsx("div",{className:"flex flex-1 flex-col gap-6 px-4 py-6 lg:px-6",children:e.jsx(ao,{owner:t,children:i=>e.jsx(yo,{organizationId:i.organizationId,isWorkspaceLoading:i.isWorkspaceLoading,children:e.jsxs("div",{className:"mx-auto flex min-h-0 w-full min-w-0 max-w-3xl flex-1 flex-col",children:[e.jsx(ha,{organizationId:i.organizationId,ownerSlug:i.ownerSlug,typeScope:a,entityScope:s,agentScope:r,automationScope:d,scheduleScope:c,attentionLens:o,activityTab:u}),e.jsx(vo,{ownerSlug:i.ownerSlug})]})})})})}export{Aa as A};
|
package/dist/owletto/dist/assets/{agent-card-controls-JubkhcHt.js → agent-card-controls-bhTMPoVi.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,dd as i,al as l}from"./index-
|
|
1
|
+
import{j as e,dd as i,al as l}from"./index-DtRfQcRH.js";import{S as c}from"./switch-CxDXvPGE.js";function m({enabled:t,name:r,expanded:s,onToggleEnabled:a,toggleDisabled:o,onToggle:n}){return e.jsxs("div",{className:"flex shrink-0 items-center gap-2 self-center",children:[e.jsx(c,{checked:t,onCheckedChange:a,disabled:o,"aria-label":t?`Disable ${r}`:`Enable ${r}`}),e.jsx("button",{type:"button",onClick:n,"aria-label":s?"Collapse":"Expand",className:"text-muted-foreground transition-colors hover:text-foreground",children:e.jsx(i,{className:l("h-4 w-4 transition-transform",s&&"rotate-90")})})]})}export{m as A};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as o,L as c,bS as u}from"./index-
|
|
1
|
+
import{j as o,L as c,bS as u}from"./index-DtRfQcRH.js";const d="https://raw.githubusercontent.com/lobu-ai/lobu/main/claude-plugin/skills/lobu/SKILL.md";function a(e){try{const t=new URL(e).hostname;return t==="lobu.ai"||t.endsWith(".lobu.ai")}catch{return!1}}function r(e,t){const n=`npx @lobu/cli@latest connect ${e}`;return a(t)?n:`${n} --url ${t}`}const i=[{id:"claude-code",label:"Claude Code",tagline:"Shared plugin with Lobu MCP and workspace skills",description:"Connect Claude Code to shared workspace context and governed actions through Lobu's native plugin setup.",installTitle:"Run in your terminal",installText:e=>r("claude-code",e),steps:e=>a(e)?["The CLI adds Lobu's marketplace and installs the shared plugin.","Start a fresh Claude Code session.","Use a Lobu tool, choose this workspace, and complete OAuth when prompted."]:["The CLI registers this MCP endpoint and installs the Lobu workspace skill.","Start a fresh Claude Code session and complete OAuth when prompted."],guideLinks:[{label:"Claude Code setup guide",href:"https://lobu.ai/connect-from/claude-code/"}]},{id:"chatgpt",label:"ChatGPT & Codex",tagline:"Web connector and coding agent for one workspace",description:"Add Lobu as a custom ChatGPT connector, or connect the Codex coding agent through the CLI — both reach this workspace with your existing Lobu access.",installTitle:"Pick a surface",installText:e=>["ChatGPT web — open Settings -> Connectors -> Create connector","Name: Lobu",`MCP URL: ${e}`,"Authentication: OAuth","",`Codex — ${r("codex",e)}`].join(`
|
|
2
2
|
`),steps:e=>["ChatGPT web: turn on developer mode under Settings -> Security -> Developer mode (custom connectors need it).",`ChatGPT web: open Settings -> Connectors -> Create connector, name it Lobu, and use ${e} with OAuth.`,"ChatGPT web: scan tools, complete Lobu sign-in, and start a new chat with Lobu enabled.",...a(e)?["Codex: run the command above — the CLI adds Lobu's marketplace and installs the shared plugin."]:["Codex: run the command above — the CLI registers this MCP endpoint and installs the Lobu workspace skill."],"Codex: start a fresh session, choose this workspace, and complete OAuth when prompted."],guideLinks:[{label:"ChatGPT setup guide",href:"https://lobu.ai/connect-from/chatgpt/"},{label:"Codex setup guide",href:"https://lobu.ai/connect-from/codex/"}]},{id:"claude-desktop",label:"Claude Desktop",tagline:"Custom MCP connector with Lobu OAuth",description:"Add Lobu as a custom Claude Desktop connector and authorize the workspace with your existing Lobu access.",installTitle:"Add from Claude settings",installText:e=>["Open Settings -> Connectors -> Add Custom Connector","Name: Lobu",`MCP URL: ${e}`].join(`
|
|
3
3
|
`),steps:e=>["Open Settings -> Connectors -> Add Custom Connector.",`Name it Lobu and use ${e}.`,"Enable Lobu and complete OAuth.","Start a new conversation with Lobu enabled."],guideLinks:[{label:"Claude setup guide",href:"https://lobu.ai/connect-from/claude/"}]},{id:"opencode",label:"OpenCode",tagline:"Native remote MCP plus a global Lobu skill",description:"Connect OpenCode through its native MCP setup and install the Lobu workspace skill globally.",installTitle:"Run in your terminal",installText:e=>`npx @lobu/cli@latest connect opencode --url ${e}`,steps:e=>[`The CLI launches OpenCode's native MCP setup for ${e}.`,"Choose remote and name the server lobu.","Run opencode mcp auth lobu and complete OAuth.","The CLI installs the Lobu skill into OpenCode's global skill directory.","Start a fresh OpenCode session."],guideLinks:[{label:"OpenCode MCP guide",href:"https://opencode.ai/docs/mcp-servers/"}]},{id:"antigravity",label:"Antigravity CLI",tagline:"Native remote MCP plus a global Lobu skill",description:"Connect Antigravity CLI through its native MCP profile and install the Lobu workspace skill globally.",installTitle:"Run in your terminal",installText:e=>`npx @lobu/cli@latest connect antigravity --url ${e}`,steps:()=>["The CLI adds Lobu to Antigravity's global MCP profile using serverUrl.","The CLI installs lobu.md into Antigravity CLI's global skills directory.","Start a fresh session with agy, confirm Lobu in /mcp, and complete OAuth when prompted."],guideLinks:[{label:"Antigravity MCP guide",href:"https://antigravity.google/docs/mcp"}]},{id:"cursor",label:"Cursor",tagline:"Native remote MCP setup",description:"Connect Cursor to shared workspace context and governed actions through its native MCP configuration.",installTitle:"Run in your terminal",installText:e=>`npx @lobu/cli@latest connect cursor --url ${e}`,steps:()=>["The CLI adds or updates the Lobu entry in Cursor's MCP configuration.","Restart Cursor and enable the Lobu MCP server.","Use a Lobu tool and complete OAuth when prompted."],guideLinks:[{label:"Lobu MCP reference",href:"https://lobu.ai/reference/mcp/"}]},{id:"other",label:"Other agent",tagline:"Let your agent configure Lobu",description:"Paste a setup prompt into another MCP-compatible agent and let it propose the exact skill and MCP configuration.",installTitle:"Paste this into your agent",setupMode:"agent-prompt",steps:()=>["Paste the prompt into the agent you want to connect.","Review the exact configuration and skill files it proposes before approving changes.","Complete Lobu OAuth and let the agent perform its read-only verification."],guideLinks:[{label:"Lobu MCP reference",href:"https://lobu.ai/reference/mcp/"}]}],h={codex:"chatgpt"};function C(e){const t=h[e]??e;return i.find(n=>n.id===t)}function g(e){const{workspaceName:t,owner:n,mcpUrl:s,clientLabel:l}=e;return[`Connect this${l?` ${l}`:""} agent to the "${t}" Lobu workspace (${n}).`,"",`Use the remote HTTP MCP server ${s}. Detect this agent's native MCP and skill mechanisms. If it supports installable skills, install the Lobu workspace skill from ${d}.`,"Inspect the current client and show the exact proposed installation or configuration changes before applying them. The Lobu CLI may be used as the setup helper, but do not initialize a Lobu project. Do not install the separate project-building starter skill. Do not enable local Automation delivery.","","Complete Lobu OAuth in the user's browser. Then start a fresh session, confirm Lobu tools are discoverable, and make one harmless read-only call. Use search_sdk before choosing SDK methods. Never fabricate a returned URL or identifier."].join(`
|
|
4
4
|
`)}function p(e,t){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 ${e===t-1?"":"border-b"}`}function m({owner:e,dashed:t=!1}){return o.jsx("div",{className:`overflow-hidden rounded-lg border ${t?"border-dashed":""}`,children:i.map((n,s)=>o.jsxs(c,{to:"/$owner/agents/connect/$clientId",params:{owner:e,clientId:n.id},className:p(s,i.length),children:[o.jsx("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border ${t?"border-dashed":""}`,children:o.jsx(u,{name:n.label})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("p",{className:"truncate text-sm font-medium",children:n.label}),o.jsx("p",{className:"truncate text-xs text-muted-foreground",children:n.tagline})]}),o.jsx("span",{className:"shrink-0 text-xs",children:"Set up"})]},n.id))})}export{m as A,g as b,C as f};
|
package/dist/owletto/dist/assets/{agent-connect-pages-Chfqn8iL.js → agent-connect-pages-DkDlFVY5.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ai as x,j as e,bg as b,gg as N,aW as A,gh as w,L as p,gi as k,o as L,r as C,h0 as S,eH as m,B as y,Y as R,bS as f,aR as I,d_ as P}from"./index-
|
|
1
|
+
import{ai as x,j as e,bg as b,gg as N,aW as A,gh as w,L as p,gi as k,o as L,r as C,h0 as S,eH as m,B as y,Y as R,bS as f,aR as I,d_ as P}from"./index-DtRfQcRH.js";import{A as M,f as _,b as $}from"./agent-client-setup-list-BBbq_2B1.js";import{u as T}from"./clients-C7ubnFsS.js";import{g as B,c as U}from"./client-rows-EJSKR6z1.js";function E(t){const n=t?`/mcp/${t}`:"/mcp";if(!x)return`http://localhost:8787${n}`;try{const s=new URL(x);return s.pathname=n,s.toString()}catch{return`${x}${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(w,{crumbs:[e.jsx(p,{to:"/$owner/agents",params:{owner:t},className:k,children:"Agents"},"agents")]})}function H({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(M,{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(I,{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}=L(t,{slug:t}),{data:h=[]}=T(null,{refetchInterval:2500}),r=C.useMemo(()=>B(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=$({workspaceName:l?.workspace?.name??t,owner:t,mcpUrl:o,clientLabel:s.id==="other"?void 0:s.label}),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(m,{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(R,{className:"ml-1.5 h-3.5 w-3.5"})]})},a.href))]})]})}),e.jsx(m,{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(m,{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{H as A,q as a};
|
package/dist/owletto/dist/assets/{agent-editor-form-BrOkwfg8.js → agent-editor-form-DwHD9j1Y.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bc as he,bd as xe,j as e,B as f,cV as pe,er as fe,bA as ve,al as be,cv as je,cw as U,aR as V,P as we,gq as ye,gr as Ne,gs as Ce,gt as Me,dQ as Se,gu as ke,k as Ae,c6 as Ie,be as Pe,r as q,aG as E,fK as G,F as Fe,ac as b,dS as $,ad as De,am as Te,bX as $e,bY as Re,bZ as _e,b_ as Ee,b$ as K}from"./index-DdGjY1Hb.js";import{b as Be,s as Le}from"./model-selector-BLCEahny.js";function ze(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 Oe(t,a){const m=new Set(a),h=ze(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 Y(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}=Y(t);return{provider:a.find(g=>g.value===t)?.provider??a.find(g=>Y(g.value).slug===m)?.provider??m,model:h}}function qe({value:t,onChange:a,disabled:m}){const{data:h=[]}=he(),{data:x=[]}=xe(),u=Be(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=Le(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 Ye({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:B}=Se(s?.agentId,{enabled:o}),L=!d&&g==="active"?C:null,R=L?ke(L.proposal):void 0,w=p,z=s?.agentId??"create",r=Ae(z,{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,H]=r.field("name"),[y,Q]=r.field("description"),[k,X]=r.field("identityMd"),[A,Z]=r.field("soulMd"),[I,J]=r.field("userMd"),[P,ee]=r.field("models"),[F,se]=r.field("showToolCalls"),[N,te]=r.field("sandboxId"),[ae,D]=Ie(z,!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:Oe(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:A.trim(),userMd:I.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:A.trim(),userMd:I.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,A,c,S,I]),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&&B)return e.jsx(G,{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",O=!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?B?e.jsx(G,{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=>X(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:A,onChange:l=>Z(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:I,onChange:l=>J(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=>H(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,O?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,O?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{Ye as A};
|
|
1
|
+
import{bc as he,bd as xe,j as e,B as f,cV as pe,er as fe,bA as ve,al as be,cv as je,cw as U,aR as V,P as we,gq as ye,gr as Ne,gs as Ce,gt as Me,dQ as Se,gu as ke,k as Ae,c6 as Ie,be as Pe,r as q,aG as E,fK as G,F as Fe,ac as b,dS as $,ad as De,am as Te,bX as $e,bY as Re,bZ as _e,b_ as Ee,b$ as K}from"./index-DtRfQcRH.js";import{b as Be,s as Le}from"./model-selector-XC5CI2Et.js";function ze(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 Oe(t,a){const m=new Set(a),h=ze(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 Y(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}=Y(t);return{provider:a.find(g=>g.value===t)?.provider??a.find(g=>Y(g.value).slug===m)?.provider??m,model:h}}function qe({value:t,onChange:a,disabled:m}){const{data:h=[]}=he(),{data:x=[]}=xe(),u=Be(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=Le(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 Ye({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:B}=Se(s?.agentId,{enabled:o}),L=!d&&g==="active"?C:null,R=L?ke(L.proposal):void 0,w=p,z=s?.agentId??"create",r=Ae(z,{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,H]=r.field("name"),[y,Q]=r.field("description"),[k,X]=r.field("identityMd"),[A,Z]=r.field("soulMd"),[I,J]=r.field("userMd"),[P,ee]=r.field("models"),[F,se]=r.field("showToolCalls"),[N,te]=r.field("sandboxId"),[ae,D]=Ie(z,!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:Oe(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:A.trim(),userMd:I.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:A.trim(),userMd:I.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,A,c,S,I]),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&&B)return e.jsx(G,{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",O=!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?B?e.jsx(G,{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=>X(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:A,onChange:l=>Z(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:I,onChange:l=>J(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=>H(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,O?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,O?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{Ye as A};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as N,j as e,ac as w,ad as k,bX as K,bY as X,bZ as Y,b_ as ee,b$ as ae,dS as te,B as S,a4 as B,dQ as A,hU as L,hV as M,gt as F,fK as se,aG as f,es as J,c1 as ne,c2 as re,bq as D,eu as ie,eO as oe,eP as le,eQ as O,eR as E,eS as de,eT as $,ah as ue,hs as ce,c9 as q,P as me,al as R,hS as ge}from"./index-DdGjY1Hb.js";import{M as he}from"./model-selector-BLCEahny.js";import{a as xe,A as pe}from"./agent-subpage-shell-B7tCQ9zd.js";import{f as je}from"./agent-loading-shells-DsiGx1fn.js";import{A as fe}from"./agent-card-controls-JubkhcHt.js";const be=[{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 I({initial:a,judgeModelDefault:t,submitLabel:n,submitting:s,onSubmit:o,onCancel:r}){const[i,d]=N.useState(a?.name??""),[h,b]=N.useState(a?.stage??"input"),[p,y]=N.useState(a?.policy??""),[j,C]=N.useState(a?.model??""),[x,u]=N.useState((a?.tools??[]).join(", ")),[l,m]=N.useState((a?.domains??[]).join(", ")),g=a?.kind,v=g==="require-tool",Q=c=>{c.preventDefault();const _=x.split(",").map(T=>T.trim()).filter(Boolean);o({name:i,stage:h,...g?{kind:g}:{},policy:p,model:j.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:Q,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(k,{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(K,{value:h,onValueChange:c=>b(c),disabled:s,children:[e.jsx(X,{id:"guardrail-stage",children:e.jsx(Y,{})}),e.jsx(ee,{children:be.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(k,{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=>y(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:j,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(k,{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(k,{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(S,{type:"button",variant:"outline",onClick:r,disabled:s,children:"Cancel"}):null,e.jsx(S,{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 Ne(a,t,n){return a.map(s=>s.name===t?V(n):s)}function ye(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}=M(t),b=o||i||h,p=F(t),y=s?.guardrailsInline??[],j=(r??[]).map(u=>u.name),C=async u=>{if(!s){f.error("Still loading agent settings — try again in a moment");return}const l=H(u,y,j,d);if(l){f.error(l);return}try{await p.mutateAsync({guardrailsInline:ve(y,u)}),f.success("Guardrail created"),n({to:"/$owner/agents/$agentId/guardrails",params:{owner:a,agentId:t}})}catch(m){f.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}),b?e.jsx(se,{rows:4}):e.jsx(I,{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 Se(a){return a.filter(t=>t.enabled||t.unknown).map(t=>t.name)}function ke(a,t,n){return Se(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=N.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}=M(t),d=F(t),[h,b]=N.useState(!1),p=o?.guardrailsInline??[],y=(r??[]).map(u=>u.name),j=async(u,l)=>{if(!o)return f.error("Still loading agent settings — try again in a moment"),!1;try{return await d.mutateAsync({guardrailsInline:u}),f.success(l),!0}catch(m){return f.error(m instanceof Error?m.message:"Failed to save guardrail"),!1}},C=async u=>{const l=H(u,p,y,i,n.name);if(l){f.error(l);return}await j(Ne(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 j(ye(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(I,{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(S,{type:"button",variant:"destructive",onClick:()=>void x(),disabled:d.isPending,children:"Delete guardrail"}),e.jsx(S,{type:"button",variant:"outline",onClick:()=>b(!1),disabled:d.isPending,children:"Cancel"})]}):e.jsxs(S,{type:"button",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>b(!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}=J(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(O,{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(O,{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 U(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:U(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:U(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=[]}=J(t),b=F(t),p=async(l,m)=>{if(!o){f.error("Still loading agent settings — try again in a moment");return}try{if(l.kind==="custom")await b.mutateAsync({guardrailsInline:Ce(o.guardrailsInline??[],l.name,m)});else{const g=P(o,i??[]);await b.mutateAsync({guardrails:ke(g,l.name,m)})}f.success(m?"Guardrail enabled":"Guardrail disabled")}catch(g){f.error(g instanceof Error?g.message:"Failed to save guardrail")}},y=i===null,j=N.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&&j.length===0?e.jsx("div",{className:"space-y-6",children:y?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(S,{type:"button",onClick:x,children:[e.jsx(me,{className:"mr-1.5 h-4 w-4"}),"New guardrail"]})}),u?e.jsx(je,{rows:3}):e.jsx("div",{className:"overflow-hidden rounded-lg border",children:j.map((l,m)=>{const g=l.name===n;return e.jsx(De,{card:l,expanded:g,isLast:m===j.length-1,onToggle:()=>C(l.name),onToggleEnabled:v=>void p(l,v),toggleDisabled:l.unknown||b.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(fe,{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 Ue({owner:a,agentId:t}){return e.jsx(Z,{owner:a,agentId:t,children:e.jsx(we,{owner:a,agentId:t})})}function Me({owner:a,agentId:t,name:n}){return e.jsx(qe,{owner:a,agentId:t,expandedName:decodeURIComponent(n)})}export{qe as A,Ue as a,Me as b};
|
|
1
|
+
import{r as N,j as e,ac as w,ad as k,bX as K,bY as X,bZ as Y,b_ as ee,b$ as ae,dS as te,B as S,a4 as B,dQ as A,hU as L,hV as M,gt as F,fK as se,aG as f,es as J,c1 as ne,c2 as re,bq as D,eu as ie,eO as oe,eP as le,eQ as O,eR as E,eS as de,eT as $,ah as ue,hs as ce,c9 as q,P as me,al as R,hS as ge}from"./index-DtRfQcRH.js";import{M as he}from"./model-selector-XC5CI2Et.js";import{a as xe,A as pe}from"./agent-subpage-shell-DtzoRy6N.js";import{f as je}from"./agent-loading-shells-BQLjzMPy.js";import{A as fe}from"./agent-card-controls-bhTMPoVi.js";const be=[{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 I({initial:a,judgeModelDefault:t,submitLabel:n,submitting:s,onSubmit:o,onCancel:r}){const[i,d]=N.useState(a?.name??""),[h,b]=N.useState(a?.stage??"input"),[p,y]=N.useState(a?.policy??""),[j,C]=N.useState(a?.model??""),[x,u]=N.useState((a?.tools??[]).join(", ")),[l,m]=N.useState((a?.domains??[]).join(", ")),g=a?.kind,v=g==="require-tool",Q=c=>{c.preventDefault();const _=x.split(",").map(T=>T.trim()).filter(Boolean);o({name:i,stage:h,...g?{kind:g}:{},policy:p,model:j.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:Q,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(k,{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(K,{value:h,onValueChange:c=>b(c),disabled:s,children:[e.jsx(X,{id:"guardrail-stage",children:e.jsx(Y,{})}),e.jsx(ee,{children:be.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(k,{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=>y(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:j,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(k,{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(k,{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(S,{type:"button",variant:"outline",onClick:r,disabled:s,children:"Cancel"}):null,e.jsx(S,{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 Ne(a,t,n){return a.map(s=>s.name===t?V(n):s)}function ye(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}=M(t),b=o||i||h,p=F(t),y=s?.guardrailsInline??[],j=(r??[]).map(u=>u.name),C=async u=>{if(!s){f.error("Still loading agent settings — try again in a moment");return}const l=H(u,y,j,d);if(l){f.error(l);return}try{await p.mutateAsync({guardrailsInline:ve(y,u)}),f.success("Guardrail created"),n({to:"/$owner/agents/$agentId/guardrails",params:{owner:a,agentId:t}})}catch(m){f.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}),b?e.jsx(se,{rows:4}):e.jsx(I,{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 Se(a){return a.filter(t=>t.enabled||t.unknown).map(t=>t.name)}function ke(a,t,n){return Se(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=N.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}=M(t),d=F(t),[h,b]=N.useState(!1),p=o?.guardrailsInline??[],y=(r??[]).map(u=>u.name),j=async(u,l)=>{if(!o)return f.error("Still loading agent settings — try again in a moment"),!1;try{return await d.mutateAsync({guardrailsInline:u}),f.success(l),!0}catch(m){return f.error(m instanceof Error?m.message:"Failed to save guardrail"),!1}},C=async u=>{const l=H(u,p,y,i,n.name);if(l){f.error(l);return}await j(Ne(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 j(ye(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(I,{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(S,{type:"button",variant:"destructive",onClick:()=>void x(),disabled:d.isPending,children:"Delete guardrail"}),e.jsx(S,{type:"button",variant:"outline",onClick:()=>b(!1),disabled:d.isPending,children:"Cancel"})]}):e.jsxs(S,{type:"button",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>b(!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}=J(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(O,{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(O,{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 U(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:U(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:U(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=[]}=J(t),b=F(t),p=async(l,m)=>{if(!o){f.error("Still loading agent settings — try again in a moment");return}try{if(l.kind==="custom")await b.mutateAsync({guardrailsInline:Ce(o.guardrailsInline??[],l.name,m)});else{const g=P(o,i??[]);await b.mutateAsync({guardrails:ke(g,l.name,m)})}f.success(m?"Guardrail enabled":"Guardrail disabled")}catch(g){f.error(g instanceof Error?g.message:"Failed to save guardrail")}},y=i===null,j=N.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&&j.length===0?e.jsx("div",{className:"space-y-6",children:y?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(S,{type:"button",onClick:x,children:[e.jsx(me,{className:"mr-1.5 h-4 w-4"}),"New guardrail"]})}),u?e.jsx(je,{rows:3}):e.jsx("div",{className:"overflow-hidden rounded-lg border",children:j.map((l,m)=>{const g=l.name===n;return e.jsx(De,{card:l,expanded:g,isLast:m===j.length-1,onToggle:()=>C(l.name),onToggleEnabled:v=>void p(l,v),toggleDisabled:l.unknown||b.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(fe,{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 Ue({owner:a,agentId:t}){return e.jsx(Z,{owner:a,agentId:t,children:e.jsx(we,{owner:a,agentId:t})})}function Me({owner:a,agentId:t,name:n}){return e.jsx(qe,{owner:a,agentId:t,expandedName:decodeURIComponent(n)})}export{qe as A,Ue as a,Me as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,S as s,al as n}from"./index-
|
|
1
|
+
import{j as e,S as s,al as n}from"./index-DtRfQcRH.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};
|