hypervibes 0.4.0-beta → 0.4.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/.build/client/assets/{_authenticated-Cv9zLaQf.js → _authenticated-C87LKvH0.js} +1 -1
- package/.build/client/assets/{_authenticated.account-BUQIEX6U.js → _authenticated.account-D-nTh_fC.js} +1 -1
- package/.build/client/assets/_authenticated.agents-HwcveLyB.js +1 -0
- package/.build/client/assets/{_authenticated.agents._agentId-M6WEcZ08.js → _authenticated.agents._agentId-DuE8Lv62.js} +1 -1
- package/.build/client/assets/{_authenticated.agents._agentId.chart-C7d7IrdC.js → _authenticated.agents._agentId.chart-Bb_XkvQx.js} +1 -1
- package/.build/client/assets/{_authenticated.agents._agentId.chat-ByZuIqSb.js → _authenticated.agents._agentId.chat-ClMMKw_N.js} +1 -1
- package/.build/client/assets/{_authenticated.agents._agentId.index-BWIZd3vd.js → _authenticated.agents._agentId.index-DNJwBwn9.js} +1 -1
- package/.build/client/assets/{_authenticated.agents._agentId.indicators-CjCgrxqH.js → _authenticated.agents._agentId.indicators-BmVjLtRI.js} +1 -1
- package/.build/client/assets/{_authenticated.agents._agentId.indicators_._indicatorId-B45wotiz.js → _authenticated.agents._agentId.indicators_._indicatorId-CMqaaFQf.js} +2 -2
- package/.build/client/assets/{_authenticated.agents._agentId.indicators_._indicatorId-Beoq1vKK.js → _authenticated.agents._agentId.indicators_._indicatorId-DtgkoNV5.js} +1 -1
- package/.build/client/assets/{_authenticated.agents._agentId.memories-BmofNWcJ.js → _authenticated.agents._agentId.memories-O-4f6a4G.js} +1 -1
- package/.build/client/assets/{_authenticated.agents._agentId.memories_._memoryRef-CGnpq7sv.js → _authenticated.agents._agentId.memories_._memoryRef-BUPtUcj3.js} +1 -1
- package/.build/client/assets/{_authenticated.agents._agentId.notifications-Z1TVoGbh.js → _authenticated.agents._agentId.notifications-2lyhXCSk.js} +1 -1
- package/.build/client/assets/{_authenticated.agents._agentId.notifications_._notificationId-BU2I1Fui.js → _authenticated.agents._agentId.notifications_._notificationId-Da3ZVT4v.js} +1 -1
- package/.build/client/assets/{_authenticated.agents._agentId.settings-CUai-n8m.js → _authenticated.agents._agentId.settings-C5cWHoYw.js} +1 -1
- package/.build/client/assets/_authenticated.agents._agentId.sub-agents-HwcveLyB.js +1 -0
- package/.build/client/assets/{_authenticated.agents._agentId.sub-agents._subagentId-CEYRqW8Q.js → _authenticated.agents._agentId.sub-agents._subagentId-CZ4MeRy4.js} +1 -1
- package/.build/client/assets/{_authenticated.agents._agentId.sub-agents._subagentId_.runs._runId-Cr7yrAJz.js → _authenticated.agents._agentId.sub-agents._subagentId_.runs._runId-dVbo5kMU.js} +1 -1
- package/.build/client/assets/{_authenticated.agents._agentId.sub-agents.index-xTEjRPdW.js → _authenticated.agents._agentId.sub-agents.index-DeWTOYJD.js} +1 -1
- package/.build/client/assets/{_authenticated.agents._agentId.sub-agents.new-B9ZR8zIn.js → _authenticated.agents._agentId.sub-agents.new-D02TflCE.js} +1 -1
- package/.build/client/assets/{_authenticated.agents._agentId.transactions-a1xzSbFO.js → _authenticated.agents._agentId.transactions-D3a8Glgj.js} +1 -1
- package/.build/client/assets/{_authenticated.agents.new-COOjMCtg.js → _authenticated.agents.new-DLRWK5Uk.js} +1 -1
- package/.build/client/assets/{_authenticated.providers-8wsMG9f-.js → _authenticated.providers-D0iPLXra.js} +1 -1
- package/.build/client/assets/{agent-chat-page-vKrkXdzr.js → agent-chat-page-C5eYFgxw.js} +1 -1
- package/.build/client/assets/{agent-enablement-control-BMJ6jULr.js → agent-enablement-control-CUzOp9ce.js} +1 -1
- package/.build/client/assets/app-DjmsvbUC.css +2 -0
- package/.build/client/assets/{index-fu66g8fn.js → index-B4hvjMmI.js} +3 -3
- package/.build/client/assets/{useMutation-Dni_73Pp.js → useMutation-DrF53EQG.js} +1 -1
- package/.build/server/assets/{_tanstack-start-manifest_v-BAHfxLOo.js → _tanstack-start-manifest_v-Baw5u9sk.js} +54 -54
- package/.build/server/assets/{router-CpYyLRfb.js → router-Hkr5TH_I.js} +1 -1
- package/.build/server/server.js +2 -2
- package/README.md +9 -11
- package/dist/agents/agent-service.js +2 -0
- package/dist/agents/run-inspection.js +7 -5
- package/dist/agents/subagent-extension.js +3 -2
- package/dist/agents/subagent-service.js +2 -1
- package/dist/agents/time-guidance.js +29 -0
- package/dist/indicators/result-schema.js +14 -11
- package/dist/research/contracts.js +18 -14
- package/dist/research/research-service.js +1 -1
- package/package.json +27 -24
- package/.build/client/assets/_authenticated.agents-dJY4sHg9.js +0 -1
- package/.build/client/assets/_authenticated.agents._agentId.sub-agents-dJY4sHg9.js +0 -1
- package/.build/client/assets/app-DcRTuyby.css +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e,l as t,t as n}from"./jsx-runtime-CIazjfqY.js";import{t as r}from"./react-dom-C6bOPxes.js";import{a as i,i as a,n as o,t as s}from"./createServerFn-DfZIp2Fu.js";import{i as c}from"./lazyRouteComponent-CJgUa7_r.js";import{t as l}from"./useMutation-
|
|
1
|
+
import{f as e,l as t,t as n}from"./jsx-runtime-CIazjfqY.js";import{t as r}from"./react-dom-C6bOPxes.js";import{a as i,i as a,n as o,t as s}from"./createServerFn-DfZIp2Fu.js";import{i as c}from"./lazyRouteComponent-CJgUa7_r.js";import{t as l}from"./useMutation-DrF53EQG.js";import{t as u}from"./useQuery-BMSU16jY.js";import{t as d}from"./useSuspenseQuery-vODFwDb8.js";import{r as f}from"./memory-queries-BttL580R.js";import{o as p}from"./index-B4hvjMmI.js";import{n as m,t as h}from"./artifact-content-COO4VTSZ.js";import{t as g}from"./instrument-label-BZYlWXR5.js";import{t as _}from"./toggle-timestamp-B50FTPmA.js";import{n as v,r as y,t as b}from"./memory-badge-BbN-DJQi.js";var x=e(t(),1),S=e(r(),1),C=s({method:`GET`}).handler(i(`e1e86a7087628812ee2a074d5771e9969a69ca9d083b55727e082836741e5f92`)),w=s({method:`POST`}).handler(i(`ce5d64321b3253f7c57ff0de77b0a4ddc9b45eb3625c3631f94bca10e522b039`)),T=(e,t,n=0)=>o({queryKey:[`artifacts`,e,t,n],queryFn:()=>C({data:{agentId:e,id:t,offset:n}}),staleTime:0}),E=n(),D=`cursor-pointer rounded-lg border border-zinc-700 px-3 py-2 text-sm text-zinc-200 hover:bg-zinc-800 disabled:cursor-wait disabled:opacity-50`;function O({agentId:e,artifactId:t,onClose:n}){let r=(0,x.useRef)(null),i=(0,x.useId)(),[o,s]=(0,x.useState)({id:t,offset:0}),c=a(),d=u(T(e,o.id,o.offset)),f=d.data,p=l({mutationFn:({id:t,action:n})=>w({data:{agentId:e,id:t,action:n}}),onSuccess:async(r,{id:i,action:a})=>{a===`delete`?(i===t?n():s({id:t,offset:0}),c.removeQueries({queryKey:[`artifacts`,e,i]}),i!==t&&await c.invalidateQueries({queryKey:[`artifacts`,e,t]})):await c.invalidateQueries({queryKey:[`artifacts`,e,i]})}}),g=p.error?.message??d.error?.message,_=d.isPending||d.isFetching,v=p.isPending,y=(0,x.useRef)(!1);function b(e){p.reset(),s(e)}function C(){y.current||n()}async function O(e){if(!(!f||y.current||_)&&!(e===`delete`&&!window.confirm(`Permanently delete this artifact? Referenced attachments cannot be deleted until their report is removed.`))){y.current=!0;try{await p.mutateAsync({id:f.id,action:e})}catch{}finally{y.current=!1}}}return(0,x.useEffect)(()=>{let e=r.current;return e.showModal(),()=>e.close()},[]),(0,S.createPortal)((0,E.jsxs)(`dialog`,{ref:r,"aria-labelledby":i,onCancel:e=>{e.preventDefault(),C()},className:`m-auto flex max-h-[calc(100dvh-2rem)] w-[calc(100%_-_2rem)] max-w-5xl flex-col rounded-2xl border border-zinc-800 bg-[#0d0d10] text-zinc-200 shadow-2xl backdrop:bg-black/70 backdrop:backdrop-blur-sm`,children:[(0,E.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-4 border-b border-zinc-800 p-5`,children:[(0,E.jsx)(`h2`,{id:i,className:`text-lg font-medium text-white`,children:f?.title??`Supporting artifact`}),(0,E.jsx)(`button`,{type:`button`,className:D,disabled:v,onClick:C,children:`Close`})]}),(0,E.jsxs)(`div`,{className:`min-h-0 space-y-4 overflow-y-auto p-5`,"aria-busy":_||v,children:[_&&(0,E.jsx)(`p`,{role:`status`,children:`Loading artifact…`}),g&&(0,E.jsx)(`p`,{role:`alert`,className:`text-red-300`,children:g}),f&&(0,E.jsxs)(E.Fragment,{children:[f.description&&(0,E.jsx)(`p`,{className:`text-sm text-zinc-400`,children:f.description}),f.mediaType.startsWith(`image/`)?(0,E.jsx)(`img`,{className:`max-h-[65vh] max-w-full object-contain`,src:m(e,f.id,!0),alt:f.title}):(0,E.jsx)(h,{agentId:e,content:f.content??``,attachments:f.attachments}),o.offset>0&&(0,E.jsx)(`button`,{type:`button`,className:D,disabled:v,onClick:()=>b({id:f.id,offset:0}),children:`First text portion`}),f.nextOffset!==null&&(0,E.jsx)(`button`,{type:`button`,className:D,disabled:v,onClick:()=>b({id:f.id,offset:f.nextOffset}),children:`Next text portion`}),f.attachments.length>0&&(0,E.jsxs)(`section`,{className:`space-y-2`,children:[(0,E.jsx)(`h3`,{className:`text-sm font-medium`,children:`Attachments`}),(0,E.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.attachments.map(e=>(0,E.jsx)(`button`,{type:`button`,className:D,disabled:v,onClick:()=>b({id:e.id,offset:0}),children:e.title},e.id))})]})]})]}),(0,E.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap gap-3 border-t border-zinc-800 p-5`,children:[(0,E.jsx)(`a`,{className:D,href:m(e,o.id),children:`Download`}),f&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`button`,{type:`button`,disabled:_||v||f.protectedByMemory&&f.expiresAt===null,className:D,onClick:()=>{O(f.expiresAt===null?`expire`:`retain`)},children:f.expiresAt===null?`Expire in seven days`:`Keep / Pin`}),(0,E.jsx)(`button`,{type:`button`,disabled:_||v||f.protectedByMemory,title:f.protectedByMemory?`Evidence referenced by memory cannot be deleted`:void 0,className:`${D} text-red-300`,onClick:()=>{O(`delete`)},children:`Delete`})]}),o.id!==t&&(0,E.jsx)(`button`,{type:`button`,className:D,disabled:_||v,onClick:()=>b({id:t,offset:0}),children:`Back to supporting artifact`})]})]}),document.body)}var k={based_on:`Based on`,corrects:`Corrects`,supersedes:`Supersedes`,reviews:`Reviews`},A=`cursor-pointer text-violet-300 hover:text-violet-200 hover:underline`;function j({agentId:e,memory:t}){let[n,r]=(0,x.useState)(null),[i,a]=(0,x.useState)(``);async function o(){try{await navigator.clipboard.writeText(t.ref),a(``)}catch{a(`Unable to copy memory reference`)}}return(0,E.jsxs)(`section`,{className:`w-full min-w-0 space-y-4 rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6 text-zinc-200`,"aria-label":`Memory detail`,children:[(0,E.jsxs)(`header`,{className:`space-y-2`,children:[(0,E.jsxs)(`nav`,{"aria-label":`Memory breadcrumb`,className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,E.jsxs)(c,{to:`/agents/$agentId/memories`,params:{agentId:e},search:{},className:`cursor-pointer text-sm text-zinc-400 hover:text-white`,children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,children:`← `}),`Memories`]}),(0,E.jsx)(`span`,{"aria-hidden":`true`,className:`text-zinc-600`,children:`/`}),(0,E.jsxs)(`h1`,{"aria-current":`page`,className:`break-words text-lg font-medium text-white`,children:[`Memory `,t.ref]}),(0,E.jsx)(`button`,{type:`button`,"aria-label":`Copy memory reference`,title:`Copy memory reference`,className:`cursor-pointer rounded-md p-1.5 text-zinc-400 hover:bg-zinc-800 hover:text-white`,onClick:()=>{o()},children:(0,E.jsxs)(`svg`,{"aria-hidden":`true`,className:`size-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`rect`,{x:`9`,y:`9`,width:`12`,height:`12`,rx:`2`}),(0,E.jsx)(`path`,{d:`M5 15H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v1`})]})}),(0,E.jsx)(y,{status:t.status})]}),(0,E.jsx)(v,{agentId:e,memory:t})]}),i&&(0,E.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:i}),(0,E.jsxs)(`dl`,{"aria-label":`Memory stats`,className:`grid grid-cols-1 gap-x-6 gap-y-5 border-t border-zinc-800 pt-5 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,E.jsx)(M,{label:`Kind`,children:(0,E.jsx)(b,{value:t.kind})}),(0,E.jsx)(M,{label:`Instrument`,children:t.instrument?(0,E.jsx)(g,{symbol:t.instrument}):`Agent-wide`}),(0,E.jsx)(M,{label:`Topic`,children:(0,E.jsx)(b,{value:t.topic})}),(0,E.jsx)(M,{label:`Interval`,children:t.interval??`—`}),(0,E.jsx)(M,{label:`Created`,children:(0,E.jsx)(_,{timestamp:t.createdAt})}),(0,E.jsx)(M,{label:`Evidence boundary`,children:t.evidenceAsOf===null?`None`:(0,E.jsx)(N,{value:t.evidenceAsOf})}),(0,E.jsx)(M,{label:`Valid until`,children:t.validUntil===null?`No market expiry`:(0,E.jsx)(_,{timestamp:t.validUntil,label:`expiry`})}),(0,E.jsx)(M,{label:`Producer`,children:t.producerSubagentId?(0,E.jsx)(c,{className:A,to:`/agents/$agentId/sub-agents/$subagentId`,params:{agentId:e,subagentId:t.producerSubagentId},children:t.producerSubagentId}):`Root agent`}),(0,E.jsx)(M,{label:`Source`,children:t.sourceRunId&&t.producerSubagentId?(0,E.jsx)(c,{className:A,to:`/agents/$agentId/sub-agents/$subagentId/runs/$runId`,params:{agentId:e,subagentId:t.producerSubagentId,runId:t.sourceRunId},children:`Source run`}):`Root authored`}),t.links.length>0&&(0,E.jsxs)(`div`,{className:`min-w-0 sm:col-span-2 xl:col-span-4`,children:[(0,E.jsx)(`dt`,{className:`text-xs uppercase tracking-[0.16em] text-zinc-500`,children:`Related memories`}),(0,E.jsx)(`dd`,{className:`mt-2 flex flex-wrap gap-x-4 gap-y-2 text-sm`,children:t.links.map(t=>(0,E.jsxs)(c,{className:A,to:`/agents/$agentId/memories/$memoryRef`,params:{agentId:e,memoryRef:t.ref},children:[k[t.relation],`: `,t.ref]},`${t.ref}:${t.relation}`))})]})]}),(0,E.jsxs)(`section`,{className:`space-y-4 border-t border-zinc-800 pt-4`,"aria-label":`Memory contents`,children:[(0,E.jsx)(`p`,{children:t.summary}),(0,E.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-sm`,children:t.content}),Object.keys(t.payload).length>0?(0,E.jsx)(`pre`,{"aria-label":`Additional memory data`,className:`whitespace-pre-wrap break-words text-xs text-zinc-400`,children:JSON.stringify(t.payload,null,2)}):null]}),t.artifactIds.length>0&&(0,E.jsxs)(`section`,{className:`space-y-2`,children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-white`,children:`Supporting artifacts`}),t.artifactIds.map(e=>(0,E.jsxs)(`button`,{type:`button`,className:`block cursor-pointer text-left text-sm text-violet-300`,onClick:()=>r(e),children:[`Supporting artifact `,e]},e))]}),n&&(0,E.jsx)(O,{agentId:e,artifactId:n,onClose:()=>r(null)},`${e}:${n}`)]})}function M({label:e,children:t}){return(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`dt`,{className:`text-xs uppercase tracking-[0.16em] text-zinc-500`,children:e}),(0,E.jsx)(`dd`,{className:`mt-2 break-words text-sm text-zinc-200`,children:t})]})}function N({value:e}){let t=new Date(e).toISOString();return(0,E.jsxs)(`time`,{dateTime:t,title:t,className:`font-mono text-xs`,children:[t.replace(`T`,` `).slice(0,19),` UTC`]})}function P(){let{agentId:e,memoryRef:t}=p.useParams(),{data:n,error:r}=d(f(e,t));return(0,E.jsxs)(E.Fragment,{children:[r&&(0,E.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:r.message}),(0,E.jsx)(j,{agentId:e,memory:n},`${e}:${n.ref}`)]})}export{P as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-CIazjfqY.js";import{v as t}from"./index-
|
|
1
|
+
import{t as e}from"./jsx-runtime-CIazjfqY.js";import{v as t}from"./index-B4hvjMmI.js";import{n}from"./agent-notifications-page-B0mr-Zz8.js";var r=e();function i(){let{agentId:e}=t.useParams(),{page:i}=t.useSearch(),a=t.useNavigate();return(0,r.jsx)(n,{agentId:e,page:i,onPage:e=>{a({search:{page:e}})}})}export{i as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-CIazjfqY.js";import{a as t}from"./index-
|
|
1
|
+
import{t as e}from"./jsx-runtime-CIazjfqY.js";import{a as t}from"./index-B4hvjMmI.js";import{t as n}from"./agent-notifications-page-B0mr-Zz8.js";var r=e();function i(){let{agentId:e,notificationId:i}=t.useParams();return(0,r.jsx)(n,{agentId:e,notificationId:i})}export{i as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e,l as t,t as n}from"./jsx-runtime-CIazjfqY.js";import{t as r}from"./react-dom-C6bOPxes.js";import{i}from"./createServerFn-DfZIp2Fu.js";import{t as a}from"./useMutation-Dni_73Pp.js";import{t as o}from"./useQuery-BMSU16jY.js";import{t as s}from"./useSuspenseQuery-vODFwDb8.js";import{t as c}from"./useRouter-c0I1aURm.js";import{o as l,p as u,t as d}from"./agent-queries-CNMBImun.js";import{n as f,t as p}from"./risk-queries-D_6PHwus.js";import{a as m,r as h,t as g}from"./notification-queries-B12DG3aS.js";import{_,f as v,g as y,h as b,j as x,m as S,p as C}from"./index-fu66g8fn.js";import{n as w}from"./config-dialog-C9x9gKW9.js";import{t as T}from"./instrument-picker-DLPpryOm.js";import{t as E}from"./agent-enablement-control-BMJ6jULr.js";var D=e(r(),1),O=e(t(),1),k=n(),A=`size-4 cursor-pointer accent-violet-500 disabled:cursor-not-allowed disabled:opacity-50`;function j({agentId:e,saved:t}){let n=i(),[r,o]=(0,O.useState)(t),s=a({mutationFn:t=>m({data:{agentId:e,...t}}),onSuccess:async t=>{n.setQueryData(h(e).queryKey,t),x.success(`Notification settings saved`),await n.invalidateQueries({queryKey:g.all(e)})}}),c=r.enabled!==t.enabled||r.submissions!==t.submissions||r.fills!==t.fills;return(0,k.jsxs)(`form`,{className:`mt-4 space-y-4`,onSubmit:e=>{e.preventDefault(),!s.isPending&&c&&s.mutate(r)},children:[(0,k.jsxs)(`fieldset`,{disabled:s.isPending,className:`space-y-3 text-sm text-zinc-300`,children:[(0,k.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3`,children:[(0,k.jsx)(`input`,{type:`checkbox`,className:A,checked:r.enabled,onChange:e=>o(t=>({...t,enabled:e.target.checked}))}),`Enable Telegram notifications`]}),(0,k.jsxs)(`fieldset`,{disabled:!r.enabled,className:`space-y-3 pl-7 disabled:opacity-50`,children:[(0,k.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3`,children:[(0,k.jsx)(`input`,{type:`checkbox`,className:A,checked:r.submissions,onChange:e=>o(t=>({...t,submissions:e.target.checked}))}),`Order submissions`]}),(0,k.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3`,children:[(0,k.jsx)(`input`,{type:`checkbox`,className:A,checked:r.fills,onChange:e=>o(t=>({...t,fills:e.target.checked}))}),`Order fills (including external/manual trades)`]})]}),c&&(0,k.jsx)(`button`,{type:`submit`,disabled:s.isPending,className:`cursor-pointer rounded-full bg-violet-600 px-4 py-2 text-sm text-white hover:bg-violet-500 disabled:cursor-wait disabled:opacity-50`,children:s.isPending?`Saving…`:`Save Telegram notification settings`})]}),s.error&&(0,k.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:s.error.message})]})}function M({agentId:e}){let t=o(h(e));return(0,k.jsxs)(`section`,{id:`notifications`,"aria-label":`Notifications`,className:`mt-6 scroll-mt-2 border-t border-zinc-800 pt-6`,children:[(0,k.jsx)(`h3`,{className:`font-medium text-white`,children:`Notifications`}),t.isPending?(0,k.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-zinc-400`,children:`Loading notification settings…`}):t.data?(0,k.jsx)(j,{agentId:e,saved:t.data},e):null,t.error&&(0,k.jsxs)(`p`,{role:`alert`,className:`mt-3 text-sm text-red-300`,children:[t.error.message,` `,(0,k.jsx)(`button`,{type:`button`,className:`cursor-pointer text-violet-300 hover:underline`,onClick:()=>{t.refetch()},children:`Retry`})]})]})}var N=`cursor-pointer rounded-full bg-violet-600 px-4 py-2 text-sm text-white hover:bg-violet-500 disabled:cursor-not-allowed disabled:opacity-50`,P=`cursor-pointer rounded-full border border-violet-600 px-4 py-2 text-sm text-violet-300 hover:border-violet-500 hover:bg-violet-950 disabled:cursor-not-allowed disabled:opacity-50`,F=`size-4 shrink-0 cursor-pointer appearance-none rounded-full border border-zinc-600 bg-zinc-950 transition checked:border-[5px] checked:border-violet-500 checked:bg-white hover:border-violet-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-400 focus-visible:ring-offset-2 focus-visible:ring-offset-zinc-950 disabled:cursor-wait disabled:opacity-50`;function I({title:e,inputLabel:t,placeholder:n,value:r,onChange:i}){let a=(0,O.useId)();return(0,k.jsxs)(`fieldset`,{className:`min-w-0 space-y-3 text-sm text-zinc-300`,children:[(0,k.jsx)(`legend`,{className:`mb-3 font-medium`,children:e}),(0,k.jsxs)(`label`,{className:`flex w-fit cursor-pointer items-center gap-2`,children:[(0,k.jsx)(`input`,{type:`radio`,name:a,value:`unlimited`,className:F,checked:!r.limited,onChange:()=>i({...r,limited:!1})}),`No limit`]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,k.jsxs)(`label`,{className:`flex shrink-0 cursor-pointer items-center gap-2`,children:[(0,k.jsx)(`input`,{type:`radio`,name:a,value:`limited`,className:F,checked:r.limited,onChange:()=>i({...r,limited:!0})}),`Limit:`]}),(0,k.jsxs)(`div`,{className:`relative min-w-0 flex-1 ${r.limited?``:`opacity-50`}`,children:[(0,k.jsx)(`input`,{"aria-label":t,"aria-describedby":`${a}-currency`,className:`block w-full rounded-lg border border-zinc-700 bg-zinc-950 py-2.5 pl-3 pr-16 text-sm text-white focus-visible:border-violet-400 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-violet-400 disabled:cursor-not-allowed`,inputMode:`decimal`,placeholder:n,disabled:!r.limited,value:r.amount,onChange:e=>i({...r,amount:e.target.value})}),(0,k.jsx)(`span`,{id:`${a}-currency`,className:`pointer-events-none absolute inset-y-0 right-3 flex items-center text-xs text-zinc-500`,children:`USDC`})]})]})]})}function L({agentId:e}){let t=i(),{data:n,error:r}=s(p(e)),[o,c]=(0,O.useState)(n.tradingEnabled),[u,d]=(0,O.useState)(n.allowedInstruments),[m,h]=(0,O.useState)({limited:n.maxOrderNotional!==null,amount:n.maxOrderNotional??``}),[g,_]=(0,O.useState)({limited:n.maxTotalNotional!==null,amount:n.maxTotalNotional??``}),v=a({mutationFn:async t=>{if(m.limited&&!m.amount.trim())throw Error(`Enter a max order notional limit or select No limit.`);if(g.limited&&!g.amount.trim())throw Error(`Enter a max total exposure limit or select No limit.`);return f({data:{agentId:e,settings:t}})},onSuccess:async n=>{t.setQueryData(p(e).queryKey,n),x.success(`Risk settings saved`),await l(t)}}),y=v.isPending,b=v.error?.message??r?.message,S={tradingEnabled:o,allowedInstruments:u,maxOrderNotional:m.limited?m.amount.trim():null,maxTotalNotional:g.limited?g.amount.trim():null},C=S.tradingEnabled!==n.tradingEnabled||JSON.stringify(S.allowedInstruments===null?null:[...S.allowedInstruments].sort())!==JSON.stringify(n.allowedInstruments===null?null:[...n.allowedInstruments].sort())||S.maxOrderNotional!==n.maxOrderNotional||S.maxTotalNotional!==n.maxTotalNotional;function w(){!y&&C&&v.mutate(S)}return(0,k.jsxs)(`section`,{id:`risk-management`,className:`w-full scroll-mt-2 rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6`,"aria-label":`Risk management`,children:[(0,k.jsx)(`h2`,{className:`text-lg font-medium text-white`,children:`Risk management`}),(0,k.jsxs)(`fieldset`,{disabled:y,className:`mt-4 space-y-4`,children:[(0,k.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 text-sm text-zinc-300`,children:[(0,k.jsxs)(`span`,{className:`relative inline-flex size-5 shrink-0`,children:[(0,k.jsx)(`input`,{type:`checkbox`,className:`peer size-5 cursor-pointer appearance-none rounded border border-zinc-600 bg-zinc-950 transition checked:border-violet-500 checked:bg-violet-600 hover:border-violet-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-400 focus-visible:ring-offset-2 focus-visible:ring-offset-zinc-950 disabled:cursor-wait disabled:opacity-50`,checked:o,onChange:e=>c(e.target.checked)}),(0,k.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:2.5,className:`pointer-events-none absolute inset-0.5 size-4 text-white opacity-0 transition peer-checked:opacity-100 peer-disabled:text-zinc-400`,children:(0,k.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m4 10 4 4 8-8`})})]}),(0,k.jsx)(`span`,{children:`Enable Trading`})]}),(0,k.jsx)(T,{agentId:e,value:u,onChange:d,disabled:y}),(0,k.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,k.jsx)(I,{title:`Max order notional`,inputLabel:`Max order notional`,placeholder:`1000`,value:m,onChange:h}),(0,k.jsx)(I,{title:`Max total exposure`,inputLabel:`Max total notional`,placeholder:`5000`,value:g,onChange:_})]}),C&&(0,k.jsx)(`button`,{type:`button`,className:N,disabled:y,onClick:()=>{w()},children:y?`Saving…`:`Save risk settings`})]}),b&&(0,k.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-red-300`,children:b})]})}function R({agent:e}){let t=c(),[n,r]=(0,O.useState)(!1),[o,s]=(0,O.useState)(``),d=i(),f=a({mutationFn:()=>u({data:{id:e.id,confirmation:o}}),onSuccess:async()=>{await t.navigate({to:`/agents`});for(let t of[`agent`,`agent-chat`,`agent-history`,`agent-dashboard`,`risk`,`journal`,`journal-notes`,`journal-audit`,`subagents`,`memories`,`insights`,`artifacts`,`chart-instruments`,`chart-layouts`,`chart-history`,`chart-fills`,`notifications`,`notification-settings`])d.removeQueries({queryKey:[t,e.id]});x.success(`Agent deleted`)},onSettled:async(t,n)=>{await l(d),n&&await Promise.all([d.invalidateQueries({queryKey:[`agent`,e.id]}),d.invalidateQueries({queryKey:[`agent-chat`,e.id]})])}}),p=f.isPending,m=f.error?.message;function h(){!p&&o===e.name&&f.mutate()}return(0,k.jsxs)(`section`,{"aria-label":`Danger zone`,className:`rounded-2xl border border-red-900/60 bg-[#0d0d10] p-6`,children:[(0,k.jsx)(`h2`,{className:`text-lg font-medium text-red-300`,children:`Danger zone`}),(0,k.jsx)(`p`,{className:`mt-3 text-sm text-zinc-400`,children:`Deleting this agent stops its workers, removes its configuration and application history, and releases its Hyperliquid account for reuse. Existing exchange orders and positions are not changed. This cannot be undone.`}),e.error&&(e.state===`stopping`||e.state===`stopped`)&&(0,k.jsx)(`p`,{role:`status`,className:`mt-3 text-sm text-red-300`,children:e.error}),n?(0,k.jsxs)(`form`,{className:`mt-4 space-y-3`,onSubmit:e=>{e.preventDefault(),h()},children:[(0,k.jsxs)(`label`,{className:`block text-sm text-zinc-300`,children:[`Type `,(0,k.jsx)(`strong`,{children:e.name}),` to confirm deletion`,(0,k.jsx)(`input`,{"aria-label":`Agent name confirmation`,autoComplete:`off`,value:o,disabled:p,onChange:e=>s(e.target.value),className:`mt-2 block w-full rounded-lg border border-zinc-700 bg-zinc-950 px-3 py-2 text-white`})]}),(0,k.jsxs)(`div`,{className:`flex gap-3`,children:[(0,k.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>{r(!1),s(``),f.reset()},className:`cursor-pointer rounded-full border border-zinc-700 px-4 py-2 text-sm text-zinc-300 disabled:cursor-not-allowed`,children:`Cancel`}),(0,k.jsx)(`button`,{type:`submit`,disabled:p||o!==e.name,className:`cursor-pointer rounded-full bg-red-700 px-4 py-2 text-sm text-white hover:bg-red-600 disabled:cursor-not-allowed disabled:opacity-50`,children:p?`Stopping and deleting…`:`Permanently delete agent`})]})]}):(0,k.jsx)(`button`,{type:`button`,onClick:()=>r(!0),className:`mt-4 cursor-pointer rounded-full border border-red-800 px-4 py-2 text-sm text-red-300 hover:bg-red-950`,children:`Delete agent`}),m&&(0,k.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-red-300`,children:m})]})}function z({agentId:e,initial:t,pollMs:n=4e3,onClose:r,onChanged:i}){let o=(0,O.useRef)(null),s=(0,O.useId)(),[c,l]=(0,O.useState)(t),[u,d]=(0,O.useState)(``),[f,p]=(0,O.useState)(null);(0,O.useEffect)(()=>{let e=o.current;return e.showModal(),()=>e.close()},[]),(0,O.useEffect)(()=>{if(!c.hasToken||c.connected)return;let t=setInterval(()=>{y({data:{id:e}}).then(e=>{l(t=>t.hasToken===e.hasToken&&t.connected===e.connected?t:e),e.connected&&i(e)}).catch(()=>void 0)},n);return()=>clearInterval(t)},[c.hasToken,c.connected,e,n,i]);let m=a({mutationFn:()=>S({data:{id:e,token:u}}),onSuccess:e=>{d(``),l(e),i(e),x.success(`Telegram bot added`)}}),h=a({mutationFn:()=>_({data:{id:e}}),onSuccess:({link:e})=>p(e)}),g=a({mutationFn:()=>b({data:{id:e}}),onSuccess:e=>{p(null),l(e),i(e)}}),v=m.isPending||h.isPending||g.isPending,C=m.error?.message??h.error?.message??g.error?.message;return(0,D.createPortal)((0,k.jsxs)(`dialog`,{ref:o,"aria-labelledby":s,onCancel:e=>{e.preventDefault(),r()},className:`m-auto flex max-h-[calc(100dvh-2rem)] w-[calc(100%_-_2rem)] max-w-md flex-col rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6 text-zinc-200 shadow-2xl backdrop:bg-black/70 backdrop:backdrop-blur-sm`,children:[(0,k.jsxs)(`h3`,{id:s,className:`flex items-center gap-2 text-lg font-semibold text-white`,children:[(0,k.jsx)(`img`,{src:`/static/telegram.svg`,alt:``,"aria-hidden":`true`,className:`h-5 w-5 rounded-full`}),`Connect Telegram`]}),(0,k.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 space-y-4 overflow-y-auto text-sm`,children:[c.hasToken?c.connected?(0,k.jsx)(k.Fragment,{children:(0,k.jsxs)(`p`,{role:`status`,children:[`Telegram connected — this Agent's main conversation is bridged to `,(0,k.jsxs)(`span`,{className:`font-medium text-white`,children:[`@`,c.botUsername]}),c.chatUsername&&(0,k.jsxs)(k.Fragment,{children:[` · chat `,(0,k.jsxs)(`span`,{className:`font-medium text-white`,children:[`@`,c.chatUsername]})]}),c.chatId!==null&&(0,k.jsxs)(k.Fragment,{children:[` · id `,(0,k.jsx)(`span`,{className:`font-medium text-white`,children:c.chatId})]}),`.`]})}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`p`,{className:`text-zinc-400`,children:[`Bot `,(0,k.jsxs)(`span`,{className:`font-medium text-white`,children:[`@`,c.botUsername]}),` is ready. Link the Telegram chat this Agent should talk in.`]}),f?(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsx)(`a`,{className:`${N} inline-block`,href:f,target:`_blank`,rel:`noopener noreferrer`,children:`Open Telegram`}),(0,k.jsxs)(`p`,{className:`text-zinc-500`,children:[`Then send the prefilled `,(0,k.jsx)(`code`,{className:`text-zinc-400`,children:`/start`}),` command. This dialog updates automatically once the chat is linked.`]})]}):(0,k.jsx)(`button`,{type:`button`,disabled:v,onClick:()=>h.mutate(),className:N,children:`Link Telegram chat`}),(0,k.jsx)(`button`,{type:`button`,disabled:v,onClick:()=>g.mutate(),className:`block rounded-full border border-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-900 disabled:cursor-not-allowed disabled:opacity-50`,children:`Remove bot token`})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`p`,{className:`text-zinc-400`,children:[`Create a bot with `,(0,k.jsx)(`a`,{className:`cursor-pointer text-violet-400 underline hover:text-violet-300`,href:`https://t.me/BotFather`,target:`_blank`,rel:`noopener noreferrer`,children:`@BotFather`}),`, then paste its token here. One bot can only serve one Agent.`]}),(0,k.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),u.trim()&&!v&&m.mutate()},children:[(0,k.jsxs)(`label`,{className:`block text-zinc-300`,htmlFor:s+`-token`,children:[`Bot token`,(0,k.jsx)(`input`,{id:s+`-token`,"aria-label":`Telegram bot token`,autoComplete:`off`,value:u,disabled:v,onChange:e=>d(e.target.value),className:`mt-2 block w-full rounded-lg border border-zinc-700 bg-zinc-950 px-3 py-2 font-mono text-sm text-white`,placeholder:`123456789:AAE…`})]}),(0,k.jsx)(`button`,{type:`submit`,disabled:v||!u.trim(),className:`${N} mt-4`,children:`Add bot token`})]})]}),C&&(0,k.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:C})]}),(0,k.jsx)(`footer`,{className:`mt-6 flex shrink-0 justify-end border-t border-zinc-800 pt-4`,children:(0,k.jsx)(`button`,{type:`button`,onClick:r,className:w,children:c.connected?`Done`:`Close`})})]}),document.body)}function B({agentId:e,notificationsAvailable:t}){let n=i(),{data:r}=s(C(e)),[o,c]=(0,O.useState)(!1),l=(0,O.useCallback)(t=>n.setQueryData(C(e).queryKey,t),[n,e]),u=a({mutationFn:()=>b({data:{id:e}}),onSuccess:async e=>{l(e),x.success(`Telegram disconnected`)}});return(0,k.jsxs)(`section`,{id:`telegram`,className:`w-full scroll-mt-2 rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6`,"aria-label":`Telegram`,children:[(0,k.jsxs)(`h2`,{className:`flex items-center gap-2 text-lg font-medium text-white`,children:[(0,k.jsx)(`img`,{src:`/static/telegram.svg`,alt:``,"aria-hidden":`true`,className:`h-5 w-5 rounded-full`}),`Telegram`]}),r.error&&(0,k.jsx)(`p`,{role:`status`,className:`mt-3 text-sm text-amber-300`,children:r.error}),r.connected?(0,k.jsxs)(`div`,{className:`mt-4 space-y-3 text-sm text-zinc-300`,children:[(0,k.jsxs)(`p`,{children:[`Connected to `,(0,k.jsxs)(`span`,{className:`font-medium text-white`,children:[`@`,r.botUsername]}),r.chatUsername&&(0,k.jsxs)(k.Fragment,{children:[` · chat `,(0,k.jsxs)(`span`,{className:`font-medium text-white`,children:[`@`,r.chatUsername]})]}),r.chatId!==null&&(0,k.jsxs)(k.Fragment,{children:[` · id `,(0,k.jsx)(`span`,{className:`font-medium text-white`,children:r.chatId})]})]}),(0,k.jsx)(`button`,{type:`button`,disabled:u.isPending,onClick:()=>u.mutate(),className:`cursor-pointer rounded-full border border-red-800 px-4 py-2 text-sm text-red-300 hover:bg-red-950 disabled:cursor-not-allowed disabled:opacity-50`,children:`Disconnect Telegram`})]}):(0,k.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,onClick:()=>c(!0),className:`${P} mt-4`,children:`Connect Telegram`}),u.error&&(0,k.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-red-300`,children:u.error.message}),r.connected&&t&&(0,k.jsx)(M,{agentId:e}),o&&(0,k.jsx)(z,{agentId:e,initial:r,onClose:()=>c(!1),onChanged:l})]})}function V({initial:e}){return(0,k.jsxs)(`div`,{className:`w-full space-y-2`,children:[(0,k.jsxs)(`section`,{className:`rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6`,children:[(0,k.jsx)(`h2`,{className:`text-lg font-medium text-white`,children:`Settings`}),(0,k.jsxs)(`dl`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`dt`,{className:`text-xs uppercase tracking-wide text-zinc-500`,children:`Trading account`}),(0,k.jsx)(`dd`,{className:`mt-2 break-all font-mono text-sm text-zinc-300`,children:e.agent.tradingAccountAddress??`No account linked (chat only)`})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`dt`,{className:`text-xs uppercase tracking-wide text-zinc-500`,children:`Lifecycle status`}),(0,k.jsx)(`dd`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-2 text-sm text-zinc-300`,children:e.agent.state===`stopping`||e.agent.state===`stopped`?e.agent.state:(0,k.jsx)(E,{id:e.agent.id,name:e.agent.name,enabled:e.agent.enabled,variant:`settings`})})]})]})]}),e.agent.state!==`stopping`&&e.agent.state!==`stopped`&&(0,k.jsx)(L,{agentId:e.agent.id}),(0,k.jsx)(B,{agentId:e.agent.id,notificationsAvailable:e.agent.state!==`stopping`&&e.agent.state!==`stopped`}),(0,k.jsx)(R,{agent:e.agent})]})}function H(){let{agentId:e}=v.useParams(),{data:t}=s(d(e));return(0,k.jsx)(V,{initial:t},e)}export{H as component};
|
|
1
|
+
import{f as e,l as t,t as n}from"./jsx-runtime-CIazjfqY.js";import{t as r}from"./react-dom-C6bOPxes.js";import{i}from"./createServerFn-DfZIp2Fu.js";import{t as a}from"./useMutation-DrF53EQG.js";import{t as o}from"./useQuery-BMSU16jY.js";import{t as s}from"./useSuspenseQuery-vODFwDb8.js";import{t as c}from"./useRouter-c0I1aURm.js";import{o as l,p as u,t as d}from"./agent-queries-CNMBImun.js";import{n as f,t as p}from"./risk-queries-D_6PHwus.js";import{a as m,r as h,t as g}from"./notification-queries-B12DG3aS.js";import{_,f as v,g as y,h as b,j as x,m as S,p as C}from"./index-B4hvjMmI.js";import{n as w}from"./config-dialog-C9x9gKW9.js";import{t as T}from"./instrument-picker-DLPpryOm.js";import{t as E}from"./agent-enablement-control-CUzOp9ce.js";var D=e(r(),1),O=e(t(),1),k=n(),A=`size-4 cursor-pointer accent-violet-500 disabled:cursor-not-allowed disabled:opacity-50`;function j({agentId:e,saved:t}){let n=i(),[r,o]=(0,O.useState)(t),s=a({mutationFn:t=>m({data:{agentId:e,...t}}),onSuccess:async t=>{n.setQueryData(h(e).queryKey,t),x.success(`Notification settings saved`),await n.invalidateQueries({queryKey:g.all(e)})}}),c=r.enabled!==t.enabled||r.submissions!==t.submissions||r.fills!==t.fills;return(0,k.jsxs)(`form`,{className:`mt-4 space-y-4`,onSubmit:e=>{e.preventDefault(),!s.isPending&&c&&s.mutate(r)},children:[(0,k.jsxs)(`fieldset`,{disabled:s.isPending,className:`space-y-3 text-sm text-zinc-300`,children:[(0,k.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3`,children:[(0,k.jsx)(`input`,{type:`checkbox`,className:A,checked:r.enabled,onChange:e=>o(t=>({...t,enabled:e.target.checked}))}),`Enable Telegram notifications`]}),(0,k.jsxs)(`fieldset`,{disabled:!r.enabled,className:`space-y-3 pl-7 disabled:opacity-50`,children:[(0,k.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3`,children:[(0,k.jsx)(`input`,{type:`checkbox`,className:A,checked:r.submissions,onChange:e=>o(t=>({...t,submissions:e.target.checked}))}),`Order submissions`]}),(0,k.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3`,children:[(0,k.jsx)(`input`,{type:`checkbox`,className:A,checked:r.fills,onChange:e=>o(t=>({...t,fills:e.target.checked}))}),`Order fills (including external/manual trades)`]})]}),c&&(0,k.jsx)(`button`,{type:`submit`,disabled:s.isPending,className:`cursor-pointer rounded-full bg-violet-600 px-4 py-2 text-sm text-white hover:bg-violet-500 disabled:cursor-wait disabled:opacity-50`,children:s.isPending?`Saving…`:`Save Telegram notification settings`})]}),s.error&&(0,k.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:s.error.message})]})}function M({agentId:e}){let t=o(h(e));return(0,k.jsxs)(`section`,{id:`notifications`,"aria-label":`Notifications`,className:`mt-6 scroll-mt-2 border-t border-zinc-800 pt-6`,children:[(0,k.jsx)(`h3`,{className:`font-medium text-white`,children:`Notifications`}),t.isPending?(0,k.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-zinc-400`,children:`Loading notification settings…`}):t.data?(0,k.jsx)(j,{agentId:e,saved:t.data},e):null,t.error&&(0,k.jsxs)(`p`,{role:`alert`,className:`mt-3 text-sm text-red-300`,children:[t.error.message,` `,(0,k.jsx)(`button`,{type:`button`,className:`cursor-pointer text-violet-300 hover:underline`,onClick:()=>{t.refetch()},children:`Retry`})]})]})}var N=`cursor-pointer rounded-full bg-violet-600 px-4 py-2 text-sm text-white hover:bg-violet-500 disabled:cursor-not-allowed disabled:opacity-50`,P=`cursor-pointer rounded-full border border-violet-600 px-4 py-2 text-sm text-violet-300 hover:border-violet-500 hover:bg-violet-950 disabled:cursor-not-allowed disabled:opacity-50`,F=`size-4 shrink-0 cursor-pointer appearance-none rounded-full border border-zinc-600 bg-zinc-950 transition checked:border-[5px] checked:border-violet-500 checked:bg-white hover:border-violet-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-400 focus-visible:ring-offset-2 focus-visible:ring-offset-zinc-950 disabled:cursor-wait disabled:opacity-50`;function I({title:e,inputLabel:t,placeholder:n,value:r,onChange:i}){let a=(0,O.useId)();return(0,k.jsxs)(`fieldset`,{className:`min-w-0 space-y-3 text-sm text-zinc-300`,children:[(0,k.jsx)(`legend`,{className:`mb-3 font-medium`,children:e}),(0,k.jsxs)(`label`,{className:`flex w-fit cursor-pointer items-center gap-2`,children:[(0,k.jsx)(`input`,{type:`radio`,name:a,value:`unlimited`,className:F,checked:!r.limited,onChange:()=>i({...r,limited:!1})}),`No limit`]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,k.jsxs)(`label`,{className:`flex shrink-0 cursor-pointer items-center gap-2`,children:[(0,k.jsx)(`input`,{type:`radio`,name:a,value:`limited`,className:F,checked:r.limited,onChange:()=>i({...r,limited:!0})}),`Limit:`]}),(0,k.jsxs)(`div`,{className:`relative min-w-0 flex-1 ${r.limited?``:`opacity-50`}`,children:[(0,k.jsx)(`input`,{"aria-label":t,"aria-describedby":`${a}-currency`,className:`block w-full rounded-lg border border-zinc-700 bg-zinc-950 py-2.5 pl-3 pr-16 text-sm text-white focus-visible:border-violet-400 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-violet-400 disabled:cursor-not-allowed`,inputMode:`decimal`,placeholder:n,disabled:!r.limited,value:r.amount,onChange:e=>i({...r,amount:e.target.value})}),(0,k.jsx)(`span`,{id:`${a}-currency`,className:`pointer-events-none absolute inset-y-0 right-3 flex items-center text-xs text-zinc-500`,children:`USDC`})]})]})]})}function L({agentId:e}){let t=i(),{data:n,error:r}=s(p(e)),[o,c]=(0,O.useState)(n.tradingEnabled),[u,d]=(0,O.useState)(n.allowedInstruments),[m,h]=(0,O.useState)({limited:n.maxOrderNotional!==null,amount:n.maxOrderNotional??``}),[g,_]=(0,O.useState)({limited:n.maxTotalNotional!==null,amount:n.maxTotalNotional??``}),v=a({mutationFn:async t=>{if(m.limited&&!m.amount.trim())throw Error(`Enter a max order notional limit or select No limit.`);if(g.limited&&!g.amount.trim())throw Error(`Enter a max total exposure limit or select No limit.`);return f({data:{agentId:e,settings:t}})},onSuccess:async n=>{t.setQueryData(p(e).queryKey,n),x.success(`Risk settings saved`),await l(t)}}),y=v.isPending,b=v.error?.message??r?.message,S={tradingEnabled:o,allowedInstruments:u,maxOrderNotional:m.limited?m.amount.trim():null,maxTotalNotional:g.limited?g.amount.trim():null},C=S.tradingEnabled!==n.tradingEnabled||JSON.stringify(S.allowedInstruments===null?null:[...S.allowedInstruments].sort())!==JSON.stringify(n.allowedInstruments===null?null:[...n.allowedInstruments].sort())||S.maxOrderNotional!==n.maxOrderNotional||S.maxTotalNotional!==n.maxTotalNotional;function w(){!y&&C&&v.mutate(S)}return(0,k.jsxs)(`section`,{id:`risk-management`,className:`w-full scroll-mt-2 rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6`,"aria-label":`Risk management`,children:[(0,k.jsx)(`h2`,{className:`text-lg font-medium text-white`,children:`Risk management`}),(0,k.jsxs)(`fieldset`,{disabled:y,className:`mt-4 space-y-4`,children:[(0,k.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 text-sm text-zinc-300`,children:[(0,k.jsxs)(`span`,{className:`relative inline-flex size-5 shrink-0`,children:[(0,k.jsx)(`input`,{type:`checkbox`,className:`peer size-5 cursor-pointer appearance-none rounded border border-zinc-600 bg-zinc-950 transition checked:border-violet-500 checked:bg-violet-600 hover:border-violet-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-400 focus-visible:ring-offset-2 focus-visible:ring-offset-zinc-950 disabled:cursor-wait disabled:opacity-50`,checked:o,onChange:e=>c(e.target.checked)}),(0,k.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:2.5,className:`pointer-events-none absolute inset-0.5 size-4 text-white opacity-0 transition peer-checked:opacity-100 peer-disabled:text-zinc-400`,children:(0,k.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m4 10 4 4 8-8`})})]}),(0,k.jsx)(`span`,{children:`Enable Trading`})]}),(0,k.jsx)(T,{agentId:e,value:u,onChange:d,disabled:y}),(0,k.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,k.jsx)(I,{title:`Max order notional`,inputLabel:`Max order notional`,placeholder:`1000`,value:m,onChange:h}),(0,k.jsx)(I,{title:`Max total exposure`,inputLabel:`Max total notional`,placeholder:`5000`,value:g,onChange:_})]}),C&&(0,k.jsx)(`button`,{type:`button`,className:N,disabled:y,onClick:()=>{w()},children:y?`Saving…`:`Save risk settings`})]}),b&&(0,k.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-red-300`,children:b})]})}function R({agent:e}){let t=c(),[n,r]=(0,O.useState)(!1),[o,s]=(0,O.useState)(``),d=i(),f=a({mutationFn:()=>u({data:{id:e.id,confirmation:o}}),onSuccess:async()=>{await t.navigate({to:`/agents`});for(let t of[`agent`,`agent-chat`,`agent-history`,`agent-dashboard`,`risk`,`journal`,`journal-notes`,`journal-audit`,`subagents`,`memories`,`insights`,`artifacts`,`chart-instruments`,`chart-layouts`,`chart-history`,`chart-fills`,`notifications`,`notification-settings`])d.removeQueries({queryKey:[t,e.id]});x.success(`Agent deleted`)},onSettled:async(t,n)=>{await l(d),n&&await Promise.all([d.invalidateQueries({queryKey:[`agent`,e.id]}),d.invalidateQueries({queryKey:[`agent-chat`,e.id]})])}}),p=f.isPending,m=f.error?.message;function h(){!p&&o===e.name&&f.mutate()}return(0,k.jsxs)(`section`,{"aria-label":`Danger zone`,className:`rounded-2xl border border-red-900/60 bg-[#0d0d10] p-6`,children:[(0,k.jsx)(`h2`,{className:`text-lg font-medium text-red-300`,children:`Danger zone`}),(0,k.jsx)(`p`,{className:`mt-3 text-sm text-zinc-400`,children:`Deleting this agent stops its workers, removes its configuration and application history, and releases its Hyperliquid account for reuse. Existing exchange orders and positions are not changed. This cannot be undone.`}),e.error&&(e.state===`stopping`||e.state===`stopped`)&&(0,k.jsx)(`p`,{role:`status`,className:`mt-3 text-sm text-red-300`,children:e.error}),n?(0,k.jsxs)(`form`,{className:`mt-4 space-y-3`,onSubmit:e=>{e.preventDefault(),h()},children:[(0,k.jsxs)(`label`,{className:`block text-sm text-zinc-300`,children:[`Type `,(0,k.jsx)(`strong`,{children:e.name}),` to confirm deletion`,(0,k.jsx)(`input`,{"aria-label":`Agent name confirmation`,autoComplete:`off`,value:o,disabled:p,onChange:e=>s(e.target.value),className:`mt-2 block w-full rounded-lg border border-zinc-700 bg-zinc-950 px-3 py-2 text-white`})]}),(0,k.jsxs)(`div`,{className:`flex gap-3`,children:[(0,k.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>{r(!1),s(``),f.reset()},className:`cursor-pointer rounded-full border border-zinc-700 px-4 py-2 text-sm text-zinc-300 disabled:cursor-not-allowed`,children:`Cancel`}),(0,k.jsx)(`button`,{type:`submit`,disabled:p||o!==e.name,className:`cursor-pointer rounded-full bg-red-700 px-4 py-2 text-sm text-white hover:bg-red-600 disabled:cursor-not-allowed disabled:opacity-50`,children:p?`Stopping and deleting…`:`Permanently delete agent`})]})]}):(0,k.jsx)(`button`,{type:`button`,onClick:()=>r(!0),className:`mt-4 cursor-pointer rounded-full border border-red-800 px-4 py-2 text-sm text-red-300 hover:bg-red-950`,children:`Delete agent`}),m&&(0,k.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-red-300`,children:m})]})}function z({agentId:e,initial:t,pollMs:n=4e3,onClose:r,onChanged:i}){let o=(0,O.useRef)(null),s=(0,O.useId)(),[c,l]=(0,O.useState)(t),[u,d]=(0,O.useState)(``),[f,p]=(0,O.useState)(null);(0,O.useEffect)(()=>{let e=o.current;return e.showModal(),()=>e.close()},[]),(0,O.useEffect)(()=>{if(!c.hasToken||c.connected)return;let t=setInterval(()=>{y({data:{id:e}}).then(e=>{l(t=>t.hasToken===e.hasToken&&t.connected===e.connected?t:e),e.connected&&i(e)}).catch(()=>void 0)},n);return()=>clearInterval(t)},[c.hasToken,c.connected,e,n,i]);let m=a({mutationFn:()=>S({data:{id:e,token:u}}),onSuccess:e=>{d(``),l(e),i(e),x.success(`Telegram bot added`)}}),h=a({mutationFn:()=>_({data:{id:e}}),onSuccess:({link:e})=>p(e)}),g=a({mutationFn:()=>b({data:{id:e}}),onSuccess:e=>{p(null),l(e),i(e)}}),v=m.isPending||h.isPending||g.isPending,C=m.error?.message??h.error?.message??g.error?.message;return(0,D.createPortal)((0,k.jsxs)(`dialog`,{ref:o,"aria-labelledby":s,onCancel:e=>{e.preventDefault(),r()},className:`m-auto flex max-h-[calc(100dvh-2rem)] w-[calc(100%_-_2rem)] max-w-md flex-col rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6 text-zinc-200 shadow-2xl backdrop:bg-black/70 backdrop:backdrop-blur-sm`,children:[(0,k.jsxs)(`h3`,{id:s,className:`flex items-center gap-2 text-lg font-semibold text-white`,children:[(0,k.jsx)(`img`,{src:`/static/telegram.svg`,alt:``,"aria-hidden":`true`,className:`h-5 w-5 rounded-full`}),`Connect Telegram`]}),(0,k.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 space-y-4 overflow-y-auto text-sm`,children:[c.hasToken?c.connected?(0,k.jsx)(k.Fragment,{children:(0,k.jsxs)(`p`,{role:`status`,children:[`Telegram connected — this Agent's main conversation is bridged to `,(0,k.jsxs)(`span`,{className:`font-medium text-white`,children:[`@`,c.botUsername]}),c.chatUsername&&(0,k.jsxs)(k.Fragment,{children:[` · chat `,(0,k.jsxs)(`span`,{className:`font-medium text-white`,children:[`@`,c.chatUsername]})]}),c.chatId!==null&&(0,k.jsxs)(k.Fragment,{children:[` · id `,(0,k.jsx)(`span`,{className:`font-medium text-white`,children:c.chatId})]}),`.`]})}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`p`,{className:`text-zinc-400`,children:[`Bot `,(0,k.jsxs)(`span`,{className:`font-medium text-white`,children:[`@`,c.botUsername]}),` is ready. Link the Telegram chat this Agent should talk in.`]}),f?(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsx)(`a`,{className:`${N} inline-block`,href:f,target:`_blank`,rel:`noopener noreferrer`,children:`Open Telegram`}),(0,k.jsxs)(`p`,{className:`text-zinc-500`,children:[`Then send the prefilled `,(0,k.jsx)(`code`,{className:`text-zinc-400`,children:`/start`}),` command. This dialog updates automatically once the chat is linked.`]})]}):(0,k.jsx)(`button`,{type:`button`,disabled:v,onClick:()=>h.mutate(),className:N,children:`Link Telegram chat`}),(0,k.jsx)(`button`,{type:`button`,disabled:v,onClick:()=>g.mutate(),className:`block rounded-full border border-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-900 disabled:cursor-not-allowed disabled:opacity-50`,children:`Remove bot token`})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`p`,{className:`text-zinc-400`,children:[`Create a bot with `,(0,k.jsx)(`a`,{className:`cursor-pointer text-violet-400 underline hover:text-violet-300`,href:`https://t.me/BotFather`,target:`_blank`,rel:`noopener noreferrer`,children:`@BotFather`}),`, then paste its token here. One bot can only serve one Agent.`]}),(0,k.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),u.trim()&&!v&&m.mutate()},children:[(0,k.jsxs)(`label`,{className:`block text-zinc-300`,htmlFor:s+`-token`,children:[`Bot token`,(0,k.jsx)(`input`,{id:s+`-token`,"aria-label":`Telegram bot token`,autoComplete:`off`,value:u,disabled:v,onChange:e=>d(e.target.value),className:`mt-2 block w-full rounded-lg border border-zinc-700 bg-zinc-950 px-3 py-2 font-mono text-sm text-white`,placeholder:`123456789:AAE…`})]}),(0,k.jsx)(`button`,{type:`submit`,disabled:v||!u.trim(),className:`${N} mt-4`,children:`Add bot token`})]})]}),C&&(0,k.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:C})]}),(0,k.jsx)(`footer`,{className:`mt-6 flex shrink-0 justify-end border-t border-zinc-800 pt-4`,children:(0,k.jsx)(`button`,{type:`button`,onClick:r,className:w,children:c.connected?`Done`:`Close`})})]}),document.body)}function B({agentId:e,notificationsAvailable:t}){let n=i(),{data:r}=s(C(e)),[o,c]=(0,O.useState)(!1),l=(0,O.useCallback)(t=>n.setQueryData(C(e).queryKey,t),[n,e]),u=a({mutationFn:()=>b({data:{id:e}}),onSuccess:async e=>{l(e),x.success(`Telegram disconnected`)}});return(0,k.jsxs)(`section`,{id:`telegram`,className:`w-full scroll-mt-2 rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6`,"aria-label":`Telegram`,children:[(0,k.jsxs)(`h2`,{className:`flex items-center gap-2 text-lg font-medium text-white`,children:[(0,k.jsx)(`img`,{src:`/static/telegram.svg`,alt:``,"aria-hidden":`true`,className:`h-5 w-5 rounded-full`}),`Telegram`]}),r.error&&(0,k.jsx)(`p`,{role:`status`,className:`mt-3 text-sm text-amber-300`,children:r.error}),r.connected?(0,k.jsxs)(`div`,{className:`mt-4 space-y-3 text-sm text-zinc-300`,children:[(0,k.jsxs)(`p`,{children:[`Connected to `,(0,k.jsxs)(`span`,{className:`font-medium text-white`,children:[`@`,r.botUsername]}),r.chatUsername&&(0,k.jsxs)(k.Fragment,{children:[` · chat `,(0,k.jsxs)(`span`,{className:`font-medium text-white`,children:[`@`,r.chatUsername]})]}),r.chatId!==null&&(0,k.jsxs)(k.Fragment,{children:[` · id `,(0,k.jsx)(`span`,{className:`font-medium text-white`,children:r.chatId})]})]}),(0,k.jsx)(`button`,{type:`button`,disabled:u.isPending,onClick:()=>u.mutate(),className:`cursor-pointer rounded-full border border-red-800 px-4 py-2 text-sm text-red-300 hover:bg-red-950 disabled:cursor-not-allowed disabled:opacity-50`,children:`Disconnect Telegram`})]}):(0,k.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,onClick:()=>c(!0),className:`${P} mt-4`,children:`Connect Telegram`}),u.error&&(0,k.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-red-300`,children:u.error.message}),r.connected&&t&&(0,k.jsx)(M,{agentId:e}),o&&(0,k.jsx)(z,{agentId:e,initial:r,onClose:()=>c(!1),onChanged:l})]})}function V({initial:e}){return(0,k.jsxs)(`div`,{className:`w-full space-y-2`,children:[(0,k.jsxs)(`section`,{className:`rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6`,children:[(0,k.jsx)(`h2`,{className:`text-lg font-medium text-white`,children:`Settings`}),(0,k.jsxs)(`dl`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`dt`,{className:`text-xs uppercase tracking-wide text-zinc-500`,children:`Trading account`}),(0,k.jsx)(`dd`,{className:`mt-2 break-all font-mono text-sm text-zinc-300`,children:e.agent.tradingAccountAddress??`No account linked (chat only)`})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`dt`,{className:`text-xs uppercase tracking-wide text-zinc-500`,children:`Lifecycle status`}),(0,k.jsx)(`dd`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-2 text-sm text-zinc-300`,children:e.agent.state===`stopping`||e.agent.state===`stopped`?e.agent.state:(0,k.jsx)(E,{id:e.agent.id,name:e.agent.name,enabled:e.agent.enabled,variant:`settings`})})]})]})]}),e.agent.state!==`stopping`&&e.agent.state!==`stopped`&&(0,k.jsx)(L,{agentId:e.agent.id}),(0,k.jsx)(B,{agentId:e.agent.id,notificationsAvailable:e.agent.state!==`stopping`&&e.agent.state!==`stopped`}),(0,k.jsx)(R,{agent:e.agent})]})}function H(){let{agentId:e}=v.useParams(),{data:t}=s(d(e));return(0,k.jsx)(V,{initial:t},e)}export{H as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{M as e}from"./index-B4hvjMmI.js";var t=e;export{t as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e,l as t,t as n}from"./jsx-runtime-CIazjfqY.js";import{i as r}from"./createServerFn-DfZIp2Fu.js";import{t as i}from"./useMutation-Dni_73Pp.js";import{t as a}from"./useSuspenseQuery-vODFwDb8.js";import{r as o}from"./provider-queries-DxPwhDOU.js";import{t as s}from"./useRouter-c0I1aURm.js";import{d as c,f as l,g as u,i as d,m as f,s as p,t as m}from"./subagent-queries-DVv5JCfs.js";import{r as h,t as g}from"./worker-triggers-DtXyn40O.js";import{t as _}from"./memory-contracts-Doi_Q1XJ.js";import{j as v,r as y}from"./index-fu66g8fn.js";import{t as ee}from"./random-uuid-DJR3ygJS.js";import{t as b}from"./contracts-HhAL7Tt7.js";import{t as te}from"./subagent-mutations-DfsDbmFu.js";import{n as x,r as S,t as C}from"./config-dialog-C9x9gKW9.js";import{t as ne}from"./provider-logo-Ddb77aBD.js";import{a as w,n as re}from"./model-picker-YCQNNmyw.js";import{t as T}from"./esm-BTb2nBdW.js";import{t as E}from"./subagent-enabled-toggle-Bk5wfScg.js";import{t as ie}from"./run-subagent-dialog-B4yQe9T9.js";import{r as ae}from"./subagent-run-history-D55Uh5VK.js";import{a as D,i as O,n as k,o as A,r as j,t as oe}from"./subagent-input-TQke90I1.js";var M=e(t(),1),N=n();function P({value:e=g,workers:t,onChange:n}){let[r,i]=(0,M.useState)(!1);return(0,N.jsxs)(`section`,{className:`space-y-2`,children:[(0,N.jsxs)(`header`,{className:`flex items-center justify-between gap-4`,children:[(0,N.jsx)(`h3`,{className:`font-medium text-white`,children:`Event triggers`}),(0,N.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,onClick:()=>i(!0),className:x,children:`Edit triggers`})]}),(0,N.jsx)(`p`,{className:`text-sm text-zinc-400`,children:e.inboxEnabled?`Event-driven inbox enabled`:`Event-driven inbox disabled`}),e.inboxEnabled&&(0,N.jsxs)(`p`,{className:`text-sm text-zinc-400`,children:[[e.researchSources.length?`${e.researchSources.length} research sources`:``,e.fills?`Order fills`:``,e.orderChanges?`Order status changes`:``].filter(Boolean).join(` · `)||`No automatic events selected`,` · `,e.workerDelegates.length,` approved worker callers`]}),r&&(0,N.jsx)(F,{value:e,workers:t,onCancel:()=>i(!1),onApply:async e=>{await n(e),i(!1)}})]})}function F({value:e,workers:t,onCancel:n,onApply:r}){let[i,a]=(0,M.useState)(e),[o,s]=(0,M.useState)(!1),[c,l]=(0,M.useState)(``),u=(0,M.useRef)(!1);async function d(){if(!u.current){u.current=!0,s(!0),l(``);try{await r(i)}catch(e){l(e instanceof Error?e.message:`Unable to save triggers`)}finally{u.current=!1,s(!1)}}}let f=(e,n)=>(0,N.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,N.jsx)(`legend`,{className:`mb-2 text-sm font-medium text-white`,children:n}),t.length?t.map(t=>(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 text-sm`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:i[e].includes(t.id),disabled:t.archived&&!i[e].includes(t.id),onChange:n=>a(r=>({...r,[e]:n.target.checked?[...r[e],t.id]:r[e].filter(e=>e!==t.id)})),className:`cursor-pointer`}),t.name,t.archived?` (archived)`:``]},t.id)):(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Create another worker first.`})]});return(0,N.jsxs)(C,{title:`Event triggers`,onCancel:()=>{u.current||n()},onApply:()=>{d()},applyDisabled:o,children:[(0,N.jsxs)(`fieldset`,{disabled:o,className:`space-y-5 disabled:opacity-60`,children:[(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 text-sm`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:i.inboxEnabled,onChange:e=>a(e.target.checked?{...i,inboxEnabled:!0}:{...g}),className:`cursor-pointer`}),`Enable event triggers`]}),i.inboxEnabled&&(0,N.jsxs)(N.Fragment,{children:[f(`researchSources`,`Research published`),f(`workerDelegates`,`Allow research delegation from`),t.filter(e=>i.workerDelegates.includes(e.id)&&e.tools!==void 0&&!D(e.tools).includes(`delegate_subagent`)).map(e=>(0,N.jsxs)(`p`,{role:`status`,className:`text-xs text-amber-200`,children:[e.name,` cannot delegate: enable delegate_subagent in its Tools.`]},e.id)),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 text-sm`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:i.fills,onChange:e=>a(t=>({...t,fills:e.target.checked})),className:`cursor-pointer`}),`Order fills — partial or complete`]}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 text-sm`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:i.orderChanges,onChange:e=>a(t=>({...t,orderChanges:e.target.checked})),className:`cursor-pointer`}),`Order status changes — canceled, rejected, expired`]})]})]}),c&&(0,N.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:c})]})}function I(e,t=1){let n=Math.max(1,Math.ceil(e/50));return{page:Math.min(t,n),pages:n,total:e,pageSize:50}}function se(e,t,n){let[r,i]=(0,M.useState)(()=>({runs:n?.runs??[],pagination:n?.pagination??I(n?.runs.length??0),schedulerError:n?.schedulerError??null})),[a,o]=(0,M.useState)(1),[s,c]=(0,M.useState)(!1),[l,u]=(0,M.useState)(``);return(0,M.useEffect)(()=>{if(!t)return;let n=!0;c(!0),u(``);let r=new EventSource(`/api/agents/${encodeURIComponent(e)}/sub-agents/${encodeURIComponent(t)}/runs/events?page=${a}`),s=(e,t)=>{n&&(c(!1),u(e?JSON.parse(e.data).message??t:t))};return r.addEventListener(`runs`,e=>{if(!n)return;let t=JSON.parse(e.data);i(t),c(!1),u(``),t.pagination.page!==a&&o(t.pagination.page)}),r.addEventListener(`unauthorized`,()=>{n&&window.location.assign(`/login`)}),r.addEventListener(`shutdown`,()=>s(void 0,`Server is restarting. Reconnecting…`)),r.addEventListener(`unavailable`,e=>s(e,`Run history updates interrupted. Reconnecting…`)),r.addEventListener(`stream-error`,e=>s(e,`Run history could not be streamed.`)),r.onerror=()=>s(void 0,`Live updates interrupted. Showing the last received history. Reconnecting…`),()=>{n=!1,r.close()}},[e,t,a]),{history:r,loading:s,connectionError:l,setPage:o}}function ce({name:e,onCancel:t,onConfirm:n}){let r=(0,M.useRef)(null),i=(0,M.useId)();return(0,M.useEffect)(()=>{let e=r.current;return e.showModal(),()=>e.close()},[]),(0,N.jsxs)(`dialog`,{ref:r,"aria-labelledby":i,"aria-describedby":`${i}-description`,onCancel:e=>{e.preventDefault(),t()},className:`m-auto w-[calc(100%_-_2rem)] max-w-md rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6 text-zinc-100 shadow-2xl backdrop:bg-black/70 backdrop:backdrop-blur-sm`,children:[(0,N.jsx)(`h3`,{id:i,className:`text-lg font-semibold text-white`,children:`Archive sub-agent?`}),(0,N.jsxs)(`p`,{id:`${i}-description`,className:`mt-2 text-sm leading-6 text-zinc-400`,children:[`Archive “`,e,`”? New assignments will be disabled. Its configuration and run history will be preserved.`]}),(0,N.jsxs)(`div`,{className:`mt-6 flex flex-col-reverse gap-3 sm:flex-row sm:justify-end`,children:[(0,N.jsx)(`button`,{type:`button`,autoFocus:!0,onClick:t,className:`cursor-pointer rounded-full border border-zinc-800 px-4 py-2 text-sm font-medium text-zinc-300 hover:border-zinc-700 hover:text-white`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,onClick:n,className:`cursor-pointer rounded-full bg-red-600 px-4 py-2 text-sm font-medium text-white hover:bg-red-500`,children:`Archive sub-agent`})]})]})}function le({value:e,main:t,agentId:n,enabled:r,onToggleEnabled:i,onChange:a,actions:o}){let[s,c]=(0,M.useState)(!1);return(0,N.jsxs)(`section`,{className:`space-y-2`,children:[(0,N.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,N.jsxs)(`nav`,{"aria-label":`Sub-agent breadcrumb`,className:`flex min-w-0 flex-1 flex-wrap items-center gap-2`,children:[(0,N.jsxs)(`a`,{href:`/agents/${n}/sub-agents`,className:`cursor-pointer text-sm text-zinc-400 hover:text-white`,children:[(0,N.jsx)(`span`,{"aria-hidden":`true`,children:`← `}),`Sub-agents`]}),(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`text-zinc-600`,children:`/`}),(0,N.jsxs)(`h2`,{"aria-current":`page`,className:`break-words text-lg font-medium text-white`,children:[e.name||`Create subagent`,t&&` · Main conversation`]}),!t&&(0,N.jsx)(E,{enabled:r,onClick:i}),(0,N.jsx)(`span`,{className:`min-w-0 break-words text-sm text-zinc-400`,children:e.description||`No description`}),(0,N.jsx)(`button`,{type:`button`,"aria-label":`Edit name and description`,title:`Edit name and description`,"aria-haspopup":`dialog`,onClick:()=>c(!0),className:`inline-flex shrink-0 cursor-pointer items-center justify-center rounded-md p-1 text-zinc-400 hover:bg-zinc-800 hover:text-white`,children:(0,N.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,className:`size-4`,children:(0,N.jsx)(`path`,{d:`m16 4 4 4M4 20l4-1L21 6a2.8 2.8 0 0 0-4-4L4 15z`})})})]}),o&&(0,N.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:o})]}),(0,N.jsx)(`hr`,{className:`border-zinc-800`}),s&&(0,N.jsx)(L,{value:e,onCancel:()=>c(!1),onApply:async e=>{await a(e),c(!1)}})]})}function L({value:e,onCancel:t,onApply:n}){let[r,i]=(0,M.useState)(e),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(``),l=(0,M.useRef)(!1),u=(0,M.useId)();async function d(){if(!(l.current||!r.name.trim())){l.current=!0,o(!0),c(``);try{await n({name:r.name.trim(),description:r.description.trim()})}catch(e){c(e instanceof Error?e.message:`Unable to save name and description. Please retry.`)}finally{l.current=!1,o(!1)}}}return(0,N.jsxs)(C,{title:`Edit name and description`,onCancel:()=>{l.current||t()},onApply:()=>{d()},applyDisabled:a||!r.name.trim(),children:[(0,N.jsxs)(`fieldset`,{disabled:a,className:`space-y-5 disabled:opacity-60`,children:[(0,N.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[`Name`,(0,N.jsx)(`input`,{autoFocus:!0,required:!0,maxLength:80,value:r.name,onChange:e=>i(t=>({...t,name:e.target.value})),className:S})]}),(0,N.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[`Description`,(0,N.jsx)(`input`,{"aria-describedby":u,maxLength:500,value:r.description,onChange:e=>i(t=>({...t,description:e.target.value})),className:S}),(0,N.jsx)(`span`,{id:u,className:`block text-xs text-zinc-400`,children:`Human-readable description.`})]})]}),a&&(0,N.jsx)(`p`,{role:`status`,className:`text-sm text-zinc-400`,children:`Saving…`}),s&&(0,N.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:s})]})}var R=[{name:`Hyperliquid`,tools:k},{name:`Research · Code Mode & Artifacts`,tools:A},{name:`Indicators — Read & Calculate`,tools:O},{name:`Indicators — Develop`,tools:j},{name:`Memories & Insights`,tools:_},{name:`Chart workspace · Orchestrator only`,tools:b},{name:`HyperVibes · Notifications`,tools:[`send_notification`]},{name:`HyperVibes · Subagents`,tools:[`list_subagents`,`delegate_subagent`,`list_subagent_runs`,`get_subagent_run`]}];function ue({tools:e,onChange:t,main:n=!1}){let[r,i]=(0,M.useState)(!1);return(0,N.jsxs)(`section`,{className:`space-y-2`,children:[(0,N.jsxs)(`header`,{className:`flex items-center justify-between gap-4`,children:[(0,N.jsx)(`h3`,{className:`font-medium text-white`,children:`Tools`}),(0,N.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,onClick:()=>i(!0),className:x,children:`Edit tools`})]}),(0,N.jsx)(`p`,{className:`text-sm text-zinc-400`,children:e.length?`${e.length} ${e.length===1?`tool`:`tools`} allowed`:`No tools allowed`}),R.map(t=>{let n=t.tools.filter(t=>e.includes(t));return n.length?(0,N.jsxs)(`p`,{className:`line-clamp-2 break-words text-sm text-zinc-200`,title:`${t.name}: ${n.join(`, `)}`,children:[t.name,`: `,(0,N.jsx)(`span`,{className:`font-mono`,children:n.join(`, `)})]},t.name):null}),r&&(0,N.jsx)(z,{tools:e,main:n,onCancel:()=>i(!1),onApply:async e=>{await t(e),i(!1)}})]})}function z({tools:e,onCancel:t,onApply:n,main:r}){let[i,a]=(0,M.useState)(e),[o,s]=(0,M.useState)(``),[c,l]=(0,M.useState)(!1),[u,d]=(0,M.useState)(``),f=(0,M.useRef)(!1);async function p(){if(!f.current){f.current=!0,l(!0),d(``);try{await n(i)}catch(e){d(e instanceof Error?e.message:`Unable to save tools. Please retry.`)}finally{f.current=!1,l(!1)}}}let m=R.filter(e=>r||e.tools!==b).map(e=>({...e,visibleTools:e.tools.filter(t=>`${e.name} ${t}`.toLowerCase().includes(o.trim().toLowerCase()))})).filter(e=>e.visibleTools.length);return(0,N.jsxs)(C,{title:`Allowed tools`,onCancel:()=>{f.current||t()},onApply:()=>{p()},applyDisabled:c,children:[(0,N.jsxs)(`fieldset`,{disabled:c,className:`space-y-4 disabled:opacity-60`,children:[(0,N.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[`Search extensions and tools`,(0,N.jsx)(`input`,{autoFocus:!0,type:`search`,value:o,onChange:e=>s(e.target.value),className:S})]}),(0,N.jsxs)(`div`,{className:`max-h-80 space-y-4 overflow-y-auto`,children:[m.map(e=>(0,N.jsxs)(`fieldset`,{className:`space-y-3 rounded-xl border border-zinc-800 p-4`,children:[(0,N.jsx)(`legend`,{className:`px-2 text-sm font-medium text-white`,children:(0,N.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-3`,children:[(0,N.jsx)(`span`,{children:e.name}),(0,N.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-xs font-normal`,children:[(0,N.jsx)(`button`,{type:`button`,"aria-label":`All tools in ${e.name}`,onClick:()=>a(t=>[...new Set([...t,...e.tools])]),className:`cursor-pointer text-zinc-400 hover:text-violet-300 hover:underline`,children:`All`}),(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`text-zinc-700`,children:`/`}),(0,N.jsx)(`button`,{type:`button`,"aria-label":`No tools in ${e.name}`,onClick:()=>a(t=>t.filter(t=>!e.tools.some(e=>e===t))),className:`cursor-pointer text-zinc-400 hover:text-violet-300 hover:underline`,children:`None`})]})]})}),(0,N.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:e.visibleTools.map(e=>(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 font-mono text-xs`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:i.includes(e),onChange:t=>a(n=>t.target.checked?[...n,e]:n.filter(t=>t!==e)),className:`cursor-pointer`}),e]},e))})]},e.name)),!m.length&&(0,N.jsx)(`p`,{className:`text-sm text-zinc-400`,children:`No matching tools.`})]}),(0,N.jsxs)(`p`,{className:`text-sm text-zinc-400`,children:[i.length,` selected`,c?` · Saving…`:``]})]}),u&&(0,N.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:u})]})}function de({value:e,onChange:t}){let[n,r]=(0,M.useState)(!1);return(0,N.jsxs)(`section`,{className:`space-y-2`,children:[(0,N.jsxs)(`header`,{className:`flex items-center justify-between gap-4`,children:[(0,N.jsx)(`h3`,{className:`font-medium text-white`,children:`Assignments & context`}),(0,N.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,onClick:()=>r(!0),className:x,children:`Edit assignments`})]}),(0,N.jsxs)(`p`,{className:`text-sm text-zinc-200`,children:[`Orchestrator delegation `,e.delegatable?`allowed`:`disabled`]}),(0,N.jsxs)(`p`,{className:`text-sm text-zinc-200`,children:[e.persistent?`Persistent conversation`:`Fresh context per assignment`,` · Timeout: `,e.timeoutSeconds,`s`]}),n&&(0,N.jsx)(B,{value:e,onCancel:()=>r(!1),onApply:async e=>{await t(e),r(!1)}})]})}function B({value:e,onCancel:t,onApply:n}){let[r,i]=(0,M.useState)({delegatable:e.delegatable,persistent:e.persistent,timeoutSeconds:e.timeoutSeconds}),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(``),l=(0,M.useRef)(!1),u=Number.isInteger(r.timeoutSeconds)&&r.timeoutSeconds>=30&&r.timeoutSeconds<=3600;async function d(){if(!(l.current||!u)){l.current=!0,o(!0),c(``);try{await n(r)}catch(e){c(e instanceof Error?e.message:`Unable to save assignment settings. Please retry.`)}finally{l.current=!1,o(!1)}}}let f=(e,t)=>(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 text-sm`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:r[e],onChange:t=>i(n=>({...n,[e]:t.target.checked})),className:`cursor-pointer`}),t]});return(0,N.jsxs)(C,{title:`Assignments & context`,onCancel:()=>{l.current||t()},onApply:()=>{d()},applyDisabled:a||!u,children:[(0,N.jsxs)(`fieldset`,{disabled:a,className:`space-y-4 disabled:opacity-60`,children:[f(`delegatable`,`Allow orchestrator delegation`),f(`persistent`,`Reuse a persistent conversation (otherwise fresh context per assignment)`),(0,N.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[`Assignment timeout (seconds)`,(0,N.jsx)(`input`,{required:!0,type:`number`,min:30,max:3600,step:1,value:r.timeoutSeconds,onChange:e=>i(t=>({...t,timeoutSeconds:Number(e.target.value)})),className:S})]})]}),a&&(0,N.jsx)(`p`,{role:`status`,className:`text-sm text-zinc-400`,children:`Saving…`}),s&&(0,N.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:s})]})}var V={save:`Save only`,notify:`Notify orchestrator without a model call`,wake:`Notify and wake orchestrator`};function H({timestamp:e}){let[,t]=(0,M.useState)(0);(0,M.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(e)},[]);let n=new Date(e).toISOString();return(0,N.jsxs)(`p`,{className:`text-sm text-violet-300`,children:[`Next run `,(0,N.jsx)(`time`,{dateTime:n,title:n,suppressHydrationWarning:!0,children:e>Date.now()?T(e):`due now`})]})}function fe({value:e,nextRunAt:t,onChange:n}){let[r,i]=(0,M.useState)(!1);return(0,N.jsxs)(`section`,{className:`space-y-2`,children:[(0,N.jsxs)(`header`,{className:`flex items-center justify-between gap-4`,children:[(0,N.jsx)(`h3`,{className:`font-medium text-white`,children:`Schedule`}),(0,N.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,onClick:()=>i(!0),className:x,children:`Edit schedule`})]}),(0,N.jsx)(`p`,{className:`text-sm text-zinc-400`,children:e.schedule?`Every ${e.schedule} candle close (UTC) · ${e.delaySeconds}s delay`:`No schedule · manual, delegated or configured event assignments`}),e.schedule&&t!=null&&(0,N.jsx)(H,{timestamp:t}),(0,N.jsxs)(`p`,{className:`text-xs text-zinc-500`,children:[`Scheduled / manual / event completion: `,V[e.completion]]}),r&&(0,N.jsx)(U,{value:e,onCancel:()=>i(!1),onApply:async e=>{await n(e),i(!1)}})]})}function U({value:e,onCancel:t,onApply:n}){let[r,i]=(0,M.useState)(()=>e.schedule?e:{...e,delaySeconds:1}),a=h[r.schedule],[o,s]=(0,M.useState)(!1),[c,l]=(0,M.useState)(``),u=(0,M.useRef)(!1),d=!r.schedule||Number.isInteger(r.delaySeconds)&&r.delaySeconds>=0&&r.delaySeconds<=300&&r.delaySeconds<a;async function f(){if(!(u.current||!d)){u.current=!0,s(!0),l(``);try{await n({schedule:r.schedule,delaySeconds:r.delaySeconds,completion:r.completion})}catch(e){l(e instanceof Error?e.message:`Unable to save schedule. Please retry.`)}finally{u.current=!1,s(!1)}}}return(0,N.jsxs)(C,{title:`Configure schedule`,onCancel:()=>{u.current||t()},onApply:()=>{f()},applyDisabled:o||!d,children:[(0,N.jsxs)(`fieldset`,{disabled:o,className:`space-y-5 disabled:opacity-60`,children:[(0,N.jsx)(`p`,{className:`text-sm text-zinc-400`,children:`Run after a UTC candle closes.`}),(0,N.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[`UTC candle close`,(0,N.jsxs)(`select`,{value:r.schedule,onChange:e=>i(t=>({...t,schedule:e.target.value})),className:`${S} cursor-pointer`,children:[(0,N.jsx)(`option`,{value:``,children:`No schedule`}),Object.keys(h).map(e=>(0,N.jsx)(`option`,{value:e,children:e===`1d`?`1d / every 24 hours`:e},e))]})]}),r.schedule&&(0,N.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[`Delay after candle close (seconds)`,(0,N.jsx)(`input`,{required:!0,type:`number`,min:0,max:Math.min(300,a-1),step:1,value:r.delaySeconds,onChange:e=>i(t=>({...t,delaySeconds:Number(e.target.value)})),className:`block w-full rounded-xl border border-zinc-700 bg-zinc-950 p-3 text-sm text-white`})]}),(0,N.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[`Scheduled / manual completion`,(0,N.jsx)(`select`,{value:r.completion,onChange:e=>i(t=>({...t,completion:e.target.value})),className:`${S} cursor-pointer`,children:Object.entries(V).map(([e,t])=>(0,N.jsx)(`option`,{value:e,children:t},e))})]})]}),o&&(0,N.jsx)(`p`,{role:`status`,className:`text-sm text-zinc-400`,children:`Saving…`}),c&&(0,N.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:c})]})}var W=`space-y-4 rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6`,pe=`mt-2 block w-full rounded-lg border border-zinc-700 bg-zinc-950 p-3 text-sm text-white`,G=`cursor-pointer rounded-full bg-violet-600 px-4 py-2 text-sm text-white hover:bg-violet-500 disabled:cursor-not-allowed disabled:opacity-50`;function K({agentId:e,subagentId:t,choices:n}){let o=s(),h=r(),g=te(h,e),{data:_,error:y}=a(d(e,t)),b=_.definition,[x,S]=(0,M.useState)(_.definition),[C,T]=(0,M.useState)(``),E=i({mutationFn:e=>e()}),D=E.isPending,O=E.error?.message??y?.message,[k,A]=(0,M.useState)(!1),[j,F]=(0,M.useState)(!1),I=(0,M.useRef)(!1),L=(0,M.useRef)(null),R=b.kind===`orchestrator`,{history:{runs:z,pagination:B,schedulerError:V,schedule:H},loading:U,connectionError:K,setPage:q}=se(e,R?void 0:b.id,_),me=H&&H.updatedAt>=b.updatedAt?H.nextRunAt:b.nextRunAt,J=n.find(e=>w(e)===w(x)),Y=(e,t)=>S(n=>({...n,[e]:t})),he=x.instructions!==b.instructions;async function X(e){if(I.current)throw Error(`An operation is already in progress. Please retry.`);I.current=!0;try{await E.mutateAsync(e)}finally{I.current=!1}}async function Z(e,t){if(b.archived)throw Error(`Settings cannot be changed right now. Please retry.`);await X(async()=>{let n=await g.saveSection({id:b.id,section:e,settings:t}),r=e===`enabled`?{enabled:n.enabled}:e===`instructions`?{instructions:n.instructions}:e===`model`?{provider:n.provider,modelId:n.modelId,thinkingLevel:n.thinkingLevel}:e===`triggers`?{triggers:n.triggers}:{schedule:n.schedule,delaySeconds:n.delaySeconds,completion:n.completion};S(e=>({...e,...r})),v.success(e===`enabled`?n.enabled?`Sub-agent enabled`:`Sub-agent paused`:e===`instructions`?`Instructions updated`:e===`model`?`Model updated`:`Schedule updated`)})}async function Q(){try{await Z(`enabled`,{enabled:!x.enabled})}catch{}}async function ge(){try{await Z(`instructions`,{instructions:x.instructions})}catch{}}async function _e(t){if(b.archived)throw Error(`Settings cannot be changed right now. Please retry.`);await X(async()=>{let n=await c({data:{agentId:e,id:b.id,settings:t}}),{delegatable:r,persistent:i,timeoutSeconds:a}=n;S(e=>({...e,delegatable:r,persistent:i,timeoutSeconds:a})),await m(h,e,n),v.success(`Assignment settings updated`)})}async function ve(t){if(b.archived)throw Error(`Settings cannot be changed right now. Please retry.`);await X(async()=>{let n=await l({data:{agentId:e,id:b.id,...t}});S(e=>({...e,name:n.name,description:n.description})),await m(h,e,n),v.success(`Name and description updated`)})}async function ye(t){if(b.archived)throw Error(`Settings cannot be changed right now. Please retry.`);await X(async()=>{let n=await f({data:{agentId:e,id:b.id,tools:t}});S(e=>({...e,tools:n.tools})),await m(h,e,n),v.success(`Tools updated`)})}async function be(){if(b.archived)throw Error(`This worker is unavailable for new assignments.`);await X(async()=>{L.current?.task!==C&&(L.current={task:C,id:ee()});let t=await g.run({id:b.id,task:C,requestId:L.current.id});L.current=null,F(!1),T(``),v.success(`Assignment started`),await o.navigate({to:`/agents/$agentId/sub-agents/$subagentId/runs/$runId`,params:{agentId:e,subagentId:b.id,runId:t.id}})})}async function $(t,n=``){if(!I.current)try{await X(async()=>{if(t===`stop`)await g.stop(n),v.success(`Assignment stopped`,{description:`Existing exchange orders were not cancelled.`});else if(t===`unarchive`){let t=await u({data:{agentId:e,id:b.id}});S(t),await m(h,e,t),v.success(`Sub-agent unarchived`,{description:`Restored paused. Enable it when ready.`})}else await p({data:{agentId:e,id:b.id}}),await m(h,e,{...b,archived:!0,enabled:!1}),v.success(`Sub-agent archived`,{description:`History is preserved.`}),await o.navigate({to:`/agents/$agentId/sub-agents`,params:{agentId:e}})})}catch{}}return(0,N.jsxs)(`div`,{className:`w-full space-y-3`,children:[b.archived&&!R&&(0,N.jsxs)(`section`,{className:`${W} flex flex-wrap items-center justify-between gap-3`,children:[(0,N.jsx)(`p`,{className:`text-sm text-amber-200`,children:`Archived — history is preserved. Unarchive to edit or run this sub-agent; it will remain paused.`}),(0,N.jsx)(`button`,{type:`button`,disabled:D,onClick:()=>{$(`unarchive`)},className:G,children:`Unarchive`})]}),(0,N.jsx)(`form`,{onSubmit:e=>{e.preventDefault()},className:W,children:(0,N.jsxs)(`fieldset`,{disabled:D||b.archived,className:`space-y-4 disabled:opacity-60`,children:[(0,N.jsx)(le,{value:x,main:R,agentId:e,enabled:x.enabled,onToggleEnabled:()=>{Q()},onChange:ve,actions:R?void 0:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`button`,{type:`button`,disabled:D||b.archived,"aria-haspopup":`dialog`,onClick:()=>F(!0),className:`inline-flex cursor-pointer items-center gap-2 rounded-full border border-violet-500 px-4 py-2 text-sm text-violet-300 hover:bg-violet-950 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,N.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,className:`size-4`,children:(0,N.jsx)(`path`,{d:`m13 2-9 12h7l-1 8 10-12h-7z`})}),`Run now`]}),(0,N.jsx)(`button`,{type:`button`,disabled:D||b.archived,"aria-label":`Archive worker`,title:`Archive worker`,"aria-haspopup":`dialog`,onClick:()=>A(!0),className:`inline-flex cursor-pointer items-center justify-center rounded-full p-2 text-red-300 hover:bg-red-950 hover:text-red-200 disabled:cursor-not-allowed disabled:opacity-50`,children:(0,N.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,className:`size-5`,children:(0,N.jsx)(`path`,{d:`M3 6h18M9 6V3h6v3M5 6l1 15h12l1-15M10 10v7m4-7v7`})})})]})}),b.archived&&(0,N.jsx)(`p`,{className:`text-sm text-amber-200`,children:`Archived — new assignments are disabled. History remains available.`}),!J&&(0,N.jsxs)(`p`,{className:`flex items-center gap-1.5 text-sm text-amber-200`,children:[(0,N.jsx)(ne,{provider:x.provider,className:`h-4 w-4 shrink-0 rounded-sm border border-zinc-800 bg-white p-0.5`}),(0,N.jsxs)(`span`,{children:[`Current model: `,x.provider,`/`,x.modelId,`. Reconnect its provider or select an available model.`]})]}),(0,N.jsx)(re,{choices:n,value:J?w(x):``,thinkingLevel:x.thinkingLevel,onChange:async(e,t)=>{let r=n.find(t=>w(t)===e);r&&await Z(`model`,{provider:r.provider,modelId:r.modelId,thinkingLevel:t})},disabled:D}),(0,N.jsxs)(`div`,{className:R?`space-y-4`:`grid gap-6 md:grid-cols-2`,children:[(0,N.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[(0,N.jsx)(ue,{tools:x.tools,onChange:ye,main:R}),x.tools.includes(`submit_orders`)&&!x.tools.includes(`record_trade_decision`)&&(0,N.jsx)(`p`,{role:`status`,className:`text-sm text-amber-200`,children:`Trading readiness: record_trade_decision is not selected. Existing permissions were not widened; select it explicitly for attributable trade rationale.`})]}),!R&&(0,N.jsxs)(`div`,{className:`min-w-0 space-y-6`,children:[(0,N.jsx)(de,{value:x,onChange:_e}),(0,N.jsx)(P,{value:x.triggers,workers:(_.workers??[]).filter(e=>e.id!==b.id),onChange:e=>Z(`triggers`,{triggers:e})}),(0,N.jsx)(fe,{value:x,nextRunAt:b.enabled&&!b.archived?me:null,onChange:e=>Z(`schedule`,e)})]})]}),(0,N.jsxs)(`label`,{className:`block text-sm text-zinc-300`,children:[`Instructions`,(0,N.jsx)(`textarea`,{required:!0,rows:7,maxLength:32e3,value:x.instructions,onChange:e=>Y(`instructions`,e.target.value),className:pe,placeholder:R?oe:void 0})]}),he&&(0,N.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>{Y(`instructions`,b.instructions),E.reset()},className:`cursor-pointer rounded-full border border-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-800`,children:`Reset`}),(0,N.jsx)(`button`,{type:`button`,disabled:!x.instructions.trim(),onClick:()=>{ge()},className:G,children:`Save instructions`})]})]})}),j&&!R&&(0,N.jsx)(ie,{task:C,onTaskChange:T,onCancel:()=>F(!1),onRun:be}),!R&&(0,N.jsxs)(`section`,{className:W,children:[(0,N.jsx)(`header`,{className:`flex items-center justify-between`,children:(0,N.jsx)(`h3`,{className:`font-medium text-white`,children:`Run history`})}),V&&(0,N.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:V}),K&&(0,N.jsx)(`p`,{role:`status`,className:`text-sm text-amber-200`,children:K}),(0,N.jsx)(ae,{agentId:e,runs:z,pending:D,onStop:e=>{$(`stop`,e)},pagination:B,loading:U,onPage:q})]}),k&&!R&&(0,N.jsx)(ce,{name:b.name,onCancel:()=>A(!1),onConfirm:()=>{A(!1),$(`archive`)}}),O&&(0,N.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:O})]})}function q(){let{agentId:e,subagentId:t}=y.useParams(),{data:n}=a(o());return(0,N.jsx)(K,{agentId:e,subagentId:t,choices:n},`${e}:${t}`)}export{q as component};
|
|
1
|
+
import{f as e,l as t,t as n}from"./jsx-runtime-CIazjfqY.js";import{i as r}from"./createServerFn-DfZIp2Fu.js";import{t as i}from"./useMutation-DrF53EQG.js";import{t as a}from"./useSuspenseQuery-vODFwDb8.js";import{r as o}from"./provider-queries-DxPwhDOU.js";import{t as s}from"./useRouter-c0I1aURm.js";import{d as c,f as l,g as u,i as d,m as f,s as p,t as m}from"./subagent-queries-DVv5JCfs.js";import{r as h,t as g}from"./worker-triggers-DtXyn40O.js";import{t as _}from"./memory-contracts-Doi_Q1XJ.js";import{j as v,r as y}from"./index-B4hvjMmI.js";import{t as ee}from"./random-uuid-DJR3ygJS.js";import{t as b}from"./contracts-HhAL7Tt7.js";import{t as te}from"./subagent-mutations-DfsDbmFu.js";import{n as x,r as S,t as C}from"./config-dialog-C9x9gKW9.js";import{t as ne}from"./provider-logo-Ddb77aBD.js";import{a as w,n as re}from"./model-picker-YCQNNmyw.js";import{t as T}from"./esm-BTb2nBdW.js";import{t as E}from"./subagent-enabled-toggle-Bk5wfScg.js";import{t as ie}from"./run-subagent-dialog-B4yQe9T9.js";import{r as ae}from"./subagent-run-history-D55Uh5VK.js";import{a as D,i as O,n as k,o as A,r as j,t as oe}from"./subagent-input-TQke90I1.js";var M=e(t(),1),N=n();function P({value:e=g,workers:t,onChange:n}){let[r,i]=(0,M.useState)(!1);return(0,N.jsxs)(`section`,{className:`space-y-2`,children:[(0,N.jsxs)(`header`,{className:`flex items-center justify-between gap-4`,children:[(0,N.jsx)(`h3`,{className:`font-medium text-white`,children:`Event triggers`}),(0,N.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,onClick:()=>i(!0),className:x,children:`Edit triggers`})]}),(0,N.jsx)(`p`,{className:`text-sm text-zinc-400`,children:e.inboxEnabled?`Event-driven inbox enabled`:`Event-driven inbox disabled`}),e.inboxEnabled&&(0,N.jsxs)(`p`,{className:`text-sm text-zinc-400`,children:[[e.researchSources.length?`${e.researchSources.length} research sources`:``,e.fills?`Order fills`:``,e.orderChanges?`Order status changes`:``].filter(Boolean).join(` · `)||`No automatic events selected`,` · `,e.workerDelegates.length,` approved worker callers`]}),r&&(0,N.jsx)(F,{value:e,workers:t,onCancel:()=>i(!1),onApply:async e=>{await n(e),i(!1)}})]})}function F({value:e,workers:t,onCancel:n,onApply:r}){let[i,a]=(0,M.useState)(e),[o,s]=(0,M.useState)(!1),[c,l]=(0,M.useState)(``),u=(0,M.useRef)(!1);async function d(){if(!u.current){u.current=!0,s(!0),l(``);try{await r(i)}catch(e){l(e instanceof Error?e.message:`Unable to save triggers`)}finally{u.current=!1,s(!1)}}}let f=(e,n)=>(0,N.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,N.jsx)(`legend`,{className:`mb-2 text-sm font-medium text-white`,children:n}),t.length?t.map(t=>(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 text-sm`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:i[e].includes(t.id),disabled:t.archived&&!i[e].includes(t.id),onChange:n=>a(r=>({...r,[e]:n.target.checked?[...r[e],t.id]:r[e].filter(e=>e!==t.id)})),className:`cursor-pointer`}),t.name,t.archived?` (archived)`:``]},t.id)):(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Create another worker first.`})]});return(0,N.jsxs)(C,{title:`Event triggers`,onCancel:()=>{u.current||n()},onApply:()=>{d()},applyDisabled:o,children:[(0,N.jsxs)(`fieldset`,{disabled:o,className:`space-y-5 disabled:opacity-60`,children:[(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 text-sm`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:i.inboxEnabled,onChange:e=>a(e.target.checked?{...i,inboxEnabled:!0}:{...g}),className:`cursor-pointer`}),`Enable event triggers`]}),i.inboxEnabled&&(0,N.jsxs)(N.Fragment,{children:[f(`researchSources`,`Research published`),f(`workerDelegates`,`Allow research delegation from`),t.filter(e=>i.workerDelegates.includes(e.id)&&e.tools!==void 0&&!D(e.tools).includes(`delegate_subagent`)).map(e=>(0,N.jsxs)(`p`,{role:`status`,className:`text-xs text-amber-200`,children:[e.name,` cannot delegate: enable delegate_subagent in its Tools.`]},e.id)),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 text-sm`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:i.fills,onChange:e=>a(t=>({...t,fills:e.target.checked})),className:`cursor-pointer`}),`Order fills — partial or complete`]}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 text-sm`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:i.orderChanges,onChange:e=>a(t=>({...t,orderChanges:e.target.checked})),className:`cursor-pointer`}),`Order status changes — canceled, rejected, expired`]})]})]}),c&&(0,N.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:c})]})}function I(e,t=1){let n=Math.max(1,Math.ceil(e/50));return{page:Math.min(t,n),pages:n,total:e,pageSize:50}}function se(e,t,n){let[r,i]=(0,M.useState)(()=>({runs:n?.runs??[],pagination:n?.pagination??I(n?.runs.length??0),schedulerError:n?.schedulerError??null})),[a,o]=(0,M.useState)(1),[s,c]=(0,M.useState)(!1),[l,u]=(0,M.useState)(``);return(0,M.useEffect)(()=>{if(!t)return;let n=!0;c(!0),u(``);let r=new EventSource(`/api/agents/${encodeURIComponent(e)}/sub-agents/${encodeURIComponent(t)}/runs/events?page=${a}`),s=(e,t)=>{n&&(c(!1),u(e?JSON.parse(e.data).message??t:t))};return r.addEventListener(`runs`,e=>{if(!n)return;let t=JSON.parse(e.data);i(t),c(!1),u(``),t.pagination.page!==a&&o(t.pagination.page)}),r.addEventListener(`unauthorized`,()=>{n&&window.location.assign(`/login`)}),r.addEventListener(`shutdown`,()=>s(void 0,`Server is restarting. Reconnecting…`)),r.addEventListener(`unavailable`,e=>s(e,`Run history updates interrupted. Reconnecting…`)),r.addEventListener(`stream-error`,e=>s(e,`Run history could not be streamed.`)),r.onerror=()=>s(void 0,`Live updates interrupted. Showing the last received history. Reconnecting…`),()=>{n=!1,r.close()}},[e,t,a]),{history:r,loading:s,connectionError:l,setPage:o}}function ce({name:e,onCancel:t,onConfirm:n}){let r=(0,M.useRef)(null),i=(0,M.useId)();return(0,M.useEffect)(()=>{let e=r.current;return e.showModal(),()=>e.close()},[]),(0,N.jsxs)(`dialog`,{ref:r,"aria-labelledby":i,"aria-describedby":`${i}-description`,onCancel:e=>{e.preventDefault(),t()},className:`m-auto w-[calc(100%_-_2rem)] max-w-md rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6 text-zinc-100 shadow-2xl backdrop:bg-black/70 backdrop:backdrop-blur-sm`,children:[(0,N.jsx)(`h3`,{id:i,className:`text-lg font-semibold text-white`,children:`Archive sub-agent?`}),(0,N.jsxs)(`p`,{id:`${i}-description`,className:`mt-2 text-sm leading-6 text-zinc-400`,children:[`Archive “`,e,`”? New assignments will be disabled. Its configuration and run history will be preserved.`]}),(0,N.jsxs)(`div`,{className:`mt-6 flex flex-col-reverse gap-3 sm:flex-row sm:justify-end`,children:[(0,N.jsx)(`button`,{type:`button`,autoFocus:!0,onClick:t,className:`cursor-pointer rounded-full border border-zinc-800 px-4 py-2 text-sm font-medium text-zinc-300 hover:border-zinc-700 hover:text-white`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,onClick:n,className:`cursor-pointer rounded-full bg-red-600 px-4 py-2 text-sm font-medium text-white hover:bg-red-500`,children:`Archive sub-agent`})]})]})}function le({value:e,main:t,agentId:n,enabled:r,onToggleEnabled:i,onChange:a,actions:o}){let[s,c]=(0,M.useState)(!1);return(0,N.jsxs)(`section`,{className:`space-y-2`,children:[(0,N.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,N.jsxs)(`nav`,{"aria-label":`Sub-agent breadcrumb`,className:`flex min-w-0 flex-1 flex-wrap items-center gap-2`,children:[(0,N.jsxs)(`a`,{href:`/agents/${n}/sub-agents`,className:`cursor-pointer text-sm text-zinc-400 hover:text-white`,children:[(0,N.jsx)(`span`,{"aria-hidden":`true`,children:`← `}),`Sub-agents`]}),(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`text-zinc-600`,children:`/`}),(0,N.jsxs)(`h2`,{"aria-current":`page`,className:`break-words text-lg font-medium text-white`,children:[e.name||`Create subagent`,t&&` · Main conversation`]}),!t&&(0,N.jsx)(E,{enabled:r,onClick:i}),(0,N.jsx)(`span`,{className:`min-w-0 break-words text-sm text-zinc-400`,children:e.description||`No description`}),(0,N.jsx)(`button`,{type:`button`,"aria-label":`Edit name and description`,title:`Edit name and description`,"aria-haspopup":`dialog`,onClick:()=>c(!0),className:`inline-flex shrink-0 cursor-pointer items-center justify-center rounded-md p-1 text-zinc-400 hover:bg-zinc-800 hover:text-white`,children:(0,N.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,className:`size-4`,children:(0,N.jsx)(`path`,{d:`m16 4 4 4M4 20l4-1L21 6a2.8 2.8 0 0 0-4-4L4 15z`})})})]}),o&&(0,N.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:o})]}),(0,N.jsx)(`hr`,{className:`border-zinc-800`}),s&&(0,N.jsx)(L,{value:e,onCancel:()=>c(!1),onApply:async e=>{await a(e),c(!1)}})]})}function L({value:e,onCancel:t,onApply:n}){let[r,i]=(0,M.useState)(e),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(``),l=(0,M.useRef)(!1),u=(0,M.useId)();async function d(){if(!(l.current||!r.name.trim())){l.current=!0,o(!0),c(``);try{await n({name:r.name.trim(),description:r.description.trim()})}catch(e){c(e instanceof Error?e.message:`Unable to save name and description. Please retry.`)}finally{l.current=!1,o(!1)}}}return(0,N.jsxs)(C,{title:`Edit name and description`,onCancel:()=>{l.current||t()},onApply:()=>{d()},applyDisabled:a||!r.name.trim(),children:[(0,N.jsxs)(`fieldset`,{disabled:a,className:`space-y-5 disabled:opacity-60`,children:[(0,N.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[`Name`,(0,N.jsx)(`input`,{autoFocus:!0,required:!0,maxLength:80,value:r.name,onChange:e=>i(t=>({...t,name:e.target.value})),className:S})]}),(0,N.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[`Description`,(0,N.jsx)(`input`,{"aria-describedby":u,maxLength:500,value:r.description,onChange:e=>i(t=>({...t,description:e.target.value})),className:S}),(0,N.jsx)(`span`,{id:u,className:`block text-xs text-zinc-400`,children:`Human-readable description.`})]})]}),a&&(0,N.jsx)(`p`,{role:`status`,className:`text-sm text-zinc-400`,children:`Saving…`}),s&&(0,N.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:s})]})}var R=[{name:`Hyperliquid`,tools:k},{name:`Research · Code Mode & Artifacts`,tools:A},{name:`Indicators — Read & Calculate`,tools:O},{name:`Indicators — Develop`,tools:j},{name:`Memories & Insights`,tools:_},{name:`Chart workspace · Orchestrator only`,tools:b},{name:`HyperVibes · Notifications`,tools:[`send_notification`]},{name:`HyperVibes · Subagents`,tools:[`list_subagents`,`delegate_subagent`,`list_subagent_runs`,`get_subagent_run`]}];function ue({tools:e,onChange:t,main:n=!1}){let[r,i]=(0,M.useState)(!1);return(0,N.jsxs)(`section`,{className:`space-y-2`,children:[(0,N.jsxs)(`header`,{className:`flex items-center justify-between gap-4`,children:[(0,N.jsx)(`h3`,{className:`font-medium text-white`,children:`Tools`}),(0,N.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,onClick:()=>i(!0),className:x,children:`Edit tools`})]}),(0,N.jsx)(`p`,{className:`text-sm text-zinc-400`,children:e.length?`${e.length} ${e.length===1?`tool`:`tools`} allowed`:`No tools allowed`}),R.map(t=>{let n=t.tools.filter(t=>e.includes(t));return n.length?(0,N.jsxs)(`p`,{className:`line-clamp-2 break-words text-sm text-zinc-200`,title:`${t.name}: ${n.join(`, `)}`,children:[t.name,`: `,(0,N.jsx)(`span`,{className:`font-mono`,children:n.join(`, `)})]},t.name):null}),r&&(0,N.jsx)(z,{tools:e,main:n,onCancel:()=>i(!1),onApply:async e=>{await t(e),i(!1)}})]})}function z({tools:e,onCancel:t,onApply:n,main:r}){let[i,a]=(0,M.useState)(e),[o,s]=(0,M.useState)(``),[c,l]=(0,M.useState)(!1),[u,d]=(0,M.useState)(``),f=(0,M.useRef)(!1);async function p(){if(!f.current){f.current=!0,l(!0),d(``);try{await n(i)}catch(e){d(e instanceof Error?e.message:`Unable to save tools. Please retry.`)}finally{f.current=!1,l(!1)}}}let m=R.filter(e=>r||e.tools!==b).map(e=>({...e,visibleTools:e.tools.filter(t=>`${e.name} ${t}`.toLowerCase().includes(o.trim().toLowerCase()))})).filter(e=>e.visibleTools.length);return(0,N.jsxs)(C,{title:`Allowed tools`,onCancel:()=>{f.current||t()},onApply:()=>{p()},applyDisabled:c,children:[(0,N.jsxs)(`fieldset`,{disabled:c,className:`space-y-4 disabled:opacity-60`,children:[(0,N.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[`Search extensions and tools`,(0,N.jsx)(`input`,{autoFocus:!0,type:`search`,value:o,onChange:e=>s(e.target.value),className:S})]}),(0,N.jsxs)(`div`,{className:`max-h-80 space-y-4 overflow-y-auto`,children:[m.map(e=>(0,N.jsxs)(`fieldset`,{className:`space-y-3 rounded-xl border border-zinc-800 p-4`,children:[(0,N.jsx)(`legend`,{className:`px-2 text-sm font-medium text-white`,children:(0,N.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-3`,children:[(0,N.jsx)(`span`,{children:e.name}),(0,N.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-xs font-normal`,children:[(0,N.jsx)(`button`,{type:`button`,"aria-label":`All tools in ${e.name}`,onClick:()=>a(t=>[...new Set([...t,...e.tools])]),className:`cursor-pointer text-zinc-400 hover:text-violet-300 hover:underline`,children:`All`}),(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`text-zinc-700`,children:`/`}),(0,N.jsx)(`button`,{type:`button`,"aria-label":`No tools in ${e.name}`,onClick:()=>a(t=>t.filter(t=>!e.tools.some(e=>e===t))),className:`cursor-pointer text-zinc-400 hover:text-violet-300 hover:underline`,children:`None`})]})]})}),(0,N.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:e.visibleTools.map(e=>(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 font-mono text-xs`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:i.includes(e),onChange:t=>a(n=>t.target.checked?[...n,e]:n.filter(t=>t!==e)),className:`cursor-pointer`}),e]},e))})]},e.name)),!m.length&&(0,N.jsx)(`p`,{className:`text-sm text-zinc-400`,children:`No matching tools.`})]}),(0,N.jsxs)(`p`,{className:`text-sm text-zinc-400`,children:[i.length,` selected`,c?` · Saving…`:``]})]}),u&&(0,N.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:u})]})}function de({value:e,onChange:t}){let[n,r]=(0,M.useState)(!1);return(0,N.jsxs)(`section`,{className:`space-y-2`,children:[(0,N.jsxs)(`header`,{className:`flex items-center justify-between gap-4`,children:[(0,N.jsx)(`h3`,{className:`font-medium text-white`,children:`Assignments & context`}),(0,N.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,onClick:()=>r(!0),className:x,children:`Edit assignments`})]}),(0,N.jsxs)(`p`,{className:`text-sm text-zinc-200`,children:[`Orchestrator delegation `,e.delegatable?`allowed`:`disabled`]}),(0,N.jsxs)(`p`,{className:`text-sm text-zinc-200`,children:[e.persistent?`Persistent conversation`:`Fresh context per assignment`,` · Timeout: `,e.timeoutSeconds,`s`]}),n&&(0,N.jsx)(B,{value:e,onCancel:()=>r(!1),onApply:async e=>{await t(e),r(!1)}})]})}function B({value:e,onCancel:t,onApply:n}){let[r,i]=(0,M.useState)({delegatable:e.delegatable,persistent:e.persistent,timeoutSeconds:e.timeoutSeconds}),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(``),l=(0,M.useRef)(!1),u=Number.isInteger(r.timeoutSeconds)&&r.timeoutSeconds>=30&&r.timeoutSeconds<=3600;async function d(){if(!(l.current||!u)){l.current=!0,o(!0),c(``);try{await n(r)}catch(e){c(e instanceof Error?e.message:`Unable to save assignment settings. Please retry.`)}finally{l.current=!1,o(!1)}}}let f=(e,t)=>(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 text-sm`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:r[e],onChange:t=>i(n=>({...n,[e]:t.target.checked})),className:`cursor-pointer`}),t]});return(0,N.jsxs)(C,{title:`Assignments & context`,onCancel:()=>{l.current||t()},onApply:()=>{d()},applyDisabled:a||!u,children:[(0,N.jsxs)(`fieldset`,{disabled:a,className:`space-y-4 disabled:opacity-60`,children:[f(`delegatable`,`Allow orchestrator delegation`),f(`persistent`,`Reuse a persistent conversation (otherwise fresh context per assignment)`),(0,N.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[`Assignment timeout (seconds)`,(0,N.jsx)(`input`,{required:!0,type:`number`,min:30,max:3600,step:1,value:r.timeoutSeconds,onChange:e=>i(t=>({...t,timeoutSeconds:Number(e.target.value)})),className:S})]})]}),a&&(0,N.jsx)(`p`,{role:`status`,className:`text-sm text-zinc-400`,children:`Saving…`}),s&&(0,N.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:s})]})}var V={save:`Save only`,notify:`Notify orchestrator without a model call`,wake:`Notify and wake orchestrator`};function H({timestamp:e}){let[,t]=(0,M.useState)(0);(0,M.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(e)},[]);let n=new Date(e).toISOString();return(0,N.jsxs)(`p`,{className:`text-sm text-violet-300`,children:[`Next run `,(0,N.jsx)(`time`,{dateTime:n,title:n,suppressHydrationWarning:!0,children:e>Date.now()?T(e):`due now`})]})}function fe({value:e,nextRunAt:t,onChange:n}){let[r,i]=(0,M.useState)(!1);return(0,N.jsxs)(`section`,{className:`space-y-2`,children:[(0,N.jsxs)(`header`,{className:`flex items-center justify-between gap-4`,children:[(0,N.jsx)(`h3`,{className:`font-medium text-white`,children:`Schedule`}),(0,N.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,onClick:()=>i(!0),className:x,children:`Edit schedule`})]}),(0,N.jsx)(`p`,{className:`text-sm text-zinc-400`,children:e.schedule?`Every ${e.schedule} candle close (UTC) · ${e.delaySeconds}s delay`:`No schedule · manual, delegated or configured event assignments`}),e.schedule&&t!=null&&(0,N.jsx)(H,{timestamp:t}),(0,N.jsxs)(`p`,{className:`text-xs text-zinc-500`,children:[`Scheduled / manual / event completion: `,V[e.completion]]}),r&&(0,N.jsx)(U,{value:e,onCancel:()=>i(!1),onApply:async e=>{await n(e),i(!1)}})]})}function U({value:e,onCancel:t,onApply:n}){let[r,i]=(0,M.useState)(()=>e.schedule?e:{...e,delaySeconds:1}),a=h[r.schedule],[o,s]=(0,M.useState)(!1),[c,l]=(0,M.useState)(``),u=(0,M.useRef)(!1),d=!r.schedule||Number.isInteger(r.delaySeconds)&&r.delaySeconds>=0&&r.delaySeconds<=300&&r.delaySeconds<a;async function f(){if(!(u.current||!d)){u.current=!0,s(!0),l(``);try{await n({schedule:r.schedule,delaySeconds:r.delaySeconds,completion:r.completion})}catch(e){l(e instanceof Error?e.message:`Unable to save schedule. Please retry.`)}finally{u.current=!1,s(!1)}}}return(0,N.jsxs)(C,{title:`Configure schedule`,onCancel:()=>{u.current||t()},onApply:()=>{f()},applyDisabled:o||!d,children:[(0,N.jsxs)(`fieldset`,{disabled:o,className:`space-y-5 disabled:opacity-60`,children:[(0,N.jsx)(`p`,{className:`text-sm text-zinc-400`,children:`Run after a UTC candle closes.`}),(0,N.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[`UTC candle close`,(0,N.jsxs)(`select`,{value:r.schedule,onChange:e=>i(t=>({...t,schedule:e.target.value})),className:`${S} cursor-pointer`,children:[(0,N.jsx)(`option`,{value:``,children:`No schedule`}),Object.keys(h).map(e=>(0,N.jsx)(`option`,{value:e,children:e===`1d`?`1d / every 24 hours`:e},e))]})]}),r.schedule&&(0,N.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[`Delay after candle close (seconds)`,(0,N.jsx)(`input`,{required:!0,type:`number`,min:0,max:Math.min(300,a-1),step:1,value:r.delaySeconds,onChange:e=>i(t=>({...t,delaySeconds:Number(e.target.value)})),className:`block w-full rounded-xl border border-zinc-700 bg-zinc-950 p-3 text-sm text-white`})]}),(0,N.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[`Scheduled / manual completion`,(0,N.jsx)(`select`,{value:r.completion,onChange:e=>i(t=>({...t,completion:e.target.value})),className:`${S} cursor-pointer`,children:Object.entries(V).map(([e,t])=>(0,N.jsx)(`option`,{value:e,children:t},e))})]})]}),o&&(0,N.jsx)(`p`,{role:`status`,className:`text-sm text-zinc-400`,children:`Saving…`}),c&&(0,N.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:c})]})}var W=`space-y-4 rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6`,pe=`mt-2 block w-full rounded-lg border border-zinc-700 bg-zinc-950 p-3 text-sm text-white`,G=`cursor-pointer rounded-full bg-violet-600 px-4 py-2 text-sm text-white hover:bg-violet-500 disabled:cursor-not-allowed disabled:opacity-50`;function K({agentId:e,subagentId:t,choices:n}){let o=s(),h=r(),g=te(h,e),{data:_,error:y}=a(d(e,t)),b=_.definition,[x,S]=(0,M.useState)(_.definition),[C,T]=(0,M.useState)(``),E=i({mutationFn:e=>e()}),D=E.isPending,O=E.error?.message??y?.message,[k,A]=(0,M.useState)(!1),[j,F]=(0,M.useState)(!1),I=(0,M.useRef)(!1),L=(0,M.useRef)(null),R=b.kind===`orchestrator`,{history:{runs:z,pagination:B,schedulerError:V,schedule:H},loading:U,connectionError:K,setPage:q}=se(e,R?void 0:b.id,_),me=H&&H.updatedAt>=b.updatedAt?H.nextRunAt:b.nextRunAt,J=n.find(e=>w(e)===w(x)),Y=(e,t)=>S(n=>({...n,[e]:t})),he=x.instructions!==b.instructions;async function X(e){if(I.current)throw Error(`An operation is already in progress. Please retry.`);I.current=!0;try{await E.mutateAsync(e)}finally{I.current=!1}}async function Z(e,t){if(b.archived)throw Error(`Settings cannot be changed right now. Please retry.`);await X(async()=>{let n=await g.saveSection({id:b.id,section:e,settings:t}),r=e===`enabled`?{enabled:n.enabled}:e===`instructions`?{instructions:n.instructions}:e===`model`?{provider:n.provider,modelId:n.modelId,thinkingLevel:n.thinkingLevel}:e===`triggers`?{triggers:n.triggers}:{schedule:n.schedule,delaySeconds:n.delaySeconds,completion:n.completion};S(e=>({...e,...r})),v.success(e===`enabled`?n.enabled?`Sub-agent enabled`:`Sub-agent paused`:e===`instructions`?`Instructions updated`:e===`model`?`Model updated`:`Schedule updated`)})}async function Q(){try{await Z(`enabled`,{enabled:!x.enabled})}catch{}}async function ge(){try{await Z(`instructions`,{instructions:x.instructions})}catch{}}async function _e(t){if(b.archived)throw Error(`Settings cannot be changed right now. Please retry.`);await X(async()=>{let n=await c({data:{agentId:e,id:b.id,settings:t}}),{delegatable:r,persistent:i,timeoutSeconds:a}=n;S(e=>({...e,delegatable:r,persistent:i,timeoutSeconds:a})),await m(h,e,n),v.success(`Assignment settings updated`)})}async function ve(t){if(b.archived)throw Error(`Settings cannot be changed right now. Please retry.`);await X(async()=>{let n=await l({data:{agentId:e,id:b.id,...t}});S(e=>({...e,name:n.name,description:n.description})),await m(h,e,n),v.success(`Name and description updated`)})}async function ye(t){if(b.archived)throw Error(`Settings cannot be changed right now. Please retry.`);await X(async()=>{let n=await f({data:{agentId:e,id:b.id,tools:t}});S(e=>({...e,tools:n.tools})),await m(h,e,n),v.success(`Tools updated`)})}async function be(){if(b.archived)throw Error(`This worker is unavailable for new assignments.`);await X(async()=>{L.current?.task!==C&&(L.current={task:C,id:ee()});let t=await g.run({id:b.id,task:C,requestId:L.current.id});L.current=null,F(!1),T(``),v.success(`Assignment started`),await o.navigate({to:`/agents/$agentId/sub-agents/$subagentId/runs/$runId`,params:{agentId:e,subagentId:b.id,runId:t.id}})})}async function $(t,n=``){if(!I.current)try{await X(async()=>{if(t===`stop`)await g.stop(n),v.success(`Assignment stopped`,{description:`Existing exchange orders were not cancelled.`});else if(t===`unarchive`){let t=await u({data:{agentId:e,id:b.id}});S(t),await m(h,e,t),v.success(`Sub-agent unarchived`,{description:`Restored paused. Enable it when ready.`})}else await p({data:{agentId:e,id:b.id}}),await m(h,e,{...b,archived:!0,enabled:!1}),v.success(`Sub-agent archived`,{description:`History is preserved.`}),await o.navigate({to:`/agents/$agentId/sub-agents`,params:{agentId:e}})})}catch{}}return(0,N.jsxs)(`div`,{className:`w-full space-y-3`,children:[b.archived&&!R&&(0,N.jsxs)(`section`,{className:`${W} flex flex-wrap items-center justify-between gap-3`,children:[(0,N.jsx)(`p`,{className:`text-sm text-amber-200`,children:`Archived — history is preserved. Unarchive to edit or run this sub-agent; it will remain paused.`}),(0,N.jsx)(`button`,{type:`button`,disabled:D,onClick:()=>{$(`unarchive`)},className:G,children:`Unarchive`})]}),(0,N.jsx)(`form`,{onSubmit:e=>{e.preventDefault()},className:W,children:(0,N.jsxs)(`fieldset`,{disabled:D||b.archived,className:`space-y-4 disabled:opacity-60`,children:[(0,N.jsx)(le,{value:x,main:R,agentId:e,enabled:x.enabled,onToggleEnabled:()=>{Q()},onChange:ve,actions:R?void 0:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`button`,{type:`button`,disabled:D||b.archived,"aria-haspopup":`dialog`,onClick:()=>F(!0),className:`inline-flex cursor-pointer items-center gap-2 rounded-full border border-violet-500 px-4 py-2 text-sm text-violet-300 hover:bg-violet-950 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,N.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,className:`size-4`,children:(0,N.jsx)(`path`,{d:`m13 2-9 12h7l-1 8 10-12h-7z`})}),`Run now`]}),(0,N.jsx)(`button`,{type:`button`,disabled:D||b.archived,"aria-label":`Archive worker`,title:`Archive worker`,"aria-haspopup":`dialog`,onClick:()=>A(!0),className:`inline-flex cursor-pointer items-center justify-center rounded-full p-2 text-red-300 hover:bg-red-950 hover:text-red-200 disabled:cursor-not-allowed disabled:opacity-50`,children:(0,N.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,className:`size-5`,children:(0,N.jsx)(`path`,{d:`M3 6h18M9 6V3h6v3M5 6l1 15h12l1-15M10 10v7m4-7v7`})})})]})}),b.archived&&(0,N.jsx)(`p`,{className:`text-sm text-amber-200`,children:`Archived — new assignments are disabled. History remains available.`}),!J&&(0,N.jsxs)(`p`,{className:`flex items-center gap-1.5 text-sm text-amber-200`,children:[(0,N.jsx)(ne,{provider:x.provider,className:`h-4 w-4 shrink-0 rounded-sm border border-zinc-800 bg-white p-0.5`}),(0,N.jsxs)(`span`,{children:[`Current model: `,x.provider,`/`,x.modelId,`. Reconnect its provider or select an available model.`]})]}),(0,N.jsx)(re,{choices:n,value:J?w(x):``,thinkingLevel:x.thinkingLevel,onChange:async(e,t)=>{let r=n.find(t=>w(t)===e);r&&await Z(`model`,{provider:r.provider,modelId:r.modelId,thinkingLevel:t})},disabled:D}),(0,N.jsxs)(`div`,{className:R?`space-y-4`:`grid gap-6 md:grid-cols-2`,children:[(0,N.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[(0,N.jsx)(ue,{tools:x.tools,onChange:ye,main:R}),x.tools.includes(`submit_orders`)&&!x.tools.includes(`record_trade_decision`)&&(0,N.jsx)(`p`,{role:`status`,className:`text-sm text-amber-200`,children:`Trading readiness: record_trade_decision is not selected. Existing permissions were not widened; select it explicitly for attributable trade rationale.`})]}),!R&&(0,N.jsxs)(`div`,{className:`min-w-0 space-y-6`,children:[(0,N.jsx)(de,{value:x,onChange:_e}),(0,N.jsx)(P,{value:x.triggers,workers:(_.workers??[]).filter(e=>e.id!==b.id),onChange:e=>Z(`triggers`,{triggers:e})}),(0,N.jsx)(fe,{value:x,nextRunAt:b.enabled&&!b.archived?me:null,onChange:e=>Z(`schedule`,e)})]})]}),(0,N.jsxs)(`label`,{className:`block text-sm text-zinc-300`,children:[`Instructions`,(0,N.jsx)(`textarea`,{required:!0,rows:7,maxLength:32e3,value:x.instructions,onChange:e=>Y(`instructions`,e.target.value),className:pe,placeholder:R?oe:void 0})]}),he&&(0,N.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>{Y(`instructions`,b.instructions),E.reset()},className:`cursor-pointer rounded-full border border-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-800`,children:`Reset`}),(0,N.jsx)(`button`,{type:`button`,disabled:!x.instructions.trim(),onClick:()=>{ge()},className:G,children:`Save instructions`})]})]})}),j&&!R&&(0,N.jsx)(ie,{task:C,onTaskChange:T,onCancel:()=>F(!1),onRun:be}),!R&&(0,N.jsxs)(`section`,{className:W,children:[(0,N.jsx)(`header`,{className:`flex items-center justify-between`,children:(0,N.jsx)(`h3`,{className:`font-medium text-white`,children:`Run history`})}),V&&(0,N.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:V}),K&&(0,N.jsx)(`p`,{role:`status`,className:`text-sm text-amber-200`,children:K}),(0,N.jsx)(ae,{agentId:e,runs:z,pending:D,onStop:e=>{$(`stop`,e)},pagination:B,loading:U,onPage:q})]}),k&&!R&&(0,N.jsx)(ce,{name:b.name,onCancel:()=>A(!1),onConfirm:()=>{A(!1),$(`archive`)}}),O&&(0,N.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:O})]})}function q(){let{agentId:e,subagentId:t}=y.useParams(),{data:n}=a(o());return(0,N.jsx)(K,{agentId:e,subagentId:t,choices:n},`${e}:${t}`)}export{q as component};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{f as e,l as t,t as n}from"./jsx-runtime-CIazjfqY.js";import{t as r}from"./react-dom-C6bOPxes.js";import{i}from"./createServerFn-DfZIp2Fu.js";import{t as a}from"./useMutation-
|
|
1
|
+
import{f as e,l as t,t as n}from"./jsx-runtime-CIazjfqY.js";import{t as r}from"./react-dom-C6bOPxes.js";import{i}from"./createServerFn-DfZIp2Fu.js";import{t as a}from"./useMutation-DrF53EQG.js";import{t as o}from"./useSuspenseQuery-vODFwDb8.js";import{a as s}from"./subagent-queries-DVv5JCfs.js";import{t as c}from"./index-B4hvjMmI.js";import{t as l}from"./subagent-mutations-DfsDbmFu.js";import{t as u}from"./provider-logo-Ddb77aBD.js";import{n as d,r as f,t as p}from"./chat-bubble-CAJkT-vL.js";import{t as m}from"./artifact-content-COO4VTSZ.js";import{n as h,t as g}from"./subagent-run-history-D55Uh5VK.js";import{s as _}from"./subagent-input-TQke90I1.js";var v=e(r(),1),y=e(t(),1);function b(e,t,n,r){let[i,a]=(0,y.useState)(r),[o,s]=(0,y.useState)(``);return(0,y.useEffect)(()=>{let r=!0;s(``);let i=new EventSource(`/api/agents/${encodeURIComponent(e)}/sub-agents/${encodeURIComponent(t)}/runs/${encodeURIComponent(n)}/events`),o=(e,t)=>{r&&s(e?JSON.parse(e.data).message??t:t)};return i.addEventListener(`run`,e=>{r&&(a(JSON.parse(e.data)),s(``))}),i.addEventListener(`unauthorized`,()=>{r&&window.location.assign(`/login`)}),i.addEventListener(`shutdown`,()=>o(void 0,`Server is restarting. Reconnecting…`)),i.addEventListener(`unavailable`,e=>o(e,`Live updates interrupted. Reconnecting…`)),i.addEventListener(`stream-error`,e=>o(e,`Run detail could not be streamed.`)),i.onerror=()=>o(void 0,`Live updates interrupted. Showing the last received detail. Reconnecting…`),()=>{r=!1,i.close()}},[e,t,n]),{detail:i,connectionError:o}}function x(e,t){let n=[],r=new Map;for(let t of e)for(let e of t.model??[])if(e.role===`assistant`)for(let t of e.content)t.type===`toolCall`&&r.set(t.id,JSON.stringify(t.arguments).slice(0,500));for(let t of e.slice(-100))for(let e of t.model??[]){if(e.role!==`toolResult`)continue;n.push({id:e.toolCallId,name:e.toolName,status:e.isError?`error`:`done`,durationMs:e.durationMs,arguments:r.get(e.toolCallId),output:e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
2
2
|
`).slice(0,1e3)});let t=e.details;if(!(!t||typeof t!=`object`||!(`calls`in t)||!Array.isArray(t.calls)))for(let r of t.calls.slice(0,100))!r||typeof r!=`object`||!(`name`in r)||typeof r.name!=`string`||n.push({id:`${e.toolCallId}${e.toolName===`codemode`?`/c`:`:`}${`id`in r?String(r.id):n.length}`,name:`↳ ${r.name}`,status:`status`in r?String(r.status):`done`,arguments:`args`in r?String(r.args).slice(0,500):void 0,error:`error`in r?String(r.error).slice(0,500):void 0,durationMs:`durationMs`in r&&typeof r.durationMs==`number`?r.durationMs:void 0,queuedMs:`queuedMs`in r&&typeof r.queuedMs==`number`?r.queuedMs:void 0})}for(let e of t?.tools??[])if(e.status!==`done`){n.push({id:e.callId,name:e.name,status:e.status,arguments:r.get(e.callId)});let t=e.details;if(!t||typeof t!=`object`||!(`calls`in t)||!Array.isArray(t.calls))continue;for(let r of t.calls.slice(0,100))!r||typeof r!=`object`||!(`status`in r)||r.status!==`queued`||!(`name`in r)||typeof r.name!=`string`||n.push({id:`${e.callId}${e.name===`codemode`?`/c`:`:`}${`id`in r?String(r.id):n.length}`,name:`↳ ${r.name}`,status:`queued`,arguments:`args`in r?String(r.args).slice(0,500):void 0})}for(let e of t?.nestedTools??[])n.push({id:e.callId,name:`↳ ${e.name}`,status:e.summary?.isError?`error`:e.status,arguments:JSON.stringify(e.arguments).slice(0,500),error:e.summary?.error?.slice(0,500),durationMs:e.summary?.durationMs});return n.slice(-125)}var S=n(),C=`space-y-4 rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6`,w=`whitespace-pre-wrap break-words text-sm text-zinc-300`,T=`cursor-pointer rounded-full border border-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-800 disabled:cursor-wait disabled:opacity-50`,E=`cursor-pointer text-sm text-zinc-400 hover:text-white`;function D({entries:e,agentId:t,tools:n=[]}){let r=new Map(e.flatMap(e=>x([e])).map(e=>[e.id,e]));for(let e of n)r.set(e.id,e);for(let t of e)for(let e of t.model??[])if(e.role===`assistant`){for(let t of e.content)if(t.type===`toolCall`){let e=r.get(t.id);r.set(t.id,{id:t.id,name:t.name,status:`pending`,...e,arguments:e?.arguments??JSON.stringify(t.arguments).slice(0,500)})}}let i=new Set(e.flatMap(e=>(e.model??[]).flatMap(e=>e.role===`assistant`?e.content.flatMap(e=>e.type===`toolCall`?[e.id]:[]):[])));function a(e,t){return e.startsWith(`${t}/`)||e.startsWith(`${t}:`)}function o(e){let t=r.get(e),n=[...r.values()].filter(t=>a(t.id,e));return t?.name===`codemode`?(0,S.jsx)(d,{tool:t,calls:n},e):[t,...n].filter(e=>e!==void 0).map(e=>(0,S.jsx)(f,{tool:e},e.id))}let s=new Set(e.flatMap(e=>(e.model??[]).flatMap(e=>e.role===`toolResult`?[e.toolCallId]:[]))),c=[];for(let t of e)for(let[e,n]of(t.model??[]).entries()){if(n.role===`toolResult`&&i.has(n.toolCallId))continue;let r={id:`${t.id}:${e}`,message:n},a=c.at(-1);n.role===`assistant`&&a?.role===`assistant`?a.messages.push(r):c.push({id:r.id,role:n.role,messages:[r]})}return(0,S.jsxs)(`div`,{className:`space-y-4`,children:[c.map(e=>(0,S.jsxs)(p,{role:e.role===`toolResult`?`tool`:e.role,children:[(e.role===`assistant`||e.role===`user`)&&(0,S.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-zinc-400`,children:e.role}),e.messages.map(({message:e,id:n})=>e.role===`toolResult`?(0,S.jsx)(`div`,{children:o(e.toolCallId)},n):e.role===`system`?(0,S.jsxs)(`details`,{children:[(0,S.jsx)(`summary`,{className:`cursor-pointer text-xs font-semibold uppercase tracking-wide text-zinc-400`,children:`System`}),(0,S.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,S.jsx)(`pre`,{className:w,children:typeof e.content==`string`?e.content:e.content.map(e=>e.text).join(`
|
|
3
3
|
`)}),Object.entries(e.sections??{}).map(([e,t])=>(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsx)(`h4`,{className:`text-xs font-medium text-zinc-400`,children:e}),(0,S.jsx)(`pre`,{className:w,children:t??`Section removed`})]},e)),!!e.toolsAdded?.length&&(0,S.jsxs)(`p`,{className:`text-xs text-zinc-400`,children:[`Tools added: `,e.toolsAdded.map(e=>e.name).join(`, `)]}),!!e.toolsRemoved?.length&&(0,S.jsxs)(`p`,{className:`text-xs text-zinc-400`,children:[`Tools removed: `,e.toolsRemoved.map(e=>e.name).join(`, `)]})]})]},n):(0,S.jsxs)(`div`,{className:`space-y-2`,children:[typeof e.content==`string`?(0,S.jsx)(m,{agentId:t,content:e.content}):e.content.map((e,n)=>(0,S.jsx)(`div`,{children:e.type===`text`?(0,S.jsx)(m,{agentId:t,content:e.text}):e.type===`thinking`?(0,S.jsxs)(`details`,{open:!0,children:[(0,S.jsx)(`summary`,{className:`cursor-pointer text-xs text-zinc-400`,children:`Thinking`}),(0,S.jsx)(`pre`,{className:w,children:e.thinking})]}):e.type===`toolCall`?(0,S.jsx)(S.Fragment,{children:o(e.id)}):(0,S.jsx)(`pre`,{className:w,children:JSON.stringify(e,null,2)})},n)),e.role===`assistant`&&e.errorMessage&&(0,S.jsx)(`p`,{className:`text-sm text-red-300`,children:e.errorMessage})]},n))]},e.id)),[...r.values()].filter(e=>![...i,...s].some(t=>e.id===t||a(e.id,t))).map(e=>(0,S.jsx)(f,{tool:e},e.id))]})}function O({instructions:e,children:t,onClose:n}){let r=(0,y.useRef)(null),i=(0,y.useId)();return(0,y.useEffect)(()=>{let e=r.current;return e.showModal(),()=>e.close()},[]),(0,v.createPortal)((0,S.jsxs)(`dialog`,{ref:r,"aria-labelledby":i,onCancel:e=>{e.preventDefault(),n()},className:`m-auto flex max-h-[calc(100dvh-2rem)] w-[calc(100%_-_2rem)] max-w-3xl flex-col overflow-hidden rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6 text-zinc-200 shadow-2xl backdrop:bg-black/70 backdrop:backdrop-blur-sm`,children:[(0,S.jsxs)(`header`,{className:`mb-4 flex shrink-0 items-center justify-between gap-3`,children:[(0,S.jsx)(`h3`,{id:i,className:`text-lg font-semibold text-white`,children:`Instructions at execution`}),(0,S.jsx)(`button`,{type:`button`,onClick:n,className:T,children:`Close`})]}),(0,S.jsx)(`pre`,{className:`${w} min-h-0 overflow-y-auto overscroll-contain`,children:e}),(0,S.jsx)(`footer`,{className:`mt-4 shrink-0 space-y-2 border-t border-zinc-800 pt-4`,children:t})]}),document.body)}function k({initial:e}){let t=a({mutationFn:l(i(),e.run.agentId).stop}),n=t.isPending,r=t.error?.message,o=(0,y.useRef)(!1);async function s(){if(!o.current){o.current=!0;try{await t.mutateAsync(e.run.id)}catch{}finally{o.current=!1}}}let[c,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)(``);async function m(){try{await navigator.clipboard.writeText(e.run.id),p(`Copied`)}catch{p(`Unable to copy`)}}let{detail:v,connectionError:x}=b(e.run.agentId,e.run.subagentId,e.run.id,e),{run:T}=v,k=(0,y.useRef)(null),A=(0,y.useRef)(null),j=(0,y.useRef)(!0),M=(0,y.useRef)(!1),N=(0,y.useRef)(!1),[P,F]=(0,y.useState)(!1);(0,y.useEffect)(()=>{let e=A.current;if(!e)return;let t=()=>{j.current=e.scrollHeight-e.scrollTop-e.clientHeight<80};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),(0,y.useLayoutEffect)(()=>{let e=T.status===`queued`||T.status===`running`;j.current&&(!N.current||e||M.current)&&k.current?.scrollIntoView({block:`end`,behavior:`instant`}),N.current||(N.current=!0,F(!0)),M.current=e},[v.entries,v.tools,T.status]);let I=`/agents/${encodeURIComponent(T.agentId)}/sub-agents/${encodeURIComponent(T.subagentId)}`;return(0,S.jsxs)(`div`,{className:`flex h-[calc(100dvh-4.5rem)] min-h-0 w-full min-w-0 flex-col gap-3 overflow-hidden sm:h-[calc(100dvh-5rem)]`,children:[(0,S.jsxs)(`section`,{"aria-label":`Run header`,className:`${C} shrink-0`,children:[(0,S.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,S.jsxs)(`nav`,{"aria-label":`Run breadcrumb`,className:`flex min-w-0 flex-1 flex-wrap items-center gap-2`,children:[(0,S.jsxs)(`a`,{href:`/agents/${encodeURIComponent(T.agentId)}/sub-agents`,className:E,children:[(0,S.jsx)(`span`,{"aria-hidden":`true`,children:`← `}),`Sub-agents`]}),(0,S.jsx)(`span`,{"aria-hidden":`true`,className:`text-zinc-600`,children:`/`}),(0,S.jsx)(`a`,{href:I,className:E,children:v.definition.name}),(0,S.jsx)(`span`,{"aria-hidden":`true`,className:`text-zinc-600`,children:`/`}),(0,S.jsxs)(`h2`,{"aria-current":`page`,className:`break-words text-lg font-medium text-white`,children:[`Run `,T.id]}),(0,S.jsx)(`button`,{type:`button`,"aria-label":`Copy run ID`,title:`Copy run ID`,onClick:()=>{m()},className:`shrink-0 cursor-pointer rounded p-1 text-zinc-400 hover:text-white focus-visible:outline-violet-400`,children:(0,S.jsxs)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,className:`size-4`,children:[(0,S.jsx)(`rect`,{x:`8`,y:`8`,width:`12`,height:`12`,rx:`2`}),(0,S.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M16 8V4H4v12h4`})]})}),f&&(0,S.jsx)(`span`,{role:`status`,className:`text-xs text-zinc-400`,children:f}),(0,S.jsx)(h,{status:T.status})]}),(0,S.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,"aria-label":`Instructions at execution`,title:`Instructions at execution`,onClick:()=>d(!0),className:`cursor-pointer rounded-full border border-zinc-700 p-2 text-zinc-300 hover:bg-zinc-800`,children:(0,S.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`currentColor`,"aria-hidden":`true`,className:`size-4`,children:(0,S.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z`})})}),(T.status===`queued`||T.status===`running`)&&(0,S.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>{s()},className:`shrink-0 cursor-pointer rounded-full border border-red-500/60 px-4 py-2 text-sm text-red-400 hover:bg-red-500/10 disabled:cursor-wait disabled:opacity-50`,children:`Cancel`})]})]}),(0,S.jsx)(`hr`,{className:`border-zinc-800`}),(0,S.jsxs)(`p`,{className:`text-sm text-zinc-400`,children:[T.source,` · Created `,(0,S.jsx)(g,{timestamp:T.createdAt}),T.finishedAt!==null&&(0,S.jsxs)(S.Fragment,{children:[` · Finished `,(0,S.jsx)(g,{timestamp:T.finishedAt})]})]}),(0,S.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-zinc-500`,children:[(0,S.jsx)(u,{provider:T.config.provider,className:`h-4 w-4 shrink-0 rounded-sm border border-zinc-800 bg-white p-0.5`}),(0,S.jsxs)(`span`,{children:[T.config.provider,`/`,T.config.modelId]}),(0,S.jsxs)(`span`,{children:[T.config.thinkingLevel&&` · Thinking: ${T.config.thinkingLevel}`,` · `,T.config.persistent?`Persistent context`:`Fresh context`]})]}),x&&(0,S.jsx)(`p`,{role:`status`,className:`text-sm text-amber-200`,children:x}),r&&(0,S.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:r}),v.warnings?.map((e,t)=>(0,S.jsxs)(`p`,{role:`status`,className:`text-sm text-amber-200`,children:[e.code.replaceAll(`_`,` `),`: `,e.message]},`${e.code}:${t}`)),c&&(0,S.jsxs)(O,{instructions:v.context?.instructions??_(T.config),onClose:()=>d(!1),children:[(0,S.jsxs)(`p`,{className:`text-xs text-zinc-400`,children:[`Insights snapshot: `,v.context?.insightStatus??`legacy/none`,`. Stopping does not cancel exchange orders.`]}),v.context?.insights&&(0,S.jsx)(`div`,{className:`flex flex-wrap gap-4 text-sm`,children:[v.context.insights.agent,v.context.insights.worker].map(e=>(0,S.jsxs)(`a`,{className:`cursor-pointer text-violet-300`,href:`/agents/${T.agentId}/memories?scope=${e.scope.kind===`worker`?encodeURIComponent(e.scope.subagentId):``}${e.version?`&version=${e.version}`:``}`,children:[e.scope.kind===`agent`?`Agent-wide`:`Worker-specific`,` insights v`,e.version]},e.scope.kind))}),v.publications?.length?(0,S.jsx)(`div`,{className:`space-y-2`,children:v.publications.map(e=>(0,S.jsxs)(`a`,{className:`block cursor-pointer text-sm text-violet-300`,href:`/agents/${encodeURIComponent(T.agentId)}/memories/${encodeURIComponent(e.ref)}`,children:[e.ref,` · `,e.kind,` · `,e.summary]},e.ref))}):null,(0,S.jsxs)(`p`,{className:`text-xs text-zinc-500`,children:[`Allowed tools: `,T.config.tools.join(`, `)||`None`]})]})]}),(0,S.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3`,children:[T.status===`failed`&&(0,S.jsxs)(`section`,{"aria-label":`Run error`,className:`max-h-[40%] shrink-0 space-y-2 overflow-y-auto overscroll-contain rounded-2xl border border-red-900/60 bg-red-950/10 p-4`,children:[(0,S.jsx)(`h2`,{className:`font-medium text-red-300`,children:`Run error`}),(0,S.jsx)(`pre`,{className:w,children:T.result.trim()||`No failure details recorded.`})]}),(0,S.jsxs)(`section`,{ref:A,"aria-label":`Conversation transcript`,className:`${C} min-h-0 flex-1 overflow-y-auto overscroll-contain${P?``:` invisible`}`,children:[(0,S.jsx)(`h2`,{className:`font-medium text-white`,children:`Conversation transcript`}),v.prior.length>0&&(0,S.jsx)(`div`,{children:(0,S.jsxs)(`details`,{children:[(0,S.jsxs)(`summary`,{className:`cursor-pointer font-medium text-white`,children:[`Earlier conversation context · `,v.prior.length,` entries`]}),(0,S.jsx)(`p`,{className:`my-4 text-sm text-zinc-400`,children:`History preceding this assignment in the persistent conversation. Later assignments are not shown.`}),(0,S.jsx)(D,{entries:v.prior,agentId:T.agentId})]})}),v.entries.length?(0,S.jsx)(D,{entries:v.entries,agentId:T.agentId,tools:v.tools}):(0,S.jsx)(`p`,{className:`text-sm text-zinc-500`,children:`No transcript entries yet.`}),(T.status===`queued`||T.status===`running`)&&(0,S.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 pt-2 text-xs text-zinc-400`,children:[(0,S.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:`size-4 text-violet-400 animate-spin`,children:(0,S.jsx)(`path`,{d:`M12 3a9 9 0 1 1-9 9`})}),T.status===`queued`?`Waiting to start`:`Thinking`,`…`]}),(0,S.jsx)(`div`,{ref:k})]})]})]})}function A(){let{agentId:e,subagentId:t,runId:n}=c.useParams(),{data:r}=o(s(e,t,n));return(0,S.jsx)(k,{initial:r},`${e}:${n}`)}export{A as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e,l as t,t as n}from"./jsx-runtime-CIazjfqY.js";import{i as r}from"./createServerFn-DfZIp2Fu.js";import{i}from"./lazyRouteComponent-CJgUa7_r.js";import{t as a}from"./useMutation-
|
|
1
|
+
import{f as e,l as t,t as n}from"./jsx-runtime-CIazjfqY.js";import{i as r}from"./createServerFn-DfZIp2Fu.js";import{i}from"./lazyRouteComponent-CJgUa7_r.js";import{t as a}from"./useMutation-DrF53EQG.js";import{t as o}from"./useSuspenseQuery-vODFwDb8.js";import{c as s,o as c,r as l}from"./subagent-queries-DVv5JCfs.js";import{i as u,j as d}from"./index-B4hvjMmI.js";import{t as f}from"./random-uuid-DJR3ygJS.js";import{t as p}from"./subagent-mutations-DfsDbmFu.js";import{t as m}from"./provider-logo-Ddb77aBD.js";import{t as h}from"./subagent-enabled-toggle-Bk5wfScg.js";var g=e(t(),1),_=n();function v({definition:e,definitions:t}){if(e.kind===`orchestrator`)return null;let n=e=>{let n=t.find(t=>t.id===e);return n?`${n.name}${n.archived?` (archived)`:n.enabled?``:` (paused)`}`:e},r=t.filter(t=>!t.archived&&t.triggers.inboxEnabled&&t.triggers.researchSources.includes(e.id)),i=[e.triggers.researchSources.length?`research`:``,e.triggers.fills?`fills`:``,e.triggers.orderChanges?`order-status changes`:``].filter(Boolean);return(0,_.jsxs)(`div`,{className:`mt-2 space-y-1 text-xs text-zinc-400`,children:[e.triggers.researchSources.length>0&&(0,_.jsxs)(`p`,{children:[`Research from: `,e.triggers.researchSources.map(n).join(`, `)]}),r.length>0&&(0,_.jsxs)(`p`,{children:[`Research delivered to: `,r.map(e=>n(e.id)).join(`, `)]}),e.triggers.inboxEnabled&&(0,_.jsxs)(`p`,{children:[`Triggers: `,i.length?i.join(`, `):`delegation only`]}),e.tools.includes(`publish_review`)&&(0,_.jsx)(`p`,{children:`Reviews Agent-wide activity`})]})}function y({agentId:e,definition:t}){let n=a({mutationFn:p(r(),e).saveSection,onSuccess:e=>{d.success(e.enabled?`Sub-agent enabled`:`Sub-agent paused`)}}),i=n.error?.message;return(0,_.jsxs)(`div`,{className:`shrink-0 text-right`,children:[(0,_.jsx)(h,{enabled:t.enabled,disabled:n.isPending,onClick:()=>n.mutate({id:t.id,section:`enabled`,settings:{enabled:!t.enabled}})}),i&&(0,_.jsx)(`p`,{role:`alert`,className:`mt-2 max-w-64 text-sm text-red-300`,children:i})]})}function b({agentId:e}){let t=r(),{data:n,error:u}=o(c(e)),[p,h]=(0,g.useState)(!1),[b,x]=(0,g.useState)(!1),S=(0,g.useRef)(null),C=a({mutationFn:()=>(S.current??=f(),s({data:{agentId:e,requestId:S.current}})),onSuccess:async()=>{await l(t,e),x(!1),S.current=null,d.success(`Default sub-agents imported. All start paused.`)}}),w=C.isPending,T=C.error?.message,E=n.filter(e=>e.archived).length,D=n.filter(e=>p||!e.archived);return(0,_.jsxs)(`section`,{className:`w-full space-y-5 rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6`,children:[(0,_.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,_.jsx)(`h2`,{className:`text-lg font-medium text-white`,children:`Sub-agents`}),(0,_.jsxs)(`div`,{className:`flex items-center gap-3`,children:[E>0&&(0,_.jsx)(`button`,{type:`button`,"aria-pressed":p,onClick:()=>h(e=>!e),className:`cursor-pointer rounded-full border border-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-800`,children:p?`Hide archived`:`Show archived (${E})`}),(0,_.jsx)(`button`,{type:`button`,"aria-expanded":b,disabled:w,onClick:()=>x(!0),className:`cursor-pointer rounded-full border border-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-800 disabled:cursor-wait`,children:`Import default sub-agents`}),(0,_.jsx)(i,{to:`/agents/$agentId/sub-agents/new`,params:{agentId:e},className:`cursor-pointer rounded-full border border-violet-500 px-4 py-2 text-sm text-violet-300 hover:bg-violet-950`,children:`Create subagent`})]})]}),b&&(0,_.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-zinc-700 p-4`,children:[(0,_.jsx)(`h3`,{className:`font-medium text-white`,children:`Import default sub-agents`}),(0,_.jsx)(`p`,{className:`text-sm text-zinc-400`,children:`Adds a connected Technical Analyst, Trader, and Daily Reviewer. All start paused. Existing sub-agents are not reused or changed. Review instruments and strategy before enabling.`}),(0,_.jsxs)(`div`,{className:`flex gap-3`,children:[(0,_.jsx)(`button`,{type:`button`,disabled:w,onClick:()=>{w||C.mutate()},className:`cursor-pointer rounded-full bg-violet-600 px-4 py-2 text-sm text-white hover:bg-violet-500 disabled:cursor-wait`,children:w?`Importing…`:`Import paused sub-agents`}),(0,_.jsx)(`button`,{type:`button`,disabled:w,onClick:()=>x(!1),className:`cursor-pointer rounded-full border border-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-800 disabled:cursor-wait`,children:`Cancel`})]}),T&&(0,_.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:T})]}),u&&(0,_.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:u.message}),(0,_.jsx)(`ul`,{className:`space-y-3`,children:D.map(t=>(0,_.jsxs)(`li`,{className:`flex items-start gap-3 rounded-xl border border-zinc-800 p-4 hover:border-violet-700`,children:[(0,_.jsxs)(i,{to:`/agents/$agentId/sub-agents/$subagentId`,params:{agentId:e,subagentId:t.id},className:`block min-w-0 flex-1 cursor-pointer`,children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,_.jsx)(`span`,{className:`font-medium text-white`,children:t.name}),(0,_.jsx)(`span`,{className:t.archived?`rounded-full border border-amber-500/60 bg-amber-500/15 px-3 py-1 text-sm font-semibold text-amber-200`:`text-xs text-zinc-400`,children:t.kind===`orchestrator`?`Main conversation`:t.archived?`Archived`:``})]}),(0,_.jsx)(`p`,{className:`mt-2 text-sm text-zinc-400`,children:t.description}),(0,_.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-zinc-500`,children:[(0,_.jsx)(m,{provider:t.provider,className:`h-4 w-4 rounded-sm border border-zinc-800 bg-white p-0.5`}),(0,_.jsxs)(`span`,{className:`break-all`,children:[t.provider,`/`,t.modelId]}),t.thinkingLevel&&(0,_.jsxs)(`span`,{children:[` · `,t.thinkingLevel]}),(0,_.jsxs)(`span`,{children:[` · `,t.kind===`orchestrator`?`Persistent`:t.persistent?`Persistent context`:`Fresh context per assignment`,t.schedule?` · ${t.schedule} UTC candle close + ${t.delaySeconds}s`:``]})]}),(0,_.jsx)(v,{definition:t,definitions:n})]}),t.kind!==`orchestrator`&&!t.archived&&(0,_.jsx)(y,{agentId:e,definition:t})]},t.id))})]})}function x(){let{agentId:e}=u.useParams();return(0,_.jsx)(b,{agentId:e},e)}export{x as component};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as e,l as t,t as n}from"./jsx-runtime-CIazjfqY.js";import{i as r}from"./createServerFn-DfZIp2Fu.js";import{t as i}from"./useMutation-
|
|
1
|
+
import{f as e,l as t,t as n}from"./jsx-runtime-CIazjfqY.js";import{i as r}from"./createServerFn-DfZIp2Fu.js";import{t as i}from"./useMutation-DrF53EQG.js";import{t as a}from"./useSuspenseQuery-vODFwDb8.js";import{r as o}from"./provider-queries-DxPwhDOU.js";import{t as s}from"./useRouter-c0I1aURm.js";import{t as c}from"./agent-input-aolvZ47U.js";import{o as l,r as u,u as d}from"./subagent-queries-DVv5JCfs.js";import{n as f,r as p}from"./worker-triggers-DtXyn40O.js";import{a as m,c as h,i as g,o as _,r as v,s as y}from"./memory-contracts-Doi_Q1XJ.js";import{j as b,n as x}from"./index-B4hvjMmI.js";import{t as S}from"./random-uuid-DJR3ygJS.js";import{a as C,n as w}from"./model-picker-YCQNNmyw.js";import{c as T}from"./subagent-input-TQke90I1.js";var E=e(t(),1),D={formatVersion:1,id:`basic-analysis`,version:12,name:`Technical Analyst`,description:`Closed-candle technical analysis and durable research handoffs, with optional supporting artifacts; no trading tools.`,instructions:[`## Role
|
|
2
2
|
|
|
3
3
|
Analyze the assigned instruments and publish research for the trader; do not place trades. Use the supplied Agent and worker insights without overriding the assignment, tool permissions or risk settings. If instruments or essential data are missing, report the blocker rather than guessing.`,`## Example strategy
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e,l as t,t as n}from"./jsx-runtime-CIazjfqY.js";import{i as r}from"./createServerFn-DfZIp2Fu.js";import{t as i}from"./useMutation-Dni_73Pp.js";import{t as a}from"./useQuery-BMSU16jY.js";import{t as o}from"./useSuspenseQuery-vODFwDb8.js";import{c as s,d as c,l,s as u,u as d}from"./index-fu66g8fn.js";import{i as f,n as p}from"./decimal-B0DEG-1V.js";import{t as m}from"./instrument-label-BZYlWXR5.js";import{t as h}from"./journal-decimal-DBvd_Ibi.js";var g=e(t(),1),_=n(),v=`cursor-pointer rounded-full border border-zinc-800 px-4 py-1.5 text-sm text-zinc-300 hover:border-zinc-600 hover:text-white disabled:cursor-not-allowed disabled:opacity-40`,y=`whitespace-nowrap px-3 py-3`;function b({value:e,color:t=!1,missing:n=`Incomplete`}){let r=e===null?0:p(e,`0`);return(0,_.jsx)(`span`,{className:`font-mono text-xs tabular-nums ${e===null?`text-amber-300`:t&&r?r<0?`text-red-400`:`text-emerald-400`:``}`,children:e===null?n:f(e)})}function x(e,t){return h(t).zero?`—`:f(h(e).div(h(t)).toString())}function S({value:e}){return(0,_.jsxs)(`time`,{dateTime:new Date(e).toISOString(),children:[new Date(e).toISOString().replace(`T`,` `).slice(0,19),` UTC`]})}function C({id:e,view:t,page:n,onNavigate:r}){let{data:i,error:a}=o(c(e,t,n)),[s,l]=(0,g.useState)(null),u=(e,t,n)=>(0,_.jsxs)(`button`,{type:`button`,className:`cursor-pointer text-violet-300 hover:text-violet-200`,"aria-label":`${n?`View`:`Add`} ${t} notes`,onClick:()=>l({id:e,label:t,trade:i.trades.find(t=>t.id===e)}),children:[`✎`,n>0&&(0,_.jsx)(`span`,{className:`ml-1 text-xs`,children:n})]}),d=i.pending||i.sync.length<3||i.sync.some(e=>e.updated_at===null);return(0,_.jsxs)(`section`,{className:`flex min-h-0 w-full flex-col rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,_.jsx)(`h2`,{className:`text-lg font-medium text-white`,children:`Transactions`}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`button`,{className:v,disabled:i.page<=1,onClick:()=>r(i.view,i.page-1),children:`Previous`}),(0,_.jsxs)(`span`,{className:`text-xs text-zinc-500`,children:[`Page `,i.page,` of `,i.pages]}),(0,_.jsx)(`button`,{className:v,disabled:i.page>=i.pages,onClick:()=>r(i.view,i.page+1),children:`Next`})]})]}),(0,_.jsx)(`nav`,{"aria-label":`Transaction view`,className:`mt-4 flex gap-2`,children:[`trades`,`activity`].map(e=>(0,_.jsx)(`button`,{className:`${v} ${i.view===e?`border-violet-500 text-white`:``}`,"aria-pressed":i.view===e,onClick:()=>r(e,1),children:e===`trades`?`Trades`:`Activity`},e))}),i.linked?(0,_.jsxs)(_.Fragment,{children:[i.historyLimited&&(0,_.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-amber-200`,children:`The initial import reached Hyperliquid’s 10,000-fill history limit. Earlier activity may be missing; account balances are incomplete.`}),d&&(0,_.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-amber-200`,children:`Synchronizing account history… Totals may be incomplete.`}),i.sync.filter(e=>e.error).map(e=>(0,_.jsxs)(`p`,{role:`alert`,className:`mt-3 text-sm text-amber-200`,children:[e.stream,`: `,e.error]},e.stream)),a&&(0,_.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-red-300`,children:a.message}),i.total===0?(0,_.jsx)(`p`,{className:`mt-6 text-sm text-zinc-400`,children:i.view===`trades`?`No trades yet.`:`No transactions have synced yet.`}):(0,_.jsx)(`div`,{className:`mt-4 min-h-0 overflow-auto`,children:(0,_.jsxs)(`table`,{className:`w-full text-sm text-zinc-300`,children:[(0,_.jsx)(`thead`,{className:`text-left text-xs uppercase text-zinc-500`,children:(0,_.jsx)(`tr`,{children:(i.view===`trades`?[`Trade`,`Status`,`Notes`,`Last activity`,`Entry / Exit price`,`Amount`,`Realized P&L`,`USDC fees`,`Funding`,`Net realized`]:[`Time`,`Notes`,`Type`,`Symbol/Asset`,`Fee USDC`,`Realized P&L USDC`,`USDC delta`,`Balance`]).map(e=>(0,_.jsx)(`th`,{className:y,children:e},e))})}),(0,_.jsx)(`tbody`,{className:`divide-y divide-zinc-800`,children:i.view===`trades`?i.trades.map(e=>(0,_.jsxs)(`tr`,{className:`hover:bg-zinc-900/50`,children:[(0,_.jsx)(`td`,{className:y,children:(0,_.jsxs)(`button`,{className:`inline-flex cursor-pointer items-center gap-1 text-violet-300`,onClick:()=>l({id:e.id,label:`${e.symbol} ${e.direction} trade`,trade:e}),children:[(0,_.jsx)(m,{symbol:e.symbol}),` · `,e.direction]})}),(0,_.jsxs)(`td`,{className:y,children:[e.status,e.coverageReason&&(0,_.jsx)(`span`,{title:e.coverageReason,className:`block text-xs text-amber-300`,children:`Incomplete coverage`})]}),(0,_.jsx)(`td`,{className:y,children:u(e.id,`${e.symbol} trade`,e.noteCount)}),(0,_.jsx)(`td`,{className:`${y} text-xs text-zinc-400`,children:(0,_.jsx)(S,{value:e.lastActivityAt})}),(0,_.jsxs)(`td`,{className:`${y} font-mono text-xs`,children:[x(e.entryNotional,e.entrySize),` / `,x(e.exitNotional,e.exitSize)]}),(0,_.jsx)(`td`,{className:`${y} font-mono text-xs`,children:e.entrySize}),(0,_.jsx)(`td`,{className:y,children:(0,_.jsx)(b,{value:e.grossPnl,color:!0})}),(0,_.jsx)(`td`,{className:y,children:(0,_.jsx)(b,{value:e.feeCoverage?e.fees:null})}),(0,_.jsx)(`td`,{className:y,children:(0,_.jsx)(b,{value:e.funding,color:!0})}),(0,_.jsx)(`td`,{className:y,children:(0,_.jsx)(b,{value:e.net,color:!0})})]},e.id)):i.activity.map(e=>(0,_.jsxs)(`tr`,{className:`hover:bg-zinc-900/50`,children:[(0,_.jsx)(`td`,{className:`${y} text-xs text-zinc-400`,children:(0,_.jsx)(S,{value:e.time})}),(0,_.jsx)(`td`,{className:y,children:u(e.id,`transaction`,e.noteCount)}),(0,_.jsx)(`td`,{className:y,children:e.type===`fill A`?`Fill · Sell`:e.type===`fill B`?`Fill · Buy`:e.type}),(0,_.jsx)(`td`,{className:y,children:e.symbol&&(e.fill||e.kind===`funding`)?(0,_.jsx)(m,{symbol:e.symbol}):e.symbol??`—`}),(0,_.jsx)(`td`,{className:y,children:(0,_.jsx)(b,{value:e.fee,missing:`—`})}),(0,_.jsx)(`td`,{className:y,children:(0,_.jsx)(b,{value:e.pnl,color:!0,missing:`—`})}),(0,_.jsx)(`td`,{className:y,children:(0,_.jsx)(b,{value:e.delta,color:!0})}),(0,_.jsx)(`td`,{className:y,children:(0,_.jsx)(b,{value:e.balance})})]},e.id))})]})}),(0,_.jsxs)(`p`,{className:`mt-4 text-xs text-zinc-500`,children:[i.total,` `,i.view===`trades`?`trades`:`events`,` · Automatic flat-to-flat grouping for perpetuals. Spot fills appear in Activity.`]}),(0,_.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500`,children:`Hyperliquid provides only the latest 10,000 historical fills. Imported history is retained locally. Funding and balances reflect imported events, not a verified account-equity snapshot. Unknown cash impacts remain incomplete.`})]}):(0,_.jsx)(`p`,{className:`mt-4 text-sm text-zinc-400`,children:`No trading account is linked to this Agent.`}),s&&(0,_.jsx)(w,{id:e,target:s,onClose:()=>l(null)},s.id)]})}function w({id:e,target:t,onClose:n}){let o=(0,g.useRef)(null),[c,u]=(0,g.useState)(``),p=r(),m=a(d(e,t.id)),h=a(l(e,t.id)),y=i({...s(e,t.id,c),onSuccess:()=>{u(``),p.invalidateQueries({queryKey:[`journal-notes`,e,t.id]})}});return(0,g.useEffect)(()=>{o.current?.showModal()},[]),(0,_.jsxs)(`dialog`,{ref:o,"aria-labelledby":`journal-notes-title`,onCancel:n,className:`m-auto max-h-[85vh] w-[calc(100vw-2rem)] max-w-3xl overflow-auto rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6 text-zinc-200 backdrop:bg-black/70`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsxs)(`h3`,{id:`journal-notes-title`,className:`text-lg font-medium`,children:[t.label,` notes`]}),(0,_.jsx)(`button`,{className:v,"aria-label":`Close notes`,onClick:n,children:`Close`})]}),t.trade&&(0,_.jsxs)(`details`,{className:`mt-4 rounded-xl border border-zinc-800 p-4`,children:[(0,_.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:`Trade fills`}),(0,_.jsx)(`div`,{className:`mt-3 space-y-2 text-xs text-zinc-400`,children:t.trade.parts.map(e=>(0,_.jsxs)(`p`,{children:[(0,_.jsx)(S,{value:e.time}),` · `,e.side,` · `,e.segment,` `,e.quantity,` @ `,f(e.price),` · fee `,e.fee??`unknown`,` · realized `,(0,_.jsx)(b,{value:e.pnl,color:!0})]},`${e.eventId}-${e.segment}`))})]}),(0,_.jsxs)(`section`,{className:`mt-4 space-y-2 rounded-xl border border-zinc-800 p-4`,"aria-label":`Order attribution`,children:[(0,_.jsx)(`h4`,{className:`text-sm`,children:`Order attribution`}),h.error&&(0,_.jsx)(`p`,{role:`status`,className:`text-xs text-amber-200`,children:h.error.message}),h.data?(t=>(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`p`,{className:`text-xs text-zinc-400`,children:[t.coverage,t.truncated?` First 50 fills only; inspect the bounded reviewer audit for more.`:``]}),!t.items.length&&(0,_.jsx)(`p`,{className:`text-xs text-zinc-400`,children:`No applicable fill attribution for this entry.`}),t.items.map(t=>(0,_.jsxs)(`p`,{className:`text-xs text-zinc-300`,children:[`OID `,t.exchangeOid??`unknown`,` · `,t.requestId?`request ${t.requestId}`:`external/unmatched`,t.decisionRef&&(0,_.jsxs)(_.Fragment,{children:[` · `,(0,_.jsx)(`a`,{className:`cursor-pointer text-violet-300`,href:`/agents/${encodeURIComponent(e)}/memories/${encodeURIComponent(t.decisionRef)}`,children:t.decisionRef})]})]},t.fillId))]}))(h.data):!h.error&&(0,_.jsx)(`p`,{className:`text-xs`,children:`Loading attribution…`})]}),(0,_.jsxs)(`div`,{className:`my-4 space-y-3`,children:[m.error&&(0,_.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:m.error.message}),y.error&&(0,_.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:y.error.message}),m.isPending?(0,_.jsx)(`p`,{role:`status`,children:`Loading notes…`}):m.data?.length?m.data.map(e=>(0,_.jsxs)(`article`,{className:`rounded-xl border border-zinc-800 p-4`,children:[(0,_.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm`,children:e.body}),(0,_.jsxs)(`p`,{className:`mt-2 text-xs text-zinc-500`,children:[`human · `,e.authorId,` · `,(0,_.jsx)(S,{value:e.createdAt})]})]},e.id)):(0,_.jsx)(`p`,{className:`text-sm text-zinc-500`,children:`No notes yet.`})]}),(0,_.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),y.mutate()},children:[(0,_.jsx)(`label`,{htmlFor:`journal-note`,className:`mb-2 block text-sm`,children:`Add a note`}),(0,_.jsx)(`textarea`,{id:`journal-note`,value:c,onChange:e=>u(e.target.value),rows:3,maxLength:4e3,required:!0,className:`w-full rounded-lg border border-zinc-700 bg-zinc-950 p-3 text-sm`}),(0,_.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,_.jsx)(`button`,{className:v,disabled:y.isPending||!c.trim(),children:y.isPending?`Saving…`:`Add note`})})]})]})}function T(){let{agentId:e}=u.useParams(),{view:t,page:n}=u.useSearch(),r=u.useNavigate();return(0,_.jsx)(C,{id:e,view:t,page:n,onNavigate:(e,t)=>{r({search:{view:e,page:t}})}},e)}export{T as component};
|
|
1
|
+
import{f as e,l as t,t as n}from"./jsx-runtime-CIazjfqY.js";import{i as r}from"./createServerFn-DfZIp2Fu.js";import{t as i}from"./useMutation-DrF53EQG.js";import{t as a}from"./useQuery-BMSU16jY.js";import{t as o}from"./useSuspenseQuery-vODFwDb8.js";import{c as s,d as c,l,s as u,u as d}from"./index-B4hvjMmI.js";import{i as f,n as p}from"./decimal-B0DEG-1V.js";import{t as m}from"./instrument-label-BZYlWXR5.js";import{t as h}from"./journal-decimal-DBvd_Ibi.js";var g=e(t(),1),_=n(),v=`cursor-pointer rounded-full border border-zinc-800 px-4 py-1.5 text-sm text-zinc-300 hover:border-zinc-600 hover:text-white disabled:cursor-not-allowed disabled:opacity-40`,y=`whitespace-nowrap px-3 py-3`;function b({value:e,color:t=!1,missing:n=`Incomplete`}){let r=e===null?0:p(e,`0`);return(0,_.jsx)(`span`,{className:`font-mono text-xs tabular-nums ${e===null?`text-amber-300`:t&&r?r<0?`text-red-400`:`text-emerald-400`:``}`,children:e===null?n:f(e)})}function x(e,t){return h(t).zero?`—`:f(h(e).div(h(t)).toString())}function S({value:e}){return(0,_.jsxs)(`time`,{dateTime:new Date(e).toISOString(),children:[new Date(e).toISOString().replace(`T`,` `).slice(0,19),` UTC`]})}function C({id:e,view:t,page:n,onNavigate:r}){let{data:i,error:a}=o(c(e,t,n)),[s,l]=(0,g.useState)(null),u=(e,t,n)=>(0,_.jsxs)(`button`,{type:`button`,className:`cursor-pointer text-violet-300 hover:text-violet-200`,"aria-label":`${n?`View`:`Add`} ${t} notes`,onClick:()=>l({id:e,label:t,trade:i.trades.find(t=>t.id===e)}),children:[`✎`,n>0&&(0,_.jsx)(`span`,{className:`ml-1 text-xs`,children:n})]}),d=i.pending||i.sync.length<3||i.sync.some(e=>e.updated_at===null);return(0,_.jsxs)(`section`,{className:`flex min-h-0 w-full flex-col rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,_.jsx)(`h2`,{className:`text-lg font-medium text-white`,children:`Transactions`}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`button`,{className:v,disabled:i.page<=1,onClick:()=>r(i.view,i.page-1),children:`Previous`}),(0,_.jsxs)(`span`,{className:`text-xs text-zinc-500`,children:[`Page `,i.page,` of `,i.pages]}),(0,_.jsx)(`button`,{className:v,disabled:i.page>=i.pages,onClick:()=>r(i.view,i.page+1),children:`Next`})]})]}),(0,_.jsx)(`nav`,{"aria-label":`Transaction view`,className:`mt-4 flex gap-2`,children:[`trades`,`activity`].map(e=>(0,_.jsx)(`button`,{className:`${v} ${i.view===e?`border-violet-500 text-white`:``}`,"aria-pressed":i.view===e,onClick:()=>r(e,1),children:e===`trades`?`Trades`:`Activity`},e))}),i.linked?(0,_.jsxs)(_.Fragment,{children:[i.historyLimited&&(0,_.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-amber-200`,children:`The initial import reached Hyperliquid’s 10,000-fill history limit. Earlier activity may be missing; account balances are incomplete.`}),d&&(0,_.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-amber-200`,children:`Synchronizing account history… Totals may be incomplete.`}),i.sync.filter(e=>e.error).map(e=>(0,_.jsxs)(`p`,{role:`alert`,className:`mt-3 text-sm text-amber-200`,children:[e.stream,`: `,e.error]},e.stream)),a&&(0,_.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-red-300`,children:a.message}),i.total===0?(0,_.jsx)(`p`,{className:`mt-6 text-sm text-zinc-400`,children:i.view===`trades`?`No trades yet.`:`No transactions have synced yet.`}):(0,_.jsx)(`div`,{className:`mt-4 min-h-0 overflow-auto`,children:(0,_.jsxs)(`table`,{className:`w-full text-sm text-zinc-300`,children:[(0,_.jsx)(`thead`,{className:`text-left text-xs uppercase text-zinc-500`,children:(0,_.jsx)(`tr`,{children:(i.view===`trades`?[`Trade`,`Status`,`Notes`,`Last activity`,`Entry / Exit price`,`Amount`,`Realized P&L`,`USDC fees`,`Funding`,`Net realized`]:[`Time`,`Notes`,`Type`,`Symbol/Asset`,`Fee USDC`,`Realized P&L USDC`,`USDC delta`,`Balance`]).map(e=>(0,_.jsx)(`th`,{className:y,children:e},e))})}),(0,_.jsx)(`tbody`,{className:`divide-y divide-zinc-800`,children:i.view===`trades`?i.trades.map(e=>(0,_.jsxs)(`tr`,{className:`hover:bg-zinc-900/50`,children:[(0,_.jsx)(`td`,{className:y,children:(0,_.jsxs)(`button`,{className:`inline-flex cursor-pointer items-center gap-1 text-violet-300`,onClick:()=>l({id:e.id,label:`${e.symbol} ${e.direction} trade`,trade:e}),children:[(0,_.jsx)(m,{symbol:e.symbol}),` · `,e.direction]})}),(0,_.jsxs)(`td`,{className:y,children:[e.status,e.coverageReason&&(0,_.jsx)(`span`,{title:e.coverageReason,className:`block text-xs text-amber-300`,children:`Incomplete coverage`})]}),(0,_.jsx)(`td`,{className:y,children:u(e.id,`${e.symbol} trade`,e.noteCount)}),(0,_.jsx)(`td`,{className:`${y} text-xs text-zinc-400`,children:(0,_.jsx)(S,{value:e.lastActivityAt})}),(0,_.jsxs)(`td`,{className:`${y} font-mono text-xs`,children:[x(e.entryNotional,e.entrySize),` / `,x(e.exitNotional,e.exitSize)]}),(0,_.jsx)(`td`,{className:`${y} font-mono text-xs`,children:e.entrySize}),(0,_.jsx)(`td`,{className:y,children:(0,_.jsx)(b,{value:e.grossPnl,color:!0})}),(0,_.jsx)(`td`,{className:y,children:(0,_.jsx)(b,{value:e.feeCoverage?e.fees:null})}),(0,_.jsx)(`td`,{className:y,children:(0,_.jsx)(b,{value:e.funding,color:!0})}),(0,_.jsx)(`td`,{className:y,children:(0,_.jsx)(b,{value:e.net,color:!0})})]},e.id)):i.activity.map(e=>(0,_.jsxs)(`tr`,{className:`hover:bg-zinc-900/50`,children:[(0,_.jsx)(`td`,{className:`${y} text-xs text-zinc-400`,children:(0,_.jsx)(S,{value:e.time})}),(0,_.jsx)(`td`,{className:y,children:u(e.id,`transaction`,e.noteCount)}),(0,_.jsx)(`td`,{className:y,children:e.type===`fill A`?`Fill · Sell`:e.type===`fill B`?`Fill · Buy`:e.type}),(0,_.jsx)(`td`,{className:y,children:e.symbol&&(e.fill||e.kind===`funding`)?(0,_.jsx)(m,{symbol:e.symbol}):e.symbol??`—`}),(0,_.jsx)(`td`,{className:y,children:(0,_.jsx)(b,{value:e.fee,missing:`—`})}),(0,_.jsx)(`td`,{className:y,children:(0,_.jsx)(b,{value:e.pnl,color:!0,missing:`—`})}),(0,_.jsx)(`td`,{className:y,children:(0,_.jsx)(b,{value:e.delta,color:!0})}),(0,_.jsx)(`td`,{className:y,children:(0,_.jsx)(b,{value:e.balance})})]},e.id))})]})}),(0,_.jsxs)(`p`,{className:`mt-4 text-xs text-zinc-500`,children:[i.total,` `,i.view===`trades`?`trades`:`events`,` · Automatic flat-to-flat grouping for perpetuals. Spot fills appear in Activity.`]}),(0,_.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500`,children:`Hyperliquid provides only the latest 10,000 historical fills. Imported history is retained locally. Funding and balances reflect imported events, not a verified account-equity snapshot. Unknown cash impacts remain incomplete.`})]}):(0,_.jsx)(`p`,{className:`mt-4 text-sm text-zinc-400`,children:`No trading account is linked to this Agent.`}),s&&(0,_.jsx)(w,{id:e,target:s,onClose:()=>l(null)},s.id)]})}function w({id:e,target:t,onClose:n}){let o=(0,g.useRef)(null),[c,u]=(0,g.useState)(``),p=r(),m=a(d(e,t.id)),h=a(l(e,t.id)),y=i({...s(e,t.id,c),onSuccess:()=>{u(``),p.invalidateQueries({queryKey:[`journal-notes`,e,t.id]})}});return(0,g.useEffect)(()=>{o.current?.showModal()},[]),(0,_.jsxs)(`dialog`,{ref:o,"aria-labelledby":`journal-notes-title`,onCancel:n,className:`m-auto max-h-[85vh] w-[calc(100vw-2rem)] max-w-3xl overflow-auto rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6 text-zinc-200 backdrop:bg-black/70`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsxs)(`h3`,{id:`journal-notes-title`,className:`text-lg font-medium`,children:[t.label,` notes`]}),(0,_.jsx)(`button`,{className:v,"aria-label":`Close notes`,onClick:n,children:`Close`})]}),t.trade&&(0,_.jsxs)(`details`,{className:`mt-4 rounded-xl border border-zinc-800 p-4`,children:[(0,_.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:`Trade fills`}),(0,_.jsx)(`div`,{className:`mt-3 space-y-2 text-xs text-zinc-400`,children:t.trade.parts.map(e=>(0,_.jsxs)(`p`,{children:[(0,_.jsx)(S,{value:e.time}),` · `,e.side,` · `,e.segment,` `,e.quantity,` @ `,f(e.price),` · fee `,e.fee??`unknown`,` · realized `,(0,_.jsx)(b,{value:e.pnl,color:!0})]},`${e.eventId}-${e.segment}`))})]}),(0,_.jsxs)(`section`,{className:`mt-4 space-y-2 rounded-xl border border-zinc-800 p-4`,"aria-label":`Order attribution`,children:[(0,_.jsx)(`h4`,{className:`text-sm`,children:`Order attribution`}),h.error&&(0,_.jsx)(`p`,{role:`status`,className:`text-xs text-amber-200`,children:h.error.message}),h.data?(t=>(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`p`,{className:`text-xs text-zinc-400`,children:[t.coverage,t.truncated?` First 50 fills only; inspect the bounded reviewer audit for more.`:``]}),!t.items.length&&(0,_.jsx)(`p`,{className:`text-xs text-zinc-400`,children:`No applicable fill attribution for this entry.`}),t.items.map(t=>(0,_.jsxs)(`p`,{className:`text-xs text-zinc-300`,children:[`OID `,t.exchangeOid??`unknown`,` · `,t.requestId?`request ${t.requestId}`:`external/unmatched`,t.decisionRef&&(0,_.jsxs)(_.Fragment,{children:[` · `,(0,_.jsx)(`a`,{className:`cursor-pointer text-violet-300`,href:`/agents/${encodeURIComponent(e)}/memories/${encodeURIComponent(t.decisionRef)}`,children:t.decisionRef})]})]},t.fillId))]}))(h.data):!h.error&&(0,_.jsx)(`p`,{className:`text-xs`,children:`Loading attribution…`})]}),(0,_.jsxs)(`div`,{className:`my-4 space-y-3`,children:[m.error&&(0,_.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:m.error.message}),y.error&&(0,_.jsx)(`p`,{role:`alert`,className:`text-sm text-red-300`,children:y.error.message}),m.isPending?(0,_.jsx)(`p`,{role:`status`,children:`Loading notes…`}):m.data?.length?m.data.map(e=>(0,_.jsxs)(`article`,{className:`rounded-xl border border-zinc-800 p-4`,children:[(0,_.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm`,children:e.body}),(0,_.jsxs)(`p`,{className:`mt-2 text-xs text-zinc-500`,children:[`human · `,e.authorId,` · `,(0,_.jsx)(S,{value:e.createdAt})]})]},e.id)):(0,_.jsx)(`p`,{className:`text-sm text-zinc-500`,children:`No notes yet.`})]}),(0,_.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),y.mutate()},children:[(0,_.jsx)(`label`,{htmlFor:`journal-note`,className:`mb-2 block text-sm`,children:`Add a note`}),(0,_.jsx)(`textarea`,{id:`journal-note`,value:c,onChange:e=>u(e.target.value),rows:3,maxLength:4e3,required:!0,className:`w-full rounded-lg border border-zinc-700 bg-zinc-950 p-3 text-sm`}),(0,_.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,_.jsx)(`button`,{className:v,disabled:y.isPending||!c.trim(),children:y.isPending?`Saving…`:`Add note`})})]})]})}function T(){let{agentId:e}=u.useParams(),{view:t,page:n}=u.useSearch(),r=u.useNavigate();return(0,_.jsx)(C,{id:e,view:t,page:n,onNavigate:(e,t)=>{r({search:{view:e,page:t}})}},e)}export{T as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e,l as t,t as n}from"./jsx-runtime-CIazjfqY.js";import{i as r}from"./createServerFn-DfZIp2Fu.js";import{t as i}from"./useMutation-
|
|
1
|
+
import{f as e,l as t,t as n}from"./jsx-runtime-CIazjfqY.js";import{i as r}from"./createServerFn-DfZIp2Fu.js";import{t as i}from"./useMutation-DrF53EQG.js";import{t as a}from"./useSuspenseQuery-vODFwDb8.js";import{r as o}from"./provider-queries-DxPwhDOU.js";import{t as s}from"./useRouter-c0I1aURm.js";import{d as c,f as l,o as u,s as d}from"./agent-queries-CNMBImun.js";import{i as f}from"./decimal-B0DEG-1V.js";import{t as p}from"./random-uuid-DJR3ygJS.js";import{a as m,n as h}from"./model-picker-YCQNNmyw.js";var g=e(t(),1),_=n();function v({choices:e,models:t,create:n,createSubaccount:a}){let o=s(),[c,l]=(0,g.useState)(``),[d,f]=(0,g.useState)(`main`),[v,b]=(0,g.useState)(``),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(!0),T=t.find(e=>m(e)===v),E=r(),D=i({mutationFn:e=>n(...e),onSuccess:async e=>{await u(E),await o.navigate({to:`/agents/$agentId`,params:{agentId:e.id}})}}),O=i({mutationFn:a,onSuccess:async e=>{f(e.address),await u(E)}}),k=D.isPending,A=O.isPending,[j,M]=(0,g.useState)(),N=j??D.error?.message,P=O.error?.message??(O.data?O.data.created?`Sub-account created.`:`An existing matching Sub-account was found.`:``),F=(0,g.useRef)(null),I=(0,g.useRef)(!1),L=(0,g.useRef)(!1),R=c.trim(),z=d===`main`?!e.mainAssignedTo:e.subaccounts.some(e=>e.address===d&&!e.assignedTo),B=e.apiWalletReady&&e.accountModeSupported&&!e.lookupError&&z;async function V(){if(!(I.current||!R||!T||!B)){I.current=!0,M(void 0);try{let e=JSON.stringify([R,d,v,C,x]);F.current?.settings!==e&&(F.current={settings:e,id:p()}),await D.mutateAsync([R,F.current.id,d,T,C,x])}catch(e){M(e instanceof Error?e.message:`Could not create the agent. Please try again.`)}finally{I.current=!1}}}async function H(){if(!(L.current||!R)){L.current=!0;try{await O.mutateAsync(R)}catch{}finally{L.current=!1}}}return(0,_.jsxs)(`div`,{className:`mx-auto max-w-3xl`,"data-agent-creation":!0,children:[(0,_.jsx)(`header`,{className:`border-b border-zinc-800 pb-6`,children:(0,_.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight text-white`,children:`Create New Agent`})}),!e.apiWalletReady&&(0,_.jsxs)(`p`,{role:`status`,className:`mt-6 rounded-2xl border border-amber-800/70 bg-amber-950/30 px-4 py-3 text-sm text-amber-200`,children:[`Every agent requires a linked Hyperliquid account and an approved API key. `,(0,_.jsx)(`a`,{href:`/account`,className:`cursor-pointer underline`,children:`Set it up on the Account page`}),` before creating an agent.`]}),e.lookupError&&(0,_.jsx)(`p`,{role:`status`,className:`mt-6 rounded-2xl border border-red-900/60 bg-red-950/20 px-4 py-3 text-sm text-red-300`,children:e.lookupError}),(0,_.jsxs)(`form`,{className:`mt-6 space-y-6`,onSubmit:e=>{e.preventDefault(),V()},children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`label`,{htmlFor:`display_name`,className:`block text-sm font-medium text-zinc-300`,children:`Name`}),(0,_.jsx)(`input`,{id:`display_name`,type:`text`,value:c,onChange:e=>l(e.target.value),required:!0,maxLength:80,autoFocus:!0,placeholder:`BTC Momentum`,className:`mt-2 block w-full rounded-xl border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:border-zinc-600 focus:outline-none`})]}),(0,_.jsx)(h,{choices:t,value:v,thinkingLevel:x,onChange:(e,t)=>{b(e),S(t)},disabled:k}),(0,_.jsx)(`a`,{href:`/providers`,className:`block cursor-pointer text-xs text-violet-300 hover:underline`,children:`Manage provider connections`}),(0,_.jsxs)(`fieldset`,{children:[(0,_.jsx)(`legend`,{className:`text-sm font-medium text-zinc-300`,children:`Trading account`}),e.subaccountCapacity&&(0,_.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:[`Sub-account capacity: `,e.subaccountCapacity,`.`]}),(0,_.jsxs)(`div`,{className:`mt-3 overflow-hidden rounded-xl border border-zinc-700 divide-y divide-zinc-800`,children:[(0,_.jsx)(y,{label:`Main account`,address:e.mainAddress,balance:e.mainBalance,checked:d===`main`,disabled:!!e.mainAssignedTo,note:e.mainAssignedTo?`Already assigned to ${e.mainAssignedTo}`:null,onSelect:()=>f(`main`)}),e.subaccounts.map(e=>(0,_.jsx)(y,{label:e.name?`Sub-account: ${e.name}`:`Sub-account`,address:e.address,balance:e.balance,checked:d===e.address,disabled:!!e.assignedTo,note:e.assignedTo?`In use by ${e.assignedTo.agentName}`:null,onSelect:()=>f(e.address)},e.address)),(0,_.jsxs)(`div`,{className:`p-4`,children:[(0,_.jsx)(`button`,{type:`button`,disabled:A||!R||!e.apiWalletReady||!e.accountModeSupported,onClick:()=>{H()},className:`cursor-pointer rounded-full border border-violet-500 px-5 py-2 text-sm font-medium text-violet-200 hover:border-violet-400 hover:bg-violet-950/40 hover:text-white disabled:cursor-wait disabled:opacity-50`,children:A?`Creating…`:`Create Sub-Account`}),(0,_.jsx)(`p`,{"aria-live":`polite`,className:`mt-3 text-sm text-zinc-400`,children:P||(R?``:`Enter an agent name first.`)})]})]})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 text-sm font-medium text-zinc-300`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:C,disabled:k,onChange:e=>w(e.target.checked),"aria-describedby":`default-subagents-description`,className:`cursor-pointer accent-violet-500`}),`Include default sub-agents`]}),(0,_.jsx)(`p`,{id:`default-subagents-description`,className:`mt-2 text-sm text-zinc-500`,children:`Adds a connected Technical Analyst, Trader, and Daily Reviewer. All start paused.`})]}),N&&(0,_.jsx)(`p`,{role:`alert`,className:`rounded-2xl border border-red-900/60 bg-red-950/20 p-4 text-sm text-red-300`,children:N}),(0,_.jsxs)(`div`,{className:`flex items-center gap-3 border-t border-zinc-800 pt-6`,children:[(0,_.jsx)(`button`,{type:`submit`,disabled:k||!R||!T||!B,className:`cursor-pointer rounded-full bg-violet-600 px-5 py-2 text-sm font-medium text-white hover:bg-violet-500 disabled:cursor-wait disabled:opacity-50`,children:k?`Creating…`:`Create agent`}),(0,_.jsx)(`a`,{href:`/agents`,className:`cursor-pointer rounded-full border border-zinc-700 px-5 py-2 text-sm font-medium text-zinc-500 hover:border-zinc-600 hover:text-zinc-300`,children:`Cancel`})]})]})]})}function y({label:e,address:t,balance:n,checked:r,disabled:i,note:a,onSelect:o}){return(0,_.jsxs)(`label`,{className:`flex cursor-pointer gap-3 p-4 transition hover:bg-zinc-900/60 ${i?`opacity-50`:``}`,children:[(0,_.jsx)(`input`,{className:`peer sr-only`,type:`radio`,name:`trading_account_selection`,checked:r,disabled:i,onChange:o}),(0,_.jsx)(`span`,{className:`peer-checked:border-violet-500 peer-checked:bg-violet-500 peer-checked:after:opacity-100 mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border-2 border-zinc-600 bg-zinc-950 transition after:size-1.5 after:rounded-full after:bg-white after:opacity-0 after:content-[''] peer-focus-visible:ring-2 peer-focus-visible:ring-violet-400`,"aria-hidden":`true`}),(0,_.jsxs)(`span`,{className:`min-w-0`,children:[(0,_.jsx)(`span`,{className:`text-sm text-white`,children:e}),t&&(0,_.jsxs)(`span`,{className:`mt-1 block break-all font-mono text-xs text-zinc-500`,children:[t,n?` · ${f(n)} USDC`:``]}),a&&(0,_.jsx)(`span`,{className:`mt-1 block text-xs text-amber-300`,children:a})]})]})}function b(){let{data:e}=a(o()),{data:t}=a(d());return(0,_.jsx)(v,{choices:t,models:e,create:(e,t,n,r,i,a)=>c({data:{name:e,requestId:t,accountSelection:n,provider:r.provider,modelId:r.modelId,includeDefaultSubagents:i,thinkingLevel:a}}),createSubaccount:e=>l({data:{name:e}})})}export{b as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e,l as t,t as n}from"./jsx-runtime-CIazjfqY.js";import{i as r}from"./createServerFn-DfZIp2Fu.js";import{t as i}from"./useMutation-Dni_73Pp.js";import{t as a}from"./useSuspenseQuery-vODFwDb8.js";import{a as o,i as s,o as c,t as l}from"./provider-queries-DxPwhDOU.js";import{j as u}from"./index-fu66g8fn.js";import{t as d}from"./setup-checklist-CUW-K484.js";import{t as f}from"./provider-logo-Ddb77aBD.js";import{a as p,i as m,r as h}from"./model-picker-YCQNNmyw.js";var g=e(t(),1),_=n(),v=`cursor-pointer rounded-lg border border-zinc-700 px-3 py-2 text-sm hover:bg-zinc-800 disabled:cursor-not-allowed disabled:opacity-50`,y=`cursor-pointer rounded-lg bg-violet-600 px-3 py-2 text-sm text-white hover:bg-violet-500 disabled:cursor-not-allowed disabled:opacity-50`,b=`cursor-pointer rounded-lg border border-red-800 px-3 py-2 text-sm text-red-300 hover:bg-red-950 hover:text-red-200 disabled:cursor-not-allowed disabled:opacity-50`,x=`w-full rounded-lg border border-zinc-700 bg-zinc-950 px-3 py-2 text-sm text-white`;function S(e){return e.type===`oauth`?`OAuth`:`API key`}function C(){let e=r(),t=(0,g.useRef)(void 0);function n(){t.current?.tab.close(),t.current=void 0}let{data:y,error:C}=a(o()),{data:E}=a(c()),{agentCount:D}=E,O=i({...s(e),onError:(e,t)=>{t.type===`answer`&&n()},onSuccess:(e,t)=>{t.type===`begin`&&e?e.state===`complete`?u.success(`Provider connected.`):A(e):t.type===`cancel`?A(void 0):t.type===`answer`&&P(``)}}),[k,A]=(0,g.useState)(y.activeLogin),[j,M]=(0,g.useState)(),[N,P]=(0,g.useState)(``),[F,I]=(0,g.useState)(``),[L,R]=(0,g.useState)(),[z,B]=(0,g.useState)(``),V=O.isPending,H=z||O.error?.message||C?.message,U=k?.state===`pending`;(0,g.useEffect)(()=>()=>n(),[]),(0,g.useEffect)(()=>{let e=t.current;if(!e)return;if(!k||k.id!==e.loginId||k.state!==`pending`){n();return}let r=k.events.slice(e.eventCount).find(e=>e.type===`auth_url`);if(r?.type===`auth_url`)try{let i=new URL(r.url);if(i.protocol!==`https:`&&i.protocol!==`http:`){n();return}e.tab.closed||e.tab.location.replace(i.href),t.current=void 0}catch{n()}},[k]),(0,g.useEffect)(()=>{P(``)},[k?.prompt?.id]),(0,g.useEffect)(()=>{if(!k||k.state!==`pending`)return;let t=!1,n=new EventSource(`/api/providers/logins/${encodeURIComponent(k.id)}/events`);return n.addEventListener(`provider-login`,r=>{if(t)return;let i=JSON.parse(r.data);if(B(``),i.state===`pending`){A(i);return}n.close(),A(i.state===`failed`?i:void 0),i.state===`complete`&&u.success(`Provider connected.`),l(e)}),n.onerror=()=>{t||(n.readyState===EventSource.CLOSED?(A(void 0),B(`Sign-in status unavailable. Reload the page to reconnect.`)):B(`Sign-in status unavailable. Reconnecting…`))},n.addEventListener(`stream-error`,()=>{n.close(),t||(A(void 0),B(`Sign-in status unavailable. Reload the page.`))}),n.addEventListener(`unauthorized`,()=>{n.close(),t||(A(void 0),B(`Session ended. Please sign in again.`))}),()=>{t=!0,n.close()}},[e,k?.id,k?.state]);function W(e,t){B(``),O.mutate({type:`begin`,providerId:e,authType:t})}function G(e){let r=k?.prompt;if(!(!k||!r)&&!V){if(e===`browser`&&r.input.type===`select`&&r.input.options.some(e=>e.id===`browser`)){n();try{let e=window.open(`about:blank`,`_blank`);e&&(e.opener=null,t.current={tab:e,loginId:k.id,eventCount:k.events.length})}catch{n()}}O.mutate({type:`answer`,id:k.id,promptId:r.id,value:e})}}function K(){if(n(),k){if(k.state!==`pending`){A(void 0);return}O.mutate({type:`cancel`,id:k.id})}}function q(e){O.mutate({type:`disconnect`,providerId:e.id})}let J=y.providers.filter(e=>e.connected),Y=e=>{let t=y.models.filter(t=>t.provider===e.id),n=L===e.id&&t.length>0;return(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4 p-4`,children:[(0,_.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,_.jsx)(f,{provider:e.id,className:`h-8 w-8 shrink-0 rounded-lg border border-zinc-800 bg-white p-1`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h3`,{className:`font-medium text-white`,children:e.name}),(0,_.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-400`,children:[(0,_.jsx)(`span`,{className:e.connected?e.configured?`text-emerald-400`:`text-amber-300`:void 0,children:e.connected?e.configured?`Configured · ${e.authType===`oauth`?`OAuth`:`API key`}`:`Connection needs attention`:`Not connected`}),` · `,t.length>0?(0,_.jsxs)(`button`,{type:`button`,className:`cursor-pointer underline decoration-zinc-600 hover:text-white`,"aria-expanded":n,onClick:()=>R(n?void 0:e.id),children:[t.length,` chat models`]}):`${t.length} chat models`]})]})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.methods.map(t=>(0,_.jsx)(`button`,{className:v,disabled:V||U||!y.storageReady,onClick:()=>W(e.id,t.type),children:e.connected?`Re-connect`:S(t)},t.type)),!e.methods.length&&(0,_.jsx)(`span`,{className:`text-xs text-zinc-500`,children:`Ambient-only authentication is not available in per-user setup.`}),e.connected&&(0,_.jsx)(`button`,{className:b,disabled:V||U,onClick:()=>M(e),children:`Disconnect`})]})]}),n&&(0,_.jsx)(`div`,{className:`max-h-60 overflow-y-auto border-t border-zinc-800 px-4 py-3`,children:(0,_.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,_.jsxs)(`caption`,{className:`sr-only`,children:[e.name,` chat models`]}),(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`text-left text-zinc-500`,children:[(0,_.jsx)(`th`,{scope:`col`,className:`py-1 pr-4 font-medium`,children:`Model`}),(0,_.jsx)(`th`,{scope:`col`,className:`py-1 pr-4 font-medium`,children:`ID`}),(0,_.jsx)(`th`,{scope:`col`,className:`py-1 pr-4 font-medium`,children:`Context`}),(0,_.jsx)(`th`,{scope:`col`,className:`py-1 pr-4 font-medium`,children:`Reasoning`}),(0,_.jsx)(`th`,{scope:`col`,className:`py-1 pr-4 text-right font-medium`,children:`Input / 1M`}),(0,_.jsx)(`th`,{scope:`col`,className:`py-1 text-right font-medium`,children:`Output / 1M`})]})}),(0,_.jsx)(`tbody`,{children:t.map(e=>(0,_.jsxs)(`tr`,{className:`border-t border-zinc-800/60`,children:[(0,_.jsx)(`td`,{className:`max-w-48 truncate py-1.5 pr-4 text-zinc-200`,children:e.name}),(0,_.jsx)(`td`,{className:`max-w-48 truncate py-1.5 pr-4 text-zinc-500`,children:e.modelId}),(0,_.jsx)(`td`,{className:`whitespace-nowrap py-1.5 pr-4 text-zinc-400`,children:h(e)}),(0,_.jsx)(`td`,{className:`whitespace-nowrap py-1.5 pr-4 text-zinc-400`,children:e.reasoning?`Yes`:`—`}),(0,_.jsx)(`td`,{className:`whitespace-nowrap py-1.5 pr-4 text-right font-mono text-zinc-400`,children:m(e.inputCost)}),(0,_.jsx)(`td`,{className:`whitespace-nowrap py-1.5 text-right font-mono text-zinc-400`,children:m(e.outputCost)})]},p(e)))})]})})]},e.id)},X=k!==void 0&&(k.state===`pending`||k.state===`failed`);return(0,_.jsxs)(`div`,{className:`mx-auto flex h-[calc(100dvh-6.5rem)] max-w-4xl flex-col gap-6 overflow-hidden`,children:[(0,_.jsxs)(`header`,{className:`shrink-0`,children:[(0,_.jsx)(`h1`,{className:`text-3xl font-semibold text-white`,children:`Providers`}),(0,_.jsx)(`p`,{className:`mt-2 text-sm text-zinc-400`,children:`Connect your AI accounts.`})]}),!y.storageReady&&(0,_.jsx)(`p`,{role:`status`,className:`shrink-0 text-sm text-amber-200`,children:`Provider setup requires AGENTS_ENCRYPTION_KEY on the server.`}),(0,_.jsx)(d,{state:{...E,providerConnected:J.length>0},agentCount:D}),H&&(0,_.jsx)(`p`,{role:`alert`,className:`shrink-0 text-sm text-red-300`,children:H}),J.length>0&&(0,_.jsxs)(`section`,{"aria-labelledby":`connected-providers-heading`,className:`shrink-0 space-y-3`,children:[(0,_.jsx)(`h2`,{id:`connected-providers-heading`,className:`text-lg font-semibold text-white`,children:`Connected Providers`}),(0,_.jsx)(`div`,{className:`divide-y divide-zinc-800 rounded-xl border border-zinc-800`,children:J.map(Y)})]}),(0,_.jsxs)(`section`,{"aria-labelledby":`all-providers-heading`,className:`flex min-h-0 flex-1 flex-col gap-3`,children:[(0,_.jsx)(`h2`,{id:`all-providers-heading`,className:`shrink-0 text-lg font-semibold text-white`,children:`All Providers`}),(0,_.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-3`,children:[(0,_.jsx)(`input`,{autoFocus:!0,"aria-label":`Search providers`,placeholder:`Search providers…`,className:`${x} flex-1`,value:F,onChange:e=>I(e.target.value)}),(0,_.jsx)(`button`,{className:v,disabled:V||U,onClick:()=>O.mutate({type:`refresh`}),children:`Refresh models`})]}),(0,_.jsx)(`div`,{className:`min-h-0 flex-1 divide-y divide-zinc-800 overflow-y-auto rounded-xl border border-zinc-800`,children:y.providers.filter(e=>!e.connected&&`${e.name} ${e.id}`.toLowerCase().includes(F.toLowerCase())).map(Y)})]}),X&&k&&(0,_.jsx)(w,{login:k,providerName:y.providers.find(e=>e.id===k.providerId)?.name??k.providerId,value:N,onValueChange:P,pending:V,onSubmit:G,onCancel:K}),j&&(0,_.jsx)(T,{provider:j,onCancel:()=>M(void 0),onConfirm:()=>{let e=j;M(void 0),q(e)}})]})}function w({login:e,providerName:t,value:n,onValueChange:r,pending:i,onSubmit:a,onCancel:o}){let s=(0,g.useRef)(null),c=(0,g.useId)(),l=(0,g.useId)();(0,g.useEffect)(()=>{let e=s.current;return e.showModal(),()=>e.close()},[]);let u=e.prompt,d=u?.input.type===`select`&&u.input.options.length===2&&u.input.options.some(e=>e.id===`browser`)&&u.input.options.some(e=>e.id===`device_code`)?[...u.input.options].sort(e=>e.id===`browser`?-1:1):void 0;return(0,_.jsxs)(`dialog`,{ref:s,"aria-labelledby":c,onCancel:e=>{e.preventDefault(),i||o()},className:`m-auto max-h-[calc(100dvh-2rem)] w-[calc(100%_-_2rem)] max-w-md overflow-y-auto rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6 text-zinc-100 shadow-2xl backdrop:bg-black/70 backdrop:backdrop-blur-sm`,children:[(0,_.jsxs)(`h3`,{id:c,className:`text-lg font-semibold text-white`,children:[t,` sign-in`]}),e.events.length>0&&(0,_.jsx)(`div`,{className:`mt-4 space-y-3`,children:e.events.map((e,t)=>(0,_.jsx)(O,{event:e},t))}),e.state===`failed`&&(0,_.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-red-300`,children:e.error??`Sign-in failed.`}),e.state===`pending`&&u&&(0,_.jsx)(`form`,{id:l,className:`mt-4 space-y-3`,onSubmit:e=>{e.preventDefault(),a(n)},children:d?(0,_.jsxs)(`fieldset`,{disabled:i,children:[(0,_.jsx)(`legend`,{className:`text-sm`,children:u.input.message}),(0,_.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:d.map(e=>(0,_.jsxs)(`button`,{type:`button`,"aria-label":e.label,title:e.description?`${e.label} — ${e.description}`:e.label,className:`${v} flex flex-col items-center justify-center gap-2 py-5 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-violet-400`,onClick:()=>a(e.id),children:[(0,_.jsx)(`svg`,{"aria-hidden":`true`,className:`h-7 w-7`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:e.id===`browser`?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`16`,rx:`2`}),(0,_.jsx)(`path`,{d:`M3 9h18M7 6.5h.01M10 6.5h.01`})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`16`,rx:`2`}),(0,_.jsx)(`path`,{d:`m7 9 3 3-3 3m6 0h4`})]})}),(0,_.jsx)(`span`,{children:e.id===`browser`?`Browser (default)`:`Device code`})]},e.id))})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`label`,{htmlFor:`provider-answer`,className:`block text-sm`,children:u.input.message}),u.input.type===`select`?(0,_.jsxs)(`select`,{id:`provider-answer`,className:x,value:n,onChange:e=>r(e.target.value),required:!0,children:[(0,_.jsx)(`option`,{value:``,children:`Choose…`}),u.input.options.map(e=>(0,_.jsxs)(`option`,{value:e.id,children:[e.label,e.description?` — ${e.description}`:``]},e.id))]}):(0,_.jsx)(`input`,{id:`provider-answer`,className:x,autoComplete:`off`,type:u.input.type===`secret`?`password`:`text`,value:n,maxLength:16e3,placeholder:`placeholder`in u.input?u.input.placeholder:void 0,onChange:e=>r(e.target.value),required:u.input.type!==`text`})]})},u.id),e.state===`pending`&&!u&&(0,_.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-zinc-400`,children:`Waiting for provider…`}),e.state===`failed`?(0,_.jsx)(`div`,{className:`mt-6 flex items-center justify-end gap-3`,children:(0,_.jsx)(`button`,{type:`button`,className:v,onClick:o,children:`Close`})}):(0,_.jsxs)(`div`,{className:`mt-6 flex items-center justify-between gap-3`,children:[(0,_.jsx)(`button`,{type:`button`,className:v,disabled:i,onClick:o,children:`Cancel sign-in`}),u&&!d&&(0,_.jsx)(`button`,{type:`submit`,form:l,className:y,disabled:i||u.input.type!==`text`&&!n.trim(),children:`Continue`})]})]})}function T({provider:e,onCancel:t,onConfirm:n}){let r=(0,g.useRef)(null),i=(0,g.useId)();return(0,g.useEffect)(()=>{let e=r.current;return e.showModal(),()=>e.close()},[]),(0,_.jsxs)(`dialog`,{ref:r,"aria-labelledby":i,"aria-describedby":`${i}-description`,onCancel:e=>{e.preventDefault(),t()},className:`m-auto w-[calc(100%_-_2rem)] max-w-md rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6 text-zinc-100 shadow-2xl backdrop:bg-black/70 backdrop:backdrop-blur-sm`,children:[(0,_.jsxs)(`h3`,{id:i,className:`text-lg font-semibold text-white`,children:[`Disconnect `,e.name,`?`]}),(0,_.jsx)(`p`,{id:`${i}-description`,className:`mt-2 text-sm leading-6 text-zinc-400`,children:`Agents using it will need another model or a reconnection.`}),(0,_.jsxs)(`div`,{className:`mt-6 flex flex-col-reverse gap-3 sm:flex-row sm:justify-end`,children:[(0,_.jsx)(`button`,{type:`button`,autoFocus:!0,onClick:t,className:`cursor-pointer rounded-full border border-zinc-800 px-4 py-2 text-sm font-medium text-zinc-300 hover:border-zinc-700 hover:text-white`,children:`Cancel`}),(0,_.jsx)(`button`,{type:`button`,onClick:n,className:`cursor-pointer rounded-full bg-red-600 px-4 py-2 text-sm font-medium text-white hover:bg-red-500`,children:`Disconnect`})]})]})}function E({url:e,children:t}){try{if(![`http:`,`https:`].includes(new URL(e).protocol))return null}catch{return null}return(0,_.jsx)(`a`,{className:`cursor-pointer break-all text-violet-300 underline`,href:e,target:`_blank`,rel:`noopener noreferrer`,children:t})}function D({code:e,url:t}){let[n,r]=(0,g.useState)(`idle`);async function i(){if(n!==`copying`){r(`copying`);try{await navigator.clipboard.writeText(e),r(`copied`)}catch{r(`failed`)}}}return(0,_.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,_.jsx)(E,{url:t,children:`Open device authorization`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,_.jsxs)(`p`,{children:[`Code: `,(0,_.jsx)(`strong`,{className:`select-all font-mono`,children:e})]}),(0,_.jsx)(`button`,{type:`button`,className:v,disabled:n===`copying`,onClick:()=>{i()},children:`Copy to clipboard`})]}),(0,_.jsx)(`p`,{role:`status`,className:n===`failed`?`text-amber-300`:`text-emerald-400`,children:n===`copied`?`Copied!`:n===`failed`?`Unable to copy. Select and copy the code above.`:n===`copying`?`Copying…`:``})]})}function O({event:e}){return e.type===`auth_url`?(0,_.jsxs)(`p`,{className:`text-sm`,children:[(0,_.jsx)(E,{url:e.url,children:`Open provider sign-in`}),e.instructions&&(0,_.jsx)(`span`,{className:`mt-1 block text-zinc-400`,children:e.instructions})]}):e.type===`device_code`?(0,_.jsx)(D,{code:e.userCode,url:e.verificationUri},e.userCode):(0,_.jsxs)(`div`,{className:`text-sm text-zinc-400`,children:[(0,_.jsx)(`p`,{children:e.message}),e.type===`info`&&e.links?.map((e,t)=>(0,_.jsx)(E,{url:e.url,children:e.label??e.url},t))]})}var k=C;export{k as component};
|
|
1
|
+
import{f as e,l as t,t as n}from"./jsx-runtime-CIazjfqY.js";import{i as r}from"./createServerFn-DfZIp2Fu.js";import{t as i}from"./useMutation-DrF53EQG.js";import{t as a}from"./useSuspenseQuery-vODFwDb8.js";import{a as o,i as s,o as c,t as l}from"./provider-queries-DxPwhDOU.js";import{j as u}from"./index-B4hvjMmI.js";import{t as d}from"./setup-checklist-CUW-K484.js";import{t as f}from"./provider-logo-Ddb77aBD.js";import{a as p,i as m,r as h}from"./model-picker-YCQNNmyw.js";var g=e(t(),1),_=n(),v=`cursor-pointer rounded-lg border border-zinc-700 px-3 py-2 text-sm hover:bg-zinc-800 disabled:cursor-not-allowed disabled:opacity-50`,y=`cursor-pointer rounded-lg bg-violet-600 px-3 py-2 text-sm text-white hover:bg-violet-500 disabled:cursor-not-allowed disabled:opacity-50`,b=`cursor-pointer rounded-lg border border-red-800 px-3 py-2 text-sm text-red-300 hover:bg-red-950 hover:text-red-200 disabled:cursor-not-allowed disabled:opacity-50`,x=`w-full rounded-lg border border-zinc-700 bg-zinc-950 px-3 py-2 text-sm text-white`;function S(e){return e.type===`oauth`?`OAuth`:`API key`}function C(){let e=r(),t=(0,g.useRef)(void 0);function n(){t.current?.tab.close(),t.current=void 0}let{data:y,error:C}=a(o()),{data:E}=a(c()),{agentCount:D}=E,O=i({...s(e),onError:(e,t)=>{t.type===`answer`&&n()},onSuccess:(e,t)=>{t.type===`begin`&&e?e.state===`complete`?u.success(`Provider connected.`):A(e):t.type===`cancel`?A(void 0):t.type===`answer`&&P(``)}}),[k,A]=(0,g.useState)(y.activeLogin),[j,M]=(0,g.useState)(),[N,P]=(0,g.useState)(``),[F,I]=(0,g.useState)(``),[L,R]=(0,g.useState)(),[z,B]=(0,g.useState)(``),V=O.isPending,H=z||O.error?.message||C?.message,U=k?.state===`pending`;(0,g.useEffect)(()=>()=>n(),[]),(0,g.useEffect)(()=>{let e=t.current;if(!e)return;if(!k||k.id!==e.loginId||k.state!==`pending`){n();return}let r=k.events.slice(e.eventCount).find(e=>e.type===`auth_url`);if(r?.type===`auth_url`)try{let i=new URL(r.url);if(i.protocol!==`https:`&&i.protocol!==`http:`){n();return}e.tab.closed||e.tab.location.replace(i.href),t.current=void 0}catch{n()}},[k]),(0,g.useEffect)(()=>{P(``)},[k?.prompt?.id]),(0,g.useEffect)(()=>{if(!k||k.state!==`pending`)return;let t=!1,n=new EventSource(`/api/providers/logins/${encodeURIComponent(k.id)}/events`);return n.addEventListener(`provider-login`,r=>{if(t)return;let i=JSON.parse(r.data);if(B(``),i.state===`pending`){A(i);return}n.close(),A(i.state===`failed`?i:void 0),i.state===`complete`&&u.success(`Provider connected.`),l(e)}),n.onerror=()=>{t||(n.readyState===EventSource.CLOSED?(A(void 0),B(`Sign-in status unavailable. Reload the page to reconnect.`)):B(`Sign-in status unavailable. Reconnecting…`))},n.addEventListener(`stream-error`,()=>{n.close(),t||(A(void 0),B(`Sign-in status unavailable. Reload the page.`))}),n.addEventListener(`unauthorized`,()=>{n.close(),t||(A(void 0),B(`Session ended. Please sign in again.`))}),()=>{t=!0,n.close()}},[e,k?.id,k?.state]);function W(e,t){B(``),O.mutate({type:`begin`,providerId:e,authType:t})}function G(e){let r=k?.prompt;if(!(!k||!r)&&!V){if(e===`browser`&&r.input.type===`select`&&r.input.options.some(e=>e.id===`browser`)){n();try{let e=window.open(`about:blank`,`_blank`);e&&(e.opener=null,t.current={tab:e,loginId:k.id,eventCount:k.events.length})}catch{n()}}O.mutate({type:`answer`,id:k.id,promptId:r.id,value:e})}}function K(){if(n(),k){if(k.state!==`pending`){A(void 0);return}O.mutate({type:`cancel`,id:k.id})}}function q(e){O.mutate({type:`disconnect`,providerId:e.id})}let J=y.providers.filter(e=>e.connected),Y=e=>{let t=y.models.filter(t=>t.provider===e.id),n=L===e.id&&t.length>0;return(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4 p-4`,children:[(0,_.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,_.jsx)(f,{provider:e.id,className:`h-8 w-8 shrink-0 rounded-lg border border-zinc-800 bg-white p-1`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h3`,{className:`font-medium text-white`,children:e.name}),(0,_.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-400`,children:[(0,_.jsx)(`span`,{className:e.connected?e.configured?`text-emerald-400`:`text-amber-300`:void 0,children:e.connected?e.configured?`Configured · ${e.authType===`oauth`?`OAuth`:`API key`}`:`Connection needs attention`:`Not connected`}),` · `,t.length>0?(0,_.jsxs)(`button`,{type:`button`,className:`cursor-pointer underline decoration-zinc-600 hover:text-white`,"aria-expanded":n,onClick:()=>R(n?void 0:e.id),children:[t.length,` chat models`]}):`${t.length} chat models`]})]})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.methods.map(t=>(0,_.jsx)(`button`,{className:v,disabled:V||U||!y.storageReady,onClick:()=>W(e.id,t.type),children:e.connected?`Re-connect`:S(t)},t.type)),!e.methods.length&&(0,_.jsx)(`span`,{className:`text-xs text-zinc-500`,children:`Ambient-only authentication is not available in per-user setup.`}),e.connected&&(0,_.jsx)(`button`,{className:b,disabled:V||U,onClick:()=>M(e),children:`Disconnect`})]})]}),n&&(0,_.jsx)(`div`,{className:`max-h-60 overflow-y-auto border-t border-zinc-800 px-4 py-3`,children:(0,_.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,_.jsxs)(`caption`,{className:`sr-only`,children:[e.name,` chat models`]}),(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`text-left text-zinc-500`,children:[(0,_.jsx)(`th`,{scope:`col`,className:`py-1 pr-4 font-medium`,children:`Model`}),(0,_.jsx)(`th`,{scope:`col`,className:`py-1 pr-4 font-medium`,children:`ID`}),(0,_.jsx)(`th`,{scope:`col`,className:`py-1 pr-4 font-medium`,children:`Context`}),(0,_.jsx)(`th`,{scope:`col`,className:`py-1 pr-4 font-medium`,children:`Reasoning`}),(0,_.jsx)(`th`,{scope:`col`,className:`py-1 pr-4 text-right font-medium`,children:`Input / 1M`}),(0,_.jsx)(`th`,{scope:`col`,className:`py-1 text-right font-medium`,children:`Output / 1M`})]})}),(0,_.jsx)(`tbody`,{children:t.map(e=>(0,_.jsxs)(`tr`,{className:`border-t border-zinc-800/60`,children:[(0,_.jsx)(`td`,{className:`max-w-48 truncate py-1.5 pr-4 text-zinc-200`,children:e.name}),(0,_.jsx)(`td`,{className:`max-w-48 truncate py-1.5 pr-4 text-zinc-500`,children:e.modelId}),(0,_.jsx)(`td`,{className:`whitespace-nowrap py-1.5 pr-4 text-zinc-400`,children:h(e)}),(0,_.jsx)(`td`,{className:`whitespace-nowrap py-1.5 pr-4 text-zinc-400`,children:e.reasoning?`Yes`:`—`}),(0,_.jsx)(`td`,{className:`whitespace-nowrap py-1.5 pr-4 text-right font-mono text-zinc-400`,children:m(e.inputCost)}),(0,_.jsx)(`td`,{className:`whitespace-nowrap py-1.5 text-right font-mono text-zinc-400`,children:m(e.outputCost)})]},p(e)))})]})})]},e.id)},X=k!==void 0&&(k.state===`pending`||k.state===`failed`);return(0,_.jsxs)(`div`,{className:`mx-auto flex h-[calc(100dvh-6.5rem)] max-w-4xl flex-col gap-6 overflow-hidden`,children:[(0,_.jsxs)(`header`,{className:`shrink-0`,children:[(0,_.jsx)(`h1`,{className:`text-3xl font-semibold text-white`,children:`Providers`}),(0,_.jsx)(`p`,{className:`mt-2 text-sm text-zinc-400`,children:`Connect your AI accounts.`})]}),!y.storageReady&&(0,_.jsx)(`p`,{role:`status`,className:`shrink-0 text-sm text-amber-200`,children:`Provider setup requires AGENTS_ENCRYPTION_KEY on the server.`}),(0,_.jsx)(d,{state:{...E,providerConnected:J.length>0},agentCount:D}),H&&(0,_.jsx)(`p`,{role:`alert`,className:`shrink-0 text-sm text-red-300`,children:H}),J.length>0&&(0,_.jsxs)(`section`,{"aria-labelledby":`connected-providers-heading`,className:`shrink-0 space-y-3`,children:[(0,_.jsx)(`h2`,{id:`connected-providers-heading`,className:`text-lg font-semibold text-white`,children:`Connected Providers`}),(0,_.jsx)(`div`,{className:`divide-y divide-zinc-800 rounded-xl border border-zinc-800`,children:J.map(Y)})]}),(0,_.jsxs)(`section`,{"aria-labelledby":`all-providers-heading`,className:`flex min-h-0 flex-1 flex-col gap-3`,children:[(0,_.jsx)(`h2`,{id:`all-providers-heading`,className:`shrink-0 text-lg font-semibold text-white`,children:`All Providers`}),(0,_.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-3`,children:[(0,_.jsx)(`input`,{autoFocus:!0,"aria-label":`Search providers`,placeholder:`Search providers…`,className:`${x} flex-1`,value:F,onChange:e=>I(e.target.value)}),(0,_.jsx)(`button`,{className:v,disabled:V||U,onClick:()=>O.mutate({type:`refresh`}),children:`Refresh models`})]}),(0,_.jsx)(`div`,{className:`min-h-0 flex-1 divide-y divide-zinc-800 overflow-y-auto rounded-xl border border-zinc-800`,children:y.providers.filter(e=>!e.connected&&`${e.name} ${e.id}`.toLowerCase().includes(F.toLowerCase())).map(Y)})]}),X&&k&&(0,_.jsx)(w,{login:k,providerName:y.providers.find(e=>e.id===k.providerId)?.name??k.providerId,value:N,onValueChange:P,pending:V,onSubmit:G,onCancel:K}),j&&(0,_.jsx)(T,{provider:j,onCancel:()=>M(void 0),onConfirm:()=>{let e=j;M(void 0),q(e)}})]})}function w({login:e,providerName:t,value:n,onValueChange:r,pending:i,onSubmit:a,onCancel:o}){let s=(0,g.useRef)(null),c=(0,g.useId)(),l=(0,g.useId)();(0,g.useEffect)(()=>{let e=s.current;return e.showModal(),()=>e.close()},[]);let u=e.prompt,d=u?.input.type===`select`&&u.input.options.length===2&&u.input.options.some(e=>e.id===`browser`)&&u.input.options.some(e=>e.id===`device_code`)?[...u.input.options].sort(e=>e.id===`browser`?-1:1):void 0;return(0,_.jsxs)(`dialog`,{ref:s,"aria-labelledby":c,onCancel:e=>{e.preventDefault(),i||o()},className:`m-auto max-h-[calc(100dvh-2rem)] w-[calc(100%_-_2rem)] max-w-md overflow-y-auto rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6 text-zinc-100 shadow-2xl backdrop:bg-black/70 backdrop:backdrop-blur-sm`,children:[(0,_.jsxs)(`h3`,{id:c,className:`text-lg font-semibold text-white`,children:[t,` sign-in`]}),e.events.length>0&&(0,_.jsx)(`div`,{className:`mt-4 space-y-3`,children:e.events.map((e,t)=>(0,_.jsx)(O,{event:e},t))}),e.state===`failed`&&(0,_.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-red-300`,children:e.error??`Sign-in failed.`}),e.state===`pending`&&u&&(0,_.jsx)(`form`,{id:l,className:`mt-4 space-y-3`,onSubmit:e=>{e.preventDefault(),a(n)},children:d?(0,_.jsxs)(`fieldset`,{disabled:i,children:[(0,_.jsx)(`legend`,{className:`text-sm`,children:u.input.message}),(0,_.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:d.map(e=>(0,_.jsxs)(`button`,{type:`button`,"aria-label":e.label,title:e.description?`${e.label} — ${e.description}`:e.label,className:`${v} flex flex-col items-center justify-center gap-2 py-5 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-violet-400`,onClick:()=>a(e.id),children:[(0,_.jsx)(`svg`,{"aria-hidden":`true`,className:`h-7 w-7`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:e.id===`browser`?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`16`,rx:`2`}),(0,_.jsx)(`path`,{d:`M3 9h18M7 6.5h.01M10 6.5h.01`})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`16`,rx:`2`}),(0,_.jsx)(`path`,{d:`m7 9 3 3-3 3m6 0h4`})]})}),(0,_.jsx)(`span`,{children:e.id===`browser`?`Browser (default)`:`Device code`})]},e.id))})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`label`,{htmlFor:`provider-answer`,className:`block text-sm`,children:u.input.message}),u.input.type===`select`?(0,_.jsxs)(`select`,{id:`provider-answer`,className:x,value:n,onChange:e=>r(e.target.value),required:!0,children:[(0,_.jsx)(`option`,{value:``,children:`Choose…`}),u.input.options.map(e=>(0,_.jsxs)(`option`,{value:e.id,children:[e.label,e.description?` — ${e.description}`:``]},e.id))]}):(0,_.jsx)(`input`,{id:`provider-answer`,className:x,autoComplete:`off`,type:u.input.type===`secret`?`password`:`text`,value:n,maxLength:16e3,placeholder:`placeholder`in u.input?u.input.placeholder:void 0,onChange:e=>r(e.target.value),required:u.input.type!==`text`})]})},u.id),e.state===`pending`&&!u&&(0,_.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-zinc-400`,children:`Waiting for provider…`}),e.state===`failed`?(0,_.jsx)(`div`,{className:`mt-6 flex items-center justify-end gap-3`,children:(0,_.jsx)(`button`,{type:`button`,className:v,onClick:o,children:`Close`})}):(0,_.jsxs)(`div`,{className:`mt-6 flex items-center justify-between gap-3`,children:[(0,_.jsx)(`button`,{type:`button`,className:v,disabled:i,onClick:o,children:`Cancel sign-in`}),u&&!d&&(0,_.jsx)(`button`,{type:`submit`,form:l,className:y,disabled:i||u.input.type!==`text`&&!n.trim(),children:`Continue`})]})]})}function T({provider:e,onCancel:t,onConfirm:n}){let r=(0,g.useRef)(null),i=(0,g.useId)();return(0,g.useEffect)(()=>{let e=r.current;return e.showModal(),()=>e.close()},[]),(0,_.jsxs)(`dialog`,{ref:r,"aria-labelledby":i,"aria-describedby":`${i}-description`,onCancel:e=>{e.preventDefault(),t()},className:`m-auto w-[calc(100%_-_2rem)] max-w-md rounded-2xl border border-zinc-800 bg-[#0d0d10] p-6 text-zinc-100 shadow-2xl backdrop:bg-black/70 backdrop:backdrop-blur-sm`,children:[(0,_.jsxs)(`h3`,{id:i,className:`text-lg font-semibold text-white`,children:[`Disconnect `,e.name,`?`]}),(0,_.jsx)(`p`,{id:`${i}-description`,className:`mt-2 text-sm leading-6 text-zinc-400`,children:`Agents using it will need another model or a reconnection.`}),(0,_.jsxs)(`div`,{className:`mt-6 flex flex-col-reverse gap-3 sm:flex-row sm:justify-end`,children:[(0,_.jsx)(`button`,{type:`button`,autoFocus:!0,onClick:t,className:`cursor-pointer rounded-full border border-zinc-800 px-4 py-2 text-sm font-medium text-zinc-300 hover:border-zinc-700 hover:text-white`,children:`Cancel`}),(0,_.jsx)(`button`,{type:`button`,onClick:n,className:`cursor-pointer rounded-full bg-red-600 px-4 py-2 text-sm font-medium text-white hover:bg-red-500`,children:`Disconnect`})]})]})}function E({url:e,children:t}){try{if(![`http:`,`https:`].includes(new URL(e).protocol))return null}catch{return null}return(0,_.jsx)(`a`,{className:`cursor-pointer break-all text-violet-300 underline`,href:e,target:`_blank`,rel:`noopener noreferrer`,children:t})}function D({code:e,url:t}){let[n,r]=(0,g.useState)(`idle`);async function i(){if(n!==`copying`){r(`copying`);try{await navigator.clipboard.writeText(e),r(`copied`)}catch{r(`failed`)}}}return(0,_.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,_.jsx)(E,{url:t,children:`Open device authorization`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,_.jsxs)(`p`,{children:[`Code: `,(0,_.jsx)(`strong`,{className:`select-all font-mono`,children:e})]}),(0,_.jsx)(`button`,{type:`button`,className:v,disabled:n===`copying`,onClick:()=>{i()},children:`Copy to clipboard`})]}),(0,_.jsx)(`p`,{role:`status`,className:n===`failed`?`text-amber-300`:`text-emerald-400`,children:n===`copied`?`Copied!`:n===`failed`?`Unable to copy. Select and copy the code above.`:n===`copying`?`Copying…`:``})]})}function O({event:e}){return e.type===`auth_url`?(0,_.jsxs)(`p`,{className:`text-sm`,children:[(0,_.jsx)(E,{url:e.url,children:`Open provider sign-in`}),e.instructions&&(0,_.jsx)(`span`,{className:`mt-1 block text-zinc-400`,children:e.instructions})]}):e.type===`device_code`?(0,_.jsx)(D,{code:e.userCode,url:e.verificationUri},e.userCode):(0,_.jsxs)(`div`,{className:`text-sm text-zinc-400`,children:[(0,_.jsx)(`p`,{children:e.message}),e.type===`info`&&e.links?.map((e,t)=>(0,_.jsx)(E,{url:e.url,children:e.label??e.url},t))]})}var k=C;export{k as component};
|