@xopcai/xopc 0.0.55 → 0.0.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/extensions/telegram/xopc.extension.json +1 -1
  2. package/dist/gateway/static/root/assets/{agents-74EbWFJ1.js → agents-D6Suddtr.js} +2 -2
  3. package/dist/gateway/static/root/assets/{agents-74EbWFJ1.js.map → agents-D6Suddtr.js.map} +1 -1
  4. package/dist/gateway/static/root/assets/{apps-page-Drte0W-4.js → apps-page-Th-Hiuo-.js} +2 -2
  5. package/dist/gateway/static/root/assets/{apps-page-Drte0W-4.js.map → apps-page-Th-Hiuo-.js.map} +1 -1
  6. package/dist/gateway/static/root/assets/{channels-settings-JfEF7kEH.js → channels-settings-D1xRSJDZ.js} +2 -2
  7. package/dist/gateway/static/root/assets/{channels-settings-JfEF7kEH.js.map → channels-settings-D1xRSJDZ.js.map} +1 -1
  8. package/dist/gateway/static/root/assets/{cron-dreaming-jobs-BhOeOExN.js → cron-dreaming-jobs-3lVHkALf.js} +2 -2
  9. package/dist/gateway/static/root/assets/{cron-dreaming-jobs-BhOeOExN.js.map → cron-dreaming-jobs-3lVHkALf.js.map} +1 -1
  10. package/dist/gateway/static/root/assets/{cron-page-Cj2srMp3.js → cron-page-D7ngje2B.js} +2 -2
  11. package/dist/gateway/static/root/assets/{cron-page-Cj2srMp3.js.map → cron-page-D7ngje2B.js.map} +1 -1
  12. package/dist/gateway/static/root/assets/{dist-DSj9MpxJ.js → dist-zjjnuQDo.js} +2 -2
  13. package/dist/gateway/static/root/assets/{dist-DSj9MpxJ.js.map → dist-zjjnuQDo.js.map} +1 -1
  14. package/dist/gateway/static/root/assets/{extension-debug-page-B9dAkTLR.js → extension-debug-page-D1j5i5LL.js} +2 -2
  15. package/dist/gateway/static/root/assets/{extension-debug-page-B9dAkTLR.js.map → extension-debug-page-D1j5i5LL.js.map} +1 -1
  16. package/dist/gateway/static/root/assets/{extension-page-CosLqD45.js → extension-page-DFlhHkSt.js} +2 -2
  17. package/dist/gateway/static/root/assets/{extension-page-CosLqD45.js.map → extension-page-DFlhHkSt.js.map} +1 -1
  18. package/dist/gateway/static/root/assets/{extension-settings-page-BnJUuHga.js → extension-settings-page-BCa14gKB.js} +2 -2
  19. package/dist/gateway/static/root/assets/{extension-settings-page-BnJUuHga.js.map → extension-settings-page-BCa14gKB.js.map} +1 -1
  20. package/dist/gateway/static/root/assets/{heartbeat-config-api-DKiU0FSn.js → heartbeat-config-api-D_OCqL2O.js} +2 -2
  21. package/dist/gateway/static/root/assets/{heartbeat-config-api-DKiU0FSn.js.map → heartbeat-config-api-D_OCqL2O.js.map} +1 -1
  22. package/dist/gateway/static/root/assets/{index-B-L6DMBk.js → index-DzugsTKg.js} +4 -4
  23. package/dist/gateway/static/root/assets/{index-B-L6DMBk.js.map → index-DzugsTKg.js.map} +1 -1
  24. package/dist/gateway/static/root/assets/{logs-page-BVDgS2FD.js → logs-page-DlOnVTqZ.js} +2 -2
  25. package/dist/gateway/static/root/assets/{logs-page-BVDgS2FD.js.map → logs-page-DlOnVTqZ.js.map} +1 -1
  26. package/dist/gateway/static/root/assets/{sessions-page-C-OAYLwZ.js → sessions-page-CdvV35AY.js} +2 -2
  27. package/dist/gateway/static/root/assets/{sessions-page-C-OAYLwZ.js.map → sessions-page-CdvV35AY.js.map} +1 -1
  28. package/dist/gateway/static/root/assets/{settings-page-PgUZ4C2F.js → settings-page-DKWTjEWN.js} +2 -2
  29. package/dist/gateway/static/root/assets/{settings-page-PgUZ4C2F.js.map → settings-page-DKWTjEWN.js.map} +1 -1
  30. package/dist/gateway/static/root/assets/{skills-page-BJ4k9_us.js → skills-page-xq8DLd0E.js} +2 -2
  31. package/dist/gateway/static/root/assets/{skills-page-BJ4k9_us.js.map → skills-page-xq8DLd0E.js.map} +1 -1
  32. package/dist/gateway/static/root/assets/{use-image-provider-credentials-OhVruFpB.js → use-image-provider-credentials-DEpLWx8J.js} +2 -2
  33. package/dist/gateway/static/root/assets/{use-image-provider-credentials-OhVruFpB.js.map → use-image-provider-credentials-DEpLWx8J.js.map} +1 -1
  34. package/dist/gateway/static/root/index.html +1 -1
  35. package/dist/package.js +1 -1
  36. package/dist/src/agent/agent-manager.js.map +1 -1
  37. package/dist/src/agent/service.js.map +1 -1
  38. package/package.json +1 -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.55",
5
+ "version": "0.0.56",
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{i as r}from"./vendor-swr-B5fPo7KK.js";import{A as i,Ai as a,An as o,At as s,C as c,Ci as l,D as u,Dt as d,E as f,En as p,F as m,Gn as h,Hn as g,Hr as _,I as v,In as y,It as b,Kn as x,Ln as S,Lr as C,Lt as w,M as ee,Mr as T,Mt as E,N as D,Nt as O,O as k,Oi as te,On as A,Ot as ne,P as j,Q as M,Qn as re,Rn as N,Rt as ie,Sn as P,Sr as ae,St as oe,T as se,Ti as ce,Tr as le,Un as ue,Vn as de,Wn as F,Wr as fe,X as pe,Yr as me,Z as I,Zn as he,_i as ge,_n as _e,a as ve,ai as ye,at as be,br as xe,c as Se,ci as Ce,cr as L,ct as we,d as Te,er as Ee,fr as De,gn as Oe,gr as R,hn as z,hr as ke,ii as Ae,it as je,j as Me,jn as B,jr as Ne,jt as Pe,k as Fe,ki as Ie,kn as Le,kt as Re,l as ze,lr as Be,lt as Ve,mn as He,mr as Ue,nt as We,o as Ge,ot as Ke,pr as qe,qn as Je,qr as Ye,ri as Xe,rt as V,s as H,sr as U,st as W,ti as Ze,tr as Qe,tt as $e,u as et,un as G,w as tt,xn as nt,xt as rt,yi as it,yn as at,zn as ot,zr as st,zt as ct}from"./index-B-L6DMBk.js";import{a as lt,b as ut,d as dt,h as ft,r as pt,t as mt,u as ht}from"./cron-dreaming-jobs-BhOeOExN.js";var K=n();function gt({open:e,onOpenChange:t,busy:n,deletePurge:r,deleteTarget:i,deleteConfirmText:a,onDeleteConfirmTextChange:o,onConfirm:c,onCancel:l,a:u}){return(0,K.jsx)(E,{open:e,onOpenChange:t,children:(0,K.jsxs)(Pe,{children:[(0,K.jsx)(s,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,K.jsxs)(ne,{className:y(`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,K.jsx)(O,{className:`text-base font-semibold text-fg`,children:r?u.purgeDisk:u.removeFromConfig}),(0,K.jsx)(Re,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:r?u.confirmDeletePurge:u.confirmDelete}),r&&i?(0,K.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,K.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-fg`,htmlFor:`agent-delete-confirm`,children:u.purgeConfirmLabel}),(0,K.jsx)(`input`,{id:`agent-delete-confirm`,type:`text`,autoComplete:`off`,spellCheck:!1,className:y(`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:u.purgeConfirmPlaceholder.replace(`{{agentId}}`,i.id),value:a,onChange:e=>o(e.target.value)}),(0,K.jsx)(`p`,{className:`pt-0.5 text-xs text-fg-muted`,children:u.purgeConfirmHint.replace(`{{agentId}}`,i.id)})]}):null,(0,K.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle/60 pt-3`,children:[(0,K.jsx)(B,{type:`button`,variant:`ghost`,disabled:n,onClick:l,children:u.createModalCancel}),(0,K.jsx)(B,{type:`button`,variant:`secondary`,className:r?`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:n||!i||r&&a.trim().toLowerCase()!==i.id.toLowerCase(),onClick:c,children:r?u.purgeDisk:u.removeFromConfig})]})]})]})})}var _t=[{id:`overview`,labelKey:`navIdentity`,icon:de},{id:`profile`,labelKey:`navProfile`,icon:Ce},{id:`tools`,labelKey:`navTools`,icon:ot},{id:`skills`,labelKey:`navSkills`,icon:qe},{id:`files`,labelKey:`navCoreFiles`,icon:Ye}],vt=[{id:`channels`,labelKey:`tabChannels`,icon:ke},{id:`cron`,labelKey:`tabCron`,icon:ye}];function yt(e){let{a:t,panel:n,onPanelChange:r}=e,i=(e,t,i)=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:y(`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,K.jsx)(i,{className:`size-4 shrink-0 opacity-90`,strokeWidth:2,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`min-w-0 truncate`,children:t})]},e);return(0,K.jsxs)(`nav`,{className:`flex w-full flex-col gap-1`,"aria-label":t.editorNavAria,children:[(0,K.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:_t.map(({id:e,labelKey:n,icon:r})=>i(e,t[n],r))}),(0,K.jsx)(`p`,{className:`mt-4 px-3 text-[10px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.navAdvanced}),(0,K.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:vt.map(({id:e,labelKey:n,icon:r})=>i(e,t[n],r))})]})}function bt(e){let{open:t,onOpenChange:n,a:r,title:i,subtitle:a,panel:o,onPanelChange:c,onFooterSave:l,footerSaveDisabled:u,footerSavedFlash:f,busy:p,children:m}=e;return(0,K.jsx)(E,{open:t,onOpenChange:n,children:(0,K.jsxs)(Pe,{children:[(0,K.jsx)(s,{className:y(`xopc-dialog-overlay fixed inset-0 bg-scrim`,H)}),(0,K.jsxs)(ne,{className:y(`xopc-dialog-content fixed flex flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,Ge,`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,K.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,K.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,K.jsx)(O,{className:`text-base font-semibold leading-snug text-fg`,children:i}),(0,K.jsx)(Re,{className:`mt-1 font-mono text-xs text-fg-muted`,children:a})]}),(0,K.jsx)(d,{asChild:!0,children:(0,K.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,K.jsx)(N,{className:`size-4`,"aria-hidden":!0})})})]}),(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row sm:overflow-hidden`,children:[(0,K.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,K.jsx)(yt,{a:r,panel:o,onPanelChange:c})}),(0,K.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 sm:pl-2 sm:pr-5`,children:m}),(0,K.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:[f?(0,K.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]}):u?(0,K.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,K.jsx)(B,{type:`button`,className:`order-1 w-full sm:order-2 sm:w-auto`,disabled:p||u,onClick:()=>void l(),children:r.save})]})]})]})]})]})})}function xt(){return`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`}function q({children:e,className:t}){return(0,K.jsx)(`section`,{className:y(xt(),t),children:e})}var St=`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted transition-colors dark:bg-surface-hover/70`;function J({icon:e,title:t,subtitle:n,trailing:r,className:i,iconInteractive:a,iconLeading:o}){let s=o??(0,K.jsx)(e,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),c=o?y(`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel p-0 ring-1 ring-inset ring-edge-subtle transition-[box-shadow] hover:ring-accent/40 dark:ring-edge-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`):y(St,`hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),l=!!(a&&o);return(0,K.jsxs)(`div`,{className:y(`mb-5 flex items-start gap-3`,i),children:[a?l?(0,K.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,K.jsx)(`button`,{type:`button`,id:a.id,onClick:a.onClick,"aria-label":a.ariaLabel,className:c,children:s}),(0,K.jsx)(`span`,{className:`pointer-events-none absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-md border border-edge bg-surface-panel text-fg-muted shadow-sm dark:border-edge dark:bg-surface-base`,"aria-hidden":!0,children:(0,K.jsx)(xe,{className:`size-2.5`,strokeWidth:2.25})})]}):(0,K.jsx)(`button`,{type:`button`,id:a.id,onClick:a.onClick,"aria-label":a.ariaLabel,className:c,children:s}):(0,K.jsx)(`div`,{className:y(o?`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel ring-1 ring-inset ring-edge-subtle dark:ring-edge-subtle`:St),"aria-hidden":!o,children:s}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t}),(0,K.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n})]}),r?(0,K.jsx)(`div`,{className:`shrink-0`,children:r}):null]})}function Y(){return y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Le,`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}}var Et=y(A,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`);function Dt(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:b,selectRecipient:x}=e,S=!c&&(l||s.length>0);return(0,K.jsxs)(q,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,K.jsx)(J,{className:`shrink-0`,icon:Ne,title:t.channelsTitle,subtitle:t.channelsHint}),r?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsLoading}):i.length===0?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsNone}):(0,K.jsx)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:i.map((e,r)=>(0,K.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,K.jsx)(`span`,{className:`font-mono text-xs`,children:wt(e.match)}),(0,K.jsx)(B,{type:`button`,variant:`secondary`,disabled:n,onClick:()=>void a(e),children:t.removeBinding})]},`${e.match.channel}-${r}`))}),(0,K.jsxs)(`form`,{className:`mt-4 flex flex-col gap-3`,onSubmit:o,children:[c?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsLoadingChannels}):l?(0,K.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-fg-muted`,children:t.channelLabel}),(0,K.jsx)(`input`,{className:Y(),value:u,onChange:e=>d(e.target.value),placeholder:`telegram`,autoComplete:`off`}),(0,K.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsManualChannelHint})]}):(0,K.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-fg-muted`,children:t.channelLabel}),(0,K.jsx)(`select`,{className:y(Y(),`py-2`),value:u,onChange:e=>{d(e.target.value),h(null),_(``)},children:s.map(e=>(0,K.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:t.channelsDisabledSuffix]},e.name))})]}),S&&u.trim()?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-3 text-sm`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-fg-muted`,children:t.channelsSessionLabel}),(0,K.jsxs)(B,{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,K.jsx)(De,{className:y(`size-3.5`,p&&`animate-spin`),strokeWidth:1.75}),t.channelsRefreshSessions]})]}),p&&f.length===0?(0,K.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsLoadingSessions}):null,(0,K.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-fg-muted`,children:t.channelsPeerFromSessions}),(0,K.jsxs)(`select`,{className:y(Y(),`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,K.jsx)(`option`,{value:``,children:t.channelsPeerAny}),f.map((e,t)=>(0,K.jsx)(`option`,{value:String(t),children:ut(e,b)},`${e.channel}-${e.chatId}-${t}`))]})]}),f.length===0&&u.trim()&&!p?(0,K.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsNoSessionsHint}):null,(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-fg-muted`,children:t.peerIdLabel}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,className:y(Y(),`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,K.jsxs)(`select`,{className:Et,value:g,onChange:e=>{let t=e.target.value;_(t||``),h(null)},children:[(0,K.jsx)(`option`,{value:``,children:x}),f.map(e=>(0,K.jsx)(`option`,{value:e.chatId,children:ut(e,b)},`${e.channel}-${e.chatId}`))]})]}),(0,K.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsCustomPeerHint})]})]}):null,(0,K.jsx)(`div`,{children:(0,K.jsx)(B,{type:`submit`,disabled:n||!u.trim()||c,children:t.addBinding})})]})]})}function Ot(e){let{a:t,data:n,busy:r,cronLoading:i,agentCronJobs:a,onSetCronJobAgent:o}=e;return(0,K.jsxs)(q,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,K.jsx)(J,{className:`shrink-0`,icon:l,title:t.cronTitle,subtitle:t.cronHint}),i?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.cronLoading}):a.length===0?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.cronNone}):(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b border-edge text-fg-muted`,children:[(0,K.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColSchedule}),(0,K.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColMessage}),(0,K.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColSession}),(0,K.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColAgent})]})}),(0,K.jsx)(`tbody`,{children:a.map(e=>{let i=!e.agentId?.trim(),a=i?``:e.agentId.trim().toLowerCase();return(0,K.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,K.jsx)(`td`,{className:`py-2 pr-3 font-mono text-xs`,children:e.schedule}),(0,K.jsx)(`td`,{className:`max-w-[12rem] truncate py-2 pr-3 text-xs`,title:pt(e),children:pt(e)}),(0,K.jsx)(`td`,{className:`py-2 pr-3 text-xs`,children:e.sessionTarget??`main`}),(0,K.jsx)(`td`,{className:`py-2 pr-3`,children:(0,K.jsxs)(`select`,{className:y(Y(),`min-w-[8rem] py-1 text-xs`),value:a,disabled:r||e.sessionTarget!==`isolated`,onChange:t=>void o(e,t.target.value),children:[(0,K.jsx)(`option`,{value:``,children:i?t.cronAgentDefault:t.cronAgentClear}),n.agents.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.id},e.id))]})})]},e.id)})})]})})]})}function kt(e){let{a:t,filesLoading:n,files:r,activeFile:i,setActiveFile:a,filesViewMode:o,setFilesViewMode:s,fileDraft:c,setFileDraft:l,fileSaving:u,profileFileLoading:d,profileEditorNonce:f}=e,p=nt(e=>e.resolved===`dark`);return(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[(0,K.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesHint}),n?(0,K.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesLoading}):r?(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,K.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.navCoreFiles,children:r.files.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:y(`-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,K.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2 overflow-hidden`,children:i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-panel p-0.5`,role:`group`,"aria-label":`${t.filesMarkdownEdit} / ${t.filesMarkdownPreview}`,children:[(0,K.jsxs)(`button`,{type:`button`,className:y(`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,K.jsx)(he,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t.filesMarkdownEdit]}),(0,K.jsxs)(`button`,{type:`button`,className:y(`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,K.jsx)(me,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t.filesMarkdownPreview]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[u?(0,K.jsx)(`span`,{children:t.filesSavingStatus}):null,(0,K.jsx)(`span`,{children:t.filesAutoSaveHint})]})]}),o===`edit`?(0,K.jsx)(`div`,{className:y(Y(),`flex min-h-0 flex-1 flex-col overflow-hidden p-0`,d&&`pointer-events-none opacity-60`),children:(0,K.jsx)(I,{initialContent:c,onChange:l,isDark:p,className:`min-h-0 flex-1`},`${i??`file`}-${f}`)}):(0,K.jsx)(`div`,{className:y(Y(),`min-h-0 flex-1 overflow-y-auto text-sm`,d&&`pointer-events-none opacity-60`),children:(0,K.jsx)(pe,{content:c,className:`text-sm`})})]}):(0,K.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.pickFile})})]}):(0,K.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesEmpty})]})}var X=e(t(),1);function At(e,t){switch(e){case`adventurer`:return t.avatarStyleAdventurer;case`bottts`:return t.avatarStyleRobot;case`lorelei`:return t.avatarStyleLorelei;case`thumbs`:return t.avatarStyleThumbs;case`fun-emoji`:return t.avatarStyleFunEmoji;default:return e}}function jt(e){let{agentId:t,value:n,onChange:r,a:i,id:a}=e,o=(0,X.useRef)(null),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null),[d,p]=(0,X.useState)(!1),m=(0,X.useMemo)(()=>{let e=Ve(n.trim());return e&&we(e.styleId)?e.styleId:je[0]??`adventurer`},[n]),h=(0,X.useCallback)(async(e,n)=>{try{await f(t)}catch{}r(Ke(e,n)),p(!1)},[t,r]),g=(0,X.useCallback)(async e=>{let n=e.target.files?.[0];if(e.target.value=``,n){u(null),c(!0);try{await v(t,n),r(be)}catch(e){let t=e instanceof Error?e.message:``;u(t===`avatar_too_large`?i.avatarTooLarge:t===`unsupported_image_type`||t===`empty_file`?i.avatarInvalidImage:i.avatarUploadFailed)}finally{c(!1)}}},[i,t,r]),_=(e,t)=>{let r=Ve(n.trim());return!!(r&&r.styleId===e&&r.seed===t)};return(0,K.jsxs)(`div`,{...a?{id:a}:{},className:`flex flex-col gap-3 sm:col-span-2`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:i.avatarPickerTitle}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{ref:o,type:`file`,accept:`image/png,image/jpeg,image/webp,.png,.jpg,.jpeg,.webp`,className:`hidden`,onChange:e=>void g(e)}),(0,K.jsxs)(B,{type:`button`,variant:`secondary`,className:`gap-1.5 px-2.5 py-1.5 text-xs`,disabled:s,onClick:()=>o.current?.click(),children:[(0,K.jsx)(ue,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),s?i.avatarUploading:i.avatarUploadCustom]})]})]}),l?(0,K.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:l}):null,(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:je.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>void h(e,V[0]??t),className:y(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,m===e?`border-fg bg-fg text-surface-base`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),children:At(e,i)},e))}),(0,K.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel/50 p-3`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[V.map(e=>(0,K.jsx)(`button`,{type:`button`,title:e,onClick:()=>void h(m,e),className:y(`flex size-12 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,_(m,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,K.jsx)(`img`,{src:W(m,e,96),alt:``,width:44,height:44,className:`size-11 rounded-full object-cover`,draggable:!1})},e)),(0,K.jsxs)(ie,{open:d,onOpenChange:p,children:[(0,K.jsx)(ct,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,className:`flex size-12 shrink-0 items-center justify-center rounded-xl border border-edge-subtle bg-surface-base text-xs font-medium text-fg-muted hover:border-edge hover:text-fg`,children:i.avatarMore})}),(0,K.jsx)(w,{children:(0,K.jsxs)(b,{className:`z-[80] max-h-72 w-[min(22rem,calc(100vw-2rem))] overflow-y-auto rounded-xl border border-edge-subtle bg-surface-panel p-3 shadow-lg`,sideOffset:6,align:`end`,children:[(0,K.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:At(m,i)}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:We.map(e=>(0,K.jsx)(`button`,{type:`button`,title:e,onClick:()=>void h(m,e),className:y(`flex size-11 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,_(m,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,K.jsx)(`img`,{src:W(m,e,88),alt:``,width:40,height:40,className:`size-10 rounded-full object-cover`,draggable:!1})},e))})]})})]})]}),(0,K.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t border-edge-subtle pt-3`,children:[(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i.personaAvatar}),(0,K.jsx)($e,{agentId:t,avatar:n,size:40}),n.trim()&&!Ve(n.trim())&&n.trim()!==`xopc:custom`?(0,K.jsx)(`span`,{className:`truncate font-mono text-[10px] text-fg-muted`,title:n,children:n}):null]})]})]})}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{i as r}from"./vendor-swr-B5fPo7KK.js";import{A as i,Ai as a,An as o,At as s,C as c,Ci as l,D as u,Dt as d,E as f,En as p,F as m,Gn as h,Hn as g,Hr as _,I as v,In as y,It as b,Kn as x,Ln as S,Lr as C,Lt as w,M as ee,Mr as T,Mt as E,N as D,Nt as O,O as k,Oi as te,On as A,Ot as ne,P as j,Q as M,Qn as re,Rn as N,Rt as ie,Sn as P,Sr as ae,St as oe,T as se,Ti as ce,Tr as le,Un as ue,Vn as de,Wn as F,Wr as fe,X as pe,Yr as me,Z as I,Zn as he,_i as ge,_n as _e,a as ve,ai as ye,at as be,br as xe,c as Se,ci as Ce,cr as L,ct as we,d as Te,er as Ee,fr as De,gn as Oe,gr as R,hn as z,hr as ke,ii as Ae,it as je,j as Me,jn as B,jr as Ne,jt as Pe,k as Fe,ki as Ie,kn as Le,kt as Re,l as ze,lr as Be,lt as Ve,mn as He,mr as Ue,nt as We,o as Ge,ot as Ke,pr as qe,qn as Je,qr as Ye,ri as Xe,rt as V,s as H,sr as U,st as W,ti as Ze,tr as Qe,tt as $e,u as et,un as G,w as tt,xn as nt,xt as rt,yi as it,yn as at,zn as ot,zr as st,zt as ct}from"./index-DzugsTKg.js";import{a as lt,b as ut,d as dt,h as ft,r as pt,t as mt,u as ht}from"./cron-dreaming-jobs-3lVHkALf.js";var K=n();function gt({open:e,onOpenChange:t,busy:n,deletePurge:r,deleteTarget:i,deleteConfirmText:a,onDeleteConfirmTextChange:o,onConfirm:c,onCancel:l,a:u}){return(0,K.jsx)(E,{open:e,onOpenChange:t,children:(0,K.jsxs)(Pe,{children:[(0,K.jsx)(s,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,K.jsxs)(ne,{className:y(`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,K.jsx)(O,{className:`text-base font-semibold text-fg`,children:r?u.purgeDisk:u.removeFromConfig}),(0,K.jsx)(Re,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:r?u.confirmDeletePurge:u.confirmDelete}),r&&i?(0,K.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,K.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-fg`,htmlFor:`agent-delete-confirm`,children:u.purgeConfirmLabel}),(0,K.jsx)(`input`,{id:`agent-delete-confirm`,type:`text`,autoComplete:`off`,spellCheck:!1,className:y(`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:u.purgeConfirmPlaceholder.replace(`{{agentId}}`,i.id),value:a,onChange:e=>o(e.target.value)}),(0,K.jsx)(`p`,{className:`pt-0.5 text-xs text-fg-muted`,children:u.purgeConfirmHint.replace(`{{agentId}}`,i.id)})]}):null,(0,K.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle/60 pt-3`,children:[(0,K.jsx)(B,{type:`button`,variant:`ghost`,disabled:n,onClick:l,children:u.createModalCancel}),(0,K.jsx)(B,{type:`button`,variant:`secondary`,className:r?`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:n||!i||r&&a.trim().toLowerCase()!==i.id.toLowerCase(),onClick:c,children:r?u.purgeDisk:u.removeFromConfig})]})]})]})})}var _t=[{id:`overview`,labelKey:`navIdentity`,icon:de},{id:`profile`,labelKey:`navProfile`,icon:Ce},{id:`tools`,labelKey:`navTools`,icon:ot},{id:`skills`,labelKey:`navSkills`,icon:qe},{id:`files`,labelKey:`navCoreFiles`,icon:Ye}],vt=[{id:`channels`,labelKey:`tabChannels`,icon:ke},{id:`cron`,labelKey:`tabCron`,icon:ye}];function yt(e){let{a:t,panel:n,onPanelChange:r}=e,i=(e,t,i)=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:y(`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,K.jsx)(i,{className:`size-4 shrink-0 opacity-90`,strokeWidth:2,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`min-w-0 truncate`,children:t})]},e);return(0,K.jsxs)(`nav`,{className:`flex w-full flex-col gap-1`,"aria-label":t.editorNavAria,children:[(0,K.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:_t.map(({id:e,labelKey:n,icon:r})=>i(e,t[n],r))}),(0,K.jsx)(`p`,{className:`mt-4 px-3 text-[10px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.navAdvanced}),(0,K.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:vt.map(({id:e,labelKey:n,icon:r})=>i(e,t[n],r))})]})}function bt(e){let{open:t,onOpenChange:n,a:r,title:i,subtitle:a,panel:o,onPanelChange:c,onFooterSave:l,footerSaveDisabled:u,footerSavedFlash:f,busy:p,children:m}=e;return(0,K.jsx)(E,{open:t,onOpenChange:n,children:(0,K.jsxs)(Pe,{children:[(0,K.jsx)(s,{className:y(`xopc-dialog-overlay fixed inset-0 bg-scrim`,H)}),(0,K.jsxs)(ne,{className:y(`xopc-dialog-content fixed flex flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,Ge,`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,K.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,K.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,K.jsx)(O,{className:`text-base font-semibold leading-snug text-fg`,children:i}),(0,K.jsx)(Re,{className:`mt-1 font-mono text-xs text-fg-muted`,children:a})]}),(0,K.jsx)(d,{asChild:!0,children:(0,K.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,K.jsx)(N,{className:`size-4`,"aria-hidden":!0})})})]}),(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row sm:overflow-hidden`,children:[(0,K.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,K.jsx)(yt,{a:r,panel:o,onPanelChange:c})}),(0,K.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 sm:pl-2 sm:pr-5`,children:m}),(0,K.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:[f?(0,K.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]}):u?(0,K.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,K.jsx)(B,{type:`button`,className:`order-1 w-full sm:order-2 sm:w-auto`,disabled:p||u,onClick:()=>void l(),children:r.save})]})]})]})]})]})})}function xt(){return`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`}function q({children:e,className:t}){return(0,K.jsx)(`section`,{className:y(xt(),t),children:e})}var St=`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted transition-colors dark:bg-surface-hover/70`;function J({icon:e,title:t,subtitle:n,trailing:r,className:i,iconInteractive:a,iconLeading:o}){let s=o??(0,K.jsx)(e,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),c=o?y(`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel p-0 ring-1 ring-inset ring-edge-subtle transition-[box-shadow] hover:ring-accent/40 dark:ring-edge-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`):y(St,`hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),l=!!(a&&o);return(0,K.jsxs)(`div`,{className:y(`mb-5 flex items-start gap-3`,i),children:[a?l?(0,K.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,K.jsx)(`button`,{type:`button`,id:a.id,onClick:a.onClick,"aria-label":a.ariaLabel,className:c,children:s}),(0,K.jsx)(`span`,{className:`pointer-events-none absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-md border border-edge bg-surface-panel text-fg-muted shadow-sm dark:border-edge dark:bg-surface-base`,"aria-hidden":!0,children:(0,K.jsx)(xe,{className:`size-2.5`,strokeWidth:2.25})})]}):(0,K.jsx)(`button`,{type:`button`,id:a.id,onClick:a.onClick,"aria-label":a.ariaLabel,className:c,children:s}):(0,K.jsx)(`div`,{className:y(o?`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel ring-1 ring-inset ring-edge-subtle dark:ring-edge-subtle`:St),"aria-hidden":!o,children:s}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t}),(0,K.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n})]}),r?(0,K.jsx)(`div`,{className:`shrink-0`,children:r}):null]})}function Y(){return y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Le,`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}}var Et=y(A,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`);function Dt(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:b,selectRecipient:x}=e,S=!c&&(l||s.length>0);return(0,K.jsxs)(q,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,K.jsx)(J,{className:`shrink-0`,icon:Ne,title:t.channelsTitle,subtitle:t.channelsHint}),r?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsLoading}):i.length===0?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsNone}):(0,K.jsx)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:i.map((e,r)=>(0,K.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,K.jsx)(`span`,{className:`font-mono text-xs`,children:wt(e.match)}),(0,K.jsx)(B,{type:`button`,variant:`secondary`,disabled:n,onClick:()=>void a(e),children:t.removeBinding})]},`${e.match.channel}-${r}`))}),(0,K.jsxs)(`form`,{className:`mt-4 flex flex-col gap-3`,onSubmit:o,children:[c?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsLoadingChannels}):l?(0,K.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-fg-muted`,children:t.channelLabel}),(0,K.jsx)(`input`,{className:Y(),value:u,onChange:e=>d(e.target.value),placeholder:`telegram`,autoComplete:`off`}),(0,K.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsManualChannelHint})]}):(0,K.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-fg-muted`,children:t.channelLabel}),(0,K.jsx)(`select`,{className:y(Y(),`py-2`),value:u,onChange:e=>{d(e.target.value),h(null),_(``)},children:s.map(e=>(0,K.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:t.channelsDisabledSuffix]},e.name))})]}),S&&u.trim()?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-3 text-sm`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-fg-muted`,children:t.channelsSessionLabel}),(0,K.jsxs)(B,{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,K.jsx)(De,{className:y(`size-3.5`,p&&`animate-spin`),strokeWidth:1.75}),t.channelsRefreshSessions]})]}),p&&f.length===0?(0,K.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsLoadingSessions}):null,(0,K.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-fg-muted`,children:t.channelsPeerFromSessions}),(0,K.jsxs)(`select`,{className:y(Y(),`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,K.jsx)(`option`,{value:``,children:t.channelsPeerAny}),f.map((e,t)=>(0,K.jsx)(`option`,{value:String(t),children:ut(e,b)},`${e.channel}-${e.chatId}-${t}`))]})]}),f.length===0&&u.trim()&&!p?(0,K.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsNoSessionsHint}):null,(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-fg-muted`,children:t.peerIdLabel}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,className:y(Y(),`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,K.jsxs)(`select`,{className:Et,value:g,onChange:e=>{let t=e.target.value;_(t||``),h(null)},children:[(0,K.jsx)(`option`,{value:``,children:x}),f.map(e=>(0,K.jsx)(`option`,{value:e.chatId,children:ut(e,b)},`${e.channel}-${e.chatId}`))]})]}),(0,K.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsCustomPeerHint})]})]}):null,(0,K.jsx)(`div`,{children:(0,K.jsx)(B,{type:`submit`,disabled:n||!u.trim()||c,children:t.addBinding})})]})]})}function Ot(e){let{a:t,data:n,busy:r,cronLoading:i,agentCronJobs:a,onSetCronJobAgent:o}=e;return(0,K.jsxs)(q,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,K.jsx)(J,{className:`shrink-0`,icon:l,title:t.cronTitle,subtitle:t.cronHint}),i?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.cronLoading}):a.length===0?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.cronNone}):(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b border-edge text-fg-muted`,children:[(0,K.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColSchedule}),(0,K.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColMessage}),(0,K.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColSession}),(0,K.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColAgent})]})}),(0,K.jsx)(`tbody`,{children:a.map(e=>{let i=!e.agentId?.trim(),a=i?``:e.agentId.trim().toLowerCase();return(0,K.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,K.jsx)(`td`,{className:`py-2 pr-3 font-mono text-xs`,children:e.schedule}),(0,K.jsx)(`td`,{className:`max-w-[12rem] truncate py-2 pr-3 text-xs`,title:pt(e),children:pt(e)}),(0,K.jsx)(`td`,{className:`py-2 pr-3 text-xs`,children:e.sessionTarget??`main`}),(0,K.jsx)(`td`,{className:`py-2 pr-3`,children:(0,K.jsxs)(`select`,{className:y(Y(),`min-w-[8rem] py-1 text-xs`),value:a,disabled:r||e.sessionTarget!==`isolated`,onChange:t=>void o(e,t.target.value),children:[(0,K.jsx)(`option`,{value:``,children:i?t.cronAgentDefault:t.cronAgentClear}),n.agents.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.id},e.id))]})})]},e.id)})})]})})]})}function kt(e){let{a:t,filesLoading:n,files:r,activeFile:i,setActiveFile:a,filesViewMode:o,setFilesViewMode:s,fileDraft:c,setFileDraft:l,fileSaving:u,profileFileLoading:d,profileEditorNonce:f}=e,p=nt(e=>e.resolved===`dark`);return(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[(0,K.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesHint}),n?(0,K.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesLoading}):r?(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,K.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.navCoreFiles,children:r.files.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:y(`-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,K.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2 overflow-hidden`,children:i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-panel p-0.5`,role:`group`,"aria-label":`${t.filesMarkdownEdit} / ${t.filesMarkdownPreview}`,children:[(0,K.jsxs)(`button`,{type:`button`,className:y(`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,K.jsx)(he,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t.filesMarkdownEdit]}),(0,K.jsxs)(`button`,{type:`button`,className:y(`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,K.jsx)(me,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t.filesMarkdownPreview]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[u?(0,K.jsx)(`span`,{children:t.filesSavingStatus}):null,(0,K.jsx)(`span`,{children:t.filesAutoSaveHint})]})]}),o===`edit`?(0,K.jsx)(`div`,{className:y(Y(),`flex min-h-0 flex-1 flex-col overflow-hidden p-0`,d&&`pointer-events-none opacity-60`),children:(0,K.jsx)(I,{initialContent:c,onChange:l,isDark:p,className:`min-h-0 flex-1`},`${i??`file`}-${f}`)}):(0,K.jsx)(`div`,{className:y(Y(),`min-h-0 flex-1 overflow-y-auto text-sm`,d&&`pointer-events-none opacity-60`),children:(0,K.jsx)(pe,{content:c,className:`text-sm`})})]}):(0,K.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.pickFile})})]}):(0,K.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesEmpty})]})}var X=e(t(),1);function At(e,t){switch(e){case`adventurer`:return t.avatarStyleAdventurer;case`bottts`:return t.avatarStyleRobot;case`lorelei`:return t.avatarStyleLorelei;case`thumbs`:return t.avatarStyleThumbs;case`fun-emoji`:return t.avatarStyleFunEmoji;default:return e}}function jt(e){let{agentId:t,value:n,onChange:r,a:i,id:a}=e,o=(0,X.useRef)(null),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null),[d,p]=(0,X.useState)(!1),m=(0,X.useMemo)(()=>{let e=Ve(n.trim());return e&&we(e.styleId)?e.styleId:je[0]??`adventurer`},[n]),h=(0,X.useCallback)(async(e,n)=>{try{await f(t)}catch{}r(Ke(e,n)),p(!1)},[t,r]),g=(0,X.useCallback)(async e=>{let n=e.target.files?.[0];if(e.target.value=``,n){u(null),c(!0);try{await v(t,n),r(be)}catch(e){let t=e instanceof Error?e.message:``;u(t===`avatar_too_large`?i.avatarTooLarge:t===`unsupported_image_type`||t===`empty_file`?i.avatarInvalidImage:i.avatarUploadFailed)}finally{c(!1)}}},[i,t,r]),_=(e,t)=>{let r=Ve(n.trim());return!!(r&&r.styleId===e&&r.seed===t)};return(0,K.jsxs)(`div`,{...a?{id:a}:{},className:`flex flex-col gap-3 sm:col-span-2`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:i.avatarPickerTitle}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{ref:o,type:`file`,accept:`image/png,image/jpeg,image/webp,.png,.jpg,.jpeg,.webp`,className:`hidden`,onChange:e=>void g(e)}),(0,K.jsxs)(B,{type:`button`,variant:`secondary`,className:`gap-1.5 px-2.5 py-1.5 text-xs`,disabled:s,onClick:()=>o.current?.click(),children:[(0,K.jsx)(ue,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),s?i.avatarUploading:i.avatarUploadCustom]})]})]}),l?(0,K.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:l}):null,(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:je.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>void h(e,V[0]??t),className:y(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,m===e?`border-fg bg-fg text-surface-base`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),children:At(e,i)},e))}),(0,K.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel/50 p-3`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[V.map(e=>(0,K.jsx)(`button`,{type:`button`,title:e,onClick:()=>void h(m,e),className:y(`flex size-12 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,_(m,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,K.jsx)(`img`,{src:W(m,e,96),alt:``,width:44,height:44,className:`size-11 rounded-full object-cover`,draggable:!1})},e)),(0,K.jsxs)(ie,{open:d,onOpenChange:p,children:[(0,K.jsx)(ct,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,className:`flex size-12 shrink-0 items-center justify-center rounded-xl border border-edge-subtle bg-surface-base text-xs font-medium text-fg-muted hover:border-edge hover:text-fg`,children:i.avatarMore})}),(0,K.jsx)(w,{children:(0,K.jsxs)(b,{className:`z-[80] max-h-72 w-[min(22rem,calc(100vw-2rem))] overflow-y-auto rounded-xl border border-edge-subtle bg-surface-panel p-3 shadow-lg`,sideOffset:6,align:`end`,children:[(0,K.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:At(m,i)}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:We.map(e=>(0,K.jsx)(`button`,{type:`button`,title:e,onClick:()=>void h(m,e),className:y(`flex size-11 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,_(m,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,K.jsx)(`img`,{src:W(m,e,88),alt:``,width:40,height:40,className:`size-10 rounded-full object-cover`,draggable:!1})},e))})]})})]})]}),(0,K.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t border-edge-subtle pt-3`,children:[(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i.personaAvatar}),(0,K.jsx)($e,{agentId:t,avatar:n,size:40}),n.trim()&&!Ve(n.trim())&&n.trim()!==`xopc:custom`?(0,K.jsx)(`span`,{className:`truncate font-mono text-[10px] text-fg-muted`,title:n,children:n}):null]})]})]})}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(`
@@ -213,4 +213,4 @@ Analytical, clear, and methodical. Like a good data scientist — lets the numbe
213
213
 
214
214
  Bold, aesthetic, and thoughtful. Like a creative director who has opinions but listens — pushes for better while respecting what the client actually needs.
215
215
  `}];function mn({existingAgentIds:e,onComplete:t,onSkip:n}){let r=P(e=>e.language),i=o(r).agentsSettings,a=(0,X.useMemo)(()=>pn.filter(t=>!e.has(t.id)),[e]),[s,c]=(0,X.useState)(()=>new Set(pn.map(e=>e.id))),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(null),[p,h]=(0,X.useState)(null);(0,X.useEffect)(()=>{a.length===0&&t()},[a,t]);let g=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},_=async()=>{let e=a.filter(e=>s.has(e.id));if(e.length===0){t();return}u(!0),h(null),f({current:0,total:e.length});for(let t=0;t<e.length;t++){let n=e[t];f({current:t+1,total:e.length});try{await se({name:n.name,id:n.id,workspace:`~/.xopc/workspace/${n.id}`,description:r===`zh`?n.descriptionZh:n.descriptionEn}),await j(n.id,`IDENTITY.md`,n.identityMd),await j(n.id,`SOUL.md`,n.soulMd);let e=n.toolsDisable;e&&e.length>0&&await m(n.id,{toolsDisable:e})}catch(e){let t=e instanceof Error?e.message:String(e);if(t.toLowerCase().includes(`already exists`))continue;h(i.presetCreateFailed.replace(`{{name}}`,n.name).replace(`{{message}}`,t)),u(!1);return}}u(!1),t()};return a.length===0?null:(0,K.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col items-center gap-6 px-4 py-12`,children:[(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsxs)(`div`,{className:`mb-3 inline-flex items-center gap-2 rounded-full bg-accent/10 px-3 py-1.5 text-sm font-medium text-accent`,children:[(0,K.jsx)(re,{className:`size-4`,"aria-hidden":!0}),i.presetSetupBadge]}),(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-fg`,children:i.presetSetupTitle}),(0,K.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:i.presetSetupSubtitle})]}),(0,K.jsx)(`div`,{className:`w-full space-y-3`,children:a.map(e=>(0,K.jsx)(hn,{preset:e,checked:s.has(e.id),disabled:l,language:r,onToggle:()=>g(e.id)},e.id))}),p?(0,K.jsx)(`div`,{role:`alert`,className:`w-full 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:p}):null,d&&l?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.presetCreatingProgress.replace(`{{current}}`,String(d.current)).replace(`{{total}}`,String(d.total))}):null,(0,K.jsxs)(`div`,{className:`flex w-full items-center justify-between border-t border-edge-subtle pt-4`,children:[(0,K.jsxs)(B,{type:`button`,variant:`ghost`,className:`gap-2 text-fg-muted`,disabled:l,onClick:()=>{localStorage.setItem(fn,`true`),n()},children:[(0,K.jsx)(Qe,{className:`size-4`,"aria-hidden":!0}),i.presetSkip]}),(0,K.jsxs)(B,{type:`button`,variant:`primary`,className:`gap-2`,disabled:l||s.size===0,onClick:()=>void _(),children:[(0,K.jsx)(re,{className:`size-4`,"aria-hidden":!0}),l?i.presetCreating:i.presetCreateSelected.replace(`{{count}}`,String(s.size))]})]})]})}function hn(e){let{preset:t,checked:n,disabled:r,language:i,onToggle:a}=e,o=i===`zh`?t.descriptionZh:t.descriptionEn;return(0,K.jsxs)(`label`,{className:y(`flex cursor-pointer items-start gap-3 rounded-xl border px-4 py-3 transition-colors`,n?`border-accent/50 bg-accent/5`:`border-edge-subtle bg-surface-panel/40`,r&&`pointer-events-none opacity-50`),children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:n,disabled:r,onChange:a,className:`mt-1 shrink-0 accent-accent`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:t.emoji}),(0,K.jsx)(`span`,{className:`font-medium text-fg`,children:t.name})]}),(0,K.jsx)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:o})]})]})}var gn=`main`,_n=/^[a-z0-9][a-z0-9_-]{0,63}$/i,vn=/[^a-z0-9_-]+/g,yn=/^-+/,bn=/-+$/,xn=/^[a-z0-9][a-z0-9_-]{0,63}$/,Sn=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 Cn(e){let t=e.trim();if(!t)return gn;let n=t.toLowerCase();return _n.test(t)?n:n.replace(vn,`-`).replace(yn,``).replace(bn,``).slice(0,64)||gn}function wn(e,t){let n=e?.trim();if(n){let e=n.toLowerCase();return xn.test(e)?e===gn?{ok:!1,error:`"${gn}" is reserved`}:Sn.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=Cn(t.trim());return r===gn?{ok:!1,error:`Display name cannot produce a valid agent folder id. Set an explicit Agent id (letters, digits, underscores, hyphens only).`}:Sn.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.`}:xn.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 Tn(e){let t=e.trim();return t?`~/.xopc/workspace/${Cn(t)}`:``}function En(){return G(`/api/dreaming`)}async function Dn(){let e=await z(En());if(!e.payload)throw Error(`Missing payload`);return e.payload}async function On(e){await z(G(`/api/dreaming/action`),{method:`POST`,body:JSON.stringify({action:e})})}async function kn(e=`deep`){let t=await z(G(`/api/dreaming/run`),{method:`POST`,body:JSON.stringify({phase:e})}),n=!!t.payload?.triggered,r=typeof t.payload?.jobId==`string`?t.payload.jobId:``;if(!n||!r)throw Error(`Failed to trigger`);return{triggered:n,jobId:r,phase:e}}async function An(e){let t=await z(G(`/api/dreaming/preview${typeof e==`number`&&Number.isFinite(e)?`?limit=${encodeURIComponent(String(e))}`:``}`));if(!t.payload)throw Error(`Missing payload`);return t.payload}async function jn(e=50){return(await z(G(`/api/dreaming/events${`?limit=${encodeURIComponent(String(e))}`}`))).payload?.events??[]}function Mn({language:e,a:t,busy:n,sleeping:r,listSearchQuery:i,onListSearchQueryChange:a,onSleep:o,onAddAgent:s}){return(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[(0,K.jsxs)(B,{type:`button`,variant:`secondary`,className:`shrink-0 gap-2`,disabled:n||r,onClick:()=>void o(),"aria-label":e===`zh`?`让智能体进入睡眠流程`:`Trigger agent sleep sequence`,title:e===`zh`?`由浅入深:Light → Deep → REM`:`Light → Deep → REM`,children:[(0,K.jsx)(ae,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),e===`zh`?r?`睡眠中…`:`睡眠`:r?`Sleeping…`:`Sleep`]}),(0,K.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,K.jsx)(U,{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,K.jsx)(`input`,{type:`search`,role:`searchbox`,enterKeyHint:`search`,value:i,onChange:e=>a(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,K.jsxs)(B,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":t.addAgentAria,disabled:n,onClick:()=>s(),children:[(0,K.jsx)(Ue,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t.addAgent]})]})}function Nn(e){let{panel:t,selectedId:n,hasToken:r,dataAgentsLength:i,saveErrorMessage:a,setError:o}=e,[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(`edit`),[y,b]=(0,X.useState)(!1),[x,S]=(0,X.useState)(0),C=(0,X.useRef)(p);C.current=p;let w=(0,X.useRef)(n);w.current=n;let ee=(0,X.useRef)(d);ee.current=d;let T=(0,X.useRef)(null),E=(0,X.useRef)(``),D=(0,X.useRef)(``),O=M(async()=>{let e=w.current,t=ee.current;if(!e||!t||`${e}:${t}`!==E.current)return;let n=C.current;if(n!==D.current){g(!0),o(null);try{await j(e,t,n),D.current=n,c(n=>!n||n.agentId!==e?n:{...n,files:n.files.map(e=>e.name===t?{...e,missing:!1}:e)})}catch(e){o(e instanceof Error?e.message:a)}finally{g(!1)}}},800),te=(0,X.useRef)(O.flush);return te.current=O.flush,(0,X.useEffect)(()=>()=>{te.current()},[]),(0,X.useEffect)(()=>{if(t!==`files`||!n||!r)return;let e=!1;return u(!0),Fe(n).then(t=>{e||c(t)}).catch(()=>{e||c(null)}).finally(()=>{e||u(!1)}),()=>{e=!0}},[t,n,r,i]),(0,X.useEffect)(()=>{if(!d||!n||!r)return;let e=!1;return O.flush(),b(!0),k(n,d).then(t=>{e||(E.current=`${n}:${d}`,D.current=t,m(t),S(e=>e+1))}).catch(()=>{e||(E.current=`${n}:${d}`,D.current=``,m(``),S(e=>e+1))}).finally(()=>{e||b(!1)}),()=>{e=!0}},[d,n,r,O]),(0,X.useEffect)(()=>{!d||!n||y||O()},[p,d,n,y,O]),(0,X.useEffect)(()=>{if(t===`files`)return()=>{O.flush()}},[t,O]),(0,X.useEffect)(()=>{v(`edit`)},[d,n]),{files:s,setFiles:c,filesLoading:l,activeFile:d,setActiveFile:f,fileDraft:p,setFileDraft:m,fileSaving:h,filesViewMode:_,setFilesViewMode:v,profileFileLoading:y,profileEditorNonce:x,overviewSaveProfileMarkdownRef:T,saveProfileMarkdownDebounced:O}}function Pn(e){let{panel:t,hasToken:n,bindingsFromConfig:r,gatewayCfgLoading:i,selected:a,saveErrorMessage:o,setBusy:s,setError:c}=e,[l,u]=(0,X.useState)([]),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)([]),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)([]),[y,b]=(0,X.useState)(!1),[x,S]=(0,X.useState)(null),[C,w]=(0,X.useState)(``),ee=(0,X.useMemo)(()=>a?l.filter(e=>e.agentId.toLowerCase()===a.id.toLowerCase()):[],[l,a?.id]);(0,X.useEffect)(()=>{t!==`channels`||!n||u(r)},[t,n,r]),(0,X.useEffect)(()=>{if(t!==`channels`||!n)return;let e=!1;return g(!0),lt().then(t=>{e||m(t)}).catch(()=>{e||m([])}).finally(()=>{e||g(!1)}),()=>{e=!0}},[t,n]),(0,X.useEffect)(()=>{h||t!==`channels`||p.length===0||f(e=>e&&p.some(t=>t.name===e)?e:p[0].name)},[h,t,p]),(0,X.useEffect)(()=>{if(t!==`channels`||!n)return;let e=d.trim();if(!e){v([]);return}let r=!1;return S(null),b(!0),ht(e).then(e=>{r||v(e)}).catch(()=>{r||v([])}).finally(()=>{r||b(!1)}),()=>{r=!0}},[t,n,d]);let T=(0,X.useCallback)(()=>{let e=d.trim();e&&(b(!0),ht(e).then(e=>{v(e),S(t=>t!=null&&t<e.length?t:null)}).catch(()=>{v([]),S(null)}).finally(()=>{b(!1)}))},[d]),E=!h&&p.length===0,O=t===`channels`&&n&&i,k=(0,X.useCallback)(async e=>{s(!0),c(null);try{let t=l.filter(t=>t!==e);await D(t),u(t)}catch(e){c(e instanceof Error?e.message:o)}finally{s(!1)}},[l,o,s,c]);return{agentBindings:ee,allBindings:l,bindChannelStatuses:p,bindChannelsLoading:h,bindSessionChats:_,bindSessionsLoading:y,bindingsLoading:O,newBindChannel:d,setNewBindChannel:f,newBindSessionIdx:x,setNewBindSessionIdx:S,newBindCustomPeer:C,setNewBindCustomPeer:w,onAddBinding:(0,X.useCallback)(async e=>{if(e.preventDefault(),!a||!d.trim())return;let t=Tt(d,C,x,_),n=[...l,{agentId:a.id,priority:100,enabled:!0,match:t}];s(!0),c(null);try{await D(n),u(n),S(null),w(``)}catch(e){c(e instanceof Error?e.message:o)}finally{s(!1)}},[l,_,d,C,x,o,a,s,c]),onRemoveBinding:k,refreshBindSessions:T,useManualChannel:E}}function Fn(e){let{panel:t,hasToken:n,data:r,selected:i,saveErrorMessage:a,setBusy:o,setError:s}=e,[c,l]=(0,X.useState)([]),[u,d]=(0,X.useState)(!1),f=(0,X.useMemo)(()=>!r||!i?[]:c.filter(e=>!mt(e)&&Ct(e,i.id,r.defaultId)),[c,r,i]);(0,X.useEffect)(()=>{if(t!==`cron`||!n)return;let e=!1;return d(!0),dt().then(t=>{e||l(t)}).catch(()=>{e||l([])}).finally(()=>{e||d(!1)}),()=>{e=!0}},[t,n]);async function p(e,t){o(!0),s(null);try{await ft(e.id,{agentId:t===``?null:t}),l(await dt())}catch(e){s(e instanceof Error?e.message:a)}finally{o(!1)}}return{agentCronJobs:f,cronJobs:c,cronLoading:u,onSetCronJobAgent:p}}function In(e,t){let[n,r]=(0,X.useState)([]),[i,a]=(0,X.useState)(!1),o=(0,X.useMemo)(()=>n.filter(e=>e.enabled!==!1),[n]);return(0,X.useEffect)(()=>{if(!e||!t)return;let n=!1;return a(!0),Me().then(e=>{n||r(e)}).catch(()=>{n||r([])}).finally(()=>{n||a(!1)}),()=>{n=!0}},[e,t]),{catalogForPick:o,skillCatalog:n,skillsCatalogLoading:i}}function Ln(e){return In(e.panel===`skills`,e.hasToken)}function Rn(e){let{panel:t,selected:n}=e,[r,i]=(0,X.useState)(()=>new Set),[a,o]=(0,X.useState)(()=>new Set),[s,c]=(0,X.useState)(!0);return(0,X.useEffect)(()=>{!n||t!==`tools`||i(new Set(n.tools.entryDisable))},[t,n]),(0,X.useEffect)(()=>{if(!n||t!==`skills`)return;let e=n.skills.entry===void 0;if(c(e),e){let e=n.skills.effectiveAllowlist;o(new Set(e??[]))}else o(new Set(n.skills.entry??[]))},[t,n]),{toolEntryDisable:r,setToolEntryDisable:i,skillsPick:a,setSkillsPick:o,skillsInherit:s,setSkillsInherit:c}}function zn(){let e=P(e=>e.language),t=o(e),n=t.agentsSettings,[s,c]=(0,X.useState)(!1),[l,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(!1),[h,g]=(0,X.useState)(``),_=t.cron,v=t.chat,y=!!_e(e=>e.token),[b,x]=a(),S=te(),{agentId:C}=Ie(),w=Oe(e=>e.setPageHeader),T=Oe(e=>e.clearPageHeader),{data:E,error:D,isLoading:O,mutate:k}=r(y?`settings-gateway-agents`:null,i,{revalidateOnFocus:!1}),{data:A}=oe(y),ne=(0,X.useMemo)(()=>ee(A?.payload?.config??{}),[A]),j=E??null,M=!!(y&&O),[re,N]=(0,X.useState)(null),ie=D instanceof Error?D.message:D?n.loadError:null,ae=re??ie,[ce,le]=(0,X.useState)(null),[ue,de]=(0,X.useState)(!1),[F,fe]=(0,X.useState)(`overview`),[pe,me]=(0,X.useState)(``),[I,he]=(0,X.useState)(``),[ge,ve]=(0,X.useState)(``),[ye,be]=(0,X.useState)(``),[xe,Se]=(0,X.useState)(``),[Ce,L]=(0,X.useState)(null),[we,Ee]=(0,X.useState)(!1),De=(0,X.useRef)(``),[R,z]=(0,X.useState)(!1),[ke,Ae]=(0,X.useState)(!1),[je,Me]=(0,X.useState)(``),[B,Ne]=(0,X.useState)(``),[Pe,Fe]=(0,X.useState)(``),[Le,Re]=(0,X.useState)(``),[Be,Ve]=(0,X.useState)(``),He=(0,X.useRef)(null),[Ue,We]=(0,X.useState)(!1),[Ge,Ke]=(0,X.useState)(!1),[qe,Je]=(0,X.useState)(!1);(0,X.useEffect)(()=>{if(j){if(C&&j.agents.some(e=>e.id===C)){le(C);return}le(e=>e&&j.agents.some(t=>t.id===e)?e:j.defaultId)}},[j,C]),(0,X.useEffect)(()=>{if(!j||M)return;let e=j.agents.length<=1&&j.agents.every(e=>e.id===j.defaultId),t=localStorage.getItem(fn)===`true`;de(e&&!t)},[j,M]);let Ye=(0,X.useCallback)(()=>{de(!1),k()},[k]),Xe=(0,X.useCallback)(()=>{de(!1)},[]);(0,X.useEffect)(()=>{!j||!C||j.agents.some(e=>e.id===C)||S(et,{replace:!0})},[j,C,S]),(0,X.useEffect)(()=>{C&&fe(`overview`)},[C]),(0,X.useEffect)(()=>{b.get(`panel`)===`defaults`&&S(`/settings/agent-chat`,{replace:!0,state:{[ze]:et}})},[b,S]),(0,X.useEffect)(()=>{if(b.get(`focus`)!==`avatar`||!C||(fe(`overview`),M||!j?.agents.some(e=>e.id===C)))return;let e=window.setTimeout(()=>{document.getElementById(`agent-avatar-settings`)?.scrollIntoView({behavior:`smooth`,block:`center`}),x(e=>{let t=new URLSearchParams(e);return t.delete(`focus`),t},{replace:!0})},220);return()=>window.clearTimeout(e)},[b,C,M,j,x]);let V=(0,X.useMemo)(()=>j?.agents.find(e=>e.id===ce)??null,[j,ce]),H=Nn({panel:F,selectedId:ce,hasToken:y,dataAgentsLength:j?.agents.length,saveErrorMessage:n.saveError,setError:N}),U=Rn({panel:F,selected:V}),W=Pn({panel:F,hasToken:y,bindingsFromConfig:ne,gatewayCfgLoading:A===void 0,selected:V,saveErrorMessage:n.saveError,setBusy:z,setError:N}),Ze=Fn({panel:F,hasToken:y,data:j,selected:V,saveErrorMessage:n.saveError,setBusy:z,setError:N}),Qe=Ln({panel:F,hasToken:y});(0,X.useEffect)(()=>{if(!V){Ne(``),Fe(``),Re(``),Ve(``);return}Ne(V.workspace),Fe(V.model?.primary??``),Re(tt(V,o(e).agentsSettings)),Ve(V.description?.trim()??``)},[V?.id,e]);let $e=(0,X.useCallback)(()=>{let e=Tn(I.trim()||pe);be(t=>t===``||t===De.current?(De.current=e,e):t)},[I,pe]),G=(0,X.useCallback)(()=>{De.current=``,me(``),he(``),ve(``),be(``),Se(``),L(null),Ee(!0)},[]),nt=(0,X.useCallback)(e=>new Promise(t=>window.setTimeout(t,e)),[]),rt=(0,X.useCallback)(async()=>{if(ke||R)return;Ae(!0),N(null);let e=[`light`,`deep`,`rem`];try{(async()=>{for(let t of e)try{await kn(t)}catch{}})();for(let t=0;t<e.length;t++){let n=e[t];window.dispatchEvent(new CustomEvent(`dreaming-phase-start`,{detail:{phase:n,source:`ui`}})),await nt(n===`light`?7e3:n===`deep`?9e3:8e3),t===e.length-1&&(window.__xopcDreamingIgnoreSseUntil=Date.now()+6e4,window.dispatchEvent(new CustomEvent(`dreaming-phase-end`,{detail:{phase:n,source:`ui`}})))}}catch(e){N(e instanceof Error?e.message:n.saveError)}finally{Ae(!1)}},[n.saveError,R,ke,nt]),it=(0,X.useMemo)(()=>(0,K.jsx)(Mn,{language:e,a:n,busy:R,sleeping:ke,listSearchQuery:je,onListSearchQueryChange:Me,onSleep:()=>void rt(),onAddAgent:()=>G()}),[n,R,e,je,G,ke,rt]);(0,X.useLayoutEffect)(()=>y?(w({startExtra:null,main:null,end:it}),()=>T()):(T(),()=>T()),[it,T,y,w]);async function at(e){e.preventDefault();let t=pe.trim();if(!t)return;let r=wn(I,t);if(r.ok===!1){L(r.error);return}let i=ye.trim()||Tn(I.trim()||t);if(i){z(!0),L(null);try{let e=ge.trim(),{createdAgentId:n,...r}=await se({name:t,workspace:i,...I.trim()?{id:I.trim()}:{},...xe.trim()?{model:xe.trim()}:{},...e?{description:e}:{}});k(r,{revalidate:!1}),me(``),he(``),ve(``),be(``),Se(``),L(null),Ee(!1),le(n),S(Te(n))}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{z(!1)}}}async function ot(){if(V){z(!0),N(null);try{let e=Be.trim();k(await m(V.id,{name:Le.trim()||void 0,description:e.length>0?e:null,workspace:B.trim()||void 0,model:Pe.trim()||null}),{revalidate:!1})}catch(e){N(e instanceof Error?e.message:n.saveError)}finally{z(!1)}}}async function st(e){z(!0),N(null);try{k(await m(e.id,{setDefault:!0}),{revalidate:!1}),le(e.id)}catch(e){N(e instanceof Error?e.message:n.saveError)}finally{z(!1)}}async function ct(e,t){z(!0),N(null);try{let n=await u(e.id,t);k(n,{revalidate:!1}),le(n.defaultId),fe(`overview`),C===e.id&&S(et,{replace:!0}),c(!1),d(null),g(``)}catch(e){N(e instanceof Error?e.message:n.saveError)}finally{z(!1)}}function lt(e,t){e.id!==`main`&&(d(e),p(t),g(``),c(!0))}async function ut(){if(V){z(!0),N(null);try{let e=[...U.toolEntryDisable].sort((e,t)=>e.localeCompare(t));k(await m(V.id,{toolsDisable:e}),{revalidate:!1})}catch(e){N(e instanceof Error?e.message:n.saveError)}finally{z(!1)}}}async function dt(){if(V){z(!0),N(null);try{k(await m(V.id,{toolsDisable:null}),{revalidate:!1}),U.setToolEntryDisable(new Set)}catch(e){N(e instanceof Error?e.message:n.saveError)}finally{z(!1)}}}async function ft(){if(V){z(!0),N(null);try{k(await m(V.id,{skills:U.skillsInherit?null:[...U.skillsPick].sort((e,t)=>e.localeCompare(t))}),{revalidate:!1})}catch(e){N(e instanceof Error?e.message:n.saveError)}finally{z(!1)}}}let pt=F===`channels`||F===`cron`,mt=(()=>{if(!V||F!==`overview`)return!1;let e=tt(V,n),t=V.description?.trim()??``,r=V.workspace,i=V.model?.primary??``;return Le.trim()!==e||Be.trim()!==t||B.trim()!==r||Pe.trim()!==i})(),ht=(()=>{if(pt)return!1;switch(F){case`overview`:return mt||Ue;case`profile`:return Ge;default:return!0}})(),gt=pt||!ht;function _t(){Je(!0),setTimeout(()=>Je(!1),2e3)}async function vt(){switch(F){case`overview`:await Promise.all([ot(),H.overviewSaveProfileMarkdownRef.current?.()??Promise.resolve()]),_t();break;case`profile`:await He.current?.(),_t();break;case`tools`:await ut(),_t();break;case`skills`:await ft(),_t();break;case`files`:H.saveProfileMarkdownDebounced.flush(),_t();break;default:break}}function yt(e){e||S(et)}return{hasToken:y,a:n,chat:v,language:e,data:j,loading:M,displayError:ae,navigate:S,routeAgentId:C,showPresetSetup:ue,onPresetSetupComplete:Ye,onPresetSetupSkip:Xe,busy:R,listSearchQuery:je,openAddAgentModal:G,panel:F,setPanel:fe,modalTitle:V?Le.trim()||tt(V,n):C??``,modalSubtitle:V?.id??C??``,footerSaveDisabled:gt,savedFlash:qe,handleModalFooterSave:vt,onAgentModalOpenChange:yt,addAgentModalOpen:we,setAddAgentModalOpen:Ee,createWorkspaceSuggestedRef:De,createModalError:Ce,setCreateModalError:L,createDisplayName:pe,setCreateDisplayName:me,createAgentId:I,setCreateAgentId:he,createDescription:ge,setCreateDescription:ve,createWorkspace:ye,setCreateWorkspace:be,createModel:xe,setCreateModel:Se,onCreate:at,applyCreateWorkspaceSuggestion:$e,deleteDialogOpen:s,setDeleteDialogOpen:c,deletePurge:f,deleteTarget:l,setDeleteTarget:d,deleteConfirmText:h,setDeleteConfirmText:g,performDelete:ct,editorPanelProps:{a:n,chat:v,cCron:_,selected:V,panel:F,data:j,busy:R,editName:Le,setEditName:Re,editDescription:Be,setEditDescription:Ve,editWorkspace:B,setEditWorkspace:Ne,editModel:Pe,setEditModel:Fe,onSetDefault:()=>{V&&st(V)},onSaveAgentEdits:()=>void ot(),onDelete:e=>{V&&lt(V,e)},overviewSaveProfileMarkdownRef:H.overviewSaveProfileMarkdownRef,profileSaveRef:He,setOverviewProfileMarkdownDirty:We,setProfileDirty:Ke,filesLoading:H.filesLoading,files:H.files,activeFile:H.activeFile,setActiveFile:H.setActiveFile,filesViewMode:H.filesViewMode,setFilesViewMode:H.setFilesViewMode,fileDraft:H.fileDraft,setFileDraft:H.setFileDraft,fileSaving:H.fileSaving,profileFileLoading:H.profileFileLoading,profileEditorNonce:H.profileEditorNonce,toolEntryDisable:U.toolEntryDisable,setToolEntryDisable:U.setToolEntryDisable,onSaveTools:()=>void ut(),onClearToolsEntry:()=>void dt(),skillsCatalogLoading:Qe.skillsCatalogLoading,catalogForPick:Qe.catalogForPick,skillsInherit:U.skillsInherit,setSkillsInherit:U.setSkillsInherit,skillsPick:U.skillsPick,setSkillsPick:U.setSkillsPick,onSaveSkills:()=>void ft(),bindingsLoading:W.bindingsLoading,agentBindings:W.agentBindings,bindChannelStatuses:W.bindChannelStatuses,bindChannelsLoading:W.bindChannelsLoading,useManualChannel:W.useManualChannel,newBindChannel:W.newBindChannel,setNewBindChannel:W.setNewBindChannel,bindSessionChats:W.bindSessionChats,bindSessionsLoading:W.bindSessionsLoading,newBindSessionIdx:W.newBindSessionIdx,setNewBindSessionIdx:W.setNewBindSessionIdx,newBindCustomPeer:W.newBindCustomPeer,setNewBindCustomPeer:W.setNewBindCustomPeer,refreshBindSessions:W.refreshBindSessions,onRemoveBinding:e=>void W.onRemoveBinding(e),onAddBinding:W.onAddBinding,cronLoading:Ze.cronLoading,agentCronJobs:Ze.agentCronJobs,onSetCronJobAgent:(e,t)=>void Ze.onSetCronJobAgent(e,t)}}}function Bn(){let e=zn();return e.hasToken?e.showPresetSetup&&e.data?(0,K.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col px-4 py-8`,children:(0,K.jsx)(mn,{existingAgentIds:new Set(e.data.agents.map(e=>e.id)),onComplete:e.onPresetSetupComplete,onSkip:e.onPresetSetupSkip})}):(0,K.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[(0,K.jsx)(un,{a:e.a}),e.displayError?(0,K.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:e.displayError}):null,e.loading?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.loading}):e.data?(0,K.jsx)(ln,{a:e.a,agents:e.data.agents,searchQuery:e.listSearchQuery,onOpenAgent:t=>e.navigate(Te(t)),onChatWithAgent:t=>e.navigate(`/chat/new`,{state:{agentId:t.trim().toLowerCase()}}),onNewAgent:e.openAddAgentModal,busy:e.busy}):null,e.routeAgentId&&e.hasToken?(0,K.jsx)(bt,{open:!!e.routeAgentId,onOpenChange:e.onAgentModalOpenChange,a:e.a,title:e.modalTitle,subtitle:e.modalSubtitle,panel:e.panel,onPanelChange:e.setPanel,onFooterSave:()=>void e.handleModalFooterSave(),footerSaveDisabled:e.footerSaveDisabled,footerSavedFlash:e.savedFlash,busy:e.busy,children:e.loading||!e.data?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.loading}):(0,K.jsx)(on,{...e.editorPanelProps})}):null,(0,K.jsx)(dn,{open:e.addAgentModalOpen,onOpenChange:t=>{e.setAddAgentModalOpen(t),t||(e.createWorkspaceSuggestedRef.current=``,e.setCreateDisplayName(``),e.setCreateAgentId(``),e.setCreateDescription(``),e.setCreateWorkspace(``),e.setCreateModel(``),e.setCreateModalError(null))},a:e.a,chat:e.chat,busy:e.busy,modalError:e.createModalError,createDisplayName:e.createDisplayName,setCreateDisplayName:e.setCreateDisplayName,createAgentId:e.createAgentId,setCreateAgentId:e.setCreateAgentId,createDescription:e.createDescription,setCreateDescription:e.setCreateDescription,createWorkspace:e.createWorkspace,setCreateWorkspace:e.setCreateWorkspace,createModel:e.createModel,setCreateModel:e.setCreateModel,onCreate:e.onCreate,onSuggestWorkspace:()=>e.applyCreateWorkspaceSuggestion()}),(0,K.jsx)(gt,{open:e.deleteDialogOpen,onOpenChange:t=>{e.setDeleteDialogOpen(t),t||(e.setDeleteTarget(null),e.setDeleteConfirmText(``))},busy:e.busy,deletePurge:e.deletePurge,deleteTarget:e.deleteTarget,deleteConfirmText:e.deleteConfirmText,onDeleteConfirmTextChange:e.setDeleteConfirmText,onConfirm:()=>{e.deleteTarget&&e.performDelete(e.deleteTarget,e.deletePurge)},onCancel:()=>e.setDeleteDialogOpen(!1),a:e.a})]}):(0,K.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,K.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:e.a.title}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.needToken})]})}function $({label:e,description:t,children:n}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e}),n,(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t})]})}var Vn=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`adaptive`];function Hn(e){let{a:t,chat:n,form:r,update:i}=e;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{icon:Ze,title:t.cardModelsTitle,subtitle:t.label.model}),(0,K.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,K.jsx)($,{label:t.label.model,description:t.desc.model,children:(0,K.jsx)(ve,{value:r.model,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>i({model:e})})})})]}),(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{icon:Ee,title:t.cardGenerationTitle,subtitle:t.cardGenerationSubtitle}),(0,K.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,K.jsx)($,{label:t.label.maxTokens,description:t.desc.maxTokens,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),value:r.maxTokens,min:1,onChange:e=>i({maxTokens:Number.parseInt(e.target.value,10)||0})})}),(0,K.jsx)($,{label:t.label.temperature,description:t.desc.temperature,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),value:r.temperature,min:0,max:2,step:.1,onChange:e=>i({temperature:Number.parseFloat(e.target.value)||0})})}),(0,K.jsx)(`div`,{className:`sm:col-span-2`,children:(0,K.jsx)($,{label:t.label.maxToolIterations,description:t.desc.maxToolIterations,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),value:r.maxToolIterations,min:1,onChange:e=>i({maxToolIterations:Number.parseInt(e.target.value,10)||0})})})})]})]}),(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{icon:S,title:t.cardBehaviorTitle,subtitle:t.cardBehaviorSubtitle}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,K.jsx)($,{label:t.label.thinkingDefault,description:t.desc.thinkingDefault,children:(0,K.jsx)(`select`,{className:Q(),value:r.thinkingDefault,onChange:e=>i({thinkingDefault:e.target.value}),children:Vn.map(e=>(0,K.jsx)(`option`,{value:e,children:n.thinkingLevels[e]},e))})}),(0,K.jsx)($,{label:t.label.reasoningDefault,description:t.desc.reasoningDefault,children:(0,K.jsxs)(`select`,{className:Q(),value:r.reasoningDefault,onChange:e=>i({reasoningDefault:e.target.value}),children:[(0,K.jsx)(`option`,{value:`off`,children:t.reasoning.off}),(0,K.jsx)(`option`,{value:`on`,children:t.reasoning.on}),(0,K.jsx)(`option`,{value:`stream`,children:t.reasoning.stream})]})}),(0,K.jsx)($,{label:t.label.verboseDefault,description:t.desc.verboseDefault,children:(0,K.jsxs)(`select`,{className:Q(),value:r.verboseDefault,onChange:e=>i({verboseDefault:e.target.value}),children:[(0,K.jsx)(`option`,{value:`off`,children:t.verbose.off}),(0,K.jsx)(`option`,{value:`on`,children:t.verbose.on}),(0,K.jsx)(`option`,{value:`full`,children:t.verbose.full})]})})]})]})]})}function Un(e){let[t,n]=(0,X.useState)(e?`unknown`:`off`),r=(0,X.useCallback)(async()=>{if(!e){n(`off`);return}try{let e=await He(G(`/api/browser/extension-status`),{signal:AbortSignal.timeout(3e3)});if(!e.ok){n(`off`);return}let t=await e.json();t.running?n(t.connected?`connected`:`waiting`):n(`off`)}catch{n(`off`)}},[e]);return(0,X.useEffect)(()=>{r();let e=setInterval(r,5e3);return()=>clearInterval(e)},[r]),t}function Wn({status:e,messages:t}){let{icon:n,color:r,label:i}={connected:{icon:R,color:`text-green-500`,label:t.browserExtensionConnected},waiting:{icon:ke,color:`text-amber-500`,label:t.browserExtensionWaiting},off:{icon:F,color:`text-fg-muted`,label:t.browserExtensionServerOff},unknown:{icon:F,color:`text-fg-muted`,label:`…`}}[e];return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs ${r}`,children:[(0,K.jsx)(n,{className:`size-3.5`}),(0,K.jsx)(`span`,{children:i})]})}function Gn(e){let{a:t,form:n,update:r}=e,i=Un(n.browserBackend===`extension`);return(0,K.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{icon:_,title:t.cardBrowserTitle,subtitle:t.cardBrowserSubtitle}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,K.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,K.jsx)($,{label:t.label.browserEnabled,description:t.desc.browserEnabled,children:(0,K.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:n.browserEnabled,onChange:e=>r({browserEnabled:e.target.checked})}),(0,K.jsx)(`span`,{children:t.browserEnabledOn})]})}),(0,K.jsx)($,{label:t.label.browserHeadless,description:t.desc.browserHeadless,children:(0,K.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:n.browserHeadless,onChange:e=>r({browserHeadless:e.target.checked})}),(0,K.jsx)(`span`,{children:t.browserHeadlessOn})]})}),(0,K.jsx)($,{label:t.label.browserAllowPrivateUrls,description:t.desc.browserAllowPrivateUrls,children:(0,K.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:n.browserAllowPrivateUrls,onChange:e=>r({browserAllowPrivateUrls:e.target.checked})}),(0,K.jsx)(`span`,{children:t.browserAllowPrivateOn})]})}),(0,K.jsx)($,{label:t.label.browserCommandTimeout,description:t.desc.browserCommandTimeout,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),min:5,value:n.browserCommandTimeout??``,placeholder:`30`,onChange:e=>{let t=e.target.value;r({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})}})})]}),(0,K.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,K.jsx)($,{label:t.label.browserBackend,description:t.desc.browserBackend,children:(0,K.jsxs)(`select`,{className:Q(),value:n.browserBackend,onChange:e=>r({browserBackend:e.target.value}),children:[(0,K.jsx)(`option`,{value:`local`,children:t.browserBackendLocal}),(0,K.jsx)(`option`,{value:`cdp`,children:t.browserBackendCdp}),(0,K.jsx)(`option`,{value:`cloud`,children:t.browserBackendCloud}),(0,K.jsx)(`option`,{value:`extension`,children:t.browserBackendExtension})]})}),(0,K.jsx)($,{label:t.label.browserDialogPolicy,description:t.desc.browserDialogPolicy,children:(0,K.jsxs)(`select`,{className:Q(),value:n.browserDialogPolicy,onChange:e=>r({browserDialogPolicy:e.target.value}),children:[(0,K.jsx)(`option`,{value:`must_respond`,children:t.browserDialogPolicyMustRespond}),(0,K.jsx)(`option`,{value:`auto_dismiss`,children:t.browserDialogPolicyAutoDismiss}),(0,K.jsx)(`option`,{value:`auto_accept`,children:t.browserDialogPolicyAutoAccept})]})})]}),n.browserBackend===`cloud`&&(0,K.jsx)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:(0,K.jsx)($,{label:t.label.browserCloudProvider,description:t.desc.browserCloudProvider,children:(0,K.jsxs)(`select`,{className:Q(),value:n.browserCloudProvider,onChange:e=>r({browserCloudProvider:e.target.value}),children:[(0,K.jsx)(`option`,{value:`browserbase`,children:t.browserCloudProviderBrowserbase}),(0,K.jsx)(`option`,{value:`browser-use`,children:t.browserCloudProviderBrowserUse})]})})}),n.browserBackend===`cdp`&&(0,K.jsx)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:(0,K.jsx)($,{label:t.label.browserCdpUrl,description:t.desc.browserCdpUrl,children:(0,K.jsx)(`input`,{type:`text`,className:Z(),value:n.browserCdpUrl,placeholder:`ws://localhost:9222`,onChange:e=>r({browserCdpUrl:e.target.value}),autoComplete:`off`})})}),n.browserBackend===`extension`&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-edge bg-surface-raised px-4 py-3`,children:[(0,K.jsx)(Wn,{status:i,messages:t}),(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`ws://127.0.0.1:19820/browser-ext`})]}),(0,K.jsx)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:(0,K.jsx)($,{label:t.label.browserDialogTimeout,description:t.desc.browserDialogTimeout,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),min:1,value:n.browserDialogTimeout??``,placeholder:`300`,onChange:e=>{let t=e.target.value;r({browserDialogTimeout:t===``?void 0:Number.parseInt(t,10)})}})})})]})]})})}function Kn(e,t){let[n,r]=(0,X.useState)([]),[a,o]=(0,X.useState)(!1);return(0,X.useEffect)(()=>{if(!e||!t)return;let n=!1;return o(!0),i().then(e=>{n||r(Array.isArray(e.builtinToolIds)?e.builtinToolIds:[])}).catch(()=>{n||r([])}).finally(()=>{n||o(!1)}),()=>{n=!0}},[e,t]),{builtinToolIds:n,loading:a}}function qn(e){let{a:t,form:n,update:r}=e,i=t.advanced,a=o(P(e=>e.language)).agentsSettings,s=!!_e(e=>e.token),{builtinToolIds:c,loading:l}=Kn(!0,s),u=(0,X.useMemo)(()=>new Set(n.toolsDisable.map(e=>e.trim()).filter(Boolean)),[n.toolsDisable]),d=(0,X.useMemo)(()=>n.toolsDisable.map(e=>e.trim()).filter(Boolean).filter(e=>!c.includes(e)).sort((e,t)=>e.localeCompare(t)),[n.toolsDisable,c]),f=(0,X.useCallback)(e=>{r({toolsDisable:nn(e)})},[r]),p=a.toolsDisableGroups,m=(0,X.useCallback)(e=>p[e],[p]),h=(0,X.useCallback)(e=>e in a.toolDescriptions?a.toolDescriptions[e]:``,[a.toolDescriptions]);return(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{icon:ot,title:i.cardToolsDisableTitle,subtitle:i.cardToolsDisableSubtitle}),(0,K.jsx)($,{label:i.toolsDisableFieldLabel,description:i.toolsDisableHint,children:(0,K.jsx)(`div`,{className:`flex flex-col gap-3`,children:s?(0,K.jsx)(rn,{mode:`defaults`,builtinToolIds:c,loading:l,disableSet:u,onDisableSetChange:f,unknownDisabledIds:d,getToolDescription:h,getGroupTitle:m,quickActionsDisabled:l,labels:{loadingBuiltin:i.toolsDisableLoadingBuiltin,emptyBuiltin:i.toolsDisableEmptyBuiltin,quickActionsLabel:i.toolsDisableQuickActionsLabel,quickEnableAll:i.toolsDisableQuickEnableAll,quickDisableAll:i.toolsDisableQuickDisableAll,quickReadOnlyWorkspace:i.toolsDisableQuickReadOnlyWorkspace,quickHighRiskOff:i.toolsDisableQuickHighRiskOff,quickNoOutbound:i.toolsDisableQuickNoOutbound,notInBuiltin:i.toolsDisableNotInBuiltin,lockedByDefaults:a.toolsLockedByDefaults}}):(0,K.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.needToken})})})]})}function Jn(e){let{a:t,chat:n,form:r,update:i}=e,a=t.advanced;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{icon:Ye,title:a.cardWebExtractTitle,subtitle:a.cardWebExtractSubtitle}),(0,K.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,K.jsx)(`div`,{className:`sm:col-span-2`,children:(0,K.jsx)($,{label:a.webExtractModel,description:a.webExtractModelDesc,children:(0,K.jsx)(ve,{value:r.webExtract.model,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>i({webExtract:{...r.webExtract,model:e}})})})}),(0,K.jsx)($,{label:a.webExtractMaxLength,description:a.webExtractMaxLengthDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),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,K.jsxs)(q,{children:[(0,K.jsx)(J,{icon:Ae,title:a.cardDelegateTitle,subtitle:a.cardDelegateSubtitle}),(0,K.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,K.jsx)($,{label:a.delegateEnabled,description:a.delegateEnabledDesc,children:(0,K.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,K.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,K.jsx)(`span`,{children:a.delegateEnabledOn})]})}),(0,K.jsx)($,{label:a.executeCodeEnabled,description:a.executeCodeEnabledDesc,children:(0,K.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,K.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,K.jsx)(`span`,{children:a.executeCodeEnabledOn})]})})]})]}),(0,K.jsx)(qn,{...e})]})}function Yn(e){let{a:t,form:n,update:r}=e,i=t.advanced;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{icon:Je,title:i.cardLimitsTitle,subtitle:i.cardLimitsSubtitle}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,K.jsx)($,{label:i.maxTaskDurationMs,description:i.maxTaskDurationMsDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),min:1,max:240,step:1,value:n.maxTaskDurationMinutes??``,placeholder:i.maxTaskDurationPlaceholder,onChange:e=>{let t=e.target.value;if(t===``){r({maxTaskDurationMinutes:void 0});return}let n=Number.parseInt(t,10);Number.isNaN(n)||r({maxTaskDurationMinutes:Math.min(240,Math.max(1,n))})}})}),(0,K.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,K.jsx)($,{label:i.maxRequestsPerTurn,description:i.maxRequestsPerTurnDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),min:10,max:200,value:n.maxRequestsPerTurn,onChange:e=>r({maxRequestsPerTurn:Number.parseInt(e.target.value,10)||50})})}),(0,K.jsx)($,{label:i.maxToolFailuresPerTurn,description:i.maxToolFailuresPerTurnDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),min:1,max:20,value:n.maxToolFailuresPerTurn,onChange:e=>r({maxToolFailuresPerTurn:Number.parseInt(e.target.value,10)||3})})})]})]})]}),(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{icon:C,title:i.cardCompactionTitle,subtitle:i.cardCompactionSubtitle}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,K.jsx)($,{label:i.compactionEnabled,description:i.compactionEnabledDesc,children:(0,K.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:n.compaction.enabled,onChange:e=>r({compaction:{...n.compaction,enabled:e.target.checked}})}),(0,K.jsx)(`span`,{children:i.compactionEnabledOn})]})}),(0,K.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,K.jsx)($,{label:i.compactionMode,description:i.compactionModeDesc,children:(0,K.jsxs)(`select`,{className:Q(),value:n.compaction.mode,onChange:e=>r({compaction:{...n.compaction,mode:e.target.value}}),children:[(0,K.jsx)(`option`,{value:`default`,children:i.compactionModeDefault}),(0,K.jsx)(`option`,{value:`safeguard`,children:i.compactionModeSafeguard})]})}),(0,K.jsx)($,{label:i.reserveTokens,description:i.reserveTokensDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),min:1e3,value:n.compaction.reserveTokens,onChange:e=>r({compaction:{...n.compaction,reserveTokens:Number.parseInt(e.target.value,10)||0}})})}),(0,K.jsx)($,{label:i.triggerThreshold,description:i.triggerThresholdDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),min:.5,max:.95,step:.05,value:n.compaction.triggerThreshold,onChange:e=>r({compaction:{...n.compaction,triggerThreshold:Number.parseFloat(e.target.value)||.8}})})}),(0,K.jsx)($,{label:i.minMessagesBeforeCompact,description:i.minMessagesBeforeCompactDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),min:1,value:n.compaction.minMessagesBeforeCompact,onChange:e=>r({compaction:{...n.compaction,minMessagesBeforeCompact:Number.parseInt(e.target.value,10)||10}})})}),(0,K.jsx)($,{label:i.keepRecentMessages,description:i.keepRecentMessagesDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),min:0,value:n.compaction.keepRecentMessages,onChange:e=>r({compaction:{...n.compaction,keepRecentMessages:Number.parseInt(e.target.value,10)||5}})})}),(0,K.jsx)($,{label:i.evictionWindow,description:i.evictionWindowDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),min:.1,max:.5,step:.05,value:n.compaction.evictionWindow,onChange:e=>r({compaction:{...n.compaction,evictionWindow:Number.parseFloat(e.target.value)||.2}})})}),(0,K.jsx)($,{label:i.retentionWindow,description:i.retentionWindowDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),min:3,max:20,value:n.compaction.retentionWindow,onChange:e=>r({compaction:{...n.compaction,retentionWindow:Number.parseInt(e.target.value,10)||6}})})})]})]})]}),(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{icon:Be,title:i.cardPruningTitle,subtitle:i.cardPruningSubtitle}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,K.jsx)($,{label:i.pruningEnabled,description:i.pruningEnabledDesc,children:(0,K.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:n.pruning.enabled,onChange:e=>r({pruning:{...n.pruning,enabled:e.target.checked}})}),(0,K.jsx)(`span`,{children:i.pruningEnabledOn})]})}),(0,K.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,K.jsx)($,{label:i.maxToolResultChars,description:i.maxToolResultCharsDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),min:1e3,value:n.pruning.maxToolResultChars,onChange:e=>r({pruning:{...n.pruning,maxToolResultChars:Number.parseInt(e.target.value,10)||1e4}})})}),(0,K.jsx)($,{label:i.headKeepRatio,description:i.headKeepRatioDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),min:0,max:1,step:.05,value:n.pruning.headKeepRatio,onChange:e=>r({pruning:{...n.pruning,headKeepRatio:Number.parseFloat(e.target.value)||.3}})})}),(0,K.jsx)($,{label:i.tailKeepRatio,description:i.tailKeepRatioDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),min:0,max:1,step:.05,value:n.pruning.tailKeepRatio,onChange:e=>r({pruning:{...n.pruning,tailKeepRatio:Number.parseFloat(e.target.value)||.3}})})})]})]})]})]})}function Xn(e){let{a:t,form:n,update:r}=e,i=t.advanced;return(0,K.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{icon:ye,title:i.cardParamsTitle,subtitle:i.cardParamsSubtitle}),(0,K.jsx)($,{label:i.paramsJson,description:i.paramsJsonDesc,children:(0,K.jsx)(`textarea`,{className:y(Z(),`min-h-[88px] resize-y font-mono text-xs`),value:n.paramsJson,placeholder:`{}`,onChange:e=>r({paramsJson:e.target.value})})})]})})}function Zn(e){let{a:t,chat:n,form:r,update:i}=e,a=t.advanced;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{icon:ge,title:a.cardMemoryTitle,subtitle:a.cardMemorySubtitle}),(0,K.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,K.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,K.jsx)($,{label:a.memoryEnabled,description:a.memoryEnabledDesc,children:(0,K.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,K.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,K.jsx)(`span`,{children:a.memoryEnabledOn})]})}),(0,K.jsx)($,{label:a.useEnhancedSystem,description:a.useEnhancedSystemDesc,children:(0,K.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,K.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,K.jsx)(`span`,{children:a.useEnhancedSystemOn})]})}),(0,K.jsx)($,{label:a.userProfileEnabled,description:a.userProfileEnabledDesc,children:(0,K.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,K.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,K.jsx)(`span`,{children:a.userProfileEnabledOn})]})}),(0,K.jsx)($,{label:a.memoryProvider,description:a.memoryProviderDesc,children:(0,K.jsxs)(`select`,{className:Q(),value:r.memory.provider,onChange:e=>i({memory:{...r.memory,provider:e.target.value}}),children:[(0,K.jsx)(`option`,{value:``,children:a.memoryProviderUnset}),(0,K.jsx)(`option`,{value:`none`,children:`none`}),(0,K.jsx)(`option`,{value:`stub`,children:`stub`})]})}),(0,K.jsx)($,{label:a.injectionFrequency,description:a.injectionFrequencyDesc,children:(0,K.jsxs)(`select`,{className:Q(),value:r.memory.injectionFrequency,onChange:e=>i({memory:{...r.memory,injectionFrequency:e.target.value}}),children:[(0,K.jsx)(`option`,{value:``,children:a.injectionFrequencyUnset}),(0,K.jsx)(`option`,{value:`every-turn`,children:a.injectionEveryTurn}),(0,K.jsx)(`option`,{value:`first-turn`,children:a.injectionFirstTurn})]})}),(0,K.jsx)($,{label:a.memoryCharLimit,description:a.memoryCharLimitDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),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,K.jsx)($,{label:a.userCharLimit,description:a.userCharLimitDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),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,K.jsx)($,{label:a.contextCadence,description:a.contextCadenceDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),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,K.jsx)($,{label:a.dialecticCadence,description:a.dialecticCadenceDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),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,K.jsxs)(q,{children:[(0,K.jsx)(J,{icon:U,title:a.cardSessionSearchTitle,subtitle:a.cardSessionSearchSubtitle}),(0,K.jsx)($,{label:a.sessionSearchSummaryModel,description:a.sessionSearchSummaryModelDesc,children:(0,K.jsx)(ve,{value:r.sessionSearch.summaryModel,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>i({sessionSearch:{...r.sessionSearch,summaryModel:e}})})})]}),(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{icon:re,title:a.cardReviewTitle,subtitle:a.cardReviewSubtitle}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,K.jsx)($,{label:a.reviewEnabled,description:a.reviewEnabledDesc,children:(0,K.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,K.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,K.jsx)(`span`,{children:a.reviewEnabledOn})]})}),(0,K.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,K.jsx)($,{label:a.memoryNudgeInterval,description:a.memoryNudgeIntervalDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),min:0,value:r.backgroundReview.memoryNudgeInterval,onChange:e=>i({backgroundReview:{...r.backgroundReview,memoryNudgeInterval:Number.parseInt(e.target.value,10)||0}})})}),(0,K.jsx)($,{label:a.skillNudgeInterval,description:a.skillNudgeIntervalDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),min:0,value:r.backgroundReview.skillNudgeInterval,onChange:e=>i({backgroundReview:{...r.backgroundReview,skillNudgeInterval:Number.parseInt(e.target.value,10)||0}})})}),(0,K.jsx)($,{label:a.reviewMaxToolRounds,description:a.reviewMaxToolRoundsDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),min:1,max:32,value:r.backgroundReview.maxToolRounds,onChange:e=>i({backgroundReview:{...r.backgroundReview,maxToolRounds:Number.parseInt(e.target.value,10)||8}})})}),(0,K.jsx)($,{label:a.reviewMaxHistoryMessages,description:a.reviewMaxHistoryMessagesDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),min:10,max:200,value:r.backgroundReview.maxHistoryMessages,onChange:e=>i({backgroundReview:{...r.backgroundReview,maxHistoryMessages:Number.parseInt(e.target.value,10)||80}})})}),(0,K.jsx)($,{label:a.reviewMaxDurationMs,description:a.reviewMaxDurationMsDesc,children:(0,K.jsx)(`input`,{type:`number`,className:Z(),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}})})})]})]})]})]})}function Qn(e){return(e.name||e.directoryId).trim()}function $n(e,t){let n=[];for(let r of t)e.has(r)&&n.push(r);let r=[...e].filter(e=>!t.includes(e)).sort();return[...n,...r]}function er(e){let{a:t,form:n,update:r}=e,i=t.advanced,a=o(P(e=>e.language)).agentsSettings,s=!!_e(e=>e.token),{catalogForPick:c,skillsCatalogLoading:l}=In(!0,s),u=(0,X.useMemo)(()=>c.map(Qn),[c]),d=n.skillsAllowlist.length>0,f=(0,X.useMemo)(()=>new Set(n.skillsAllowlist.map(e=>e.trim()).filter(Boolean)),[n.skillsAllowlist]),p=(0,X.useMemo)(()=>n.skillsAllowlist.filter(e=>e.trim()&&!u.includes(e.trim())),[n.skillsAllowlist,u]),m=(0,X.useMemo)(()=>p.map(e=>({name:e.trim(),directoryId:e.trim()})),[p]),h=(0,X.useMemo)(()=>[...m,...c],[m,c]),g=(0,X.useCallback)(()=>{r({skillsAllowlist:[]})},[r]),_=(0,X.useCallback)(()=>{r({skillsAllowlist:[...u]})},[r,u]),v=(0,X.useCallback)((e,t)=>{let i=new Set(n.skillsAllowlist.map(e=>e.trim()).filter(Boolean));if(t?i.add(e):i.delete(e),i.size===0){r({skillsAllowlist:[]});return}r({skillsAllowlist:$n(i,u)})},[n.skillsAllowlist,u,r]);return(0,K.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{icon:T,title:i.cardSkillsTitle,subtitle:i.cardSkillsSubtitle}),(0,K.jsx)($,{label:i.skillsAllowlist,description:i.skillsAllowlistDesc,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(B,{type:`button`,variant:`secondary`,className:Qt,onClick:g,children:i.skillsAllowlistModeAll}),(0,K.jsx)(B,{type:`button`,variant:`secondary`,className:Qt,disabled:!d&&u.length===0,onClick:()=>{d||_()},children:i.skillsAllowlistModeRestrict})]}),(0,K.jsx)(ce,{to:at(`skills`),className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,children:a.skillsLibraryLink})]}),s?l?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.skillsCatalogLoading}):h.length===0?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.skillsEmptyCatalog}):(0,K.jsx)(`div`,{className:y(`max-h-[min(50vh,22rem)] overflow-y-auto overscroll-contain pr-0.5`,!d&&`pointer-events-none opacity-50`),children:(0,K.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,role:`list`,children:h.filter(e=>Qn(e)).map(e=>{let t=Qn(e),n=d&&f.has(t),r=typeof e.description==`string`?e.description.trim():``,o=r||a.skillsNoDescription,s=!u.includes(t);return(0,K.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,K.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:n,disabled:!d,onChange:()=>v(t,!n)}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:[t,s?(0,K.jsxs)(`span`,{className:`ml-1.5 font-sans text-[10px] font-normal text-fg-muted`,children:[`(`,i.skillsAllowlistNotInCatalog,`)`]}):null]}),(0,K.jsx)(`p`,{className:y(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!r&&`italic text-fg-subtle`),title:o,children:o})]})]})},t)})})}):(0,K.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.needToken})]})})]})})}function tr(e){let{a:t,form:n,update:r}=e,i=t.advanced;return(0,K.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{icon:L,title:i.cardSystemPromptTitle,subtitle:i.cardSystemPromptSubtitle}),(0,K.jsx)($,{label:i.systemPromptOverride,description:i.systemPromptOverrideDesc,children:(0,K.jsx)(`textarea`,{className:y(Z(),`min-h-[140px] resize-y font-mono text-xs`),value:n.systemPromptOverride,placeholder:i.systemPromptPlaceholder,onChange:e=>r({systemPromptOverride:e.target.value})})})]})})}function nr(e){let{a:t,form:n,update:r}=e;return(0,K.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{icon:fe,title:t.cardWorkspaceTitle,subtitle:t.cardWorkspaceSubtitle}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,K.jsx)($,{label:t.label.workspace,description:t.desc.workspace,children:(0,K.jsx)(`input`,{type:`text`,className:Z(),value:n.workspace,onChange:e=>r({workspace:e.target.value}),autoComplete:`off`})}),(0,K.jsx)($,{label:t.label.mediaMaxMb,description:t.desc.mediaMaxMb,children:(0,K.jsx)(`input`,{type:`number`,min:1,step:1,className:Z(),value:n.mediaMaxMb??``,placeholder:`20`,onChange:e=>{let t=e.target.value;r({mediaMaxMb:t===``?void 0:Number(t)})}})})]})]})})}function rr(e){let{sectionId:t,intro:n,vm:r,children:i}=e,a=o(P(e=>e.language)),s=a.agentSettings,c=a.settingsSections[t]??t;return r.hasToken?r.loading?(0,K.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,K.jsx)(`div`,{className:`h-8 w-48 animate-pulse rounded bg-surface-hover`}),(0,K.jsx)(`div`,{className:`mt-6 h-32 animate-pulse rounded-xl bg-surface-hover`}),(0,K.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:a.logs.loading})]}):r.form?(0,K.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[(0,K.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:c}),(0,K.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:s.sectionDesc})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[r.saveOk?(0,K.jsx)(`span`,{className:`text-sm text-fg-muted`,children:s.saved}):null,(0,K.jsx)(B,{type:`button`,variant:`secondary`,disabled:!r.dirty||r.saving,onClick:r.discard,children:s.discard}),(0,K.jsx)(B,{type:`button`,variant:`primary`,disabled:!r.dirty||r.saving,onClick:()=>void r.save(),children:r.saving?s.saving:s.save})]})]}),r.error?(0,K.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:r.error}):null,(0,K.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:i})]}):(0,K.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-10`,children:[(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.error??r.fetchError??s.loadError}),(0,K.jsx)(B,{type:`button`,variant:`secondary`,onClick:()=>void r.mutate(),children:a.logs.refresh})]}):(0,K.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-10`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[(0,K.jsx)(Ze,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:c}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s.needToken})]})]})})}var ir={enabled:!0,mode:`default`,reserveTokens:8e3,triggerThreshold:.8,minMessagesBeforeCompact:10,keepRecentMessages:5,evictionWindow:.2,retentionWindow:6},ar={enabled:!0,maxToolResultChars:1e4,headKeepRatio:.3,tailKeepRatio:.3},or={enabled:!0,useEnhancedSystem:!0,userProfileEnabled:!0,provider:``,injectionFrequency:``,memoryCharLimit:void 0,userCharLimit:void 0,contextCadence:void 0,dialecticCadence:void 0},sr={summaryModel:``},cr={enabled:!1,memoryNudgeInterval:10,skillNudgeInterval:10,maxToolRounds:8,maxHistoryMessages:80,maxDurationMs:12e4},lr={model:``,maxLength:void 0};function ur(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 dr(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 fr(e){if(!e||typeof e!=`object`)return;let t=e,n=t.payload;if(n&&typeof n==`object`&&`config`in n)return n.config;if(`config`in t)return t.config}function pr(e){return e===!0||e===`true`||e===1}function mr(e){let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{browserEnabled:!1,browserHeadless:!1,browserAllowPrivateUrls:!1,browserCommandTimeout:void 0,browserBackend:`local`,browserCloudProvider:`local`,browserCdpUrl:``,browserExtensionPort:void 0,browserExtensionHost:`127.0.0.1`,browserDialogPolicy:`auto_dismiss`,browserDialogTimeout:void 0};let n=t,r=pr(n.enabled),i=n.headless,a=i===!0||i===`true`||i===1,o=pr(n.allowPrivateUrls),s=typeof n.commandTimeout==`number`&&Number.isFinite(n.commandTimeout)&&n.commandTimeout>=5?Math.floor(n.commandTimeout):void 0,c=n.backend,l=c===`cdp`||c===`cloud`||c===`extension`?c:`local`,u=n.cloudProvider,d=u===`browserbase`||u===`browser-use`?u:`local`,f=typeof n.cdpUrl==`string`?n.cdpUrl:``,p=typeof n.extension==`object`&&n.extension&&!Array.isArray(n.extension)?n.extension:{},m=typeof p.port==`number`&&Number.isFinite(p.port)&&p.port>=1024&&p.port<=65535?Math.floor(p.port):void 0,h=typeof p.host==`string`&&p.host?p.host:`127.0.0.1`,g=n.dialogPolicy;return{browserEnabled:r,browserHeadless:a,browserAllowPrivateUrls:o,browserCommandTimeout:s,browserBackend:l,browserCloudProvider:d,browserCdpUrl:f,browserExtensionPort:m,browserExtensionHost:h,browserDialogPolicy:g===`must_respond`||g===`auto_accept`?g:`auto_dismiss`,browserDialogTimeout:typeof n.dialogTimeoutSeconds==`number`&&Number.isFinite(n.dialogTimeoutSeconds)&&n.dialogTimeoutSeconds>=1?Math.floor(n.dialogTimeoutSeconds):void 0}}function hr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...ir};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:ir.enabled,mode:t.mode===`safeguard`?`safeguard`:`default`,reserveTokens:typeof t.reserveTokens==`number`&&Number.isFinite(t.reserveTokens)?Math.floor(t.reserveTokens):ir.reserveTokens,triggerThreshold:typeof t.triggerThreshold==`number`&&Number.isFinite(t.triggerThreshold)?t.triggerThreshold:ir.triggerThreshold,minMessagesBeforeCompact:typeof t.minMessagesBeforeCompact==`number`&&Number.isFinite(t.minMessagesBeforeCompact)?Math.floor(t.minMessagesBeforeCompact):ir.minMessagesBeforeCompact,keepRecentMessages:typeof t.keepRecentMessages==`number`&&Number.isFinite(t.keepRecentMessages)?Math.floor(t.keepRecentMessages):ir.keepRecentMessages,evictionWindow:typeof t.evictionWindow==`number`&&Number.isFinite(t.evictionWindow)?t.evictionWindow:ir.evictionWindow,retentionWindow:typeof t.retentionWindow==`number`&&Number.isFinite(t.retentionWindow)?Math.floor(t.retentionWindow):ir.retentionWindow}}function gr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...ar};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:ar.enabled,maxToolResultChars:typeof t.maxToolResultChars==`number`&&Number.isFinite(t.maxToolResultChars)?Math.floor(t.maxToolResultChars):ar.maxToolResultChars,headKeepRatio:typeof t.headKeepRatio==`number`&&Number.isFinite(t.headKeepRatio)?t.headKeepRatio:ar.headKeepRatio,tailKeepRatio:typeof t.tailKeepRatio==`number`&&Number.isFinite(t.tailKeepRatio)?t.tailKeepRatio:ar.tailKeepRatio}}function _r(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...or};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:or.enabled,useEnhancedSystem:typeof t.useEnhancedSystem==`boolean`?t.useEnhancedSystem:or.useEnhancedSystem,userProfileEnabled:typeof t.userProfileEnabled==`boolean`?t.userProfileEnabled:or.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 vr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...sr};let t=e;return{summaryModel:typeof t.summaryModel==`string`?t.summaryModel:``}}function yr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...cr};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:cr.enabled,memoryNudgeInterval:typeof t.memoryNudgeInterval==`number`&&t.memoryNudgeInterval>=0?Math.floor(t.memoryNudgeInterval):cr.memoryNudgeInterval,skillNudgeInterval:typeof t.skillNudgeInterval==`number`&&t.skillNudgeInterval>=0?Math.floor(t.skillNudgeInterval):cr.skillNudgeInterval,maxToolRounds:typeof t.maxToolRounds==`number`&&t.maxToolRounds>=1&&t.maxToolRounds<=32?Math.floor(t.maxToolRounds):cr.maxToolRounds,maxHistoryMessages:typeof t.maxHistoryMessages==`number`&&t.maxHistoryMessages>=10&&t.maxHistoryMessages<=200?Math.floor(t.maxHistoryMessages):cr.maxHistoryMessages,maxDurationMs:typeof t.maxDurationMs==`number`&&t.maxDurationMs>=3e4&&t.maxDurationMs<=6e5?Math.floor(t.maxDurationMs):cr.maxDurationMs}}function br(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...lr};let t=e;return{model:typeof t.model==`string`?t.model:``,maxLength:typeof t.maxLength==`number`&&t.maxLength>0?t.maxLength:void 0}}function xr(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 Sr(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Cr(e){if(e==null)return``;if(typeof e==`string`){let t=e.trim();if(!t)return``;try{let e=JSON.parse(t);if(typeof e==`object`&&e&&!Array.isArray(e))return JSON.stringify(e,null,2)}catch{return t}return``}if(typeof e==`object`&&!Array.isArray(e))try{return JSON.stringify(e,null,2)}catch{return``}return``}function wr(e){let t=e.imageGenerationModelTimeoutMs;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return Math.floor(t);let n=e.imageGenerationModel;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=n.timeoutMs;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return Math.floor(e)}return null}function Tr(e){if(e.imageGenerationModelAutoProviderFallback===!0)return!0;let t=e.imageGenerationModel;return t&&typeof t==`object`&&!Array.isArray(t)?t.autoProviderFallback===!0:!1}function Er(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:dr(r.model),o=r.imageModelFallbacks,s=Array.isArray(o)&&o.every(e=>typeof e==`string`)?o:dr(r.imageModel),c=r.imageGenerationModelFallbacks,l=Array.isArray(c)&&c.every(e=>typeof e==`string`)?c:dr(r.imageGenerationModel),u=mr(r),d=typeof r.maxTaskDurationMs==`number`&&Number.isFinite(r.maxTaskDurationMs)?r.maxTaskDurationMs:void 0,f=d===void 0?void 0:Math.round(d/6e4);return{model:ur(r.model),modelFallbacks:a,imageModel:ur(r.imageModel),imageModelFallbacks:s,imageGenerationModel:ur(r.imageGenerationModel),imageGenerationModelFallbacks:l,imageGenerationModelTimeoutMs:wr(r),imageGenerationModelAutoProviderFallback:Tr(r),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:f,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`,...u,thinkingDefault:typeof r.thinkingDefault==`string`?r.thinkingDefault:`medium`,reasoningDefault:typeof r.reasoningDefault==`string`?r.reasoningDefault:`stream`,verboseDefault:typeof r.verboseDefault==`string`?r.verboseDefault:`full`,compaction:hr(r.compaction),pruning:gr(r.pruning),memory:_r(r.memory),sessionSearch:vr(r.sessionSearch),backgroundReview:yr(r.backgroundReview),webExtract:br(r.webExtract),delegate:xr(r.delegate,!1),executeCode:xr(r.executeCode,!1),systemPromptOverride:typeof r.systemPromptOverride==`string`?r.systemPromptOverride:``,skillsAllowlist:Sr(r.skills),toolsDisable:(()=>{let e=r.tools;if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e.disable;return Sr(t)})(),paramsJson:Cr(r.params)}}function Dr(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 Or(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 kr(){return Er(fr(await z(G(`/api/config`)))??{})}async function Ar(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=e.imageGenerationModel.trim(),s=typeof e.imageGenerationModelTimeoutMs==`number`&&e.imageGenerationModelTimeoutMs>0?Math.floor(e.imageGenerationModelTimeoutMs):null,c=e.imageGenerationModelAutoProviderFallback===!0,l=(()=>{let e={};return o&&(e.primary=o),a.length>0&&(e.fallbacks=a),s&&(e.timeoutMs=s),c&&(e.autoProviderFallback=!0),Object.keys(e).length===0?``:Object.keys(e).length===1&&typeof e.primary==`string`?e.primary:e})(),u=e.maxTaskDurationMinutes===void 0||e.maxTaskDurationMinutes===null?null:(()=>{let t=Math.floor(e.maxTaskDurationMinutes)*6e4;return t<6e4||t>144e5?null:t})(),d=e.skillsAllowlist.map(e=>e.trim()).filter(Boolean),f=e.toolsDisable.map(e=>e.trim()).filter(Boolean),p=Or(e.paramsJson),m=p===null||Object.keys(p).length===0?null:p,h={model:n,imageModel:i,imageGenerationModel:l,mediaMaxMb:e.mediaMaxMb??null,maxTokens:e.maxTokens,temperature:e.temperature,maxToolIterations:e.maxToolIterations,maxTaskDurationMs:u,maxRequestsPerTurn:e.maxRequestsPerTurn,maxToolFailuresPerTurn:e.maxToolFailuresPerTurn,workspace:e.workspace,browser:{enabled:e.browserEnabled,headless:e.browserHeadless,allowPrivateUrls:e.browserAllowPrivateUrls,commandTimeout:e.browserCommandTimeout??null,backend:e.browserBackend===`local`?null:e.browserBackend,cloudProvider:e.browserCloudProvider===`local`?null:e.browserCloudProvider,cdpUrl:e.browserCdpUrl.trim()||null,extension:e.browserBackend===`extension`?{port:e.browserExtensionPort??null,host:e.browserExtensionHost===`127.0.0.1`?null:e.browserExtensionHost}:null,dialogPolicy:e.browserDialogPolicy===`auto_dismiss`?null:e.browserDialogPolicy,dialogTimeoutSeconds:e.browserDialogTimeout??null},thinkingDefault:e.thinkingDefault,reasoningDefault:e.reasoningDefault,verboseDefault:e.verboseDefault,compaction:{...e.compaction},pruning:{...e.pruning},memory:Dr(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:d.length>0?d:null,tools:{disable:f.length>0?f:null},params:m};await z(G(`/api/config`),{method:`PATCH`,body:JSON.stringify({agents:{defaults:h}})}),rt()}function jr(e){let t=!!_e(e=>e.token),[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(!1),f=(0,X.useRef)(!1),{data:p,error:m,isLoading:h,mutate:g}=oe(t),_=(0,X.useMemo)(()=>p?.payload?.config===void 0?null:Er(p.payload.config),[p]);(0,X.useEffect)(()=>{if(!t){r(null),a(null),f.current=!1;return}if(_!==null&&!f.current){let e=structuredClone(_);r(e),a(structuredClone(e))}},[t,_]);let v=!!(t&&h&&p===void 0&&!m),y=m instanceof Error?m.message:m?String(m):null,b=(0,X.useMemo)(()=>!n||!i?!1:JSON.stringify(n)!==JSON.stringify(i),[n,i]);return{hasToken:t,loading:v,fetchError:y,form:n,update:(0,X.useCallback)(e=>{f.current=!0,r(t=>t?{...t,...e}:null)},[]),dirty:b,saving:o,saveOk:u,error:c,setError:l,save:(0,X.useCallback)(async()=>{if(!n||o)return!1;s(!0),l(null),d(!1);try{try{Or(n.paramsJson)}catch(t){return l(t instanceof SyntaxError?e.advanced.paramsInvalidJson:t instanceof Error?t.message:e.advanced.paramsInvalidJson),!1}return await Ar(n),f.current=!1,a(structuredClone(n)),d(!0),window.setTimeout(()=>d(!1),2500),!0}catch(t){return l(t instanceof Error?t.message:e.saveError),!1}finally{s(!1)}},[n,o,e.saveError,e.advanced]),discard:(0,X.useCallback)(()=>{i&&(f.current=!1,r(structuredClone(i)),l(null),d(!1))},[i]),mutate:g}}function Mr(){let e=o(P(e=>e.language)),t=e.agentSettings,n=e.chat,r=jr(t);return{vm:r,pp:(0,X.useMemo)(()=>r.form?{form:r.form,update:r.update,a:t,chat:n}:null,[r.form,r.update,t,n]),a:t}}function Nr(){let{vm:e,pp:t,a:n}=Mr();return(0,K.jsx)(rr,{sectionId:`agent-chat`,intro:n.routeIntro.chat,vm:e,children:t?(0,K.jsx)(Hn,{...t}):null})}function Pr(){let{vm:e,pp:t,a:n}=Mr();return(0,K.jsx)(rr,{sectionId:`agent-workspace`,intro:n.routeIntro.workspace,vm:e,children:t?(0,K.jsx)(nr,{...t}):null})}function Fr(){let{vm:e,pp:t,a:n}=Mr();return(0,K.jsx)(rr,{sectionId:`agent-browser`,intro:n.routeIntro.browser,vm:e,children:t?(0,K.jsx)(Gn,{...t}):null})}function Ir(){let{vm:e,pp:t,a:n}=Mr();return(0,K.jsx)(rr,{sectionId:`agent-runtime`,intro:n.routeIntro.runtime,vm:e,children:t?(0,K.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,K.jsx)(Yn,{...t}),(0,K.jsx)(Zn,{...t})]}):null})}function Lr(){let{vm:e,pp:t,a:n}=Mr();return(0,K.jsx)(rr,{sectionId:`agent-tools`,intro:n.routeIntro.tools,vm:e,children:t?(0,K.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,K.jsx)(Jn,{...t}),(0,K.jsx)(er,{...t}),(0,K.jsx)(Xn,{...t})]}):null})}function Rr(){let{vm:e,pp:t,a:n}=Mr();return(0,K.jsx)(rr,{sectionId:`agent-system-prompt`,intro:n.routeIntro.systemPrompt,vm:e,children:t?(0,K.jsx)(tr,{...t}):null})}export{Bn as AgentsSettingsPanel,kn as _,Lr as a,xt as b,kr as c,$ as d,En as f,On as g,Dn as h,Rr as i,Or as l,An as m,Nr as n,Pr as o,jn as p,Ir as r,jr as s,Fr as t,Ar as u,q as v,J as y};
216
- //# sourceMappingURL=agents-74EbWFJ1.js.map
216
+ //# sourceMappingURL=agents-D6Suddtr.js.map