@xopcai/xopc 0.0.43 → 0.0.45

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 (173) hide show
  1. package/README.md +138 -102
  2. package/README.zh-CN.md +155 -67
  3. package/dist/extensions/dingtalk/src/plugin.js +1 -1
  4. package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
  5. package/dist/extensions/telegram/src/plugin.js +1 -1
  6. package/dist/extensions/telegram/src/routing-integration.js +2 -2
  7. package/dist/extensions/telegram/xopc.extension.json +1 -1
  8. package/dist/extensions/weixin/src/api/api.js +2 -2
  9. package/dist/extensions/weixin/src/auth/accounts.js +1 -1
  10. package/dist/extensions/weixin/src/cdn/upload.js +1 -1
  11. package/dist/extensions/weixin/src/media/data-url.js +1 -1
  12. package/dist/extensions/weixin/src/messaging/debug-mode.js +1 -1
  13. package/dist/extensions/weixin/src/messaging/inbound.js +1 -1
  14. package/dist/extensions/weixin/src/messaging/process-message.js +1 -1
  15. package/dist/extensions/weixin/src/plugin.js +1 -1
  16. package/dist/extensions/weixin/src/storage/sync-buf.js +1 -1
  17. package/dist/gateway/static/root/assets/agents-Bk2uuFvC.js +216 -0
  18. package/dist/gateway/static/root/assets/agents-Bk2uuFvC.js.map +1 -0
  19. package/dist/gateway/static/root/assets/{apps-page-Bco3oZzd.js → apps-page-CbSr8cvX.js} +2 -2
  20. package/dist/gateway/static/root/assets/{apps-page-Bco3oZzd.js.map → apps-page-CbSr8cvX.js.map} +1 -1
  21. package/dist/gateway/static/root/assets/channels-settings-Dn-hIRl1.js +2 -0
  22. package/dist/gateway/static/root/assets/{channels-settings-CpTZxCKG.js.map → channels-settings-Dn-hIRl1.js.map} +1 -1
  23. package/dist/gateway/static/root/assets/{cron-api-YLqLzMDN.js → cron-dreaming-jobs-D460WnXB.js} +3 -3
  24. package/dist/gateway/static/root/assets/cron-dreaming-jobs-D460WnXB.js.map +1 -0
  25. package/dist/gateway/static/root/assets/cron-page-Df6AyXfn.js +2 -0
  26. package/dist/gateway/static/root/assets/cron-page-Df6AyXfn.js.map +1 -0
  27. package/dist/gateway/static/root/assets/dist-DN37Fw0E.js +2 -0
  28. package/dist/gateway/static/root/assets/{dist-4ClCuR-G.js.map → dist-DN37Fw0E.js.map} +1 -1
  29. package/dist/gateway/static/root/assets/{extension-debug-page-yNO3rwBQ.js → extension-debug-page-CqdKfBv_.js} +2 -2
  30. package/dist/gateway/static/root/assets/{extension-debug-page-yNO3rwBQ.js.map → extension-debug-page-CqdKfBv_.js.map} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-page-D0vOu9eC.js → extension-page-DhxjnfDf.js} +2 -2
  32. package/dist/gateway/static/root/assets/{extension-page-D0vOu9eC.js.map → extension-page-DhxjnfDf.js.map} +1 -1
  33. package/dist/gateway/static/root/assets/extension-settings-page-B3uhrA_f.js +2 -0
  34. package/dist/gateway/static/root/assets/{extension-settings-page-DqaNWoo7.js.map → extension-settings-page-B3uhrA_f.js.map} +1 -1
  35. package/dist/gateway/static/root/assets/heartbeat-config-api-z1kl5_rE.js +2 -0
  36. package/dist/gateway/static/root/assets/heartbeat-config-api-z1kl5_rE.js.map +1 -0
  37. package/dist/gateway/static/root/assets/{index-K0ZDwzeJ.css → index-B8G4Y9YY.css} +1 -1
  38. package/dist/gateway/static/root/assets/{index-KxjI2fjF.js → index-BUYGk2UT.js} +93 -93
  39. package/dist/gateway/static/root/assets/{index-KxjI2fjF.js.map → index-BUYGk2UT.js.map} +1 -1
  40. package/dist/gateway/static/root/assets/logs-page-Z9KRHWeO.js +2 -0
  41. package/dist/gateway/static/root/assets/{logs-page-DSdKuyeD.js.map → logs-page-Z9KRHWeO.js.map} +1 -1
  42. package/dist/gateway/static/root/assets/sessions-page-TlMYZxuv.js +2 -0
  43. package/dist/gateway/static/root/assets/{sessions-page-Bfb-hZJb.js.map → sessions-page-TlMYZxuv.js.map} +1 -1
  44. package/dist/gateway/static/root/assets/settings-page-X8vVcB8e.js +2 -0
  45. package/dist/gateway/static/root/assets/settings-page-X8vVcB8e.js.map +1 -0
  46. package/dist/gateway/static/root/assets/skills-page-B-tO9-I7.js +3 -0
  47. package/dist/gateway/static/root/assets/skills-page-B-tO9-I7.js.map +1 -0
  48. package/dist/gateway/static/root/assets/{use-image-provider-credentials-Cu5zeVdn.js → use-image-provider-credentials-DsYECmye.js} +2 -2
  49. package/dist/gateway/static/root/assets/{use-image-provider-credentials-Cu5zeVdn.js.map → use-image-provider-credentials-DsYECmye.js.map} +1 -1
  50. package/dist/gateway/static/root/index.html +2 -2
  51. package/dist/package.js +1 -1
  52. package/dist/src/agent/agent-manager.js +6 -6
  53. package/dist/src/agent/context/workspace-seed.js +2 -2
  54. package/dist/src/agent/goals/post-turn.js +1 -1
  55. package/dist/src/agent/image/load-image-media.js +1 -1
  56. package/dist/src/agent/ipc/bus.js +1 -1
  57. package/dist/src/agent/ipc/inbox.js +2 -2
  58. package/dist/src/agent/ipc/socket.js +1 -1
  59. package/dist/src/agent/memory/builtin-memory-store.js +1 -1
  60. package/dist/src/agent/memory/dreaming/deep-promotion.js +1 -1
  61. package/dist/src/agent/memory/dreaming/events.js +1 -1
  62. package/dist/src/agent/memory/dreaming/last-run.js +1 -1
  63. package/dist/src/agent/memory/dreaming/light-sweep.js +1 -1
  64. package/dist/src/agent/memory/dreaming/preview.js +1 -1
  65. package/dist/src/agent/memory/dreaming/rem-patterns.js +1 -1
  66. package/dist/src/agent/memory/dreaming/short-term-store.js +1 -1
  67. package/dist/src/agent/memory/dreaming/utils.js +1 -1
  68. package/dist/src/agent/memory/plugin-discovery.js +1 -1
  69. package/dist/src/agent/models/manager.js +1 -1
  70. package/dist/src/agent/prompt/service-prompt-builder.js +2 -2
  71. package/dist/src/agent/service.js +5 -5
  72. package/dist/src/agent/skills/config.js +1 -1
  73. package/dist/src/agent/skills/hub-hash.js +2 -2
  74. package/dist/src/agent/skills/hub-lock.js +1 -1
  75. package/dist/src/agent/skills/hub-pull.js +1 -1
  76. package/dist/src/agent/skills/index.js +1 -1
  77. package/dist/src/agent/skills/managed-store.js +1 -1
  78. package/dist/src/agent/skills/scanner.js +1 -1
  79. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  80. package/dist/src/agent/skills/skill-manager.js +1 -1
  81. package/dist/src/agent/tools/dreaming-tool.js +1 -1
  82. package/dist/src/agent/tools/factory.js +1 -1
  83. package/dist/src/agent/tools/image-generate-tool.js +1 -1
  84. package/dist/src/agent/tools/send-media.js +1 -1
  85. package/dist/src/agent/tools/skill-manage-tool.js +1 -1
  86. package/dist/src/agent/tools/write.js +1 -1
  87. package/dist/src/auth/credentials.js +3 -3
  88. package/dist/src/auth/profiles/store.js +1 -1
  89. package/dist/src/auth/sync-provider-auth.js +1 -1
  90. package/dist/src/channels/attachments/inbound-persist.js +1 -1
  91. package/dist/src/channels/attachments/outbound-tts-persist.js +1 -1
  92. package/dist/src/channels/outbound/persist-store.js +1 -1
  93. package/dist/src/channels/pairing/allow-from-file.js +1 -1
  94. package/dist/src/channels/pairing/pairing-store.js +2 -2
  95. package/dist/src/chat-commands/builtins/config.js +2 -2
  96. package/dist/src/chat-commands/context.js +1 -1
  97. package/dist/src/cli/commands/agent.js +1 -1
  98. package/dist/src/cli/commands/agents.js +1 -1
  99. package/dist/src/cli/commands/config.js +1 -1
  100. package/dist/src/cli/commands/doctor/checks/config-health.js +1 -1
  101. package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
  102. package/dist/src/cli/commands/doctor/checks/session-integrity.js +1 -1
  103. package/dist/src/cli/commands/doctor/checks/state-integrity.js +1 -1
  104. package/dist/src/cli/commands/doctor/checks/workspace-status.js +1 -1
  105. package/dist/src/cli/commands/extension-dev.js +1 -1
  106. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  107. package/dist/src/cli/commands/extension-pack.js +1 -1
  108. package/dist/src/cli/commands/image.js +1 -1
  109. package/dist/src/cli/commands/init.js +4 -4
  110. package/dist/src/cli/utils/init-workspace.js +2 -2
  111. package/dist/src/config/index.js +2 -2
  112. package/dist/src/config/loader.js +2 -2
  113. package/dist/src/config/models-json.js +2 -2
  114. package/dist/src/config/profile.js +2 -2
  115. package/dist/src/cron/executor.js +2 -2
  116. package/dist/src/cron/persistence.js +1 -1
  117. package/dist/src/cron/run-log-store.js +1 -1
  118. package/dist/src/daemon/launchd.js +2 -2
  119. package/dist/src/daemon/systemd.js +2 -2
  120. package/dist/src/extensions/health.js +1 -1
  121. package/dist/src/extensions/loader.js +1 -1
  122. package/dist/src/extensions/lockfile.js +2 -2
  123. package/dist/src/gateway/agents-admin.js +2 -2
  124. package/dist/src/gateway/hono/lib/extension-store.js +1 -1
  125. package/dist/src/gateway/hono/lib/static-ui.js +1 -1
  126. package/dist/src/gateway/hono/oauth.js +1 -1
  127. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  128. package/dist/src/gateway/hono/routes/config.js +1 -1
  129. package/dist/src/gateway/hono/routes/dreaming.js +1 -1
  130. package/dist/src/gateway/hono/routes/host-fs.js +1 -1
  131. package/dist/src/gateway/hono/routes/models.js +1 -1
  132. package/dist/src/gateway/hono/routes/workspace.js +3 -3
  133. package/dist/src/gateway/hono/sse.js +2 -2
  134. package/dist/src/gateway/lock.js +2 -2
  135. package/dist/src/gateway/service/run-gateway-agent.js +2 -2
  136. package/dist/src/gateway/service.js +5 -5
  137. package/dist/src/gateway/workspace-fs-file-list.js +1 -1
  138. package/dist/src/gateway/workspace-heartbeat-path.js +1 -1
  139. package/dist/src/infra/update-check.js +1 -1
  140. package/dist/src/infra/update-lock.js +3 -3
  141. package/dist/src/infra/update-runner.js +1 -1
  142. package/dist/src/infra/update-startup.js +2 -2
  143. package/dist/src/infra/write-file-atomic.js +2 -2
  144. package/dist/src/providers/auth-runtime/auth-profile-store.js +1 -1
  145. package/dist/src/providers/index.js +2 -2
  146. package/dist/src/providers/model-registry.js +1 -1
  147. package/dist/src/session/config-store.js +2 -2
  148. package/dist/src/session/search-index-cache.js +1 -1
  149. package/dist/src/session/search-index.js +1 -1
  150. package/dist/src/session/session-title.js +1 -1
  151. package/dist/src/session/store.js +5 -5
  152. package/dist/src/tui/backends/embedded-backend.js +1 -1
  153. package/dist/src/tui/tui.js +1 -1
  154. package/dist/src/utils/logger/audit.js +1 -1
  155. package/dist/src/utils/logger/log-store.js +1 -1
  156. package/dist/src/utils/logger/rotation.js +1 -1
  157. package/dist/src/voice/tts/audio.js +1 -1
  158. package/dist/src/voice/tts/providers/edge-speech.js +1 -1
  159. package/package.json +2 -2
  160. package/dist/gateway/static/root/assets/agents-BDhkkT2o.js +0 -216
  161. package/dist/gateway/static/root/assets/agents-BDhkkT2o.js.map +0 -1
  162. package/dist/gateway/static/root/assets/channels-settings-CpTZxCKG.js +0 -2
  163. package/dist/gateway/static/root/assets/cron-api-YLqLzMDN.js.map +0 -1
  164. package/dist/gateway/static/root/assets/cron-page-aiDeJtJ-.js +0 -2
  165. package/dist/gateway/static/root/assets/cron-page-aiDeJtJ-.js.map +0 -1
  166. package/dist/gateway/static/root/assets/dist-4ClCuR-G.js +0 -2
  167. package/dist/gateway/static/root/assets/extension-settings-page-DqaNWoo7.js +0 -2
  168. package/dist/gateway/static/root/assets/logs-page-DSdKuyeD.js +0 -2
  169. package/dist/gateway/static/root/assets/sessions-page-Bfb-hZJb.js +0 -2
  170. package/dist/gateway/static/root/assets/settings-page-B7NZPSpO.js +0 -2
  171. package/dist/gateway/static/root/assets/settings-page-B7NZPSpO.js.map +0 -1
  172. package/dist/gateway/static/root/assets/skills-page-D-AJTEVx.js +0 -3
  173. package/dist/gateway/static/root/assets/skills-page-D-AJTEVx.js.map +0 -1
@@ -0,0 +1,216 @@
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{$n as i,A as a,An as o,Ar as s,At as c,C as l,Cn as u,Cr as d,D as f,Di as p,Dn as m,Dt as h,E as g,F as _,Gn as v,Hn as y,I as b,In as x,Ir as S,It as C,Jr as w,Kn as T,Kr as ee,Ln as E,Lt as D,M as O,Mn as k,Mt as te,N as A,Nt as j,O as M,Oi as ne,Ot as re,P as N,Q as ie,Rn as ae,Rr as oe,Rt as P,S as se,Si as ce,Sn as le,St as ue,T as de,Un as F,Ur as fe,Vn as pe,Vr as me,Wn as I,X as he,Xn as ge,Z as _e,Zn as ve,_ as ye,_n as be,at as xe,b as Se,bn as L,br as Ce,cr as R,ct as we,dn as z,dr as Te,ei as B,er as V,fr as Ee,gi as De,gn as H,ii as Oe,it as ke,j as Ae,jn as je,jr as Me,jt as Ne,k as Pe,ki as Fe,kn as Ie,kt as Le,lt as Re,m as ze,mr as Be,ni as Ve,nt as He,or as Ue,ot as We,pr as Ge,ri as Ke,rt as qe,si as U,sr as W,st as G,tt as K,v as Je,vi as Ye,vn as Xe,vr as Ze,w as Qe,wi as $e,x as et,xt as tt,y as nt,zn as rt,zt as it}from"./index-BUYGk2UT.js";import{a as at,b as ot,d as st,h as ct,r as lt,t as ut,u as dt}from"./cron-dreaming-jobs-D460WnXB.js";var q=n();function ft({open:e,onOpenChange:t,busy:n,deletePurge:r,deleteTarget:i,deleteConfirmText:a,onDeleteConfirmTextChange:o,onConfirm:s,onCancel:l,a:u}){return(0,q.jsx)(te,{open:e,onOpenChange:t,children:(0,q.jsxs)(Ne,{children:[(0,q.jsx)(c,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,q.jsxs)(re,{className:x(`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,q.jsx)(j,{className:`text-base font-semibold text-fg`,children:r?u.purgeDisk:u.removeFromConfig}),(0,q.jsx)(Le,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:r?u.confirmDeletePurge:u.confirmDelete}),r&&i?(0,q.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,q.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-fg`,htmlFor:`agent-delete-confirm`,children:u.purgeConfirmLabel}),(0,q.jsx)(`input`,{id:`agent-delete-confirm`,type:`text`,autoComplete:`off`,spellCheck:!1,className:x(`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,q.jsx)(`p`,{className:`pt-0.5 text-xs text-fg-muted`,children:u.purgeConfirmHint.replace(`{{agentId}}`,i.id)})]}):null,(0,q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle/60 pt-3`,children:[(0,q.jsx)(k,{type:`button`,variant:`ghost`,disabled:n,onClick:l,children:u.createModalCancel}),(0,q.jsx)(k,{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:s,children:r?u.purgeDisk:u.removeFromConfig})]})]})]})})}var pt=[{id:`overview`,labelKey:`navIdentity`,icon:pe},{id:`profile`,labelKey:`navProfile`,icon:U},{id:`tools`,labelKey:`navTools`,icon:rt},{id:`skills`,labelKey:`navSkills`,icon:Ee},{id:`files`,labelKey:`navCoreFiles`,icon:ee}],mt=[{id:`channels`,labelKey:`tabChannels`,icon:Be},{id:`cron`,labelKey:`tabCron`,icon:Oe}];function ht(e){let{a:t,panel:n,onPanelChange:r}=e,i=(e,t,i)=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:x(`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,q.jsx)(i,{className:`size-4 shrink-0 opacity-90`,strokeWidth:2,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`min-w-0 truncate`,children:t})]},e);return(0,q.jsxs)(`nav`,{className:`flex w-full flex-col gap-1`,"aria-label":t.editorNavAria,children:[(0,q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:pt.map(({id:e,labelKey:n,icon:r})=>i(e,t[n],r))}),(0,q.jsx)(`p`,{className:`mt-4 px-3 text-[10px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.navAdvanced}),(0,q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:mt.map(({id:e,labelKey:n,icon:r})=>i(e,t[n],r))})]})}function gt(e){let{open:t,onOpenChange:n,a:r,title:i,subtitle:a,panel:o,onPanelChange:s,onFooterSave:l,footerSaveDisabled:u,footerSavedFlash:d,busy:f,children:p}=e;return(0,q.jsx)(te,{open:t,onOpenChange:n,children:(0,q.jsxs)(Ne,{children:[(0,q.jsx)(c,{className:x(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Je)}),(0,q.jsxs)(re,{className:x(`xopc-dialog-content fixed flex flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,ye,`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,q.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,q.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,q.jsx)(j,{className:`text-base font-semibold leading-snug text-fg`,children:i}),(0,q.jsx)(Le,{className:`mt-1 font-mono text-xs text-fg-muted`,children:a})]}),(0,q.jsx)(h,{asChild:!0,children:(0,q.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,q.jsx)(ae,{className:`size-4`,"aria-hidden":!0})})})]}),(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row sm:overflow-hidden`,children:[(0,q.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,q.jsx)(ht,{a:r,panel:o,onPanelChange:s})}),(0,q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 sm:pl-2 sm:pr-5`,children:p}),(0,q.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:[d?(0,q.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,q.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,q.jsx)(k,{type:`button`,className:`order-1 w-full sm:order-2 sm:w-auto`,disabled:f||u,onClick:()=>void l(),children:r.save})]})]})]})]})]})})}function _t(){return`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`}function J({children:e,className:t}){return(0,q.jsx)(`section`,{className:x(_t(),t),children:e})}var vt=`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 Y({icon:e,title:t,subtitle:n,trailing:r,className:i,iconInteractive:a,iconLeading:o}){let s=o??(0,q.jsx)(e,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),c=o?x(`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`):x(vt,`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,q.jsxs)(`div`,{className:x(`mb-5 flex items-start gap-3`,i),children:[a?l?(0,q.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,q.jsx)(`button`,{type:`button`,id:a.id,onClick:a.onClick,"aria-label":a.ariaLabel,className:c,children:s}),(0,q.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,q.jsx)(Ze,{className:`size-2.5`,strokeWidth:2.25})})]}):(0,q.jsx)(`button`,{type:`button`,id:a.id,onClick:a.onClick,"aria-label":a.ariaLabel,className:c,children:s}):(0,q.jsx)(`div`,{className:x(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`:vt),"aria-hidden":!o,children:s}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t}),(0,q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n})]}),r?(0,q.jsx)(`div`,{className:`shrink-0`,children:r}):null]})}function X(){return x(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,o,`dark:border-edge`)}function yt(e,t,n){let r=e.agentId?.trim().toLowerCase();return r?r===t.toLowerCase():t.toLowerCase()===n.toLowerCase()}function bt(e){return[e.channel,e.accountId,e.peerKind,e.peerId].filter(e=>typeof e==`string`&&e.length>0).join(` · `)||e.channel}function xt(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 St=x(Ie,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`);function Ct(e){let{a:t,busy:n,bindingsLoading:r,agentBindings:i,onRemoveBinding:a,onAddBinding:o,channelStatuses:c,channelsStatusLoading:l,useManualChannel:u,newBindChannel:d,setNewBindChannel:f,bindSessionChats:p,sessionsLoading:m,newBindSessionIdx:h,setNewBindSessionIdx:g,newBindCustomPeer:_,setNewBindCustomPeer:v,onRefreshSessions:y,lastActiveLabels:b,selectRecipient:S}=e,C=!l&&(u||c.length>0);return(0,q.jsxs)(J,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,q.jsx)(Y,{className:`shrink-0`,icon:s,title:t.channelsTitle,subtitle:t.channelsHint}),r?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsLoading}):i.length===0?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsNone}):(0,q.jsx)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:i.map((e,r)=>(0,q.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,q.jsx)(`span`,{className:`font-mono text-xs`,children:bt(e.match)}),(0,q.jsx)(k,{type:`button`,variant:`secondary`,disabled:n,onClick:()=>void a(e),children:t.removeBinding})]},`${e.match.channel}-${r}`))}),(0,q.jsxs)(`form`,{className:`mt-4 flex flex-col gap-3`,onSubmit:o,children:[l?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsLoadingChannels}):u?(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:t.channelLabel}),(0,q.jsx)(`input`,{className:X(),value:d,onChange:e=>f(e.target.value),placeholder:`telegram`,autoComplete:`off`}),(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsManualChannelHint})]}):(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:t.channelLabel}),(0,q.jsx)(`select`,{className:x(X(),`py-2`),value:d,onChange:e=>{f(e.target.value),g(null),v(``)},children:c.map(e=>(0,q.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:t.channelsDisabledSuffix]},e.name))})]}),C&&d.trim()?(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-3 text-sm`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:t.channelsSessionLabel}),(0,q.jsxs)(k,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,disabled:n||m||!d.trim(),title:t.channelsRefreshSessionsHint,onClick:()=>y(),children:[(0,q.jsx)(Te,{className:x(`size-3.5`,m&&`animate-spin`),strokeWidth:1.75}),t.channelsRefreshSessions]})]}),m&&p.length===0?(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsLoadingSessions}):null,(0,q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:t.channelsPeerFromSessions}),(0,q.jsxs)(`select`,{className:x(X(),`py-2`),value:h==null?``:String(h),disabled:n||!d.trim()||!!_.trim(),onChange:e=>{let t=e.target.value;g(t===``?null:Number(t))},children:[(0,q.jsx)(`option`,{value:``,children:t.channelsPeerAny}),p.map((e,t)=>(0,q.jsx)(`option`,{value:String(t),children:ot(e,b)},`${e.channel}-${e.chatId}-${t}`))]})]}),p.length===0&&d.trim()&&!m?(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsNoSessionsHint}):null,(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:t.peerIdLabel}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,q.jsx)(`input`,{type:`text`,className:x(X(),`min-w-0 w-full sm:flex-1`),value:_,onChange:e=>{v(e.target.value),e.target.value.trim()&&g(null)},placeholder:t.channelsCustomPeerPlaceholder,autoComplete:`off`}),(0,q.jsxs)(`select`,{className:St,value:_,onChange:e=>{let t=e.target.value;v(t||``),g(null)},children:[(0,q.jsx)(`option`,{value:``,children:S}),p.map(e=>(0,q.jsx)(`option`,{value:e.chatId,children:ot(e,b)},`${e.channel}-${e.chatId}`))]})]}),(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsCustomPeerHint})]})]}):null,(0,q.jsx)(`div`,{children:(0,q.jsx)(k,{type:`submit`,disabled:n||!d.trim()||l,children:t.addBinding})})]})]})}function wt(e){let{a:t,data:n,busy:r,cronLoading:i,agentCronJobs:a,onSetCronJobAgent:o}=e;return(0,q.jsxs)(J,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,q.jsx)(Y,{className:`shrink-0`,icon:ce,title:t.cronTitle,subtitle:t.cronHint}),i?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.cronLoading}):a.length===0?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.cronNone}):(0,q.jsx)(`div`,{className:`overflow-x-auto`,children:(0,q.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{className:`border-b border-edge text-fg-muted`,children:[(0,q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColSchedule}),(0,q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColMessage}),(0,q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColSession}),(0,q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColAgent})]})}),(0,q.jsx)(`tbody`,{children:a.map(e=>{let i=!e.agentId?.trim(),a=i?``:e.agentId.trim().toLowerCase();return(0,q.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,q.jsx)(`td`,{className:`py-2 pr-3 font-mono text-xs`,children:e.schedule}),(0,q.jsx)(`td`,{className:`max-w-[12rem] truncate py-2 pr-3 text-xs`,title:lt(e),children:lt(e)}),(0,q.jsx)(`td`,{className:`py-2 pr-3 text-xs`,children:e.sessionTarget??`main`}),(0,q.jsx)(`td`,{className:`py-2 pr-3`,children:(0,q.jsxs)(`select`,{className:x(X(),`min-w-[8rem] py-1 text-xs`),value:a,disabled:r||e.sessionTarget!==`isolated`,onChange:t=>void o(e,t.target.value),children:[(0,q.jsx)(`option`,{value:``,children:i?t.cronAgentDefault:t.cronAgentClear}),n.agents.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.id},e.id))]})})]},e.id)})})]})})]})}function Tt(e){let{a:t,filesLoading:n,files:r,activeFile:i,setActiveFile:a,bootstrapViewMode:o,setBootstrapViewMode:s,fileDraft:c,setFileDraft:l,fileSaving:u,bootstrapFileLoading:d,bootstrapEditorNonce:f}=e,p=le(e=>e.resolved===`dark`);return(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[(0,q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesHint}),n?(0,q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesLoading}):r?(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,q.jsx)(`nav`,{className:`flex shrink-0 flex-row flex-wrap gap-x-0.5 gap-y-0 border-b border-edge-subtle`,"aria-label":t.tabFiles,children:r.files.map(e=>(0,q.jsxs)(`button`,{type:`button`,className:x(`-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,q.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2 overflow-hidden`,children:i?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2`,children:[(0,q.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-panel p-0.5`,role:`group`,"aria-label":t.filesBootstrapEdit,children:[(0,q.jsxs)(`button`,{type:`button`,className:x(`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,q.jsx)(ge,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t.filesBootstrapEdit]}),(0,q.jsxs)(`button`,{type:`button`,className:x(`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,q.jsx)(w,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t.filesBootstrapPreview]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[u?(0,q.jsx)(`span`,{children:t.filesSavingStatus}):null,(0,q.jsx)(`span`,{children:t.filesAutoSaveHint})]})]}),o===`edit`?(0,q.jsx)(`div`,{className:x(X(),`flex min-h-0 flex-1 flex-col overflow-hidden p-0`,d&&`pointer-events-none opacity-60`),children:(0,q.jsx)(_e,{initialContent:c,onChange:l,isDark:p,className:`min-h-0 flex-1`},`${i??`file`}-${f}`)}):(0,q.jsx)(`div`,{className:x(X(),`min-h-0 flex-1 overflow-y-auto text-sm`,d&&`pointer-events-none opacity-60`),children:(0,q.jsx)(he,{content:c,className:`text-sm`})})]}):(0,q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.pickFile})})]}):(0,q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesEmpty})]})}var Z=e(t(),1);function Et(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 Dt(e){let{agentId:t,value:n,onChange:r,a:i,id:a}=e,o=(0,Z.useRef)(null),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(!1),p=(0,Z.useMemo)(()=>{let e=Re(n.trim());return e&&we(e.styleId)?e.styleId:ke[0]??`adventurer`},[n]),m=(0,Z.useCallback)(async(e,n)=>{try{await g(t)}catch{}r(We(e,n)),f(!1)},[t,r]),h=(0,Z.useCallback)(async e=>{let n=e.target.files?.[0];if(e.target.value=``,n){u(null),c(!0);try{await b(t,n),r(xe)}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=Re(n.trim());return!!(r&&r.styleId===e&&r.seed===t)};return(0,q.jsxs)(`div`,{...a?{id:a}:{},className:`flex flex-col gap-3 sm:col-span-2`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:i.avatarPickerTitle}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{ref:o,type:`file`,accept:`image/png,image/jpeg,image/webp,.png,.jpg,.jpeg,.webp`,className:`hidden`,onChange:e=>void h(e)}),(0,q.jsxs)(k,{type:`button`,variant:`secondary`,className:`gap-1.5 px-2.5 py-1.5 text-xs`,disabled:s,onClick:()=>o.current?.click(),children:[(0,q.jsx)(F,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),s?i.avatarUploading:i.avatarUploadCustom]})]})]}),l?(0,q.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:l}):null,(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ke.map(e=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>void m(e,qe[0]??t),className:x(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,p===e?`border-fg bg-fg text-surface-base`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),children:Et(e,i)},e))}),(0,q.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel/50 p-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[qe.map(e=>(0,q.jsx)(`button`,{type:`button`,title:e,onClick:()=>void m(p,e),className:x(`flex size-12 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,_(p,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,q.jsx)(`img`,{src:G(p,e,96),alt:``,width:44,height:44,className:`size-11 rounded-full object-cover`,draggable:!1})},e)),(0,q.jsxs)(P,{open:d,onOpenChange:f,children:[(0,q.jsx)(it,{asChild:!0,children:(0,q.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,q.jsx)(D,{children:(0,q.jsxs)(C,{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,q.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:Et(p,i)}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:He.map(e=>(0,q.jsx)(`button`,{type:`button`,title:e,onClick:()=>void m(p,e),className:x(`flex size-11 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,_(p,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,q.jsx)(`img`,{src:G(p,e,88),alt:``,width:40,height:40,className:`size-10 rounded-full object-cover`,draggable:!1})},e))})]})})]})]}),(0,q.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t border-edge-subtle pt-3`,children:[(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i.personaAvatar}),(0,q.jsx)(K,{agentId:t,avatar:n,size:40}),n.trim()&&!Re(n.trim())&&n.trim()!==`xopc:custom`?(0,q.jsx)(`span`,{className:`truncate font-mono text-[10px] text-fg-muted`,title:n,children:n}):null]})]})]})}var Ot={name:``,creature:``,emoji:``,avatar:``};function kt(e){let t={...Ot};if(!e.trim())return t;let n={name:`name`,creature:`creature`,emoji:`emoji`,avatar:`avatar`};for(let r of e.split(`
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 At(e){return[`# IDENTITY.md - Who Am I?`,``,`- **Name:** ${e.name}`,`- **Creature:** ${e.creature}`,`- **Emoji:** ${e.emoji}`,`- **Avatar:** ${e.avatar}`,``].join(`
3
+ `)}var jt={callName:``,pronouns:``,timezone:``,notes:``};function Mt(e){let t={...jt};if(!e.trim())return t;let n={name:`callName`,"what to call them":`callName`,pronouns:`pronouns`,timezone:`timezone`,notes:`notes`},r=e.split(`
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(`
5
+ `).replace(/^_\(.*?\)_\s*/gm,``).replace(/^---\s*$/gm,``).replace(/The more you know.*$/s,``).trim();e&&!t.notes&&(t.notes=e)}return t}function Nt(e){let t=[`# USER.md - About Your Human`,``,`- **Name:** ${e.callName}`,`- **Pronouns:** ${e.pronouns}`,`- **Timezone:** ${e.timezone}`,``];return e.notes.trim()&&t.push(`## Context`,``,e.notes.trim(),``),t.join(`
6
+ `)}var Pt=[{id:`professional`,labelEn:`Professional & Efficient`,labelZh:`专业高效`,emoji:`🎯`,content:`# SOUL.md - Who You Are
7
+
8
+ ## Core Truths
9
+
10
+ **Be genuinely helpful, not performatively helpful.** Skip the filler words — just help. Actions speak louder than pleasantries.
11
+
12
+ **Be precise and efficient.** Value the user's time. Give concise, actionable answers. Expand only when asked.
13
+
14
+ **Earn trust through competence.** Be careful with external actions. Be bold with internal ones (reading, organizing, learning).
15
+
16
+ **Remember you're a guest.** You have access to someone's life. Treat it with respect.
17
+
18
+ ## Boundaries
19
+
20
+ - Private things stay private. Period.
21
+ - When in doubt, ask before acting externally.
22
+ - Never send half-baked replies to messaging surfaces.
23
+
24
+ ## Vibe
25
+
26
+ Professional, competent, and respectful. Concise when needed, thorough when it matters.`},{id:`casual`,labelEn:`Warm & Friendly`,labelZh:`轻松友好`,emoji:`😊`,content:`# SOUL.md - Who You Are
27
+
28
+ ## Core Truths
29
+
30
+ **Be a good friend, not a corporate drone.** Be warm, genuine, and real. Skip the formality when it gets in the way.
31
+
32
+ **Have personality.** You're allowed to be amused, surprised, or excited. An assistant with no personality is just a search engine.
33
+
34
+ **Be resourceful before asking.** Try to figure it out first. Then ask if you're stuck.
35
+
36
+ **Earn trust by being reliable.** Show up, follow through, and remember what matters.
37
+
38
+ **Respect the intimacy.** You have access to someone's life. That's a privilege.
39
+
40
+ ## Boundaries
41
+
42
+ - Private things stay private. Always.
43
+ - When in doubt, ask before acting externally.
44
+ - Be careful in group chats — you're not the user's voice.
45
+
46
+ ## Vibe
47
+
48
+ Warm, friendly, and a little playful. Like a helpful friend who happens to know everything.`},{id:`geeky`,labelEn:`Geeky & Witty`,labelZh:`极客风格`,emoji:`🧑‍💻`,content:`# SOUL.md - Who You Are
49
+
50
+ ## Core Truths
51
+
52
+ **Precision over politeness.** "This is broken" beats "This might be worth considering." Be direct.
53
+
54
+ **Have opinions.** Disagree, prefer things, find stuff interesting or dull. No personality = no value.
55
+
56
+ **Go deep.** When something is interesting, explore it. Surface-level answers are for search engines.
57
+
58
+ **Be resourceful.** Read the file. Check the context. Search for it. Come back with answers, not questions.
59
+
60
+ **Earn trust through competence.** Be careful with external actions. Be bold with internal ones.
61
+
62
+ ## Boundaries
63
+
64
+ - Private things stay private.
65
+ - When in doubt, ask before acting externally.
66
+ - Never send half-baked replies.
67
+
68
+ ## Vibe
69
+
70
+ Sharp, direct, slightly nerdy. The kind of engineer you'd want on your team — competent, opinionated, and occasionally funny.`},{id:`custom`,labelEn:`Custom`,labelZh:`自定义`,emoji:`✍️`,content:``}];function Ft(e){let t=e.trimStart();if(!t.startsWith(`---`))return e;let n=t.indexOf(`---`,3);return n===-1?e:t.slice(n+3).trimStart()}function It(e){let t=Ft(e).trim();if(!t)return`professional`;for(let e of Pt)if(e.id!==`custom`&&(t===e.content.trim()||Lt(e.id).filter(e=>t.includes(e)).length>=2))return e.id;return`custom`}function Lt(e){switch(e){case`professional`:return[`precise and efficient`,`Value the user's time`,`actionable answers`];case`casual`:return[`good friend`,`corporate drone`,`a little playful`];case`geeky`:return[`Precision over politeness`,`Go deep`,`slightly nerdy`];default:return[]}}var Rt=[{value:``,labelEn:`Not set`,labelZh:`未设置`},{value:`Asia/Shanghai`,labelEn:`Asia/Shanghai (CST, UTC+8)`,labelZh:`亚洲/上海 (北京时间, UTC+8)`},{value:`Asia/Tokyo`,labelEn:`Asia/Tokyo (JST, UTC+9)`,labelZh:`亚洲/东京 (日本时间, UTC+9)`},{value:`Asia/Seoul`,labelEn:`Asia/Seoul (KST, UTC+9)`,labelZh:`亚洲/首尔 (韩国时间, UTC+9)`},{value:`Asia/Singapore`,labelEn:`Asia/Singapore (SGT, UTC+8)`,labelZh:`亚洲/新加坡 (UTC+8)`},{value:`Asia/Hong_Kong`,labelEn:`Asia/Hong Kong (HKT, UTC+8)`,labelZh:`亚洲/香港 (UTC+8)`},{value:`Asia/Taipei`,labelEn:`Asia/Taipei (CST, UTC+8)`,labelZh:`亚洲/台北 (UTC+8)`},{value:`Asia/Kolkata`,labelEn:`Asia/Kolkata (IST, UTC+5:30)`,labelZh:`亚洲/加尔各答 (印度时间, UTC+5:30)`},{value:`Asia/Dubai`,labelEn:`Asia/Dubai (GST, UTC+4)`,labelZh:`亚洲/迪拜 (UTC+4)`},{value:`Europe/London`,labelEn:`Europe/London (GMT/BST)`,labelZh:`欧洲/伦敦 (格林尼治时间)`},{value:`Europe/Paris`,labelEn:`Europe/Paris (CET, UTC+1)`,labelZh:`欧洲/巴黎 (中欧时间, UTC+1)`},{value:`Europe/Berlin`,labelEn:`Europe/Berlin (CET, UTC+1)`,labelZh:`欧洲/柏林 (中欧时间, UTC+1)`},{value:`Europe/Moscow`,labelEn:`Europe/Moscow (MSK, UTC+3)`,labelZh:`欧洲/莫斯科 (UTC+3)`},{value:`America/New_York`,labelEn:`America/New York (EST, UTC-5)`,labelZh:`美国/纽约 (东部时间, UTC-5)`},{value:`America/Chicago`,labelEn:`America/Chicago (CST, UTC-6)`,labelZh:`美国/芝加哥 (中部时间, UTC-6)`},{value:`America/Denver`,labelEn:`America/Denver (MST, UTC-7)`,labelZh:`美国/丹佛 (山地时间, UTC-7)`},{value:`America/Los_Angeles`,labelEn:`America/Los Angeles (PST, UTC-8)`,labelZh:`美国/洛杉矶 (太平洋时间, UTC-8)`},{value:`America/Sao_Paulo`,labelEn:`America/São Paulo (BRT, UTC-3)`,labelZh:`美洲/圣保罗 (巴西时间, UTC-3)`},{value:`Australia/Sydney`,labelEn:`Australia/Sydney (AEST, UTC+10)`,labelZh:`澳大利亚/悉尼 (UTC+10)`},{value:`Pacific/Auckland`,labelEn:`Pacific/Auckland (NZST, UTC+12)`,labelZh:`太平洋/奥克兰 (新西兰时间, UTC+12)`}];function zt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return``}}var Bt=[{value:`先生`,labelEn:`Mr.`,labelZh:`先生`},{value:`女士`,labelEn:`Ms.`,labelZh:`女士`},{value:`同学`,labelEn:`Colleague`,labelZh:`同学`},{value:`老师`,labelEn:`Teacher`,labelZh:`老师`},{value:`老板`,labelEn:`Boss`,labelZh:`老板`},{value:`朋友`,labelEn:`Friend`,labelZh:`朋友`}],Vt=[{value:`AI assistant`,labelEn:`AI Assistant`,labelZh:`AI 助手`},{value:`robot`,labelEn:`Robot`,labelZh:`机器人`},{value:`familiar`,labelEn:`Familiar`,labelZh:`精灵`},{value:`ghost in the machine`,labelEn:`Ghost in the machine`,labelZh:`机器幽灵`},{value:`digital companion`,labelEn:`Digital Companion`,labelZh:`数字伙伴`}];function Ht(e){let{a:t,chat:n,selected:r,busy:i,editName:a,setEditName:o,editDescription:s,setEditDescription:l,editWorkspace:d,setEditWorkspace:f,editModel:p,setEditModel:m,onSetDefault:g,onSaveAgentEdits:_,onDelete:y,hideInlineSave:b,saveBootstrapRef:S,onBootstrapDirtyChange:C}=e,T=u(e=>e.language),ee=le(e=>e.resolved===`dark`),[E,D]=(0,Z.useState)(!0),[,O]=(0,Z.useState)(!1),[A,ne]=(0,Z.useState)({name:``,creature:``,emoji:``,avatar:``}),[ie,oe]=(0,Z.useState)(`professional`),[P,se]=(0,Z.useState)(``),[ce,ue]=(0,Z.useState)(0),[de,F]=(0,Z.useState)(!1),[fe,me]=(0,Z.useState)(!1),ge=(0,Z.useRef)(!1),be=(0,Z.useRef)(r?.id??``);be.current=r?.id??``;let xe=(0,Z.useRef)(``),Se=(0,Z.useRef)(``);(0,Z.useEffect)(()=>{if(!r)return;let e=!1;return ge.current=!1,D(!0),(async()=>{try{let[t,n]=await Promise.all([M(r.id,`IDENTITY.md`).catch(()=>``),M(r.id,`SOUL.md`).catch(()=>``)]);if(e)return;let i=kt(t);ne(i),xe.current=JSON.stringify(i),oe(It(n)),se(n),Se.current=n,ue(e=>e+1)}finally{e||(D(!1),ge.current=!0)}})(),()=>{e=!0}},[r?.id]);let L=(0,Z.useCallback)(async(e,t)=>{O(!0);try{await N(be.current,e,t)}finally{O(!1)}},[]),Ce=(0,Z.useRef)(A);Ce.current=A;let R=(0,Z.useRef)(P);R.current=P,(0,Z.useEffect)(()=>{if(S)return S.current=async()=>{await Promise.all([L(`IDENTITY.md`,At(Ce.current)),L(`SOUL.md`,R.current)]),xe.current=JSON.stringify(Ce.current),Se.current=R.current,C?.(!1)},()=>{S.current=null}},[S,L,C]),(0,Z.useEffect)(()=>{if(!C)return;let e=JSON.stringify(A)!==xe.current,t=P!==Se.current;C(e||t)},[A,P,C]);let we=(0,Z.useCallback)(e=>{ne(t=>({...t,...e}))},[]),z=(0,Z.useCallback)(e=>{if(oe(e),e!==`custom`){let t=Pt.find(t=>t.id===e);t?.content&&(se(t.content),ue(e=>e+1))}},[]),Te=(0,Z.useCallback)(e=>{se(e),oe(`custom`)},[]),B=(0,Z.useCallback)((e,t)=>T===`zh`?t:e,[T]),V=X();return r?(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-8 overflow-y-auto`,children:[(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:ve,title:t.personaSectionIdentity,subtitle:t.personaSectionIdentityHint,iconLeading:(0,q.jsx)(K,{agentId:r.id,avatar:A.avatar,size:36,className:`size-9 rounded-lg`}),iconInteractive:{onClick:()=>me(!0),ariaLabel:t.avatarOpenSettingsAria,id:`agent-avatar-settings`},trailing:r.isDefault?null:(0,q.jsx)(k,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:i,onClick:()=>void g(),children:t.setDefault})}),(0,q.jsx)(te,{open:fe,onOpenChange:me,children:(0,q.jsxs)(Ne,{children:[(0,q.jsx)(c,{className:x(`fixed inset-0 bg-scrim backdrop-blur-[2px]`,Je)}),(0,q.jsxs)(re,{className:x(`fixed left-1/2 top-1/2 w-[min(calc(100vw-2rem),26rem)] max-h-[min(90dvh,36rem)] -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,ye),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,q.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[(0,q.jsx)(j,{className:`text-base font-semibold text-fg`,children:t.avatarPickerTitle}),(0,q.jsx)(h,{asChild:!0,children:(0,q.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":t.closeDialogAria,children:(0,q.jsx)(ae,{className:`size-4`,"aria-hidden":!0})})})]}),(0,q.jsx)(Le,{className:`sr-only`,children:t.avatarRowHint}),(0,q.jsx)(Dt,{agentId:r.id,value:A.avatar,onChange:e=>we({avatar:e}),a:t})]})]})}),(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium text-fg`,children:t.displayName}),(0,q.jsx)(`input`,{className:V,value:a,onChange:e=>{o(e.target.value),we({name:e.target.value})},placeholder:t.personaNamePlaceholder,autoComplete:`off`})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium text-fg`,children:t.personaEmoji}),(0,q.jsx)(`input`,{className:V,value:A.emoji,onChange:e=>we({emoji:e.target.value}),placeholder:t.personaEmojiPlaceholder,autoComplete:`off`})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,q.jsx)(`span`,{className:`font-medium text-fg`,children:t.agentDescription}),(0,q.jsx)(`textarea`,{className:x(V,`min-h-16 resize-y text-sm leading-relaxed`),value:s,onChange:e=>l(e.target.value),placeholder:t.agentDescriptionPlaceholder,maxLength:4e3,rows:3,spellCheck:!0})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium text-fg`,children:t.personaCreature}),(0,q.jsxs)(`select`,{className:V,value:Vt.some(e=>e.value===A.creature)?A.creature:`__custom__`,onChange:e=>{if(e.target.value===`__custom__`){we({creature:``});return}we({creature:e.target.value})},children:[Vt.map(e=>(0,q.jsx)(`option`,{value:e.value,children:B(e.labelEn,e.labelZh)},e.value)),(0,q.jsx)(`option`,{value:`__custom__`,children:B(`Custom…`,`自定义…`)})]}),Vt.some(e=>e.value===A.creature)?null:(0,q.jsx)(`input`,{className:x(V,`mt-1 text-xs`),value:A.creature,onChange:e=>we({creature:e.target.value}),placeholder:t.personaCreaturePlaceholder,autoComplete:`off`})]})]})]}),(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:Ve,title:t.editAgent,subtitle:t.editAgentHint}),(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,q.jsx)(`span`,{className:`font-medium text-fg`,children:t.modelPrimary}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[(0,q.jsx)(ze,{className:`min-w-0 flex-1`,popoverContentClassName:nt,value:p,disabled:i,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>m(e)}),p.trim()?(0,q.jsx)(k,{type:`button`,variant:`secondary`,className:`shrink-0`,disabled:i,onClick:()=>m(``),children:t.modelClear}):null]})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,q.jsx)(`span`,{className:`font-medium text-fg`,children:t.workspacePath}),(0,q.jsx)(`input`,{className:x(V,`font-mono text-xs`),value:d,onChange:e=>f(e.target.value)})]})]}),b?null:(0,q.jsx)(`div`,{className:`mt-4`,children:(0,q.jsx)(k,{type:`button`,disabled:i,onClick:()=>void _(),children:t.save})})]}),E?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.loading}):(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:pe,title:t.personaSectionSoul,subtitle:t.personaSectionSoulHint}),(0,q.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.personaSoulTemplate}),(0,q.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-4`,children:Pt.map(e=>(0,q.jsxs)(`button`,{type:`button`,className:x(`flex flex-col items-center gap-1.5 rounded-xl border-2 px-3 py-3 text-center transition-all`,ie===e.id?`border-accent bg-accent-soft/40 shadow-sm`:`border-edge hover:border-accent/40 hover:bg-surface-hover`),onClick:()=>z(e.id),children:[(0,q.jsx)(`span`,{className:`text-xl`,children:e.emoji}),(0,q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:B(e.labelEn,e.labelZh)})]},e.id))})]}),ie===`custom`?(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.personaSoulCustomEdit}),(0,q.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:de?t.personaSoulEdit:t.personaSoulPreview,"aria-label":de?t.personaSoulEdit:t.personaSoulPreview,onClick:()=>F(e=>!e),children:de?(0,q.jsx)(Ze,{className:`size-4`,"aria-hidden":!0}):(0,q.jsx)(w,{className:`size-4`,"aria-hidden":!0})})]}),(0,q.jsx)(`div`,{className:x(V,`flex min-h-64 flex-col overflow-hidden p-0`),children:de?(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,q.jsx)(he,{content:P})}):(0,q.jsx)(_e,{initialContent:P,onChange:Te,isDark:ee,className:`min-h-0 flex-1`},`soul-${ce}`)})]}):null]}),r.id===`main`?null:(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:I,title:B(`Danger Zone`,`危险操作`),subtitle:B(`Actions that cannot be undone. Be careful.`,`以下操作不可撤销,请谨慎操作。`)}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsxs)(k,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void y(!1),children:[(0,q.jsx)(v,{className:`mr-1 size-4`,"aria-hidden":!0}),t.removeFromConfig]}),(0,q.jsx)(k,{type:`button`,variant:`secondary`,className:`border-red-200 text-red-700 hover:bg-red-50 dark:border-red-900/60 dark:text-red-300 dark:hover:bg-red-950/40`,disabled:i,onClick:()=>void y(!0),children:t.purgeDisk})]})]})]}):(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.selectAgentHint})}function Ut({a:e,agentId:t,saveRef:n,onDirtyChange:r}){let i=u(e=>e.language),[a,o]=(0,Z.useState)(!0),[,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)({callName:``,pronouns:``,timezone:``,notes:``}),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(``),_=(0,Z.useRef)(!1),v=(0,Z.useRef)(t);v.current=t;let y=(0,Z.useRef)(``),b=(0,Z.useCallback)(async e=>{let t=v.current;s(!0);try{await N(t,`USER.md`,e)}finally{s(!1)}},[]),S=(0,Z.useRef)(c);S.current=c,(0,Z.useEffect)(()=>{if(n)return n.current=async()=>{await b(Nt(S.current)),y.current=JSON.stringify(S.current),r?.(!1)},()=>{n.current=null}},[n,b,r]),(0,Z.useEffect)(()=>{r&&r(JSON.stringify(c)!==y.current)},[c,r]),(0,Z.useEffect)(()=>{let e=!1;return _.current=!1,o(!0),(async()=>{try{let n=await M(t,`USER.md`).catch(()=>``);if(e)return;let r=Mt(n),i=r;if(!r.timezone){let e=zt();e&&(i={...r,timezone:e})}l(i),y.current=JSON.stringify(i);let a=!i.pronouns||Bt.some(e=>e.value===i.pronouns);i.pronouns&&!a&&f(!0);let o=Rt.some(e=>e.value===i.timezone);i.timezone&&!o&&(m(!0),g(i.timezone))}finally{e||(o(!1),_.current=!0)}})(),()=>{e=!0}},[t]);let C=(0,Z.useCallback)(e=>{l(t=>({...t,...e}))},[]),w=(0,Z.useCallback)(e=>{if(e===`__custom__`){m(!0);return}m(!1),g(``),C({timezone:e})},[C]),T=(0,Z.useCallback)(e=>{g(e),C({timezone:e})},[C]),ee=(0,Z.useCallback)(()=>{let e=zt();e&&(Rt.some(t=>t.value===e)?(m(!1),g(``)):(m(!0),g(e)),C({timezone:e}))},[C]),E=p?`__custom__`:Rt.some(e=>e.value===c.timezone)?c.timezone:`__custom__`,D=(0,Z.useCallback)((e,t)=>i===`zh`?t:e,[i]);if(a)return(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.loading});let O=X();return(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto`,children:[(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.personaSectionUserHint}),(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:U,title:e.personaSectionUser,subtitle:e.personaSectionUserHint}),(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaCallName}),(0,q.jsx)(`input`,{className:O,value:c.callName,onChange:e=>C({callName:e.target.value}),placeholder:e.personaCallNamePlaceholder,autoComplete:`off`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaPronouns}),(0,q.jsxs)(`select`,{className:O,value:Bt.some(e=>e.value===c.pronouns)?c.pronouns:`__custom__`,onChange:e=>{if(e.target.value===`__custom__`){f(!0);return}f(!1),C({pronouns:e.target.value})},children:[(0,q.jsx)(`option`,{value:``,disabled:!0,children:e.personaPronounsPlaceholder}),Bt.map(e=>(0,q.jsx)(`option`,{value:e.value,children:D(e.labelEn,e.labelZh)},e.value)),(0,q.jsx)(`option`,{value:`__custom__`,children:D(`Custom…`,`自定义…`)})]}),d?(0,q.jsx)(`input`,{className:x(O,`mt-1 text-xs`),value:Bt.some(e=>e.value===c.pronouns)?``:c.pronouns,onChange:e=>C({pronouns:e.target.value}),placeholder:e.personaPronounsPlaceholder,autoComplete:`off`}):null]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,q.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaTimezone}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[(0,q.jsxs)(`select`,{className:x(O,`min-w-0 flex-1`),value:E,onChange:e=>w(e.target.value),children:[Rt.map(e=>(0,q.jsx)(`option`,{value:e.value,children:D(e.labelEn,e.labelZh)},e.value)),(0,q.jsx)(`option`,{value:`__custom__`,children:e.personaTimezoneCustom})]}),(0,q.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:ee,children:e.personaTimezoneDetect})]}),p?(0,q.jsx)(`input`,{className:x(O,`mt-1 font-mono text-xs`),value:h,onChange:e=>T(e.target.value),placeholder:`e.g. Asia/Shanghai`,autoComplete:`off`}):null]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,q.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaNotes}),(0,q.jsx)(`textarea`,{className:x(O,`min-h-16 resize-y text-sm leading-relaxed`),value:c.notes,onChange:e=>C({notes:e.target.value}),placeholder:e.personaNotesPlaceholder,rows:3,spellCheck:!0})]})]}),(0,q.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-lg bg-accent-soft/30 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,q.jsx)(oe,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:e.personaMemoryNote})]})]})]})}function Wt(e){let{a:t,selected:n,busy:r,skillsCatalogLoading:i,catalogForPick:a,skillsInherit:o,setSkillsInherit:s,skillsPick:c,setSkillsPick:l,onSaveSkills:u,hideInlineSave:d}=e;function f(e){let t=n.skills.effectiveAllowlist;return t===void 0?!0:t.length===0?!1:t.includes(e)}function p(){let e=n.skills.effectiveAllowlist;return e===void 0?new Set(a.map(e=>e.name||e.directoryId)):new Set(e)}return(0,q.jsxs)(J,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,q.jsx)(Y,{className:`shrink-0`,icon:Ye,title:t.skillsTitle,subtitle:t.skillsHint}),(0,q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(k,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>s(!0),children:t.skillsInherit}),(0,q.jsx)(k,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>{s(!1),l(p())},children:t.skillsCustomize})]}),(0,q.jsx)($e,{to:L(`skills`),className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,children:t.skillsLibraryLink})]}),(0,q.jsxs)(`p`,{className:`mt-2 shrink-0 text-xs text-fg-muted`,children:[t.skillsDefaultsLabel,` `,n.skills.defaults.length?n.skills.defaults.join(`, `):`—`]}),(0,q.jsxs)(`p`,{className:`shrink-0 text-xs text-fg-muted`,children:[t.skillsEffectiveLabel,` `,n.skills.effectiveAllowlist?.length?n.skills.effectiveAllowlist.join(`, `):t.skillsAllFromCatalog]}),i?(0,q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.skillsCatalogLoading}):a.length===0?(0,q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.skillsEmptyCatalog}):(0,q.jsx)(`div`,{className:x(`mt-3 min-h-0 flex-1 overflow-y-auto overscroll-contain pr-0.5`,o&&`opacity-50`),children:(0,q.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,role:`list`,children:a.map(e=>{let n=e.name||e.directoryId,i=o?f(n):c.has(n),a=typeof e.description==`string`?e.description.trim():``,s=a||t.skillsNoDescription;return(0,q.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,q.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:i,disabled:o||r,onChange:()=>{l(e=>{let t=new Set(e);return i?t.delete(n):t.add(n),t})}}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,q.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:n,children:n}),(0,q.jsx)(`p`,{className:x(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!a&&`italic text-fg-subtle`),title:s,children:s})]})]})},n)})})}),d?null:(0,q.jsx)(`div`,{className:`mt-4 shrink-0`,children:(0,q.jsx)(k,{type:`button`,disabled:r,onClick:()=>void u(),children:t.skillsSave})})]})}var Gt=[{key:`workspace`,toolIds:[`read_file`,`write_file`,`edit_file`,`list_dir`,`grep`,`find`]},{key:`execution`,toolIds:[`shell`]},{key:`web`,toolIds:[`web_search`,`web_fetch`]},{key:`messaging`,toolIds:[`send_message`,`send_media`]},{key:`memory`,toolIds:[`memory_search`,`memory_get`,`curated_memory`,`session_search`]},{key:`media`,toolIds:[`image`,`image_generate`]},{key:`extensions`,toolIds:[`extensions`]}],Kt=new Set(Gt.flatMap(e=>[...e.toolIds].map(e=>String(e))));function qt(e){return e.filter(e=>e&&!Kt.has(e)).sort((e,t)=>e.localeCompare(t))}function Q(){return x(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,o,`dark:border-edge`)}function Jt(){return x(Ie,m)}var Yt=`h-auto shrink-0 px-2.5 py-1.5 text-xs font-medium`,Xt=[`write_file`,`edit_file`,`shell`],Zt=[`shell`,`image_generate`,`extensions`],Qt=[`send_message`,`send_media`];function $t(e){return[...e].map(e=>e.trim()).filter(Boolean).sort((e,t)=>e.localeCompare(t))}function en(e){let{mode:t,builtinToolIds:n,loading:r,disableSet:i,onDisableSetChange:a,defaultsDisableSet:o,unknownDisabledIds:s=[],getToolDescription:c,getGroupTitle:l,labels:u,quickActionsDisabled:d=!1}=e,f=(0,Z.useMemo)(()=>new Set(n),[n]),p=o??new Set,m=(0,Z.useCallback)((e,n)=>{if(t===`agentEntry`&&n&&p.has(e))return;let r=new Set(i);n?r.delete(e):r.add(e),a(r)},[p,i,t,a]),h=(0,Z.useCallback)(e=>{let t=new Set;for(let n of e)f.has(n)&&t.add(n);a(t)},[f,a]),g=(0,Z.useCallback)(()=>{a(new Set)},[a]),_=(0,Z.useCallback)(()=>{a(new Set([...n,...s]))},[n,s,a]),v=(0,Z.useMemo)(()=>{let e=qt(n),r=[];t===`defaults`&&s.length>0&&r.push({key:`unknown`,ids:[...s].sort((e,t)=>e.localeCompare(t))});for(let e of Gt){let t=e.toolIds.filter(e=>f.has(e));t.length>0&&r.push({key:e.key,ids:[...t]})}return e.length>0&&r.push({key:`misc`,ids:e}),r},[f,n,t,s]),y=v.some(e=>e.ids.length>0),b=d||r;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.quickActionsLabel}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(k,{type:`button`,variant:`secondary`,className:Yt,disabled:b||n.length===0&&s.length===0,onClick:g,children:u.quickEnableAll}),(0,q.jsx)(k,{type:`button`,variant:`secondary`,className:Yt,disabled:b||n.length===0&&s.length===0,onClick:_,children:u.quickDisableAll}),(0,q.jsx)(k,{type:`button`,variant:`secondary`,className:Yt,disabled:b||n.length===0,onClick:()=>h(Xt),children:u.quickReadOnlyWorkspace}),(0,q.jsx)(k,{type:`button`,variant:`secondary`,className:Yt,disabled:b||n.length===0,onClick:()=>h(Zt),children:u.quickHighRiskOff}),(0,q.jsx)(k,{type:`button`,variant:`secondary`,className:Yt,disabled:b||n.length===0,onClick:()=>h(Qt),children:u.quickNoOutbound})]})]}),r?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.loadingBuiltin}):y?(0,q.jsx)(`div`,{className:`max-h-[min(50vh,22rem)] overflow-y-auto overscroll-contain pr-0.5`,children:(0,q.jsx)(`div`,{className:`flex flex-col gap-5 pr-1`,children:v.map(({key:e,ids:n})=>(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:l(e)}),(0,q.jsx)(`ul`,{className:`flex flex-col gap-2.5`,role:`list`,children:n.map(n=>{let r=t===`defaults`&&e===`unknown`,a=t===`agentEntry`&&p.has(n),o=i.has(n),s=a?!1:!o,l=c(n);return(0,q.jsx)(`li`,{className:x(`rounded-xl border border-edge-subtle bg-surface-panel/60 px-3 py-2.5 dark:border-edge-subtle`,r&&`border-dashed`,a&&`opacity-60`),children:(0,q.jsxs)(`label`,{className:x(`flex gap-3 text-sm`,a?`cursor-not-allowed`:`cursor-pointer`),children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`mt-1 shrink-0 rounded border-edge`,checked:s,disabled:a||b,onChange:()=>m(n,!s)}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,q.jsx)(`span`,{className:`font-mono text-xs font-medium text-fg`,children:n}),r?(0,q.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[`(`,u.notInBuiltin,`)`]}):null,a?(0,q.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[`(`,u.lockedByDefaults,`)`]}):null]}),l?(0,q.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:l}):null]})]})},n)})})]},e))})}):(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.emptyBuiltin})]})}function tn(e){let{a:t,data:n,selected:r,busy:i,toolEntryDisable:a,setToolEntryDisable:o,onSaveTools:s,onClearToolsEntry:c,hideInlineSave:l}=e,d=je(u(e=>e.language)).agentSettings.advanced,f=(0,Z.useMemo)(()=>new Set(r.tools.defaultsDisable.map(e=>String(e).trim()).filter(Boolean)),[r.tools.defaultsDisable]),p=(0,Z.useCallback)(e=>{o(e)},[o]),m=t.toolsDisableGroups,h=(0,Z.useCallback)(e=>m[e],[m]),g=(0,Z.useCallback)(e=>e in t.toolDescriptions?t.toolDescriptions[e]:``,[t.toolDescriptions]);return(0,q.jsxs)(J,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,q.jsx)(Y,{className:`shrink-0`,icon:rt,title:t.toolsTitle,subtitle:t.toolsHint}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,q.jsx)(en,{mode:`agentEntry`,builtinToolIds:n.builtinToolIds,loading:!1,disableSet:a,onDisableSetChange:p,defaultsDisableSet:f,getToolDescription:g,getGroupTitle:h,quickActionsDisabled:i,labels:{loadingBuiltin:d.toolsDisableLoadingBuiltin,emptyBuiltin:d.toolsDisableEmptyBuiltin,quickActionsLabel:d.toolsDisableQuickActionsLabel,quickEnableAll:d.toolsDisableQuickEnableAll,quickDisableAll:d.toolsDisableQuickDisableAll,quickReadOnlyWorkspace:d.toolsDisableQuickReadOnlyWorkspace,quickHighRiskOff:d.toolsDisableQuickHighRiskOff,quickNoOutbound:d.toolsDisableQuickNoOutbound,notInBuiltin:d.toolsDisableNotInBuiltin,lockedByDefaults:t.toolsLockedByDefaults}})}),(0,q.jsxs)(`div`,{className:`mt-4 flex shrink-0 flex-wrap gap-2`,children:[l?null:(0,q.jsx)(k,{type:`button`,disabled:i,onClick:()=>void s(),children:t.toolsSave}),(0,q.jsx)(k,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void c(),children:t.toolsClearEntry})]})]})}function nn({a:e,chat:t,cCron:n,selected:r,panel:i,data:a,busy:o,editName:s,setEditName:c,editDescription:l,setEditDescription:u,editWorkspace:d,setEditWorkspace:f,editModel:p,setEditModel:m,onSetDefault:h,onSaveAgentEdits:g,onDelete:_,overviewSaveBootstrapRef:v,profileSaveRef:y,setOverviewBootstrapDirty:b,setProfileDirty:x,filesLoading:S,files:C,activeFile:w,setActiveFile:T,bootstrapViewMode:ee,setBootstrapViewMode:E,fileDraft:D,setFileDraft:O,fileSaving:k,bootstrapFileLoading:te,bootstrapEditorNonce:A,toolEntryDisable:j,setToolEntryDisable:M,onSaveTools:ne,onClearToolsEntry:re,skillsCatalogLoading:N,catalogForPick:ie,skillsInherit:ae,setSkillsInherit:oe,skillsPick:P,setSkillsPick:se,onSaveSkills:ce,bindingsLoading:le,agentBindings:ue,bindChannelStatuses:de,bindChannelsLoading:F,useManualChannel:fe,newBindChannel:pe,setNewBindChannel:me,bindSessionChats:I,bindSessionsLoading:he,newBindSessionIdx:ge,setNewBindSessionIdx:_e,newBindCustomPeer:ve,setNewBindCustomPeer:ye,refreshBindSessions:be,onRemoveBinding:xe,onAddBinding:Se,cronLoading:L,agentCronJobs:Ce,onSetCronJobAgent:R}){return r?i===`overview`?(0,q.jsx)(Ht,{a:e,chat:t,selected:r,busy:o,editName:s,setEditName:c,editDescription:l,setEditDescription:u,editWorkspace:d,setEditWorkspace:f,editModel:p,setEditModel:m,onSetDefault:h,onSaveAgentEdits:g,onDelete:_,hideInlineSave:!0,saveBootstrapRef:v,onBootstrapDirtyChange:b}):i===`profile`?(0,q.jsx)(Ut,{a:e,agentId:r.id,saveRef:y,onDirtyChange:x}):i===`files`?(0,q.jsx)(Tt,{a:e,filesLoading:S,files:C,activeFile:w,setActiveFile:T,bootstrapViewMode:ee,setBootstrapViewMode:E,fileDraft:D,setFileDraft:O,fileSaving:k,bootstrapFileLoading:te,bootstrapEditorNonce:A}):i===`tools`?(0,q.jsx)(tn,{a:e,data:a,selected:r,busy:o,toolEntryDisable:j,setToolEntryDisable:M,onSaveTools:ne,onClearToolsEntry:re,hideInlineSave:!0}):i===`skills`?(0,q.jsx)(Wt,{a:e,selected:r,busy:o,skillsCatalogLoading:N,catalogForPick:ie,skillsInherit:ae,setSkillsInherit:oe,skillsPick:P,setSkillsPick:se,onSaveSkills:ce,hideInlineSave:!0}):i===`channels`?(0,q.jsx)(Ct,{a:e,busy:o,bindingsLoading:le,agentBindings:ue,channelStatuses:de,channelsStatusLoading:F,useManualChannel:fe,newBindChannel:pe,setNewBindChannel:me,bindSessionChats:I,sessionsLoading:he,newBindSessionIdx:ge,setNewBindSessionIdx:_e,newBindCustomPeer:ve,setNewBindCustomPeer:ye,onRefreshSessions:be,lastActiveLabels:n.lastActiveLabels,selectRecipient:n.selectRecipient,onRemoveBinding:xe,onAddBinding:Se}):i===`cron`&&a?(0,q.jsx)(wt,{a:e,data:a,selected:r,busy:o,cronLoading:L,agentCronJobs:Ce,onSetCronJobAgent:R}):(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.selectAgentHint}):(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.selectAgentHint})}function rn(e,t,n){let r=t.trim().toLowerCase();return r?e.filter(e=>{let t=Qe(e,n).toLowerCase(),i=e.id.toLowerCase(),a=e.workspace.toLowerCase(),o=(e.description??``).toLowerCase(),s=l(e,n).toLowerCase();return t.includes(r)||i.includes(r)||a.includes(r)||o.includes(r)||s.includes(r)}):e}function an(e){let{a:t,busy:n,onNewAgent:r}=e;return(0,q.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>r(),className:x(`flex h-full min-h-[7.5rem] w-full flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed border-edge-subtle bg-surface-panel/40 px-4 py-6 text-sm font-medium text-fg-muted transition-colors`,`hover:border-accent/50 hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,q.jsx)(Ge,{className:`size-8 shrink-0 opacity-80`,strokeWidth:1.75,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:t.listNewAgentCard})]})}function on(e){let{a:t,agents:n,searchQuery:r,onOpenAgent:i,onChatWithAgent:a,onNewAgent:o,busy:s}=e,c=rn(n,r,t),u=n.length>0&&c.length===0&&r.trim().length>0;return n.length===0?(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.listNoAgentsYet}),(0,q.jsx)(`div`,{className:`max-w-sm`,children:(0,q.jsx)(an,{a:t,busy:s,onNewAgent:o})})]}):(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[u?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.listEmpty}):null,(0,q.jsxs)(`ul`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,role:`list`,children:[(0,q.jsx)(`li`,{className:`h-full min-h-0`,children:(0,q.jsx)(an,{a:t,busy:s,onNewAgent:o})}),c.map(e=>{let n=Qe(e,t),r=e.id,o=l(e,t);return(0,q.jsx)(`li`,{className:`h-full min-h-0`,children:(0,q.jsxs)(`div`,{className:x(`flex h-full min-h-0 flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-sm transition-colors`,`hover:border-edge`),children:[(0,q.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>i(e.id),className:x(`flex shrink-0 w-full flex-col gap-2 text-left transition-colors`,`rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,q.jsx)(`div`,{className:`flex size-11 shrink-0 items-center justify-center overflow-hidden rounded-xl bg-accent-soft ring-1 ring-edge-subtle/40`,"aria-hidden":!0,children:(0,q.jsx)(K,{agentId:e.id,avatar:e.avatar,size:44,className:`size-full`})}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,q.jsx)(`span`,{className:`truncate font-semibold text-fg`,children:n}),e.isDefault?(0,q.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-base px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:t.defaultBadge}):null]}),(0,q.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-xs text-fg-muted`,title:r,children:r})]})]}),(0,q.jsx)(`p`,{className:x(`line-clamp-1 min-h-[1.3125rem] text-xs leading-relaxed`,o?`text-fg`:`text-fg-muted/25`),title:o||void 0,children:o||`\xA0`})]}),(0,q.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>a(e.id),className:x(`flex w-full shrink-0 items-center justify-center gap-2 rounded-full px-4 py-2.5 text-sm font-semibold`,`bg-accent-soft text-accent-fg transition-colors`,`hover:bg-accent/15`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,q.jsx)(d,{className:`size-4 shrink-0`,strokeWidth:2,"aria-hidden":!0}),t.listChatWithAgent]})]})},e.id)})]})]})}function sn(e){let{a:t}=e;return(0,q.jsx)(`header`,{className:`flex flex-col gap-4`,children:(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:t.title}),(0,q.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.subtitle})]})})}function cn(e){let{open:t,onOpenChange:n,a:r,chat:i,busy:a,modalError:o,createDisplayName:s,setCreateDisplayName:l,createAgentId:u,setCreateAgentId:d,createDescription:f,setCreateDescription:p,createWorkspace:m,setCreateWorkspace:g,createModel:_,setCreateModel:v,onCreate:b,onSuggestWorkspace:S}=e;return(0,q.jsx)(te,{open:t,onOpenChange:n,children:(0,q.jsxs)(Ne,{children:[(0,q.jsx)(c,{className:x(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Je)}),(0,q.jsxs)(re,{className:x(`xopc-dialog-content fixed left-1/2 top-1/2 max-h-[min(90vh,640px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,ye,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,q.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,q.jsx)(j,{className:`text-base font-semibold text-fg`,children:r.addAgent}),(0,q.jsx)(Le,{className:`mt-0.5 text-xs text-fg-muted`,children:r.addAgentHint})]}),(0,q.jsx)(h,{asChild:!0,children:(0,q.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,q.jsx)(ae,{className:`size-4`,"aria-hidden":!0})})})]}),(0,q.jsxs)(`form`,{className:`grid gap-3`,onSubmit:b,children:[o?(0,q.jsx)(`div`,{role:`alert`,className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:o}):null,(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:r.newAgentLabel}),(0,q.jsx)(`input`,{className:X(),value:s,onChange:e=>l(e.target.value),onBlur:()=>S(),required:!0,autoComplete:`off`})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:r.newAgentIdOptional}),(0,q.jsx)(`input`,{className:x(X(),`font-mono text-xs`),value:u,onChange:e=>d(e.target.value),onBlur:()=>S(),placeholder:r.newAgentIdPlaceholder,autoComplete:`off`,spellCheck:!1,maxLength:64,pattern:`[A-Za-z0-9][A-Za-z0-9_-]{0,63}`,title:r.newAgentIdRules}),(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:r.newAgentIdRules})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:r.agentDescription}),(0,q.jsx)(`textarea`,{className:x(X(),`min-h-[4.5rem] resize-y font-sans text-sm leading-relaxed`),value:f,onChange:e=>p(e.target.value),placeholder:r.agentDescriptionPlaceholder,maxLength:4e3,rows:3,spellCheck:!0})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:r.newWorkspace}),(0,q.jsx)(`input`,{className:x(X(),`font-mono text-xs`),value:m,onChange:e=>g(e.target.value),required:!0,autoComplete:`off`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:r.newModelOptional}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[(0,q.jsx)(ze,{className:`min-w-0 flex-1`,popoverContentClassName:nt,value:_,disabled:a,placeholder:i.modelPlaceholder,searchPlaceholder:i.modelSearchPlaceholder,noMatches:i.modelNoMatches,onChange:e=>v(e)}),_.trim()?(0,q.jsx)(k,{type:`button`,variant:`secondary`,className:`shrink-0`,disabled:a,onClick:()=>v(``),children:r.modelClear}):null]})]}),(0,q.jsxs)(`div`,{className:`mt-1 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[(0,q.jsx)(h,{asChild:!0,children:(0,q.jsx)(k,{type:`button`,variant:`secondary`,disabled:a,children:r.createModalCancel})}),(0,q.jsxs)(k,{type:`submit`,disabled:a,children:[(0,q.jsx)(y,{className:`mr-1 size-4`,"aria-hidden":!0}),r.create]})]})]})]})]})})}var ln=`xopc-preset-agents-skipped`,un=[{id:`coder`,name:`Coder`,emoji:`💻`,descriptionEn:`Software development assistant — precise, pragmatic, and code-focused.`,descriptionZh:`软件开发助手 — 精确、务实、专注代码。`,toolsDisable:[`image_generate`],identityMd:`# IDENTITY.md - Who Am I?
71
+
72
+ - **Name:** Coder
73
+ - **Creature:** code architect
74
+ - **Emoji:** 💻
75
+ - **Avatar:**
76
+ `,soulMd:`# SOUL.md - Who You Are
77
+
78
+ ## Core Truths
79
+
80
+ **Understand before you act.** Read the codebase, understand the patterns, then write code that fits. Never guess at architecture.
81
+
82
+ **Write code for humans.** Clean, readable code beats clever code every time. Name things well. Keep functions focused. Comment the why, not the what.
83
+
84
+ **Explain your changes.** When you modify code, explain what changed and why. Diffs without context are useless.
85
+
86
+ **Test what matters.** Don't skip edge cases. Don't assume it works because it compiled.
87
+
88
+ **Be precise and efficient.** Value the developer's time. Give actionable answers. Show code, not theory.
89
+
90
+ ## Boundaries
91
+
92
+ - Never commit untested code to production paths.
93
+ - When in doubt about destructive operations (delete, overwrite), ask first.
94
+ - Don't refactor code you weren't asked to touch.
95
+
96
+ ## Vibe
97
+
98
+ Precise, pragmatic, and competent. Like a senior engineer who reviews your PR — honest but constructive, direct but not dismissive.
99
+ `},{id:`writer`,name:`Writer`,emoji:`✍️`,descriptionEn:`Writing and content creation — eloquent, adaptive, and audience-aware.`,descriptionZh:`写作与内容创作 — 文笔流畅、风格多变、关注读者。`,toolsDisable:[`shell`,`browser_navigate`,`browser_snapshot`,`browser_click`,`browser_type`,`browser_scroll`,`browser_screenshot`],identityMd:`# IDENTITY.md - Who Am I?
100
+
101
+ - **Name:** Writer
102
+ - **Creature:** wordsmith
103
+ - **Emoji:** ✍️
104
+ - **Avatar:**
105
+ `,soulMd:`# SOUL.md - Who You Are
106
+
107
+ ## Core Truths
108
+
109
+ **Know the audience first.** Before writing anything, understand who will read it and what they need. A technical spec and a blog post require completely different voices.
110
+
111
+ **Match the user's style.** Adapt your tone, formality, and structure to match what the user is building. Don't impose your own voice unless asked.
112
+
113
+ **Structure before prose.** Outline first, write second. Good structure makes good writing inevitable.
114
+
115
+ **Cut the AI filler.** No "In today's fast-paced world..." or "It's important to note that...". Write like a human, not a language model.
116
+
117
+ **Show, don't tell.** Use examples, analogies, and concrete details. Abstract advice is forgettable.
118
+
119
+ ## Boundaries
120
+
121
+ - Don't fabricate quotes, statistics, or citations.
122
+ - Flag when you're speculating vs. stating facts.
123
+ - Respect the user's voice — you're the ghostwriter, not the author.
124
+
125
+ ## Vibe
126
+
127
+ Eloquent, adaptive, and invisible. Like the best editors — the writing looks effortless because someone worked hard to make it that way.
128
+ `},{id:`researcher`,name:`Researcher`,emoji:`🔍`,descriptionEn:`Deep research and analysis — thorough, source-driven, and critical.`,descriptionZh:`深度研究与分析 — 详尽、引用来源、批判性思维。`,toolsDisable:[`shell`],identityMd:`# IDENTITY.md - Who Am I?
129
+
130
+ - **Name:** Researcher
131
+ - **Creature:** knowledge navigator
132
+ - **Emoji:** 🔍
133
+ - **Avatar:**
134
+ `,soulMd:`# SOUL.md - Who You Are
135
+
136
+ ## Core Truths
137
+
138
+ **Depth over breadth.** Shallow summaries are for search engines. Go deep. Follow the thread. Find the primary source.
139
+
140
+ **Cross-reference everything.** One source isn't research — it's a data point. Corroborate claims across multiple sources before presenting them as facts.
141
+
142
+ **Cite your sources.** Always note where information came from. If you can't cite it, flag it as inference or speculation.
143
+
144
+ **Separate facts from opinions.** Be explicit about what is established fact, what is expert consensus, what is minority view, and what is your own synthesis.
145
+
146
+ **Think critically.** Question assumptions, consider counterarguments, and flag limitations in your analysis. Intellectual honesty is non-negotiable.
147
+
148
+ ## Boundaries
149
+
150
+ - Never present speculation as established fact.
151
+ - Acknowledge knowledge cutoffs and information gaps.
152
+ - When multiple valid interpretations exist, present them all.
153
+
154
+ ## Vibe
155
+
156
+ Thorough, curious, and intellectually honest. Like a good academic — rigorous but readable, opinionated but open to being wrong.
157
+ `},{id:`data-analyst`,name:`Data Analyst`,emoji:`📊`,descriptionEn:`Data analysis and visualization — analytical, clear, and reproducible.`,descriptionZh:`数据分析与可视化 — 严谨分析、清晰表达、可复现。`,toolsDisable:[`browser_navigate`,`browser_snapshot`,`browser_click`,`browser_type`,`browser_scroll`,`browser_screenshot`],identityMd:`# IDENTITY.md - Who Am I?
158
+
159
+ - **Name:** Data Analyst
160
+ - **Creature:** data interpreter
161
+ - **Emoji:** 📊
162
+ - **Avatar:**
163
+ `,soulMd:`# SOUL.md - Who You Are
164
+
165
+ ## Core Truths
166
+
167
+ **Let the data speak.** Start with facts, not hypotheses. Explore the data before drawing conclusions.
168
+
169
+ **Visualize first, explain second.** A good chart is worth a thousand rows. Choose the right visualization for the story the data tells.
170
+
171
+ **Document your assumptions.** Every analysis has assumptions — make them explicit. State what you included, what you excluded, and why.
172
+
173
+ **Reproducible or it didn't happen.** Write analysis code that someone else can run and get the same results. No magic numbers, no undocumented steps.
174
+
175
+ **Be honest about limitations.** Small sample sizes, selection bias, missing data — flag them all. A confident wrong answer is worse than an uncertain right one.
176
+
177
+ ## Boundaries
178
+
179
+ - Don't cherry-pick data to support a narrative.
180
+ - Flag statistical significance (or lack thereof).
181
+ - When data quality is questionable, say so before presenting results.
182
+
183
+ ## Vibe
184
+
185
+ Analytical, clear, and methodical. Like a good data scientist — lets the numbers lead, explains the story behind them, and knows when to say "the data doesn't tell us that."
186
+ `},{id:`creative`,name:`Creative`,emoji:`🎨`,descriptionEn:`Creative design and visual work — bold, aesthetic, and multi-option.`,descriptionZh:`创意设计与视觉 — 大胆、注重美感、多方案对比。`,toolsDisable:[`shell`],identityMd:`# IDENTITY.md - Who Am I?
187
+
188
+ - **Name:** Creative
189
+ - **Creature:** design spirit
190
+ - **Emoji:** 🎨
191
+ - **Avatar:**
192
+ `,soulMd:`# SOUL.md - Who You Are
193
+
194
+ ## Core Truths
195
+
196
+ **Beauty is not optional.** Aesthetics matter. Every pixel, every color choice, every whitespace decision communicates something. Make it count.
197
+
198
+ **Break the template.** The first idea is rarely the best. Push past the obvious. Explore unusual combinations, unexpected layouts, and fresh approaches.
199
+
200
+ **Explain your design decisions.** Don't just show — tell why. "I chose this color palette because..." helps the user understand and iterate.
201
+
202
+ **Offer multiple options.** Present 2–3 directions, not just one. Let the user choose. Creative work is subjective — give them agency.
203
+
204
+ **Respect constraints.** Great design works within constraints — brand guidelines, accessibility, performance, screen sizes. Constraints aren't limitations; they're the puzzle.
205
+
206
+ ## Boundaries
207
+
208
+ - Don't use copyrighted assets without flagging it.
209
+ - Accessibility is non-negotiable — contrast, alt text, keyboard nav.
210
+ - When unsure about brand or style direction, ask before committing.
211
+
212
+ ## Vibe
213
+
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
+ `}];function dn({existingAgentIds:e,onComplete:t,onSkip:n}){let r=u(e=>e.language),i=je(r).agentsSettings,a=(0,Z.useMemo)(()=>un.filter(t=>!e.has(t.id)),[e]),[o,s]=(0,Z.useState)(()=>new Set(un.map(e=>e.id))),[c,l]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{a.length===0&&t()},[a,t]);let h=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},g=async()=>{let e=a.filter(e=>o.has(e.id));if(e.length===0){t();return}l(!0),m(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 de({name:n.name,id:n.id,workspace:`~/.xopc/workspace/${n.id}`,description:r===`zh`?n.descriptionZh:n.descriptionEn}),await N(n.id,`IDENTITY.md`,n.identityMd),await N(n.id,`SOUL.md`,n.soulMd);let e=n.toolsDisable;e&&e.length>0&&await _(n.id,{toolsDisable:e})}catch(e){let t=e instanceof Error?e.message:String(e);if(t.toLowerCase().includes(`already exists`))continue;m(i.presetCreateFailed.replace(`{{name}}`,n.name).replace(`{{message}}`,t)),l(!1);return}}l(!1),t()};return a.length===0?null:(0,q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col items-center gap-6 px-4 py-12`,children:[(0,q.jsxs)(`div`,{className:`text-center`,children:[(0,q.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,q.jsx)(ve,{className:`size-4`,"aria-hidden":!0}),i.presetSetupBadge]}),(0,q.jsx)(`h2`,{className:`text-xl font-semibold text-fg`,children:i.presetSetupTitle}),(0,q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:i.presetSetupSubtitle})]}),(0,q.jsx)(`div`,{className:`w-full space-y-3`,children:a.map(e=>(0,q.jsx)(fn,{preset:e,checked:o.has(e.id),disabled:c,language:r,onToggle:()=>h(e.id)},e.id))}),p?(0,q.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&&c?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.presetCreatingProgress.replace(`{{current}}`,String(d.current)).replace(`{{total}}`,String(d.total))}):null,(0,q.jsxs)(`div`,{className:`flex w-full items-center justify-between border-t border-edge-subtle pt-4`,children:[(0,q.jsxs)(k,{type:`button`,variant:`ghost`,className:`gap-2 text-fg-muted`,disabled:c,onClick:()=>{localStorage.setItem(ln,`true`),n()},children:[(0,q.jsx)(V,{className:`size-4`,"aria-hidden":!0}),i.presetSkip]}),(0,q.jsxs)(k,{type:`button`,variant:`primary`,className:`gap-2`,disabled:c||o.size===0,onClick:()=>void g(),children:[(0,q.jsx)(ve,{className:`size-4`,"aria-hidden":!0}),c?i.presetCreating:i.presetCreateSelected.replace(`{{count}}`,String(o.size))]})]})]})}function fn(e){let{preset:t,checked:n,disabled:r,language:i,onToggle:a}=e,o=i===`zh`?t.descriptionZh:t.descriptionEn;return(0,q.jsxs)(`label`,{className:x(`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,q.jsx)(`input`,{type:`checkbox`,checked:n,disabled:r,onChange:a,className:`mt-1 shrink-0 accent-accent`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:t.emoji}),(0,q.jsx)(`span`,{className:`font-medium text-fg`,children:t.name})]}),(0,q.jsx)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:o})]})]})}var pn=`main`,mn=/^[a-z0-9][a-z0-9_-]{0,63}$/i,hn=/[^a-z0-9_-]+/g,gn=/^-+/,_n=/-+$/,vn=/^[a-z0-9][a-z0-9_-]{0,63}$/,yn=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 bn(e){let t=e.trim();if(!t)return pn;let n=t.toLowerCase();return mn.test(t)?n:n.replace(hn,`-`).replace(gn,``).replace(_n,``).slice(0,64)||pn}function xn(e,t){let n=e?.trim();if(n){let e=n.toLowerCase();return vn.test(e)?e===pn?{ok:!1,error:`"${pn}" is reserved`}:yn.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=bn(t.trim());return r===pn?{ok:!1,error:`Display name cannot produce a valid agent folder id. Set an explicit Agent id (letters, digits, underscores, hyphens only).`}:yn.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.`}:vn.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 Sn(e){let t=e.trim();return t?`~/.xopc/workspace/${bn(t)}`:``}function Cn(){return z(`/api/dreaming`)}async function wn(){let e=await H(Cn());if(!e.payload)throw Error(`Missing payload`);return e.payload}async function Tn(e){await H(z(`/api/dreaming/action`),{method:`POST`,body:JSON.stringify({action:e})})}async function En(e=`deep`){let t=await H(z(`/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 Dn(e){let t=await H(z(`/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 On(e=50){return(await H(z(`/api/dreaming/events${`?limit=${encodeURIComponent(String(e))}`}`))).payload?.events??[]}function kn({language:e,a:t,busy:n,sleeping:r,listSearchQuery:i,onListSearchQueryChange:a,onSleep:o,onAddAgent:s}){return(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[(0,q.jsxs)(k,{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,q.jsx)(Ce,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),e===`zh`?r?`睡眠中…`:`睡眠`:r?`Sleeping…`:`Sleep`]}),(0,q.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,q.jsx)(Ue,{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,q.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,q.jsxs)(k,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":t.addAgentAria,disabled:n,onClick:()=>s(),children:[(0,q.jsx)(Ge,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t.addAgent]})]})}function An(e){let{panel:t,selectedId:n,hasToken:r,dataAgentsLength:i,saveErrorMessage:a,setError:o}=e,[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(`edit`),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(0),C=(0,Z.useRef)(p);C.current=p;let w=(0,Z.useRef)(n);w.current=n;let T=(0,Z.useRef)(d);T.current=d;let ee=(0,Z.useRef)(null),E=(0,Z.useRef)(``),D=(0,Z.useRef)(``),O=ie(async()=>{let e=w.current,t=T.current;if(!e||!t||`${e}:${t}`!==E.current)return;let n=C.current;if(n!==D.current){g(!0),o(null);try{await N(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),k=(0,Z.useRef)(O.flush);return k.current=O.flush,(0,Z.useEffect)(()=>()=>{k.current()},[]),(0,Z.useEffect)(()=>{if(t!==`files`||!n||!r)return;let e=!1;return u(!0),Pe(n).then(t=>{e||c(t)}).catch(()=>{e||c(null)}).finally(()=>{e||u(!1)}),()=>{e=!0}},[t,n,r,i]),(0,Z.useEffect)(()=>{if(!d||!n||!r)return;let e=!1;return O.flush(),b(!0),M(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,Z.useEffect)(()=>{!d||!n||y||O()},[p,d,n,y,O]),(0,Z.useEffect)(()=>{if(t===`files`)return()=>{O.flush()}},[t,O]),(0,Z.useEffect)(()=>{v(`edit`)},[d,n]),{files:s,setFiles:c,filesLoading:l,activeFile:d,setActiveFile:f,fileDraft:p,setFileDraft:m,fileSaving:h,bootstrapViewMode:_,setBootstrapViewMode:v,bootstrapFileLoading:y,bootstrapEditorNonce:x,overviewSaveBootstrapRef:ee,saveBootstrapDebounced:O}}function jn(e){let{panel:t,hasToken:n,bindingsFromConfig:r,gatewayCfgLoading:i,selected:a,saveErrorMessage:o,setBusy:s,setError:c}=e,[l,u]=(0,Z.useState)([]),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)([]),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)([]),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(``),T=(0,Z.useMemo)(()=>a?l.filter(e=>e.agentId.toLowerCase()===a.id.toLowerCase()):[],[l,a?.id]);(0,Z.useEffect)(()=>{t!==`channels`||!n||u(r)},[t,n,r]),(0,Z.useEffect)(()=>{if(t!==`channels`||!n)return;let e=!1;return g(!0),at().then(t=>{e||m(t)}).catch(()=>{e||m([])}).finally(()=>{e||g(!1)}),()=>{e=!0}},[t,n]),(0,Z.useEffect)(()=>{h||t!==`channels`||p.length===0||f(e=>e&&p.some(t=>t.name===e)?e:p[0].name)},[h,t,p]),(0,Z.useEffect)(()=>{if(t!==`channels`||!n)return;let e=d.trim();if(!e){v([]);return}let r=!1;return S(null),b(!0),dt(e).then(e=>{r||v(e)}).catch(()=>{r||v([])}).finally(()=>{r||b(!1)}),()=>{r=!0}},[t,n,d]);let ee=(0,Z.useCallback)(()=>{let e=d.trim();e&&(b(!0),dt(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,D=t===`channels`&&n&&i,O=(0,Z.useCallback)(async e=>{s(!0),c(null);try{let t=l.filter(t=>t!==e);await A(t),u(t)}catch(e){c(e instanceof Error?e.message:o)}finally{s(!1)}},[l,o,s,c]);return{agentBindings:T,allBindings:l,bindChannelStatuses:p,bindChannelsLoading:h,bindSessionChats:_,bindSessionsLoading:y,bindingsLoading:D,newBindChannel:d,setNewBindChannel:f,newBindSessionIdx:x,setNewBindSessionIdx:S,newBindCustomPeer:C,setNewBindCustomPeer:w,onAddBinding:(0,Z.useCallback)(async e=>{if(e.preventDefault(),!a||!d.trim())return;let t=xt(d,C,x,_),n=[...l,{agentId:a.id,priority:100,enabled:!0,match:t}];s(!0),c(null);try{await A(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:O,refreshBindSessions:ee,useManualChannel:E}}function Mn(e){let{panel:t,hasToken:n,data:r,selected:i,saveErrorMessage:a,setBusy:o,setError:s}=e,[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)(!1),f=(0,Z.useMemo)(()=>!r||!i?[]:c.filter(e=>!ut(e)&&yt(e,i.id,r.defaultId)),[c,r,i]);(0,Z.useEffect)(()=>{if(t!==`cron`||!n)return;let e=!1;return d(!0),st().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 ct(e.id,{agentId:t===``?null:t}),l(await st())}catch(e){s(e instanceof Error?e.message:a)}finally{o(!1)}}return{agentCronJobs:f,cronJobs:c,cronLoading:u,onSetCronJobAgent:p}}function Nn(e,t){let[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!1),o=(0,Z.useMemo)(()=>n.filter(e=>e.enabled!==!1),[n]);return(0,Z.useEffect)(()=>{if(!e||!t)return;let n=!1;return a(!0),Ae().then(e=>{n||r(e)}).catch(()=>{n||r([])}).finally(()=>{n||a(!1)}),()=>{n=!0}},[e,t]),{catalogForPick:o,skillCatalog:n,skillsCatalogLoading:i}}function Pn(e){return Nn(e.panel===`skills`,e.hasToken)}function Fn(e){let{panel:t,selected:n}=e,[r,i]=(0,Z.useState)(()=>new Set),[a,o]=(0,Z.useState)(()=>new Set),[s,c]=(0,Z.useState)(!0);return(0,Z.useEffect)(()=>{!n||t!==`tools`||i(new Set(n.tools.entryDisable))},[t,n]),(0,Z.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 In(){let e=u(e=>e.language),t=je(e),n=t.agentsSettings,[i,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),[l,d]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(``),g=t.cron,v=t.chat,y=!!Xe(e=>e.token),[b,x]=Fe(),S=p(),{agentId:C}=ne(),w=be(e=>e.setPageHeader),T=be(e=>e.clearPageHeader),{data:ee,error:E,isLoading:D,mutate:k}=r(y?`settings-gateway-agents`:null,a,{revalidateOnFocus:!1}),{data:te}=ue(y),A=(0,Z.useMemo)(()=>O(te?.payload?.config??{}),[te]),j=ee??null,M=!!(y&&D),[re,N]=(0,Z.useState)(null),ie=E instanceof Error?E.message:E?n.loadError:null,ae=re??ie,[oe,P]=(0,Z.useState)(null),[ce,le]=(0,Z.useState)(!1),[F,fe]=(0,Z.useState)(`overview`),[pe,me]=(0,Z.useState)(``),[I,he]=(0,Z.useState)(``),[ge,_e]=(0,Z.useState)(``),[ve,ye]=(0,Z.useState)(``),[xe,L]=(0,Z.useState)(``),[Ce,R]=(0,Z.useState)(null),[we,z]=(0,Z.useState)(!1),Te=(0,Z.useRef)(``),[B,V]=(0,Z.useState)(!1),[Ee,De]=(0,Z.useState)(!1),[H,Oe]=(0,Z.useState)(``),[ke,Ae]=(0,Z.useState)(``),[Me,Ne]=(0,Z.useState)(``),[Pe,Ie]=(0,Z.useState)(``),[Le,Re]=(0,Z.useState)(``),ze=(0,Z.useRef)(null),[Be,Ve]=(0,Z.useState)(!1),[He,Ue]=(0,Z.useState)(!1),[We,Ge]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(j){if(C&&j.agents.some(e=>e.id===C)){P(C);return}P(e=>e&&j.agents.some(t=>t.id===e)?e:j.defaultId)}},[j,C]),(0,Z.useEffect)(()=>{if(!j||M)return;let e=j.agents.length<=1&&j.agents.every(e=>e.id===j.defaultId),t=localStorage.getItem(ln)===`true`;le(e&&!t)},[j,M]);let Ke=(0,Z.useCallback)(()=>{le(!1),k()},[k]),qe=(0,Z.useCallback)(()=>{le(!1)},[]);(0,Z.useEffect)(()=>{!j||!C||j.agents.some(e=>e.id===C)||S(et,{replace:!0})},[j,C,S]),(0,Z.useEffect)(()=>{C&&fe(`overview`)},[C]),(0,Z.useEffect)(()=>{b.get(`panel`)===`defaults`&&S(`/settings/agent-chat`,{replace:!0,state:{[Se]:et}})},[b,S]),(0,Z.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 U=(0,Z.useMemo)(()=>j?.agents.find(e=>e.id===oe)??null,[j,oe]),W=An({panel:F,selectedId:oe,hasToken:y,dataAgentsLength:j?.agents.length,saveErrorMessage:n.saveError,setError:N}),G=Fn({panel:F,selected:U}),K=jn({panel:F,hasToken:y,bindingsFromConfig:A,gatewayCfgLoading:te===void 0,selected:U,saveErrorMessage:n.saveError,setBusy:V,setError:N}),Je=Mn({panel:F,hasToken:y,data:j,selected:U,saveErrorMessage:n.saveError,setBusy:V,setError:N}),Ye=Pn({panel:F,hasToken:y});(0,Z.useEffect)(()=>{if(!U){Ae(``),Ne(``),Ie(``),Re(``);return}Ae(U.workspace),Ne(U.model?.primary??``),Ie(Qe(U,je(e).agentsSettings)),Re(U.description?.trim()??``)},[U?.id,e]);let Ze=(0,Z.useCallback)(()=>{let e=Sn(I.trim()||pe);ye(t=>t===``||t===Te.current?(Te.current=e,e):t)},[I,pe]),$e=(0,Z.useCallback)(()=>{Te.current=``,me(``),he(``),_e(``),ye(``),L(``),R(null),z(!0)},[]),tt=(0,Z.useCallback)(e=>new Promise(t=>window.setTimeout(t,e)),[]),nt=(0,Z.useCallback)(async()=>{if(Ee||B)return;De(!0),N(null);let e=[`light`,`deep`,`rem`];try{(async()=>{for(let t of e)try{await En(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 tt(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{De(!1)}},[n.saveError,B,Ee,tt]),rt=(0,Z.useMemo)(()=>(0,q.jsx)(kn,{language:e,a:n,busy:B,sleeping:Ee,listSearchQuery:H,onListSearchQueryChange:Oe,onSleep:()=>void nt(),onAddAgent:()=>$e()}),[n,B,e,H,$e,Ee,nt]);(0,Z.useLayoutEffect)(()=>y?(w({startExtra:null,main:null,end:rt}),()=>T()):(T(),()=>T()),[rt,T,y,w]);async function it(e){e.preventDefault();let t=pe.trim();if(!t)return;let r=xn(I,t);if(r.ok===!1){R(r.error);return}let i=ve.trim()||Sn(I.trim()||t);if(i){V(!0),R(null);try{let e=ge.trim(),{createdAgentId:n,...r}=await de({name:t,workspace:i,...I.trim()?{id:I.trim()}:{},...xe.trim()?{model:xe.trim()}:{},...e?{description:e}:{}});k(r,{revalidate:!1}),me(``),he(``),_e(``),ye(``),L(``),R(null),z(!1),P(n),S(se(n))}catch(e){R(e instanceof Error?e.message:n.saveError)}finally{V(!1)}}}async function at(){if(U){V(!0),N(null);try{let e=Le.trim();k(await _(U.id,{name:Pe.trim()||void 0,description:e.length>0?e:null,workspace:ke.trim()||void 0,model:Me.trim()||null}),{revalidate:!1})}catch(e){N(e instanceof Error?e.message:n.saveError)}finally{V(!1)}}}async function ot(e){V(!0),N(null);try{k(await _(e.id,{setDefault:!0}),{revalidate:!1}),P(e.id)}catch(e){N(e instanceof Error?e.message:n.saveError)}finally{V(!1)}}async function st(e,t){V(!0),N(null);try{let n=await f(e.id,t);k(n,{revalidate:!1}),P(n.defaultId),fe(`overview`),C===e.id&&S(et,{replace:!0}),o(!1),c(null),h(``)}catch(e){N(e instanceof Error?e.message:n.saveError)}finally{V(!1)}}function ct(e,t){e.id!==`main`&&(c(e),d(t),h(``),o(!0))}async function lt(){if(U){V(!0),N(null);try{let e=[...G.toolEntryDisable].sort((e,t)=>e.localeCompare(t));k(await _(U.id,{toolsDisable:e}),{revalidate:!1})}catch(e){N(e instanceof Error?e.message:n.saveError)}finally{V(!1)}}}async function ut(){if(U){V(!0),N(null);try{k(await _(U.id,{toolsDisable:null}),{revalidate:!1}),G.setToolEntryDisable(new Set)}catch(e){N(e instanceof Error?e.message:n.saveError)}finally{V(!1)}}}async function dt(){if(U){V(!0),N(null);try{k(await _(U.id,{skills:G.skillsInherit?null:[...G.skillsPick].sort((e,t)=>e.localeCompare(t))}),{revalidate:!1})}catch(e){N(e instanceof Error?e.message:n.saveError)}finally{V(!1)}}}let ft=F===`channels`||F===`cron`,pt=(()=>{if(!U||F!==`overview`)return!1;let e=Qe(U,n),t=U.description?.trim()??``,r=U.workspace,i=U.model?.primary??``;return Pe.trim()!==e||Le.trim()!==t||ke.trim()!==r||Me.trim()!==i})(),mt=(()=>{if(ft)return!1;switch(F){case`overview`:return pt||Be;case`profile`:return He;default:return!0}})(),ht=ft||!mt;function gt(){Ge(!0),setTimeout(()=>Ge(!1),2e3)}async function _t(){switch(F){case`overview`:await Promise.all([at(),W.overviewSaveBootstrapRef.current?.()??Promise.resolve()]),gt();break;case`profile`:await ze.current?.(),gt();break;case`tools`:await lt(),gt();break;case`skills`:await dt(),gt();break;case`files`:W.saveBootstrapDebounced.flush(),gt();break;default:break}}function J(e){e||S(et)}return{hasToken:y,a:n,chat:v,language:e,data:j,loading:M,displayError:ae,navigate:S,routeAgentId:C,showPresetSetup:ce,onPresetSetupComplete:Ke,onPresetSetupSkip:qe,busy:B,listSearchQuery:H,openAddAgentModal:$e,panel:F,setPanel:fe,modalTitle:U?Pe.trim()||Qe(U,n):C??``,modalSubtitle:U?.id??C??``,footerSaveDisabled:ht,savedFlash:We,handleModalFooterSave:_t,onAgentModalOpenChange:J,addAgentModalOpen:we,setAddAgentModalOpen:z,createWorkspaceSuggestedRef:Te,createModalError:Ce,setCreateModalError:R,createDisplayName:pe,setCreateDisplayName:me,createAgentId:I,setCreateAgentId:he,createDescription:ge,setCreateDescription:_e,createWorkspace:ve,setCreateWorkspace:ye,createModel:xe,setCreateModel:L,onCreate:it,applyCreateWorkspaceSuggestion:Ze,deleteDialogOpen:i,setDeleteDialogOpen:o,deletePurge:l,deleteTarget:s,setDeleteTarget:c,deleteConfirmText:m,setDeleteConfirmText:h,performDelete:st,editorPanelProps:{a:n,chat:v,cCron:g,selected:U,panel:F,data:j,busy:B,editName:Pe,setEditName:Ie,editDescription:Le,setEditDescription:Re,editWorkspace:ke,setEditWorkspace:Ae,editModel:Me,setEditModel:Ne,onSetDefault:()=>{U&&ot(U)},onSaveAgentEdits:()=>void at(),onDelete:e=>{U&&ct(U,e)},overviewSaveBootstrapRef:W.overviewSaveBootstrapRef,profileSaveRef:ze,setOverviewBootstrapDirty:Ve,setProfileDirty:Ue,filesLoading:W.filesLoading,files:W.files,activeFile:W.activeFile,setActiveFile:W.setActiveFile,bootstrapViewMode:W.bootstrapViewMode,setBootstrapViewMode:W.setBootstrapViewMode,fileDraft:W.fileDraft,setFileDraft:W.setFileDraft,fileSaving:W.fileSaving,bootstrapFileLoading:W.bootstrapFileLoading,bootstrapEditorNonce:W.bootstrapEditorNonce,toolEntryDisable:G.toolEntryDisable,setToolEntryDisable:G.setToolEntryDisable,onSaveTools:()=>void lt(),onClearToolsEntry:()=>void ut(),skillsCatalogLoading:Ye.skillsCatalogLoading,catalogForPick:Ye.catalogForPick,skillsInherit:G.skillsInherit,setSkillsInherit:G.setSkillsInherit,skillsPick:G.skillsPick,setSkillsPick:G.setSkillsPick,onSaveSkills:()=>void dt(),bindingsLoading:K.bindingsLoading,agentBindings:K.agentBindings,bindChannelStatuses:K.bindChannelStatuses,bindChannelsLoading:K.bindChannelsLoading,useManualChannel:K.useManualChannel,newBindChannel:K.newBindChannel,setNewBindChannel:K.setNewBindChannel,bindSessionChats:K.bindSessionChats,bindSessionsLoading:K.bindSessionsLoading,newBindSessionIdx:K.newBindSessionIdx,setNewBindSessionIdx:K.setNewBindSessionIdx,newBindCustomPeer:K.newBindCustomPeer,setNewBindCustomPeer:K.setNewBindCustomPeer,refreshBindSessions:K.refreshBindSessions,onRemoveBinding:e=>void K.onRemoveBinding(e),onAddBinding:K.onAddBinding,cronLoading:Je.cronLoading,agentCronJobs:Je.agentCronJobs,onSetCronJobAgent:(e,t)=>void Je.onSetCronJobAgent(e,t)}}}function Ln(){let e=In();return e.hasToken?e.showPresetSetup&&e.data?(0,q.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col px-4 py-8`,children:(0,q.jsx)(dn,{existingAgentIds:new Set(e.data.agents.map(e=>e.id)),onComplete:e.onPresetSetupComplete,onSkip:e.onPresetSetupSkip})}):(0,q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[(0,q.jsx)(sn,{a:e.a}),e.displayError?(0,q.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,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.loading}):e.data?(0,q.jsx)(on,{a:e.a,agents:e.data.agents,searchQuery:e.listSearchQuery,onOpenAgent:t=>e.navigate(se(t)),onChatWithAgent:t=>e.navigate(`/chat/new`,{state:{agentId:t.trim().toLowerCase()}}),onNewAgent:e.openAddAgentModal,busy:e.busy}):null,e.routeAgentId&&e.hasToken?(0,q.jsx)(gt,{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,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.loading}):(0,q.jsx)(nn,{...e.editorPanelProps})}):null,(0,q.jsx)(cn,{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,q.jsx)(ft,{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,q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,q.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:e.a.title}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.needToken})]})}function $({label:e,description:t,children:n}){return(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e}),n,(0,q.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t})]})}var Rn=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`adaptive`];function zn(e){let{a:t,chat:n,form:r,update:a}=e;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:B,title:t.cardModelsTitle,subtitle:t.label.model}),(0,q.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,q.jsx)($,{label:t.label.model,description:t.desc.model,children:(0,q.jsx)(ze,{value:r.model,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>a({model:e})})})})]}),(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:i,title:t.cardGenerationTitle,subtitle:t.cardGenerationSubtitle}),(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:t.label.maxTokens,description:t.desc.maxTokens,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),value:r.maxTokens,min:1,onChange:e=>a({maxTokens:Number.parseInt(e.target.value,10)||0})})}),(0,q.jsx)($,{label:t.label.temperature,description:t.desc.temperature,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),value:r.temperature,min:0,max:2,step:.1,onChange:e=>a({temperature:Number.parseFloat(e.target.value)||0})})}),(0,q.jsx)(`div`,{className:`sm:col-span-2`,children:(0,q.jsx)($,{label:t.label.maxToolIterations,description:t.desc.maxToolIterations,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),value:r.maxToolIterations,min:1,onChange:e=>a({maxToolIterations:Number.parseInt(e.target.value,10)||0})})})})]})]}),(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:E,title:t.cardBehaviorTitle,subtitle:t.cardBehaviorSubtitle}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsx)($,{label:t.label.thinkingDefault,description:t.desc.thinkingDefault,children:(0,q.jsx)(`select`,{className:Jt(),value:r.thinkingDefault,onChange:e=>a({thinkingDefault:e.target.value}),children:Rn.map(e=>(0,q.jsx)(`option`,{value:e,children:n.thinkingLevels[e]},e))})}),(0,q.jsx)($,{label:t.label.reasoningDefault,description:t.desc.reasoningDefault,children:(0,q.jsxs)(`select`,{className:Jt(),value:r.reasoningDefault,onChange:e=>a({reasoningDefault:e.target.value}),children:[(0,q.jsx)(`option`,{value:`off`,children:t.reasoning.off}),(0,q.jsx)(`option`,{value:`on`,children:t.reasoning.on}),(0,q.jsx)(`option`,{value:`stream`,children:t.reasoning.stream})]})}),(0,q.jsx)($,{label:t.label.verboseDefault,description:t.desc.verboseDefault,children:(0,q.jsxs)(`select`,{className:Jt(),value:r.verboseDefault,onChange:e=>a({verboseDefault:e.target.value}),children:[(0,q.jsx)(`option`,{value:`off`,children:t.verbose.off}),(0,q.jsx)(`option`,{value:`on`,children:t.verbose.on}),(0,q.jsx)(`option`,{value:`full`,children:t.verbose.full})]})})]})]})]})}function Bn(e){let{a:t,form:n,update:r}=e;return(0,q.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:me,title:t.cardBrowserTitle,subtitle:t.cardBrowserSubtitle}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:t.label.browserEnabled,description:t.desc.browserEnabled,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:n.browserEnabled,onChange:e=>r({browserEnabled:e.target.checked})}),(0,q.jsx)(`span`,{children:t.browserEnabledOn})]})}),(0,q.jsx)($,{label:t.label.browserHeadless,description:t.desc.browserHeadless,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:n.browserHeadless,onChange:e=>r({browserHeadless:e.target.checked})}),(0,q.jsx)(`span`,{children:t.browserHeadlessOn})]})}),(0,q.jsx)($,{label:t.label.browserAllowPrivateUrls,description:t.desc.browserAllowPrivateUrls,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:n.browserAllowPrivateUrls,onChange:e=>r({browserAllowPrivateUrls:e.target.checked})}),(0,q.jsx)(`span`,{children:t.browserAllowPrivateOn})]})}),(0,q.jsx)($,{label:t.label.browserCommandTimeout,description:t.desc.browserCommandTimeout,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:5,value:n.browserCommandTimeout??``,placeholder:`30`,onChange:e=>{let t=e.target.value;r({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})}})})]}),(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:t.label.browserCloudProvider,description:t.desc.browserCloudProvider,children:(0,q.jsxs)(`select`,{className:Jt(),value:n.browserCloudProvider,onChange:e=>r({browserCloudProvider:e.target.value}),children:[(0,q.jsx)(`option`,{value:`local`,children:t.browserCloudProviderLocal}),(0,q.jsx)(`option`,{value:`browserbase`,children:t.browserCloudProviderBrowserbase}),(0,q.jsx)(`option`,{value:`browser-use`,children:t.browserCloudProviderBrowserUse})]})}),(0,q.jsx)($,{label:t.label.browserDialogPolicy,description:t.desc.browserDialogPolicy,children:(0,q.jsxs)(`select`,{className:Jt(),value:n.browserDialogPolicy,onChange:e=>r({browserDialogPolicy:e.target.value}),children:[(0,q.jsx)(`option`,{value:`must_respond`,children:t.browserDialogPolicyMustRespond}),(0,q.jsx)(`option`,{value:`auto_dismiss`,children:t.browserDialogPolicyAutoDismiss}),(0,q.jsx)(`option`,{value:`auto_accept`,children:t.browserDialogPolicyAutoAccept})]})})]}),(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:t.label.browserCdpUrl,description:t.desc.browserCdpUrl,children:(0,q.jsx)(`input`,{type:`text`,className:Q(),value:n.browserCdpUrl,placeholder:`ws://localhost:9222`,onChange:e=>r({browserCdpUrl:e.target.value}),autoComplete:`off`})}),(0,q.jsx)($,{label:t.label.browserDialogTimeout,description:t.desc.browserDialogTimeout,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:1,value:n.browserDialogTimeout??``,placeholder:`300`,onChange:e=>{let t=e.target.value;r({browserDialogTimeout:t===``?void 0:Number.parseInt(t,10)})}})})]})]})]})})}function Vn(e,t){let[n,r]=(0,Z.useState)([]),[i,o]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{if(!e||!t)return;let n=!1;return o(!0),a().then(e=>{n||r(Array.isArray(e.builtinToolIds)?e.builtinToolIds:[])}).catch(()=>{n||r([])}).finally(()=>{n||o(!1)}),()=>{n=!0}},[e,t]),{builtinToolIds:n,loading:i}}function Hn(e){let{a:t,form:n,update:r}=e,i=t.advanced,a=je(u(e=>e.language)).agentsSettings,o=!!Xe(e=>e.token),{builtinToolIds:s,loading:c}=Vn(!0,o),l=(0,Z.useMemo)(()=>new Set(n.toolsDisable.map(e=>e.trim()).filter(Boolean)),[n.toolsDisable]),d=(0,Z.useMemo)(()=>n.toolsDisable.map(e=>e.trim()).filter(Boolean).filter(e=>!s.includes(e)).sort((e,t)=>e.localeCompare(t)),[n.toolsDisable,s]),f=(0,Z.useCallback)(e=>{r({toolsDisable:$t(e)})},[r]),p=a.toolsDisableGroups,m=(0,Z.useCallback)(e=>p[e],[p]),h=(0,Z.useCallback)(e=>e in a.toolDescriptions?a.toolDescriptions[e]:``,[a.toolDescriptions]);return(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:rt,title:i.cardToolsDisableTitle,subtitle:i.cardToolsDisableSubtitle}),(0,q.jsx)($,{label:i.toolsDisableFieldLabel,description:i.toolsDisableHint,children:(0,q.jsx)(`div`,{className:`flex flex-col gap-3`,children:o?(0,q.jsx)(en,{mode:`defaults`,builtinToolIds:s,loading:c,disableSet:l,onDisableSetChange:f,unknownDisabledIds:d,getToolDescription:h,getGroupTitle:m,quickActionsDisabled:c,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,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.needToken})})})]})}function Un(e){let{a:t,chat:n,form:r,update:i}=e,a=t.advanced;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:ee,title:a.cardWebExtractTitle,subtitle:a.cardWebExtractSubtitle}),(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)(`div`,{className:`sm:col-span-2`,children:(0,q.jsx)($,{label:a.webExtractModel,description:a.webExtractModelDesc,children:(0,q.jsx)(ze,{value:r.webExtract.model,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>i({webExtract:{...r.webExtract,model:e}})})})}),(0,q.jsx)($,{label:a.webExtractMaxLength,description:a.webExtractMaxLengthDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),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,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:Ke,title:a.cardDelegateTitle,subtitle:a.cardDelegateSubtitle}),(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:a.delegateEnabled,description:a.delegateEnabledDesc,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.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,q.jsx)(`span`,{children:a.delegateEnabledOn})]})}),(0,q.jsx)($,{label:a.executeCodeEnabled,description:a.executeCodeEnabledDesc,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.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,q.jsx)(`span`,{children:a.executeCodeEnabledOn})]})})]})]}),(0,q.jsx)(Hn,{...e})]})}function Wn(e){let{a:t,form:n,update:r}=e,i=t.advanced;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:T,title:i.cardLimitsTitle,subtitle:i.cardLimitsSubtitle}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsx)($,{label:i.maxTaskDurationMs,description:i.maxTaskDurationMsDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),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,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:i.maxRequestsPerTurn,description:i.maxRequestsPerTurnDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:10,max:200,value:n.maxRequestsPerTurn,onChange:e=>r({maxRequestsPerTurn:Number.parseInt(e.target.value,10)||50})})}),(0,q.jsx)($,{label:i.maxToolFailuresPerTurn,description:i.maxToolFailuresPerTurnDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:1,max:20,value:n.maxToolFailuresPerTurn,onChange:e=>r({maxToolFailuresPerTurn:Number.parseInt(e.target.value,10)||3})})})]})]})]}),(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:S,title:i.cardCompactionTitle,subtitle:i.cardCompactionSubtitle}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsx)($,{label:i.compactionEnabled,description:i.compactionEnabledDesc,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.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,q.jsx)(`span`,{children:i.compactionEnabledOn})]})}),(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:i.compactionMode,description:i.compactionModeDesc,children:(0,q.jsxs)(`select`,{className:Jt(),value:n.compaction.mode,onChange:e=>r({compaction:{...n.compaction,mode:e.target.value}}),children:[(0,q.jsx)(`option`,{value:`default`,children:i.compactionModeDefault}),(0,q.jsx)(`option`,{value:`safeguard`,children:i.compactionModeSafeguard})]})}),(0,q.jsx)($,{label:i.reserveTokens,description:i.reserveTokensDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:1e3,value:n.compaction.reserveTokens,onChange:e=>r({compaction:{...n.compaction,reserveTokens:Number.parseInt(e.target.value,10)||0}})})}),(0,q.jsx)($,{label:i.triggerThreshold,description:i.triggerThresholdDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:.5,max:.95,step:.05,value:n.compaction.triggerThreshold,onChange:e=>r({compaction:{...n.compaction,triggerThreshold:Number.parseFloat(e.target.value)||.8}})})}),(0,q.jsx)($,{label:i.minMessagesBeforeCompact,description:i.minMessagesBeforeCompactDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:1,value:n.compaction.minMessagesBeforeCompact,onChange:e=>r({compaction:{...n.compaction,minMessagesBeforeCompact:Number.parseInt(e.target.value,10)||10}})})}),(0,q.jsx)($,{label:i.keepRecentMessages,description:i.keepRecentMessagesDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:0,value:n.compaction.keepRecentMessages,onChange:e=>r({compaction:{...n.compaction,keepRecentMessages:Number.parseInt(e.target.value,10)||5}})})}),(0,q.jsx)($,{label:i.evictionWindow,description:i.evictionWindowDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:.1,max:.5,step:.05,value:n.compaction.evictionWindow,onChange:e=>r({compaction:{...n.compaction,evictionWindow:Number.parseFloat(e.target.value)||.2}})})}),(0,q.jsx)($,{label:i.retentionWindow,description:i.retentionWindowDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:3,max:20,value:n.compaction.retentionWindow,onChange:e=>r({compaction:{...n.compaction,retentionWindow:Number.parseInt(e.target.value,10)||6}})})})]})]})]}),(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:R,title:i.cardPruningTitle,subtitle:i.cardPruningSubtitle}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsx)($,{label:i.pruningEnabled,description:i.pruningEnabledDesc,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.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,q.jsx)(`span`,{children:i.pruningEnabledOn})]})}),(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:i.maxToolResultChars,description:i.maxToolResultCharsDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:1e3,value:n.pruning.maxToolResultChars,onChange:e=>r({pruning:{...n.pruning,maxToolResultChars:Number.parseInt(e.target.value,10)||1e4}})})}),(0,q.jsx)($,{label:i.headKeepRatio,description:i.headKeepRatioDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:0,max:1,step:.05,value:n.pruning.headKeepRatio,onChange:e=>r({pruning:{...n.pruning,headKeepRatio:Number.parseFloat(e.target.value)||.3}})})}),(0,q.jsx)($,{label:i.tailKeepRatio,description:i.tailKeepRatioDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:0,max:1,step:.05,value:n.pruning.tailKeepRatio,onChange:e=>r({pruning:{...n.pruning,tailKeepRatio:Number.parseFloat(e.target.value)||.3}})})})]})]})]})]})}function Gn(e){let{a:t,form:n,update:r}=e,i=t.advanced;return(0,q.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:Oe,title:i.cardParamsTitle,subtitle:i.cardParamsSubtitle}),(0,q.jsx)($,{label:i.paramsJson,description:i.paramsJsonDesc,children:(0,q.jsx)(`textarea`,{className:x(Q(),`min-h-[88px] resize-y font-mono text-xs`),value:n.paramsJson,placeholder:`{}`,onChange:e=>r({paramsJson:e.target.value})})})]})})}function Kn(e){let{a:t,chat:n,form:r,update:i}=e,a=t.advanced;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:De,title:a.cardMemoryTitle,subtitle:a.cardMemorySubtitle}),(0,q.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:a.memoryEnabled,description:a.memoryEnabledDesc,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.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,q.jsx)(`span`,{children:a.memoryEnabledOn})]})}),(0,q.jsx)($,{label:a.useEnhancedSystem,description:a.useEnhancedSystemDesc,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.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,q.jsx)(`span`,{children:a.useEnhancedSystemOn})]})}),(0,q.jsx)($,{label:a.userProfileEnabled,description:a.userProfileEnabledDesc,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.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,q.jsx)(`span`,{children:a.userProfileEnabledOn})]})}),(0,q.jsx)($,{label:a.memoryProvider,description:a.memoryProviderDesc,children:(0,q.jsxs)(`select`,{className:Jt(),value:r.memory.provider,onChange:e=>i({memory:{...r.memory,provider:e.target.value}}),children:[(0,q.jsx)(`option`,{value:``,children:a.memoryProviderUnset}),(0,q.jsx)(`option`,{value:`none`,children:`none`}),(0,q.jsx)(`option`,{value:`stub`,children:`stub`})]})}),(0,q.jsx)($,{label:a.injectionFrequency,description:a.injectionFrequencyDesc,children:(0,q.jsxs)(`select`,{className:Jt(),value:r.memory.injectionFrequency,onChange:e=>i({memory:{...r.memory,injectionFrequency:e.target.value}}),children:[(0,q.jsx)(`option`,{value:``,children:a.injectionFrequencyUnset}),(0,q.jsx)(`option`,{value:`every-turn`,children:a.injectionEveryTurn}),(0,q.jsx)(`option`,{value:`first-turn`,children:a.injectionFirstTurn})]})}),(0,q.jsx)($,{label:a.memoryCharLimit,description:a.memoryCharLimitDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),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,q.jsx)($,{label:a.userCharLimit,description:a.userCharLimitDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),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,q.jsx)($,{label:a.contextCadence,description:a.contextCadenceDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),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,q.jsx)($,{label:a.dialecticCadence,description:a.dialecticCadenceDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),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,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:Ue,title:a.cardSessionSearchTitle,subtitle:a.cardSessionSearchSubtitle}),(0,q.jsx)($,{label:a.sessionSearchSummaryModel,description:a.sessionSearchSummaryModelDesc,children:(0,q.jsx)(ze,{value:r.sessionSearch.summaryModel,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>i({sessionSearch:{...r.sessionSearch,summaryModel:e}})})})]}),(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:ve,title:a.cardReviewTitle,subtitle:a.cardReviewSubtitle}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsx)($,{label:a.reviewEnabled,description:a.reviewEnabledDesc,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.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,q.jsx)(`span`,{children:a.reviewEnabledOn})]})}),(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:a.memoryNudgeInterval,description:a.memoryNudgeIntervalDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:0,value:r.backgroundReview.memoryNudgeInterval,onChange:e=>i({backgroundReview:{...r.backgroundReview,memoryNudgeInterval:Number.parseInt(e.target.value,10)||0}})})}),(0,q.jsx)($,{label:a.skillNudgeInterval,description:a.skillNudgeIntervalDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:0,value:r.backgroundReview.skillNudgeInterval,onChange:e=>i({backgroundReview:{...r.backgroundReview,skillNudgeInterval:Number.parseInt(e.target.value,10)||0}})})}),(0,q.jsx)($,{label:a.reviewMaxToolRounds,description:a.reviewMaxToolRoundsDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:1,max:32,value:r.backgroundReview.maxToolRounds,onChange:e=>i({backgroundReview:{...r.backgroundReview,maxToolRounds:Number.parseInt(e.target.value,10)||8}})})}),(0,q.jsx)($,{label:a.reviewMaxHistoryMessages,description:a.reviewMaxHistoryMessagesDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:10,max:200,value:r.backgroundReview.maxHistoryMessages,onChange:e=>i({backgroundReview:{...r.backgroundReview,maxHistoryMessages:Number.parseInt(e.target.value,10)||80}})})}),(0,q.jsx)($,{label:a.reviewMaxDurationMs,description:a.reviewMaxDurationMsDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),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 Jn(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 Yn(e){let{a:t,form:n,update:r}=e,i=t.advanced,a=je(u(e=>e.language)).agentsSettings,o=!!Xe(e=>e.token),{catalogForPick:s,skillsCatalogLoading:c}=Nn(!0,o),l=(0,Z.useMemo)(()=>s.map(qn),[s]),d=n.skillsAllowlist.length>0,f=(0,Z.useMemo)(()=>new Set(n.skillsAllowlist.map(e=>e.trim()).filter(Boolean)),[n.skillsAllowlist]),p=(0,Z.useMemo)(()=>n.skillsAllowlist.filter(e=>e.trim()&&!l.includes(e.trim())),[n.skillsAllowlist,l]),m=(0,Z.useMemo)(()=>p.map(e=>({name:e.trim(),directoryId:e.trim()})),[p]),h=(0,Z.useMemo)(()=>[...m,...s],[m,s]),g=(0,Z.useCallback)(()=>{r({skillsAllowlist:[]})},[r]),_=(0,Z.useCallback)(()=>{r({skillsAllowlist:[...l]})},[r,l]),v=(0,Z.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:Jn(i,l)})},[n.skillsAllowlist,l,r]);return(0,q.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:Me,title:i.cardSkillsTitle,subtitle:i.cardSkillsSubtitle}),(0,q.jsx)($,{label:i.skillsAllowlist,description:i.skillsAllowlistDesc,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(k,{type:`button`,variant:`secondary`,className:Yt,onClick:g,children:i.skillsAllowlistModeAll}),(0,q.jsx)(k,{type:`button`,variant:`secondary`,className:Yt,disabled:!d&&l.length===0,onClick:()=>{d||_()},children:i.skillsAllowlistModeRestrict})]}),(0,q.jsx)($e,{to:L(`skills`),className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,children:a.skillsLibraryLink})]}),o?c?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.skillsCatalogLoading}):h.length===0?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.skillsEmptyCatalog}):(0,q.jsx)(`div`,{className:x(`max-h-[min(50vh,22rem)] overflow-y-auto overscroll-contain pr-0.5`,!d&&`pointer-events-none opacity-50`),children:(0,q.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=!l.includes(t);return(0,q.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,q.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:n,disabled:!d,onChange:()=>v(t,!n)}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,q.jsxs)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:[t,s?(0,q.jsxs)(`span`,{className:`ml-1.5 font-sans text-[10px] font-normal text-fg-muted`,children:[`(`,i.skillsAllowlistNotInCatalog,`)`]}):null]}),(0,q.jsx)(`p`,{className:x(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!r&&`italic text-fg-subtle`),title:o,children:o})]})]})},t)})})}):(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.needToken})]})})]})})}function Xn(e){let{a:t,form:n,update:r}=e,i=t.advanced;return(0,q.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:W,title:i.cardSystemPromptTitle,subtitle:i.cardSystemPromptSubtitle}),(0,q.jsx)($,{label:i.systemPromptOverride,description:i.systemPromptOverrideDesc,children:(0,q.jsx)(`textarea`,{className:x(Q(),`min-h-[140px] resize-y font-mono text-xs`),value:n.systemPromptOverride,placeholder:i.systemPromptPlaceholder,onChange:e=>r({systemPromptOverride:e.target.value})})})]})})}function Zn(e){let{a:t,form:n,update:r}=e;return(0,q.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:fe,title:t.cardWorkspaceTitle,subtitle:t.cardWorkspaceSubtitle}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsx)($,{label:t.label.workspace,description:t.desc.workspace,children:(0,q.jsx)(`input`,{type:`text`,className:Q(),value:n.workspace,onChange:e=>r({workspace:e.target.value}),autoComplete:`off`})}),(0,q.jsx)($,{label:t.label.mediaMaxMb,description:t.desc.mediaMaxMb,children:(0,q.jsx)(`input`,{type:`number`,min:1,step:1,className:Q(),value:n.mediaMaxMb??``,placeholder:`20`,onChange:e=>{let t=e.target.value;r({mediaMaxMb:t===``?void 0:Number(t)})}})})]})]})})}function Qn(e){let{sectionId:t,intro:n,vm:r,children:i}=e,a=je(u(e=>e.language)),o=a.agentSettings,s=a.settingsSections[t]??t;return r.hasToken?r.loading?(0,q.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,q.jsx)(`div`,{className:`h-8 w-48 animate-pulse rounded bg-surface-hover`}),(0,q.jsx)(`div`,{className:`mt-6 h-32 animate-pulse rounded-xl bg-surface-hover`}),(0,q.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:a.logs.loading})]}):r.form?(0,q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[(0,q.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:s}),(0,q.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:o.sectionDesc})]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[r.saveOk?(0,q.jsx)(`span`,{className:`text-sm text-fg-muted`,children:o.saved}):null,(0,q.jsx)(k,{type:`button`,variant:`secondary`,disabled:!r.dirty||r.saving,onClick:r.discard,children:o.discard}),(0,q.jsx)(k,{type:`button`,variant:`primary`,disabled:!r.dirty||r.saving,onClick:()=>void r.save(),children:r.saving?o.saving:o.save})]})]}),r.error?(0,q.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,q.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:i})]}):(0,q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-10`,children:[(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.error??r.fetchError??o.loadError}),(0,q.jsx)(k,{type:`button`,variant:`secondary`,onClick:()=>void r.mutate(),children:a.logs.refresh})]}):(0,q.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-10`,children:(0,q.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[(0,q.jsx)(B,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:s}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o.needToken})]})]})})}var $n={enabled:!0,mode:`default`,reserveTokens:8e3,triggerThreshold:.8,minMessagesBeforeCompact:10,keepRecentMessages:5,evictionWindow:.2,retentionWindow:6},er={enabled:!0,maxToolResultChars:1e4,headKeepRatio:.3,tailKeepRatio:.3},tr={enabled:!0,useEnhancedSystem:!0,userProfileEnabled:!0,provider:``,injectionFrequency:``,memoryCharLimit:void 0,userCharLimit:void 0,contextCadence:void 0,dialecticCadence:void 0},nr={summaryModel:``},rr={enabled:!1,memoryNudgeInterval:10,skillNudgeInterval:10,maxToolRounds:8,maxHistoryMessages:80,maxDurationMs:12e4},ir={model:``,maxLength:void 0};function ar(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 or(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 sr(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 cr(e){return e===!0||e===`true`||e===1}function lr(e){let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{browserEnabled:!1,browserHeadless:!0,browserAllowPrivateUrls:!1,browserCommandTimeout:void 0,browserCloudProvider:`local`,browserCdpUrl:``,browserDialogPolicy:`auto_dismiss`,browserDialogTimeout:void 0};let n=t,r=cr(n.enabled),i=n.headless,a=!(i===!1||i===`false`||i===0),o=cr(n.allowPrivateUrls),s=typeof n.commandTimeout==`number`&&Number.isFinite(n.commandTimeout)&&n.commandTimeout>=5?Math.floor(n.commandTimeout):void 0,c=n.cloudProvider,l=c===`browserbase`||c===`browser-use`?c:`local`,u=typeof n.cdpUrl==`string`?n.cdpUrl:``,d=n.dialogPolicy;return{browserEnabled:r,browserHeadless:a,browserAllowPrivateUrls:o,browserCommandTimeout:s,browserCloudProvider:l,browserCdpUrl:u,browserDialogPolicy:d===`must_respond`||d===`auto_accept`?d:`auto_dismiss`,browserDialogTimeout:typeof n.dialogTimeoutSeconds==`number`&&Number.isFinite(n.dialogTimeoutSeconds)&&n.dialogTimeoutSeconds>=1?Math.floor(n.dialogTimeoutSeconds):void 0}}function ur(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...$n};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:$n.enabled,mode:t.mode===`safeguard`?`safeguard`:`default`,reserveTokens:typeof t.reserveTokens==`number`&&Number.isFinite(t.reserveTokens)?Math.floor(t.reserveTokens):$n.reserveTokens,triggerThreshold:typeof t.triggerThreshold==`number`&&Number.isFinite(t.triggerThreshold)?t.triggerThreshold:$n.triggerThreshold,minMessagesBeforeCompact:typeof t.minMessagesBeforeCompact==`number`&&Number.isFinite(t.minMessagesBeforeCompact)?Math.floor(t.minMessagesBeforeCompact):$n.minMessagesBeforeCompact,keepRecentMessages:typeof t.keepRecentMessages==`number`&&Number.isFinite(t.keepRecentMessages)?Math.floor(t.keepRecentMessages):$n.keepRecentMessages,evictionWindow:typeof t.evictionWindow==`number`&&Number.isFinite(t.evictionWindow)?t.evictionWindow:$n.evictionWindow,retentionWindow:typeof t.retentionWindow==`number`&&Number.isFinite(t.retentionWindow)?Math.floor(t.retentionWindow):$n.retentionWindow}}function dr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...er};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:er.enabled,maxToolResultChars:typeof t.maxToolResultChars==`number`&&Number.isFinite(t.maxToolResultChars)?Math.floor(t.maxToolResultChars):er.maxToolResultChars,headKeepRatio:typeof t.headKeepRatio==`number`&&Number.isFinite(t.headKeepRatio)?t.headKeepRatio:er.headKeepRatio,tailKeepRatio:typeof t.tailKeepRatio==`number`&&Number.isFinite(t.tailKeepRatio)?t.tailKeepRatio:er.tailKeepRatio}}function fr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...tr};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:tr.enabled,useEnhancedSystem:typeof t.useEnhancedSystem==`boolean`?t.useEnhancedSystem:tr.useEnhancedSystem,userProfileEnabled:typeof t.userProfileEnabled==`boolean`?t.userProfileEnabled:tr.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 pr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...nr};let t=e;return{summaryModel:typeof t.summaryModel==`string`?t.summaryModel:``}}function mr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...rr};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:rr.enabled,memoryNudgeInterval:typeof t.memoryNudgeInterval==`number`&&t.memoryNudgeInterval>=0?Math.floor(t.memoryNudgeInterval):rr.memoryNudgeInterval,skillNudgeInterval:typeof t.skillNudgeInterval==`number`&&t.skillNudgeInterval>=0?Math.floor(t.skillNudgeInterval):rr.skillNudgeInterval,maxToolRounds:typeof t.maxToolRounds==`number`&&t.maxToolRounds>=1&&t.maxToolRounds<=32?Math.floor(t.maxToolRounds):rr.maxToolRounds,maxHistoryMessages:typeof t.maxHistoryMessages==`number`&&t.maxHistoryMessages>=10&&t.maxHistoryMessages<=200?Math.floor(t.maxHistoryMessages):rr.maxHistoryMessages,maxDurationMs:typeof t.maxDurationMs==`number`&&t.maxDurationMs>=3e4&&t.maxDurationMs<=6e5?Math.floor(t.maxDurationMs):rr.maxDurationMs}}function hr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...ir};let t=e;return{model:typeof t.model==`string`?t.model:``,maxLength:typeof t.maxLength==`number`&&t.maxLength>0?t.maxLength:void 0}}function gr(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 _r(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function vr(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 yr(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 br(e){if(e.imageGenerationModelAutoProviderFallback===!0)return!0;let t=e.imageGenerationModel;return t&&typeof t==`object`&&!Array.isArray(t)?t.autoProviderFallback===!0:!1}function xr(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:or(r.model),o=r.imageModelFallbacks,s=Array.isArray(o)&&o.every(e=>typeof e==`string`)?o:or(r.imageModel),c=r.imageGenerationModelFallbacks,l=Array.isArray(c)&&c.every(e=>typeof e==`string`)?c:or(r.imageGenerationModel),u=lr(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:ar(r.model),modelFallbacks:a,imageModel:ar(r.imageModel),imageModelFallbacks:s,imageGenerationModel:ar(r.imageGenerationModel),imageGenerationModelFallbacks:l,imageGenerationModelTimeoutMs:yr(r),imageGenerationModelAutoProviderFallback:br(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:ur(r.compaction),pruning:dr(r.pruning),memory:fr(r.memory),sessionSearch:pr(r.sessionSearch),backgroundReview:mr(r.backgroundReview),webExtract:hr(r.webExtract),delegate:gr(r.delegate,!1),executeCode:gr(r.executeCode,!1),systemPromptOverride:typeof r.systemPromptOverride==`string`?r.systemPromptOverride:``,skillsAllowlist:_r(r.skills),toolsDisable:(()=>{let e=r.tools;if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e.disable;return _r(t)})(),paramsJson:vr(r.params)}}function Sr(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 Cr(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 wr(){return xr(sr(await H(z(`/api/config`)))??{})}async function Tr(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=Cr(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,cloudProvider:e.browserCloudProvider===`local`?null:e.browserCloudProvider,cdpUrl:e.browserCdpUrl.trim()||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:Sr(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 H(z(`/api/config`),{method:`PATCH`,body:JSON.stringify({agents:{defaults:h}})}),tt()}function Er(e){let t=!!Xe(e=>e.token),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),f=(0,Z.useRef)(!1),{data:p,error:m,isLoading:h,mutate:g}=ue(t),_=(0,Z.useMemo)(()=>p?.payload?.config===void 0?null:xr(p.payload.config),[p]);(0,Z.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,Z.useMemo)(()=>!n||!i?!1:JSON.stringify(n)!==JSON.stringify(i),[n,i]);return{hasToken:t,loading:v,fetchError:y,form:n,update:(0,Z.useCallback)(e=>{f.current=!0,r(t=>t?{...t,...e}:null)},[]),dirty:b,saving:o,saveOk:u,error:c,setError:l,save:(0,Z.useCallback)(async()=>{if(!n||o)return!1;s(!0),l(null),d(!1);try{try{Cr(n.paramsJson)}catch(t){return l(t instanceof SyntaxError?e.advanced.paramsInvalidJson:t instanceof Error?t.message:e.advanced.paramsInvalidJson),!1}return await Tr(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,Z.useCallback)(()=>{i&&(f.current=!1,r(structuredClone(i)),l(null),d(!1))},[i]),mutate:g}}function Dr(){let e=je(u(e=>e.language)),t=e.agentSettings,n=e.chat,r=Er(t);return{vm:r,pp:(0,Z.useMemo)(()=>r.form?{form:r.form,update:r.update,a:t,chat:n}:null,[r.form,r.update,t,n]),a:t}}function Or(){let{vm:e,pp:t,a:n}=Dr();return(0,q.jsx)(Qn,{sectionId:`agent-chat`,intro:n.routeIntro.chat,vm:e,children:t?(0,q.jsx)(zn,{...t}):null})}function kr(){let{vm:e,pp:t,a:n}=Dr();return(0,q.jsx)(Qn,{sectionId:`agent-workspace`,intro:n.routeIntro.workspace,vm:e,children:t?(0,q.jsx)(Zn,{...t}):null})}function Ar(){let{vm:e,pp:t,a:n}=Dr();return(0,q.jsx)(Qn,{sectionId:`agent-browser`,intro:n.routeIntro.browser,vm:e,children:t?(0,q.jsx)(Bn,{...t}):null})}function jr(){let{vm:e,pp:t,a:n}=Dr();return(0,q.jsx)(Qn,{sectionId:`agent-runtime`,intro:n.routeIntro.runtime,vm:e,children:t?(0,q.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,q.jsx)(Wn,{...t}),(0,q.jsx)(Kn,{...t})]}):null})}function Mr(){let{vm:e,pp:t,a:n}=Dr();return(0,q.jsx)(Qn,{sectionId:`agent-tools`,intro:n.routeIntro.tools,vm:e,children:t?(0,q.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,q.jsx)(Un,{...t}),(0,q.jsx)(Yn,{...t}),(0,q.jsx)(Gn,{...t})]}):null})}function Nr(){let{vm:e,pp:t,a:n}=Dr();return(0,q.jsx)(Qn,{sectionId:`agent-system-prompt`,intro:n.routeIntro.systemPrompt,vm:e,children:t?(0,q.jsx)(Xn,{...t}):null})}export{Ln as AgentsSettingsPanel,En as _,Mr as a,_t as b,wr as c,$ as d,Cn as f,Tn as g,wn as h,Nr as i,Cr as l,Dn as m,Or as n,kr as o,On as p,jr as r,Er as s,Ar as t,Tr as u,J as v,Y as y};
216
+ //# sourceMappingURL=agents-Bk2uuFvC.js.map