morpheus-cli 0.9.4 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -43
- package/dist/channels/discord.js +3 -6
- package/dist/channels/telegram.js +3 -6
- package/dist/cli/commands/restart.js +15 -0
- package/dist/cli/commands/start.js +16 -0
- package/dist/config/manager.js +61 -0
- package/dist/config/paths.js +1 -0
- package/dist/config/schemas.js +11 -3
- package/dist/http/api.js +3 -0
- package/dist/http/routers/link.js +239 -0
- package/dist/http/routers/skills.js +1 -8
- package/dist/http/routers/smiths.js +14 -4
- package/dist/runtime/apoc.js +1 -1
- package/dist/runtime/audit/repository.js +1 -1
- package/dist/runtime/link-chunker.js +214 -0
- package/dist/runtime/link-repository.js +301 -0
- package/dist/runtime/link-search.js +298 -0
- package/dist/runtime/link-worker.js +284 -0
- package/dist/runtime/link.js +295 -0
- package/dist/runtime/memory/sati/service.js +1 -1
- package/dist/runtime/neo.js +1 -1
- package/dist/runtime/oracle.js +81 -44
- package/dist/runtime/scaffold.js +4 -17
- package/dist/runtime/skills/__tests__/loader.test.js +7 -10
- package/dist/runtime/skills/__tests__/registry.test.js +2 -18
- package/dist/runtime/skills/__tests__/tool.test.js +55 -224
- package/dist/runtime/skills/index.js +1 -2
- package/dist/runtime/skills/loader.js +0 -2
- package/dist/runtime/skills/registry.js +8 -20
- package/dist/runtime/skills/schema.js +0 -4
- package/dist/runtime/skills/tool.js +42 -209
- package/dist/runtime/smiths/delegator.js +1 -1
- package/dist/runtime/smiths/registry.js +1 -1
- package/dist/runtime/tasks/worker.js +12 -44
- package/dist/runtime/trinity.js +1 -1
- package/dist/types/config.js +14 -0
- package/dist/ui/assets/AuditDashboard-93LCGHG1.js +1 -0
- package/dist/ui/assets/{Chat-5AeRYuRj.js → Chat-CK5sNcQ1.js} +8 -8
- package/dist/ui/assets/{Chronos-BrKldYVw.js → Chronos-m2h--GEe.js} +1 -1
- package/dist/ui/assets/{ConfirmationModal-DsbS3XkJ.js → ConfirmationModal-Dd5pUJme.js} +1 -1
- package/dist/ui/assets/{Dashboard-DvrTXLdo.js → Dashboard-ODwl7d-a.js} +1 -1
- package/dist/ui/assets/{DeleteConfirmationModal-BfSjv04R.js → DeleteConfirmationModal-CCcojDmr.js} +1 -1
- package/dist/ui/assets/Documents-dWnSoxFO.js +7 -0
- package/dist/ui/assets/{Logs-B0ZYWs5x.js → Logs-Dc9Z2LBj.js} +1 -1
- package/dist/ui/assets/{MCPManager-BwHGTeNs.js → MCPManager-CMkb8vMn.js} +1 -1
- package/dist/ui/assets/{ModelPricing-CYhGRQr8.js → ModelPricing-DtHPPbEQ.js} +1 -1
- package/dist/ui/assets/{Notifications-BYMAtVMq.js → Notifications-BPvo-DWP.js} +1 -1
- package/dist/ui/assets/{Pagination-oTGieBLM.js → Pagination-BHZKk42X.js} +1 -1
- package/dist/ui/assets/{SatiMemories-I1vsYtP2.js → SatiMemories-BUPu1Lxr.js} +1 -1
- package/dist/ui/assets/SessionAudit-CFKF4DA8.js +9 -0
- package/dist/ui/assets/Settings-C4JrXfsR.js +47 -0
- package/dist/ui/assets/{Skills-lGU3I5DO.js → Skills-BUlvJgJ4.js} +1 -1
- package/dist/ui/assets/Smiths-CDtJdY0I.js +1 -0
- package/dist/ui/assets/{Tasks-Bz92GPWK.js → Tasks-DK_cOsNK.js} +1 -1
- package/dist/ui/assets/{TrinityDatabases-BUY-3j7Q.js → TrinityDatabases-X07by-19.js} +1 -1
- package/dist/ui/assets/{UsageStats-Dr5eSgJc.js → UsageStats-dYcgckLq.js} +1 -1
- package/dist/ui/assets/{WebhookManager-DIASAC-1.js → WebhookManager-DDw5eX2R.js} +1 -1
- package/dist/ui/assets/{audit-CcAEDbZh.js → audit-DZ5WLUEm.js} +1 -1
- package/dist/ui/assets/{chronos-2Z9E96_1.js → chronos-B_HI4mlq.js} +1 -1
- package/dist/ui/assets/{config-DdfK4DX6.js → config-B-YxlVrc.js} +1 -1
- package/dist/ui/assets/index-DVjwJ8jT.css +1 -0
- package/dist/ui/assets/{index-Dpd1Mkgp.js → index-DfJwcKqG.js} +5 -5
- package/dist/ui/assets/{mcp-BWMt8aY7.js → mcp-k-_pwbqA.js} +1 -1
- package/dist/ui/assets/{skills-D7JjK7JH.js → skills-xMXangks.js} +1 -1
- package/dist/ui/assets/{stats-DoIhtLot.js → stats-C4QZIv5O.js} +1 -1
- package/dist/ui/assets/{vendor-icons-DMd9RGvJ.js → vendor-icons-NHF9HNeN.js} +1 -1
- package/dist/ui/index.html +3 -3
- package/dist/ui/sw.js +1 -1
- package/package.json +3 -1
- package/dist/runtime/__tests__/keymaker.test.js +0 -148
- package/dist/runtime/keymaker.js +0 -157
- package/dist/ui/assets/AuditDashboard-C1f6Hbdw.js +0 -1
- package/dist/ui/assets/SessionAudit-BCecQWde.js +0 -9
- package/dist/ui/assets/Settings-Cu4D-7tb.js +0 -47
- package/dist/ui/assets/Smiths-DnEH3nID.js +0 -1
- package/dist/ui/assets/index-D4fzIKy1.css +0 -1
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as b,f as U,c as I}from"./vendor-react-DikRIOlj.js";import{u as F}from"./audit-CcAEDbZh.js";import{E as N,q as P,F as O,J as A,m as $,g as T,I as J,ai as D,as as R,G as B,o as M,a6 as G,w as V,y as W,aj as Z,i as q,at as H,au as X,O as K,a8 as Q,av as Y,r as ee,a2 as te}from"./vendor-icons-DMd9RGvJ.js";import"./vendor-utils-D4NnWbOU.js";import"./index-Dpd1Mkgp.js";const re={llm_call:e.jsx(R,{size:16}),tool_call:e.jsx(N,{size:16}),mcp_tool:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M3.49994 11.7501L11.6717 3.57855C12.7762 2.47398 14.5672 2.47398 15.6717 3.57855C16.7762 4.68312 16.7762 6.47398 15.6717 7.57855M15.6717 7.57855L9.49994 13.7501M15.6717 7.57855C16.7762 6.47398 18.5672 6.47398 19.6717 7.57855C20.7762 8.68312 20.7762 10.474 19.6717 11.5785L12.7072 18.543C12.3167 18.9335 12.3167 19.5667 12.7072 19.9572L13.9999 21.2499",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M17.4999 9.74921L11.3282 15.921C10.2237 17.0255 8.43272 17.0255 7.32823 15.921C6.22373 14.8164 6.22373 13.0255 7.32823 11.921L13.4999 5.74939",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),task_created:e.jsx(D,{size:16}),task_completed:e.jsx(O,{size:16}),skill_executed:e.jsx(J,{size:16}),chronos_job:e.jsx(T,{size:16}),memory_recovery:e.jsx($,{size:16}),memory_persist:e.jsx($,{size:16}),telephonist:e.jsx(A,{size:16})},se={llm_call:"text-blue-400 dark:text-blue-400",tool_call:"text-amber-500 dark:text-amber-400",mcp_tool:"text-orange-500 dark:text-orange-400",task_created:"text-gray-500 dark:text-matrix-secondary",task_completed:"text-green-600 dark:text-matrix-highlight",skill_executed:"text-teal-600 dark:text-teal-400",chronos_job:"text-orange-500 dark:text-orange-400",memory_recovery:"text-emerald-600 dark:text-emerald-400",memory_persist:"text-violet-600 dark:text-violet-400",telephonist:"text-rose-500 dark:text-rose-400"},ae={llm_call:"border-blue-300 dark:border-blue-500/40",tool_call:"border-amber-300 dark:border-amber-500/40",mcp_tool:"border-purple-300 dark:border-purple-500/40",task_created:"border-gray-300 dark:border-matrix-primary/40",task_completed:"border-green-300 dark:border-matrix-highlight/40",skill_executed:"border-teal-300 dark:border-teal-500/40",chronos_job:"border-orange-300 dark:border-orange-500/40",memory_recovery:"border-emerald-300 dark:border-emerald-500/40",memory_persist:"border-violet-300 dark:border-violet-500/40",telephonist:"border-rose-300 dark:border-rose-500/40"},ne={oracle:"🔮",apoc:"🧑🔬",neo:"🥷",trinity:"👩💻",smith:"🤖",keymaker:"🗝️",chronos:"⏰",sati:"🧠",telephonist:"📞"},oe={oracle:"bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300",apoc:"bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-300",neo:"bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300",trinity:"bg-teal-100 text-teal-700 dark:bg-teal-900/40 dark:text-teal-300",smith:"bg-gray-200 text-gray-700 dark:bg-gray-700/60 dark:text-gray-300",keymaker:"bg-pink-100 text-pink-700 dark:bg-pink-900/40 dark:text-pink-300",chronos:"bg-orange-100 text-orange-700 dark:bg-orange-900/40 dark:text-orange-300",sati:"bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300",telephonist:"bg-rose-100 text-rose-700 dark:bg-rose-900/40 dark:text-rose-300"};function ie(t){return t==null?"—":t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`}function le(t){return t==null||t===0?"—":t<1e-4?"<$0.0001":`$${t.toFixed(4)}`}function de(t,r){if(t==null&&r==null)return"";const l=t??0,n=r??0;return`↑${l.toLocaleString()} ↓${n.toLocaleString()}`}function S(t){return typeof t=="string"?t:JSON.stringify(t,null,2)}function xe({parsedMeta:t,eventType:r}){const l=r==="tool_call"||r==="mcp_tool",{args:n,result:o,...m}=t;if(r==="memory_persist"){const x=Array.isArray(t.inclusions)?t.inclusions:[],d=Array.isArray(t.edits)?t.edits:[],a=Array.isArray(t.deletions)?t.deletions:[];return x.length===0&&d.length===0&&a.length===0?e.jsx("p",{className:"text-[11px] text-gray-400 dark:text-matrix-secondary/50 italic",children:"No memory changes recorded."}):e.jsxs("div",{className:"space-y-2.5",children:[x.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-gray-400 dark:text-matrix-secondary/50 mb-1 flex items-center gap-1",children:[e.jsx(G,{size:10,className:"text-green-500 dark:text-green-400"})," new memories (",x.length,")"]}),e.jsx("div",{className:"space-y-1",children:x.map((s,c)=>e.jsxs("div",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded px-2 py-1.5 flex items-start gap-2",children:[e.jsx("span",{className:"flex-shrink-0 text-[10px] uppercase font-bold text-violet-500 dark:text-violet-400 bg-violet-50 dark:bg-violet-900/30 px-1 rounded",children:s.category??"?"}),e.jsx("span",{className:"flex-1 break-words",children:s.summary??"—"}),s.importance!=null&&e.jsxs("span",{className:"flex-shrink-0 text-[10px] text-gray-400 dark:text-matrix-secondary/50",children:["imp:",s.importance]})]},c))})]}),d.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-gray-400 dark:text-matrix-secondary/50 mb-1 flex items-center gap-1",children:[e.jsx(V,{size:10,className:"text-amber-500 dark:text-amber-400"})," edited memories (",d.length,")"]}),e.jsx("div",{className:"space-y-1",children:d.map((s,c)=>e.jsxs("div",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded px-2 py-1.5",children:[s.id&&e.jsxs("span",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/50 mr-2",children:["#",s.id]}),s.summary&&e.jsx("span",{className:"break-words",children:s.summary}),s.reason&&e.jsxs("span",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/50 ml-2",children:["— ",s.reason]})]},c))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-gray-400 dark:text-matrix-secondary/50 mb-1 flex items-center gap-1",children:[e.jsx(W,{size:10,className:"text-red-500 dark:text-red-400"})," archived memories (",a.length,")"]}),e.jsx("div",{className:"space-y-1",children:a.map((s,c)=>e.jsxs("div",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded px-2 py-1.5",children:[s.id&&e.jsxs("span",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/50 mr-2",children:["#",s.id]}),s.reason&&e.jsx("span",{className:"break-words",children:s.reason})]},c))})]})]})}return l&&(n!==void 0||o!==void 0)?e.jsxs("div",{className:"space-y-2",children:[n!==void 0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-gray-400 dark:text-matrix-secondary/50 mb-1",children:"args"}),e.jsx("pre",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded p-2 overflow-x-auto whitespace-pre-wrap break-words max-h-40 overflow-y-auto",children:S(n)})]}),o!==void 0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-gray-400 dark:text-matrix-secondary/50 mb-1",children:"result"}),e.jsx("pre",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded p-2 overflow-x-auto whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:S(o)})]}),Object.keys(m).length>0&&e.jsx("pre",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded p-2 overflow-x-auto whitespace-pre-wrap break-words",children:JSON.stringify(m,null,2)})]}):e.jsx("pre",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded p-2 overflow-x-auto whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:JSON.stringify(t,null,2)})}const L=({event:t})=>{const[r,l]=b.useState(!1),n=re[t.event_type]??e.jsx(N,{size:14}),o=se[t.event_type]??"text-gray-500",m=ae[t.event_type]??"border-gray-300 dark:border-matrix-primary/40",x=t.agent?oe[t.agent]??"bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-300":null,d=t.agent?ne[t.agent]:void 0,a=d?`${t.agent?.toUpperCase()} ${d}`:t.agent?.toUpperCase()||null,s=(()=>{try{return t.metadata?typeof t.metadata=="object"?t.metadata:JSON.parse(t.metadata):null}catch{return null}})(),c=s!==null&&Object.keys(s).length>0,i=t.event_type==="memory_recovery"?`${s?.memories_count??0} memories retrieved`:t.event_type==="memory_persist"?(()=>{const h=s?.inclusions_count??0,p=s?.edits_count??0,u=s?.deletions_count??0,y=[];return h&&y.push(`+${h} new`),p&&y.push(`~${p} edited`),u&&y.push(`-${u} archived`),y.length>0?y.join(", "):"memory persisted"})():t.event_type==="telephonist"?(()=>{const h=s?.audio_duration_seconds,p=s?.text_preview,u=h!=null?`${h}s`:"",y=typeof p=="string"&&p?`"${p.length>60?p.slice(0,60)+"…":p}"`:"";return[u,y].filter(Boolean).join(" · ")||"audio transcription"})():t.tool_name??t.model??t.event_type,g=t.event_type==="telephonist",v=s?.audio_duration_seconds,k=g?v!=null?`🎵 ${v}s audio`:"":de(t.input_tokens,t.output_tokens),f=le(t.estimated_cost_usd),_=ie(t.duration_ms),w=t.status==="error"?e.jsx(P,{size:14,className:"text-red-500 flex-shrink-0"}):t.status==="success"?e.jsx(O,{size:14,className:"text-green-500 dark:text-matrix-highlight flex-shrink-0"}):null,C=e.jsx("span",{className:`flex-shrink-0 w-3.5 flex items-center justify-center transition-colors ${c?"text-gray-300 dark:text-matrix-secondary/30 hover:text-gray-500 dark:hover:text-matrix-secondary cursor-pointer":"text-transparent pointer-events-none"}`,children:r?e.jsx(B,{size:12}):e.jsx(M,{size:12})}),z=()=>{c&&l(h=>!h)};return e.jsxs("div",{className:"py-2 px-3 rounded-lg hover:bg-gray-50 dark:hover:bg-zinc-900/60 transition-colors border-b border-gray-100 dark:border-matrix-primary/20 last:border-0",children:[e.jsxs("div",{className:"flex flex-col gap-0.5 md:hidden",children:[e.jsxs("div",{className:`flex items-center gap-2 min-w-0 ${c?"cursor-pointer":""}`,onClick:z,children:[C,e.jsx("span",{className:`flex-shrink-0 ${o}`,children:n}),x&&e.jsx("span",{className:`flex-shrink-0 text-xs font-semibold px-1.5 py-0.5 rounded ${x}`,children:a}),e.jsx("span",{className:"flex-1 text-sm text-gray-700 dark:text-matrix-secondary font-mono break-all leading-snug",children:i}),w]}),e.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-0 pl-5 text-[11px] text-gray-400 dark:text-matrix-secondary/60 font-mono",children:[k&&e.jsx("span",{children:k}),e.jsx("span",{children:_}),f!=="—"&&e.jsx("span",{className:"text-gray-600 dark:text-matrix-secondary",children:f})]})]}),e.jsxs("div",{className:`hidden md:flex items-center gap-3 ${c?"cursor-pointer":""}`,onClick:z,children:[C,e.jsx("span",{className:`flex-shrink-0 ${o}`,children:n}),x&&e.jsx("span",{className:`flex-shrink-0 text-xs font-semibold px-1.5 py-0.5 rounded ${x}`,children:a}),e.jsx("span",{className:"flex-1 text-sm truncate text-gray-700 dark:text-matrix-secondary font-mono",children:i}),k&&e.jsx("span",{className:"text-xs text-gray-400 dark:text-matrix-secondary/60 font-mono whitespace-nowrap",children:k}),e.jsx("span",{className:"text-xs text-gray-400 dark:text-matrix-secondary/60 font-mono w-16 text-right whitespace-nowrap",children:_}),w,e.jsx("span",{className:"text-xs text-gray-400 dark:text-matrix-secondary/60 font-mono w-20 text-right whitespace-nowrap",children:f})]}),r&&c&&s&&e.jsx("div",{className:`mt-1.5 ml-5 pl-3 border-l-2 ${m}`,children:e.jsx(xe,{parsedMeta:s,eventType:t.event_type})})]})},ce=({events:t,page:r,pageSize:l,totalCount:n,onPageChange:o})=>{const m=Math.ceil(n/l),x=r*l+1,d=Math.min(r*l+t.length,n);if(t.length===0)return e.jsx("div",{className:"flex items-center justify-center h-40 text-gray-400 dark:text-matrix-secondary/50 text-sm",children:"No audit events for this session."});const a=[],s=new Map;for(const i of t)if(i.task_id){const g=s.get(i.task_id)??[];g.push(i),s.set(i.task_id,g)}const c=new Set;for(const i of t)i.task_id?c.has(i.task_id)||(c.add(i.task_id),a.push({taskId:i.task_id,events:s.get(i.task_id)})):a.push({taskId:null,events:[i]});return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"hidden md:flex items-center gap-3 px-3 py-1 text-xs text-gray-400 dark:text-matrix-secondary/60 border-b border-gray-200 dark:border-matrix-primary/30 font-mono",children:[e.jsx("span",{className:"w-4"}),e.jsx("span",{className:"w-14 flex-shrink-0",children:"agent"}),e.jsx("span",{className:"flex-1",children:"event / tool / model"}),e.jsx("span",{className:"w-28 text-right",children:"tokens ↑↓"}),e.jsx("span",{className:"w-16 text-right",children:"duration"}),e.jsx("span",{className:"w-4"}),e.jsx("span",{className:"w-20 text-right",children:"cost"})]}),e.jsx("div",{className:"flex flex-col",children:a.map(i=>i.taskId?e.jsxs("div",{className:"mb-1",children:[e.jsxs("div",{className:"px-3 py-1 text-xs text-gray-400 dark:text-matrix-secondary/50 font-mono border-l-2 border-blue-300 dark:border-matrix-primary/60 ml-1 mb-0.5",children:["task: ",i.taskId.slice(0,8),"…"]}),e.jsx("div",{className:"pl-4",children:i.events.map(g=>e.jsx(L,{event:g},g.id))})]},i.taskId):e.jsx(L,{event:i.events[0]},i.events[0].id))}),m>1&&e.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-gray-200 dark:border-matrix-primary/30 mt-2",children:[e.jsxs("span",{className:"text-xs text-gray-400 dark:text-matrix-secondary/60",children:[x,"–",d," of ",n," events"]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>o(r-1),disabled:r===0,className:"p-1 rounded text-gray-400 dark:text-matrix-secondary hover:text-gray-700 dark:hover:text-matrix-highlight disabled:opacity-30 transition-colors",children:e.jsx(Z,{size:16})}),e.jsxs("span",{className:"text-xs self-center text-gray-500 dark:text-matrix-secondary font-mono px-2",children:[r+1," / ",m]}),e.jsx("button",{onClick:()=>o(r+1),disabled:r>=m-1,className:"p-1 rounded text-gray-400 dark:text-matrix-secondary hover:text-gray-700 dark:hover:text-matrix-highlight disabled:opacity-30 transition-colors",children:e.jsx(M,{size:16})})]})]})]})};function j(t){return t===0?"$0.00":t<1e-4?"<$0.0001":`$${t.toFixed(4)}`}function me(t){return t<1e3?`${t}ms`:t<6e4?`${(t/1e3).toFixed(1)}s`:`${(t/6e4).toFixed(1)}m`}const pe=({summary:t})=>e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-matrix-primary p-4 bg-white dark:bg-black",children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-700 dark:text-matrix-highlight mb-3 flex items-center gap-2",children:[e.jsx(q,{size:14})," Total Cost"]}),e.jsx("div",{className:"text-2xl font-bold text-gray-900 dark:text-matrix-highlight font-mono",children:j(t.totalCostUsd)}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs text-gray-500 dark:text-matrix-secondary",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(R,{size:12,className:"text-blue-400"}),e.jsxs("span",{children:[t.llmCallCount," LLM calls"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(N,{size:12,className:"text-amber-400"}),e.jsxs("span",{children:[t.toolCallCount," tool calls"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[e.jsx(T,{size:12,className:"text-gray-400"}),e.jsxs("span",{children:[me(t.totalDurationMs)," total duration"]})]}),t.totalAudioSeconds>0&&e.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[e.jsx(A,{size:12,className:"text-rose-400"}),e.jsxs("span",{children:[t.totalAudioSeconds.toFixed(1),"s audio"]})]})]})]}),t.byAgent.length>0&&e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-matrix-primary p-4 bg-white dark:bg-black",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-700 dark:text-matrix-highlight mb-3",children:"By Agent"}),e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-gray-400 dark:text-matrix-secondary/60 border-b border-gray-100 dark:border-matrix-primary/30",children:[e.jsx("th",{className:"text-left pb-1.5",children:"Agent"}),e.jsx("th",{className:"text-right pb-1.5",children:"Calls"}),e.jsx("th",{className:"text-right pb-1.5",children:"Tokens"}),e.jsx("th",{className:"text-right pb-1.5",children:"Cost"})]})}),e.jsx("tbody",{children:t.byAgent.map(r=>e.jsxs("tr",{className:"border-b border-gray-50 dark:border-matrix-primary/10 last:border-0",children:[e.jsx("td",{className:"py-1.5 text-gray-700 dark:text-matrix-secondary font-semibold",children:r.agent}),e.jsx("td",{className:"py-1.5 text-right text-gray-500 dark:text-matrix-secondary/70 font-mono",children:r.llmCalls}),e.jsx("td",{className:"py-1.5 text-right text-gray-500 dark:text-matrix-secondary/70 font-mono",children:(r.inputTokens+r.outputTokens).toLocaleString()}),e.jsx("td",{className:"py-1.5 text-right text-gray-700 dark:text-matrix-highlight font-mono",children:j(r.estimatedCostUsd)})]},r.agent))})]})]}),t.byModel.length>0&&e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-matrix-primary p-4 bg-white dark:bg-black",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-700 dark:text-matrix-highlight mb-3",children:"By Model"}),e.jsx("div",{className:"flex flex-col gap-2",children:t.byModel.map(r=>e.jsxs("div",{className:"border-b border-gray-50 dark:border-matrix-primary/10 last:border-0 pb-2 last:pb-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-0.5",children:[e.jsx("span",{className:"text-xs font-mono text-gray-700 dark:text-matrix-secondary break-all leading-snug",children:r.model}),e.jsx("span",{className:"text-xs font-mono text-gray-700 dark:text-matrix-highlight whitespace-nowrap shrink-0",children:j(r.estimatedCostUsd)})]}),e.jsxs("div",{className:"text-[11px] text-gray-400 dark:text-matrix-secondary/60 font-mono flex flex-wrap gap-x-3",children:[e.jsxs("span",{children:[r.calls," calls"]}),e.jsxs("span",{children:["in ",r.inputTokens.toLocaleString()]}),e.jsxs("span",{children:["out ",r.outputTokens.toLocaleString()]})]})]},`${r.provider}/${r.model}`))})]})]});function ge(t,r){const l=new Blob([JSON.stringify(r,null,2)],{type:"application/json"}),n=URL.createObjectURL(l),o=document.createElement("a");o.href=n,o.download=`audit-${t.slice(0,8)}.json`,o.click(),URL.revokeObjectURL(n)}function he(t,r){const l=["id","created_at","event_type","agent","tool_name","provider","model","input_tokens","output_tokens","duration_ms","status","estimated_cost_usd"],n=r.events.map(a=>[a.id,new Date(a.created_at).toISOString(),a.event_type,a.agent??"",a.tool_name??"",a.provider??"",a.model??"",a.input_tokens??"",a.output_tokens??"",a.duration_ms??"",a.status??"",a.estimated_cost_usd??""].map(s=>`"${String(s).replace(/"/g,'""')}"`).join(",")),o=[l.join(","),...n].join(`
|
|
2
|
-
`),m=new Blob([o],{type:"text/csv"}),x=URL.createObjectURL(m),d=document.createElement("a");d.href=x,d.download=`audit-${t.slice(0,8)}.csv`,d.click(),URL.revokeObjectURL(x)}const ye=({sessionId:t,data:r})=>{const[l,n]=b.useState(!1);return r?e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>n(!l),className:"flex items-center gap-1.5 text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-matrix-primary text-gray-600 dark:text-matrix-secondary hover:text-gray-900 dark:hover:text-matrix-highlight hover:border-gray-300 dark:hover:border-matrix-highlight transition-colors",children:[e.jsx(H,{size:14}),"Export",e.jsx(B,{size:12})]}),l&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>n(!1)}),e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 bg-white dark:bg-black border border-gray-200 dark:border-matrix-primary rounded-lg shadow-xl min-w-[140px] py-1",children:[e.jsxs("button",{onClick:()=>{ge(t,r),n(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-matrix-secondary hover:bg-gray-50 dark:hover:bg-zinc-900 transition-colors",children:[e.jsx(X,{size:14,className:"text-blue-500"}),"Export JSON"]}),e.jsxs("button",{onClick:()=>{he(t,r),n(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-matrix-secondary hover:bg-gray-50 dark:hover:bg-zinc-900 transition-colors",children:[e.jsx(K,{size:14,className:"text-green-500"}),"Export CSV"]})]})]})]}):null},E=100,ve=()=>{const{id:t}=U(),r=I(),[l,n]=b.useState(0),{data:o,error:m,isLoading:x}=F(t??null,l,E),d=b.useRef(null),[a,s]=b.useState(()=>typeof window<"u"?window.innerWidth>=768:!0);return b.useEffect(()=>{d.current&&(d.current.scrollTop=d.current.scrollHeight)},[o]),e.jsxs("div",{className:"flex flex-col h-full bg-gray-50 dark:bg-black",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-matrix-primary bg-white dark:bg-black flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>r(-1),className:"p-1.5 rounded-lg text-gray-400 dark:text-matrix-secondary hover:text-gray-700 dark:hover:text-matrix-highlight hover:bg-gray-100 dark:hover:bg-zinc-900 transition-colors",children:e.jsx(Q,{size:18})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 dark:text-matrix-highlight",children:"Session Audit"}),e.jsx("p",{className:"text-xs text-gray-400 dark:text-matrix-secondary/60 font-mono",children:t})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>s(c=>!c),className:"p-1.5 rounded-lg text-gray-400 dark:text-matrix-secondary hover:text-gray-700 dark:hover:text-matrix-highlight hover:bg-gray-100 dark:hover:bg-zinc-900 transition-colors md:hidden",title:"Toggle summary panel",children:e.jsx(Y,{size:18})}),e.jsx(ye,{sessionId:t??"",data:o})]})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden relative",children:[a&&e.jsx("div",{className:"fixed inset-0 bg-black/40 z-20 md:hidden",onClick:()=>s(!1)}),e.jsxs("div",{ref:d,className:"flex-[6] overflow-y-auto p-6 custom-scrollbar",children:[x&&e.jsxs("div",{className:"flex items-center justify-center h-40 gap-2 text-gray-400 dark:text-matrix-secondary",children:[e.jsx(ee,{size:18,className:"animate-spin"}),"Loading audit events…"]}),m&&e.jsxs("div",{className:"flex items-center gap-2 text-red-500 dark:text-red-400 p-4 rounded-lg border border-red-200 dark:border-red-800 bg-red-50 dark:bg-red-900/20",children:[e.jsx(te,{size:16}),"Failed to load audit events: ",m.message]}),o&&e.jsx(ce,{events:o.events,page:l,pageSize:E,totalCount:o.summary.llmCallCount+o.summary.toolCallCount,onPageChange:n})]}),e.jsx("div",{className:`
|
|
3
|
-
fixed top-16 bottom-0 right-0 z-40 w-72
|
|
4
|
-
md:relative md:inset-auto md:z-auto md:w-auto md:flex-[4] md:translate-x-0
|
|
5
|
-
transition-transform duration-300 ease-out
|
|
6
|
-
overflow-y-auto p-6 border-l border-gray-200 dark:border-matrix-primary
|
|
7
|
-
bg-white dark:bg-black custom-scrollbar
|
|
8
|
-
${a?"translate-x-0":"translate-x-full"}
|
|
9
|
-
`,children:o?e.jsx(pe,{summary:o.summary}):!x&&e.jsx("div",{className:"text-sm text-gray-400 dark:text-matrix-secondary/50 text-center mt-10",children:"No summary available."})})]})]})};export{ve as SessionAudit};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import{j as s}from"./vendor-motion-C3CZ8ZlO.js";import{r as I}from"./vendor-react-DikRIOlj.js";import{u as de,Z as gr,m as me}from"./vendor-utils-D4NnWbOU.js";import{u as br,c as vr}from"./chronos-2Z9E96_1.js";import{T as w,S as K}from"./SelectInput-KVLsnfra.js";import{c as V,N as M,S as H}from"./config-DdfK4DX6.js";import{C as yr}from"./ConfirmationModal-DsbS3XkJ.js";import{h as xr}from"./index-Dpd1Mkgp.js";import{d as _r,X as kr,N as wr}from"./vendor-icons-DMd9RGvJ.js";function L({title:e,description:t,children:r}){return s.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded-lg p-6 bg-azure-surface/50 dark:bg-matrix-base/50",children:[s.jsxs("div",{className:"mb-4",children:[s.jsx("h3",{className:"text-lg font-medium text-azure-text-primary dark:text-matrix-highlight",children:e}),t&&s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mt-1",children:t})]}),s.jsx("div",{className:"space-y-4",children:r})]})}function p(e,t,r){function n(l,d){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:d,constr:a,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,d);const m=a.prototype,f=Object.keys(m);for(let u=0;u<f.length;u++){const h=f[u];h in l||(l[h]=m[h].bind(l))}}const o=r?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function a(l){var d;const m=r?.Parent?new i:this;n(m,l),(d=m._zod).deferred??(d.deferred=[]);for(const f of m._zod.deferred)f();return m}return Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:l=>r?.Parent&&l instanceof r.Parent?!0:l?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}class ye extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class $t extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Ot={};function ie(e){return Ot}function Ct(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function Ke(e,t){return typeof t=="bigint"?t.toString():t}function Re(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ge(e){return e==null}function qe(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function zr(e,t){const r=(e.toString().split(".")[1]||"").length,n=t.toString();let o=(n.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(n)){const d=n.match(/\d?e-(\d?)/);d?.[1]&&(o=Number.parseInt(d[1]))}const i=r>o?r:o,a=Number.parseInt(e.toFixed(i).replace(".","")),l=Number.parseInt(t.toFixed(i).replace(".",""));return a%l/10**i}const at=Symbol("evaluating");function z(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==at)return n===void 0&&(n=at,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function pe(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function le(...e){const t={};for(const r of e){const n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function it(e){return JSON.stringify(e)}function jr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Zt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ne(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Sr=Re(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function xe(e){if(Ne(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(Ne(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function At(e){return xe(e)?{...e}:Array.isArray(e)?[...e]:e}const Nr=new Set(["string","number","symbol"]);function _e(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ce(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function b(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function $r(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Or={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Cr(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=le(e._zod.def,{get shape(){const a={};for(const l in t){if(!(l in r.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(a[l]=r.shape[l])}return pe(this,"shape",a),a},checks:[]});return ce(e,i)}function Zr(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=le(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const l in t){if(!(l in r.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&delete a[l]}return pe(this,"shape",a),a},checks:[]});return ce(e,i)}function Ar(e,t){if(!xe(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const i=e._zod.def.shape;for(const a in t)if(Object.getOwnPropertyDescriptor(i,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=le(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return pe(this,"shape",i),i}});return ce(e,o)}function Tr(e,t){if(!xe(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=le(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return pe(this,"shape",n),n}});return ce(e,r)}function Er(e,t){const r=le(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return pe(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return ce(e,r)}function Ir(e,t,r){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const a=le(t._zod.def,{get shape(){const l=t._zod.def.shape,d={...l};if(r)for(const m in r){if(!(m in l))throw new Error(`Unrecognized key: "${m}"`);r[m]&&(d[m]=e?new e({type:"optional",innerType:l[m]}):l[m])}else for(const m in l)d[m]=e?new e({type:"optional",innerType:l[m]}):l[m];return pe(this,"shape",d),d},checks:[]});return ce(t,a)}function Pr(e,t,r){const n=le(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(r)for(const a in r){if(!(a in i))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(i[a]=new e({type:"nonoptional",innerType:o[a]}))}else for(const a in o)i[a]=new e({type:"nonoptional",innerType:o[a]});return pe(this,"shape",i),i}});return ce(t,n)}function be(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function ve(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Ce(e){return typeof e=="string"?e:e?.message}function se(e,t,r){const n={...e,path:e.path??[]};if(!e.message){const o=Ce(e.inst?._zod.def?.error?.(e))??Ce(t?.error?.(e))??Ce(r.customError?.(e))??Ce(r.localeError?.(e))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function Ye(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function $e(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const Tt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ke,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Et=p("$ZodError",Tt),It=p("$ZodError",Tt,{Parent:Error});function Rr(e,t=r=>r.message){const r={},n=[];for(const o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Dr(e,t=r=>r.message){const r={_errors:[]},n=o=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a}));else if(i.code==="invalid_key")n({issues:i.issues});else if(i.code==="invalid_element")n({issues:i.issues});else if(i.path.length===0)r._errors.push(t(i));else{let a=r,l=0;for(;l<i.path.length;){const d=i.path[l];l===i.path.length-1?(a[d]=a[d]||{_errors:[]},a[d]._errors.push(t(i))):a[d]=a[d]||{_errors:[]},a=a[d],l++}}};return n(e),r}const Xe=e=>(t,r,n,o)=>{const i=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise)throw new ye;if(a.issues.length){const l=new(o?.Err??e)(a.issues.map(d=>se(d,i,ie())));throw Zt(l,o?.callee),l}return a.value},He=e=>async(t,r,n,o)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const l=new(o?.Err??e)(a.issues.map(d=>se(d,i,ie())));throw Zt(l,o?.callee),l}return a.value},De=e=>(t,r,n)=>{const o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new ye;return i.issues.length?{success:!1,error:new(e??Et)(i.issues.map(a=>se(a,o,ie())))}:{success:!0,data:i.value}},Mr=De(It),Me=e=>async(t,r,n)=>{const o=n?Object.assign(n,{async:!0}):{async:!0};let i=t._zod.run({value:r,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>se(a,o,ie())))}:{success:!0,data:i.value}},Ur=Me(It),Jr=e=>(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Xe(e)(t,r,o)},Lr=e=>(t,r,n)=>Xe(e)(t,r,n),Fr=e=>async(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return He(e)(t,r,o)},Br=e=>async(t,r,n)=>He(e)(t,r,n),Kr=e=>(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return De(e)(t,r,o)},Vr=e=>(t,r,n)=>De(e)(t,r,n),Wr=e=>async(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Me(e)(t,r,o)},Gr=e=>async(t,r,n)=>Me(e)(t,r,n),qr=/^[cC][^\s-]{8,}$/,Yr=/^[0-9a-z]+$/,Xr=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Hr=/^[0-9a-vA-V]{20}$/,Qr=/^[A-Za-z0-9]{27}$/,en=/^[a-zA-Z0-9_-]{21}$/,tn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,rn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,st=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,nn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,on="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function an(){return new RegExp(on,"u")}const sn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ln=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,cn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,un=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,dn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Pt=/^[A-Za-z0-9_-]*$/,mn=/^\+[1-9]\d{6,14}$/,Rt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",pn=new RegExp(`^${Rt}$`);function Dt(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function fn(e){return new RegExp(`^${Dt(e)}$`)}function hn(e){const t=Dt({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Rt}T(?:${n})$`)}const gn=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},bn=/^-?\d+$/,Mt=/^-?\d+(?:\.\d+)?$/,vn=/^(?:true|false)$/i,yn=/^[^A-Z]*$/,xn=/^[^a-z]*$/,B=p("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Ut={number:"number",bigint:"bigint",object:"date"},Jt=p("$ZodCheckLessThan",(e,t)=>{B.init(e,t);const r=Ut[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Lt=p("$ZodCheckGreaterThan",(e,t)=>{B.init(e,t);const r=Ut[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),_n=p("$ZodCheckMultipleOf",(e,t)=>{B.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):zr(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),kn=p("$ZodCheckNumberFormat",(e,t)=>{B.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[o,i]=Or[t.format];e._zod.onattach.push(a=>{const l=a._zod.bag;l.format=t.format,l.minimum=o,l.maximum=i,r&&(l.pattern=bn)}),e._zod.check=a=>{const l=a.value;if(r){if(!Number.isInteger(l)){a.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?a.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):a.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}l<o&&a.issues.push({origin:"number",input:l,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),l>i&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),wn=p("$ZodCheckMaxLength",(e,t)=>{var r;B.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!Ge(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const o=n.value;if(o.length<=t.maximum)return;const a=Ye(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),zn=p("$ZodCheckMinLength",(e,t)=>{var r;B.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!Ge(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const o=n.value;if(o.length>=t.minimum)return;const a=Ye(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),jn=p("$ZodCheckLengthEquals",(e,t)=>{var r;B.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!Ge(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{const o=n.value,i=o.length;if(i===t.length)return;const a=Ye(o),l=i>t.length;n.issues.push({origin:a,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ue=p("$ZodCheckStringFormat",(e,t)=>{var r,n;B.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Sn=p("$ZodCheckRegex",(e,t)=>{Ue.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Nn=p("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=yn),Ue.init(e,t)}),$n=p("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=xn),Ue.init(e,t)}),On=p("$ZodCheckIncludes",(e,t)=>{B.init(e,t);const r=_e(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Cn=p("$ZodCheckStartsWith",(e,t)=>{B.init(e,t);const r=new RegExp(`^${_e(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Zn=p("$ZodCheckEndsWith",(e,t)=>{B.init(e,t);const r=new RegExp(`.*${_e(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),An=p("$ZodCheckOverwrite",(e,t)=>{B.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class Tn{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(`
|
|
2
|
-
`).filter(a=>a),o=Math.min(...n.map(a=>a.length-a.trimStart().length)),i=n.map(a=>a.slice(o)).map(a=>" ".repeat(this.indent*2)+a);for(const a of i)this.content.push(a)}compile(){const t=Function,r=this?.args,o=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...r,o.join(`
|
|
3
|
-
`))}}const En={major:4,minor:3,patch:6},Z=p("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=En;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const o of n)for(const i of o._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,l,d)=>{let m=be(a),f;for(const u of l){if(u._zod.def.when){if(!u._zod.def.when(a))continue}else if(m)continue;const h=a.issues.length,g=u._zod.check(a);if(g instanceof Promise&&d?.async===!1)throw new ye;if(f||g instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await g,a.issues.length!==h&&(m||(m=be(a,h)))});else{if(a.issues.length===h)continue;m||(m=be(a,h))}}return f?f.then(()=>a):a},i=(a,l,d)=>{if(be(a))return a.aborted=!0,a;const m=o(l,n,d);if(m instanceof Promise){if(d.async===!1)throw new ye;return m.then(f=>e._zod.parse(f,d))}return e._zod.parse(m,d)};e._zod.run=(a,l)=>{if(l.skipChecks)return e._zod.parse(a,l);if(l.direction==="backward"){const m=e._zod.parse({value:a.value,issues:[]},{...l,skipChecks:!0});return m instanceof Promise?m.then(f=>i(f,a,l)):i(m,a,l)}const d=e._zod.parse(a,l);if(d instanceof Promise){if(l.async===!1)throw new ye;return d.then(m=>o(m,n,l))}return o(d,n,l)}}z(e,"~standard",()=>({validate:o=>{try{const i=Mr(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return Ur(e,o).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),Qe=p("$ZodString",(e,t)=>{Z.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??gn(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),O=p("$ZodStringFormat",(e,t)=>{Ue.init(e,t),Qe.init(e,t)}),In=p("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=rn),O.init(e,t)}),Pn=p("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=st(n))}else t.pattern??(t.pattern=st());O.init(e,t)}),Rn=p("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=nn),O.init(e,t)}),Dn=p("$ZodURL",(e,t)=>{O.init(e,t),e._zod.check=r=>{try{const n=r.value.trim(),o=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=o.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Mn=p("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=an()),O.init(e,t)}),Un=p("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=en),O.init(e,t)}),Jn=p("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=qr),O.init(e,t)}),Ln=p("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Yr),O.init(e,t)}),Fn=p("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Xr),O.init(e,t)}),Bn=p("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Hr),O.init(e,t)}),Kn=p("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Qr),O.init(e,t)}),Vn=p("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=hn(t)),O.init(e,t)}),Wn=p("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=pn),O.init(e,t)}),Gn=p("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=fn(t)),O.init(e,t)}),qn=p("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=tn),O.init(e,t)}),Yn=p("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=sn),O.init(e,t),e._zod.bag.format="ipv4"}),Xn=p("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ln),O.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Hn=p("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=cn),O.init(e,t)}),Qn=p("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=un),O.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[o,i]=n;if(!i)throw new Error;const a=Number(i);if(`${a}`!==i)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Ft(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const eo=p("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=dn),O.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{Ft(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function to(e){if(!Pt.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ft(r)}const ro=p("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Pt),O.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{to(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),no=p("$ZodE164",(e,t)=>{t.pattern??(t.pattern=mn),O.init(e,t)});function oo(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const ao=p("$ZodJWT",(e,t)=>{O.init(e,t),e._zod.check=r=>{oo(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Bt=p("$ZodNumber",(e,t)=>{Z.init(e,t),e._zod.pattern=e._zod.bag.pattern??Mt,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}const o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;const i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}}),io=p("$ZodNumberFormat",(e,t)=>{kn.init(e,t),Bt.init(e,t)}),so=p("$ZodBoolean",(e,t)=>{Z.init(e,t),e._zod.pattern=vn,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}const o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),lo=p("$ZodUnknown",(e,t)=>{Z.init(e,t),e._zod.parse=r=>r}),co=p("$ZodNever",(e,t)=>{Z.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function lt(e,t,r){e.issues.length&&t.issues.push(...ve(r,e.issues)),t.value[r]=e.value}const uo=p("$ZodArray",(e,t)=>{Z.init(e,t),e._zod.parse=(r,n)=>{const o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);const i=[];for(let a=0;a<o.length;a++){const l=o[a],d=t.element._zod.run({value:l,issues:[]},n);d instanceof Promise?i.push(d.then(m=>lt(m,r,a))):lt(d,r,a)}return i.length?Promise.all(i).then(()=>r):r}});function Ee(e,t,r,n,o){if(e.issues.length){if(o&&!(r in n))return;t.issues.push(...ve(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function Kt(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const r=$r(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Vt(e,t,r,n,o,i){const a=[],l=o.keySet,d=o.catchall._zod,m=d.def.type,f=d.optout==="optional";for(const u in t){if(l.has(u))continue;if(m==="never"){a.push(u);continue}const h=d.run({value:t[u],issues:[]},n);h instanceof Promise?e.push(h.then(g=>Ee(g,r,u,t,f))):Ee(h,r,u,t,f)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}const mo=p("$ZodObject",(e,t)=>{if(Z.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const d={...l};return Object.defineProperty(t,"shape",{value:d}),d}})}const n=Re(()=>Kt(t));z(e._zod,"propValues",()=>{const l=t.shape,d={};for(const m in l){const f=l[m]._zod;if(f.values){d[m]??(d[m]=new Set);for(const u of f.values)d[m].add(u)}}return d});const o=Ne,i=t.catchall;let a;e._zod.parse=(l,d)=>{a??(a=n.value);const m=l.value;if(!o(m))return l.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),l;l.value={};const f=[],u=a.shape;for(const h of a.keys){const g=u[h],$=g._zod.optout==="optional",v=g._zod.run({value:m[h],issues:[]},d);v instanceof Promise?f.push(v.then(Q=>Ee(Q,l,h,m,$))):Ee(v,l,h,m,$)}return i?Vt(f,m,l,d,n.value,e):f.length?Promise.all(f).then(()=>l):l}}),po=p("$ZodObjectJIT",(e,t)=>{mo.init(e,t);const r=e._zod.parse,n=Re(()=>Kt(t)),o=h=>{const g=new Tn(["shape","payload","ctx"]),$=n.value,v=_=>{const D=it(_);return`shape[${D}]._zod.run({ value: input[${D}], issues: [] }, ctx)`};g.write("const input = payload.value;");const Q=Object.create(null);let C=0;for(const _ of $.keys)Q[_]=`key_${C++}`;g.write("const newResult = {};");for(const _ of $.keys){const D=Q[_],E=it(_),re=h[_]?._zod?.optout==="optional";g.write(`const ${D} = ${v(_)};`),re?g.write(`
|
|
4
|
-
if (${D}.issues.length) {
|
|
5
|
-
if (${E} in input) {
|
|
6
|
-
payload.issues = payload.issues.concat(${D}.issues.map(iss => ({
|
|
7
|
-
...iss,
|
|
8
|
-
path: iss.path ? [${E}, ...iss.path] : [${E}]
|
|
9
|
-
})));
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (${D}.value === undefined) {
|
|
14
|
-
if (${E} in input) {
|
|
15
|
-
newResult[${E}] = undefined;
|
|
16
|
-
}
|
|
17
|
-
} else {
|
|
18
|
-
newResult[${E}] = ${D}.value;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
`):g.write(`
|
|
22
|
-
if (${D}.issues.length) {
|
|
23
|
-
payload.issues = payload.issues.concat(${D}.issues.map(iss => ({
|
|
24
|
-
...iss,
|
|
25
|
-
path: iss.path ? [${E}, ...iss.path] : [${E}]
|
|
26
|
-
})));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (${D}.value === undefined) {
|
|
30
|
-
if (${E} in input) {
|
|
31
|
-
newResult[${E}] = undefined;
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
newResult[${E}] = ${D}.value;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
`)}g.write("payload.value = newResult;"),g.write("return payload;");const fe=g.compile();return(_,D)=>fe(h,_,D)};let i;const a=Ne,l=!Ot.jitless,m=l&&Sr.value,f=t.catchall;let u;e._zod.parse=(h,g)=>{u??(u=n.value);const $=h.value;return a($)?l&&m&&g?.async===!1&&g.jitless!==!0?(i||(i=o(t.shape)),h=i(h,g),f?Vt([],$,h,g,u,e):h):r(h,g):(h.issues.push({expected:"object",code:"invalid_type",input:$,inst:e}),h)}});function ct(e,t,r,n){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!be(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(a=>se(a,n,ie())))}),t)}const Wt=p("$ZodUnion",(e,t)=>{Z.init(e,t),z(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),z(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),z(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),z(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>qe(i.source)).join("|")})$`)}});const r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(r)return n(o,i);let a=!1;const l=[];for(const d of t.options){const m=d._zod.run({value:o.value,issues:[]},i);if(m instanceof Promise)l.push(m),a=!0;else{if(m.issues.length===0)return m;l.push(m)}}return a?Promise.all(l).then(d=>ct(d,o,e,i)):ct(l,o,e,i)}}),fo=p("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Wt.init(e,t);const r=e._zod.parse;z(e._zod,"propValues",()=>{const o={};for(const i of t.options){const a=i._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[l,d]of Object.entries(a)){o[l]||(o[l]=new Set);for(const m of d)o[l].add(m)}}return o});const n=Re(()=>{const o=t.options,i=new Map;for(const a of o){const l=a._zod.propValues?.[t.discriminator];if(!l||l.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const d of l){if(i.has(d))throw new Error(`Duplicate discriminator value "${String(d)}"`);i.set(d,a)}}return i});e._zod.parse=(o,i)=>{const a=o.value;if(!Ne(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;const l=n.value.get(a?.[t.discriminator]);return l?l._zod.run(o,i):t.unionFallback?r(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),o)}}),ho=p("$ZodIntersection",(e,t)=>{Z.init(e,t),e._zod.parse=(r,n)=>{const o=r.value,i=t.left._zod.run({value:o,issues:[]},n),a=t.right._zod.run({value:o,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([d,m])=>ut(r,d,m)):ut(r,i,a)}});function Ve(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(xe(e)&&xe(t)){const r=Object.keys(t),n=Object.keys(e).filter(i=>r.indexOf(i)!==-1),o={...e,...t};for(const i of n){const a=Ve(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};o[i]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const o=e[n],i=t[n],a=Ve(o,i);if(!a.valid)return{valid:!1,mergeErrorPath:[n,...a.mergeErrorPath]};r.push(a.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function ut(e,t,r){const n=new Map;let o;for(const l of t.issues)if(l.code==="unrecognized_keys"){o??(o=l);for(const d of l.keys)n.has(d)||n.set(d,{}),n.get(d).l=!0}else e.issues.push(l);for(const l of r.issues)if(l.code==="unrecognized_keys")for(const d of l.keys)n.has(d)||n.set(d,{}),n.get(d).r=!0;else e.issues.push(l);const i=[...n].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(i.length&&o&&e.issues.push({...o,keys:i}),be(e))return e;const a=Ve(t.value,r.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}const go=p("$ZodRecord",(e,t)=>{Z.init(e,t),e._zod.parse=(r,n)=>{const o=r.value;if(!xe(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;const i=[],a=t.keyType._zod.values;if(a){r.value={};const l=new Set;for(const m of a)if(typeof m=="string"||typeof m=="number"||typeof m=="symbol"){l.add(typeof m=="number"?m.toString():m);const f=t.valueType._zod.run({value:o[m],issues:[]},n);f instanceof Promise?i.push(f.then(u=>{u.issues.length&&r.issues.push(...ve(m,u.issues)),r.value[m]=u.value})):(f.issues.length&&r.issues.push(...ve(m,f.issues)),r.value[m]=f.value)}let d;for(const m in o)l.has(m)||(d=d??[],d.push(m));d&&d.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:d})}else{r.value={};for(const l of Reflect.ownKeys(o)){if(l==="__proto__")continue;let d=t.keyType._zod.run({value:l,issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&Mt.test(l)&&d.issues.length){const u=t.keyType._zod.run({value:Number(l),issues:[]},n);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");u.issues.length===0&&(d=u)}if(d.issues.length){t.mode==="loose"?r.value[l]=o[l]:r.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(u=>se(u,n,ie())),input:l,path:[l],inst:e});continue}const f=t.valueType._zod.run({value:o[l],issues:[]},n);f instanceof Promise?i.push(f.then(u=>{u.issues.length&&r.issues.push(...ve(l,u.issues)),r.value[d.value]=u.value})):(f.issues.length&&r.issues.push(...ve(l,f.issues)),r.value[d.value]=f.value)}}return i.length?Promise.all(i).then(()=>r):r}}),bo=p("$ZodEnum",(e,t)=>{Z.init(e,t);const r=Ct(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>Nr.has(typeof o)).map(o=>typeof o=="string"?_e(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const a=o.value;return n.has(a)||o.issues.push({code:"invalid_value",values:r,input:a,inst:e}),o}}),vo=p("$ZodLiteral",(e,t)=>{if(Z.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?_e(n):n?_e(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,o)=>{const i=n.value;return r.has(i)||n.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),n}}),yo=p("$ZodTransform",(e,t)=>{Z.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new $t(e.constructor.name);const o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(a=>(r.value=a,r));if(o instanceof Promise)throw new ye;return r.value=o,r}});function dt(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Gt=p("$ZodOptional",(e,t)=>{Z.init(e,t),e._zod.optin="optional",e._zod.optout="optional",z(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),z(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${qe(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>dt(i,r.value)):dt(o,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),xo=p("$ZodExactOptional",(e,t)=>{Gt.init(e,t),z(e._zod,"values",()=>t.innerType._zod.values),z(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),_o=p("$ZodNullable",(e,t)=>{Z.init(e,t),z(e._zod,"optin",()=>t.innerType._zod.optin),z(e._zod,"optout",()=>t.innerType._zod.optout),z(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${qe(r.source)}|null)$`):void 0}),z(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),ko=p("$ZodDefault",(e,t)=>{Z.init(e,t),e._zod.optin="optional",z(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>mt(i,t)):mt(o,t)}});function mt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const wo=p("$ZodPrefault",(e,t)=>{Z.init(e,t),e._zod.optin="optional",z(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),zo=p("$ZodNonOptional",(e,t)=>{Z.init(e,t),z(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>pt(i,e)):pt(o,e)}});function pt(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const jo=p("$ZodCatch",(e,t)=>{Z.init(e,t),z(e._zod,"optin",()=>t.innerType._zod.optin),z(e._zod,"optout",()=>t.innerType._zod.optout),z(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(a=>se(a,n,ie()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(i=>se(i,n,ie()))},input:r.value}),r.issues=[]),r)}}),So=p("$ZodPipe",(e,t)=>{Z.init(e,t),z(e._zod,"values",()=>t.in._zod.values),z(e._zod,"optin",()=>t.in._zod.optin),z(e._zod,"optout",()=>t.out._zod.optout),z(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const i=t.out._zod.run(r,n);return i instanceof Promise?i.then(a=>Ze(a,t.in,n)):Ze(i,t.in,n)}const o=t.in._zod.run(r,n);return o instanceof Promise?o.then(i=>Ze(i,t.out,n)):Ze(o,t.out,n)}});function Ze(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}const No=p("$ZodReadonly",(e,t)=>{Z.init(e,t),z(e._zod,"propValues",()=>t.innerType._zod.propValues),z(e._zod,"values",()=>t.innerType._zod.values),z(e._zod,"optin",()=>t.innerType?._zod?.optin),z(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(ft):ft(o)}});function ft(e){return e.value=Object.freeze(e.value),e}const $o=p("$ZodCustom",(e,t)=>{B.init(e,t),Z.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(i=>ht(i,r,n,e));ht(o,r,n,e)}});function ht(e,t,r,n){if(!e){const o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push($e(o))}}var gt;class Oo{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){const n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){const r=t._zod.parent;if(r){const n={...this.get(r)??{}};delete n.id;const o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Co(){return new Oo}(gt=globalThis).__zod_globalRegistry??(gt.__zod_globalRegistry=Co());const Se=globalThis.__zod_globalRegistry;function Zo(e,t){return new e({type:"string",...b(t)})}function Ao(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...b(t)})}function bt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...b(t)})}function To(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...b(t)})}function Eo(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...b(t)})}function Io(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...b(t)})}function Po(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...b(t)})}function Ro(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...b(t)})}function Do(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...b(t)})}function Mo(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...b(t)})}function Uo(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...b(t)})}function Jo(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...b(t)})}function Lo(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...b(t)})}function Fo(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...b(t)})}function Bo(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...b(t)})}function Ko(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...b(t)})}function Vo(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...b(t)})}function Wo(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...b(t)})}function Go(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...b(t)})}function qo(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...b(t)})}function Yo(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...b(t)})}function Xo(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...b(t)})}function Ho(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...b(t)})}function Qo(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...b(t)})}function ea(e,t){return new e({type:"string",format:"date",check:"string_format",...b(t)})}function ta(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...b(t)})}function ra(e,t){return new e({type:"string",format:"duration",check:"string_format",...b(t)})}function na(e,t){return new e({type:"number",checks:[],...b(t)})}function oa(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...b(t)})}function aa(e,t){return new e({type:"boolean",...b(t)})}function ia(e){return new e({type:"unknown"})}function sa(e,t){return new e({type:"never",...b(t)})}function vt(e,t){return new Jt({check:"less_than",...b(t),value:e,inclusive:!1})}function Fe(e,t){return new Jt({check:"less_than",...b(t),value:e,inclusive:!0})}function yt(e,t){return new Lt({check:"greater_than",...b(t),value:e,inclusive:!1})}function Be(e,t){return new Lt({check:"greater_than",...b(t),value:e,inclusive:!0})}function xt(e,t){return new _n({check:"multiple_of",...b(t),value:e})}function qt(e,t){return new wn({check:"max_length",...b(t),maximum:e})}function Ie(e,t){return new zn({check:"min_length",...b(t),minimum:e})}function Yt(e,t){return new jn({check:"length_equals",...b(t),length:e})}function la(e,t){return new Sn({check:"string_format",format:"regex",...b(t),pattern:e})}function ca(e){return new Nn({check:"string_format",format:"lowercase",...b(e)})}function ua(e){return new $n({check:"string_format",format:"uppercase",...b(e)})}function da(e,t){return new On({check:"string_format",format:"includes",...b(t),includes:e})}function ma(e,t){return new Cn({check:"string_format",format:"starts_with",...b(t),prefix:e})}function pa(e,t){return new Zn({check:"string_format",format:"ends_with",...b(t),suffix:e})}function ke(e){return new An({check:"overwrite",tx:e})}function fa(e){return ke(t=>t.normalize(e))}function ha(){return ke(e=>e.trim())}function ga(){return ke(e=>e.toLowerCase())}function ba(){return ke(e=>e.toUpperCase())}function va(){return ke(e=>jr(e))}function ya(e,t,r){return new e({type:"array",element:t,...b(r)})}function xa(e,t,r){return new e({type:"custom",check:"custom",fn:t,...b(r)})}function _a(e){const t=ka(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push($e(n,r.value,t._zod.def));else{const o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),r.issues.push($e(o))}},e(r.value,r)));return t}function ka(e,t){const r=new B({check:"custom",...b(t)});return r._zod.check=e,r}function Xt(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Se,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function R(e,t,r={path:[],schemaPath:[]}){var n;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a);const l=e._zod.toJSONSchema?.();if(l)a.schema=l;else{const f={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,f);else{const h=a.schema,g=t.processors[o.type];if(!g)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);g(e,t,h,f)}const u=e._zod.parent;u&&(a.ref||(a.ref=u),R(u,t,f),t.seen.get(u).isParent=!0)}const d=t.metadataRegistry.get(e);return d&&Object.assign(a.schema,d),t.io==="input"&&F(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Ht(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const a of e.seen.entries()){const l=e.metadataRegistry.get(a[0])?.id;if(l){const d=n.get(l);if(d&&d!==a[0])throw new Error(`Duplicate schema id "${l}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(l,a[0])}}const o=a=>{const l=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const u=e.external.registry.get(a[0])?.id,h=e.external.uri??($=>$);if(u)return{ref:h(u)};const g=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=g,{defId:g,ref:`${h("__shared")}#/${l}/${g}`}}if(a[1]===r)return{ref:"#"};const m=`#/${l}/`,f=a[1].schema.id??`__schema${e.counter++}`;return{defId:f,ref:m+f}},i=a=>{if(a[1].schema.$ref)return;const l=a[1],{ref:d,defId:m}=o(a);l.def={...l.schema},m&&(l.defId=m);const f=l.schema;for(const u in f)delete f[u];f.$ref=d};if(e.cycles==="throw")for(const a of e.seen.entries()){const l=a[1];if(l.cycle)throw new Error(`Cycle detected: #/${l.cycle?.join("/")}/<root>
|
|
38
|
-
|
|
39
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const a of e.seen.entries()){const l=a[1];if(t===a[0]){i(a);continue}if(e.external){const m=e.external.registry.get(a[0])?.id;if(t!==a[0]&&m){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(l.cycle){i(a);continue}if(l.count>1&&e.reused==="ref"){i(a);continue}}}function Qt(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=a=>{const l=e.seen.get(a);if(l.ref===null)return;const d=l.def??l.schema,m={...d},f=l.ref;if(l.ref=null,f){n(f);const h=e.seen.get(f),g=h.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(d.allOf=d.allOf??[],d.allOf.push(g)):Object.assign(d,g),Object.assign(d,m),a._zod.parent===f)for(const v in d)v==="$ref"||v==="allOf"||v in m||delete d[v];if(g.$ref&&h.def)for(const v in d)v==="$ref"||v==="allOf"||v in h.def&&JSON.stringify(d[v])===JSON.stringify(h.def[v])&&delete d[v]}const u=a._zod.parent;if(u&&u!==f){n(u);const h=e.seen.get(u);if(h?.schema.$ref&&(d.$ref=h.schema.$ref,h.def))for(const g in d)g==="$ref"||g==="allOf"||g in h.def&&JSON.stringify(d[g])===JSON.stringify(h.def[g])&&delete d[g]}e.override({zodSchema:a,jsonSchema:d,path:l.path??[]})};for(const a of[...e.seen.entries()].reverse())n(a[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Object.assign(o,r.def??r.schema);const i=e.external?.defs??{};for(const a of e.seen.entries()){const l=a[1];l.def&&l.defId&&(i[l.defId]=l.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Pe(t,"input",e.processors),output:Pe(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function F(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return F(n.element,r);if(n.type==="set")return F(n.valueType,r);if(n.type==="lazy")return F(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return F(n.innerType,r);if(n.type==="intersection")return F(n.left,r)||F(n.right,r);if(n.type==="record"||n.type==="map")return F(n.keyType,r)||F(n.valueType,r);if(n.type==="pipe")return F(n.in,r)||F(n.out,r);if(n.type==="object"){for(const o in n.shape)if(F(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(const o of n.options)if(F(o,r))return!0;return!1}if(n.type==="tuple"){for(const o of n.items)if(F(o,r))return!0;return!!(n.rest&&F(n.rest,r))}return!1}const wa=(e,t={})=>r=>{const n=Xt({...r,processors:t});return R(e,n),Ht(n,e),Qt(n,e)},Pe=(e,t,r={})=>n=>{const{libraryOptions:o,target:i}=n??{},a=Xt({...o??{},target:i,io:t,processors:r});return R(e,a),Ht(a,e),Qt(a,e)},za={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ja=(e,t,r,n)=>{const o=r;o.type="string";const{minimum:i,maximum:a,format:l,patterns:d,contentEncoding:m}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof a=="number"&&(o.maxLength=a),l&&(o.format=za[l]??l,o.format===""&&delete o.format,l==="time"&&delete o.format),m&&(o.contentEncoding=m),d&&d.size>0){const f=[...d];f.length===1?o.pattern=f[0].source:f.length>1&&(o.allOf=[...f.map(u=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:u.source}))])}},Sa=(e,t,r,n)=>{const o=r,{minimum:i,maximum:a,format:l,multipleOf:d,exclusiveMaximum:m,exclusiveMinimum:f}=e._zod.bag;typeof l=="string"&&l.includes("int")?o.type="integer":o.type="number",typeof f=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=f,o.exclusiveMinimum=!0):o.exclusiveMinimum=f),typeof i=="number"&&(o.minimum=i,typeof f=="number"&&t.target!=="draft-04"&&(f>=i?delete o.minimum:delete o.exclusiveMinimum)),typeof m=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=m,o.exclusiveMaximum=!0):o.exclusiveMaximum=m),typeof a=="number"&&(o.maximum=a,typeof m=="number"&&t.target!=="draft-04"&&(m<=a?delete o.maximum:delete o.exclusiveMaximum)),typeof d=="number"&&(o.multipleOf=d)},Na=(e,t,r,n)=>{r.type="boolean"},$a=(e,t,r,n)=>{r.not={}},Oa=(e,t,r,n)=>{},Ca=(e,t,r,n)=>{const o=e._zod.def,i=Ct(o.entries);i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),r.enum=i},Za=(e,t,r,n)=>{const o=e._zod.def,i=[];for(const a of o.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){const a=i[0];r.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[a]:r.const=a}else i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),i.every(a=>typeof a=="boolean")&&(r.type="boolean"),i.every(a=>a===null)&&(r.type="null"),r.enum=i},Aa=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Ta=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ea=(e,t,r,n)=>{const o=r,i=e._zod.def,{minimum:a,maximum:l}=e._zod.bag;typeof a=="number"&&(o.minItems=a),typeof l=="number"&&(o.maxItems=l),o.type="array",o.items=R(i.element,t,{...n,path:[...n.path,"items"]})},Ia=(e,t,r,n)=>{const o=r,i=e._zod.def;o.type="object",o.properties={};const a=i.shape;for(const m in a)o.properties[m]=R(a[m],t,{...n,path:[...n.path,"properties",m]});const l=new Set(Object.keys(a)),d=new Set([...l].filter(m=>{const f=i.shape[m]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));d.size>0&&(o.required=Array.from(d)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=R(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Pa=(e,t,r,n)=>{const o=e._zod.def,i=o.inclusive===!1,a=o.options.map((l,d)=>R(l,t,{...n,path:[...n.path,i?"oneOf":"anyOf",d]}));i?r.oneOf=a:r.anyOf=a},Ra=(e,t,r,n)=>{const o=e._zod.def,i=R(o.left,t,{...n,path:[...n.path,"allOf",0]}),a=R(o.right,t,{...n,path:[...n.path,"allOf",1]}),l=m=>"allOf"in m&&Object.keys(m).length===1,d=[...l(i)?i.allOf:[i],...l(a)?a.allOf:[a]];r.allOf=d},Da=(e,t,r,n)=>{const o=r,i=e._zod.def;o.type="object";const a=i.keyType,d=a._zod.bag?.patterns;if(i.mode==="loose"&&d&&d.size>0){const f=R(i.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(const u of d)o.patternProperties[u.source]=f}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=R(i.keyType,t,{...n,path:[...n.path,"propertyNames"]})),o.additionalProperties=R(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]});const m=a._zod.values;if(m){const f=[...m].filter(u=>typeof u=="string"||typeof u=="number");f.length>0&&(o.required=f)}},Ma=(e,t,r,n)=>{const o=e._zod.def,i=R(o.innerType,t,n),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},Ua=(e,t,r,n)=>{const o=e._zod.def;R(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType},Ja=(e,t,r,n)=>{const o=e._zod.def;R(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},La=(e,t,r,n)=>{const o=e._zod.def;R(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Fa=(e,t,r,n)=>{const o=e._zod.def;R(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=a},Ba=(e,t,r,n)=>{const o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;R(i,t,n);const a=t.seen.get(e);a.ref=i},Ka=(e,t,r,n)=>{const o=e._zod.def;R(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0},er=(e,t,r,n)=>{const o=e._zod.def;R(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType},Va=p("ZodISODateTime",(e,t)=>{Vn.init(e,t),T.init(e,t)});function Wa(e){return Qo(Va,e)}const Ga=p("ZodISODate",(e,t)=>{Wn.init(e,t),T.init(e,t)});function qa(e){return ea(Ga,e)}const Ya=p("ZodISOTime",(e,t)=>{Gn.init(e,t),T.init(e,t)});function Xa(e){return ta(Ya,e)}const Ha=p("ZodISODuration",(e,t)=>{qn.init(e,t),T.init(e,t)});function Qa(e){return ra(Ha,e)}const ei=(e,t)=>{Et.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Dr(e,r)},flatten:{value:r=>Rr(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,Ke,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,Ke,2)}},isEmpty:{get(){return e.issues.length===0}}})},W=p("ZodError",ei,{Parent:Error}),ti=Xe(W),ri=He(W),ni=De(W),oi=Me(W),ai=Jr(W),ii=Lr(W),si=Fr(W),li=Br(W),ci=Kr(W),ui=Vr(W),di=Wr(W),mi=Gr(W),A=p("ZodType",(e,t)=>(Z.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Pe(e,"input"),output:Pe(e,"output")}}),e.toJSONSchema=wa(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(le(t,{checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(r,n)=>ce(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>ti(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>ni(e,r,n),e.parseAsync=async(r,n)=>ri(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>oi(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>ai(e,r,n),e.decode=(r,n)=>ii(e,r,n),e.encodeAsync=async(r,n)=>si(e,r,n),e.decodeAsync=async(r,n)=>li(e,r,n),e.safeEncode=(r,n)=>ci(e,r,n),e.safeDecode=(r,n)=>ui(e,r,n),e.safeEncodeAsync=async(r,n)=>di(e,r,n),e.safeDecodeAsync=async(r,n)=>mi(e,r,n),e.refine=(r,n)=>e.check(is(r,n)),e.superRefine=r=>e.check(ss(r)),e.overwrite=r=>e.check(ke(r)),e.optional=()=>jt(e),e.exactOptional=()=>Wi(e),e.nullable=()=>St(e),e.nullish=()=>jt(St(e)),e.nonoptional=r=>Qi(e,r),e.array=()=>te(e),e.or=r=>or([e,r]),e.and=r=>Ji(e,r),e.transform=r=>Nt(e,Ki(r)),e.default=r=>Yi(e,r),e.prefault=r=>Hi(e,r),e.catch=r=>ts(e,r),e.pipe=r=>Nt(e,r),e.readonly=()=>os(e),e.describe=r=>{const n=e.clone();return Se.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return Se.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Se.get(e);const n=e.clone();return Se.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=r=>r(e),e)),tr=p("_ZodString",(e,t)=>{Qe.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,o,i)=>ja(e,n,o);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(la(...n)),e.includes=(...n)=>e.check(da(...n)),e.startsWith=(...n)=>e.check(ma(...n)),e.endsWith=(...n)=>e.check(pa(...n)),e.min=(...n)=>e.check(Ie(...n)),e.max=(...n)=>e.check(qt(...n)),e.length=(...n)=>e.check(Yt(...n)),e.nonempty=(...n)=>e.check(Ie(1,...n)),e.lowercase=n=>e.check(ca(n)),e.uppercase=n=>e.check(ua(n)),e.trim=()=>e.check(ha()),e.normalize=(...n)=>e.check(fa(...n)),e.toLowerCase=()=>e.check(ga()),e.toUpperCase=()=>e.check(ba()),e.slugify=()=>e.check(va())}),pi=p("ZodString",(e,t)=>{Qe.init(e,t),tr.init(e,t),e.email=r=>e.check(Ao(fi,r)),e.url=r=>e.check(Ro(hi,r)),e.jwt=r=>e.check(Ho(Ci,r)),e.emoji=r=>e.check(Do(gi,r)),e.guid=r=>e.check(bt(_t,r)),e.uuid=r=>e.check(To(Ae,r)),e.uuidv4=r=>e.check(Eo(Ae,r)),e.uuidv6=r=>e.check(Io(Ae,r)),e.uuidv7=r=>e.check(Po(Ae,r)),e.nanoid=r=>e.check(Mo(bi,r)),e.guid=r=>e.check(bt(_t,r)),e.cuid=r=>e.check(Uo(vi,r)),e.cuid2=r=>e.check(Jo(yi,r)),e.ulid=r=>e.check(Lo(xi,r)),e.base64=r=>e.check(qo(Ni,r)),e.base64url=r=>e.check(Yo($i,r)),e.xid=r=>e.check(Fo(_i,r)),e.ksuid=r=>e.check(Bo(ki,r)),e.ipv4=r=>e.check(Ko(wi,r)),e.ipv6=r=>e.check(Vo(zi,r)),e.cidrv4=r=>e.check(Wo(ji,r)),e.cidrv6=r=>e.check(Go(Si,r)),e.e164=r=>e.check(Xo(Oi,r)),e.datetime=r=>e.check(Wa(r)),e.date=r=>e.check(qa(r)),e.time=r=>e.check(Xa(r)),e.duration=r=>e.check(Qa(r))});function y(e){return Zo(pi,e)}const T=p("ZodStringFormat",(e,t)=>{O.init(e,t),tr.init(e,t)}),fi=p("ZodEmail",(e,t)=>{Rn.init(e,t),T.init(e,t)}),_t=p("ZodGUID",(e,t)=>{In.init(e,t),T.init(e,t)}),Ae=p("ZodUUID",(e,t)=>{Pn.init(e,t),T.init(e,t)}),hi=p("ZodURL",(e,t)=>{Dn.init(e,t),T.init(e,t)}),gi=p("ZodEmoji",(e,t)=>{Mn.init(e,t),T.init(e,t)}),bi=p("ZodNanoID",(e,t)=>{Un.init(e,t),T.init(e,t)}),vi=p("ZodCUID",(e,t)=>{Jn.init(e,t),T.init(e,t)}),yi=p("ZodCUID2",(e,t)=>{Ln.init(e,t),T.init(e,t)}),xi=p("ZodULID",(e,t)=>{Fn.init(e,t),T.init(e,t)}),_i=p("ZodXID",(e,t)=>{Bn.init(e,t),T.init(e,t)}),ki=p("ZodKSUID",(e,t)=>{Kn.init(e,t),T.init(e,t)}),wi=p("ZodIPv4",(e,t)=>{Yn.init(e,t),T.init(e,t)}),zi=p("ZodIPv6",(e,t)=>{Xn.init(e,t),T.init(e,t)}),ji=p("ZodCIDRv4",(e,t)=>{Hn.init(e,t),T.init(e,t)}),Si=p("ZodCIDRv6",(e,t)=>{Qn.init(e,t),T.init(e,t)}),Ni=p("ZodBase64",(e,t)=>{eo.init(e,t),T.init(e,t)}),$i=p("ZodBase64URL",(e,t)=>{ro.init(e,t),T.init(e,t)}),Oi=p("ZodE164",(e,t)=>{no.init(e,t),T.init(e,t)}),Ci=p("ZodJWT",(e,t)=>{ao.init(e,t),T.init(e,t)}),rr=p("ZodNumber",(e,t)=>{Bt.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Sa(e,n,o),e.gt=(n,o)=>e.check(yt(n,o)),e.gte=(n,o)=>e.check(Be(n,o)),e.min=(n,o)=>e.check(Be(n,o)),e.lt=(n,o)=>e.check(vt(n,o)),e.lte=(n,o)=>e.check(Fe(n,o)),e.max=(n,o)=>e.check(Fe(n,o)),e.int=n=>e.check(kt(n)),e.safe=n=>e.check(kt(n)),e.positive=n=>e.check(yt(0,n)),e.nonnegative=n=>e.check(Be(0,n)),e.negative=n=>e.check(vt(0,n)),e.nonpositive=n=>e.check(Fe(0,n)),e.multipleOf=(n,o)=>e.check(xt(n,o)),e.step=(n,o)=>e.check(xt(n,o)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function J(e){return na(rr,e)}const Zi=p("ZodNumberFormat",(e,t)=>{io.init(e,t),rr.init(e,t)});function kt(e){return oa(Zi,e)}const Ai=p("ZodBoolean",(e,t)=>{so.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Na(e,r,n)});function U(e){return aa(Ai,e)}const Ti=p("ZodUnknown",(e,t)=>{lo.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Oa()});function wt(){return ia(Ti)}const Ei=p("ZodNever",(e,t)=>{co.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$a(e,r,n)});function Ii(e){return sa(Ei,e)}const Pi=p("ZodArray",(e,t)=>{uo.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ea(e,r,n,o),e.element=t.element,e.min=(r,n)=>e.check(Ie(r,n)),e.nonempty=r=>e.check(Ie(1,r)),e.max=(r,n)=>e.check(qt(r,n)),e.length=(r,n)=>e.check(Yt(r,n)),e.unwrap=()=>e.element});function te(e,t){return ya(Pi,e,t)}const Ri=p("ZodObject",(e,t)=>{po.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ia(e,r,n,o),z(e,"shape",()=>t.shape),e.keyof=()=>ue(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:wt()}),e.loose=()=>e.clone({...e._zod.def,catchall:wt()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ii()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>Ar(e,r),e.safeExtend=r=>Tr(e,r),e.merge=r=>Er(e,r),e.pick=r=>Cr(e,r),e.omit=r=>Zr(e,r),e.partial=(...r)=>Ir(ar,e,r[0]),e.required=(...r)=>Pr(ir,e,r[0])});function P(e,t){const r={type:"object",shape:e??{},...b(t)};return new Ri(r)}const nr=p("ZodUnion",(e,t)=>{Wt.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Pa(e,r,n,o),e.options=t.options});function or(e,t){return new nr({type:"union",options:e,...b(t)})}const Di=p("ZodDiscriminatedUnion",(e,t)=>{nr.init(e,t),fo.init(e,t)});function Mi(e,t,r){return new Di({type:"union",options:t,discriminator:e,...b(r)})}const Ui=p("ZodIntersection",(e,t)=>{ho.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ra(e,r,n,o)});function Ji(e,t){return new Ui({type:"intersection",left:e,right:t})}const Li=p("ZodRecord",(e,t)=>{go.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Da(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function Te(e,t,r){return new Li({type:"record",keyType:e,valueType:t,...b(r)})}const We=p("ZodEnum",(e,t)=>{bo.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Ca(e,n,o),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{const i={};for(const a of n)if(r.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new We({...t,checks:[],...b(o),entries:i})},e.exclude=(n,o)=>{const i={...t.entries};for(const a of n)if(r.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new We({...t,checks:[],...b(o),entries:i})}});function ue(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new We({type:"enum",entries:r,...b(t)})}const Fi=p("ZodLiteral",(e,t)=>{vo.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Za(e,r,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function zt(e,t){return new Fi({type:"literal",values:Array.isArray(e)?e:[e],...b(t)})}const Bi=p("ZodTransform",(e,t)=>{yo.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ta(e,r),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new $t(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push($e(i,r.value,t));else{const a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=e),r.issues.push($e(a))}};const o=t.transform(r.value,r);return o instanceof Promise?o.then(i=>(r.value=i,r)):(r.value=o,r)}});function Ki(e){return new Bi({type:"transform",transform:e})}const ar=p("ZodOptional",(e,t)=>{Gt.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>er(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function jt(e){return new ar({type:"optional",innerType:e})}const Vi=p("ZodExactOptional",(e,t)=>{xo.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>er(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Wi(e){return new Vi({type:"optional",innerType:e})}const Gi=p("ZodNullable",(e,t)=>{_o.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ma(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function St(e){return new Gi({type:"nullable",innerType:e})}const qi=p("ZodDefault",(e,t)=>{ko.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ja(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Yi(e,t){return new qi({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():At(t)}})}const Xi=p("ZodPrefault",(e,t)=>{wo.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>La(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Hi(e,t){return new Xi({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():At(t)}})}const ir=p("ZodNonOptional",(e,t)=>{zo.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ua(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Qi(e,t){return new ir({type:"nonoptional",innerType:e,...b(t)})}const es=p("ZodCatch",(e,t)=>{jo.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Fa(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ts(e,t){return new es({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const rs=p("ZodPipe",(e,t)=>{So.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ba(e,r,n,o),e.in=t.in,e.out=t.out});function Nt(e,t){return new rs({type:"pipe",in:e,out:t})}const ns=p("ZodReadonly",(e,t)=>{No.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ka(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function os(e){return new ns({type:"readonly",innerType:e})}const as=p("ZodCustom",(e,t)=>{$o.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Aa(e,r)});function is(e,t={}){return xa(as,e,t)}function ss(e){return _a(e)}const N={agent:{name:"morpheus",personality:"helpful_dev"},logging:{enabled:!0,level:"info",retention:"14d"},audio:{provider:"google",model:"gemini-2.5-flash-lite",enabled:!0,maxDurationSeconds:300,supportedMimeTypes:["audio/ogg","audio/mp3","audio/mpeg","audio/wav"]},memory:{limit:100},runtime:{async_tasks:{enabled:!0}},llm:{provider:"openai",model:"gpt-4",temperature:.7,context_window:100},channels:{telegram:{enabled:!1,allowedUsers:[]},discord:{enabled:!1,allowedUsers:[]}},ui:{enabled:!0,port:3333}},ls=P({provider:ue(["google","openai","openrouter","ollama"]).default(N.audio.provider),model:y().min(1).default(N.audio.model),enabled:U().default(N.audio.enabled),apiKey:y().optional(),base_url:y().optional(),maxDurationSeconds:J().default(N.audio.maxDurationSeconds),supportedMimeTypes:te(y()).default(N.audio.supportedMimeTypes)}),we=P({provider:ue(["openai","anthropic","openrouter","ollama","gemini"]).default(N.llm.provider),model:y().min(1).default(N.llm.model),temperature:J().min(0).max(1).default(N.llm.temperature),max_tokens:J().int().positive().optional(),api_key:y().optional(),base_url:y().optional(),context_window:J().int().positive().optional()}),cs=we.extend({memory_limit:J().int().positive().optional(),enabled_archived_sessions:U().default(!0),similarity_threshold:J().min(0).max(1).default(.9),evaluation_interval:J().int().min(1).default(1)}),us=we.extend({working_dir:y().optional(),timeout_ms:J().int().positive().optional(),execution_mode:ue(["sync","async"]).default("async")}),ds=we.extend({execution_mode:ue(["sync","async"]).default("async")}),ms=we.extend({execution_mode:ue(["sync","async"]).default("async")}),ps=we.extend({skills_dir:y().optional()}),fs=P({telegram_notify_all:U().optional()}).optional(),hs=P({timezone:y().default("UTC"),check_interval_ms:J().min(6e4).default(6e4),max_active_jobs:J().min(1).max(1e3).default(100)}),gs=P({sandbox_dir:y().optional(),readonly_mode:U().default(!1),allowed_shell_commands:te(y()).default([]),enable_filesystem:U().default(!0),enable_shell:U().default(!0),enable_git:U().default(!0),enable_network:U().default(!0),timeout_ms:J().int().positive().default(3e4)}),bs=P({name:y().min(1).max(64).regex(/^[a-z0-9][a-z0-9_-]*$/,"Smith name must be lowercase alphanumeric with hyphens/underscores"),host:y().min(1),port:J().int().min(1).max(65535).default(7900),auth_token:y().min(1),tls:U().default(!1)}),vs=P({enabled:U().default(!0),fields:te(y()).default(["name","timezone","preferred_language"])}),ys=P({enabled:U().default(!1),execution_mode:ue(["sync","async"]).default("async"),heartbeat_interval_ms:J().int().min(5e3).default(3e4),connection_timeout_ms:J().int().min(1e3).default(1e4),task_timeout_ms:J().int().min(1e3).default(6e4),entries:te(bs).default([])}),xs=P({agent:P({name:y().default(N.agent.name),personality:y().default(N.agent.personality)}).default(N.agent),llm:we.default(N.llm),sati:cs.optional(),neo:ds.optional(),apoc:us.optional(),trinity:ms.optional(),keymaker:ps.optional(),webhooks:fs,audio:ls.default(N.audio),memory:P({limit:J().int().positive().optional()}).default(N.memory),runtime:P({async_tasks:P({enabled:U().default(N.runtime?.async_tasks.enabled)}).default(N.runtime?.async_tasks??{enabled:!0})}).optional(),chronos:hs.optional(),devkit:gs.optional(),smiths:ys.optional(),setup:vs.optional(),verbose_mode:U().default(!0),channels:P({telegram:P({enabled:U().default(!1),token:y().optional(),allowedUsers:te(y()).default([])}).default(N.channels.telegram),discord:P({enabled:U().default(!1),token:y().optional(),allowedUsers:te(y()).default([])}).default(N.channels.discord)}).default(N.channels),ui:P({enabled:U().default(N.ui.enabled),port:J().default(N.ui.port)}).default(N.ui),logging:P({enabled:U().default(N.logging.enabled),level:ue(["debug","info","warn","error"]).default(N.logging.level),retention:y().default(N.logging.retention)}).default(N.logging)}),_s=Mi("transport",[P({transport:zt("stdio"),command:y().min(1,"Command is required for stdio transport"),args:te(y()).optional().default([]),env:Te(y(),y()).optional().default({}),_comment:y().optional()}),P({transport:zt("http"),url:y().url("Valid URL is required for http transport"),headers:Te(y(),y()).optional().default({}),args:te(y()).optional().default([]),env:Te(y(),y()).optional().default({}),_comment:y().optional()})]);Te(y(),or([_s,y()]));const ks={resetData:async e=>xr.delete("/danger/reset",{categories:e})},ws=[{id:"general",label:"General"},{id:"agents",label:"Agents"},{id:"devkit",label:"DevKit"},{id:"audio",label:"Audio"},{id:"channels",label:"Channels"},{id:"chronos",label:"Chronos"},{id:"danger",label:"Danger Zone"}],zs=[{id:"oracle",label:"Oracle"},{id:"sati",label:"Sati"},{id:"neo",label:"Neo"},{id:"apoc",label:"Apoc"},{id:"trinity",label:"Trinity"}],je=[{label:"OpenAI",value:"openai"},{label:"Anthropic",value:"anthropic"},{label:"OpenRouter",value:"openrouter"},{label:"Ollama",value:"ollama"},{label:"Google Gemini",value:"gemini"}];function Is(){const{data:e,error:t}=de("/api/config",V.fetchConfig),{data:r}=de("/api/config/sati",V.getSatiConfig),{data:n}=de("/api/config/apoc",V.getApocConfig),{data:o}=de("/api/config/neo",V.getNeoConfig),{data:i}=de("/api/config/trinity",V.getTrinityConfig),{data:a}=de("/api/config/encryption-status",()=>V.getEncryptionStatus()),{data:l}=de("/api/config/env-overrides",()=>V.getEnvOverrides()),{data:d}=br(),[m,f]=I.useState(null),[u,h]=I.useState(null),[g,$]=I.useState(null),[v,Q]=I.useState(null),[C,fe]=I.useState(null),[_,D]=I.useState(null),[E,et]=I.useState("general"),[re,sr]=I.useState("oracle"),[tt,rt]=I.useState(!1),[q,Oe]=I.useState({}),[Je,ze]=I.useState(null);I.useEffect(()=>{e&&!u&&h(e)},[e]),I.useEffect(()=>{r&&!g&&$(r)},[r]),I.useEffect(()=>{n&&!C?fe(n):!n&&!C&&u&&fe({...u.apoc??u.llm,temperature:u.apoc?.temperature??.2,timeout_ms:u.apoc?.timeout_ms??3e4})},[n,u]),I.useEffect(()=>{o&&!v?Q(o):!o&&!v&&u&&Q({...u.neo??u.llm,temperature:u.neo?.temperature??.2})},[o,u]),I.useEffect(()=>{i&&!_?D(i):!i&&!_&&u&&D({...u.trinity??u.llm,temperature:u.trinity?.temperature??.2})},[i,u]),I.useEffect(()=>{d&&!m&&f(d)},[d]);const nt=JSON.stringify(e)!==JSON.stringify(u)||JSON.stringify(r)!==JSON.stringify(g)||JSON.stringify(o)!==JSON.stringify(v)||JSON.stringify(n)!==JSON.stringify(C)||JSON.stringify(i)!==JSON.stringify(_)||JSON.stringify(d)!==JSON.stringify(m),lr={general:JSON.stringify(e?.agent)!==JSON.stringify(u?.agent)||e?.verbose_mode!==u?.verbose_mode,agents:JSON.stringify(e?.llm)!==JSON.stringify(u?.llm)||JSON.stringify(r)!==JSON.stringify(g)||JSON.stringify(o)!==JSON.stringify(v)||JSON.stringify(n)!==JSON.stringify(C)||JSON.stringify(i)!==JSON.stringify(_),devkit:JSON.stringify(e?.devkit)!==JSON.stringify(u?.devkit),audio:JSON.stringify(e?.audio)!==JSON.stringify(u?.audio),channels:JSON.stringify(e?.channels?.telegram)!==JSON.stringify(u?.channels?.telegram)||JSON.stringify(e?.channels?.discord)!==JSON.stringify(u?.channels?.discord)||JSON.stringify(e?.webhooks)!==JSON.stringify(u?.webhooks),ui:JSON.stringify(e?.ui)!==JSON.stringify(u?.ui),logging:JSON.stringify(e?.logging)!==JSON.stringify(u?.logging),chronos:JSON.stringify(d)!==JSON.stringify(m)},he=(c,S)=>{if(!a?.apiKeysEncrypted)return null;const{morpheusSecretSet:Y,apiKeysEncrypted:X}=a,G=X[c];return!S?s.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-azure-surface border border-azure-border text-azure-text-secondary dark:bg-matrix-primary/10 dark:border-matrix-primary dark:text-matrix-tertiary",children:"No API key"}):l&&l[cr(c)]?null:Y?G?s.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-emerald-100 border border-emerald-300 text-emerald-800 dark:bg-emerald-900/30 dark:border-emerald-700 dark:text-emerald-400",title:"API key encrypted with AES-256-GCM",children:"🔒 Encrypted"}):s.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-amber-100 border border-amber-300 text-amber-800 dark:bg-amber-900/30 dark:border-amber-700 dark:text-amber-400",title:"Re-save this configuration to encrypt the API key",children:"⚠️ Re-save to encrypt"}):s.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-amber-100 border border-amber-300 text-amber-800 dark:bg-amber-900/30 dark:border-amber-700 dark:text-amber-400",title:"Set MORPHEUS_SECRET to enable encryption",children:"⚠️ Plaintext"})},cr=c=>({oracle:"llm.api_key",sati:"sati.api_key",neo:"neo.api_key",apoc:"apoc.api_key",trinity:"trinity.api_key",audio:"audio.apiKey"})[c],j=c=>!l||!l[c]?null:s.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-blue-100 border border-blue-300 text-blue-800 dark:bg-blue-900/30 dark:border-blue-700 dark:text-blue-400",title:"This field is set by an environment variable and cannot be edited",children:"🔒 Env Var"}),k=c=>!!(l&&l[c]),x=(c,S)=>{if(!u)return;const Y=JSON.parse(JSON.stringify(u));let X=Y;for(let G=0;G<c.length-1;G++)(X[c[G]]===void 0||X[c[G]]===null)&&(X[c[G]]={}),X=X[c[G]];X[c[c.length-1]]=S,h(Y);try{xs.parse(Y),Oe({})}catch(G){if(G instanceof gr){const Le={};G.errors.forEach(ot=>{const hr=ot.path.join(".");Le[hr]=ot.message}),Oe(Le)}}},ne=(c,S)=>{g&&$({...g,[c]:S})},oe=(c,S)=>{C&&fe({...C,[c]:S})},ee=(c,S)=>{v&&Q({...v,[c]:S})},ae=(c,S)=>{_&&D({..._,[c]:S})},ur=()=>{!u||!_||D({..._,provider:u.llm.provider,model:u.llm.model,api_key:u.llm.api_key})},dr=()=>{!u||!g||$({...g,provider:u.llm.provider,model:u.llm.model,api_key:u.llm.api_key})},mr=()=>{!u||!C||fe({...C,provider:u.llm.provider,model:u.llm.model,api_key:u.llm.api_key})},pr=()=>{!u||!v||Q({...v,provider:u.llm.provider,model:u.llm.model,api_key:u.llm.api_key})},fr=async()=>{if(u){rt(!0),ze(null);try{const c=await V.updateConfig(u);g&&await V.updateSatiConfig(g),v&&await V.updateNeoConfig(v),C&&await V.updateApocConfig(C),_&&await V.updateTrinityConfig(_),m&&await vr.updateConfig(m),me("/api/config"),me("/api/config/sati"),me("/api/config/neo"),me("/api/config/apoc"),me("/api/config/trinity"),me("/api/config/chronos"),Oe({});const S=c._restartRequired||[],Y=S.length>0?`Settings saved and applied. Some changes require restart: ${S.join(", ")}`:"Settings saved and applied successfully.";ze({type:"success",message:Y}),setTimeout(()=>ze(null),5e3)}catch(c){if(ze({type:"error",message:c.message}),c.details&&Array.isArray(c.details)){const S={};c.details.forEach(Y=>{const X=Y.path.join(".");S[X]=Y.message}),Oe(S)}}finally{rt(!1)}}};return t?s.jsx("div",{className:"p-8 text-red-500",children:"Failed to load configuration"}):u?s.jsxs("div",{className:"max-w-4xl mx-auto p-0 md:p-6 space-y-6",children:[s.jsxs("div",{className:"flex justify-between items-center flex-wrap gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:s.jsx(_r,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Zaion Settings"}),s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Configure agents, models, channels, and runtime behavior."})]})]}),s.jsx("button",{onClick:fr,disabled:!nt||Object.keys(q).length>0||tt,className:`px-4 py-2 rounded font-medium transition-colors ${nt&&Object.keys(q).length===0?"bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90":"bg-azure-border text-azure-text-secondary cursor-not-allowed dark:bg-matrix-primary/50 dark:text-matrix-highlight/50"}`,children:tt?"Saving...":"Save Changes"})]}),Je&&s.jsxs("div",{className:`flex items-start justify-between gap-3 p-4 rounded border ${Je.type==="success"?"border-azure-primary text-azure-primary bg-azure-primary/10 dark:border-matrix-highlight dark:text-matrix-highlight dark:bg-matrix-highlight/10":"border-red-500 text-red-500 bg-red-900/10"}`,children:[s.jsx("span",{className:"text-sm",children:Je.message}),s.jsx("button",{type:"button",onClick:()=>ze(null),className:"shrink-0 opacity-60 hover:opacity-100 transition-opacity","aria-label":"Dismiss",children:s.jsx(kr,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"overflow-x-auto py-1 hide-scrollbar",children:s.jsx("div",{className:"flex space-x-1 border-b border-azure-border dark:border-matrix-primary pb-px min-w-max",children:ws.map(c=>s.jsxs("button",{onClick:()=>et(c.id),className:`px-4 py-2 text-sm font-medium rounded-t-md transition-colors flex-shrink-0 flex items-center gap-1.5 ${E===c.id?"bg-azure-surface/50 text-azure-primary border-t border-x border-azure-border dark:bg-matrix-primary/20 dark:text-matrix-highlight dark:border-t dark:border-x dark:border-matrix-primary":"text-azure-text-secondary hover:text-azure-primary dark:text-matrix-secondary dark:hover:text-matrix-highlight"}`,children:[c.label,lr[c.id]&&s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0"})]},c.id))})}),s.jsxs("div",{className:"space-y-6",children:[E==="general"&&s.jsxs(L,{title:"Agent Identity",children:[s.jsx(w,{label:"Agent Name",value:u.agent.name,onChange:c=>x(["agent","name"],c.target.value),error:q["agent.name"]}),s.jsx(w,{label:"Personality",value:u.agent.personality,onChange:c=>x(["agent","personality"],c.target.value),error:q["agent.personality"]}),s.jsx(K,{label:"Verbose Mode",value:u.verbose_mode!==!1?"true":"false",onChange:c=>x(["verbose_mode"],c.target.value==="true"),options:[{value:"true",label:"Enabled (notify tool execution on channels)"},{value:"false",label:"Disabled"}],helperText:"When enabled, channels like Telegram/Discord show which tools are being executed in real-time."})]}),E==="agents"&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex space-x-1 border-b border-azure-border dark:border-matrix-primary pb-px",children:zs.map(c=>s.jsx("button",{onClick:()=>sr(c.id),className:`px-4 py-2 text-sm font-medium rounded-t-md transition-colors ${re===c.id?"bg-azure-primary/10 text-azure-primary border-b-2 border-azure-primary dark:bg-matrix-highlight/10 dark:text-matrix-highlight dark:border-matrix-highlight":"text-azure-text-secondary hover:text-azure-primary dark:text-matrix-secondary dark:hover:text-matrix-highlight"}`,children:c.label},c.id))}),re==="oracle"&&s.jsxs(L,{title:"Oracle Agent",children:[s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Main orchestration agent — handles user requests and delegates to subagents"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),j("llm.provider")]}),s.jsx(K,{label:"",value:u.llm.provider,onChange:c=>x(["llm","provider"],c.target.value),options:je,error:q["llm.provider"],disabled:k("llm.provider")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),j("llm.model")]}),s.jsx(w,{label:"",value:u.llm.model,onChange:c=>x(["llm","model"],c.target.value),disabled:k("llm.model")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Temperature"}),j("llm.temperature")]}),s.jsx(M,{label:"",value:u.llm.temperature,onChange:c=>x(["llm","temperature"],parseFloat(c.target.value)),step:.1,min:0,max:1,error:q["llm.temperature"],disabled:k("llm.temperature")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Max Tokens"}),j("llm.max_tokens")]}),s.jsx(M,{label:"",value:u.llm.max_tokens??"",onChange:c=>x(["llm","max_tokens"],c.target.value?parseInt(c.target.value):void 0),min:1,error:q["llm.max_tokens"],helperText:"Maximum tokens per response. Leave empty for model default.",disabled:k("llm.max_tokens")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Context Window (Messages)"}),j("llm.context_window")]}),s.jsx(M,{label:"",value:u.llm.context_window??100,onChange:c=>x(["llm","context_window"],parseInt(c.target.value)),min:1,step:1,error:q["llm.context_window"],helperText:"Number of past interactions to load into LLM context (e.g., 100).",disabled:k("llm.context_window")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),s.jsxs("div",{className:"flex items-center gap-2",children:[j("llm.api_key"),he("oracle",u.llm.api_key)]})]}),s.jsx(w,{label:"",type:"password",value:u.llm.api_key||"",onChange:c=>x(["llm","api_key"],c.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:k("llm.api_key")}),u.llm.provider==="openrouter"&&s.jsx(w,{label:"Base URL",value:u.llm.base_url||"https://openrouter.ai/api/v1",onChange:c=>x(["llm","base_url"],c.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"})]}),re==="sati"&&s.jsxs(L,{title:"Sati Agent",children:[s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Background memory consolidation agent — evaluates conversations and persists important context"}),s.jsxs("div",{className:"mb-4",children:[s.jsx("button",{type:"button",onClick:dr,className:"px-3 py-1.5 text-sm bg-azure-surface border border-azure-border rounded hover:bg-azure-primary/10 dark:bg-matrix-primary/20 dark:border-matrix-primary dark:hover:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight transition-colors",children:"Copy from Oracle Agent"}),s.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Copy Provider, Model, and API Key from Oracle Agent configuration"})]}),g&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),j("sati.provider")]}),s.jsx(K,{label:"",value:g.provider,onChange:c=>ne("provider",c.target.value),options:je,disabled:k("sati.provider")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),j("sati.model")]}),s.jsx(w,{label:"",value:g.model,onChange:c=>ne("model",c.target.value),disabled:k("sati.model")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),s.jsxs("div",{className:"flex items-center gap-2",children:[j("sati.api_key"),he("sati",g.api_key)]})]}),s.jsx(w,{label:"",type:"password",value:g.api_key||"",onChange:c=>ne("api_key",c.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:k("sati.api_key")}),g.provider==="openrouter"&&s.jsx(w,{label:"Base URL",value:g.base_url||"https://openrouter.ai/api/v1",onChange:c=>ne("base_url",c.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"}),s.jsx(M,{label:"Memory Limit",value:g.memory_limit??10,onChange:c=>ne("memory_limit",parseInt(c.target.value)),min:1,step:1,helperText:"Number of memory items to retrieve from long-term storage."}),s.jsx(M,{label:"Evaluation Interval",value:g.evaluation_interval??1,onChange:c=>ne("evaluation_interval",parseInt(c.target.value)),min:1,step:1,helperText:"Oracle turns between memory evaluations. Default: 1 (every turn). *If Evaluation interval is more than context window, this value will be ignored."}),s.jsx(H,{label:"Enable Archived Sessions in Memory Retrieval",checked:g.enabled_archived_sessions??!0,onChange:c=>ne("enabled_archived_sessions",c)}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Similarity Threshold"}),s.jsx("span",{className:"text-sm font-mono text-azure-text-primary dark:text-matrix-highlight",children:(g.similarity_threshold??.9).toFixed(2)})]}),s.jsx("input",{type:"range",min:0,max:1,step:.01,value:g.similarity_threshold??.9,onChange:c=>ne("similarity_threshold",parseFloat(c.target.value)),className:`w-full h-1.5 rounded-full appearance-none cursor-pointer
|
|
40
|
-
bg-gray-200 dark:bg-matrix-primary/30
|
|
41
|
-
accent-azure-primary dark:accent-matrix-highlight`}),s.jsx("p",{className:"mt-1.5 text-xs text-gray-400 dark:text-matrix-secondary",children:"Minimum cosine similarity to consider a memory relevant (0–1). Lower values retrieve more memories, but may increase token consumption."})]})]})]}),re==="neo"&&s.jsxs(L,{title:"Neo Agent",children:[s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"MCP + internal tools subagent — executes analytical and operational tasks delegated by Oracle"}),s.jsxs("div",{className:"mb-4",children:[s.jsx("button",{type:"button",onClick:pr,className:"px-3 py-1.5 text-sm bg-azure-surface border border-azure-border rounded hover:bg-azure-primary/10 dark:bg-matrix-primary/20 dark:border-matrix-primary dark:hover:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight transition-colors",children:"Copy from Oracle Agent"}),s.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Copy Provider, Model, and API Key from Oracle Agent configuration"})]}),v&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),j("neo.provider")]}),s.jsx(K,{label:"",value:v.provider,onChange:c=>ee("provider",c.target.value),options:je,disabled:k("neo.provider")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),j("neo.model")]}),s.jsx(w,{label:"",value:v.model,onChange:c=>ee("model",c.target.value),disabled:k("neo.model")}),s.jsx(w,{label:"Personality",value:v.personality||"analytical_engineer",onChange:c=>ee("personality",c.target.value),placeholder:"analytical_engineer",helperText:"e.g., analytical_engineer, meticulous_auditor, systems_thinker"}),s.jsx(K,{label:"Execution Mode",value:v.execution_mode||"async",onChange:c=>ee("execution_mode",c.target.value),options:[{value:"async",label:"Async (background task)"},{value:"sync",label:"Sync (inline response)"}]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Temperature"}),j("neo.temperature")]}),s.jsx(M,{label:"",value:v.temperature,onChange:c=>ee("temperature",parseFloat(c.target.value)),step:.1,min:0,max:1,disabled:k("neo.temperature")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Max Tokens"}),j("neo.max_tokens")]}),s.jsx(M,{label:"",value:v.max_tokens??"",onChange:c=>ee("max_tokens",c.target.value?parseInt(c.target.value):void 0),min:1,helperText:"Maximum tokens per response. Leave empty for model default.",disabled:k("neo.max_tokens")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Context Window (Messages)"}),j("neo.context_window")]}),s.jsx(M,{label:"",value:v.context_window??100,onChange:c=>ee("context_window",parseInt(c.target.value)),min:1,step:1,disabled:k("neo.context_window")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),s.jsxs("div",{className:"flex items-center gap-2",children:[j("neo.api_key"),he("neo",v.api_key)]})]}),s.jsx(w,{label:"",type:"password",value:v.api_key||"",onChange:c=>ee("api_key",c.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:k("neo.api_key")}),v.provider==="openrouter"&&s.jsx(w,{label:"Base URL",value:v.base_url||"https://openrouter.ai/api/v1",onChange:c=>ee("base_url",c.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"})]})]}),re==="trinity"&&s.jsxs(L,{title:"Trinity Agent",children:[s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Database subagent — interprets natural language queries and executes them against registered databases (PostgreSQL, MySQL, SQLite, MongoDB)"}),s.jsxs("div",{className:"mb-4",children:[s.jsx("button",{type:"button",onClick:ur,className:"px-3 py-1.5 text-sm bg-azure-surface border border-azure-border rounded hover:bg-azure-primary/10 dark:bg-matrix-primary/20 dark:border-matrix-primary dark:hover:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight transition-colors",children:"Copy from Oracle Agent"}),s.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Copy Provider, Model, and API Key from Oracle Agent configuration"})]}),_&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),j("trinity.provider")]}),s.jsx(K,{label:"",value:_.provider,onChange:c=>ae("provider",c.target.value),options:je,disabled:k("trinity.provider")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),j("trinity.model")]}),s.jsx(w,{label:"",value:_.model,onChange:c=>ae("model",c.target.value),disabled:k("trinity.model")}),s.jsx(w,{label:"Personality",value:_.personality||"data_specialist",onChange:c=>ae("personality",c.target.value),placeholder:"data_specialist",helperText:"e.g., data_specialist, query_optimizer, db_architect"}),s.jsx(K,{label:"Execution Mode",value:_.execution_mode||"async",onChange:c=>ae("execution_mode",c.target.value),options:[{value:"async",label:"Async (background task)"},{value:"sync",label:"Sync (inline response)"}]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Temperature"}),j("trinity.temperature")]}),s.jsx(M,{label:"",value:_.temperature,onChange:c=>ae("temperature",parseFloat(c.target.value)),step:.1,min:0,max:1,disabled:k("trinity.temperature")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Max Tokens"}),j("trinity.max_tokens")]}),s.jsx(M,{label:"",value:_.max_tokens??"",onChange:c=>ae("max_tokens",c.target.value?parseInt(c.target.value):void 0),min:1,helperText:"Maximum tokens per response. Leave empty for model default.",disabled:k("trinity.max_tokens")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),s.jsxs("div",{className:"flex items-center gap-2",children:[j("trinity.api_key"),he("trinity",_.api_key)]})]}),s.jsx(w,{label:"",type:"password",value:_.api_key||"",onChange:c=>ae("api_key",c.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:k("trinity.api_key")}),_.provider==="openrouter"&&s.jsx(w,{label:"Base URL",value:_.base_url||"https://openrouter.ai/api/v1",onChange:c=>ae("base_url",c.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"})]})]}),re==="apoc"&&s.jsxs(L,{title:"Apoc Agent",children:[s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"DevTools subagent — executes file, shell, git, network, and system operations on behalf of Oracle"}),s.jsxs("div",{className:"mb-4",children:[s.jsx("button",{type:"button",onClick:mr,className:"px-3 py-1.5 text-sm bg-azure-surface border border-azure-border rounded hover:bg-azure-primary/10 dark:bg-matrix-primary/20 dark:border-matrix-primary dark:hover:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight transition-colors",children:"Copy from Oracle Agent"}),s.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Copy Provider, Model, and API Key from Oracle Agent configuration"})]}),C&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),j("apoc.provider")]}),s.jsx(K,{label:"",value:C.provider,onChange:c=>oe("provider",c.target.value),options:je,disabled:k("apoc.provider")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),j("apoc.model")]}),s.jsx(w,{label:"",value:C.model,onChange:c=>oe("model",c.target.value),disabled:k("apoc.model")}),s.jsx(w,{label:"Personality",value:C.personality||"pragmatic_dev",onChange:c=>oe("personality",c.target.value),placeholder:"pragmatic_dev",helperText:"e.g., pragmatic_dev, cautious_admin, automation_specialist"}),s.jsx(K,{label:"Execution Mode",value:C.execution_mode||"async",onChange:c=>oe("execution_mode",c.target.value),options:[{value:"async",label:"Async (background task)"},{value:"sync",label:"Sync (inline response)"}]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Temperature"}),j("apoc.temperature")]}),s.jsx(M,{label:"",value:C.temperature,onChange:c=>oe("temperature",parseFloat(c.target.value)),step:.1,min:0,max:1,disabled:k("apoc.temperature")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),s.jsxs("div",{className:"flex items-center gap-2",children:[j("apoc.api_key"),he("apoc",C.api_key)]})]}),s.jsx(w,{label:"",type:"password",value:C.api_key||"",onChange:c=>oe("api_key",c.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:k("apoc.api_key")}),C.provider==="openrouter"&&s.jsx(w,{label:"Base URL",value:C.base_url||"https://openrouter.ai/api/v1",onChange:c=>oe("base_url",c.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"}),s.jsx(M,{label:"Timeout (ms)",value:C.timeout_ms??3e4,onChange:c=>oe("timeout_ms",parseInt(c.target.value)),min:1e3,step:1e3,helperText:"Maximum execution time for shell and system operations in milliseconds."})]})]})]}),E==="devkit"&&s.jsxs(s.Fragment,{children:[s.jsxs(L,{title:"DevKit Security",children:[s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Shared security configuration for DevKit tools used by Apoc and Keymaker. Controls path sandboxing, shell command restrictions, and tool category access."}),s.jsx(w,{label:"Sandbox Directory",value:u.devkit?.sandbox_dir||"",onChange:c=>x(["devkit","sandbox_dir"],c.target.value),placeholder:typeof window<"u"?"(defaults to process.cwd())":"",helperText:"Root directory for all DevKit operations. All file, shell, and git paths are confined here.",disabled:k("devkit.sandbox_dir")}),s.jsx(K,{label:"Read-Only Mode",value:u.devkit?.readonly_mode?"true":"false",onChange:c=>x(["devkit","readonly_mode"],c.target.value==="true"),options:[{value:"false",label:"Disabled (read + write)"},{value:"true",label:"Enabled (read-only, blocks writes/deletes)"}],helperText:"When enabled, blocks all write, delete, and create operations on the filesystem.",disabled:k("devkit.readonly_mode")}),s.jsx(M,{label:"Timeout (ms)",value:u.devkit?.timeout_ms??3e4,onChange:c=>x(["devkit","timeout_ms"],parseInt(c.target.value)),min:1e3,step:1e3,helperText:"Default timeout for shell and system operations in milliseconds.",disabled:k("devkit.timeout_ms")})]}),s.jsxs(L,{title:"Tool Categories",children:[s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Enable or disable entire categories of DevKit tools."}),s.jsx(H,{label:"Filesystem (read, write, list, copy, move, delete files)",checked:u.devkit?.enable_filesystem!==!1,onChange:c=>x(["devkit","enable_filesystem"],c)}),s.jsx(H,{label:"Shell (run_command, run_script, which)",checked:u.devkit?.enable_shell!==!1,onChange:c=>x(["devkit","enable_shell"],c)}),s.jsx(H,{label:"Git (status, diff, commit, push, pull, clone, branch)",checked:u.devkit?.enable_git!==!1,onChange:c=>x(["devkit","enable_git"],c)}),s.jsx(H,{label:"Network (http_request, ping, dns_lookup, download_file)",checked:u.devkit?.enable_network!==!1,onChange:c=>x(["devkit","enable_network"],c)})]}),s.jsxs(L,{title:"Shell Command Allowlist",children:[s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Restrict which shell commands Apoc and Keymaker can execute. Leave empty to allow all commands (default)."}),s.jsx(w,{label:"Allowed Commands",value:(u.devkit?.allowed_shell_commands||[]).join(", "),onChange:c=>x(["devkit","allowed_shell_commands"],c.target.value.split(",").map(S=>S.trim()).filter(Boolean)),placeholder:"e.g. node, npm, git, python, cargo",helperText:"Comma-separated list of allowed binary names. Empty = all commands allowed.",disabled:k("devkit.allowed_shell_commands")})]})]}),E==="audio"&&s.jsxs(L,{title:"Audio Transcription",children:[s.jsx(H,{label:"Enable Audio",checked:u.audio.enabled,onChange:c=>x(["audio","enabled"],c)}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),j("audio.provider")]}),s.jsx(K,{label:"",value:u.audio.provider||"google",onChange:c=>x(["audio","provider"],c.target.value),options:[{label:"Google Gemini",value:"google"},{label:"OpenAI (Whisper)",value:"openai"},{label:"OpenRouter (multimodal)",value:"openrouter"},{label:"Ollama (Whisper local)",value:"ollama"}],error:q["audio.provider"],disabled:k("audio.provider")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model"}),j("audio.model")]}),s.jsx(w,{label:"",value:u.audio.model,onChange:c=>x(["audio","model"],c.target.value),placeholder:"e.g. whisper-1, gemini-2.5-flash-lite...",helperText:"Model to use for audio transcription.",error:q["audio.model"],disabled:k("audio.model")}),u.audio.provider==="ollama"&&s.jsx(w,{label:"Base URL",value:u.audio.base_url||"",onChange:c=>x(["audio","base_url"],c.target.value),placeholder:"http://localhost:11434",helperText:"Ollama base URL. Requires a Whisper model loaded (ollama pull whisper)."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),s.jsxs("div",{className:"flex items-center gap-2",children:[j("audio.apiKey"),he("audio",u.audio.apiKey)]})]}),s.jsx(w,{label:"",type:"password",value:u.audio.apiKey||"",onChange:c=>x(["audio","apiKey"],c.target.value),placeholder:"If different from LLM key...",helperText:"Leave empty to use LLM API key if using the same provider.",disabled:k("audio.apiKey")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Max Duration (Seconds)"}),j("audio.maxDurationSeconds")]}),s.jsx(M,{label:"",value:u.audio.maxDurationSeconds,onChange:c=>x(["audio","maxDurationSeconds"],parseInt(c.target.value)),min:1,disabled:k("audio.maxDurationSeconds")}),s.jsx(w,{label:"Supported Mime Types",value:u.audio.supportedMimeTypes.join(", "),onChange:c=>x(["audio","supportedMimeTypes"],c.target.value.split(",").map(S=>S.trim()).filter(Boolean)),helperText:"Comma separated list (e.g. audio/ogg, audio/mp3)"})]}),E==="channels"&&s.jsxs(s.Fragment,{children:[s.jsxs(L,{title:"Telegram",children:[s.jsx(H,{label:"Enable Telegram",checked:u.channels.telegram.enabled,onChange:c=>x(["channels","telegram","enabled"],c)}),u.channels.telegram.enabled&&s.jsxs("div",{className:"space-y-4 mt-4 pl-4 border-l border-matrix-primary",children:[s.jsx(w,{label:"Bot Token",type:"password",value:u.channels.telegram.token||"",onChange:c=>x(["channels","telegram","token"],c.target.value)}),s.jsx(w,{label:"Allowed Users (comma separated)",value:u.channels.telegram.allowedUsers.join(", "),onChange:c=>x(["channels","telegram","allowedUsers"],c.target.value.split(",").map(S=>S.trim()).filter(Boolean)),helperText:"User IDs allowed to interact with the bot"})]})]}),s.jsxs(L,{title:"Discord",children:[s.jsx(H,{label:"Enable Discord",checked:u.channels.discord.enabled,onChange:c=>x(["channels","discord","enabled"],c)}),u.channels.discord.enabled&&s.jsxs("div",{className:"space-y-4 mt-4 pl-4 border-l border-matrix-primary",children:[s.jsx(w,{label:"Bot Token",type:"password",value:u.channels.discord.token||"",onChange:c=>x(["channels","discord","token"],c.target.value)}),s.jsx(w,{label:"Allowed Users (comma separated)",value:(u.channels.discord.allowedUsers??[]).join(", "),onChange:c=>x(["channels","discord","allowedUsers"],c.target.value.split(",").map(S=>S.trim()).filter(Boolean)),helperText:"Discord user IDs allowed to interact with the bot"})]})]})]}),E==="ui"&&s.jsxs(L,{title:"Dashboard",children:[s.jsx(H,{label:"Enable Web UI",checked:u.ui.enabled,onChange:c=>x(["ui","enabled"],c)}),s.jsx(M,{label:"Port",value:u.ui.port,onChange:c=>x(["ui","port"],parseInt(c.target.value)),disabled:!0,helperText:"Port changes require daemon restart."})]}),E==="logging"&&s.jsxs(L,{title:"Logging",children:[s.jsx(H,{label:"Enable Logging",checked:u.logging.enabled,onChange:c=>x(["logging","enabled"],c)}),s.jsx(K,{label:"Log Level",value:u.logging.level,onChange:c=>x(["logging","level"],c.target.value),options:[{label:"Debug",value:"debug"},{label:"Info",value:"info"},{label:"Warning",value:"warn"},{label:"Error",value:"error"}]})]}),E==="chronos"&&m&&s.jsxs(L,{title:"Chronos — Temporal Intent Engine",children:[s.jsx(K,{label:"Timezone",value:m.timezone,onChange:c=>f({...m,timezone:c.target.value}),options:[{label:"UTC",value:"UTC"},{label:"America/New_York",value:"America/New_York"},{label:"America/Chicago",value:"America/Chicago"},{label:"America/Denver",value:"America/Denver"},{label:"America/Los_Angeles",value:"America/Los_Angeles"},{label:"America/Sao_Paulo",value:"America/Sao_Paulo"},{label:"America/Buenos_Aires",value:"America/Buenos_Aires"},{label:"America/Bogota",value:"America/Bogota"},{label:"America/Lima",value:"America/Lima"},{label:"America/Santiago",value:"America/Santiago"},{label:"America/Mexico_City",value:"America/Mexico_City"},{label:"America/Toronto",value:"America/Toronto"},{label:"America/Vancouver",value:"America/Vancouver"},{label:"Europe/London",value:"Europe/London"},{label:"Europe/Paris",value:"Europe/Paris"},{label:"Europe/Berlin",value:"Europe/Berlin"},{label:"Europe/Madrid",value:"Europe/Madrid"},{label:"Europe/Rome",value:"Europe/Rome"},{label:"Europe/Amsterdam",value:"Europe/Amsterdam"},{label:"Europe/Brussels",value:"Europe/Brussels"},{label:"Europe/Zurich",value:"Europe/Zurich"},{label:"Europe/Lisbon",value:"Europe/Lisbon"},{label:"Europe/Warsaw",value:"Europe/Warsaw"},{label:"Europe/Stockholm",value:"Europe/Stockholm"},{label:"Europe/Helsinki",value:"Europe/Helsinki"},{label:"Europe/Moscow",value:"Europe/Moscow"},{label:"Asia/Dubai",value:"Asia/Dubai"},{label:"Asia/Kolkata",value:"Asia/Kolkata"},{label:"Asia/Bangkok",value:"Asia/Bangkok"},{label:"Asia/Singapore",value:"Asia/Singapore"},{label:"Asia/Hong_Kong",value:"Asia/Hong_Kong"},{label:"Asia/Shanghai",value:"Asia/Shanghai"},{label:"Asia/Tokyo",value:"Asia/Tokyo"},{label:"Asia/Seoul",value:"Asia/Seoul"},{label:"Australia/Sydney",value:"Australia/Sydney"},{label:"Australia/Melbourne",value:"Australia/Melbourne"},{label:"Pacific/Auckland",value:"Pacific/Auckland"},{label:"Africa/Cairo",value:"Africa/Cairo"},{label:"Africa/Johannesburg",value:"Africa/Johannesburg"}]}),s.jsx(M,{label:"Check Interval (seconds)",value:Math.round(m.check_interval_ms/1e3),onChange:c=>f({...m,check_interval_ms:Number(c.target.value)*1e3}),min:60}),s.jsx(M,{label:"Max Active Jobs",value:m.max_active_jobs,onChange:c=>f({...m,max_active_jobs:Number(c.target.value)}),min:1,max:1e3})]}),E==="danger"&&s.jsx(js,{})]})]}):s.jsx("div",{className:"p-8 text-azure-primary dark:text-matrix-highlight",children:"Loading settings..."})}const ge=[{id:"sessions",label:"Sessions & Messages",description:"All chat sessions and their messages"},{id:"memories",label:"Long-term Memories",description:"Sati knowledge base, embeddings, and archived session chunks"},{id:"tasks",label:"Tasks",description:"Background task queue and execution results"},{id:"audit",label:"Audit Logs",description:"All agent and tool audit events"},{id:"chronos",label:"Chronos Jobs",description:"Scheduled jobs and their execution history"},{id:"webhooks",label:"Webhooks",description:"Webhook definitions and notification history"}];function js(){const[e,t]=I.useState(new Set),[r,n]=I.useState(!1),[o,i]=I.useState(!1),[a,l]=I.useState(null),d=h=>{t(g=>{const $=new Set(g);return $.has(h)?$.delete(h):$.add(h),$})},m=()=>{e.size===ge.length?t(new Set):t(new Set(ge.map(h=>h.id)))},f=async()=>{if(e.size!==0){i(!0),l(null);try{const h=await ks.resetData([...e]);l({success:!0,message:h.message}),t(new Set),me(()=>!0,void 0,{revalidate:!0})}catch(h){l({success:!1,message:h instanceof Error?h.message:"Failed to reset data"})}finally{i(!1)}}},u=ge.filter(h=>e.has(h.id)).map(h=>h.label);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg border-2 border-red-300 dark:border-red-900 bg-red-50 dark:bg-red-950/20 p-6 space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(wr,{className:"w-6 h-6 text-red-500 dark:text-red-400 shrink-0"}),s.jsx("h3",{className:"text-lg font-semibold text-red-700 dark:text-red-400",children:"Danger Zone"})]}),s.jsxs("p",{className:"text-sm text-red-600 dark:text-red-300/80",children:["Select the data you want to permanently delete. These actions are ",s.jsx("strong",{children:"irreversible"}),"."]}),s.jsxs("div",{className:"rounded-md border border-red-200 dark:border-red-900/60 bg-white dark:bg-black p-4 space-y-3",children:[s.jsxs("label",{className:"flex items-center gap-3 pb-2 border-b border-red-100 dark:border-red-900/40 cursor-pointer select-none",children:[s.jsx("input",{type:"checkbox",checked:e.size===ge.length,onChange:m,className:`w-4 h-4 rounded border-red-300 text-red-600 focus:ring-red-500
|
|
42
|
-
dark:border-red-800 dark:bg-black dark:checked:bg-red-600`}),s.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-400",children:"Select all"})]}),ge.map(h=>s.jsxs("label",{className:"flex items-start gap-3 cursor-pointer select-none",children:[s.jsx("input",{type:"checkbox",checked:e.has(h.id),onChange:()=>d(h.id),className:`w-4 h-4 mt-0.5 rounded border-red-300 text-red-600 focus:ring-red-500
|
|
43
|
-
dark:border-red-800 dark:bg-black dark:checked:bg-red-600`}),s.jsxs("div",{children:[s.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:h.label}),s.jsx("p",{className:"text-xs text-red-500 dark:text-red-300/60",children:h.description})]})]},h.id))]}),s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("p",{className:"text-xs text-red-500 dark:text-red-300/50",children:e.size===0?"No categories selected":`${e.size} of ${ge.length} selected`}),s.jsx("button",{onClick:()=>n(!0),disabled:o||e.size===0,className:`shrink-0 px-4 py-2 text-sm font-medium rounded-md
|
|
44
|
-
bg-red-600 text-white hover:bg-red-700
|
|
45
|
-
dark:bg-red-900/50 dark:text-red-200 dark:hover:bg-red-800/60
|
|
46
|
-
disabled:opacity-50 disabled:cursor-not-allowed
|
|
47
|
-
transition-colors`,children:o?"Resetting...":"Reset selected data"})]}),a&&s.jsx("div",{className:`rounded-md p-3 text-sm ${a.success?"bg-green-50 text-green-700 dark:bg-green-950/30 dark:text-green-400 border border-green-200 dark:border-green-900":"bg-red-100 text-red-700 dark:bg-red-950/40 dark:text-red-300 border border-red-300 dark:border-red-800"}`,children:a.message})]}),s.jsx(yr,{isOpen:r,onClose:()=>n(!1),onConfirm:f,title:"Reset selected data?",description:`This will permanently delete: ${u.join(", ")}. This action cannot be undone.`,confirmJson:"Yes, delete permanently",variant:"destructive"})]})}export{Is as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as x}from"./vendor-react-DikRIOlj.js";import{u as F}from"./vendor-utils-D4NnWbOU.js";import{c as b,S as Q,N as v}from"./config-DdfK4DX6.js";import{S as X,T as z}from"./SelectInput-KVLsnfra.js";import{h as Y,a2 as C,H as S,Q as J,am as D,a6 as H,ac as V,an as I,ad as Z,ao as ee,ap as te,aq as re,w as ae,z as se,l as ie,ar as ne,g as le,ae as de,G as oe,X as ce}from"./vendor-icons-DMd9RGvJ.js";import"./index-Dpd1Mkgp.js";const xe={name:"",host:"",port:7900,auth_token:"",tls:!1};function me(t){const l=Math.floor(t/86400),i=Math.floor(t%86400/3600),o=Math.floor(t%3600/60);return l>0?`${l}d ${i}h`:i>0?`${i}h ${o}m`:`${o}m`}function he(t,l){const i=t>=1024?`${(t/1024).toFixed(1)}GB`:`${Math.round(t)}MB`,o=l>=1024?`${(l/1024).toFixed(1)}GB`:`${Math.round(l)}MB`;return`${i} / ${o}`}function ue({state:t}){return t==="online"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-emerald-500 bg-emerald-500/10 border border-emerald-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),"online"]}):t==="connecting"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-amber-500 bg-amber-500/10 border border-amber-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse"}),"connecting"]}):t==="error"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-red-500 bg-red-500/10 border border-red-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"error"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-zinc-500 bg-zinc-500/10 border border-zinc-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-zinc-500"}),"offline"]})}function ge({cap:t}){const i={filesystem:"text-blue-400 bg-blue-400/10 border-blue-400/30",shell:"text-yellow-400 bg-yellow-400/10 border-yellow-400/30",git:"text-orange-400 bg-orange-400/10 border-orange-400/30",browser:"text-purple-400 bg-purple-400/10 border-purple-400/30",network:"text-cyan-400 bg-cyan-400/10 border-cyan-400/30",packages:"text-green-400 bg-green-400/10 border-green-400/30",processes:"text-pink-400 bg-pink-400/10 border-pink-400/30",system:"text-indigo-400 bg-indigo-400/10 border-indigo-400/30"}[t]??"text-zinc-400 bg-zinc-400/10 border-zinc-400/30";return e.jsx("span",{className:`text-[10px] font-medium border rounded px-1.5 py-0.5 ${i}`,children:t})}function be({status:t,entry:l,onPing:i,onEdit:o,onDelete:a}){const[d,h]=x.useState(!1),s=t.state==="online";return e.jsxs("div",{className:`rounded-lg border bg-white dark:bg-zinc-900 shadow-sm transition-all ${s?"border-emerald-500/40 dark:border-emerald-500/30":t.state==="error"?"border-red-500/40 dark:border-red-500/30":t.state==="connecting"?"border-amber-500/40 dark:border-amber-500/30":"border-azure-border dark:border-matrix-primary"}`,children:[e.jsxs("div",{className:"p-4 bg-white dark:bg-zinc-900 shadow-sm rounded-tl-lg rounded-tr-lg",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 ${s?"bg-emerald-500/10":"bg-zinc-100 dark:bg-zinc-900"}`,children:e.jsx(te,{className:`w-4 h-4 ${s?"text-emerald-500":"text-zinc-400 dark:text-matrix-tertiary"}`})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-semibold text-azure-text dark:text-matrix-highlight truncate",children:t.name}),e.jsx(ue,{state:t.state}),l?.tls&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-emerald-500 bg-emerald-500/10 border border-emerald-500/30 rounded px-1.5 py-0.5",children:[e.jsx(re,{className:"w-2.5 h-2.5"}),"TLS"]})]}),e.jsxs("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-tertiary mt-0.5",children:[t.host,":",t.port]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>i(t.name),className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"Ping",children:e.jsx(I,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>o(l??{name:t.name,host:t.host,port:t.port,auth_token:"",tls:!1}),className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"Edit",children:e.jsx(ae,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>a(t.name),className:"p-1.5 rounded border border-red-200 dark:border-red-800/50 text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 hover:text-red-500 transition-colors",title:"Remove",children:e.jsx(se,{className:"w-3.5 h-3.5"})})]})]}),t.error&&e.jsxs("div",{className:"mt-3 flex items-start gap-2 text-xs text-red-500 bg-red-500/10 border border-red-500/20 rounded p-2",children:[e.jsx(C,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),e.jsx("span",{children:t.error})]}),s&&t.stats&&e.jsx("div",{className:"mt-3 space-y-2",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"OS"}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:t.stats.os})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"Hostname"}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono truncate max-w-[120px]",children:t.stats.hostname})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary flex items-center gap-1",children:[e.jsx(ie,{className:"w-3 h-3"})," CPU"]}),e.jsxs("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:[t.stats.cpu_percent.toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary flex items-center gap-1",children:[e.jsx(ne,{className:"w-3 h-3"})," RAM"]}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:he(t.stats.memory_used_mb,t.stats.memory_total_mb)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary flex items-center gap-1",children:[e.jsx(le,{className:"w-3 h-3"})," Uptime"]}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:me(t.stats.uptime_seconds)})]}),t.config?.sandbox_dir&&e.jsxs("div",{className:"flex justify-between col-span-2",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary shrink-0",children:"Sandbox"}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono truncate text-right ml-2",children:t.config.sandbox_dir})]}),t.config&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"Read-only"}),e.jsx("span",{className:`font-medium ${t.config.readonly_mode?"text-amber-500":"text-emerald-500"}`,children:t.config.readonly_mode?"yes":"no"})]})]})}),!s&&t.lastSeen&&e.jsxs("div",{className:"mt-2 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:["Last seen: ",new Date(t.lastSeen).toLocaleString()]})]}),t.capabilities.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>h(!d),className:"w-full flex items-center justify-between px-4 py-2 border-t border-azure-border dark:border-matrix-primary/30 text-xs text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-secondary hover:bg-azure-surface/50 dark:hover:bg-zinc-900/50 transition-colors",children:[e.jsxs("span",{children:["Capabilities (",t.capabilities.length,")"]}),d?e.jsx(de,{className:"w-3.5 h-3.5"}):e.jsx(oe,{className:"w-3.5 h-3.5"})]}),d&&e.jsxs("div",{className:"px-4 pb-4 pt-3 border-t border-azure-border dark:border-matrix-primary/30 bg-azure-surface/30 dark:bg-zinc-900/30",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.capabilities.map(m=>e.jsx(ge,{cap:m},m))}),t.lastSeen&&e.jsxs("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-tertiary mt-3",children:["Last seen: ",new Date(t.lastSeen).toLocaleString()]})]})]})]})}function O({title:t,initial:l,isEdit:i,onSave:o,onClose:a,saving:d,error:h}){const[s,m]=x.useState(l),[j,p]=x.useState(null),f=()=>{if(!s.name.trim()){p("Name is required.");return}if(!s.host.trim()){p("Host is required.");return}if(!i&&!s.auth_token.trim()){p("Auth token is required.");return}p(null),o(s)};return e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-azure-border dark:border-matrix-primary",children:[e.jsxs("h2",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight flex items-center gap-2",children:[e.jsx(S,{className:"w-4 h-4"}),t]}),e.jsx("button",{onClick:a,className:"text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight transition-colors",children:e.jsx(ce,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"p-5 space-y-3",children:[(j||h)&&e.jsxs("div",{className:"flex items-start gap-2 text-sm text-red-500 bg-red-500/10 border border-red-500/20 rounded p-3",children:[e.jsx(C,{className:"w-4 h-4 shrink-0 mt-0.5"}),e.jsx("span",{children:j||h})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx("div",{className:"col-span-2",children:e.jsx(z,{label:"Name",value:s.name,onChange:c=>m({...s,name:c.target.value}),disabled:i,helperText:i?"Name cannot be changed after creation.":"Unique identifier (lowercase, hyphens ok)."})}),e.jsx(z,{label:"Host",value:s.host,onChange:c=>m({...s,host:c.target.value}),placeholder:"localhost"}),e.jsx(v,{label:"Port",value:s.port,onChange:c=>m({...s,port:Number(c.target.value)}),min:1,max:65535}),e.jsx("div",{className:"col-span-2",children:e.jsx(z,{label:"Auth Token",value:s.auth_token,onChange:c=>m({...s,auth_token:c.target.value}),placeholder:i?"Leave blank to keep existing token":"Shared secret",helperText:i?"Leave blank to keep the current token.":void 0})})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("input",{type:"checkbox",id:"smith-tls",checked:s.tls??!1,onChange:c=>m({...s,tls:c.target.checked}),className:"w-4 h-4 accent-azure-primary dark:accent-matrix-highlight"}),e.jsxs("label",{htmlFor:"smith-tls",className:"text-sm text-azure-text-secondary dark:text-matrix-secondary cursor-pointer",children:["Use TLS (",e.jsx("code",{className:"text-xs font-mono",children:"wss://"}),")"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 px-5 py-4 border-t border-azure-border dark:border-matrix-primary",children:[e.jsx("button",{onClick:a,className:"px-4 py-2 rounded text-sm text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight transition-colors",children:"Cancel"}),e.jsx("button",{onClick:f,disabled:d,className:"px-4 py-2 rounded text-sm font-medium bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:d?"Saving…":i?"Update Smith":"Add Smith"})]})]})})}function we(){const{data:t,mutate:l}=F("/api/smiths",b.getSmithsList,{refreshInterval:1e4}),{data:i,mutate:o}=F("/api/smiths/config",b.getSmithsConfig),[a,d]=x.useState(null),[h,s]=x.useState(!1),[m,j]=x.useState(!1),[p,f]=x.useState(!1),[c,w]=x.useState(null),[_,k]=x.useState(!1),[$,u]=x.useState(null),[N,T]=x.useState(null),[U,M]=x.useState(!1);i&&!a&&d(i);const g=(r,n)=>{T({type:r,message:n}),setTimeout(()=>T(null),4e3)},q=async r=>{try{const n=await b.pingSmith(r);g("success",`Ping ${r}: ${n.latency_ms}ms`)}catch(n){g("error",`Ping failed: ${n.message}`)}},B=async r=>{if(confirm(`Remove Smith "${r}" from the registry?`))try{await b.removeSmith(r),l(),o(),d(null),g("success",`Smith "${r}" removed.`)}catch(n){g("error",`Failed to remove: ${n.message}`)}},G=async r=>{if(a){if(a.entries.some(n=>n.name===r.name)){u(`Smith "${r.name}" already exists.`);return}k(!0),u(null);try{const n={...a,entries:[...a.entries,r]};await b.updateSmithsConfig(n),f(!1),d(null),l(),o(),g("success",`Smith "${r.name}" added.`)}catch(n){u(n.message)}finally{k(!1)}}},W=async r=>{if(a){k(!0),u(null);try{const n={...a,entries:a.entries.map(R=>R.name===r.name?r:R)};await b.updateSmithsConfig(n),w(null),d(null),l(),o(),g("success",`Smith "${r.name}" updated.`)}catch(n){u(n.message)}finally{k(!1)}}},K=async()=>{if(a){j(!0);try{await b.updateSmithsConfig(a),l(),o(),g("success","Settings saved."),s(!1)}catch(r){g("error",r.message)}finally{j(!1)}}},y=t?.smiths??[],L=y.filter(r=>r.state==="online").length,P=y.filter(r=>r.state==="offline"||r.state==="error").length,A=y.filter(r=>r.state==="connecting").length,E={};return(a??i)?.entries?.forEach(r=>{E[r.name]=r}),e.jsxs("div",{className:"space-y-6",children:[N&&e.jsxs("div",{className:`fixed top-4 right-4 z-50 flex items-center gap-2 px-4 py-3 rounded-lg shadow-xl text-sm border ${N.type==="success"?"bg-emerald-50 dark:bg-emerald-900/30 border-emerald-300 dark:border-emerald-500/50 text-emerald-700 dark:text-emerald-400":"bg-red-50 dark:bg-red-900/30 border-red-300 dark:border-red-500/50 text-red-700 dark:text-red-400"}`,children:[N.type==="success"?e.jsx(Y,{className:"w-4 h-4"}):e.jsx(C,{className:"w-4 h-4"}),N.message]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(S,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Smiths"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Remote DevKit agents via WebSocket"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:async()=>{M(!0),await Promise.all([l(),o(),new Promise(r=>setTimeout(r,500))]),M(!1)},className:"p-2 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight transition-colors",title:"Refresh",children:e.jsx(J,{className:`w-4 h-4 transition-transform ${U?"animate-spin":""}`})}),e.jsxs("button",{onClick:()=>{s(!h),!a&&i&&d(i)},className:`flex items-center gap-1.5 px-3 py-2 rounded border text-sm transition-colors ${h?"bg-azure-primary/10 border-azure-primary dark:bg-matrix-highlight/10 dark:border-matrix-highlight text-azure-primary dark:text-matrix-highlight":"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight"}`,children:[e.jsx(D,{className:"w-4 h-4"}),"Settings"]}),e.jsxs("button",{onClick:()=>{f(!0),u(null)},className:"flex items-center gap-1.5 px-3 py-2 rounded bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 text-sm font-medium transition-colors",children:[e.jsx(H,{className:"w-4 h-4"}),"Add Smith"]})]})]}),t&&e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"Total"}),e.jsx("span",{className:"font-semibold text-azure-text dark:text-matrix-secondary",children:t.total})]}),L>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(V,{className:"w-3.5 h-3.5 text-emerald-500"}),e.jsxs("span",{className:"font-semibold text-emerald-500",children:[L," online"]})]}),A>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(I,{className:"w-3.5 h-3.5 text-amber-500"}),e.jsxs("span",{className:"font-semibold text-amber-500",children:[A," connecting"]})]}),P>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(Z,{className:"w-3.5 h-3.5 text-zinc-400 dark:text-matrix-tertiary"}),e.jsxs("span",{className:"font-semibold text-zinc-500 dark:text-matrix-tertiary",children:[P," offline"]})]}),!t.enabled&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-amber-500 bg-amber-500/10 border border-amber-500/30 rounded-full px-2.5 py-0.5",children:[e.jsx(ee,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Smiths subsystem disabled"})]})]}),h&&a&&e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-5 space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h2",{className:"text-sm font-semibold text-azure-text dark:text-matrix-highlight flex items-center gap-2",children:[e.jsx(D,{className:"w-4 h-4"}),"Global Settings"]})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx("div",{className:"sm:col-span-2",children:e.jsx(Q,{label:"Enable Smiths",checked:a.enabled,onChange:r=>d({...a,enabled:r}),helperText:"Master switch — disabling stops all Smith connections."})}),e.jsx(X,{label:"Execution Mode",value:a.execution_mode,onChange:r=>d({...a,execution_mode:r.target.value}),options:[{label:"Sync — inline result",value:"sync"},{label:"Async — background task",value:"async"}]}),e.jsx(v,{label:"Heartbeat Interval (s)",value:Math.round(a.heartbeat_interval_ms/1e3),onChange:r=>d({...a,heartbeat_interval_ms:Number(r.target.value)*1e3}),min:5}),e.jsx(v,{label:"Connection Timeout (s)",value:Math.round(a.connection_timeout_ms/1e3),onChange:r=>d({...a,connection_timeout_ms:Number(r.target.value)*1e3}),min:1}),e.jsx(v,{label:"Task Timeout (s)",value:Math.round(a.task_timeout_ms/1e3),onChange:r=>d({...a,task_timeout_ms:Number(r.target.value)*1e3}),min:5})]}),e.jsx("div",{className:"flex justify-end pt-1",children:e.jsx("button",{onClick:K,disabled:m,className:"px-4 py-2 rounded text-sm font-medium bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:m?"Saving…":"Save Settings"})})]}),y.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary flex items-center justify-center mb-4",children:e.jsx(S,{className:"w-7 h-7 text-azure-text-secondary dark:text-matrix-tertiary"})}),e.jsx("h3",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight mb-1",children:"No Smiths configured"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary mb-4",children:"Add a remote agent to delegate DevKit tasks to isolated environments."}),e.jsxs("button",{onClick:()=>{f(!0),u(null)},className:"flex items-center gap-2 px-4 py-2 rounded bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black text-sm font-medium transition-colors",children:[e.jsx(H,{className:"w-4 h-4"}),"Add First Smith"]})]}):e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:y.map(r=>e.jsx(be,{status:r,entry:E[r.name],onPing:q,onEdit:n=>{w({...n,auth_token:""}),u(null)},onDelete:B},r.name))}),p&&e.jsx(O,{title:"Add Smith",initial:xe,onSave:G,onClose:()=>f(!1),saving:_,error:$}),c&&e.jsx(O,{title:"Edit Smith",initial:c,isEdit:!0,onSave:W,onClose:()=>w(null),saving:_,error:$})]})}export{we as SmithsPage};
|