@xopcai/xopc 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agents-MbH57-L9.js → agents-BcLv59-r.js} +2 -2
- package/dist/gateway/static/root/assets/{agents-MbH57-L9.js.map → agents-BcLv59-r.js.map} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-3i3DvI7i.js → apps-page-Bl-yxbQo.js} +2 -2
- package/dist/gateway/static/root/assets/{apps-page-3i3DvI7i.js.map → apps-page-Bl-yxbQo.js.map} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-CcuSzoB6.js → channels-settings-BGueHxMv.js} +2 -2
- package/dist/gateway/static/root/assets/{channels-settings-CcuSzoB6.js.map → channels-settings-BGueHxMv.js.map} +1 -1
- package/dist/gateway/static/root/assets/{cron-page-Be1h9Yub.js → cron-page-DsVZzPqv.js} +2 -2
- package/dist/gateway/static/root/assets/{cron-page-Be1h9Yub.js.map → cron-page-DsVZzPqv.js.map} +1 -1
- package/dist/gateway/static/root/assets/{cron-utils-CR97EvZS.js → cron-utils-zbRs2yND.js} +2 -2
- package/dist/gateway/static/root/assets/{cron-utils-CR97EvZS.js.map → cron-utils-zbRs2yND.js.map} +1 -1
- package/dist/gateway/static/root/assets/{dist-r_Gy-XJv.js → dist-CDA7gR_M.js} +2 -2
- package/dist/gateway/static/root/assets/{dist-r_Gy-XJv.js.map → dist-CDA7gR_M.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-QfYEYruq.js → extension-debug-page-CDLp4DAs.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-debug-page-QfYEYruq.js.map → extension-debug-page-CDLp4DAs.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-4FW-BmKG.js → extension-page-DwSCjzHO.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-page-4FW-BmKG.js.map → extension-page-DwSCjzHO.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-E_Wq9LL8.js → extension-settings-page-Rdmxe24_.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-settings-page-E_Wq9LL8.js.map → extension-settings-page-Rdmxe24_.js.map} +1 -1
- package/dist/gateway/static/root/assets/index-DG8WvMbu.js +150 -0
- package/dist/gateway/static/root/assets/index-DG8WvMbu.js.map +1 -0
- package/dist/gateway/static/root/assets/{logs-page-DFhTU-kG.js → logs-page-ChJ0nsPh.js} +2 -2
- package/dist/gateway/static/root/assets/{logs-page-DFhTU-kG.js.map → logs-page-ChJ0nsPh.js.map} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-wmnnIj6Z.js → sessions-page-Cle4fPla.js} +2 -2
- package/dist/gateway/static/root/assets/{sessions-page-wmnnIj6Z.js.map → sessions-page-Cle4fPla.js.map} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BTmUXY4s.js → settings-page-Dyo2NYdy.js} +2 -2
- package/dist/gateway/static/root/assets/{settings-page-BTmUXY4s.js.map → settings-page-Dyo2NYdy.js.map} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-D-fRbJG0.js → skills-page-B-smhcB2.js} +2 -2
- package/dist/gateway/static/root/assets/{skills-page-D-fRbJG0.js.map → skills-page-B-smhcB2.js.map} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/index-CcQtNJKo.js +0 -150
- package/dist/gateway/static/root/assets/index-CcQtNJKo.js.map +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "telegram",
|
|
3
3
|
"name": "Telegram Channel",
|
|
4
4
|
"description": "Bundled Telegram Bot channel (private workspace sources; ships inside @xopcai/xopc dist/)",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.22",
|
|
6
6
|
"kind": "channel",
|
|
7
7
|
"main": "src/index.ts",
|
|
8
8
|
"channels": ["telegram"],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{i as t,t as n}from"./vendor-react-DbimaAId.js";import{r}from"./vendor-swr-Dp4nzp5h.js";import{$ as i,$t as a,B as o,Bn as s,Bt as c,C as l,Cn as u,Er as d,Ft as f,Gt as p,H as m,In as h,It as g,Kn as _,Kt as v,Lt as y,Mt as ee,Nn as b,On as te,Ot as x,Pn as ne,Pt as re,Qn as S,Qt as ie,Rn as C,Rt as w,Tr as ae,V as T,Vt as E,Wn as D,Wt as O,Xt as oe,Yt as se,Zt as k,ar as ce,at as A,b as j,br as le,c as ue,cr as M,ct as de,dn as fe,dt as pe,er as me,et as N,fn as P,fr as F,ft as he,gr as ge,hn as I,hr as L,in as _e,it as ve,jt as ye,kn as be,ln as xe,lt as Se,mn as Ce,nn as we,nr as Te,o as Ee,ot as De,pr as Oe,qt as ke,r as R,rn as z,rt as B,s as Ae,st as je,tr as Me,tt as Ne,un as Pe,ut as Fe,wr as Ie,x as Le,xr as Re,y as ze,yn as Be,z as Ve,zt as He}from"./index-CcQtNJKo.js";import{C as Ue,a as We,d as Ge,p as Ke,v as qe,y as Je}from"./cron-utils-CR97EvZS.js";var V=e(t(),1);function Ye(e){return{...e,skills:e.skills??{defaults:[]},tools:e.tools??{defaultsDisable:[],entryDisable:[],effectiveDisable:[]}}}async function Xe(){let e=(await A(B(`/api/agents`))).payload;if(!e?.defaultId||!Array.isArray(e.agents))throw Error(`Invalid /api/agents response`);let t=Array.isArray(e.builtinToolIds)?e.builtinToolIds:[];return{defaultId:e.defaultId,agents:e.agents.map(Ye),builtinToolIds:t}}async function Ze(e){let t=await A(B(`/api/agents`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),n=typeof t.payload?.agentId==`string`?t.payload.agentId.trim():``,r=t.payload?.agents;if(!n||!r?.defaultId||!Array.isArray(r.agents))throw Error(`Invalid create agent response`);return{createdAgentId:n,defaultId:r.defaultId,agents:r.agents.map(Ye),builtinToolIds:Array.isArray(r.builtinToolIds)?r.builtinToolIds:[]}}async function Qe(e,t){let n=(await A(B(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).payload;if(!n?.defaultId||!Array.isArray(n.agents))throw Error(`Invalid update agent response`);return{defaultId:n.defaultId,agents:n.agents.map(Ye),builtinToolIds:Array.isArray(n.builtinToolIds)?n.builtinToolIds:[]}}async function $e(e,t){let n=(await A(B(`/api/agents/${encodeURIComponent(e)}${t?`?purge=true`:``}`),{method:`DELETE`})).payload?.agents;if(!n?.defaultId||!Array.isArray(n.agents))throw Error(`Invalid delete agent response`);return{defaultId:n.defaultId,agents:n.agents.map(Ye),builtinToolIds:Array.isArray(n.builtinToolIds)?n.builtinToolIds:[]}}function et(e){if(!e||typeof e!=`object`||!(`bindings`in e))return[];let t=e.bindings;return Array.isArray(t)?t:[]}async function tt(e){await A(B(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({bindings:e})}),N()}async function nt(){let e=(await A(B(`/api/skills`))).payload?.catalog;return Array.isArray(e)?e:[]}async function rt(e){let t=(await A(B(`/api/agents/${encodeURIComponent(e)}/files`))).payload;if(!t?.files||!t.bootstrapDir)throw Error(`Invalid files list response`);return t}async function it(e,t){let n=(await A(B(`/api/agents/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`))).payload?.content;if(typeof n!=`string`)throw Error(`Invalid file content response`);return n}async function at(e,t,n){await A(B(`/api/agents/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})})}var ot=`main`,st=/^[a-z0-9][a-z0-9_-]{0,63}$/i,ct=/[^a-z0-9_-]+/g,H=/^-+/,lt=/-+$/,ut=/^[a-z0-9][a-z0-9_-]{0,63}$/,dt=new Set([`con`,`prn`,`aux`,`nul`,`com1`,`com2`,`com3`,`com4`,`com5`,`com6`,`com7`,`com8`,`com9`,`lpt1`,`lpt2`,`lpt3`,`lpt4`,`lpt5`,`lpt6`,`lpt7`,`lpt8`,`lpt9`]);function ft(e){let t=e.trim();if(!t)return ot;let n=t.toLowerCase();return st.test(t)?n:n.replace(ct,`-`).replace(H,``).replace(lt,``).slice(0,64)||ot}function pt(e,t){let n=e?.trim();if(n){let e=n.toLowerCase();return ut.test(e)?e===ot?{ok:!1,error:`"${ot}" is reserved`}:dt.has(e)?{ok:!1,error:`Agent id "${e}" is reserved (Windows device name).`}:{ok:!0,agentId:e}:{ok:!1,error:`Invalid agent id: use 1–64 characters; letters, digits, underscores, and hyphens only; start with a letter or digit.`}}let r=ft(t.trim());return r===ot?{ok:!1,error:`Display name cannot produce a valid agent folder id. Set an explicit Agent id (letters, digits, underscores, hyphens only).`}:dt.has(r)?{ok:!1,error:`That display name resolves to "${r}", which is reserved. Use a different display name or set an explicit Agent id.`}:ut.test(r)?{ok:!0,agentId:r}:{ok:!1,error:`Could not derive a folder-safe agent id from the display name. Set an explicit Agent id (letters, digits, underscores, hyphens only).`}}function mt(e){let t=e.trim();return t?`~/.xopc/workspace/${ft(t)}`:``}var U=n(),ht=[{id:`overview`,labelKey:`navIdentity`,icon:se},{id:`profile`,labelKey:`navProfile`,icon:ce},{id:`tools`,labelKey:`navTools`,icon:ke},{id:`skills`,labelKey:`navSkills`,icon:P},{id:`files`,labelKey:`navCoreFiles`,icon:D}],gt=[{id:`channels`,labelKey:`tabChannels`,icon:I},{id:`cron`,labelKey:`tabCron`,icon:Te}];function _t(e){let{a:t,panel:n,onPanelChange:r}=e,i=(e,t,i)=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:O(`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors`,n===e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,U.jsx)(i,{className:`size-4 shrink-0 opacity-90`,strokeWidth:2,"aria-hidden":!0}),(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:t})]},e);return(0,U.jsxs)(`nav`,{className:`flex w-full flex-col gap-1`,"aria-label":t.editorNavAria,children:[(0,U.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:ht.map(({id:e,labelKey:n,icon:r})=>i(e,t[n],r))}),(0,U.jsx)(`p`,{className:`mt-4 px-3 text-[10px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.navAdvanced}),(0,U.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:gt.map(({id:e,labelKey:n,icon:r})=>i(e,t[n],r))})]})}function vt(e){let{open:t,onOpenChange:n,a:r,title:i,subtitle:a,panel:o,onPanelChange:s,onFooterSave:c,footerSaveDisabled:l,footerSavedFlash:u,busy:d,children:f}=e;return(0,U.jsx)(pe,{open:t,onOpenChange:n,children:(0,U.jsxs)(Fe,{children:[(0,U.jsx)(Se,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,U.jsxs)(je,{className:O(`xopc-dialog-content fixed z-[60] flex flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,`inset-4 h-[calc(100dvh-2rem)] max-h-[calc(100dvh-2rem)] min-h-0`,`sm:inset-auto sm:left-1/2 sm:top-1/2 sm:h-[min(88vh,48rem)] sm:max-h-[min(88vh,48rem)] sm:min-h-[32rem] sm:w-[min(100%-2rem,58rem)] sm:-translate-x-1/2 sm:-translate-y-1/2`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-edge-subtle px-4 pb-3 pt-4 dark:border-edge`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,U.jsx)(he,{className:`text-base font-semibold leading-snug text-fg`,children:i}),(0,U.jsx)(de,{className:`mt-1 font-mono text-xs text-fg-muted`,children:a})]}),(0,U.jsx)(De,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-lg p-1.5 text-fg-muted hover:bg-surface-base hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":r.closeDialogAria,children:(0,U.jsx)(v,{className:`size-4`,"aria-hidden":!0})})})]}),(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row sm:overflow-hidden`,children:[(0,U.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle px-4 py-3 dark:border-edge sm:flex sm:w-56 sm:shrink-0 sm:flex-col sm:overflow-y-auto sm:border-b-0 sm:border-r sm:px-0 sm:py-4 sm:pl-4 sm:pr-3`,children:(0,U.jsx)(_t,{a:r,panel:o,onPanelChange:s})}),(0,U.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 sm:pl-2 sm:pr-5`,children:f}),(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1 border-t border-edge-subtle px-4 py-3 dark:border-edge sm:flex-row sm:items-center sm:justify-end sm:gap-3`,children:[u?(0,U.jsxs)(`p`,{className:`order-2 text-center text-xs font-medium text-green-600 sm:order-1 sm:mr-auto sm:text-left dark:text-green-400`,children:[`✓ `,r.personaSaved]}):l?(0,U.jsx)(`p`,{className:`order-2 text-center text-xs text-fg-muted sm:order-1 sm:mr-auto sm:text-left`,children:r.footerSaveNotApplicable}):null,(0,U.jsx)(E,{type:`button`,className:`order-1 w-full sm:order-2 sm:w-auto`,disabled:d||l,onClick:()=>void c(),children:r.save})]})]})]})]})]})})}function yt(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>{let t=(e.name??``).toLowerCase(),r=e.id.toLowerCase(),i=e.workspace.toLowerCase(),a=(e.description??``).toLowerCase();return t.includes(n)||r.includes(n)||i.includes(n)||a.includes(n)}):e}function bt(e){let{a:t,busy:n,onNewAgent:r}=e;return(0,U.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>r(),className:O(`flex h-full min-h-[7.5rem] w-full flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed border-edge-subtle bg-surface-panel/40 px-4 py-6 text-sm font-medium text-fg-muted transition-colors`,`hover:border-accent/50 hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,U.jsx)(Ce,{className:`size-8 shrink-0 opacity-80`,strokeWidth:1.75,"aria-hidden":!0}),(0,U.jsx)(`span`,{children:t.listNewAgentCard})]})}function xt(e){let{a:t,agents:n,searchQuery:r,onOpenAgent:i,onChatWithAgent:a,onNewAgent:o,busy:s}=e,c=yt(n,r),l=n.length>0&&c.length===0&&r.trim().length>0;return n.length===0?(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.listNoAgentsYet}),(0,U.jsx)(`div`,{className:`max-w-sm`,children:(0,U.jsx)(bt,{a:t,busy:s,onNewAgent:o})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[l?(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.listEmpty}):null,(0,U.jsxs)(`ul`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,role:`list`,children:[(0,U.jsx)(`li`,{className:`h-full min-h-0`,children:(0,U.jsx)(bt,{a:t,busy:s,onNewAgent:o})}),c.map(e=>{let n=e.name?.trim()?e.name.trim():e.id,r=e.id,o=e.description?.trim()??``;return(0,U.jsx)(`li`,{className:`h-full min-h-0`,children:(0,U.jsxs)(`div`,{className:O(`flex h-full min-h-0 flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-sm transition-colors`,`hover:border-edge`),children:[(0,U.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>i(e.id),className:O(`flex shrink-0 w-full flex-col gap-2 text-left transition-colors`,`rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,U.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,U.jsx)(`span`,{className:`flex size-11 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,"aria-hidden":!0,children:(0,U.jsx)(L,{className:`size-6`,strokeWidth:1.75})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,U.jsx)(`span`,{className:`truncate font-semibold text-fg`,children:n}),e.isDefault?(0,U.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-base px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:t.defaultBadge}):null]}),(0,U.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-xs text-fg-muted`,title:r,children:r})]})]}),(0,U.jsx)(`p`,{className:O(`line-clamp-1 min-h-[1.3125rem] text-xs leading-relaxed`,o?`text-fg`:`text-fg-muted/25`),title:o||void 0,children:o||`\xA0`})]}),(0,U.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>a(e.id),className:O(`flex w-full shrink-0 items-center justify-center gap-2 rounded-full px-4 py-2.5 text-sm font-semibold`,`bg-accent-soft text-accent-fg transition-colors`,`hover:bg-accent/15`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,U.jsx)(u,{className:`size-4 shrink-0`,strokeWidth:2,"aria-hidden":!0}),t.listChatWithAgent]})]})},e.id)})]})]})}function St(e){let{a:t}=e;return(0,U.jsx)(`header`,{className:`flex flex-col gap-4`,children:(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:t.title}),(0,U.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.subtitle})]})})}function W(){return O(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,He,`dark:border-edge`)}function Ct(e,t,n){let r=e.agentId?.trim().toLowerCase();return r?r===t.toLowerCase():t.toLowerCase()===n.toLowerCase()}function wt(e){return[e.channel,e.accountId,e.peerKind,e.peerId].filter(e=>typeof e==`string`&&e.length>0).join(` · `)||e.channel}function Tt(e,t,n,r){let i=e.trim(),a=t.trim();if(a)return{channel:i,peerId:a};if(n!=null){let e=r[n];if(!e)return{channel:i};let t={channel:i};e.accountId?.trim()&&(t.accountId=e.accountId.trim()),e.peerKind?.trim()&&(t.peerKind=e.peerKind.trim());let a=e.peerId?.trim()||e.chatId?.trim();return a&&(t.peerId=a),t}return{channel:i}}function Et(e){let{open:t,onOpenChange:n,a:r,chat:i,busy:a,modalError:o,createDisplayName:s,setCreateDisplayName:c,createAgentId:l,setCreateAgentId:u,createDescription:d,setCreateDescription:f,createWorkspace:p,setCreateWorkspace:m,createModel:h,setCreateModel:g,onCreate:_,onSuggestWorkspace:y}=e;return(0,U.jsx)(pe,{open:t,onOpenChange:n,children:(0,U.jsxs)(Fe,{children:[(0,U.jsx)(Se,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,U.jsxs)(je,{className:O(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,640px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,U.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,U.jsx)(he,{className:`text-base font-semibold text-fg`,children:r.addAgent}),(0,U.jsx)(de,{className:`mt-0.5 text-xs text-fg-muted`,children:r.addAgentHint})]}),(0,U.jsx)(De,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-lg p-1.5 text-fg-muted hover:bg-surface-base hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":r.closeDialogAria,children:(0,U.jsx)(v,{className:`size-4`,"aria-hidden":!0})})})]}),(0,U.jsxs)(`form`,{className:`grid gap-3`,onSubmit:_,children:[o?(0,U.jsx)(`div`,{role:`alert`,className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:o}):null,(0,U.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:r.newAgentLabel}),(0,U.jsx)(`input`,{className:W(),value:s,onChange:e=>c(e.target.value),onBlur:()=>y(),required:!0,autoComplete:`off`})]}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:r.newAgentIdOptional}),(0,U.jsx)(`input`,{className:O(W(),`font-mono text-xs`),value:l,onChange:e=>u(e.target.value),onBlur:()=>y(),placeholder:r.newAgentIdPlaceholder,autoComplete:`off`,spellCheck:!1,maxLength:64,pattern:`[A-Za-z0-9][A-Za-z0-9_-]{0,63}`,title:r.newAgentIdRules}),(0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:r.newAgentIdRules})]}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:r.agentDescription}),(0,U.jsx)(`textarea`,{className:O(W(),`min-h-[4.5rem] resize-y font-sans text-sm leading-relaxed`),value:d,onChange:e=>f(e.target.value),placeholder:r.agentDescriptionPlaceholder,maxLength:4e3,rows:3,spellCheck:!0})]}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:r.newWorkspace}),(0,U.jsx)(`input`,{className:O(W(),`font-mono text-xs`),value:p,onChange:e=>m(e.target.value),required:!0,autoComplete:`off`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:r.newModelOptional}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[(0,U.jsx)(R,{className:`min-w-0 flex-1`,popoverContentClassName:`z-[70]`,value:h,disabled:a,placeholder:i.modelPlaceholder,searchPlaceholder:i.modelSearchPlaceholder,noMatches:i.modelNoMatches,onChange:e=>g(e)}),h.trim()?(0,U.jsx)(E,{type:`button`,variant:`secondary`,className:`shrink-0`,disabled:a,onClick:()=>g(``),children:r.modelClear}):null]})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[(0,U.jsx)(De,{asChild:!0,children:(0,U.jsx)(E,{type:`button`,variant:`secondary`,disabled:a,children:r.createModalCancel})}),(0,U.jsxs)(E,{type:`submit`,disabled:a,children:[(0,U.jsx)(oe,{className:`mr-1 size-4`,"aria-hidden":!0}),r.create]})]})]})]})]})})}function Dt(){return`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`}function G({children:e,className:t}){return(0,U.jsx)(`section`,{className:O(Dt(),t),children:e})}function K({icon:e,title:t,subtitle:n,trailing:r,className:i}){return(0,U.jsxs)(`div`,{className:O(`mb-5 flex items-start gap-3`,i),children:[(0,U.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted dark:bg-surface-hover/70`,"aria-hidden":!0,children:(0,U.jsx)(e,{className:`size-4`,strokeWidth:1.75})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t}),(0,U.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n})]}),r?(0,U.jsx)(`div`,{className:`shrink-0`,children:r}):null]})}var Ot=O(w,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`);function kt(e){let{a:t,busy:n,bindingsLoading:r,agentBindings:i,onRemoveBinding:a,onAddBinding:o,channelStatuses:s,channelsStatusLoading:c,useManualChannel:l,newBindChannel:u,setNewBindChannel:d,bindSessionChats:f,sessionsLoading:p,newBindSessionIdx:m,setNewBindSessionIdx:h,newBindCustomPeer:g,setNewBindCustomPeer:_,onRefreshSessions:v,lastActiveLabels:y,selectRecipient:ee}=e,b=!c&&(l||s.length>0);return(0,U.jsxs)(G,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,U.jsx)(K,{className:`shrink-0`,icon:te,title:t.channelsTitle,subtitle:t.channelsHint}),r?(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsLoading}):i.length===0?(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsNone}):(0,U.jsx)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:i.map((e,r)=>(0,U.jsxs)(`li`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs`,children:wt(e.match)}),(0,U.jsx)(E,{type:`button`,variant:`secondary`,disabled:n,onClick:()=>void a(e),children:t.removeBinding})]},`${e.match.channel}-${r}`))}),(0,U.jsxs)(`form`,{className:`mt-4 flex flex-col gap-3`,onSubmit:o,children:[c?(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsLoadingChannels}):l?(0,U.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:t.channelLabel}),(0,U.jsx)(`input`,{className:W(),value:u,onChange:e=>d(e.target.value),placeholder:`telegram`,autoComplete:`off`}),(0,U.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsManualChannelHint})]}):(0,U.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:t.channelLabel}),(0,U.jsx)(`select`,{className:O(W(),`py-2`),value:u,onChange:e=>{d(e.target.value),h(null),_(``)},children:s.map(e=>(0,U.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:t.channelsDisabledSuffix]},e.name))})]}),b&&u.trim()?(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-3 text-sm`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:t.channelsSessionLabel}),(0,U.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,disabled:n||p||!u.trim(),title:t.channelsRefreshSessionsHint,onClick:()=>v(),children:[(0,U.jsx)(fe,{className:O(`size-3.5`,p&&`animate-spin`),strokeWidth:1.75}),t.channelsRefreshSessions]})]}),p&&f.length===0?(0,U.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsLoadingSessions}):null,(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:t.channelsPeerFromSessions}),(0,U.jsxs)(`select`,{className:O(W(),`py-2`),value:m==null?``:String(m),disabled:n||!u.trim()||!!g.trim(),onChange:e=>{let t=e.target.value;h(t===``?null:Number(t))},children:[(0,U.jsx)(`option`,{value:``,children:t.channelsPeerAny}),f.map((e,t)=>(0,U.jsx)(`option`,{value:String(t),children:We(e,y)},`${e.channel}-${e.chatId}-${t}`))]})]}),f.length===0&&u.trim()&&!p?(0,U.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsNoSessionsHint}):null,(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:t.peerIdLabel}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,U.jsx)(`input`,{type:`text`,className:O(W(),`min-w-0 w-full sm:flex-1`),value:g,onChange:e=>{_(e.target.value),e.target.value.trim()&&h(null)},placeholder:t.channelsCustomPeerPlaceholder,autoComplete:`off`}),(0,U.jsxs)(`select`,{className:Ot,value:g,onChange:e=>{let t=e.target.value;_(t||``),h(null)},children:[(0,U.jsx)(`option`,{value:``,children:ee}),f.map(e=>(0,U.jsx)(`option`,{value:e.chatId,children:We(e,y)},`${e.channel}-${e.chatId}`))]})]}),(0,U.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsCustomPeerHint})]})]}):null,(0,U.jsx)(`div`,{children:(0,U.jsx)(E,{type:`submit`,disabled:n||!u.trim()||c,children:t.addBinding})})]})]})}function At(e){let{a:t,data:n,busy:r,cronLoading:i,agentCronJobs:a,onSetCronJobAgent:o}=e;return(0,U.jsxs)(G,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,U.jsx)(K,{className:`shrink-0`,icon:le,title:t.cronTitle,subtitle:t.cronHint}),i?(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.cronLoading}):a.length===0?(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.cronNone}):(0,U.jsx)(`div`,{className:`overflow-x-auto`,children:(0,U.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[(0,U.jsx)(`thead`,{children:(0,U.jsxs)(`tr`,{className:`border-b border-edge text-fg-muted`,children:[(0,U.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColSchedule}),(0,U.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColMessage}),(0,U.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColSession}),(0,U.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColAgent})]})}),(0,U.jsx)(`tbody`,{children:a.map(e=>{let i=!e.agentId?.trim(),a=i?``:e.agentId.trim().toLowerCase();return(0,U.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,U.jsx)(`td`,{className:`py-2 pr-3 font-mono text-xs`,children:e.schedule}),(0,U.jsx)(`td`,{className:`max-w-[12rem] truncate py-2 pr-3 text-xs`,title:Ge(e),children:Ge(e)}),(0,U.jsx)(`td`,{className:`py-2 pr-3 text-xs`,children:e.sessionTarget??`main`}),(0,U.jsx)(`td`,{className:`py-2 pr-3`,children:(0,U.jsxs)(`select`,{className:O(W(),`min-w-[8rem] py-1 text-xs`),value:a,disabled:r||e.sessionTarget!==`isolated`,onChange:t=>void o(e,t.target.value),children:[(0,U.jsx)(`option`,{value:``,children:i?t.cronAgentDefault:t.cronAgentClear}),n.agents.map(e=>(0,U.jsx)(`option`,{value:e.id,children:e.id},e.id))]})})]},e.id)})})]})})]})}function jt(e){let{a:t,filesLoading:n,files:r,activeFile:i,setActiveFile:a,bootstrapViewMode:o,setBootstrapViewMode:s,fileDraft:c,setFileDraft:l,fileSaving:u,bootstrapFileLoading:d,bootstrapEditorNonce:f}=e,p=ye(e=>e.resolved===`dark`);return(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[(0,U.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesHint}),n?(0,U.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesLoading}):r?(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,U.jsx)(`nav`,{className:`flex shrink-0 flex-row flex-wrap gap-x-0.5 gap-y-0 border-b border-edge-subtle`,"aria-label":t.tabFiles,children:r.files.map(e=>(0,U.jsxs)(`button`,{type:`button`,className:O(`-mb-px shrink-0 border-b-2 border-transparent px-3 py-2 text-left font-mono text-xs whitespace-nowrap transition-colors`,i===e.name?`border-accent text-fg`:`text-fg-muted hover:border-edge-subtle hover:text-fg`,e.missing&&`opacity-60`),onClick:()=>a(e.name),children:[e.name,e.missing?` (${t.missing})`:``]},e.name))}),(0,U.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2 overflow-hidden`,children:i?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-panel p-0.5`,role:`group`,"aria-label":t.filesBootstrapEdit,children:[(0,U.jsxs)(`button`,{type:`button`,className:O(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,o===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>s(`edit`),children:[(0,U.jsx)(we,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t.filesBootstrapEdit]}),(0,U.jsxs)(`button`,{type:`button`,className:O(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,o===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>s(`preview`),children:[(0,U.jsx)(_,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t.filesBootstrapPreview]})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[u?(0,U.jsx)(`span`,{children:t.filesSavingStatus}):null,(0,U.jsx)(`span`,{children:t.filesAutoSaveHint})]})]}),o===`edit`?(0,U.jsx)(`div`,{className:O(W(),`flex min-h-0 flex-1 flex-col overflow-hidden p-0`,d&&`pointer-events-none opacity-60`),children:(0,U.jsx)(Le,{initialContent:c,onChange:l,isDark:p,className:`min-h-0 flex-1`},`${i??`file`}-${f}`)}):(0,U.jsx)(`div`,{className:O(W(),`min-h-0 flex-1 overflow-y-auto text-sm`,d&&`pointer-events-none opacity-60`),children:(0,U.jsx)(j,{content:c,className:`text-sm`})})]}):(0,U.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.pickFile})})]}):(0,U.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesEmpty})]})}var Mt={name:``,creature:``,emoji:``,avatar:``};function Nt(e){let t={...Mt};if(!e.trim())return t;let n={name:`name`,creature:`creature`,emoji:`emoji`,avatar:`avatar`};for(let r of e.split(`
|
|
1
|
+
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{i as t,t as n}from"./vendor-react-DbimaAId.js";import{r}from"./vendor-swr-Dp4nzp5h.js";import{$ as i,$t as a,B as o,Bn as s,Bt as c,C as l,Cn as u,Er as d,Ft as f,Gt as p,H as m,In as h,It as g,Kn as _,Kt as v,Lt as y,Mt as ee,Nn as b,On as te,Ot as x,Pn as ne,Pt as re,Qn as S,Qt as ie,Rn as C,Rt as w,Tr as ae,V as T,Vt as E,Wn as D,Wt as O,Xt as oe,Yt as se,Zt as k,ar as ce,at as A,b as j,br as le,c as ue,cr as M,ct as de,dn as fe,dt as pe,er as me,et as N,fn as P,fr as F,ft as he,gr as ge,hn as I,hr as L,in as _e,it as ve,jt as ye,kn as be,ln as xe,lt as Se,mn as Ce,nn as we,nr as Te,o as Ee,ot as De,pr as Oe,qt as ke,r as R,rn as z,rt as B,s as Ae,st as je,tr as Me,tt as Ne,un as Pe,ut as Fe,wr as Ie,x as Le,xr as Re,y as ze,yn as Be,z as Ve,zt as He}from"./index-DG8WvMbu.js";import{C as Ue,a as We,d as Ge,p as Ke,v as qe,y as Je}from"./cron-utils-zbRs2yND.js";var V=e(t(),1);function Ye(e){return{...e,skills:e.skills??{defaults:[]},tools:e.tools??{defaultsDisable:[],entryDisable:[],effectiveDisable:[]}}}async function Xe(){let e=(await A(B(`/api/agents`))).payload;if(!e?.defaultId||!Array.isArray(e.agents))throw Error(`Invalid /api/agents response`);let t=Array.isArray(e.builtinToolIds)?e.builtinToolIds:[];return{defaultId:e.defaultId,agents:e.agents.map(Ye),builtinToolIds:t}}async function Ze(e){let t=await A(B(`/api/agents`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),n=typeof t.payload?.agentId==`string`?t.payload.agentId.trim():``,r=t.payload?.agents;if(!n||!r?.defaultId||!Array.isArray(r.agents))throw Error(`Invalid create agent response`);return{createdAgentId:n,defaultId:r.defaultId,agents:r.agents.map(Ye),builtinToolIds:Array.isArray(r.builtinToolIds)?r.builtinToolIds:[]}}async function Qe(e,t){let n=(await A(B(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).payload;if(!n?.defaultId||!Array.isArray(n.agents))throw Error(`Invalid update agent response`);return{defaultId:n.defaultId,agents:n.agents.map(Ye),builtinToolIds:Array.isArray(n.builtinToolIds)?n.builtinToolIds:[]}}async function $e(e,t){let n=(await A(B(`/api/agents/${encodeURIComponent(e)}${t?`?purge=true`:``}`),{method:`DELETE`})).payload?.agents;if(!n?.defaultId||!Array.isArray(n.agents))throw Error(`Invalid delete agent response`);return{defaultId:n.defaultId,agents:n.agents.map(Ye),builtinToolIds:Array.isArray(n.builtinToolIds)?n.builtinToolIds:[]}}function et(e){if(!e||typeof e!=`object`||!(`bindings`in e))return[];let t=e.bindings;return Array.isArray(t)?t:[]}async function tt(e){await A(B(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({bindings:e})}),N()}async function nt(){let e=(await A(B(`/api/skills`))).payload?.catalog;return Array.isArray(e)?e:[]}async function rt(e){let t=(await A(B(`/api/agents/${encodeURIComponent(e)}/files`))).payload;if(!t?.files||!t.bootstrapDir)throw Error(`Invalid files list response`);return t}async function it(e,t){let n=(await A(B(`/api/agents/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`))).payload?.content;if(typeof n!=`string`)throw Error(`Invalid file content response`);return n}async function at(e,t,n){await A(B(`/api/agents/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})})}var ot=`main`,st=/^[a-z0-9][a-z0-9_-]{0,63}$/i,ct=/[^a-z0-9_-]+/g,H=/^-+/,lt=/-+$/,ut=/^[a-z0-9][a-z0-9_-]{0,63}$/,dt=new Set([`con`,`prn`,`aux`,`nul`,`com1`,`com2`,`com3`,`com4`,`com5`,`com6`,`com7`,`com8`,`com9`,`lpt1`,`lpt2`,`lpt3`,`lpt4`,`lpt5`,`lpt6`,`lpt7`,`lpt8`,`lpt9`]);function ft(e){let t=e.trim();if(!t)return ot;let n=t.toLowerCase();return st.test(t)?n:n.replace(ct,`-`).replace(H,``).replace(lt,``).slice(0,64)||ot}function pt(e,t){let n=e?.trim();if(n){let e=n.toLowerCase();return ut.test(e)?e===ot?{ok:!1,error:`"${ot}" is reserved`}:dt.has(e)?{ok:!1,error:`Agent id "${e}" is reserved (Windows device name).`}:{ok:!0,agentId:e}:{ok:!1,error:`Invalid agent id: use 1–64 characters; letters, digits, underscores, and hyphens only; start with a letter or digit.`}}let r=ft(t.trim());return r===ot?{ok:!1,error:`Display name cannot produce a valid agent folder id. Set an explicit Agent id (letters, digits, underscores, hyphens only).`}:dt.has(r)?{ok:!1,error:`That display name resolves to "${r}", which is reserved. Use a different display name or set an explicit Agent id.`}:ut.test(r)?{ok:!0,agentId:r}:{ok:!1,error:`Could not derive a folder-safe agent id from the display name. Set an explicit Agent id (letters, digits, underscores, hyphens only).`}}function mt(e){let t=e.trim();return t?`~/.xopc/workspace/${ft(t)}`:``}var U=n(),ht=[{id:`overview`,labelKey:`navIdentity`,icon:se},{id:`profile`,labelKey:`navProfile`,icon:ce},{id:`tools`,labelKey:`navTools`,icon:ke},{id:`skills`,labelKey:`navSkills`,icon:P},{id:`files`,labelKey:`navCoreFiles`,icon:D}],gt=[{id:`channels`,labelKey:`tabChannels`,icon:I},{id:`cron`,labelKey:`tabCron`,icon:Te}];function _t(e){let{a:t,panel:n,onPanelChange:r}=e,i=(e,t,i)=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:O(`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors`,n===e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,U.jsx)(i,{className:`size-4 shrink-0 opacity-90`,strokeWidth:2,"aria-hidden":!0}),(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:t})]},e);return(0,U.jsxs)(`nav`,{className:`flex w-full flex-col gap-1`,"aria-label":t.editorNavAria,children:[(0,U.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:ht.map(({id:e,labelKey:n,icon:r})=>i(e,t[n],r))}),(0,U.jsx)(`p`,{className:`mt-4 px-3 text-[10px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.navAdvanced}),(0,U.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:gt.map(({id:e,labelKey:n,icon:r})=>i(e,t[n],r))})]})}function vt(e){let{open:t,onOpenChange:n,a:r,title:i,subtitle:a,panel:o,onPanelChange:s,onFooterSave:c,footerSaveDisabled:l,footerSavedFlash:u,busy:d,children:f}=e;return(0,U.jsx)(pe,{open:t,onOpenChange:n,children:(0,U.jsxs)(Fe,{children:[(0,U.jsx)(Se,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,U.jsxs)(je,{className:O(`xopc-dialog-content fixed z-[60] flex flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,`inset-4 h-[calc(100dvh-2rem)] max-h-[calc(100dvh-2rem)] min-h-0`,`sm:inset-auto sm:left-1/2 sm:top-1/2 sm:h-[min(88vh,48rem)] sm:max-h-[min(88vh,48rem)] sm:min-h-[32rem] sm:w-[min(100%-2rem,58rem)] sm:-translate-x-1/2 sm:-translate-y-1/2`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-edge-subtle px-4 pb-3 pt-4 dark:border-edge`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,U.jsx)(he,{className:`text-base font-semibold leading-snug text-fg`,children:i}),(0,U.jsx)(de,{className:`mt-1 font-mono text-xs text-fg-muted`,children:a})]}),(0,U.jsx)(De,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-lg p-1.5 text-fg-muted hover:bg-surface-base hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":r.closeDialogAria,children:(0,U.jsx)(v,{className:`size-4`,"aria-hidden":!0})})})]}),(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row sm:overflow-hidden`,children:[(0,U.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle px-4 py-3 dark:border-edge sm:flex sm:w-56 sm:shrink-0 sm:flex-col sm:overflow-y-auto sm:border-b-0 sm:border-r sm:px-0 sm:py-4 sm:pl-4 sm:pr-3`,children:(0,U.jsx)(_t,{a:r,panel:o,onPanelChange:s})}),(0,U.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 sm:pl-2 sm:pr-5`,children:f}),(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1 border-t border-edge-subtle px-4 py-3 dark:border-edge sm:flex-row sm:items-center sm:justify-end sm:gap-3`,children:[u?(0,U.jsxs)(`p`,{className:`order-2 text-center text-xs font-medium text-green-600 sm:order-1 sm:mr-auto sm:text-left dark:text-green-400`,children:[`✓ `,r.personaSaved]}):l?(0,U.jsx)(`p`,{className:`order-2 text-center text-xs text-fg-muted sm:order-1 sm:mr-auto sm:text-left`,children:r.footerSaveNotApplicable}):null,(0,U.jsx)(E,{type:`button`,className:`order-1 w-full sm:order-2 sm:w-auto`,disabled:d||l,onClick:()=>void c(),children:r.save})]})]})]})]})]})})}function yt(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>{let t=(e.name??``).toLowerCase(),r=e.id.toLowerCase(),i=e.workspace.toLowerCase(),a=(e.description??``).toLowerCase();return t.includes(n)||r.includes(n)||i.includes(n)||a.includes(n)}):e}function bt(e){let{a:t,busy:n,onNewAgent:r}=e;return(0,U.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>r(),className:O(`flex h-full min-h-[7.5rem] w-full flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed border-edge-subtle bg-surface-panel/40 px-4 py-6 text-sm font-medium text-fg-muted transition-colors`,`hover:border-accent/50 hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,U.jsx)(Ce,{className:`size-8 shrink-0 opacity-80`,strokeWidth:1.75,"aria-hidden":!0}),(0,U.jsx)(`span`,{children:t.listNewAgentCard})]})}function xt(e){let{a:t,agents:n,searchQuery:r,onOpenAgent:i,onChatWithAgent:a,onNewAgent:o,busy:s}=e,c=yt(n,r),l=n.length>0&&c.length===0&&r.trim().length>0;return n.length===0?(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.listNoAgentsYet}),(0,U.jsx)(`div`,{className:`max-w-sm`,children:(0,U.jsx)(bt,{a:t,busy:s,onNewAgent:o})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[l?(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.listEmpty}):null,(0,U.jsxs)(`ul`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,role:`list`,children:[(0,U.jsx)(`li`,{className:`h-full min-h-0`,children:(0,U.jsx)(bt,{a:t,busy:s,onNewAgent:o})}),c.map(e=>{let n=e.name?.trim()?e.name.trim():e.id,r=e.id,o=e.description?.trim()??``;return(0,U.jsx)(`li`,{className:`h-full min-h-0`,children:(0,U.jsxs)(`div`,{className:O(`flex h-full min-h-0 flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-sm transition-colors`,`hover:border-edge`),children:[(0,U.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>i(e.id),className:O(`flex shrink-0 w-full flex-col gap-2 text-left transition-colors`,`rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,U.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,U.jsx)(`span`,{className:`flex size-11 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,"aria-hidden":!0,children:(0,U.jsx)(L,{className:`size-6`,strokeWidth:1.75})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,U.jsx)(`span`,{className:`truncate font-semibold text-fg`,children:n}),e.isDefault?(0,U.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-base px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:t.defaultBadge}):null]}),(0,U.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-xs text-fg-muted`,title:r,children:r})]})]}),(0,U.jsx)(`p`,{className:O(`line-clamp-1 min-h-[1.3125rem] text-xs leading-relaxed`,o?`text-fg`:`text-fg-muted/25`),title:o||void 0,children:o||`\xA0`})]}),(0,U.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>a(e.id),className:O(`flex w-full shrink-0 items-center justify-center gap-2 rounded-full px-4 py-2.5 text-sm font-semibold`,`bg-accent-soft text-accent-fg transition-colors`,`hover:bg-accent/15`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,U.jsx)(u,{className:`size-4 shrink-0`,strokeWidth:2,"aria-hidden":!0}),t.listChatWithAgent]})]})},e.id)})]})]})}function St(e){let{a:t}=e;return(0,U.jsx)(`header`,{className:`flex flex-col gap-4`,children:(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:t.title}),(0,U.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.subtitle})]})})}function W(){return O(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,He,`dark:border-edge`)}function Ct(e,t,n){let r=e.agentId?.trim().toLowerCase();return r?r===t.toLowerCase():t.toLowerCase()===n.toLowerCase()}function wt(e){return[e.channel,e.accountId,e.peerKind,e.peerId].filter(e=>typeof e==`string`&&e.length>0).join(` · `)||e.channel}function Tt(e,t,n,r){let i=e.trim(),a=t.trim();if(a)return{channel:i,peerId:a};if(n!=null){let e=r[n];if(!e)return{channel:i};let t={channel:i};e.accountId?.trim()&&(t.accountId=e.accountId.trim()),e.peerKind?.trim()&&(t.peerKind=e.peerKind.trim());let a=e.peerId?.trim()||e.chatId?.trim();return a&&(t.peerId=a),t}return{channel:i}}function Et(e){let{open:t,onOpenChange:n,a:r,chat:i,busy:a,modalError:o,createDisplayName:s,setCreateDisplayName:c,createAgentId:l,setCreateAgentId:u,createDescription:d,setCreateDescription:f,createWorkspace:p,setCreateWorkspace:m,createModel:h,setCreateModel:g,onCreate:_,onSuggestWorkspace:y}=e;return(0,U.jsx)(pe,{open:t,onOpenChange:n,children:(0,U.jsxs)(Fe,{children:[(0,U.jsx)(Se,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,U.jsxs)(je,{className:O(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,640px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,U.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,U.jsx)(he,{className:`text-base font-semibold text-fg`,children:r.addAgent}),(0,U.jsx)(de,{className:`mt-0.5 text-xs text-fg-muted`,children:r.addAgentHint})]}),(0,U.jsx)(De,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-lg p-1.5 text-fg-muted hover:bg-surface-base hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":r.closeDialogAria,children:(0,U.jsx)(v,{className:`size-4`,"aria-hidden":!0})})})]}),(0,U.jsxs)(`form`,{className:`grid gap-3`,onSubmit:_,children:[o?(0,U.jsx)(`div`,{role:`alert`,className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:o}):null,(0,U.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:r.newAgentLabel}),(0,U.jsx)(`input`,{className:W(),value:s,onChange:e=>c(e.target.value),onBlur:()=>y(),required:!0,autoComplete:`off`})]}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:r.newAgentIdOptional}),(0,U.jsx)(`input`,{className:O(W(),`font-mono text-xs`),value:l,onChange:e=>u(e.target.value),onBlur:()=>y(),placeholder:r.newAgentIdPlaceholder,autoComplete:`off`,spellCheck:!1,maxLength:64,pattern:`[A-Za-z0-9][A-Za-z0-9_-]{0,63}`,title:r.newAgentIdRules}),(0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:r.newAgentIdRules})]}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:r.agentDescription}),(0,U.jsx)(`textarea`,{className:O(W(),`min-h-[4.5rem] resize-y font-sans text-sm leading-relaxed`),value:d,onChange:e=>f(e.target.value),placeholder:r.agentDescriptionPlaceholder,maxLength:4e3,rows:3,spellCheck:!0})]}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:r.newWorkspace}),(0,U.jsx)(`input`,{className:O(W(),`font-mono text-xs`),value:p,onChange:e=>m(e.target.value),required:!0,autoComplete:`off`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:r.newModelOptional}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[(0,U.jsx)(R,{className:`min-w-0 flex-1`,popoverContentClassName:`z-[70]`,value:h,disabled:a,placeholder:i.modelPlaceholder,searchPlaceholder:i.modelSearchPlaceholder,noMatches:i.modelNoMatches,onChange:e=>g(e)}),h.trim()?(0,U.jsx)(E,{type:`button`,variant:`secondary`,className:`shrink-0`,disabled:a,onClick:()=>g(``),children:r.modelClear}):null]})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[(0,U.jsx)(De,{asChild:!0,children:(0,U.jsx)(E,{type:`button`,variant:`secondary`,disabled:a,children:r.createModalCancel})}),(0,U.jsxs)(E,{type:`submit`,disabled:a,children:[(0,U.jsx)(oe,{className:`mr-1 size-4`,"aria-hidden":!0}),r.create]})]})]})]})]})})}function Dt(){return`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`}function G({children:e,className:t}){return(0,U.jsx)(`section`,{className:O(Dt(),t),children:e})}function K({icon:e,title:t,subtitle:n,trailing:r,className:i}){return(0,U.jsxs)(`div`,{className:O(`mb-5 flex items-start gap-3`,i),children:[(0,U.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted dark:bg-surface-hover/70`,"aria-hidden":!0,children:(0,U.jsx)(e,{className:`size-4`,strokeWidth:1.75})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t}),(0,U.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n})]}),r?(0,U.jsx)(`div`,{className:`shrink-0`,children:r}):null]})}var Ot=O(w,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`);function kt(e){let{a:t,busy:n,bindingsLoading:r,agentBindings:i,onRemoveBinding:a,onAddBinding:o,channelStatuses:s,channelsStatusLoading:c,useManualChannel:l,newBindChannel:u,setNewBindChannel:d,bindSessionChats:f,sessionsLoading:p,newBindSessionIdx:m,setNewBindSessionIdx:h,newBindCustomPeer:g,setNewBindCustomPeer:_,onRefreshSessions:v,lastActiveLabels:y,selectRecipient:ee}=e,b=!c&&(l||s.length>0);return(0,U.jsxs)(G,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,U.jsx)(K,{className:`shrink-0`,icon:te,title:t.channelsTitle,subtitle:t.channelsHint}),r?(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsLoading}):i.length===0?(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsNone}):(0,U.jsx)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:i.map((e,r)=>(0,U.jsxs)(`li`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs`,children:wt(e.match)}),(0,U.jsx)(E,{type:`button`,variant:`secondary`,disabled:n,onClick:()=>void a(e),children:t.removeBinding})]},`${e.match.channel}-${r}`))}),(0,U.jsxs)(`form`,{className:`mt-4 flex flex-col gap-3`,onSubmit:o,children:[c?(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsLoadingChannels}):l?(0,U.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:t.channelLabel}),(0,U.jsx)(`input`,{className:W(),value:u,onChange:e=>d(e.target.value),placeholder:`telegram`,autoComplete:`off`}),(0,U.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsManualChannelHint})]}):(0,U.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:t.channelLabel}),(0,U.jsx)(`select`,{className:O(W(),`py-2`),value:u,onChange:e=>{d(e.target.value),h(null),_(``)},children:s.map(e=>(0,U.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:t.channelsDisabledSuffix]},e.name))})]}),b&&u.trim()?(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-3 text-sm`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:t.channelsSessionLabel}),(0,U.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,disabled:n||p||!u.trim(),title:t.channelsRefreshSessionsHint,onClick:()=>v(),children:[(0,U.jsx)(fe,{className:O(`size-3.5`,p&&`animate-spin`),strokeWidth:1.75}),t.channelsRefreshSessions]})]}),p&&f.length===0?(0,U.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsLoadingSessions}):null,(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:t.channelsPeerFromSessions}),(0,U.jsxs)(`select`,{className:O(W(),`py-2`),value:m==null?``:String(m),disabled:n||!u.trim()||!!g.trim(),onChange:e=>{let t=e.target.value;h(t===``?null:Number(t))},children:[(0,U.jsx)(`option`,{value:``,children:t.channelsPeerAny}),f.map((e,t)=>(0,U.jsx)(`option`,{value:String(t),children:We(e,y)},`${e.channel}-${e.chatId}-${t}`))]})]}),f.length===0&&u.trim()&&!p?(0,U.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsNoSessionsHint}):null,(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-fg-muted`,children:t.peerIdLabel}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,U.jsx)(`input`,{type:`text`,className:O(W(),`min-w-0 w-full sm:flex-1`),value:g,onChange:e=>{_(e.target.value),e.target.value.trim()&&h(null)},placeholder:t.channelsCustomPeerPlaceholder,autoComplete:`off`}),(0,U.jsxs)(`select`,{className:Ot,value:g,onChange:e=>{let t=e.target.value;_(t||``),h(null)},children:[(0,U.jsx)(`option`,{value:``,children:ee}),f.map(e=>(0,U.jsx)(`option`,{value:e.chatId,children:We(e,y)},`${e.channel}-${e.chatId}`))]})]}),(0,U.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsCustomPeerHint})]})]}):null,(0,U.jsx)(`div`,{children:(0,U.jsx)(E,{type:`submit`,disabled:n||!u.trim()||c,children:t.addBinding})})]})]})}function At(e){let{a:t,data:n,busy:r,cronLoading:i,agentCronJobs:a,onSetCronJobAgent:o}=e;return(0,U.jsxs)(G,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,U.jsx)(K,{className:`shrink-0`,icon:le,title:t.cronTitle,subtitle:t.cronHint}),i?(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.cronLoading}):a.length===0?(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.cronNone}):(0,U.jsx)(`div`,{className:`overflow-x-auto`,children:(0,U.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[(0,U.jsx)(`thead`,{children:(0,U.jsxs)(`tr`,{className:`border-b border-edge text-fg-muted`,children:[(0,U.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColSchedule}),(0,U.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColMessage}),(0,U.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColSession}),(0,U.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColAgent})]})}),(0,U.jsx)(`tbody`,{children:a.map(e=>{let i=!e.agentId?.trim(),a=i?``:e.agentId.trim().toLowerCase();return(0,U.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,U.jsx)(`td`,{className:`py-2 pr-3 font-mono text-xs`,children:e.schedule}),(0,U.jsx)(`td`,{className:`max-w-[12rem] truncate py-2 pr-3 text-xs`,title:Ge(e),children:Ge(e)}),(0,U.jsx)(`td`,{className:`py-2 pr-3 text-xs`,children:e.sessionTarget??`main`}),(0,U.jsx)(`td`,{className:`py-2 pr-3`,children:(0,U.jsxs)(`select`,{className:O(W(),`min-w-[8rem] py-1 text-xs`),value:a,disabled:r||e.sessionTarget!==`isolated`,onChange:t=>void o(e,t.target.value),children:[(0,U.jsx)(`option`,{value:``,children:i?t.cronAgentDefault:t.cronAgentClear}),n.agents.map(e=>(0,U.jsx)(`option`,{value:e.id,children:e.id},e.id))]})})]},e.id)})})]})})]})}function jt(e){let{a:t,filesLoading:n,files:r,activeFile:i,setActiveFile:a,bootstrapViewMode:o,setBootstrapViewMode:s,fileDraft:c,setFileDraft:l,fileSaving:u,bootstrapFileLoading:d,bootstrapEditorNonce:f}=e,p=ye(e=>e.resolved===`dark`);return(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[(0,U.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesHint}),n?(0,U.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesLoading}):r?(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,U.jsx)(`nav`,{className:`flex shrink-0 flex-row flex-wrap gap-x-0.5 gap-y-0 border-b border-edge-subtle`,"aria-label":t.tabFiles,children:r.files.map(e=>(0,U.jsxs)(`button`,{type:`button`,className:O(`-mb-px shrink-0 border-b-2 border-transparent px-3 py-2 text-left font-mono text-xs whitespace-nowrap transition-colors`,i===e.name?`border-accent text-fg`:`text-fg-muted hover:border-edge-subtle hover:text-fg`,e.missing&&`opacity-60`),onClick:()=>a(e.name),children:[e.name,e.missing?` (${t.missing})`:``]},e.name))}),(0,U.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2 overflow-hidden`,children:i?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-panel p-0.5`,role:`group`,"aria-label":t.filesBootstrapEdit,children:[(0,U.jsxs)(`button`,{type:`button`,className:O(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,o===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>s(`edit`),children:[(0,U.jsx)(we,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t.filesBootstrapEdit]}),(0,U.jsxs)(`button`,{type:`button`,className:O(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,o===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>s(`preview`),children:[(0,U.jsx)(_,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t.filesBootstrapPreview]})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[u?(0,U.jsx)(`span`,{children:t.filesSavingStatus}):null,(0,U.jsx)(`span`,{children:t.filesAutoSaveHint})]})]}),o===`edit`?(0,U.jsx)(`div`,{className:O(W(),`flex min-h-0 flex-1 flex-col overflow-hidden p-0`,d&&`pointer-events-none opacity-60`),children:(0,U.jsx)(Le,{initialContent:c,onChange:l,isDark:p,className:`min-h-0 flex-1`},`${i??`file`}-${f}`)}):(0,U.jsx)(`div`,{className:O(W(),`min-h-0 flex-1 overflow-y-auto text-sm`,d&&`pointer-events-none opacity-60`),children:(0,U.jsx)(j,{content:c,className:`text-sm`})})]}):(0,U.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.pickFile})})]}):(0,U.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesEmpty})]})}var Mt={name:``,creature:``,emoji:``,avatar:``};function Nt(e){let t={...Mt};if(!e.trim())return t;let n={name:`name`,creature:`creature`,emoji:`emoji`,avatar:`avatar`};for(let r of e.split(`
|
|
2
2
|
`)){let e=r.match(/^[-*]\s+\*\*(\w+):\*\*\s*(.*)/i);if(!e)continue;let i=n[e[1].toLowerCase()];if(!i)continue;let a=e[2].trim();/^_\(.*\)_$/.test(a)&&(a=``),t[i]=a}return t}function Pt(e){return[`# IDENTITY.md - Who Am I?`,``,`- **Name:** ${e.name}`,`- **Creature:** ${e.creature}`,`- **Emoji:** ${e.emoji}`,`- **Avatar:** ${e.avatar}`,``].join(`
|
|
3
3
|
`)}var Ft={callName:``,pronouns:``,timezone:``,notes:``};function It(e){let t={...Ft};if(!e.trim())return t;let n={name:`callName`,"what to call them":`callName`,pronouns:`pronouns`,timezone:`timezone`,notes:`notes`},r=e.split(`
|
|
4
4
|
`),i=-1;for(let e=0;e<r.length;e++){let a=r[e];if(/^##\s+Context/i.test(a)){i=e+1;continue}let o=a.match(/^[-*]\s+\*\*(.+?):\*\*\s*(.*)/i);if(!o)continue;let s=n[o[1].toLowerCase().trim()];if(!s)continue;let c=o[2].trim();/^_\(.*\)_$/.test(c)&&(c=``),t[s]=c}if(i>0){let e=r.slice(i).join(`
|
|
@@ -68,4 +68,4 @@ Warm, friendly, and a little playful. Like a helpful friend who happens to know
|
|
|
68
68
|
## Vibe
|
|
69
69
|
|
|
70
70
|
Sharp, direct, slightly nerdy. The kind of engineer you'd want on your team — competent, opinionated, and occasionally funny.`},{id:`custom`,labelEn:`Custom`,labelZh:`自定义`,emoji:`✍️`,content:``}];function zt(e){let t=e.trimStart();if(!t.startsWith(`---`))return e;let n=t.indexOf(`---`,3);return n===-1?e:t.slice(n+3).trimStart()}function Bt(e){let t=zt(e).trim();if(!t)return`professional`;for(let e of Rt)if(e.id!==`custom`&&(t===e.content.trim()||q(e.id).filter(e=>t.includes(e)).length>=2))return e.id;return`custom`}function q(e){switch(e){case`professional`:return[`precise and efficient`,`Value the user's time`,`actionable answers`];case`casual`:return[`good friend`,`corporate drone`,`a little playful`];case`geeky`:return[`Precision over politeness`,`Go deep`,`slightly nerdy`];default:return[]}}var Vt=[{value:``,labelEn:`Not set`,labelZh:`未设置`},{value:`Asia/Shanghai`,labelEn:`Asia/Shanghai (CST, UTC+8)`,labelZh:`亚洲/上海 (北京时间, UTC+8)`},{value:`Asia/Tokyo`,labelEn:`Asia/Tokyo (JST, UTC+9)`,labelZh:`亚洲/东京 (日本时间, UTC+9)`},{value:`Asia/Seoul`,labelEn:`Asia/Seoul (KST, UTC+9)`,labelZh:`亚洲/首尔 (韩国时间, UTC+9)`},{value:`Asia/Singapore`,labelEn:`Asia/Singapore (SGT, UTC+8)`,labelZh:`亚洲/新加坡 (UTC+8)`},{value:`Asia/Hong_Kong`,labelEn:`Asia/Hong Kong (HKT, UTC+8)`,labelZh:`亚洲/香港 (UTC+8)`},{value:`Asia/Taipei`,labelEn:`Asia/Taipei (CST, UTC+8)`,labelZh:`亚洲/台北 (UTC+8)`},{value:`Asia/Kolkata`,labelEn:`Asia/Kolkata (IST, UTC+5:30)`,labelZh:`亚洲/加尔各答 (印度时间, UTC+5:30)`},{value:`Asia/Dubai`,labelEn:`Asia/Dubai (GST, UTC+4)`,labelZh:`亚洲/迪拜 (UTC+4)`},{value:`Europe/London`,labelEn:`Europe/London (GMT/BST)`,labelZh:`欧洲/伦敦 (格林尼治时间)`},{value:`Europe/Paris`,labelEn:`Europe/Paris (CET, UTC+1)`,labelZh:`欧洲/巴黎 (中欧时间, UTC+1)`},{value:`Europe/Berlin`,labelEn:`Europe/Berlin (CET, UTC+1)`,labelZh:`欧洲/柏林 (中欧时间, UTC+1)`},{value:`Europe/Moscow`,labelEn:`Europe/Moscow (MSK, UTC+3)`,labelZh:`欧洲/莫斯科 (UTC+3)`},{value:`America/New_York`,labelEn:`America/New York (EST, UTC-5)`,labelZh:`美国/纽约 (东部时间, UTC-5)`},{value:`America/Chicago`,labelEn:`America/Chicago (CST, UTC-6)`,labelZh:`美国/芝加哥 (中部时间, UTC-6)`},{value:`America/Denver`,labelEn:`America/Denver (MST, UTC-7)`,labelZh:`美国/丹佛 (山地时间, UTC-7)`},{value:`America/Los_Angeles`,labelEn:`America/Los Angeles (PST, UTC-8)`,labelZh:`美国/洛杉矶 (太平洋时间, UTC-8)`},{value:`America/Sao_Paulo`,labelEn:`America/São Paulo (BRT, UTC-3)`,labelZh:`美洲/圣保罗 (巴西时间, UTC-3)`},{value:`Australia/Sydney`,labelEn:`Australia/Sydney (AEST, UTC+10)`,labelZh:`澳大利亚/悉尼 (UTC+10)`},{value:`Pacific/Auckland`,labelEn:`Pacific/Auckland (NZST, UTC+12)`,labelZh:`太平洋/奥克兰 (新西兰时间, UTC+12)`}];function Ht(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return``}}var Ut=[{value:`先生`,labelEn:`Mr.`,labelZh:`先生`},{value:`女士`,labelEn:`Ms.`,labelZh:`女士`},{value:`同学`,labelEn:`Colleague`,labelZh:`同学`},{value:`老师`,labelEn:`Teacher`,labelZh:`老师`},{value:`老板`,labelEn:`Boss`,labelZh:`老板`},{value:`朋友`,labelEn:`Friend`,labelZh:`朋友`}],Wt=[{value:`AI assistant`,labelEn:`AI Assistant`,labelZh:`AI 助手`},{value:`robot`,labelEn:`Robot`,labelZh:`机器人`},{value:`familiar`,labelEn:`Familiar`,labelZh:`精灵`},{value:`ghost in the machine`,labelEn:`Ghost in the machine`,labelZh:`机器幽灵`},{value:`digital companion`,labelEn:`Digital Companion`,labelZh:`数字伙伴`}];function Gt(e){let{a:t,chat:n,selected:r,busy:i,editName:a,setEditName:o,editDescription:s,setEditDescription:c,editWorkspace:l,setEditWorkspace:u,editModel:d,setEditModel:f,onSetDefault:p,onSaveAgentEdits:m,onDelete:h,hideInlineSave:g,saveBootstrapRef:v,onBootstrapDirtyChange:y}=e,b=ee(e=>e.language),te=ye(e=>e.resolved===`dark`),[x,ne]=(0,V.useState)(!0),[,re]=(0,V.useState)(!1),[S,C]=(0,V.useState)({name:``,creature:``,emoji:``,avatar:``}),[w,ae]=(0,V.useState)(`professional`),[T,D]=(0,V.useState)(``),[oe,ce]=(0,V.useState)(0),[A,le]=(0,V.useState)(!1),ue=(0,V.useRef)(!1),M=(0,V.useRef)(r?.id??``);M.current=r?.id??``;let de=(0,V.useRef)(``),fe=(0,V.useRef)(``);(0,V.useEffect)(()=>{if(!r)return;let e=!1;return ue.current=!1,ne(!0),(async()=>{try{let[t,n]=await Promise.all([it(r.id,`IDENTITY.md`).catch(()=>``),it(r.id,`SOUL.md`).catch(()=>``)]);if(e)return;let i=Nt(t);C(i),de.current=JSON.stringify(i),ae(Bt(n)),D(n),fe.current=n,ce(e=>e+1)}finally{e||(ne(!1),ue.current=!0)}})(),()=>{e=!0}},[r?.id]);let pe=(0,V.useCallback)(async(e,t)=>{re(!0);try{await at(M.current,e,t)}finally{re(!1)}},[]),N=(0,V.useRef)(S);N.current=S;let P=(0,V.useRef)(T);P.current=T,(0,V.useEffect)(()=>{if(v)return v.current=async()=>{await Promise.all([pe(`IDENTITY.md`,Pt(N.current)),pe(`SOUL.md`,P.current)]),de.current=JSON.stringify(N.current),fe.current=P.current,y?.(!1)},()=>{v.current=null}},[v,pe,y]),(0,V.useEffect)(()=>{if(!y)return;let e=JSON.stringify(S)!==de.current,t=T!==fe.current;y(e||t)},[S,T,y]);let F=(0,V.useCallback)(e=>{C(t=>({...t,...e}))},[]),he=(0,V.useCallback)(e=>{if(ae(e),e!==`custom`){let t=Rt.find(t=>t.id===e);t?.content&&(D(t.content),ce(e=>e+1))}},[]),ge=(0,V.useCallback)(e=>{D(e),ae(`custom`)},[]),I=(0,V.useCallback)((e,t)=>b===`zh`?t:e,[b]),L=W();return r?(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-8 overflow-y-auto`,children:[(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:z,title:t.personaSectionIdentity,subtitle:t.personaSectionIdentityHint,trailing:r.isDefault?null:(0,U.jsx)(E,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:i,onClick:()=>void p(),children:t.setDefault})}),(0,U.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,U.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,U.jsx)(`span`,{className:`font-medium text-fg`,children:t.displayName}),(0,U.jsx)(`input`,{className:L,value:a,onChange:e=>{o(e.target.value),F({name:e.target.value})},placeholder:t.personaNamePlaceholder,autoComplete:`off`})]}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,U.jsx)(`span`,{className:`font-medium text-fg`,children:t.personaEmoji}),(0,U.jsx)(`input`,{className:L,value:S.emoji,onChange:e=>F({emoji:e.target.value}),placeholder:t.personaEmojiPlaceholder,autoComplete:`off`})]}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,U.jsx)(`span`,{className:`font-medium text-fg`,children:t.agentDescription}),(0,U.jsx)(`textarea`,{className:O(L,`min-h-16 resize-y text-sm leading-relaxed`),value:s,onChange:e=>c(e.target.value),placeholder:t.agentDescriptionPlaceholder,maxLength:4e3,rows:3,spellCheck:!0})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,U.jsx)(`span`,{className:`font-medium text-fg`,children:t.personaCreature}),(0,U.jsxs)(`select`,{className:L,value:Wt.some(e=>e.value===S.creature)?S.creature:`__custom__`,onChange:e=>{if(e.target.value===`__custom__`){F({creature:``});return}F({creature:e.target.value})},children:[Wt.map(e=>(0,U.jsx)(`option`,{value:e.value,children:I(e.labelEn,e.labelZh)},e.value)),(0,U.jsx)(`option`,{value:`__custom__`,children:I(`Custom…`,`自定义…`)})]}),Wt.some(e=>e.value===S.creature)?null:(0,U.jsx)(`input`,{className:O(L,`mt-1 text-xs`),value:S.creature,onChange:e=>F({creature:e.target.value}),placeholder:t.personaCreaturePlaceholder,autoComplete:`off`})]}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,U.jsx)(`span`,{className:`font-medium text-fg`,children:t.personaAvatar}),(0,U.jsx)(`input`,{className:O(L,`font-mono text-xs`),value:S.avatar,onChange:e=>F({avatar:e.target.value}),placeholder:t.personaAvatarPlaceholder,autoComplete:`off`})]})]})]}),(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:me,title:t.editAgent,subtitle:t.editAgentHint}),(0,U.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,U.jsx)(`span`,{className:`font-medium text-fg`,children:t.modelPrimary}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[(0,U.jsx)(R,{className:`min-w-0 flex-1`,popoverContentClassName:`z-[70]`,value:d,disabled:i,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>f(e)}),d.trim()?(0,U.jsx)(E,{type:`button`,variant:`secondary`,className:`shrink-0`,disabled:i,onClick:()=>f(``),children:t.modelClear}):null]})]}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,U.jsx)(`span`,{className:`font-medium text-fg`,children:t.workspacePath}),(0,U.jsx)(`input`,{className:O(L,`font-mono text-xs`),value:l,onChange:e=>u(e.target.value)})]})]}),g?null:(0,U.jsx)(`div`,{className:`mt-4`,children:(0,U.jsx)(E,{type:`button`,disabled:i,onClick:()=>void m(),children:t.save})})]}),x?(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.loading}):(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:se,title:t.personaSectionSoul,subtitle:t.personaSectionSoulHint}),(0,U.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.personaSoulTemplate}),(0,U.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-4`,children:Rt.map(e=>(0,U.jsxs)(`button`,{type:`button`,className:O(`flex flex-col items-center gap-1.5 rounded-xl border-2 px-3 py-3 text-center transition-all`,w===e.id?`border-accent bg-accent-soft/40 shadow-sm`:`border-edge hover:border-accent/40 hover:bg-surface-hover`),onClick:()=>he(e.id),children:[(0,U.jsx)(`span`,{className:`text-xl`,children:e.emoji}),(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:I(e.labelEn,e.labelZh)})]},e.id))})]}),w===`custom`?(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.personaSoulCustomEdit}),(0,U.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:A?t.personaSoulEdit:t.personaSoulPreview,"aria-label":A?t.personaSoulEdit:t.personaSoulPreview,onClick:()=>le(e=>!e),children:A?(0,U.jsx)(Be,{className:`size-4`,"aria-hidden":!0}):(0,U.jsx)(_,{className:`size-4`,"aria-hidden":!0})})]}),(0,U.jsx)(`div`,{className:O(L,`flex min-h-64 flex-col overflow-hidden p-0`),children:A?(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,U.jsx)(j,{content:T})}):(0,U.jsx)(Le,{initialContent:T,onChange:ge,isDark:te,className:`min-h-0 flex-1`},`soul-${oe}`)})]}):null]}),r.id===`main`?null:(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:k,title:I(`Danger Zone`,`危险操作`),subtitle:I(`Actions that cannot be undone. Be careful.`,`以下操作不可撤销,请谨慎操作。`)}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsxs)(E,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void h(!1),children:[(0,U.jsx)(ie,{className:`mr-1 size-4`,"aria-hidden":!0}),t.removeFromConfig]}),(0,U.jsx)(E,{type:`button`,variant:`secondary`,className:`border-red-200 text-red-700 hover:bg-red-50 dark:border-red-900/60 dark:text-red-300 dark:hover:bg-red-950/40`,disabled:i,onClick:()=>void h(!0),children:t.purgeDisk})]})]})]}):(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.selectAgentHint})}function Kt({a:e,agentId:t,saveRef:n,onDirtyChange:r}){let i=ee(e=>e.language),[a,o]=(0,V.useState)(!0),[,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)({callName:``,pronouns:``,timezone:``,notes:``}),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(!1),[m,g]=(0,V.useState)(``),_=(0,V.useRef)(!1),v=(0,V.useRef)(t);v.current=t;let y=(0,V.useRef)(``),b=(0,V.useCallback)(async e=>{let t=v.current;s(!0);try{await at(t,`USER.md`,e)}finally{s(!1)}},[]),te=(0,V.useRef)(c);te.current=c,(0,V.useEffect)(()=>{if(n)return n.current=async()=>{await b(Lt(te.current)),y.current=JSON.stringify(te.current),r?.(!1)},()=>{n.current=null}},[n,b,r]),(0,V.useEffect)(()=>{r&&r(JSON.stringify(c)!==y.current)},[c,r]),(0,V.useEffect)(()=>{let e=!1;return _.current=!1,o(!0),(async()=>{try{let n=await it(t,`USER.md`).catch(()=>``);if(e)return;let r=It(n),i=r;if(!r.timezone){let e=Ht();e&&(i={...r,timezone:e})}l(i),y.current=JSON.stringify(i);let a=!i.pronouns||Ut.some(e=>e.value===i.pronouns);i.pronouns&&!a&&d(!0);let o=Vt.some(e=>e.value===i.timezone);i.timezone&&!o&&(p(!0),g(i.timezone))}finally{e||(o(!1),_.current=!0)}})(),()=>{e=!0}},[t]);let x=(0,V.useCallback)(e=>{l(t=>({...t,...e}))},[]),ne=(0,V.useCallback)(e=>{if(e===`__custom__`){p(!0);return}p(!1),g(``),x({timezone:e})},[x]),re=(0,V.useCallback)(e=>{g(e),x({timezone:e})},[x]),S=(0,V.useCallback)(()=>{let e=Ht();e&&(Vt.some(t=>t.value===e)?(p(!1),g(``)):(p(!0),g(e)),x({timezone:e}))},[x]),ie=f?`__custom__`:Vt.some(e=>e.value===c.timezone)?c.timezone:`__custom__`,C=(0,V.useCallback)((e,t)=>i===`zh`?t:e,[i]);if(a)return(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.loading});let w=W();return(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto`,children:[(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.personaSectionUserHint}),(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:ce,title:e.personaSectionUser,subtitle:e.personaSectionUserHint}),(0,U.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,U.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,U.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaCallName}),(0,U.jsx)(`input`,{className:w,value:c.callName,onChange:e=>x({callName:e.target.value}),placeholder:e.personaCallNamePlaceholder,autoComplete:`off`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,U.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaPronouns}),(0,U.jsxs)(`select`,{className:w,value:Ut.some(e=>e.value===c.pronouns)?c.pronouns:`__custom__`,onChange:e=>{if(e.target.value===`__custom__`){d(!0);return}d(!1),x({pronouns:e.target.value})},children:[(0,U.jsx)(`option`,{value:``,disabled:!0,children:e.personaPronounsPlaceholder}),Ut.map(e=>(0,U.jsx)(`option`,{value:e.value,children:C(e.labelEn,e.labelZh)},e.value)),(0,U.jsx)(`option`,{value:`__custom__`,children:C(`Custom…`,`自定义…`)})]}),u?(0,U.jsx)(`input`,{className:O(w,`mt-1 text-xs`),value:Ut.some(e=>e.value===c.pronouns)?``:c.pronouns,onChange:e=>x({pronouns:e.target.value}),placeholder:e.personaPronounsPlaceholder,autoComplete:`off`}):null]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,U.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaTimezone}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[(0,U.jsxs)(`select`,{className:O(w,`min-w-0 flex-1`),value:ie,onChange:e=>ne(e.target.value),children:[Vt.map(e=>(0,U.jsx)(`option`,{value:e.value,children:C(e.labelEn,e.labelZh)},e.value)),(0,U.jsx)(`option`,{value:`__custom__`,children:e.personaTimezoneCustom})]}),(0,U.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:S,children:e.personaTimezoneDetect})]}),f?(0,U.jsx)(`input`,{className:O(w,`mt-1 font-mono text-xs`),value:m,onChange:e=>re(e.target.value),placeholder:`e.g. Asia/Shanghai`,autoComplete:`off`}):null]}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,U.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaNotes}),(0,U.jsx)(`textarea`,{className:O(w,`min-h-16 resize-y text-sm leading-relaxed`),value:c.notes,onChange:e=>x({notes:e.target.value}),placeholder:e.personaNotesPlaceholder,rows:3,spellCheck:!0})]})]}),(0,U.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-lg bg-accent-soft/30 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,U.jsx)(h,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,U.jsx)(`span`,{children:e.personaMemoryNote})]})]})]})}function qt(e){let{a:t,selected:n,busy:r,skillsCatalogLoading:i,catalogForPick:a,skillsInherit:o,setSkillsInherit:s,skillsPick:c,setSkillsPick:l,onSaveSkills:u,hideInlineSave:d}=e;function f(e){let t=n.skills.effectiveAllowlist;return t===void 0?!0:t.length===0?!1:t.includes(e)}function p(){let e=n.skills.effectiveAllowlist;return e===void 0?new Set(a.map(e=>e.name||e.directoryId)):new Set(e)}return(0,U.jsxs)(G,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.jsx)(K,{className:`shrink-0`,icon:ge,title:t.skillsTitle,subtitle:t.skillsHint}),(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsx)(E,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>s(!0),children:t.skillsInherit}),(0,U.jsx)(E,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>{s(!1),l(p())},children:t.skillsCustomize})]}),(0,U.jsx)(Re,{to:`/skills`,className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,children:t.skillsLibraryLink})]}),(0,U.jsxs)(`p`,{className:`mt-2 shrink-0 text-xs text-fg-muted`,children:[t.skillsDefaultsLabel,` `,n.skills.defaults.length?n.skills.defaults.join(`, `):`—`]}),(0,U.jsxs)(`p`,{className:`shrink-0 text-xs text-fg-muted`,children:[t.skillsEffectiveLabel,` `,n.skills.effectiveAllowlist?.length?n.skills.effectiveAllowlist.join(`, `):t.skillsAllFromCatalog]}),i?(0,U.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.skillsCatalogLoading}):a.length===0?(0,U.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.skillsEmptyCatalog}):(0,U.jsx)(`div`,{className:O(`mt-3 min-h-0 flex-1 overflow-y-auto overscroll-contain pr-0.5`,o&&`opacity-50`),children:(0,U.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,role:`list`,children:a.map(e=>{let n=e.name||e.directoryId,i=o?f(n):c.has(n),a=typeof e.description==`string`?e.description.trim():``,s=a||t.skillsNoDescription;return(0,U.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel/60 px-3 dark:border-edge-subtle`,children:(0,U.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:i,disabled:o||r,onChange:()=>{l(e=>{let t=new Set(e);return i?t.delete(n):t.add(n),t})}}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,U.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:n,children:n}),(0,U.jsx)(`p`,{className:O(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!a&&`italic text-fg-subtle`),title:s,children:s})]})]})},n)})})}),d?null:(0,U.jsx)(`div`,{className:`mt-4 shrink-0`,children:(0,U.jsx)(E,{type:`button`,disabled:r,onClick:()=>void u(),children:t.skillsSave})})]})}function Jt(e){let{a:t,data:n,selected:r,busy:i,toolEntryDisable:a,setToolEntryDisable:o,onSaveTools:s,onClearToolsEntry:c,hideInlineSave:l}=e;return(0,U.jsxs)(G,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.jsx)(K,{className:`shrink-0`,icon:ke,title:t.toolsTitle,subtitle:t.toolsHint}),(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,U.jsx)(`ul`,{className:`flex flex-col gap-2.5 pr-1`,role:`list`,children:(n.builtinToolIds.length?n.builtinToolIds:[]).map(e=>{let n=r.tools.defaultsDisable.includes(e),s=n?!1:!a.has(e),c=e in t.toolDescriptions?t.toolDescriptions[e]:``;return(0,U.jsx)(`li`,{className:O(`rounded-xl border border-edge-subtle bg-surface-panel/60 px-3 py-2.5 dark:border-edge-subtle`,n&&`opacity-60`),children:(0,U.jsxs)(`label`,{className:O(`flex cursor-pointer gap-3 text-sm`,n&&`cursor-not-allowed`),children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`mt-1 shrink-0 rounded border-edge`,checked:s,disabled:n||i,onChange:()=>{n||o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs font-medium text-fg`,children:e}),n?(0,U.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[`(`,t.toolsLockedByDefaults,`)`]}):null]}),c?(0,U.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c}):null]})]})},e)})})}),(0,U.jsxs)(`div`,{className:`mt-4 flex shrink-0 flex-wrap gap-2`,children:[l?null:(0,U.jsx)(E,{type:`button`,disabled:i,onClick:()=>void s(),children:t.toolsSave}),(0,U.jsx)(E,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void c(),children:t.toolsClearEntry})]})]})}function Yt(){let e=c(ee(e=>e.language)),t=e.agentsSettings,[n,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(null),[u,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(``),h=e.cron,g=e.chat,_=!!x(e=>e.token),[v]=d(),y=Ie(),{agentId:b}=ae(),te=i(e=>e.setPageHeader),ne=i(e=>e.clearPageHeader),{data:re,error:S,isLoading:ie,mutate:C}=r(_?`settings-gateway-agents`:null,Xe,{revalidateOnFocus:!1}),{data:w}=Ne(_),T=(0,V.useMemo)(()=>et(w?.payload?.config??{}),[w]),D=re??null,oe=!!(_&&ie),[se,k]=(0,V.useState)(null),ce=S instanceof Error?S.message:S?t.loadError:null,A=se??ce,[j,le]=(0,V.useState)(null),[M,fe]=(0,V.useState)(`overview`),[me,N]=(0,V.useState)(``),[P,F]=(0,V.useState)(``),[ge,I]=(0,V.useState)(``),[L,ve]=(0,V.useState)(``),[ye,be]=(0,V.useState)(``),[we,Te]=(0,V.useState)(null),[De,Oe]=(0,V.useState)(!1),ke=(0,V.useRef)(``),[R,z]=(0,V.useState)(!1),[B,Me]=(0,V.useState)(``),[Pe,Le]=(0,V.useState)(``),[ze,Be]=(0,V.useState)(``),[Ve,He]=(0,V.useState)(``),[We,Ge]=(0,V.useState)(``),[Ye,ot]=(0,V.useState)(null),[st,ct]=(0,V.useState)(!1),[H,lt]=(0,V.useState)(null),[ut,dt]=(0,V.useState)(``),[ft,ht]=(0,V.useState)(!1),[gt,_t]=(0,V.useState)(`edit`),[yt,bt]=(0,V.useState)(!1),[W,wt]=(0,V.useState)(0),Dt=(0,V.useRef)(ut);Dt.current=ut;let G=(0,V.useRef)(j);G.current=j;let K=(0,V.useRef)(H);K.current=H;let Ot=(0,V.useRef)(null),Mt=(0,V.useRef)(null),[Nt,Pt]=(0,V.useState)(!1),[Ft,It]=(0,V.useState)(!1),[Lt,Rt]=(0,V.useState)(!1),zt=(0,V.useRef)(``),Bt=(0,V.useRef)(``),q=l(async()=>{let e=G.current,n=K.current;if(!e||!n||`${e}:${n}`!==zt.current)return;let r=Dt.current;if(r!==Bt.current){ht(!0),k(null);try{await at(e,n,r),Bt.current=r,ot(t=>!t||t.agentId!==e?t:{...t,files:t.files.map(e=>e.name===n?{...e,missing:!1}:e)})}catch(e){k(e instanceof Error?e.message:t.saveError)}finally{ht(!1)}}},800),Vt=(0,V.useRef)(q.flush);Vt.current=q.flush,(0,V.useEffect)(()=>()=>{Vt.current()},[]);let[Ht,Ut]=(0,V.useState)(()=>new Set),[Wt,Yt]=(0,V.useState)(()=>new Set),[J,Xt]=(0,V.useState)(!0),[Zt,Qt]=(0,V.useState)([]),[Y,$t]=(0,V.useState)(``),[en,tn]=(0,V.useState)([]),[nn,rn]=(0,V.useState)(!1),[an,on]=(0,V.useState)([]),[sn,cn]=(0,V.useState)(!1),[ln,un]=(0,V.useState)(null),[dn,fn]=(0,V.useState)(``),[pn,mn]=(0,V.useState)([]),[hn,gn]=(0,V.useState)(!1),[_n,X]=(0,V.useState)([]),[vn,Z]=(0,V.useState)(!1);(0,V.useEffect)(()=>{if(D){if(b&&D.agents.some(e=>e.id===b)){le(b);return}le(e=>e&&D.agents.some(t=>t.id===e)?e:D.defaultId)}},[D,b]),(0,V.useEffect)(()=>{!D||!b||D.agents.some(e=>e.id===b)||y(Ae,{replace:!0})},[D,b,y]),(0,V.useEffect)(()=>{b&&fe(`overview`)},[b]),(0,V.useEffect)(()=>{v.get(`panel`)===`defaults`&&y(`/settings/agent-defaults`,{replace:!0,state:{[Ee]:Ae}})},[v,y]);let Q=(0,V.useMemo)(()=>D?.agents.find(e=>e.id===j)??null,[D,j]),yn=(0,V.useMemo)(()=>Q?Zt.filter(e=>e.agentId.toLowerCase()===Q.id.toLowerCase()):[],[Zt,Q?.id]),bn=(0,V.useMemo)(()=>!D||!Q?[]:pn.filter(e=>Ct(e,Q.id,D.defaultId)),[pn,D,Q?.id]),xn=(0,V.useMemo)(()=>_n.filter(e=>e.enabled!==!1),[_n]);(0,V.useEffect)(()=>{if(!Q){Le(``),Be(``),He(``),Ge(``);return}Le(Q.workspace),Be(Q.model?.primary??``),He(Q.name?.trim()?Q.name.trim():Q.id),Ge(Q.description?.trim()??``)},[Q?.id]),(0,V.useEffect)(()=>{if(M!==`files`||!j||!_)return;let e=!1;return ct(!0),rt(j).then(t=>{e||ot(t)}).catch(()=>{e||ot(null)}).finally(()=>{e||ct(!1)}),()=>{e=!0}},[M,j,_,D?.agents.length]),(0,V.useEffect)(()=>{!Q||M!==`tools`||Ut(new Set(Q.tools.entryDisable))},[M,Q]),(0,V.useEffect)(()=>{if(!Q||M!==`skills`)return;let e=Q.skills.entry===void 0;if(Xt(e),e){let e=Q.skills.effectiveAllowlist;Yt(new Set(e??[]))}else Yt(new Set(Q.skills.entry??[]))},[M,Q]),(0,V.useEffect)(()=>{M!==`channels`||!_||Qt(T)},[M,_,T]),(0,V.useEffect)(()=>{if(M!==`channels`||!_)return;let e=!1;return rn(!0),Ke().then(t=>{e||tn(t)}).catch(()=>{e||tn([])}).finally(()=>{e||rn(!1)}),()=>{e=!0}},[M,_]),(0,V.useEffect)(()=>{nn||M!==`channels`||en.length===0||$t(e=>e&&en.some(t=>t.name===e)?e:en[0].name)},[nn,M,en]),(0,V.useEffect)(()=>{if(M!==`channels`||!_)return;let e=Y.trim();if(!e){on([]);return}let t=!1;return un(null),cn(!0),qe(e).then(e=>{t||on(e)}).catch(()=>{t||on([])}).finally(()=>{t||cn(!1)}),()=>{t=!0}},[M,_,Y]);let Sn=(0,V.useCallback)(()=>{let e=Y.trim();e&&(cn(!0),qe(e).then(e=>{on(e),un(t=>t!=null&&t<e.length?t:null)}).catch(()=>{on([]),un(null)}).finally(()=>{cn(!1)}))},[Y]),Cn=!nn&&en.length===0,wn=M===`channels`&&_&&w===void 0;(0,V.useEffect)(()=>{if(M!==`cron`||!_)return;let e=!1;return gn(!0),Je().then(t=>{e||mn(t)}).catch(()=>{e||mn([])}).finally(()=>{e||gn(!1)}),()=>{e=!0}},[M,_]),(0,V.useEffect)(()=>{if(M!==`skills`||!_)return;let e=!1;return Z(!0),nt().then(t=>{e||X(t)}).catch(()=>{e||X([])}).finally(()=>{e||Z(!1)}),()=>{e=!0}},[M,_]),(0,V.useEffect)(()=>{if(!H||!j||!_)return;let e=!1;return q.flush(),bt(!0),it(j,H).then(t=>{e||(zt.current=`${j}:${H}`,Bt.current=t,dt(t),wt(e=>e+1))}).catch(()=>{e||(zt.current=`${j}:${H}`,Bt.current=``,dt(``),wt(e=>e+1))}).finally(()=>{e||bt(!1)}),()=>{e=!0}},[H,j,_,q]),(0,V.useEffect)(()=>{!H||!j||yt||q()},[ut,H,j,yt,q]),(0,V.useEffect)(()=>{if(M===`files`)return()=>{q.flush()}},[M,q]),(0,V.useEffect)(()=>{_t(`edit`)},[H,j]);let $=(0,V.useCallback)(()=>{let e=mt(P.trim()||me);ve(t=>t===``||t===ke.current?(ke.current=e,e):t)},[P,me]),Tn=(0,V.useCallback)(()=>{ke.current=``,N(``),F(``),I(``),ve(``),be(``),Te(null),Oe(!0)},[]),En=e.settingsSections[`agent-defaults`],Dn=(0,V.useMemo)(()=>(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[(0,U.jsx)(E,{asChild:!0,variant:`secondary`,className:`shrink-0 gap-2`,children:(0,U.jsxs)(Re,{to:`/settings/agent-defaults`,title:En,state:{[Ee]:Ae},children:[(0,U.jsx)(_e,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),En]})}),(0,U.jsxs)(`label`,{className:`relative flex min-h-9 min-w-0 max-w-sm cursor-text items-center rounded-pill border border-edge bg-surface-base py-1.5 pl-9 pr-3 shadow-surface dark:bg-surface-hover/40 sm:max-w-md`,children:[(0,U.jsx)(xe,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,U.jsx)(`input`,{type:`search`,role:`searchbox`,enterKeyHint:`search`,value:B,onChange:e=>Me(e.target.value),placeholder:t.listSearchPlaceholder,autoComplete:`off`,spellCheck:!1,"aria-label":t.listSearchPlaceholder,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`})]}),(0,U.jsxs)(E,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":t.addAgentAria,disabled:R,onClick:()=>Tn(),children:[(0,U.jsx)(Ce,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t.addAgent]})]}),[t.addAgent,t.addAgentAria,t.listSearchPlaceholder,R,En,B,Tn]);(0,V.useLayoutEffect)(()=>_?(te({startExtra:null,main:null,end:Dn}),()=>ne()):(ne(),()=>ne()),[Dn,ne,_,te]);async function On(e){e.preventDefault();let n=me.trim();if(!n)return;let r=pt(P,n);if(r.ok===!1){Te(r.error);return}let i=L.trim()||mt(P.trim()||n);if(i){z(!0),Te(null);try{let e=ge.trim(),{createdAgentId:t,...r}=await Ze({name:n,workspace:i,...P.trim()?{id:P.trim()}:{},...ye.trim()?{model:ye.trim()}:{},...e?{description:e}:{}});C(r,{revalidate:!1}),N(``),F(``),I(``),ve(``),be(``),Te(null),Oe(!1),le(t),y(ue(t))}catch(e){Te(e instanceof Error?e.message:t.saveError)}finally{z(!1)}}}async function kn(){if(Q){z(!0),k(null);try{let e=We.trim();C(await Qe(Q.id,{name:Ve.trim()||void 0,description:e.length>0?e:null,workspace:Pe.trim()||void 0,model:ze.trim()||null}),{revalidate:!1})}catch(e){k(e instanceof Error?e.message:t.saveError)}finally{z(!1)}}}async function An(e){z(!0),k(null);try{C(await Qe(e.id,{setDefault:!0}),{revalidate:!1}),le(e.id)}catch(e){k(e instanceof Error?e.message:t.saveError)}finally{z(!1)}}async function jn(e,n){z(!0),k(null);try{let t=await $e(e.id,n);C(t,{revalidate:!1}),le(t.defaultId),fe(`overview`),b===e.id&&y(Ae,{replace:!0}),a(!1),s(null),m(``)}catch(e){k(e instanceof Error?e.message:t.saveError)}finally{z(!1)}}function Mn(e,t){e.id!==`main`&&(s(e),f(t),m(``),a(!0))}async function Nn(){if(Q){z(!0),k(null);try{let e=[...Ht].sort((e,t)=>e.localeCompare(t));C(await Qe(Q.id,{toolsDisable:e}),{revalidate:!1})}catch(e){k(e instanceof Error?e.message:t.saveError)}finally{z(!1)}}}async function Pn(){if(Q){z(!0),k(null);try{C(await Qe(Q.id,{toolsDisable:null}),{revalidate:!1}),Ut(new Set)}catch(e){k(e instanceof Error?e.message:t.saveError)}finally{z(!1)}}}async function Fn(){if(Q){z(!0),k(null);try{C(await Qe(Q.id,{skills:J?null:[...Wt].sort((e,t)=>e.localeCompare(t))}),{revalidate:!1})}catch(e){k(e instanceof Error?e.message:t.saveError)}finally{z(!1)}}}async function In(e){z(!0),k(null);try{let t=Zt.filter(t=>t!==e);await tt(t),Qt(t)}catch(e){k(e instanceof Error?e.message:t.saveError)}finally{z(!1)}}async function Ln(e){if(e.preventDefault(),!Q||!Y.trim())return;let n=Tt(Y,dn,ln,an),r=[...Zt,{agentId:Q.id,priority:100,enabled:!0,match:n}];z(!0),k(null);try{await tt(r),Qt(r),un(null),fn(``)}catch(e){k(e instanceof Error?e.message:t.saveError)}finally{z(!1)}}async function Rn(e,n){z(!0),k(null);try{await Ue(e.id,{agentId:n===``?null:n}),mn(await Je())}catch(e){k(e instanceof Error?e.message:t.saveError)}finally{z(!1)}}let zn=M===`channels`||M===`cron`,Bn=(()=>{if(!Q||M!==`overview`)return!1;let e=Q.name?.trim()||Q.id,t=Q.description?.trim()??``,n=Q.workspace,r=Q.model?.primary??``;return Ve.trim()!==e||We.trim()!==t||Pe.trim()!==n||ze.trim()!==r})(),Vn=(()=>{if(zn)return!1;switch(M){case`overview`:return Bn||Nt;case`profile`:return Ft;default:return!0}})(),Hn=zn||!Vn;function Un(){Rt(!0),setTimeout(()=>Rt(!1),2e3)}async function Wn(){switch(M){case`overview`:await Promise.all([kn(),Ot.current?.()??Promise.resolve()]),Un();break;case`profile`:await Mt.current?.(),Un();break;case`tools`:await Nn(),Un();break;case`skills`:await Fn(),Un();break;case`files`:q.flush(),Un();break;default:break}}function Gn(e){e||y(Ae)}let Kn=Q?Ve.trim()||Q.name?.trim()||Q.id:b??``,qn=Q?.id??b??``;if(!_)return(0,U.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,U.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:t.title}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]});let Jn=Q?M===`overview`?(0,U.jsx)(Gt,{a:t,chat:g,selected:Q,busy:R,editName:Ve,setEditName:He,editDescription:We,setEditDescription:Ge,editWorkspace:Pe,setEditWorkspace:Le,editModel:ze,setEditModel:Be,onSetDefault:()=>void An(Q),onSaveAgentEdits:()=>void kn(),onDelete:e=>void Mn(Q,e),hideInlineSave:!0,saveBootstrapRef:Ot,onBootstrapDirtyChange:Pt}):M===`profile`?(0,U.jsx)(Kt,{a:t,agentId:Q.id,saveRef:Mt,onDirtyChange:It}):M===`files`?(0,U.jsx)(jt,{a:t,filesLoading:st,files:Ye,activeFile:H,setActiveFile:lt,bootstrapViewMode:gt,setBootstrapViewMode:_t,fileDraft:ut,setFileDraft:dt,fileSaving:ft,bootstrapFileLoading:yt,bootstrapEditorNonce:W}):M===`tools`?(0,U.jsx)(Jt,{a:t,data:D,selected:Q,busy:R,toolEntryDisable:Ht,setToolEntryDisable:Ut,onSaveTools:()=>void Nn(),onClearToolsEntry:()=>void Pn(),hideInlineSave:!0}):M===`skills`?(0,U.jsx)(qt,{a:t,selected:Q,busy:R,skillsCatalogLoading:vn,catalogForPick:xn,skillsInherit:J,setSkillsInherit:Xt,skillsPick:Wt,setSkillsPick:Yt,onSaveSkills:()=>void Fn(),hideInlineSave:!0}):M===`channels`?(0,U.jsx)(kt,{a:t,busy:R,bindingsLoading:wn,agentBindings:yn,channelStatuses:en,channelsStatusLoading:nn,useManualChannel:Cn,newBindChannel:Y,setNewBindChannel:$t,bindSessionChats:an,sessionsLoading:sn,newBindSessionIdx:ln,setNewBindSessionIdx:un,newBindCustomPeer:dn,setNewBindCustomPeer:fn,onRefreshSessions:Sn,lastActiveLabels:h.lastActiveLabels,selectRecipient:h.selectRecipient,onRemoveBinding:e=>void In(e),onAddBinding:Ln}):M===`cron`&&D?(0,U.jsx)(At,{a:t,data:D,selected:Q,busy:R,cronLoading:hn,agentCronJobs:bn,onSetCronJobAgent:(e,t)=>void Rn(e,t)}):(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.selectAgentHint}):(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.selectAgentHint});return(0,U.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[(0,U.jsx)(St,{a:t}),A?(0,U.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:A}):null,oe?(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.loading}):D?(0,U.jsx)(xt,{a:t,agents:D.agents,searchQuery:B,onOpenAgent:e=>y(ue(e)),onChatWithAgent:e=>y(`/chat/new`,{state:{agentId:e.trim().toLowerCase()}}),onNewAgent:Tn,busy:R}):null,b&&_?(0,U.jsx)(vt,{open:!!b,onOpenChange:Gn,a:t,title:Kn,subtitle:qn,panel:M,onPanelChange:fe,onFooterSave:()=>void Wn(),footerSaveDisabled:Hn,footerSavedFlash:Lt,busy:R,children:oe||!D?(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.loading}):Jn}):null,(0,U.jsx)(Et,{open:De,onOpenChange:e=>{Oe(e),e||(ke.current=``,N(``),F(``),I(``),ve(``),be(``),Te(null))},a:t,chat:g,busy:R,modalError:we,createDisplayName:me,setCreateDisplayName:N,createAgentId:P,setCreateAgentId:F,createDescription:ge,setCreateDescription:I,createWorkspace:L,setCreateWorkspace:ve,createModel:ye,setCreateModel:be,onCreate:On,onSuggestWorkspace:()=>$()}),(0,U.jsx)(pe,{open:n,onOpenChange:e=>{a(e),e||(s(null),m(``))},children:(0,U.jsxs)(Fe,{children:[(0,U.jsx)(Se,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,U.jsxs)(je,{className:O(`fixed left-1/2 top-1/2 z-[81] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,`dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,U.jsx)(he,{className:`text-base font-semibold text-fg`,children:u?t.purgeDisk:t.removeFromConfig}),(0,U.jsx)(de,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:u?t.confirmDeletePurge:t.confirmDelete}),u&&o?(0,U.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,U.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-fg`,htmlFor:`agent-delete-confirm`,children:t.purgeConfirmLabel}),(0,U.jsx)(`input`,{id:`agent-delete-confirm`,type:`text`,autoComplete:`off`,spellCheck:!1,className:O(`w-full rounded-md border border-edge bg-surface-panel px-3 py-1.5 font-mono text-xs text-fg`,`placeholder:text-fg-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:border-edge`),placeholder:t.purgeConfirmPlaceholder.replace(`{{agentId}}`,o.id),value:p,onChange:e=>m(e.target.value)}),(0,U.jsx)(`p`,{className:`pt-0.5 text-xs text-fg-muted`,children:t.purgeConfirmHint.replace(`{{agentId}}`,o.id)})]}):null,(0,U.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle/60 pt-3`,children:[(0,U.jsx)(E,{type:`button`,variant:`ghost`,disabled:R,onClick:()=>a(!1),children:t.createModalCancel}),(0,U.jsx)(E,{type:`button`,variant:`secondary`,className:u?`border-red-200 text-red-700 hover:bg-red-50 dark:border-red-900/60 dark:text-red-300 dark:hover:bg-red-950/40`:void 0,disabled:R||!o||u&&p.trim().toLowerCase()!==o.id.toLowerCase(),onClick:()=>{o&&jn(o,u)},children:u?t.purgeDisk:t.removeFromConfig})]})]})]})})]})}var J={enabled:!0,mode:`default`,reserveTokens:8e3,triggerThreshold:.8,minMessagesBeforeCompact:10,keepRecentMessages:5,evictionWindow:.2,retentionWindow:6},Xt={enabled:!0,maxToolResultChars:1e4,headKeepRatio:.3,tailKeepRatio:.3},Zt={enabled:!0,useEnhancedSystem:!0,userProfileEnabled:!0,provider:``,injectionFrequency:``,memoryCharLimit:void 0,userCharLimit:void 0,contextCadence:void 0,dialecticCadence:void 0},Qt={summaryModel:``},Y={enabled:!1,memoryNudgeInterval:10,skillNudgeInterval:10,maxToolRounds:8,maxHistoryMessages:80,maxDurationMs:12e4},$t={model:``,maxLength:void 0};function en(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`object`&&e&&`primary`in e){let t=e.primary;return typeof t==`string`?t:``}return``}function tn(e){if(typeof e!=`object`||!e||!(`fallbacks`in e))return[];let t=e.fallbacks;return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim().length>0):[]}function nn(e){return e===!0||e===`true`||e===1}function rn(e){let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{browserEnabled:!1,browserHeadless:!0};let n=t,r=nn(n.enabled),i=n.headless;return{browserEnabled:r,browserHeadless:!(i===!1||i===`false`||i===0)}}function an(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...J};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:J.enabled,mode:t.mode===`safeguard`?`safeguard`:`default`,reserveTokens:typeof t.reserveTokens==`number`&&Number.isFinite(t.reserveTokens)?Math.floor(t.reserveTokens):J.reserveTokens,triggerThreshold:typeof t.triggerThreshold==`number`&&Number.isFinite(t.triggerThreshold)?t.triggerThreshold:J.triggerThreshold,minMessagesBeforeCompact:typeof t.minMessagesBeforeCompact==`number`&&Number.isFinite(t.minMessagesBeforeCompact)?Math.floor(t.minMessagesBeforeCompact):J.minMessagesBeforeCompact,keepRecentMessages:typeof t.keepRecentMessages==`number`&&Number.isFinite(t.keepRecentMessages)?Math.floor(t.keepRecentMessages):J.keepRecentMessages,evictionWindow:typeof t.evictionWindow==`number`&&Number.isFinite(t.evictionWindow)?t.evictionWindow:J.evictionWindow,retentionWindow:typeof t.retentionWindow==`number`&&Number.isFinite(t.retentionWindow)?Math.floor(t.retentionWindow):J.retentionWindow}}function on(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...Xt};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:Xt.enabled,maxToolResultChars:typeof t.maxToolResultChars==`number`&&Number.isFinite(t.maxToolResultChars)?Math.floor(t.maxToolResultChars):Xt.maxToolResultChars,headKeepRatio:typeof t.headKeepRatio==`number`&&Number.isFinite(t.headKeepRatio)?t.headKeepRatio:Xt.headKeepRatio,tailKeepRatio:typeof t.tailKeepRatio==`number`&&Number.isFinite(t.tailKeepRatio)?t.tailKeepRatio:Xt.tailKeepRatio}}function sn(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...Zt};let t=e,n=t.provider,r=n===`none`||n===`stub`?n:``,i=t.injectionFrequency,a=i===`every-turn`||i===`first-turn`?i:``;return{enabled:typeof t.enabled==`boolean`?t.enabled:Zt.enabled,useEnhancedSystem:typeof t.useEnhancedSystem==`boolean`?t.useEnhancedSystem:Zt.useEnhancedSystem,userProfileEnabled:typeof t.userProfileEnabled==`boolean`?t.userProfileEnabled:Zt.userProfileEnabled,provider:r,injectionFrequency:a,memoryCharLimit:typeof t.memoryCharLimit==`number`&&t.memoryCharLimit>0?Math.floor(t.memoryCharLimit):void 0,userCharLimit:typeof t.userCharLimit==`number`&&t.userCharLimit>0?Math.floor(t.userCharLimit):void 0,contextCadence:typeof t.contextCadence==`number`&&t.contextCadence>=1?Math.floor(t.contextCadence):void 0,dialecticCadence:typeof t.dialecticCadence==`number`&&t.dialecticCadence>=1?Math.floor(t.dialecticCadence):void 0}}function cn(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...Qt};let t=e;return{summaryModel:typeof t.summaryModel==`string`?t.summaryModel:``}}function ln(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...Y};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:Y.enabled,memoryNudgeInterval:typeof t.memoryNudgeInterval==`number`&&t.memoryNudgeInterval>=0?Math.floor(t.memoryNudgeInterval):Y.memoryNudgeInterval,skillNudgeInterval:typeof t.skillNudgeInterval==`number`&&t.skillNudgeInterval>=0?Math.floor(t.skillNudgeInterval):Y.skillNudgeInterval,maxToolRounds:typeof t.maxToolRounds==`number`&&t.maxToolRounds>=1&&t.maxToolRounds<=32?Math.floor(t.maxToolRounds):Y.maxToolRounds,maxHistoryMessages:typeof t.maxHistoryMessages==`number`&&t.maxHistoryMessages>=10&&t.maxHistoryMessages<=200?Math.floor(t.maxHistoryMessages):Y.maxHistoryMessages,maxDurationMs:typeof t.maxDurationMs==`number`&&t.maxDurationMs>=3e4&&t.maxDurationMs<=6e5?Math.floor(t.maxDurationMs):Y.maxDurationMs}}function un(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...$t};let t=e;return{model:typeof t.model==`string`?t.model:``,maxLength:typeof t.maxLength==`number`&&t.maxLength>0?t.maxLength:void 0}}function dn(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return{enabled:t};let n=e;return{enabled:typeof n.enabled==`boolean`?n.enabled:t}}function fn(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function pn(e){if(e==null)return``;if(typeof e==`object`&&!Array.isArray(e))try{return JSON.stringify(e,null,2)}catch{return``}return``}function mn(e){let t=e&&typeof e==`object`&&!Array.isArray(e)&&`agents`in e?e.agents:void 0,n=t&&typeof t==`object`&&!Array.isArray(t)&&`defaults`in t?t.defaults:void 0,r=n&&typeof n==`object`&&!Array.isArray(n)?n:{},i=r.modelFallbacks,a=Array.isArray(i)&&i.every(e=>typeof e==`string`)?i:tn(r.model),o=r.imageModelFallbacks,s=Array.isArray(o)&&o.every(e=>typeof e==`string`)?o:tn(r.imageModel),c=r.imageGenerationModelFallbacks,l=Array.isArray(c)&&c.every(e=>typeof e==`string`)?c:tn(r.imageGenerationModel),{browserEnabled:u,browserHeadless:d}=rn(r),f=typeof r.maxTaskDurationMs==`number`&&Number.isFinite(r.maxTaskDurationMs)?r.maxTaskDurationMs:void 0,p=f===void 0?void 0:Math.round(f/6e4);return{model:en(r.model),modelFallbacks:a,imageModel:en(r.imageModel),imageModelFallbacks:s,imageGenerationModel:en(r.imageGenerationModel),imageGenerationModelFallbacks:l,mediaMaxMb:typeof r.mediaMaxMb==`number`&&!Number.isNaN(r.mediaMaxMb)?r.mediaMaxMb:void 0,maxTokens:typeof r.maxTokens==`number`?r.maxTokens:8192,temperature:typeof r.temperature==`number`?r.temperature:.7,maxToolIterations:typeof r.maxToolIterations==`number`?r.maxToolIterations:20,maxTaskDurationMinutes:p,maxRequestsPerTurn:typeof r.maxRequestsPerTurn==`number`?r.maxRequestsPerTurn:50,maxToolFailuresPerTurn:typeof r.maxToolFailuresPerTurn==`number`?r.maxToolFailuresPerTurn:3,workspace:typeof r.workspace==`string`?r.workspace:`~/.xopc/workspace`,browserEnabled:u,browserHeadless:d,thinkingDefault:typeof r.thinkingDefault==`string`?r.thinkingDefault:`medium`,reasoningDefault:typeof r.reasoningDefault==`string`?r.reasoningDefault:`off`,verboseDefault:typeof r.verboseDefault==`string`?r.verboseDefault:`off`,compaction:an(r.compaction),pruning:on(r.pruning),memory:sn(r.memory),sessionSearch:cn(r.sessionSearch),backgroundReview:ln(r.backgroundReview),webExtract:un(r.webExtract),delegate:dn(r.delegate,!1),executeCode:dn(r.executeCode,!1),systemPromptOverride:typeof r.systemPromptOverride==`string`?r.systemPromptOverride:``,skillsAllowlist:fn(r.skills),toolsDisable:(()=>{let e=r.tools;if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e.disable;return fn(t)})(),paramsJson:pn(r.params)}}function hn(e){let t={enabled:e.enabled,useEnhancedSystem:e.useEnhancedSystem,userProfileEnabled:e.userProfileEnabled};return e.provider===`none`||e.provider===`stub`?t.provider=e.provider:t.provider=null,e.injectionFrequency===`every-turn`||e.injectionFrequency===`first-turn`?t.injectionFrequency=e.injectionFrequency:t.injectionFrequency=null,t.memoryCharLimit=e.memoryCharLimit??null,t.userCharLimit=e.userCharLimit??null,t.contextCadence=e.contextCadence??null,t.dialecticCadence=e.dialecticCadence??null,t}function gn(e){let t=e.trim();if(!t)return null;let n=JSON.parse(t);if(n===null)return null;if(typeof n!=`object`||Array.isArray(n))throw Error(`params must be a JSON object`);return n}async function _n(e){let t=e.modelFallbacks.map(e=>e.trim()).filter(Boolean),n=t.length>0?{primary:e.model,fallbacks:t}:e.model,r=e.imageModelFallbacks.map(e=>e.trim()).filter(Boolean),i=r.length>0&&e.imageModel.trim()?{primary:e.imageModel.trim(),fallbacks:r}:e.imageModel||``,a=e.imageGenerationModelFallbacks.map(e=>e.trim()).filter(Boolean),o=a.length>0&&e.imageGenerationModel.trim()?{primary:e.imageGenerationModel.trim(),fallbacks:a}:e.imageGenerationModel||``,s=e.maxTaskDurationMinutes===void 0||e.maxTaskDurationMinutes===null?null:(()=>{let t=Math.floor(e.maxTaskDurationMinutes)*6e4;return t<6e4||t>144e5?null:t})(),c=e.skillsAllowlist.map(e=>e.trim()).filter(Boolean),l=e.toolsDisable.map(e=>e.trim()).filter(Boolean),u=gn(e.paramsJson),d=u===null||Object.keys(u).length===0?null:u,f={model:n,imageModel:i,imageGenerationModel:o,mediaMaxMb:e.mediaMaxMb??null,maxTokens:e.maxTokens,temperature:e.temperature,maxToolIterations:e.maxToolIterations,maxTaskDurationMs:s,maxRequestsPerTurn:e.maxRequestsPerTurn,maxToolFailuresPerTurn:e.maxToolFailuresPerTurn,workspace:e.workspace,browser:{enabled:e.browserEnabled,headless:e.browserHeadless},thinkingDefault:e.thinkingDefault,reasoningDefault:e.reasoningDefault,verboseDefault:e.verboseDefault,compaction:{...e.compaction},pruning:{...e.pruning},memory:hn(e.memory),sessionSearch:{summaryModel:e.sessionSearch.summaryModel.trim()||null},backgroundReview:{enabled:e.backgroundReview.enabled,memoryNudgeInterval:e.backgroundReview.memoryNudgeInterval,skillNudgeInterval:e.backgroundReview.skillNudgeInterval,maxToolRounds:e.backgroundReview.maxToolRounds,maxHistoryMessages:e.backgroundReview.maxHistoryMessages,maxDurationMs:e.backgroundReview.maxDurationMs},webExtract:{model:e.webExtract.model.trim()||null,maxLength:e.webExtract.maxLength??null},delegate:{enabled:e.delegate.enabled},executeCode:{enabled:e.executeCode.enabled},systemPromptOverride:e.systemPromptOverride.trim()||null,skills:c.length>0?c:null,tools:{disable:l.length>0?l:null},params:d};await A(B(`/api/config`),{method:`PATCH`,body:JSON.stringify({agents:{defaults:f}})}),N()}function X(){return O(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,He,`dark:border-edge`)}function vn(){return O(w,g)}function Z({label:e,description:t,children:n}){return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e}),n,(0,U.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t})]})}function Q(e){let{a:t,chat:n,form:r,update:i}=e,o=t.advanced;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:a,title:o.cardLimitsTitle,subtitle:o.cardLimitsSubtitle}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,U.jsx)(Z,{label:o.maxTaskDurationMs,description:o.maxTaskDurationMsDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:1,max:240,step:1,value:r.maxTaskDurationMinutes??``,placeholder:o.maxTaskDurationPlaceholder,onChange:e=>{let t=e.target.value;if(t===``){i({maxTaskDurationMinutes:void 0});return}let n=Number.parseInt(t,10);Number.isNaN(n)||i({maxTaskDurationMinutes:Math.min(240,Math.max(1,n))})}})}),(0,U.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,U.jsx)(Z,{label:o.maxRequestsPerTurn,description:o.maxRequestsPerTurnDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:10,max:200,value:r.maxRequestsPerTurn,onChange:e=>i({maxRequestsPerTurn:Number.parseInt(e.target.value,10)||50})})}),(0,U.jsx)(Z,{label:o.maxToolFailuresPerTurn,description:o.maxToolFailuresPerTurnDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:1,max:20,value:r.maxToolFailuresPerTurn,onChange:e=>i({maxToolFailuresPerTurn:Number.parseInt(e.target.value,10)||3})})})]})]})]}),(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:ne,title:o.cardCompactionTitle,subtitle:o.cardCompactionSubtitle}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,U.jsx)(Z,{label:o.compactionEnabled,description:o.compactionEnabledDesc,children:(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.compaction.enabled,onChange:e=>i({compaction:{...r.compaction,enabled:e.target.checked}})}),(0,U.jsx)(`span`,{children:o.compactionEnabledOn})]})}),(0,U.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,U.jsx)(Z,{label:o.compactionMode,description:o.compactionModeDesc,children:(0,U.jsxs)(`select`,{className:vn(),value:r.compaction.mode,onChange:e=>i({compaction:{...r.compaction,mode:e.target.value}}),children:[(0,U.jsx)(`option`,{value:`default`,children:o.compactionModeDefault}),(0,U.jsx)(`option`,{value:`safeguard`,children:o.compactionModeSafeguard})]})}),(0,U.jsx)(Z,{label:o.reserveTokens,description:o.reserveTokensDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:1e3,value:r.compaction.reserveTokens,onChange:e=>i({compaction:{...r.compaction,reserveTokens:Number.parseInt(e.target.value,10)||0}})})}),(0,U.jsx)(Z,{label:o.triggerThreshold,description:o.triggerThresholdDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:.5,max:.95,step:.05,value:r.compaction.triggerThreshold,onChange:e=>i({compaction:{...r.compaction,triggerThreshold:Number.parseFloat(e.target.value)||.8}})})}),(0,U.jsx)(Z,{label:o.minMessagesBeforeCompact,description:o.minMessagesBeforeCompactDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:1,value:r.compaction.minMessagesBeforeCompact,onChange:e=>i({compaction:{...r.compaction,minMessagesBeforeCompact:Number.parseInt(e.target.value,10)||10}})})}),(0,U.jsx)(Z,{label:o.keepRecentMessages,description:o.keepRecentMessagesDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:0,value:r.compaction.keepRecentMessages,onChange:e=>i({compaction:{...r.compaction,keepRecentMessages:Number.parseInt(e.target.value,10)||5}})})}),(0,U.jsx)(Z,{label:o.evictionWindow,description:o.evictionWindowDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:.1,max:.5,step:.05,value:r.compaction.evictionWindow,onChange:e=>i({compaction:{...r.compaction,evictionWindow:Number.parseFloat(e.target.value)||.2}})})}),(0,U.jsx)(Z,{label:o.retentionWindow,description:o.retentionWindowDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:3,max:20,value:r.compaction.retentionWindow,onChange:e=>i({compaction:{...r.compaction,retentionWindow:Number.parseInt(e.target.value,10)||6}})})})]})]})]}),(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:Pe,title:o.cardPruningTitle,subtitle:o.cardPruningSubtitle}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,U.jsx)(Z,{label:o.pruningEnabled,description:o.pruningEnabledDesc,children:(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.pruning.enabled,onChange:e=>i({pruning:{...r.pruning,enabled:e.target.checked}})}),(0,U.jsx)(`span`,{children:o.pruningEnabledOn})]})}),(0,U.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,U.jsx)(Z,{label:o.maxToolResultChars,description:o.maxToolResultCharsDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:1e3,value:r.pruning.maxToolResultChars,onChange:e=>i({pruning:{...r.pruning,maxToolResultChars:Number.parseInt(e.target.value,10)||1e4}})})}),(0,U.jsx)(Z,{label:o.headKeepRatio,description:o.headKeepRatioDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:0,max:1,step:.05,value:r.pruning.headKeepRatio,onChange:e=>i({pruning:{...r.pruning,headKeepRatio:Number.parseFloat(e.target.value)||.3}})})}),(0,U.jsx)(Z,{label:o.tailKeepRatio,description:o.tailKeepRatioDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:0,max:1,step:.05,value:r.pruning.tailKeepRatio,onChange:e=>i({pruning:{...r.pruning,tailKeepRatio:Number.parseFloat(e.target.value)||.3}})})})]})]})]}),(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:Oe,title:o.cardMemoryTitle,subtitle:o.cardMemorySubtitle}),(0,U.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,U.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,U.jsx)(Z,{label:o.memoryEnabled,description:o.memoryEnabledDesc,children:(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.memory.enabled,onChange:e=>i({memory:{...r.memory,enabled:e.target.checked}})}),(0,U.jsx)(`span`,{children:o.memoryEnabledOn})]})}),(0,U.jsx)(Z,{label:o.useEnhancedSystem,description:o.useEnhancedSystemDesc,children:(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.memory.useEnhancedSystem,onChange:e=>i({memory:{...r.memory,useEnhancedSystem:e.target.checked}})}),(0,U.jsx)(`span`,{children:o.useEnhancedSystemOn})]})}),(0,U.jsx)(Z,{label:o.userProfileEnabled,description:o.userProfileEnabledDesc,children:(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.memory.userProfileEnabled,onChange:e=>i({memory:{...r.memory,userProfileEnabled:e.target.checked}})}),(0,U.jsx)(`span`,{children:o.userProfileEnabledOn})]})}),(0,U.jsx)(Z,{label:o.memoryProvider,description:o.memoryProviderDesc,children:(0,U.jsxs)(`select`,{className:vn(),value:r.memory.provider,onChange:e=>i({memory:{...r.memory,provider:e.target.value}}),children:[(0,U.jsx)(`option`,{value:``,children:o.memoryProviderUnset}),(0,U.jsx)(`option`,{value:`none`,children:`none`}),(0,U.jsx)(`option`,{value:`stub`,children:`stub`})]})}),(0,U.jsx)(Z,{label:o.injectionFrequency,description:o.injectionFrequencyDesc,children:(0,U.jsxs)(`select`,{className:vn(),value:r.memory.injectionFrequency,onChange:e=>i({memory:{...r.memory,injectionFrequency:e.target.value}}),children:[(0,U.jsx)(`option`,{value:``,children:o.injectionFrequencyUnset}),(0,U.jsx)(`option`,{value:`every-turn`,children:o.injectionEveryTurn}),(0,U.jsx)(`option`,{value:`first-turn`,children:o.injectionFirstTurn})]})}),(0,U.jsx)(Z,{label:o.memoryCharLimit,description:o.memoryCharLimitDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:1,value:r.memory.memoryCharLimit??``,placeholder:`—`,onChange:e=>{let t=e.target.value;i({memory:{...r.memory,memoryCharLimit:t===``?void 0:Number.parseInt(t,10)}})}})}),(0,U.jsx)(Z,{label:o.userCharLimit,description:o.userCharLimitDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:1,value:r.memory.userCharLimit??``,placeholder:`—`,onChange:e=>{let t=e.target.value;i({memory:{...r.memory,userCharLimit:t===``?void 0:Number.parseInt(t,10)}})}})}),(0,U.jsx)(Z,{label:o.contextCadence,description:o.contextCadenceDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:1,value:r.memory.contextCadence??``,placeholder:`—`,onChange:e=>{let t=e.target.value;i({memory:{...r.memory,contextCadence:t===``?void 0:Number.parseInt(t,10)}})}})}),(0,U.jsx)(Z,{label:o.dialecticCadence,description:o.dialecticCadenceDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:1,value:r.memory.dialecticCadence??``,placeholder:`—`,onChange:e=>{let t=e.target.value;i({memory:{...r.memory,dialecticCadence:t===``?void 0:Number.parseInt(t,10)}})}})})]})})]}),(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:xe,title:o.cardSessionSearchTitle,subtitle:o.cardSessionSearchSubtitle}),(0,U.jsx)(Z,{label:o.sessionSearchSummaryModel,description:o.sessionSearchSummaryModelDesc,children:(0,U.jsx)(R,{value:r.sessionSearch.summaryModel,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>i({sessionSearch:{...r.sessionSearch,summaryModel:e}})})})]}),(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:z,title:o.cardReviewTitle,subtitle:o.cardReviewSubtitle}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,U.jsx)(Z,{label:o.reviewEnabled,description:o.reviewEnabledDesc,children:(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.backgroundReview.enabled,onChange:e=>i({backgroundReview:{...r.backgroundReview,enabled:e.target.checked}})}),(0,U.jsx)(`span`,{children:o.reviewEnabledOn})]})}),(0,U.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,U.jsx)(Z,{label:o.memoryNudgeInterval,description:o.memoryNudgeIntervalDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:0,value:r.backgroundReview.memoryNudgeInterval,onChange:e=>i({backgroundReview:{...r.backgroundReview,memoryNudgeInterval:Number.parseInt(e.target.value,10)||0}})})}),(0,U.jsx)(Z,{label:o.skillNudgeInterval,description:o.skillNudgeIntervalDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:0,value:r.backgroundReview.skillNudgeInterval,onChange:e=>i({backgroundReview:{...r.backgroundReview,skillNudgeInterval:Number.parseInt(e.target.value,10)||0}})})}),(0,U.jsx)(Z,{label:o.reviewMaxToolRounds,description:o.reviewMaxToolRoundsDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:1,max:32,value:r.backgroundReview.maxToolRounds,onChange:e=>i({backgroundReview:{...r.backgroundReview,maxToolRounds:Number.parseInt(e.target.value,10)||8}})})}),(0,U.jsx)(Z,{label:o.reviewMaxHistoryMessages,description:o.reviewMaxHistoryMessagesDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:10,max:200,value:r.backgroundReview.maxHistoryMessages,onChange:e=>i({backgroundReview:{...r.backgroundReview,maxHistoryMessages:Number.parseInt(e.target.value,10)||80}})})}),(0,U.jsx)(Z,{label:o.reviewMaxDurationMs,description:o.reviewMaxDurationMsDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:30,max:600,step:1,value:Math.round((r.backgroundReview.maxDurationMs??12e4)/1e3),onChange:e=>i({backgroundReview:{...r.backgroundReview,maxDurationMs:(Number.parseInt(e.target.value,10)||120)*1e3}})})})]})]})]}),(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:D,title:o.cardWebExtractTitle,subtitle:o.cardWebExtractSubtitle}),(0,U.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,U.jsx)(`div`,{className:`sm:col-span-2`,children:(0,U.jsx)(Z,{label:o.webExtractModel,description:o.webExtractModelDesc,children:(0,U.jsx)(R,{value:r.webExtract.model,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>i({webExtract:{...r.webExtract,model:e}})})})}),(0,U.jsx)(Z,{label:o.webExtractMaxLength,description:o.webExtractMaxLengthDesc,children:(0,U.jsx)(`input`,{type:`number`,className:X(),min:1,value:r.webExtract.maxLength??``,placeholder:`—`,onChange:e=>{let t=e.target.value;i({webExtract:{...r.webExtract,maxLength:t===``?void 0:Number.parseInt(t,10)}})}})})]})]}),(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:Me,title:o.cardDelegateTitle,subtitle:o.cardDelegateSubtitle}),(0,U.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,U.jsx)(Z,{label:o.delegateEnabled,description:o.delegateEnabledDesc,children:(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.delegate.enabled,onChange:e=>i({delegate:{...r.delegate,enabled:e.target.checked}})}),(0,U.jsx)(`span`,{children:o.delegateEnabledOn})]})}),(0,U.jsx)(Z,{label:o.executeCodeEnabled,description:o.executeCodeEnabledDesc,children:(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.executeCode.enabled,onChange:e=>i({executeCode:{...r.executeCode,enabled:e.target.checked}})}),(0,U.jsx)(`span`,{children:o.executeCodeEnabledOn})]})})]})]}),(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:be,title:o.cardPromptSkillsTitle,subtitle:o.cardPromptSkillsSubtitle}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,U.jsx)(Z,{label:o.systemPromptOverride,description:o.systemPromptOverrideDesc,children:(0,U.jsx)(`textarea`,{className:O(X(),`min-h-[100px] resize-y font-mono text-xs`),value:r.systemPromptOverride,placeholder:o.systemPromptPlaceholder,onChange:e=>i({systemPromptOverride:e.target.value})})}),(0,U.jsx)(Z,{label:o.skillsAllowlist,description:o.skillsAllowlistDesc,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.skillsAllowlist.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`input`,{type:`text`,className:O(X(),`font-mono text-xs`),value:e,onChange:e=>{let n=[...r.skillsAllowlist];n[t]=e.target.value,i({skillsAllowlist:n})}}),(0,U.jsx)(E,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":o.removeListItem,onClick:()=>i({skillsAllowlist:r.skillsAllowlist.filter((e,n)=>n!==t)}),children:`×`})]},t)),(0,U.jsx)(E,{type:`button`,variant:`secondary`,className:`w-fit`,onClick:()=>i({skillsAllowlist:[...r.skillsAllowlist,``]}),children:o.addSkillName})]})})]})]}),(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:ke,title:o.cardToolsDisableTitle,subtitle:o.cardToolsDisableSubtitle}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,U.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o.toolsDisableHint}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.toolsDisable.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`input`,{type:`text`,className:O(X(),`font-mono text-xs`),value:e,placeholder:`shell`,onChange:e=>{let n=[...r.toolsDisable];n[t]=e.target.value,i({toolsDisable:n})}}),(0,U.jsx)(E,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":o.removeListItem,onClick:()=>i({toolsDisable:r.toolsDisable.filter((e,n)=>n!==t)}),children:`×`})]},t)),(0,U.jsx)(E,{type:`button`,variant:`secondary`,className:`w-fit`,onClick:()=>i({toolsDisable:[...r.toolsDisable,``]}),children:o.addToolName})]})]})]}),(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:Te,title:o.cardParamsTitle,subtitle:o.cardParamsSubtitle}),(0,U.jsx)(Z,{label:o.paramsJson,description:o.paramsJsonDesc,children:(0,U.jsx)(`textarea`,{className:O(X(),`min-h-[88px] resize-y font-mono text-xs`),value:r.paramsJson,placeholder:`{}`,onChange:e=>i({paramsJson:e.target.value})})})]})]})}async function yn(){let e=await ve(B(`/api/image/providers`));if(!e.ok)throw Error(`Image providers: HTTP ${e.status}`);return(await e.json()).payload?.providers??[]}function bn(e){let t=new Set,n=[];for(let r of e){let e=r.models.length>0?r.models:r.defaultModel?[r.defaultModel]:[];for(let i of e){let e=`${r.id}/${i}`;t.has(e)||(t.add(e),n.push(e))}}return n}function xn(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=n.split(/[/\s]+/).filter(Boolean);return e.filter(e=>{let t=e.toLowerCase();return r.every(e=>t.includes(e))})}var Sn=`image-generation-providers`;function Cn({value:e,disabled:t,placeholder:n,searchPlaceholder:i,noMatches:a,className:s,onChange:c}){let[l,u]=(0,V.useState)(!1),[d,p]=(0,V.useState)(``),{data:h,isLoading:g,error:_}=r(Sn,yn,{revalidateOnFocus:!1}),v=(0,V.useMemo)(()=>bn(h??[]),[h]),ee=(0,V.useMemo)(()=>xn(v,d),[v,d]),b=e.trim()?e:n,te=e.trim()||n,x=(0,V.useCallback)(e=>{u(e),e||p(``)},[]);return(0,U.jsxs)(T,{open:l,onOpenChange:x,modal:!1,children:[(0,U.jsx)(m,{asChild:!0,children:(0,U.jsxs)(`button`,{type:`button`,disabled:t||g,title:g?`…`:te,className:O(re,`items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-left text-sm font-normal text-fg`,ze.transition,`hover:border-edge hover:bg-surface-hover/45`,y,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,s),"aria-haspopup":`listbox`,"aria-expanded":l,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:g?`…`:b}),(0,U.jsx)(M,{className:`h-4 w-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0})]})}),(0,U.jsx)(o,{children:(0,U.jsxs)(Ve,{className:`z-50 w-[min(22rem,calc(100vw-2rem))] rounded-xl border border-edge-subtle bg-surface-panel p-1 shadow-elevated dark:border-edge-subtle`,side:`bottom`,sideOffset:4,align:`end`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,U.jsx)(`input`,{type:`search`,className:O(`mb-1 w-full rounded-lg border border-edge-subtle bg-surface-base px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-disabled dark:bg-surface-hover/40`,f),placeholder:i,value:d,onChange:e=>p(e.target.value),onKeyDown:e=>e.stopPropagation()}),(0,U.jsxs)(`div`,{className:`max-h-60 overflow-auto`,role:`listbox`,"aria-label":i,children:[_?(0,U.jsx)(`div`,{className:`px-2 py-2 text-xs text-red-600 dark:text-red-400`,children:_ instanceof Error?_.message:`Failed to load image providers`}):null,!_&&v.length===0&&!g?(0,U.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:a}):null,!_&&v.length>0&&ee.length===0?(0,U.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:a}):null,ee.map(t=>(0,U.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===e,className:O(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,t===e&&`bg-surface-hover/90 font-medium dark:bg-surface-hover/70`),onClick:()=>{c(t),u(!1),p(``)},children:[(0,U.jsx)(F,{className:O(`h-4 w-4 shrink-0`,t!==e&&`invisible`),"aria-hidden":!0}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:t})]},t))]})]})})]})}var wn=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`adaptive`];function $({label:e,description:t,children:n}){return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e}),n,(0,U.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t})]})}function Tn(){let e=c(ee(e=>e.language)),t=e.agentSettings,n=e.chat,r=!!x(e=>e.token),[i,a]=(0,V.useState)(null),[o,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(!1),[f,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(!1),_=(0,V.useRef)(!1),{data:v,error:y,isLoading:te,mutate:ne}=Ne(r),re=(0,V.useMemo)(()=>v?.payload?.config===void 0?null:mn(v.payload.config),[v]);(0,V.useEffect)(()=>{if(!r){a(null),l(null),_.current=!1;return}re!==null&&(_.current||(a(re),l(re)))},[r,re]);let w=!!(r&&te&&v===void 0&&!y),ae=y instanceof Error?y.message:y?String(y):null,T=(0,V.useMemo)(()=>!i||!o?!1:JSON.stringify(i)!==JSON.stringify(o),[i,o]),D=(0,V.useCallback)(e=>{_.current=!0,a(t=>t?{...t,...e}:null)},[]),O=(0,V.useCallback)(async()=>{if(!(!i||u)){d(!0),m(null),g(!1);try{try{gn(i.paramsJson)}catch(e){m(e instanceof SyntaxError?t.advanced.paramsInvalidJson:e instanceof Error?e.message:t.advanced.paramsInvalidJson);return}await _n(i),_.current=!1,g(!0),window.setTimeout(()=>g(!1),2500)}catch(e){m(e instanceof Error?e.message:t.saveError)}finally{d(!1)}}},[i,u,t.saveError,t.advanced]),oe=e.settingsSections[`agent-defaults`];return r?w?(0,U.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,U.jsx)(`div`,{className:`h-8 w-48 animate-pulse rounded bg-surface-hover`}),(0,U.jsx)(`div`,{className:`mt-6 h-32 animate-pulse rounded-xl bg-surface-hover`}),(0,U.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:e.logs.loading})]}):i?(0,U.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[(0,U.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:oe}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.subtitle}),(0,U.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.sectionDesc})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[h?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.saved}):null,(0,U.jsx)(E,{type:`button`,variant:`primary`,disabled:!T||u,onClick:()=>void O(),children:u?t.saving:t.save})]})]}),f?(0,U.jsx)(`div`,{className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/50 dark:text-red-400`,role:`alert`,children:f}):null,(0,U.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:S,title:t.cardModelsTitle,subtitle:t.cardModelsSubtitle}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,U.jsx)($,{label:t.label.model,description:t.desc.model,children:(0,U.jsx)(R,{value:i.model,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>D({model:e})})}),(0,U.jsx)($,{label:t.label.modelFallbacks,description:t.desc.modelFallbacks,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i.modelFallbacks.map((e,r)=>(0,U.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,U.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,U.jsx)(R,{value:e,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>{let t=[...i.modelFallbacks];t[r]=e,D({modelFallbacks:t})}})}),(0,U.jsx)(E,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":t.removeModelFallback,onClick:()=>D({modelFallbacks:i.modelFallbacks.filter((e,t)=>t!==r)}),children:(0,U.jsx)(ie,{className:`size-4`,strokeWidth:1.75})})]},r)),(0,U.jsxs)(E,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,onClick:()=>D({modelFallbacks:[...i.modelFallbacks,``]}),children:[(0,U.jsx)(Ce,{className:`size-4 shrink-0`,strokeWidth:1.75}),t.addModelFallback]})]})}),(0,U.jsx)($,{label:t.label.imageModel,description:t.desc.imageModel,children:(0,U.jsx)(R,{value:i.imageModel,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>D({imageModel:e})})}),(0,U.jsx)($,{label:t.label.imageModelFallbacks,description:t.desc.imageModelFallbacks,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i.imageModelFallbacks.map((e,r)=>(0,U.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,U.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,U.jsx)(R,{value:e,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>{let t=[...i.imageModelFallbacks];t[r]=e,D({imageModelFallbacks:t})}})}),(0,U.jsx)(E,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":t.removeModelFallback,onClick:()=>D({imageModelFallbacks:i.imageModelFallbacks.filter((e,t)=>t!==r)}),children:(0,U.jsx)(ie,{className:`size-4`,strokeWidth:1.75})})]},r)),(0,U.jsxs)(E,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,onClick:()=>D({imageModelFallbacks:[...i.imageModelFallbacks,``]}),children:[(0,U.jsx)(Ce,{className:`size-4 shrink-0`,strokeWidth:1.75}),t.addModelFallback]})]})}),(0,U.jsx)($,{label:t.label.imageGenerationModel,description:t.desc.imageGenerationModel,children:(0,U.jsx)(Cn,{value:i.imageGenerationModel,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>D({imageGenerationModel:e})})}),(0,U.jsx)($,{label:t.label.imageGenerationModelFallbacks,description:t.desc.imageGenerationModelFallbacks,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i.imageGenerationModelFallbacks.map((e,r)=>(0,U.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,U.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,U.jsx)(Cn,{value:e,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>{let t=[...i.imageGenerationModelFallbacks];t[r]=e,D({imageGenerationModelFallbacks:t})}})}),(0,U.jsx)(E,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":t.removeModelFallback,onClick:()=>D({imageGenerationModelFallbacks:i.imageGenerationModelFallbacks.filter((e,t)=>t!==r)}),children:(0,U.jsx)(ie,{className:`size-4`,strokeWidth:1.75})})]},r)),(0,U.jsxs)(E,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,onClick:()=>D({imageGenerationModelFallbacks:[...i.imageGenerationModelFallbacks,``]}),children:[(0,U.jsx)(Ce,{className:`size-4 shrink-0`,strokeWidth:1.75}),t.addModelFallback]})]})})]})]}),(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:s,title:t.cardWorkspaceTitle,subtitle:t.cardWorkspaceSubtitle}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,U.jsx)($,{label:t.label.workspace,description:t.desc.workspace,children:(0,U.jsx)(`input`,{type:`text`,className:X(),value:i.workspace,onChange:e=>D({workspace:e.target.value}),autoComplete:`off`})}),(0,U.jsx)($,{label:t.label.mediaMaxMb,description:t.desc.mediaMaxMb,children:(0,U.jsx)(`input`,{type:`number`,min:1,step:1,className:X(),value:i.mediaMaxMb??``,placeholder:`20`,onChange:e=>{let t=e.target.value;D({mediaMaxMb:t===``?void 0:Number(t)})}})})]})]}),(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:C,title:t.cardBrowserTitle,subtitle:t.cardBrowserSubtitle}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,U.jsx)($,{label:t.label.browserEnabled,description:t.desc.browserEnabled,children:(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:i.browserEnabled,onChange:e=>D({browserEnabled:e.target.checked})}),(0,U.jsx)(`span`,{children:t.browserEnabledOn})]})}),(0,U.jsx)($,{label:t.label.browserHeadless,description:t.desc.browserHeadless,children:(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:i.browserHeadless,onChange:e=>D({browserHeadless:e.target.checked})}),(0,U.jsx)(`span`,{children:t.browserHeadlessOn})]})})]})]}),(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:b,title:t.cardGenerationTitle,subtitle:t.cardGenerationSubtitle}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,U.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,U.jsx)($,{label:t.label.maxTokens,description:t.desc.maxTokens,children:(0,U.jsx)(`input`,{type:`number`,className:X(),value:i.maxTokens,min:1,onChange:e=>D({maxTokens:Number.parseInt(e.target.value,10)||0})})}),(0,U.jsx)($,{label:t.label.temperature,description:t.desc.temperature,children:(0,U.jsx)(`input`,{type:`number`,className:X(),value:i.temperature,min:0,max:2,step:.1,onChange:e=>D({temperature:Number.parseFloat(e.target.value)||0})})})]}),(0,U.jsx)($,{label:t.label.maxToolIterations,description:t.desc.maxToolIterations,children:(0,U.jsx)(`input`,{type:`number`,className:X(),value:i.maxToolIterations,min:1,onChange:e=>D({maxToolIterations:Number.parseInt(e.target.value,10)||0})})})]})]}),(0,U.jsxs)(G,{children:[(0,U.jsx)(K,{icon:p,title:t.cardBehaviorTitle,subtitle:t.cardBehaviorSubtitle}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,U.jsx)($,{label:t.label.thinkingDefault,description:t.desc.thinkingDefault,children:(0,U.jsx)(`select`,{className:vn(),value:i.thinkingDefault,onChange:e=>D({thinkingDefault:e.target.value}),children:wn.map(e=>(0,U.jsx)(`option`,{value:e,children:n.thinkingLevels[e]},e))})}),(0,U.jsx)($,{label:t.label.reasoningDefault,description:t.desc.reasoningDefault,children:(0,U.jsxs)(`select`,{className:vn(),value:i.reasoningDefault,onChange:e=>D({reasoningDefault:e.target.value}),children:[(0,U.jsx)(`option`,{value:`off`,children:t.reasoning.off}),(0,U.jsx)(`option`,{value:`on`,children:t.reasoning.on}),(0,U.jsx)(`option`,{value:`stream`,children:t.reasoning.stream})]})}),(0,U.jsx)($,{label:t.label.verboseDefault,description:t.desc.verboseDefault,children:(0,U.jsxs)(`select`,{className:vn(),value:i.verboseDefault,onChange:e=>D({verboseDefault:e.target.value}),children:[(0,U.jsx)(`option`,{value:`off`,children:t.verbose.off}),(0,U.jsx)(`option`,{value:`on`,children:t.verbose.on}),(0,U.jsx)(`option`,{value:`full`,children:t.verbose.full})]})})]})]}),(0,U.jsx)(Q,{a:t,chat:n,form:i,update:D})]})]}):(0,U.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-10`,children:[(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f??ae??t.loadError}),(0,U.jsx)(E,{type:`button`,variant:`secondary`,onClick:()=>void ne(),children:e.logs.refresh})]}):(0,U.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-10`,children:(0,U.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[(0,U.jsx)(S,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:oe}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.needToken})]})]})})}export{Yt as AgentsSettingsPanel,Dt as i,G as n,K as r,Tn as t};
|
|
71
|
-
//# sourceMappingURL=agents-
|
|
71
|
+
//# sourceMappingURL=agents-BcLv59-r.js.map
|