@goondocks/myco 0.15.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-run-DUOJ3KDI.js → agent-run-T433ENJS.js} +4 -4
- package/dist/{agent-tasks-LUWBY5JD.js → agent-tasks-TAIU3V5I.js} +4 -4
- package/dist/{chunk-DK5VEBB5.js → chunk-2QMDRZPJ.js} +17 -13
- package/dist/chunk-2QMDRZPJ.js.map +1 -0
- package/dist/{chunk-R3YW7XVF.js → chunk-4O3QNM5I.js} +2 -2
- package/dist/{chunk-GZ7MXWYX.js → chunk-6GG2IVNV.js} +2 -2
- package/dist/{chunk-OMZCVRX6.js → chunk-BFM6AM6R.js} +2 -2
- package/dist/{chunk-DKGUCEWU.js → chunk-GCCBXCHF.js} +2 -2
- package/dist/{chunk-B3SF2CCW.js → chunk-TQO4PF5K.js} +2 -2
- package/dist/{cli-YBD2GPK4.js → cli-W37MRZHD.js} +35 -35
- package/dist/{client-CJ3X252K.js → client-YNTTC75R.js} +3 -3
- package/dist/{doctor-JR7NEL7K.js → doctor-PAAQU5AS.js} +5 -5
- package/dist/{executor-7XOKS6HS.js → executor-4OXDK4ZA.js} +359 -72
- package/dist/executor-4OXDK4ZA.js.map +1 -0
- package/dist/{init-PDLKYWQ4.js → init-PHQAQANR.js} +7 -7
- package/dist/{init-wizard-WH3SXNMB.js → init-wizard-RFD46XAJ.js} +2 -2
- package/dist/{llm-DK44LYO6.js → llm-D4VWYUK7.js} +2 -2
- package/dist/{main-JB3R3DQE.js → main-ADLCOYKM.js} +13 -10
- package/dist/{main-JB3R3DQE.js.map → main-ADLCOYKM.js.map} +1 -1
- package/dist/{open-AADZPSLW.js → open-3VPUP3HD.js} +4 -4
- package/dist/{post-compact-KNQ4DYLM.js → post-compact-5NYLOC46.js} +4 -4
- package/dist/{post-tool-use-OMWHFQLM.js → post-tool-use-SNNXSZ5Y.js} +3 -3
- package/dist/{post-tool-use-failure-KFP6MB7Z.js → post-tool-use-failure-POKVXQHY.js} +4 -4
- package/dist/{pre-compact-2ZYE2HRB.js → pre-compact-ZUICBJEX.js} +4 -4
- package/dist/{remove-QT7634L5.js → remove-SVU2V4Q7.js} +4 -4
- package/dist/{restart-YQNQEHOU.js → restart-NBB5CXJ4.js} +5 -5
- package/dist/{search-C6JTQDWY.js → search-YUQZFRZX.js} +4 -4
- package/dist/{server-QJ3RWZZZ.js → server-NBRX56VL.js} +3 -3
- package/dist/{session-JLVL5TYX.js → session-2QP4HMZ5.js} +4 -4
- package/dist/{session-end-XFZRRP5H.js → session-end-NNFBW7CQ.js} +3 -3
- package/dist/{session-start-XGINISXO.js → session-start-NPNP4IXX.js} +3 -3
- package/dist/{setup-llm-X2OCM6R7.js → setup-llm-C3IGFLRN.js} +4 -4
- package/dist/src/cli.js +1 -1
- package/dist/src/daemon/main.js +1 -1
- package/dist/src/hooks/post-tool-use.js +1 -1
- package/dist/src/hooks/session-end.js +1 -1
- package/dist/src/hooks/session-start.js +1 -1
- package/dist/src/hooks/stop.js +1 -1
- package/dist/src/hooks/user-prompt-submit.js +1 -1
- package/dist/src/mcp/server.js +1 -1
- package/dist/{stats-2EAETG2T.js → stats-FEEXIRMS.js} +5 -5
- package/dist/{stop-WOBDYTSA.js → stop-FGDGWXTK.js} +3 -3
- package/dist/{stop-failure-QEC7ZGBQ.js → stop-failure-5YAGH2TQ.js} +4 -4
- package/dist/{subagent-start-H6DVRVOE.js → subagent-start-UCKVJDR4.js} +4 -4
- package/dist/{subagent-stop-LKENKJ65.js → subagent-stop-H25B3QEC.js} +4 -4
- package/dist/{task-completed-ZZ47PRPD.js → task-completed-2JGZN2CF.js} +4 -4
- package/dist/{team-J62N7VMG.js → team-TG5WZXWO.js} +2 -2
- package/dist/ui/assets/{index-Bx9l8uxa.js → index-7Vimyg7g.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/dist/{update-LX3CJ4TJ.js → update-EG3N2EXI.js} +4 -4
- package/dist/{user-prompt-submit-NNMLY3EW.js → user-prompt-submit-7FFQ3ORA.js} +3 -3
- package/dist/{verify-AMRQXQ3K.js → verify-2M3DYHEY.js} +2 -2
- package/dist/{version-6OJH5HLZ.js → version-JUQU5W22.js} +2 -2
- package/package.json +2 -2
- package/dist/chunk-DK5VEBB5.js.map +0 -1
- package/dist/executor-7XOKS6HS.js.map +0 -1
- /package/dist/{agent-run-DUOJ3KDI.js.map → agent-run-T433ENJS.js.map} +0 -0
- /package/dist/{agent-tasks-LUWBY5JD.js.map → agent-tasks-TAIU3V5I.js.map} +0 -0
- /package/dist/{chunk-R3YW7XVF.js.map → chunk-4O3QNM5I.js.map} +0 -0
- /package/dist/{chunk-GZ7MXWYX.js.map → chunk-6GG2IVNV.js.map} +0 -0
- /package/dist/{chunk-OMZCVRX6.js.map → chunk-BFM6AM6R.js.map} +0 -0
- /package/dist/{chunk-DKGUCEWU.js.map → chunk-GCCBXCHF.js.map} +0 -0
- /package/dist/{chunk-B3SF2CCW.js.map → chunk-TQO4PF5K.js.map} +0 -0
- /package/dist/{cli-YBD2GPK4.js.map → cli-W37MRZHD.js.map} +0 -0
- /package/dist/{client-CJ3X252K.js.map → client-YNTTC75R.js.map} +0 -0
- /package/dist/{doctor-JR7NEL7K.js.map → doctor-PAAQU5AS.js.map} +0 -0
- /package/dist/{init-PDLKYWQ4.js.map → init-PHQAQANR.js.map} +0 -0
- /package/dist/{init-wizard-WH3SXNMB.js.map → init-wizard-RFD46XAJ.js.map} +0 -0
- /package/dist/{llm-DK44LYO6.js.map → llm-D4VWYUK7.js.map} +0 -0
- /package/dist/{open-AADZPSLW.js.map → open-3VPUP3HD.js.map} +0 -0
- /package/dist/{post-compact-KNQ4DYLM.js.map → post-compact-5NYLOC46.js.map} +0 -0
- /package/dist/{post-tool-use-OMWHFQLM.js.map → post-tool-use-SNNXSZ5Y.js.map} +0 -0
- /package/dist/{post-tool-use-failure-KFP6MB7Z.js.map → post-tool-use-failure-POKVXQHY.js.map} +0 -0
- /package/dist/{pre-compact-2ZYE2HRB.js.map → pre-compact-ZUICBJEX.js.map} +0 -0
- /package/dist/{remove-QT7634L5.js.map → remove-SVU2V4Q7.js.map} +0 -0
- /package/dist/{restart-YQNQEHOU.js.map → restart-NBB5CXJ4.js.map} +0 -0
- /package/dist/{search-C6JTQDWY.js.map → search-YUQZFRZX.js.map} +0 -0
- /package/dist/{server-QJ3RWZZZ.js.map → server-NBRX56VL.js.map} +0 -0
- /package/dist/{session-JLVL5TYX.js.map → session-2QP4HMZ5.js.map} +0 -0
- /package/dist/{session-end-XFZRRP5H.js.map → session-end-NNFBW7CQ.js.map} +0 -0
- /package/dist/{session-start-XGINISXO.js.map → session-start-NPNP4IXX.js.map} +0 -0
- /package/dist/{setup-llm-X2OCM6R7.js.map → setup-llm-C3IGFLRN.js.map} +0 -0
- /package/dist/{stats-2EAETG2T.js.map → stats-FEEXIRMS.js.map} +0 -0
- /package/dist/{stop-WOBDYTSA.js.map → stop-FGDGWXTK.js.map} +0 -0
- /package/dist/{stop-failure-QEC7ZGBQ.js.map → stop-failure-5YAGH2TQ.js.map} +0 -0
- /package/dist/{subagent-start-H6DVRVOE.js.map → subagent-start-UCKVJDR4.js.map} +0 -0
- /package/dist/{subagent-stop-LKENKJ65.js.map → subagent-stop-H25B3QEC.js.map} +0 -0
- /package/dist/{task-completed-ZZ47PRPD.js.map → task-completed-2JGZN2CF.js.map} +0 -0
- /package/dist/{team-J62N7VMG.js.map → team-TG5WZXWO.js.map} +0 -0
- /package/dist/{update-LX3CJ4TJ.js.map → update-EG3N2EXI.js.map} +0 -0
- /package/dist/{user-prompt-submit-NNMLY3EW.js.map → user-prompt-submit-7FFQ3ORA.js.map} +0 -0
- /package/dist/{verify-AMRQXQ3K.js.map → verify-2M3DYHEY.js.map} +0 -0
- /package/dist/{version-6OJH5HLZ.js.map → version-JUQU5W22.js.map} +0 -0
|
@@ -831,7 +831,7 @@ ${x}`,fullLabel:y.name,type:y.type,degree:f.get(y.id)??0,nodeSize:fte(f.get(y.id
|
|
|
831
831
|
`):void 0;a.mutate({task:e.name,instruction:C},{onSuccess:R=>{f(!1),d({}),m(""),t==null||t(R.runId)}})}function S(w,N){d(C=>({...C,[w]:N}))}return h.jsxs("div",{className:"flex gap-2",children:[h.jsx(_e,{size:"sm",onClick:()=>{f(!0)},children:"Run Now"}),e.source===Kz&&h.jsx(_e,{variant:"outline",size:"sm",onClick:()=>i.mutate({taskId:e.name},{onSuccess:w=>{var C;const N=(C=w==null?void 0:w.task)==null?void 0:C.name;N&&r&&r(N)}}),children:"Customize"}),e.source===A1&&h.jsx(_e,{variant:"destructive",size:"sm",onClick:()=>{l.mutate(e.name,{onSuccess:()=>n==null?void 0:n()})},children:"Delete"}),h.jsx(Nd,{open:o,onOpenChange:f,children:h.jsxs(cc,{className:"sm:max-w-md",children:[h.jsx(kd,{children:h.jsxs(fc,{children:["Run ",e.displayName]})}),h.jsxs("div",{className:"space-y-4 py-2",children:[y.map(w=>h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"font-sans text-sm font-medium text-on-surface",children:kA(w)}),h.jsx(cn,{value:c[w]??"",onChange:N=>S(w,N.target.value),placeholder:yne[w]??`Enter ${kA(w).toLowerCase()}`,className:"font-mono",autoFocus:y.indexOf(w)===0})]},w)),h.jsxs("div",{className:"space-y-1",children:[h.jsxs("label",{className:"font-sans text-sm font-medium text-on-surface",children:["Instruction",h.jsx("span",{className:"ml-1 font-sans text-xs text-on-surface-variant font-normal",children:"(optional)"})]}),h.jsx("textarea",{className:"w-full rounded-md bg-surface-container-lowest border border-[var(--ghost-border)] px-3 py-2 font-sans text-sm text-on-surface placeholder:text-on-surface-variant/50 focus:outline-none focus:border-primary/40 resize-none",rows:2,placeholder:"Additional instructions for this run...",value:p,onChange:w=>m(w.target.value),disabled:a.isPending})]})]}),h.jsxs(Pp,{children:[h.jsx(_e,{variant:"ghost",size:"sm",onClick:()=>f(!1),children:"Cancel"}),h.jsxs(_e,{size:"sm",disabled:a.isPending,onClick:b,className:"gap-2",children:[a.isPending?h.jsx(qn,{className:"h-3.5 w-3.5 animate-spin"}):h.jsx(Zu,{className:"h-3.5 w-3.5"}),"Run"]})]})]})})]})}const wne=20;function Sne({taskId:e,onSaved:t}){const{data:n,isLoading:r,isError:a}=zq(e),i=Iq(),[l,o]=j.useState(""),[f,c]=j.useState(!1);j.useEffect(()=>{n!=null&&n.yaml&&(o(n.yaml),c(!1))},[n==null?void 0:n.yaml]);function d(x){o(x),c(!0)}function p(){i.mutate({taskId:e,yaml:l},{onSuccess:()=>{c(!1),t==null||t()}})}function m(){n!=null&&n.yaml&&(o(n.yaml),c(!1))}if(r)return h.jsx("div",{className:"h-64 animate-pulse rounded-md bg-surface-container-low"});if(a)return h.jsx("div",{className:"rounded-md bg-tertiary-container/20 p-4 font-sans text-sm text-tertiary",children:"Failed to load task YAML."});const y=(n==null?void 0:n.source)!=="user";return h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("h2",{className:"font-sans text-sm font-medium text-on-surface-variant uppercase tracking-wide",children:["Task Definition ",y&&"(read-only)"]}),!y&&h.jsxs("div",{className:"flex gap-2",children:[h.jsx(_e,{variant:"ghost",size:"sm",onClick:m,disabled:!f,children:"Reset"}),h.jsx(_e,{size:"sm",onClick:p,disabled:!f||i.isPending,children:i.isPending?"Saving...":"Save"})]})]}),h.jsx("textarea",{value:l,onChange:x=>d(x.target.value),readOnly:y,rows:wne,spellCheck:!1,className:`w-full rounded-md bg-surface-container-lowest p-4 font-mono text-sm text-on-surface leading-relaxed resize-y focus:outline-none focus:ring-2 focus:ring-primary/40 ${y?"opacity-75 cursor-not-allowed":""}`}),i.isError&&h.jsx("div",{className:"rounded-md bg-tertiary-container/20 p-3 font-sans text-sm text-tertiary",children:i.error.message}),i.isSuccess&&!f&&h.jsx("div",{className:"rounded-md bg-primary-container/20 p-3 font-sans text-sm text-primary",children:"Task saved successfully."})]})}function fl({checked:e,onCheckedChange:t,disabled:n}){return h.jsx("button",{type:"button",role:"switch","aria-checked":e,disabled:n,onClick:()=>t(!e),className:`relative inline-flex h-6 w-11 shrink-0 rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:ring-offset-2 ${n?"cursor-not-allowed opacity-50":"cursor-pointer"} ${e?"bg-primary":"bg-surface-container-high"}`,children:h.jsx("span",{className:`pointer-events-none block h-5 w-5 rounded-full bg-on-surface shadow-lg ring-0 transition-transform ${e?"translate-x-5":"translate-x-0"}`})})}const X_=3e4;function Ene(e){return tn({queryKey:["task-config",e],queryFn:({signal:t})=>ot(`/agent/tasks/${e}/config`,{signal:t}),enabled:e!==void 0,staleTime:X_})}function Cne(){return tn({queryKey:["providers"],queryFn:({signal:e})=>ot("/providers",{signal:e}),staleTime:X_})}function Nne(){return br({mutationFn:e=>kn("/providers/test",e)})}function kne(){const e=Vn();return br({mutationFn:({taskId:t,config:n})=>oc(`/agent/tasks/${t}/config`,n),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["task-config",n.taskId]})}})}const Tne={cloud:"Anthropic Cloud",ollama:"Ollama",lmstudio:"LM Studio"},jne={cloud:uz,ollama:jz,lmstudio:N1};function Q_({providerType:e,model:t,baseUrl:n,contextLength:r,modelPlaceholder:a,providers:i,isLoadingProviders:l,onProviderChange:o,onModelChange:f,onBaseUrlChange:c,onContextLengthChange:d}){const p=i.find(x=>x.type===e),m=e==="ollama"||e==="lmstudio",y=(p==null?void 0:p.models)??[];return h.jsxs("div",{className:"space-y-3",children:[h.jsx("div",{className:"grid grid-cols-3 gap-2",children:["cloud","ollama","lmstudio"].map(x=>{const b=jne[x],S=i.find(N=>N.type===x),w=e===x;return b?h.jsxs("button",{onClick:()=>o(x),className:`
|
|
832
832
|
flex flex-col items-center gap-1.5 rounded-md border px-3 py-2.5 transition-colors
|
|
833
833
|
${w?"border-primary/40 bg-primary/5 text-on-surface":"border-[var(--ghost-border)] bg-surface-container-lowest text-on-surface-variant hover:border-primary/20"}
|
|
834
|
-
`,children:[h.jsx(b,{className:"h-4 w-4"}),h.jsx("span",{className:"font-sans text-xs font-medium",children:Tne[x]}),!l&&h.jsx(Ct,{variant:S!=null&&S.available?"secondary":"destructive",className:"text-[10px] px-1.5 py-0",children:S!=null&&S.available?"online":"offline"})]},x):null})}),m&&h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Base URL"}),h.jsx(cn,{value:n,onChange:x=>c(x.target.value),placeholder:(p==null?void 0:p.baseUrl)??""})]}),m&&h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Context Length"}),h.jsx(cn,{type:"number",value:r,onChange:x=>d(x.target.value),placeholder:"32768"})]}),h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Model"}),y.length>0?h.jsxs(Zi,{value:t,onValueChange:f,children:[h.jsx(vi,{children:h.jsx(Ji,{placeholder:a??"Select a model"})}),h.jsx(pi,{children:y.map(x=>h.jsx(ia,{value:x,children:h.jsx("span",{className:"font-mono text-sm",children:x})},x))})]}):h.jsx(cn,{value:t,onChange:x=>f(x.target.value),placeholder:(p==null?void 0:p.available)===!1?"Provider offline":"Enter model name",disabled:(p==null?void 0:p.available)===!1})]})]})}function Ane({phase:e,override:t,taskModel:n,providers:r,isLoadingProviders:a,onChange:i}){var c,d,p,m;const[l,o]=j.useState(!1),f=t.provider!==void 0||t.model!==void 0||t.maxTurns!==void 0;return h.jsxs("div",{className:"border border-[var(--ghost-border)] rounded-md",children:[h.jsxs("button",{onClick:()=>o(!l),className:"flex items-center gap-2 w-full px-3 py-2 text-left hover:bg-surface-container-low/50 transition-colors rounded-md",children:[l?h.jsx(Ua,{className:"h-3.5 w-3.5 text-on-surface-variant"}):h.jsx(ua,{className:"h-3.5 w-3.5 text-on-surface-variant"}),h.jsx("span",{className:"font-sans text-sm text-on-surface",children:e.name}),h.jsxs("span",{className:"font-mono text-xs text-on-surface-variant",children:["max ",t.maxTurns??e.maxTurns," turns"]}),f&&h.jsx(Ct,{variant:"secondary",className:"text-[10px] ml-auto",children:"override"})]}),l&&h.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-[var(--ghost-border)]",children:[h.jsx("div",{className:"pt-3",children:h.jsx(Q_,{providerType:((c=t.provider)==null?void 0:c.type)??"cloud",model:((d=t.provider)==null?void 0:d.model)??t.model??"",baseUrl:((p=t.provider)==null?void 0:p.base_url)??"",contextLength:((m=t.provider)==null?void 0:m.context_length)!=null?String(t.provider.context_length):"",modelPlaceholder:e.model??n,providers:r,isLoadingProviders:a,onProviderChange:y=>{var b;const x=(b=r.find(S=>S.type===y))==null?void 0:b.baseUrl;i({...t,provider:{type:y,base_url:x},model:void 0})},onModelChange:y=>i({...t,provider:t.provider?{...t.provider,model:y}:void 0,model:t.provider?void 0:y}),onBaseUrlChange:y=>i({...t,provider:t.provider?{...t.provider,base_url:y}:void 0}),onContextLengthChange:y=>i({...t,provider:t.provider?{...t.provider,context_length:y?Number(y):void 0}:void 0})})}),h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Max Turns"}),h.jsx(cn,{type:"number",value:t.maxTurns??"",onChange:y=>i({...t,maxTurns:y.target.value?Number(y.target.value):void 0}),placeholder:String(e.maxTurns)})]}),f&&h.jsx(_e,{variant:"ghost",size:"sm",onClick:()=>i(null),className:"text-xs text-on-surface-variant",children:"Clear Phase Override"})]})]})}const Rne=["active","idle","sleep"],Dne={active:"Active",idle:"Idle",sleep:"Sleep"};function Mne({taskId:e,phases:t,defaults:n,schedule:r,params:a}){const{data:i,isPending:l}=Cne(),{data:o}=Ene(e),f=Nne(),c=kne(),d=o==null?void 0:o.config,[p,m]=j.useState("cloud"),[y,x]=j.useState(""),[b,S]=j.useState(""),[w,N]=j.useState(""),[C,T]=j.useState(""),[R,A]=j.useState(""),[D,L]=j.useState({}),[B,M]=j.useState({}),[_,P]=j.useState({}),[H,$]=j.useState(!1);j.useEffect(()=>{var z,W,re,ae;d&&(m(((z=d.provider)==null?void 0:z.type)??"cloud"),x(((W=d.provider)==null?void 0:W.model)??d.model??""),S(((re=d.provider)==null?void 0:re.base_url)??""),N(((ae=d.provider)==null?void 0:ae.context_length)!=null?String(d.provider.context_length):""),T(d.maxTurns!=null?String(d.maxTurns):""),A(d.timeoutSeconds!=null?String(d.timeoutSeconds):""),L(d.phases??{}),M(d.schedule??{}),P(d.params??{}),$(!1))},[d]);const V=B.enabled??(r==null?void 0:r.enabled)??!1,I=B.runIn??(r==null?void 0:r.runIn)??[],U=(i==null?void 0:i.providers)??[];function Y(z){var W;m(z),x(""),S(((W=U.find(re=>re.type===z))==null?void 0:W.baseUrl)??""),N(""),$(!0),f.reset()}function Q(z,W){L(re=>{const ae={...re};return W===null?delete ae[z]:ae[z]=W,ae}),$(!0)}function F(){const z=p==="ollama"||p==="lmstudio",W={type:p,...y?{model:y}:{},...z&&b?{base_url:b}:{},...z&&w?{context_length:Number(w)}:{}},re=r?Object.keys(B).length>0?{schedule:B}:{schedule:null}:{},ae=a&&Object.keys(_).length>0?{params:_}:{};c.mutate({taskId:e,config:{provider:W,...C?{maxTurns:Number(C)}:{maxTurns:null},...R?{timeoutSeconds:Number(R)}:{timeoutSeconds:null},...Object.keys(D).length>0?{phases:D}:{phases:null},...re,...ae}},{onSuccess:()=>$(!1)})}function q(){c.mutate({taskId:e,config:{provider:null,model:null,maxTurns:null,timeoutSeconds:null,phases:null,schedule:null,params:null}},{onSuccess:()=>{m("cloud"),x(""),S(""),N(""),T(""),A(""),L({}),M({}),P({}),$(!1)}})}function X(){const W={type:p,...(p==="ollama"||p==="lmstudio")&&b?{base_url:b}:{}};f.mutate(W)}return h.jsxs(Qe,{level:"low",className:"p-4 space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("h2",{className:"font-sans text-sm font-medium text-on-surface-variant uppercase tracking-wide",children:"Task Config"}),d&&h.jsx(_e,{variant:"ghost",size:"sm",onClick:q,className:"text-xs text-on-surface-variant",children:"Clear All Overrides"})]}),h.jsx(Q_,{providerType:p,model:y,baseUrl:b,contextLength:w,modelPlaceholder:n==null?void 0:n.model,providers:U,isLoadingProviders:l,onProviderChange:Y,onModelChange:z=>{x(z),$(!0)},onBaseUrlChange:z=>{S(z),$(!0)},onContextLengthChange:z=>{N(z),$(!0)}}),h.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Max Turns"}),h.jsx(cn,{type:"number",value:C,onChange:z=>{T(z.target.value),$(!0)},placeholder:(n==null?void 0:n.maxTurns)!=null?String(n.maxTurns):"—"})]}),h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Timeout (seconds)"}),h.jsx(cn,{type:"number",value:R,onChange:z=>{A(z.target.value),$(!0)},placeholder:(n==null?void 0:n.timeoutSeconds)!=null?String(n.timeoutSeconds):"—"})]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(_e,{variant:"ghost",size:"sm",onClick:X,disabled:f.isPending,className:"gap-1.5 text-on-surface-variant",children:[f.isPending?h.jsx(qn,{className:"h-3.5 w-3.5 animate-spin"}):h.jsx(Iz,{className:"h-3.5 w-3.5"}),"Test"]}),f.isSuccess&&h.jsx("span",{className:"flex items-center gap-1 text-xs",children:f.data.ok?h.jsxs(h.Fragment,{children:[h.jsx(Sd,{className:"h-3.5 w-3.5 text-green-500"}),h.jsxs("span",{className:"text-green-500 font-mono",children:[f.data.latency_ms,"ms"]})]}):h.jsxs(h.Fragment,{children:[h.jsx(Ed,{className:"h-3.5 w-3.5 text-red-400"}),h.jsx("span",{className:"text-red-400",children:f.data.error})]})}),h.jsx("div",{className:"flex-1"}),h.jsxs(_e,{size:"sm",onClick:F,disabled:!H||c.isPending,className:"gap-1.5",children:[c.isPending&&h.jsx(qn,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]}),r&&h.jsxs("div",{className:"space-y-3 pt-2 border-t border-[var(--ghost-border)]",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(BR,{className:"h-3.5 w-3.5 text-on-surface-variant"}),h.jsx("h3",{className:"font-sans text-xs font-medium text-on-surface-variant uppercase tracking-wide",children:"Scheduling"}),h.jsx(Ct,{variant:V?"secondary":"outline",className:"text-[10px] px-1.5 py-0",children:V?"active":"off"})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"space-y-0.5",children:[h.jsx("label",{className:"font-sans text-xs text-on-surface",children:"Auto-run"}),h.jsx("p",{className:"font-sans text-[11px] text-on-surface-variant",children:"Automatically run this task on a schedule"})]}),h.jsx(fl,{checked:V,onCheckedChange:z=>{M(W=>({...W,enabled:z})),$(!0)}})]}),V&&h.jsxs("div",{className:"space-y-3 pl-0.5",children:[h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Run every (seconds)"}),h.jsx(cn,{type:"number",min:10,value:B.intervalSeconds??"",onChange:z=>{const W=z.target.value;M(re=>({...re,intervalSeconds:W?Number(W):void 0})),$(!0)},placeholder:r.intervalSeconds!=null?String(r.intervalSeconds):"300"})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Run in states"}),h.jsx("div",{className:"flex gap-2",children:Rne.map(z=>{const W=I.includes(z);return h.jsx("button",{onClick:()=>{const re=W?I.filter(ae=>ae!==z):[...I,z];M(ae=>({...ae,runIn:re.length>0?re:void 0})),$(!0)},className:`
|
|
834
|
+
`,children:[h.jsx(b,{className:"h-4 w-4"}),h.jsx("span",{className:"font-sans text-xs font-medium",children:Tne[x]}),!l&&h.jsx(Ct,{variant:S!=null&&S.available?"secondary":"destructive",className:"text-[10px] px-1.5 py-0",children:S!=null&&S.available?"online":"offline"})]},x):null})}),m&&h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Base URL"}),h.jsx(cn,{value:n,onChange:x=>c(x.target.value),placeholder:(p==null?void 0:p.baseUrl)??""})]}),m&&h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Context Length"}),h.jsx(cn,{type:"number",value:r,onChange:x=>d(x.target.value),placeholder:"32768 (default)"}),h.jsx("p",{className:"font-sans text-[11px] text-on-surface-variant/70",children:"Leave blank to use the 32K default. Myco creates a Modelfile variant at this size so the model loads at the size you asked for, not its (much larger) native default."})]}),h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Model"}),y.length>0?h.jsxs(Zi,{value:t,onValueChange:f,children:[h.jsx(vi,{children:h.jsx(Ji,{placeholder:a??"Select a model"})}),h.jsx(pi,{children:y.map(x=>h.jsx(ia,{value:x,children:h.jsx("span",{className:"font-mono text-sm",children:x})},x))})]}):h.jsx(cn,{value:t,onChange:x=>f(x.target.value),placeholder:(p==null?void 0:p.available)===!1?"Provider offline":"Enter model name",disabled:(p==null?void 0:p.available)===!1})]})]})}function Ane({phase:e,override:t,taskModel:n,providers:r,isLoadingProviders:a,onChange:i}){var c,d,p,m;const[l,o]=j.useState(!1),f=t.provider!==void 0||t.model!==void 0||t.maxTurns!==void 0;return h.jsxs("div",{className:"border border-[var(--ghost-border)] rounded-md",children:[h.jsxs("button",{onClick:()=>o(!l),className:"flex items-center gap-2 w-full px-3 py-2 text-left hover:bg-surface-container-low/50 transition-colors rounded-md",children:[l?h.jsx(Ua,{className:"h-3.5 w-3.5 text-on-surface-variant"}):h.jsx(ua,{className:"h-3.5 w-3.5 text-on-surface-variant"}),h.jsx("span",{className:"font-sans text-sm text-on-surface",children:e.name}),h.jsxs("span",{className:"font-mono text-xs text-on-surface-variant",children:["max ",t.maxTurns??e.maxTurns," turns"]}),f&&h.jsx(Ct,{variant:"secondary",className:"text-[10px] ml-auto",children:"override"})]}),l&&h.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-[var(--ghost-border)]",children:[h.jsx("div",{className:"pt-3",children:h.jsx(Q_,{providerType:((c=t.provider)==null?void 0:c.type)??"cloud",model:((d=t.provider)==null?void 0:d.model)??t.model??"",baseUrl:((p=t.provider)==null?void 0:p.base_url)??"",contextLength:((m=t.provider)==null?void 0:m.context_length)!=null?String(t.provider.context_length):"",modelPlaceholder:e.model??n,providers:r,isLoadingProviders:a,onProviderChange:y=>{var b;const x=(b=r.find(S=>S.type===y))==null?void 0:b.baseUrl;i({...t,provider:{type:y,base_url:x},model:void 0})},onModelChange:y=>i({...t,provider:t.provider?{...t.provider,model:y}:void 0,model:t.provider?void 0:y}),onBaseUrlChange:y=>i({...t,provider:t.provider?{...t.provider,base_url:y}:void 0}),onContextLengthChange:y=>i({...t,provider:t.provider?{...t.provider,context_length:y?Number(y):void 0}:void 0})})}),h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Max Turns"}),h.jsx(cn,{type:"number",value:t.maxTurns??"",onChange:y=>i({...t,maxTurns:y.target.value?Number(y.target.value):void 0}),placeholder:String(e.maxTurns)})]}),f&&h.jsx(_e,{variant:"ghost",size:"sm",onClick:()=>i(null),className:"text-xs text-on-surface-variant",children:"Clear Phase Override"})]})]})}const Rne=["active","idle","sleep"],Dne={active:"Active",idle:"Idle",sleep:"Sleep"};function Mne({taskId:e,phases:t,defaults:n,schedule:r,params:a}){const{data:i,isPending:l}=Cne(),{data:o}=Ene(e),f=Nne(),c=kne(),d=o==null?void 0:o.config,[p,m]=j.useState("cloud"),[y,x]=j.useState(""),[b,S]=j.useState(""),[w,N]=j.useState(""),[C,T]=j.useState(""),[R,A]=j.useState(""),[D,L]=j.useState({}),[B,M]=j.useState({}),[_,P]=j.useState({}),[H,$]=j.useState(!1);j.useEffect(()=>{var z,W,re,ae;d&&(m(((z=d.provider)==null?void 0:z.type)??"cloud"),x(((W=d.provider)==null?void 0:W.model)??d.model??""),S(((re=d.provider)==null?void 0:re.base_url)??""),N(((ae=d.provider)==null?void 0:ae.context_length)!=null?String(d.provider.context_length):""),T(d.maxTurns!=null?String(d.maxTurns):""),A(d.timeoutSeconds!=null?String(d.timeoutSeconds):""),L(d.phases??{}),M(d.schedule??{}),P(d.params??{}),$(!1))},[d]);const V=B.enabled??(r==null?void 0:r.enabled)??!1,I=B.runIn??(r==null?void 0:r.runIn)??[],U=(i==null?void 0:i.providers)??[];function Y(z){var W;m(z),x(""),S(((W=U.find(re=>re.type===z))==null?void 0:W.baseUrl)??""),N(""),$(!0),f.reset()}function Q(z,W){L(re=>{const ae={...re};return W===null?delete ae[z]:ae[z]=W,ae}),$(!0)}function F(){const z=p==="ollama"||p==="lmstudio",W={type:p,...y?{model:y}:{},...z&&b?{base_url:b}:{},...z&&w?{context_length:Number(w)}:{}},re=r?Object.keys(B).length>0?{schedule:B}:{schedule:null}:{},ae=a&&Object.keys(_).length>0?{params:_}:{};c.mutate({taskId:e,config:{provider:W,...C?{maxTurns:Number(C)}:{maxTurns:null},...R?{timeoutSeconds:Number(R)}:{timeoutSeconds:null},...Object.keys(D).length>0?{phases:D}:{phases:null},...re,...ae}},{onSuccess:()=>$(!1)})}function q(){c.mutate({taskId:e,config:{provider:null,model:null,maxTurns:null,timeoutSeconds:null,phases:null,schedule:null,params:null}},{onSuccess:()=>{m("cloud"),x(""),S(""),N(""),T(""),A(""),L({}),M({}),P({}),$(!1)}})}function X(){const W={type:p,...(p==="ollama"||p==="lmstudio")&&b?{base_url:b}:{}};f.mutate(W)}return h.jsxs(Qe,{level:"low",className:"p-4 space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("h2",{className:"font-sans text-sm font-medium text-on-surface-variant uppercase tracking-wide",children:"Task Config"}),d&&h.jsx(_e,{variant:"ghost",size:"sm",onClick:q,className:"text-xs text-on-surface-variant",children:"Clear All Overrides"})]}),h.jsx(Q_,{providerType:p,model:y,baseUrl:b,contextLength:w,modelPlaceholder:n==null?void 0:n.model,providers:U,isLoadingProviders:l,onProviderChange:Y,onModelChange:z=>{x(z),$(!0)},onBaseUrlChange:z=>{S(z),$(!0)},onContextLengthChange:z=>{N(z),$(!0)}}),h.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Max Turns"}),h.jsx(cn,{type:"number",value:C,onChange:z=>{T(z.target.value),$(!0)},placeholder:(n==null?void 0:n.maxTurns)!=null?String(n.maxTurns):"—"})]}),h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Timeout (seconds)"}),h.jsx(cn,{type:"number",value:R,onChange:z=>{A(z.target.value),$(!0)},placeholder:(n==null?void 0:n.timeoutSeconds)!=null?String(n.timeoutSeconds):"—"})]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(_e,{variant:"ghost",size:"sm",onClick:X,disabled:f.isPending,className:"gap-1.5 text-on-surface-variant",children:[f.isPending?h.jsx(qn,{className:"h-3.5 w-3.5 animate-spin"}):h.jsx(Iz,{className:"h-3.5 w-3.5"}),"Test"]}),f.isSuccess&&h.jsx("span",{className:"flex items-center gap-1 text-xs",children:f.data.ok?h.jsxs(h.Fragment,{children:[h.jsx(Sd,{className:"h-3.5 w-3.5 text-green-500"}),h.jsxs("span",{className:"text-green-500 font-mono",children:[f.data.latency_ms,"ms"]})]}):h.jsxs(h.Fragment,{children:[h.jsx(Ed,{className:"h-3.5 w-3.5 text-red-400"}),h.jsx("span",{className:"text-red-400",children:f.data.error})]})}),h.jsx("div",{className:"flex-1"}),h.jsxs(_e,{size:"sm",onClick:F,disabled:!H||c.isPending,className:"gap-1.5",children:[c.isPending&&h.jsx(qn,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]}),r&&h.jsxs("div",{className:"space-y-3 pt-2 border-t border-[var(--ghost-border)]",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(BR,{className:"h-3.5 w-3.5 text-on-surface-variant"}),h.jsx("h3",{className:"font-sans text-xs font-medium text-on-surface-variant uppercase tracking-wide",children:"Scheduling"}),h.jsx(Ct,{variant:V?"secondary":"outline",className:"text-[10px] px-1.5 py-0",children:V?"active":"off"})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"space-y-0.5",children:[h.jsx("label",{className:"font-sans text-xs text-on-surface",children:"Auto-run"}),h.jsx("p",{className:"font-sans text-[11px] text-on-surface-variant",children:"Automatically run this task on a schedule"})]}),h.jsx(fl,{checked:V,onCheckedChange:z=>{M(W=>({...W,enabled:z})),$(!0)}})]}),V&&h.jsxs("div",{className:"space-y-3 pl-0.5",children:[h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Run every (seconds)"}),h.jsx(cn,{type:"number",min:10,value:B.intervalSeconds??"",onChange:z=>{const W=z.target.value;M(re=>({...re,intervalSeconds:W?Number(W):void 0})),$(!0)},placeholder:r.intervalSeconds!=null?String(r.intervalSeconds):"300"})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsx("label",{className:"font-sans text-xs text-on-surface-variant",children:"Run in states"}),h.jsx("div",{className:"flex gap-2",children:Rne.map(z=>{const W=I.includes(z);return h.jsx("button",{onClick:()=>{const re=W?I.filter(ae=>ae!==z):[...I,z];M(ae=>({...ae,runIn:re.length>0?re:void 0})),$(!0)},className:`
|
|
835
835
|
rounded-md border px-3 py-1.5 font-sans text-xs font-medium transition-colors
|
|
836
836
|
${W?"border-primary/40 bg-primary/5 text-on-surface":"border-[var(--ghost-border)] bg-surface-container-lowest text-on-surface-variant hover:border-primary/20"}
|
|
837
837
|
`,children:Dne[z]},z)})})]})]})]}),a&&Object.keys(a).length>0&&h.jsxs("div",{className:"space-y-3 pt-2 border-t border-[var(--ghost-border)]",children:[h.jsx("h3",{className:"font-sans text-sm font-medium text-on-surface-variant uppercase tracking-wide",children:"Parameters"}),Object.entries(a).map(([z,W])=>{const re=_[z],ae=re??W,ie=z.replace(/_/g," ").replace(/\b\w/g,ye=>ye.toUpperCase());return typeof W=="boolean"?h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("label",{className:"font-sans text-sm text-on-surface",children:ie}),h.jsx(fl,{checked:ae,onCheckedChange:ye=>{P(ue=>({...ue,[z]:ye})),$(!0)}})]},z):h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"font-sans text-sm text-on-surface",children:ie}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(cn,{type:typeof W=="number"?"number":"text",value:re!=null?String(re):"",placeholder:String(W),onChange:ye=>{const ue=typeof W=="number"?ye.target.value===""?void 0:Number(ye.target.value):ye.target.value;P(ue===void 0?ee=>{const ne={...ee};return delete ne[z],ne}:ee=>({...ee,[z]:ue})),$(!0)},className:"w-40 font-mono"}),h.jsxs("span",{className:"font-sans text-xs text-on-surface-variant",children:["default: ",String(W)]})]})]},z)})]}),t&&t.length>0&&h.jsxs("div",{className:"space-y-2 pt-2 border-t border-[var(--ghost-border)]",children:[h.jsx("h3",{className:"font-sans text-xs font-medium text-on-surface-variant uppercase tracking-wide",children:"Per-Phase Overrides"}),t.map(z=>h.jsx(Ane,{phase:z,override:D[z.name]??{},taskModel:y||"claude-sonnet-4-6",providers:U,isLoadingProviders:l,onChange:W=>Q(z.name,W)},z.name))]})]})}const One=3;function Lne(e){var t,n,r;return{model:((t=e.execution)==null?void 0:t.model)??e.model,maxTurns:((n=e.execution)==null?void 0:n.maxTurns)??e.maxTurns,timeoutSeconds:((r=e.execution)==null?void 0:r.timeoutSeconds)??e.timeoutSeconds}}function _ne(){return h.jsxs("div",{className:"space-y-6",children:[h.jsx("div",{className:"h-8 w-24 animate-pulse rounded bg-surface-container-high"}),h.jsxs("div",{className:"rounded-md bg-surface-container-low p-4 space-y-3",children:[h.jsx("div",{className:"h-6 w-48 animate-pulse rounded bg-surface-container-high"}),h.jsx("div",{className:"h-4 w-64 animate-pulse rounded bg-surface-container-high"}),h.jsx("div",{className:"h-8 w-32 animate-pulse rounded bg-surface-container-high"})]}),h.jsx("div",{className:"rounded-md bg-surface-container-low p-4 space-y-2",children:Array.from({length:One}).map((e,t)=>h.jsx("div",{className:"h-5 animate-pulse rounded bg-surface-container-high"},t))})]})}function Bne({phase:e,index:t}){return h.jsxs(Qe,{level:"low",className:"p-4 space-y-3",children:[h.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-surface-container-high font-mono text-xs font-semibold text-on-surface-variant shrink-0",children:t+1}),h.jsx("span",{className:"font-sans text-sm font-medium text-on-surface",children:e.name}),!e.required&&h.jsx(Ct,{variant:"secondary",children:"optional"})]}),h.jsxs("span",{className:"font-mono text-xs text-on-surface-variant shrink-0",children:["max ",e.maxTurns," turns"]})]}),e.tools.length>0&&h.jsx("div",{className:"flex flex-wrap gap-1",children:e.tools.map(n=>h.jsx("span",{className:"font-mono text-xs px-1.5 py-0.5 rounded-sm bg-surface-container-high text-on-surface-variant",children:n},n))}),h.jsx(Qe,{level:"lowest",className:"p-3 overflow-auto max-h-40",children:h.jsx(Ma,{content:e.prompt})})]})}function Pne({taskId:e,onBack:t,onNavigate:n,onRunTriggered:r}){const{data:a,isPending:i,isError:l}=_q(e);if(i)return h.jsx(_ne,{});if(l||!(a!=null&&a.task))return h.jsxs("div",{className:"space-y-4",children:[h.jsxs(_e,{variant:"ghost",size:"sm",onClick:t,className:"gap-2 text-on-surface-variant",children:[h.jsx(di,{className:"h-4 w-4"}),"Tasks"]}),h.jsxs("div",{className:"flex h-40 flex-col items-center justify-center gap-2 text-tertiary",children:[h.jsx(Ar,{className:"h-5 w-5"}),h.jsx("span",{className:"font-sans text-sm",children:"Task not found"})]})]});const o=a.task,f=o.phases??[],c=Lne(o);return h.jsxs("div",{className:"space-y-6",children:[h.jsxs(_e,{variant:"ghost",size:"sm",onClick:t,className:"gap-2 text-on-surface-variant",children:[h.jsx(di,{className:"h-4 w-4"}),"Tasks"]}),h.jsxs(Qe,{level:"low",className:"p-4 space-y-4",children:[h.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[h.jsxs("div",{className:"flex-1 space-y-1 min-w-0",children:[h.jsx("h1",{className:"font-serif text-lg text-on-surface",children:o.displayName}),o.description&&h.jsx("p",{className:"font-sans text-sm text-on-surface-variant",children:o.description})]}),h.jsx(Ct,{variant:GD(o.source),className:"shrink-0",children:$1(o.source??"built-in")})]}),h.jsx(bne,{task:o,onDeleted:t,onCustomized:d=>n==null?void 0:n(d),onRunTriggered:r})]}),h.jsx(Mne,{taskId:e,phases:f,defaults:{model:c.model,maxTurns:c.maxTurns,timeoutSeconds:c.timeoutSeconds},schedule:o.schedule,params:o.params}),(c.model!==void 0||c.maxTurns!==void 0||c.timeoutSeconds!==void 0)&&h.jsxs(Qe,{level:"low",className:"p-4 space-y-3",children:[h.jsx("h2",{className:"font-sans text-sm font-medium text-on-surface-variant uppercase tracking-wide",children:"Execution Config"}),h.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[c.model!==void 0&&h.jsxs("div",{children:[h.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Model"}),h.jsx("p",{className:"font-mono text-sm text-on-surface mt-0.5",children:c.model})]}),c.maxTurns!==void 0&&h.jsxs("div",{children:[h.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Max Turns"}),h.jsx("p",{className:"font-mono text-sm text-on-surface mt-0.5",children:c.maxTurns})]}),c.timeoutSeconds!==void 0&&h.jsxs("div",{children:[h.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Timeout"}),h.jsxs("p",{className:"font-mono text-sm text-on-surface mt-0.5",children:[c.timeoutSeconds,"s"]})]})]})]}),f.length>0?h.jsxs("div",{className:"space-y-3",children:[h.jsxs("h2",{className:"font-sans text-sm font-medium text-on-surface-variant uppercase tracking-wide",children:["Phases",h.jsxs("span",{className:"ml-2 text-on-surface normal-case font-normal",children:[f.length," ",f.length===1?"phase":"phases"]})]}),f.map((d,p)=>h.jsx(Bne,{phase:d,index:p},d.name))]}):h.jsxs("div",{className:"space-y-3",children:[h.jsx("h2",{className:"font-sans text-sm font-medium text-on-surface-variant uppercase tracking-wide",children:"Prompt"}),h.jsx(Qe,{level:"lowest",className:"p-4 overflow-auto max-h-96",children:h.jsx(Ma,{content:o.prompt??""})})]}),h.jsx(Sne,{taskId:e})]})}function W_(e,t){var n,r,a;return{summaryBatchInterval:String(((n=e.agent)==null?void 0:n.summary_batch_interval)??pb),defaultTask:t??"",scheduledTasksEnabled:((r=e.agent)==null?void 0:r.scheduled_tasks_enabled)??!0,eventTasksEnabled:((a=e.agent)==null?void 0:a.event_tasks_enabled)??!0}}function zne(e,t,n){const r=W_(t,n);return e.summaryBatchInterval!==r.summaryBatchInterval||e.defaultTask!==r.defaultTask||e.scheduledTasksEnabled!==r.scheduledTasksEnabled||e.eventTasksEnabled!==r.eventTasksEnabled}function TA({label:e,value:t,max:n,color:r}){const a=n>0?Math.round(t/n*100):0,i=2*Math.PI*36,l=i-a/100*i;return h.jsxs("div",{className:"flex flex-col items-center gap-2",children:[h.jsxs("div",{className:"relative h-20 w-20",children:[h.jsxs("svg",{className:"h-20 w-20 -rotate-90",viewBox:"0 0 80 80",children:[h.jsx("circle",{cx:"40",cy:"40",r:"36",fill:"none",stroke:"currentColor",className:"text-surface-container/30",strokeWidth:"6"}),h.jsx("circle",{cx:"40",cy:"40",r:"36",fill:"none",stroke:r,strokeWidth:"6",strokeLinecap:"round",strokeDasharray:i,strokeDashoffset:l,className:"transition-all duration-700"})]}),h.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:h.jsxs("span",{className:"text-sm font-semibold font-mono text-on-surface",children:[a,"%"]})})]}),h.jsx("span",{className:"text-xs text-on-surface-variant text-center font-sans",children:e})]})}function Vi({label:e,value:t}){return h.jsxs("div",{className:"flex items-center justify-between py-1",children:[h.jsx("span",{className:"text-xs text-on-surface-variant font-sans",children:e}),h.jsx("span",{className:"text-xs font-mono text-on-surface",children:t})]})}function Ine({stats:e}){const t=e.embedding.total_embeddable>0?e.embedding.embedded_count:0,n=e.embedding.total_embeddable;return h.jsxs("div",{className:"space-y-4",children:[h.jsxs("h2",{className:"text-xs font-semibold text-on-surface-variant uppercase tracking-widest flex items-center gap-2 font-sans",children:[h.jsx(db,{className:"h-3.5 w-3.5"}),"System Health"]}),h.jsxs("div",{className:"flex justify-center gap-8 py-2",children:[h.jsx(TA,{label:"Embedding Coverage",value:t,max:n,color:"#abcfb8"}),h.jsx(TA,{label:"Queue Health",value:Math.max(0,n-e.embedding.queue_depth),max:n,color:"#edbf7f"})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-0",children:[h.jsx(Vi,{label:"Sessions",value:String(e.vault.session_count)}),h.jsx(Vi,{label:"Spores",value:String(e.vault.spore_count)}),h.jsx(Vi,{label:"Entities",value:String(e.vault.entity_count)}),h.jsx(Vi,{label:"Graph edges",value:String(e.vault.edge_count)}),h.jsx(Vi,{label:"Uptime",value:V1(e.daemon.uptime_seconds)}),h.jsx(Vi,{label:"Daemon",value:`v${e.daemon.version} :${e.daemon.port}`}),e.agent.last_run_at!==null&&h.jsxs(h.Fragment,{children:[h.jsx(Vi,{label:"Last run",value:gi(e.agent.last_run_at)}),h.jsx(Vi,{label:"Total runs",value:String(e.agent.total_runs)})]}),e.digest.freshest_tier!==null&&h.jsx(Vi,{label:"Digest tier",value:`T${e.digest.freshest_tier}`})]})]})}function Fne(){var L;const{config:e,isLoading:t,saveConfig:n,isSaving:r}=Ip(),{data:a,isLoading:i}=Dp(),{data:l,isLoading:o}=dc(),{restart:f}=M1(),[c,d]=j.useState(null),[p,m]=j.useState(null),[y,x]=j.useState("idle"),[b,S]=j.useState(""),w=(l==null?void 0:l.tasks)??[],N=((L=w.find(B=>B.isDefault))==null?void 0:L.name)??"",C=j.useRef(!1);e&&!o&&!C.current&&(C.current=!0,c===null&&d(W_(e,N)));const T=c&&e?zne(c,e,N):!1,R=j.useCallback((B,M)=>{d(_=>_&&{..._,[B]:M}),m(null)},[]),A=async()=>{if(!(!c||!e)){m(null);try{const B={...e,agent:{...e.agent,summary_batch_interval:Sb(c.summaryBatchInterval,pb),scheduled_tasks_enabled:c.scheduledTasksEnabled,event_tasks_enabled:c.eventTasksEnabled}};await n(B),m({type:"success",text:"Agent settings saved. Restarting daemon..."});try{await f()}catch{m({type:"success",text:"Settings saved. Daemon restart may require manual action."})}}catch{m({type:"error",text:"Failed to save settings."})}}},D=async()=>{if(e){x("testing"),S("");try{const B=new URLSearchParams({provider:e.embedding.provider,type:"embedding"});e.embedding.base_url&&B.set("base_url",e.embedding.base_url);const _=(await ot(`/models?${B.toString()}`)).models.length;x("success"),S(`Connected -- ${_} model${_!==1?"s":""} available.`)}catch(B){x("error"),S(B instanceof Error?B.message:"Connection failed.")}}};return t||!e||!c?h.jsx("div",{className:"space-y-4",children:[1,2,3].map(B=>h.jsx("div",{className:"h-32 rounded-md animate-pulse bg-surface-container-low"},B))}):h.jsxs("div",{className:"space-y-6",children:[h.jsxs(Qe,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-sage",children:[h.jsx(Bt,{children:h.jsxs("span",{className:"flex items-center gap-2",children:[h.jsx(Az,{className:"h-4 w-4 text-primary"}),"Agent Operations"]})}),h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"space-y-0.5",children:[h.jsx("label",{className:"font-sans text-sm font-medium text-on-surface",children:"Scheduled Tasks"}),h.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Intelligence, skill survey, and skill evolution run automatically on a schedule"})]}),h.jsx(fl,{checked:c.scheduledTasksEnabled,onCheckedChange:B=>R("scheduledTasksEnabled",B)})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"space-y-0.5",children:[h.jsx("label",{className:"font-sans text-sm font-medium text-on-surface",children:"Event-Driven Tasks"}),h.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Titles and summaries generated automatically after coding sessions"})]}),h.jsx(fl,{checked:c.eventTasksEnabled,onCheckedChange:B=>R("eventTasksEnabled",B)})]})]}),h.jsx("div",{className:"border-t border-outline-variant/20"}),h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"font-sans text-sm font-medium text-on-surface",children:"Title & Summary Batch Interval"}),h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(cn,{type:"number",min:0,placeholder:String(pb),value:c.summaryBatchInterval,onChange:B=>R("summaryBatchInterval",B.target.value),className:"w-32 font-mono"}),h.jsx("span",{className:"font-sans text-xs text-on-surface-variant",children:"batches"})]}),h.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Run the Title & Summary task every N batches to keep active sessions properly titled. Set to 0 to disable."})]}),h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"font-sans text-sm font-medium text-on-surface",children:"Default Task"}),o?h.jsxs("div",{className:"flex h-9 items-center gap-2 text-on-surface-variant font-sans text-sm",children:[h.jsx(qn,{className:"h-4 w-4 animate-spin"}),"Loading tasks..."]}):h.jsxs(Zi,{value:c.defaultTask,onValueChange:B=>R("defaultTask",B),children:[h.jsx(vi,{children:h.jsx(Ji,{placeholder:"Select default task"})}),h.jsx(pi,{children:w.map(B=>h.jsx(ia,{value:B.name,children:B.displayName},B.name))})]}),h.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"The task used when Run Now is clicked or no task is specified."})]}),h.jsxs("div",{className:"flex items-center gap-3 pt-2 border-t border-outline-variant/20",children:[h.jsxs(_e,{onClick:A,disabled:!T||r,size:"sm",children:[r?h.jsx(qn,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):null,"Save Changes"]}),p&&h.jsx("span",{className:p.type==="success"?"font-sans text-xs text-primary":"font-sans text-xs text-tertiary",children:p.text})]})]}),h.jsxs(Qe,{level:"low",className:"p-6 space-y-4 border-t-2 border-t-ochre",children:[h.jsx(Bt,{children:h.jsxs("span",{className:"flex items-center gap-2",children:[h.jsx(N1,{className:"h-4 w-4 text-secondary"}),"Embedding Configuration"]})}),h.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2",children:[h.jsxs("div",{children:[h.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Provider"}),h.jsx("p",{className:"text-sm font-mono text-on-surface mt-0.5",children:e.embedding.provider})]}),h.jsxs("div",{children:[h.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Model"}),h.jsx("p",{className:"text-sm font-mono text-on-surface mt-0.5 truncate",title:e.embedding.model,children:e.embedding.model})]}),e.embedding.base_url&&h.jsxs("div",{className:"col-span-2",children:[h.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Base URL"}),h.jsx("p",{className:"text-sm font-mono text-on-surface mt-0.5 truncate",title:e.embedding.base_url,children:e.embedding.base_url})]})]}),h.jsxs("div",{className:"flex items-center gap-3 pt-2 border-t border-outline-variant/20",children:[h.jsxs(_e,{type:"button",variant:"ghost",size:"sm",onClick:D,disabled:y==="testing",children:[y==="testing"?h.jsx(qn,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):null,"Test Connection"]}),h.jsxs("a",{href:"/settings",className:"flex items-center gap-1 font-sans text-xs text-on-surface-variant hover:text-on-surface transition-colors",children:[h.jsx(Cd,{className:"h-3 w-3"}),"Edit in Settings"]}),y==="success"&&h.jsxs("span",{className:"flex items-center gap-1 font-sans text-xs text-primary",children:[h.jsx(_R,{className:"h-3.5 w-3.5"}),b]}),y==="error"&&h.jsxs("span",{className:"flex items-center gap-1 font-sans text-xs text-tertiary",children:[h.jsx(Ed,{className:"h-3.5 w-3.5"}),b]})]})]}),i?h.jsx(Qe,{level:"low",className:"p-6",children:h.jsx("div",{className:"h-32 animate-pulse rounded-md bg-surface-container"})}):a?h.jsx(Qe,{level:"low",className:"p-6",children:h.jsx(Ine,{stats:a})}):null]})}const Z_="tab",J_="run",e5="task",qne=new Set(["runs","tasks","config"]);function jA(){const e=new URLSearchParams(window.location.search),t=e.get(Z_);return{tab:t&&qne.has(t)?t:"runs",runId:e.get(J_)??void 0,taskId:e.get(e5)??void 0}}function Une(e,t,n){const r=new URLSearchParams;e!=="runs"&&r.set(Z_,e),t&&r.set(J_,t),n&&r.set(e5,n);const a=r.toString(),i=a?`${window.location.pathname}?${a}`:window.location.pathname;window.history.pushState(null,"",i)}const Vne=[{id:"runs",label:"Runs"},{id:"tasks",label:"Tasks"},{id:"config",label:"Config"}];function Hne(){const e=jA(),[t,n]=j.useState(e.tab),[r,a]=j.useState(e.runId),[i,l]=j.useState(e.taskId),[o,f]=j.useState(!1),c=j.useRef(!1),d=j.useRef(!1);j.useEffect(()=>{if(!c.current){c.current=!0;return}if(d.current){d.current=!1;return}Une(t,r,i)},[t,r,i]),j.useEffect(()=>{function m(){d.current=!0;const y=jA();n(y.tab),a(y.runId),l(y.taskId)}return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[]);const p=j.useCallback(m=>{const y=m;n(y),y!=="runs"&&a(void 0),y!=="tasks"&&l(void 0)},[]);return h.jsxs("div",{className:"p-6 space-y-4",children:[h.jsx(yi,{title:"Agent",subtitle:"Intelligence runs, task configuration, and operational settings",tabs:Vne,activeTab:t,onTabChange:p,actions:t==="runs"?h.jsxs(_e,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>f(!0),children:[h.jsx(Zu,{className:"h-3.5 w-3.5"}),"Run Now"]}):void 0}),t==="runs"&&(r?h.jsx(une,{runId:r,onBack:()=>a(void 0)}):h.jsx(ene,{onSelectRun:a,onTriggerRun:()=>f(!0)})),t==="tasks"&&(i?h.jsx(Pne,{taskId:i,onBack:()=>l(void 0),onNavigate:l,onRunTriggered:m=>{l(void 0),n("runs"),m&&a(m)}}):h.jsx(pne,{onSelect:l})),t==="config"&&h.jsx(Fne,{}),h.jsx(fne,{open:o,onOpenChange:f,onTriggered:()=>a(void 0)})]})}function t5(e){const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),(e==null?void 0:e.limit)!==void 0&&t.set("limit",String(e.limit)),(e==null?void 0:e.offset)!==void 0&&t.set("offset",String(e.offset));const n=t.toString(),r=n?`/skill-candidates?${n}`:"/skill-candidates";return tn({queryKey:["skill-candidates",e],queryFn:({signal:a})=>ot(r,{signal:a})})}function $ne(){const e=Vn();return br({mutationFn:({id:t,...n})=>oc(`/skill-candidates/${t}`,n),onSuccess:()=>{e.invalidateQueries({queryKey:["skill-candidates"]})}})}function n5(e){const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),(e==null?void 0:e.limit)!==void 0&&t.set("limit",String(e.limit)),(e==null?void 0:e.offset)!==void 0&&t.set("offset",String(e.offset));const n=t.toString(),r=n?`/skill-records?${n}`:"/skill-records";return tn({queryKey:["skill-records",e],queryFn:({signal:a})=>ot(r,{signal:a})})}function Gne(e){return tn({queryKey:["skill-record",e],queryFn:({signal:t})=>ot(`/skill-records/${e}`,{signal:t}),enabled:!!e})}function Kne(){const e=Vn();return br({mutationFn:t=>j1(`/skill-records/${encodeURIComponent(t)}`),onSuccess:()=>{e.invalidateQueries({queryKey:["skill-records"]}),e.invalidateQueries({queryKey:["skill-record"]})}})}const Yne=[{key:"status",label:"Status",options:[{value:Jn,label:"All statuses"},{value:"identified",label:"Identified"},{value:"approved",label:"Approved"},{value:"generated",label:"Generated"},{value:"dismissed",label:"Dismissed"}]}];function Xne(e){const t=`${(e*100).toFixed(0)}%`;return e>=.85?{text:t,variant:"default"}:e>=.7?{text:t,variant:"secondary"}:{text:t,variant:"outline"}}function Qne(e){const t=Math.floor(Date.now()/1e3)-e;return t<60?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function Wne(e){switch(e){case"identified":return h.jsx(Ct,{variant:"outline",children:"Identified"});case"approved":return h.jsx(Ct,{variant:"secondary",children:"Approved"});case"generated":return h.jsx(Ct,{variant:"default",children:"Generated"});case"dismissed":return h.jsx(Ct,{variant:"outline",className:"opacity-50",children:"Dismissed"});default:return h.jsx(Ct,{variant:"outline",children:e})}}function Zne({candidate:e,onApprove:t,onDismiss:n,isApproving:r,isDismissing:a}){const i=Xne(e.confidence),l=e.status==="identified"||e.status==="approved";return h.jsxs(Qe,{level:"low",className:"p-5 space-y-3",children:[h.jsxs("div",{className:"flex items-start justify-between gap-4",children:[h.jsx("div",{className:"flex-1 min-w-0",children:h.jsx("h3",{className:"font-serif text-lg text-on-surface leading-tight",children:e.topic})}),h.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[Wne(e.status),h.jsx(Ct,{variant:i.variant,children:i.text}),h.jsx("span",{className:"font-sans text-xs text-on-surface-variant",children:Qne(e.created_at)})]})]}),h.jsx(Ma,{content:e.rationale,className:"text-sm text-on-surface-variant"}),l&&h.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.status==="identified"&&h.jsxs(h.Fragment,{children:[h.jsxs(_e,{size:"sm",variant:"default",onClick:t,disabled:r,children:[h.jsx(wd,{className:"h-3.5 w-3.5 mr-1.5"}),r?"Approving...":"Approve"]}),h.jsxs(_e,{size:"sm",variant:"ghost",onClick:n,disabled:a,className:"text-on-surface-variant",children:[h.jsx(Ed,{className:"h-3.5 w-3.5 mr-1.5"}),a?"Dismissing...":"Dismiss"]})]}),e.status==="approved"&&h.jsx("span",{className:"font-sans text-xs text-on-surface-variant",children:"Awaiting generation"})]})]})}function Jne(){return h.jsxs(Qe,{level:"low",className:"p-5 space-y-3",children:[h.jsxs("div",{className:"flex items-start justify-between",children:[h.jsx("div",{className:"h-5 w-64 rounded bg-surface-container-high animate-pulse"}),h.jsx("div",{className:"h-5 w-20 rounded bg-surface-container-high animate-pulse"})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsx("div",{className:"h-3 w-full rounded bg-surface-container-high animate-pulse"}),h.jsx("div",{className:"h-3 w-3/4 rounded bg-surface-container-high animate-pulse"})]}),h.jsx("div",{className:"h-8 w-32 rounded bg-surface-container-high animate-pulse"})]})}function ere(){const e=$ne(),{searchInput:t,debouncedSearch:n,filterValues:r,offset:a,setOffset:i,handleSearchChange:l,handleFilterChange:o,activeFilter:f}=Ad({initialFilters:{status:"identified"}}),c=f("status"),{data:d,isLoading:p,isError:m,error:y}=t5({status:c,limit:$r,offset:a}),x=(d==null?void 0:d.candidates)??[],b=(d==null?void 0:d.total)??0,S=j.useMemo(()=>{if(!n)return x;const T=n.toLowerCase();return x.filter(R=>R.topic.toLowerCase().includes(T)||R.rationale.toLowerCase().includes(T))},[x,n]);function w(T){e.mutate({id:T.id,status:"approved"})}function N(T){e.mutate({id:T.id,status:"dismissed"})}const C=h.jsx(jd,{searchPlaceholder:"Search candidates...",searchValue:t,onSearchChange:l,filters:Yne,filterValues:r,onFilterChange:o});return m?h.jsxs("div",{className:"space-y-3",children:[C,h.jsxs("div",{className:"flex h-40 flex-col items-center justify-center gap-2 text-tertiary",children:[h.jsx(Ar,{className:"h-5 w-5"}),h.jsx("span",{className:"font-sans text-sm",children:"Failed to load candidates"}),h.jsx("span",{className:"font-sans text-xs text-on-surface-variant",children:y instanceof Error?y.message:"Unknown error"})]})]}):p?h.jsxs("div",{className:"space-y-3",children:[C,Array.from({length:3}).map((T,R)=>h.jsx(Jne,{},R))]}):h.jsxs("div",{className:"space-y-3",children:[C,S.length===0?h.jsxs("div",{className:"flex h-48 flex-col items-center justify-center gap-3 text-on-surface-variant",children:[h.jsx(bz,{className:"h-10 w-10 opacity-20"}),b===0&&!c&&!n?h.jsxs("div",{className:"text-center space-y-2 max-w-md",children:[h.jsx("p",{className:"font-sans text-sm font-medium text-on-surface",children:"No skill candidates discovered yet"}),h.jsx("p",{className:"font-sans text-xs leading-relaxed",children:"Candidates are procedural patterns discovered from your vault knowledge. Review and approve them here, then Myco generates full skills from them."}),h.jsxs("div",{className:"font-sans text-xs space-y-1 pt-1",children:[h.jsxs("p",{children:[h.jsx("span",{className:"font-medium text-on-surface",children:"Automatic:"})," ","The"," ",h.jsx(Ra,{to:"/agent?tab=tasks&task=skill-survey",className:"text-primary hover:underline",children:"Skill Survey"})," ","task runs automatically during idle periods and discovers candidates from session history, decisions, and gotchas."]}),h.jsxs("p",{children:[h.jsx("span",{className:"font-medium text-on-surface",children:"Manual:"})," ","Run"," ",h.jsxs(Ra,{to:"/agent?tab=tasks&task=skill-survey",className:"inline-flex items-center gap-1 text-primary hover:underline",children:[h.jsx(Cd,{className:"h-3 w-3"}),"Skill Survey"]})," ","from the Agent page to discover candidates on demand."]})]})]}):h.jsx("span",{className:"font-sans text-sm",children:"No matching candidates"})]}):h.jsxs(h.Fragment,{children:[h.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:n?`${S.length} of ${b} candidate${b!==1?"s":""}`:`${b} candidate${b!==1?"s":""}`}),S.map(T=>{var R,A,D,L;return h.jsx(Zne,{candidate:T,onApprove:()=>w(T),onDismiss:()=>N(T),isApproving:e.isPending&&((R=e.variables)==null?void 0:R.id)===T.id&&((A=e.variables)==null?void 0:A.status)==="approved",isDismissing:e.isPending&&((D=e.variables)==null?void 0:D.id)===T.id&&((L=e.variables)==null?void 0:L.status)==="dismissed"},T.id)})]}),h.jsx(mc,{total:n?S.length:b,offset:a,limit:$r,onPageChange:i})]})}const tre=5,nre=[{key:"status",label:"Status",options:[{value:Jn,label:"All statuses"},{value:"active",label:"Active"},{value:"stale",label:"Stale"},{value:"retired",label:"Retired"}]}];function rre(e){return e==="active"?"default":e==="stale"?"secondary":"outline"}function Lf({children:e,className:t}){return h.jsx("th",{className:Te("px-4 py-3 text-left font-sans text-[10px] font-medium uppercase tracking-widest text-on-surface-variant",t),children:e})}function are(){return h.jsxs("tr",{className:"border-b border-[var(--ghost-border)]",children:[h.jsx("td",{className:"px-4 py-3",children:h.jsx("div",{className:"h-3 w-40 rounded bg-surface-container-high animate-pulse"})}),h.jsx("td",{className:"px-4 py-3",children:h.jsx("div",{className:"h-3 w-12 rounded bg-surface-container-high animate-pulse"})}),h.jsx("td",{className:"px-4 py-3",children:h.jsx("div",{className:"h-3 w-16 rounded bg-surface-container-high animate-pulse"})}),h.jsx("td",{className:"px-4 py-3",children:h.jsx("div",{className:"h-3 w-10 rounded bg-surface-container-high animate-pulse"})}),h.jsx("td",{className:"px-4 py-3",children:h.jsx("div",{className:"h-3 w-20 rounded bg-surface-container-high animate-pulse"})})]})}function ire({record:e,onClick:t}){return h.jsxs("tr",{className:"border-b border-[var(--ghost-border)] last:border-0 hover:bg-surface-container/60 cursor-pointer transition-all duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary/40 hover:shadow-[inset_3px_0_0_var(--primary)]",onClick:t,onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),t())},tabIndex:0,role:"row","aria-label":`Skill: ${e.display_name}`,children:[h.jsxs("td",{className:"px-4 py-3",children:[h.jsx("span",{className:"font-sans text-sm font-medium text-on-surface block",children:e.display_name}),h.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant block mt-0.5",children:e.name})]}),h.jsx("td",{className:"px-4 py-3",children:h.jsxs(Ct,{variant:"outline",className:"font-mono text-[10px] px-1.5 py-0",children:["gen ",e.generation]})}),h.jsx("td",{className:"px-4 py-3",children:h.jsx(Ct,{variant:rre(e.status),children:e.status})}),h.jsx("td",{className:"px-4 py-3",children:h.jsx("span",{className:"font-mono text-xs text-on-surface-variant",children:e.usage_count})}),h.jsx("td",{className:"px-4 py-3",children:h.jsx("span",{className:"font-mono text-xs text-on-surface-variant",children:qp(e.updated_at)})})]})}function sre({onSelectSkill:e}){const{searchInput:t,debouncedSearch:n,filterValues:r,offset:a,setOffset:i,handleSearchChange:l,handleFilterChange:o,activeFilter:f}=Ad({initialFilters:{status:Jn}}),c=f("status"),{data:d,isLoading:p,isError:m,error:y}=n5({status:c,limit:$r,offset:a}),x=(d==null?void 0:d.records)??[],b=(d==null?void 0:d.total)??0,S=n?x.filter(C=>C.display_name.toLowerCase().includes(n.toLowerCase())||C.name.toLowerCase().includes(n.toLowerCase())||C.description.toLowerCase().includes(n.toLowerCase())):x,w=h.jsx(jd,{searchPlaceholder:"Search skills...",searchValue:t,onSearchChange:l,filters:nre,filterValues:r,onFilterChange:o}),N=h.jsx("thead",{children:h.jsxs("tr",{className:"border-b border-[var(--ghost-border)] bg-surface-container/50",children:[h.jsx(Lf,{children:"Name"}),h.jsx(Lf,{children:"Generation"}),h.jsx(Lf,{children:"Status"}),h.jsx(Lf,{children:"Usage"}),h.jsx(Lf,{children:"Last Evolved"})]})});return m?h.jsxs("div",{children:[w,h.jsxs("div",{className:"flex h-40 flex-col items-center justify-center gap-2 text-tertiary mt-4",children:[h.jsx(Ar,{className:"h-5 w-5"}),h.jsx("span",{className:"font-sans text-sm",children:"Failed to load skills"}),h.jsx("span",{className:"font-sans text-xs text-on-surface-variant",children:y instanceof Error?y.message:"Unknown error"})]})]}):h.jsxs("div",{children:[w,p?h.jsx(Qe,{level:"low",className:"rounded-md overflow-hidden mt-4",children:h.jsxs("table",{className:"w-full",children:[N,h.jsx("tbody",{children:Array.from({length:tre}).map((C,T)=>h.jsx(are,{},T))})]})}):S.length===0?h.jsxs("div",{className:"flex h-48 flex-col items-center justify-center gap-3 text-on-surface-variant mt-4",children:[h.jsx(iz,{className:"h-10 w-10 opacity-20"}),b===0&&!n&&!c?h.jsxs("div",{className:"text-center space-y-2 max-w-md",children:[h.jsx("p",{className:"font-sans text-sm font-medium text-on-surface",children:"No skills generated yet"}),h.jsx("p",{className:"font-sans text-xs leading-relaxed",children:"Skills are project-specific procedural guides generated from your vault knowledge. They teach agents how to accomplish tasks in this codebase."}),h.jsxs("div",{className:"font-sans text-xs space-y-1 pt-1",children:[h.jsxs("p",{children:[h.jsx("span",{className:"font-medium text-on-surface",children:"Automatic:"})," ","The"," ",h.jsx(Ra,{to:"/agent?tab=tasks&task=skill-survey",className:"text-primary hover:underline",children:"Skill Survey"})," ","task runs automatically and discovers candidates from your vault. Approve candidates in the"," ",h.jsx(Ra,{to:"/skills?tab=candidates",className:"text-primary hover:underline",children:"Candidates tab"}),", then enable the"," ",h.jsx(Ra,{to:"/agent?tab=tasks&task=skill-generate",className:"text-primary hover:underline",children:"Skill Generate"})," ","task to produce skills automatically."]}),h.jsxs("p",{children:[h.jsx("span",{className:"font-medium text-on-surface",children:"Manual:"})," ","Run"," ",h.jsx(Ra,{to:"/agent?tab=tasks&task=skill-generate",className:"text-primary hover:underline",children:"Skill Generate"})," ","from the Agent page to generate a skill on demand."]})]})]}):h.jsx("span",{className:"font-sans text-sm",children:"No matching skills"})]}):h.jsx(Qe,{level:"low",className:"rounded-md overflow-hidden mt-4",children:h.jsxs("table",{className:"w-full","aria-label":"Skills",children:[N,h.jsx("tbody",{children:S.map(C=>h.jsx(ire,{record:C,onClick:()=>e(C.name)},C.id))})]})}),h.jsx(mc,{total:b,offset:a,limit:$r,onPageChange:i})]})}const lre={created:"default",updated:"secondary",split:"warning",retired:"outline"};function ore({entry:e}){const[t,n]=j.useState(!1);return h.jsxs("div",{className:"relative pl-6",children:[h.jsx("div",{className:"absolute left-0 top-2 h-2.5 w-2.5 rounded-full border-2 border-outline-variant bg-surface-container"}),h.jsxs("button",{type:"button",className:"w-full text-left group cursor-pointer",onClick:()=>n(r=>!r),"aria-expanded":t,children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsxs(Ct,{variant:"outline",className:"font-mono text-[10px] px-1.5 py-0",children:["v",e.generation]}),h.jsx(Ct,{variant:lre[e.action]??"outline",children:e.action}),h.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant ml-auto shrink-0",children:qp(e.created_at)}),h.jsx(ua,{className:Te("h-3.5 w-3.5 text-on-surface-variant transition-transform duration-150",t&&"rotate-90")})]}),e.rationale&&h.jsx("p",{className:"font-sans text-sm text-on-surface-variant mt-1 leading-relaxed",children:e.rationale})]}),t&&e.content_snapshot&&h.jsx(Qe,{level:"lowest",className:"mt-2 p-3 overflow-auto max-h-96",children:h.jsx("pre",{className:"font-mono text-xs text-on-surface whitespace-pre-wrap break-words",children:e.content_snapshot})})]})}function ure({entries:e}){return e.length===0?h.jsx("p",{className:"font-sans text-sm text-on-surface-variant py-4",children:"No evolution history."}):h.jsxs("div",{className:"relative space-y-4",children:[h.jsx("div",{className:"absolute left-[4.5px] top-2 bottom-2 w-px bg-outline-variant/30"}),e.map(t=>h.jsx(ore,{entry:t},t.id))]})}function cre(e){return e==="active"?"default":e==="stale"?"secondary":"outline"}function fre(e){if(!e)return 0;try{const t=JSON.parse(e);return Array.isArray(t)?t.length:0}catch{return 0}}function dre(){return h.jsxs("div",{className:"space-y-6",children:[h.jsx("div",{className:"h-8 w-24 animate-pulse rounded bg-surface-container-high"}),h.jsxs("div",{className:"rounded-md bg-surface-container-low p-4 space-y-3",children:[h.jsx("div",{className:"h-6 w-48 animate-pulse rounded bg-surface-container-high"}),h.jsx("div",{className:"h-4 w-64 animate-pulse rounded bg-surface-container-high"}),h.jsx("div",{className:"h-5 w-32 animate-pulse rounded bg-surface-container-high"})]}),h.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:Array.from({length:3}).map((e,t)=>h.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-surface-container-high"},t))})]})}function hre({skillName:e,onBack:t}){var m,y;const{data:n,isPending:r,isError:a}=Gne(e),i=Kne(),[l,o]=j.useState(!1);if(r)return h.jsx(dre,{});if(a||!n)return h.jsxs("div",{className:"space-y-4",children:[h.jsxs(_e,{variant:"ghost",size:"sm",onClick:t,className:"gap-2 text-on-surface-variant",children:[h.jsx(di,{className:"h-4 w-4"}),"Skills"]}),h.jsxs("div",{className:"flex h-40 flex-col items-center justify-center gap-2 text-tertiary",children:[h.jsx(Ar,{className:"h-5 w-5"}),h.jsx("span",{className:"font-sans text-sm",children:"Skill not found"})]})]});const f=fre(n.source_ids),c=((y=(m=n.lineage)==null?void 0:m[0])==null?void 0:y.content_snapshot)??null,d=n.frontmatter??{},p=(c==null?void 0:c.replace(/^---\n[\s\S]*?\n---\n*/,""))??null;return h.jsxs("div",{className:"space-y-6",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs(_e,{variant:"ghost",size:"sm",onClick:t,className:"gap-2 text-on-surface-variant",children:[h.jsx(di,{className:"h-4 w-4"}),"Skills"]}),h.jsxs(_e,{variant:"ghost",size:"sm",className:"gap-2 text-tertiary hover:text-tertiary hover:bg-tertiary/10",onClick:()=>o(!0),children:[h.jsx(dl,{className:"h-4 w-4"}),"Delete"]})]}),h.jsx(Qe,{level:"low",className:"p-4 space-y-3",children:h.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[h.jsxs("div",{className:"flex-1 space-y-1 min-w-0",children:[h.jsx("h1",{className:"font-serif text-lg text-on-surface",children:n.display_name}),n.description&&h.jsx("p",{className:"font-sans text-sm text-on-surface-variant",children:n.description}),n.path&&h.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant mt-1",children:n.path}),Object.keys(d).length>0&&h.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[d["user-invocable"]==="true"&&h.jsx(Ct,{variant:"secondary",children:"user-invocable"}),d["allowed-tools"]&&h.jsxs(Ct,{variant:"outline",children:["tools: ",d["allowed-tools"]]})]})]}),h.jsx(Ct,{variant:cre(n.status),className:"shrink-0",children:n.status})]})}),h.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[h.jsx(sn,{label:"Generation",value:`v${n.generation}`,accent:"sage"}),h.jsx(sn,{label:"Usage",value:`${n.usage_total??n.usage_count??0}`,sublabel:"sessions",accent:"ochre"}),h.jsx(sn,{label:"Sources",value:`${f}`,accent:"outline"})]}),h.jsxs("div",{className:"space-y-3",children:[h.jsx(Bt,{children:"Evolution History"}),h.jsx(ure,{entries:n.lineage??[]})]}),h.jsxs("div",{className:"space-y-3",children:[h.jsx(Bt,{children:"Current Content"}),p?h.jsx(Ma,{content:p}):h.jsx("p",{className:"font-sans text-sm text-on-surface-variant py-4",children:"No content snapshot available."})]}),h.jsx(W1,{open:l,onOpenChange:o,title:"Delete Skill",description:"This will permanently delete the skill record, evolution history, and the SKILL.md file from disk.",icon:h.jsx(dl,{className:"h-4 w-4 text-tertiary"}),meta:n?[{label:"Name",value:n.name},{label:"Title",value:n.display_name}]:[],confirmLabel:"Delete Skill",variant:"destructive",onConfirm:()=>{i.mutate(n.name,{onSuccess:()=>{o(!1),t()}})},isPending:i.isPending})]})}const r5="tab",a5="skill",vre=new Set(["candidates","skills"]);function pre(){const e=new URLSearchParams(window.location.search),t=e.get(r5);return{tab:t&&vre.has(t)?t:"skills",skill:e.get(a5)??void 0}}function mre(e,t){const n=new URLSearchParams;e!=="skills"&&n.set(r5,e),t&&n.set(a5,t);const r=n.toString(),a=r?`${window.location.pathname}?${r}`:window.location.pathname;window.history.replaceState(null,"",a)}const gre=[{id:"skills",label:"Skills"},{id:"candidates",label:"Candidates"}];function yre(){return h.jsxs(Nd,{children:[h.jsx(oF,{asChild:!0,children:h.jsx(_e,{variant:"ghost",size:"sm",className:"text-on-surface-variant",children:h.jsx(lz,{className:"h-4 w-4"})})}),h.jsxs(cc,{className:"max-w-lg",children:[h.jsxs(kd,{children:[h.jsx(fc,{children:"How Skills Work"}),h.jsx(zp,{children:"Skills are project-specific procedural guides generated from your vault knowledge. They teach agents how to accomplish tasks in your codebase."})]}),h.jsxs("div",{className:"space-y-4 font-sans text-sm text-on-surface-variant",children:[h.jsxs("div",{className:"space-y-1.5",children:[h.jsx("h4",{className:"font-medium text-on-surface",children:"The Pipeline"}),h.jsxs("ol",{className:"list-decimal pl-5 space-y-1",children:[h.jsxs("li",{children:[h.jsx("span",{className:"font-medium text-on-surface",children:"Survey"})," — discovers candidate skills from vault knowledge (sessions, decisions, gotchas)"]}),h.jsxs("li",{children:[h.jsx("span",{className:"font-medium text-on-surface",children:"Approve"})," — you review candidates and approve the ones worth generating"]}),h.jsxs("li",{children:[h.jsx("span",{className:"font-medium text-on-surface",children:"Generate"})," — produces a SKILL.md file from the approved candidate's source material"]}),h.jsxs("li",{children:[h.jsx("span",{className:"font-medium text-on-surface",children:"Evolve"})," — updates existing skills when new knowledge makes them stale"]})]})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsx("h4",{className:"font-medium text-on-surface",children:"Scheduling"}),h.jsxs("p",{children:[h.jsx("span",{className:"font-medium text-on-surface",children:"Skill Survey"})," runs automatically during idle periods. Skill Generate and Skill Evolve are off by default — enable them in the"," ",h.jsxs(Ra,{to:"/agent?tab=tasks",className:"text-primary hover:underline inline-flex items-center gap-0.5",children:["Agent Tasks",h.jsx(Cd,{className:"h-3 w-3"})]})," ","page for fully automatic operation, or trigger them manually with Run Now."]})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsx("h4",{className:"font-medium text-on-surface",children:"Quick Start"}),h.jsxs("ol",{className:"list-decimal pl-5 space-y-1",children:[h.jsx("li",{children:"Wait for the survey to discover candidates (or run it manually)"}),h.jsx("li",{children:"Review candidates in the Candidates tab and approve the best ones"}),h.jsxs("li",{children:["Run"," ",h.jsx(Ra,{to:"/agent?tab=tasks&task=skill-generate",className:"text-primary hover:underline",children:"Skill Generate"})," ","to produce skills from approved candidates"]})]})]})]})]})]})}function xre(){const e=pre(),[t,n]=j.useState(e.tab),[r,a]=j.useState(e.skill),{data:i}=t5({status:"identified"}),{data:l}=n5({status:"active"}),o=(i==null?void 0:i.total)??0,f=(l==null?void 0:l.total)??0;j.useEffect(()=>{mre(t,r)},[t,r]);const c=j.useCallback(p=>{const m=p;n(m),m!=="skills"&&a(void 0)},[]),d=j.useCallback(p=>{n("skills"),a(p)},[]);return h.jsxs("div",{className:"p-6 space-y-4",children:[h.jsx(yi,{title:"Skills",subtitle:"Discovered skill candidates and promoted skill records",tabs:gre,activeTab:t,onTabChange:c,actions:h.jsxs("div",{className:"flex items-center gap-2",children:[o>0&&h.jsxs(Ct,{variant:"secondary",children:[o," pending"]}),f>0&&h.jsxs(Ct,{variant:"default",children:[f," active"]}),h.jsx(yre,{})]})}),t==="candidates"&&h.jsx(ere,{}),t==="skills"&&!r&&h.jsx(sre,{onSelectSkill:d}),t==="skills"&&r&&h.jsx(hre,{skillName:r,onBack:()=>a(void 0)})]})}function bre(){const[e,t]=j.useState({}),[n,r]=j.useState([]),[a,i]=j.useState([]),[l,o]=j.useState(""),[f,c]=j.useState(!1),[d,p]=j.useState(null),[m,y]=j.useState(!0);j.useEffect(()=>{ot("/config/plan-dirs").then(T=>{t(T.symbiont),r(T.custom),i(T.custom)}).catch(()=>{}).finally(()=>y(!1))},[]);const x=n.length!==a.length||n.some((T,R)=>T!==a[R]),b=j.useCallback(()=>{const T=l.trim();!T||n.includes(T)||(r(R=>[...R,T]),o(""),p(null))},[l,n]),S=j.useCallback(T=>{r(R=>R.filter(A=>A!==T)),p(null)},[]),w=j.useCallback(async()=>{c(!0),p(null);try{const T=await kn("/config/plan-dirs",{plan_dirs:n});i(T.custom),r(T.custom),p({type:"success",text:"Plan directories saved."})}catch{p({type:"error",text:"Failed to save plan directories."})}finally{c(!1)}},[n]),N=j.useCallback(T=>{T.key==="Enter"&&b()},[b]),C=Object.entries(e);return h.jsxs(Qe,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-amber-500",children:[h.jsx(Bt,{children:"Plan Capture"}),m?h.jsx("p",{className:"font-sans text-sm text-on-surface-variant",children:"Loading..."}):h.jsxs("div",{className:"space-y-5",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"font-sans text-sm font-medium text-on-surface",children:"Agent Directories"}),h.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Directories monitored by connected agents. Managed by symbiont manifests."}),C.length===0?h.jsx("p",{className:"font-sans text-xs text-on-surface-variant italic",children:"No agent directories configured."}):h.jsx("div",{className:"space-y-3",children:C.map(([T,R])=>h.jsxs("div",{className:"space-y-1",children:[h.jsx("p",{className:"font-sans text-xs font-medium text-on-surface-variant uppercase tracking-wide",children:T}),h.jsx("div",{className:"space-y-1",children:R.map(A=>h.jsx("div",{className:"rounded bg-surface-container px-3 py-1.5 font-mono text-xs text-on-surface-variant",children:A},A))})]},T))})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"font-sans text-sm font-medium text-on-surface",children:"Custom Directories"}),h.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Additional directories to watch for plan files."}),n.length>0&&h.jsx("div",{className:"space-y-1",children:n.map(T=>h.jsxs("div",{className:"flex items-center gap-2 rounded bg-surface-container px-3 py-1.5",children:[h.jsx("span",{className:"flex-1 font-mono text-xs text-on-surface",children:T}),h.jsx("button",{type:"button",onClick:()=>S(T),className:"font-sans text-xs text-on-surface-variant hover:text-tertiary transition-colors leading-none","aria-label":`Remove ${T}`,children:"x"})]},T))}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(cn,{placeholder:"/path/to/plans",value:l,onChange:T=>o(T.target.value),onKeyDown:N,className:"flex-1 font-mono text-xs"}),h.jsx(_e,{type:"button",size:"sm",onClick:b,disabled:!l.trim(),children:"Add"})]})]}),x&&h.jsxs("div",{className:"flex items-center gap-4 pt-1",children:[h.jsx(_e,{onClick:w,disabled:f,size:"sm",children:f?"Saving...":"Save"}),d&&h.jsx("span",{className:d.type==="success"?"font-sans text-sm text-primary":"font-sans text-sm text-tertiary",children:d.text})]}),!x&&(d==null?void 0:d.type)==="success"&&h.jsx("p",{className:"font-sans text-sm text-primary",children:d.text})]})]})}function Mv({children:e,hint:t}){return h.jsxs("label",{className:"font-sans text-sm font-medium text-on-surface",children:[e,t&&h.jsxs("span",{className:"ml-1 font-sans text-xs text-on-surface-variant font-normal",children:["(",t,")"]})]})}function Y0({children:e}){return h.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:e})}function wre(){var y,x,b,S;const{config:e,saveConfig:t,isSaving:n}=Ip(),{data:r}=TF(),[a,i]=j.useState(null),[l,o]=j.useState(null);j.useEffect(()=>{var w,N,C,T;e&&!a&&i({enabled:((w=e.notifications)==null?void 0:w.enabled)??!0,system_notifications:((N=e.notifications)==null?void 0:N.system_notifications)??!1,default_mode:((C=e.notifications)==null?void 0:C.default_mode)??"banner",domains:((T=e.notifications)==null?void 0:T.domains)??{}})},[e,a]);const f=j.useCallback((w,N)=>{i(C=>C&&{...C,[w]:N}),o(null)},[]),c=j.useCallback((w,N)=>{i(C=>{if(!C)return C;const T=C.domains[w]??{enabled:!0};return{...C,domains:{...C.domains,[w]:{...T,...N}}}}),o(null)},[]),d=j.useCallback(async()=>{if(!(!a||!e)){o(null);try{await t({...e,notifications:a}),o({type:"success",text:"Notification settings saved."})}catch{o({type:"error",text:"Failed to save notification settings."})}}},[a,e,t]);if(!a||!e)return null;const p=(r==null?void 0:r.domains)??[],m=e?a.enabled!==(((y=e.notifications)==null?void 0:y.enabled)??!0)||a.system_notifications!==(((x=e.notifications)==null?void 0:x.system_notifications)??!1)||a.default_mode!==(((b=e.notifications)==null?void 0:b.default_mode)??"banner")||JSON.stringify(a.domains)!==JSON.stringify(((S=e.notifications)==null?void 0:S.domains)??{}):!1;return h.jsxs(Qe,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-sage",children:[h.jsx(Bt,{children:"Notifications"}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"space-y-0.5",children:[h.jsx(Mv,{children:"Enabled"}),h.jsx(Y0,{children:"Master switch for all notification types."})]}),h.jsx(fl,{checked:a.enabled,onCheckedChange:w=>f("enabled",w)})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"space-y-0.5",children:[h.jsx(Mv,{children:"System Notifications"}),h.jsx(Y0,{children:"Show browser notifications when the tab is not focused."})]}),h.jsx(fl,{checked:a.system_notifications,onCheckedChange:w=>f("system_notifications",w),disabled:!a.enabled})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(Mv,{children:"Default Mode"}),h.jsxs(Zi,{value:a.default_mode,onValueChange:w=>f("default_mode",w),disabled:!a.enabled,children:[h.jsx(vi,{className:"w-40",children:h.jsx(Ji,{})}),h.jsxs(pi,{children:[h.jsx(ia,{value:"banner",children:"Banner"}),h.jsx(ia,{value:"summary",children:"Summary"})]})]}),h.jsx(Y0,{children:"Banner shows as a pop-up overlay. Summary shows only in the notification panel."})]}),p.length>0&&h.jsxs("div",{className:"space-y-3 pt-2",children:[h.jsx(Mv,{children:"Domain Notifications"}),h.jsx("div",{className:"space-y-3",children:p.map(w=>{const N=a.domains[w.domain]??{enabled:!0},C=N.enabled;return h.jsxs("div",{className:"flex items-center justify-between gap-3 py-1",children:[h.jsxs("div",{className:"space-y-0.5 flex-1 min-w-0",children:[h.jsx("span",{className:"text-sm text-on-surface",children:w.label}),h.jsx("p",{className:"text-[11px] text-on-surface-variant",children:w.types.map(T=>T.label).join(", ")})]}),h.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[h.jsxs(Zi,{value:N.mode??"default",onValueChange:T=>c(w.domain,{mode:T==="default"?void 0:T}),disabled:!a.enabled||!C,children:[h.jsx(vi,{className:"w-[110px] h-8 text-xs",children:h.jsx(Ji,{})}),h.jsxs(pi,{children:[h.jsx(ia,{value:"default",children:"Default"}),h.jsx(ia,{value:"banner",children:"Banner"}),h.jsx(ia,{value:"summary",children:"Summary"})]})]}),h.jsx(fl,{checked:C,onCheckedChange:T=>c(w.domain,{enabled:T}),disabled:!a.enabled})]})]},w.domain)})})]})]}),h.jsxs("div",{className:"flex items-center gap-4 pt-2",children:[h.jsxs(_e,{onClick:d,disabled:!m||n,size:"sm",children:[n?h.jsx(qn,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save Notifications"]}),l&&h.jsx("span",{className:l.type==="success"?"font-sans text-sm text-primary":"font-sans text-sm text-tertiary",children:l.text})]})]})}const Sre=["debug","info","warn","error"],Ere=[{value:"ollama",label:"Ollama"},{value:"openai-compatible",label:"OpenAI-compatible"}],Cre=[{value:"1500",label:"1.5K — Executive briefing"},{value:"5000",label:"5K — Deep onboarding"},{value:"10000",label:"10K — Full institutional"}];function i5(e){var t,n,r;return{daemonPort:e.daemon.port!=null?String(e.daemon.port):"",logLevel:e.daemon.log_level,logRetentionDays:String(e.daemon.log_retention_days),embeddingProvider:e.embedding.provider,embeddingModel:e.embedding.model,embeddingBaseUrl:e.embedding.base_url??"",contextDigestTier:String(((t=e.context)==null?void 0:t.digest_tier)??HR),contextPromptSearch:((n=e.context)==null?void 0:n.prompt_search)??!0,contextMaxSpores:String(((r=e.context)==null?void 0:r.prompt_max_spores)??$R)}}function Nre(e,t){return{...t,daemon:{...t.daemon,port:e.daemonPort!==""?Number(e.daemonPort):null,log_level:e.logLevel,log_retention_days:Number(e.logRetentionDays)},embedding:{...t.embedding,provider:e.embeddingProvider,model:e.embeddingModel,base_url:e.embeddingBaseUrl!==""?e.embeddingBaseUrl:void 0},agent:t.agent,context:{...t.context,digest_tier:Sb(e.contextDigestTier,HR),prompt_search:e.contextPromptSearch,prompt_max_spores:Sb(e.contextMaxSpores,$R)}}}function kre(e,t){const n=i5(t);return e.daemonPort!==n.daemonPort||e.logLevel!==n.logLevel||e.logRetentionDays!==n.logRetentionDays||e.embeddingProvider!==n.embeddingProvider||e.embeddingModel!==n.embeddingModel||e.embeddingBaseUrl!==n.embeddingBaseUrl||e.contextDigestTier!==n.contextDigestTier||e.contextPromptSearch!==n.contextPromptSearch||e.contextMaxSpores!==n.contextMaxSpores}function ni({children:e,hint:t}){return h.jsxs("label",{className:"font-sans text-sm font-medium text-on-surface",children:[e,t&&h.jsxs("span",{className:"ml-1 font-sans text-xs text-on-surface-variant font-normal",children:["(",t,")"]})]})}function Ov({children:e}){return h.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:e})}function Tre(){const{config:e,isLoading:t,saveConfig:n,isSaving:r}=Ip(),{data:a}=Dp(),{restart:i}=M1(),l=j.useRef(!1),[o,f]=j.useState(null);e&&!l.current&&(l.current=!0,o===null&&f(i5(e)));const[c,d]=j.useState(null),[p,m]=j.useState("idle"),[y,x]=j.useState(""),b=o&&e?kre(o,e):!1,S=j.useCallback((T,R)=>{f(A=>A&&{...A,[T]:R}),d(null)},[]),w=j.useCallback(async()=>{if(!(!o||!e)){d(null);try{await n(Nre(o,e)),d({type:"success",text:"Settings saved. Restarting daemon..."});try{await i()}catch{d({type:"success",text:"Settings saved. Daemon restart may require manual action."})}}catch{d({type:"error",text:"Failed to save settings."})}}},[o,e,n,i]),N=j.useCallback(async()=>{if(o){m("testing"),x("");try{const T=new URLSearchParams({provider:o.embeddingProvider,type:"embedding"});o.embeddingBaseUrl&&T.set("base_url",o.embeddingBaseUrl);const A=(await ot(`/models?${T.toString()}`)).models.length;m("success"),x(`Connected -- ${A} model${A!==1?"s":""} available.`)}catch(T){m("error"),x(T instanceof Error?T.message:"Connection failed.")}}},[o]);if(t||!o||!e)return h.jsxs("div",{className:"p-6",children:[h.jsx(yi,{title:"Settings"}),h.jsx("p",{className:"font-sans text-sm text-on-surface-variant mt-2",children:"Loading..."})]});const C=(a==null?void 0:a.vault.name)??e.embedding.provider;return h.jsxs("div",{className:"p-6",children:[h.jsx(yi,{title:"Settings",subtitle:"Vault configuration and daemon settings"}),h.jsxs("div",{className:"space-y-6",children:[h.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[h.jsxs(Qe,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-sage",children:[h.jsx(Bt,{children:"Project"}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(ni,{children:"Vault Name"}),h.jsx(cn,{value:C,readOnly:!0,disabled:!0,className:"text-on-surface-variant bg-surface-container-lowest"})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(ni,{children:"Daemon Port"}),h.jsx(cn,{type:"number",placeholder:"Auto",value:o.daemonPort,onChange:T=>S("daemonPort",T.target.value)}),h.jsx(Ov,{children:"Leave blank to use a random available port."})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(ni,{children:"Log Level"}),h.jsxs(Zi,{value:o.logLevel,onValueChange:T=>S("logLevel",T),children:[h.jsx(vi,{children:h.jsx(Ji,{})}),h.jsx(pi,{children:Sre.map(T=>h.jsx(ia,{value:T,children:T},T))})]})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(ni,{children:"Log Retention (days)"}),h.jsx(cn,{type:"number",min:1,max:365,className:"w-24",value:o.logRetentionDays,onChange:T=>S("logRetentionDays",T.target.value)})]})]})]}),h.jsxs(Qe,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-ochre h-fit",children:[h.jsx(Bt,{children:"Embedding"}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(ni,{children:"Provider"}),h.jsxs(Zi,{value:o.embeddingProvider,onValueChange:T=>{S("embeddingProvider",T),m("idle"),x("")},children:[h.jsx(vi,{children:h.jsx(Ji,{})}),h.jsx(pi,{children:Ere.map(T=>h.jsx(ia,{value:T.value,children:T.label},T.value))})]})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(ni,{children:"Model"}),h.jsx(cn,{placeholder:"bge-m3",value:o.embeddingModel,onChange:T=>S("embeddingModel",T.target.value)})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(ni,{hint:"optional",children:"Base URL"}),h.jsx(cn,{type:"url",placeholder:"http://localhost:11434",value:o.embeddingBaseUrl,onChange:T=>{S("embeddingBaseUrl",T.target.value),m("idle"),x("")}})]}),h.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[h.jsxs(_e,{type:"button",variant:"ghost",size:"sm",onClick:N,disabled:p==="testing",children:[p==="testing"?h.jsx(qn,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Test Connection"]}),p==="success"&&h.jsxs("span",{className:"flex items-center gap-1 font-sans text-sm text-primary",children:[h.jsx(_R,{className:"h-4 w-4"}),y]}),p==="error"&&h.jsxs("span",{className:"flex items-center gap-1 font-sans text-sm text-tertiary",children:[h.jsx(Ed,{className:"h-4 w-4"}),y]})]})]})]})]}),h.jsxs(Qe,{level:"low",className:"p-6 space-y-5 border-t-2 border-t-ochre",children:[h.jsx(Bt,{children:"Context Injection"}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(ni,{children:"Digest Tier"}),h.jsxs(Zi,{value:o.contextDigestTier,onValueChange:T=>S("contextDigestTier",T),children:[h.jsx(vi,{children:h.jsx(Ji,{})}),h.jsx(pi,{children:Cre.map(T=>h.jsx(ia,{value:T.value,children:T.label},T.value))})]}),h.jsx(Ov,{children:"Token budget for digest context injected at session start."})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"space-y-0.5",children:[h.jsx(ni,{children:"Prompt Search"}),h.jsx(Ov,{children:"Search vault for relevant observations on each prompt."})]}),h.jsx(fl,{checked:o.contextPromptSearch,onCheckedChange:T=>S("contextPromptSearch",T)})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(ni,{children:"Max Spores per Prompt"}),h.jsx(cn,{type:"number",min:"0",max:"10",placeholder:"3",value:o.contextMaxSpores,onChange:T=>S("contextMaxSpores",T.target.value)}),h.jsx(Ov,{children:"Maximum observations injected per prompt. Lower = leaner context."})]})]})]}),h.jsx(wre,{}),h.jsx(bre,{}),h.jsxs(Qe,{level:"low",className:"p-4 flex items-center gap-4 border-t-2 border-t-sage",children:[h.jsxs(_e,{onClick:w,disabled:!b||r,children:[r?h.jsx(qn,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save Settings"]}),c&&h.jsx("span",{className:c.type==="success"?"font-sans text-sm text-primary":"font-sans text-sm text-tertiary",children:c.text})]})]})]})}function jre(){return ca({queryKey:["embedding-details"],queryFn:({signal:e})=>ot("/embedding/details",{signal:e}),refetchInterval:Rr.STATS,pollCategory:"standard"})}const Lv=1024;function AA(e){if(e<Lv)return`${e} B`;const t=e/Lv;return t<Lv?`${t.toFixed(1)} KB`:`${(t/Lv).toFixed(1)} MB`}function Are(e){return new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Rre(){const[e,t]=j.useState([]),[n,r]=j.useState(!1),[a,i]=j.useState(!1),[l,o]=j.useState(null),[f,c]=j.useState(null),[d,p]=j.useState(""),[m,y]=j.useState(!1);j.useEffect(()=>{ot("/backup/config").then(C=>{p(C.dir??"")}).catch(()=>{})},[]);const x=j.useCallback(async()=>{y(!0);try{await oc("/backup/config",{dir:d||null}),o({type:"success",text:d?"Backup directory updated. Restart daemon to apply.":"Backup directory reset to default. Restart daemon to apply."})}catch{o({type:"error",text:"Failed to save backup directory."})}finally{y(!1)}},[d]),b=j.useCallback(async()=>{try{const C=await ot("/backups");t(C.backups),r(!0)}catch(C){o({type:"error",text:`Failed to load backups: ${C.message}`})}},[]);!n&&!a&&(i(!0),b().finally(()=>i(!1)));async function S(){o(null),c(null);try{const C=await kn("/backup");o({type:"success",text:`Backup created: ${C.machine_id} (${AA(C.size_bytes)})`}),await b()}catch(C){o({type:"error",text:`Backup failed: ${C.message}`})}}async function w(C){o(null),c(null);try{const T=await kn("/restore/preview",{machine_id:C});c(T)}catch(T){o({type:"error",text:`Preview failed: ${T.message}`})}}async function N(C){o(null),c(null);try{const T=await kn("/restore",{machine_id:C});o({type:"success",text:`Restored ${T.total_restored} records, skipped ${T.total_skipped} duplicates`})}catch(T){o({type:"error",text:`Restore failed: ${T.message}`})}}return h.jsxs(Qe,{level:"low",className:"p-6 space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(gz,{className:"h-4 w-4 text-primary"}),h.jsx(Bt,{children:"Backup & Restore"})]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsxs(_e,{variant:"ghost",size:"sm",onClick:b,children:[h.jsx(vo,{className:"mr-1.5 h-3.5 w-3.5"}),"Refresh"]}),h.jsxs(_e,{variant:"default",size:"sm",onClick:S,children:[h.jsx(cz,{className:"mr-1.5 h-3.5 w-3.5"}),"Backup Now"]})]})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsxs("label",{className:"font-sans text-xs text-on-surface-variant flex items-center gap-1.5",children:[h.jsx(mz,{className:"h-3.5 w-3.5"}),"Backup Directory"]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("input",{type:"text",value:d,onChange:C=>p(C.target.value),placeholder:".myco/backups",className:"flex-1 bg-surface-container text-on-surface font-mono text-sm rounded px-3 py-1.5 outline-none border border-outline-variant/15 focus:border-primary/40 placeholder:text-on-surface-variant/50"}),h.jsx(_e,{variant:"ghost",size:"sm",onClick:x,disabled:m,children:m?"Saving...":"Save"})]}),h.jsx("p",{className:"font-sans text-xs text-on-surface-variant",children:"Override where backups are stored. Leave empty for default (.myco/backups). Supports ~ for home directory. Useful for network shares or git-tracked directories."})]}),l&&h.jsx("p",{className:Te("font-sans text-sm",l.type==="success"?"text-primary":"text-tertiary"),children:l.text}),e.length>0?h.jsx("div",{className:"space-y-2",children:e.map(C=>h.jsxs("div",{className:Te("flex items-center justify-between rounded-md px-4 py-3","bg-surface-container-lowest transition-colors"),children:[h.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[h.jsx("span",{className:"font-mono text-sm text-on-surface truncate",children:C.machine_id}),h.jsx(Ct,{variant:"secondary",children:AA(C.size_bytes)}),h.jsx("span",{className:"text-xs text-on-surface-variant",children:Are(C.modified_at)})]}),h.jsxs("div",{className:"flex gap-2 flex-shrink-0 ml-3",children:[h.jsx(_e,{variant:"ghost",size:"sm",onClick:()=>w(C.machine_id),children:"Preview"}),h.jsxs(_e,{variant:"secondary",size:"sm",onClick:()=>N(C.machine_id),children:[h.jsx(Bz,{className:"mr-1.5 h-3.5 w-3.5"}),"Restore"]})]})]},C.machine_id))}):n?h.jsx("p",{className:"font-sans text-sm text-on-surface-variant",children:'No backups yet. Click "Backup Now" to create one.'}):null,f&&h.jsxs(Qe,{level:"lowest",className:"p-4 space-y-3",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Bt,{children:"Restore Preview"}),h.jsx(Ct,{variant:"outline",children:f.machine_id})]}),h.jsx("div",{className:"overflow-x-auto",children:h.jsxs("table",{className:"w-full font-mono text-sm","aria-label":"Restore preview",children:[h.jsx("thead",{children:h.jsxs("tr",{className:"text-left text-on-surface-variant",children:[h.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest",scope:"col",children:"Table"}),h.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"New"}),h.jsx("th",{className:"pb-2 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"Existing"})]})}),h.jsx("tbody",{children:f.tables.map((C,T)=>h.jsxs("tr",{className:Te("transition-colors hover:bg-surface-container-high/50",T%2===1?"bg-surface-container-low/30":""),children:[h.jsx("td",{className:"py-2 pr-4",children:C.table}),h.jsx("td",{className:"py-2 pr-4 text-right",children:C.new>0?h.jsx("span",{className:"text-primary",children:C.new}):0}),h.jsx("td",{className:"py-2 text-right text-on-surface-variant",children:C.existing})]},C.table))})]})}),h.jsxs("div",{className:"flex gap-4 font-sans text-sm text-on-surface-variant",children:[h.jsxs("span",{children:["New: ",h.jsx("strong",{className:"text-primary",children:f.total_new})]}),h.jsxs("span",{children:["Existing: ",h.jsx("strong",{children:f.total_existing})]})]})]})]})}const Dre=["stable","beta"],RA=500,Mre=6e4;function Ore(e){return e?new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"Never"}function Lre(){const{data:e}=KR(),t=Yz(),n=Xz(),r=Qz(),[a,i]=j.useState("idle"),[l,o]=j.useState(null),f=j.useCallback(async()=>{i("applying"),o(null);try{await n.mutateAsync(),i("restarting");const b=Date.now()+Mre;await new Promise((S,w)=>{const N=async()=>{if(Date.now()>b){w(new Error("timeout"));return}try{if((await fetch("/health")).ok){S();return}}catch{}setTimeout(N,RA)};setTimeout(N,RA)}),window.location.reload()}catch(b){i("error");const S=b.message==="timeout"?"Daemon did not restart within the expected time. Check the terminal.":b.message;o(S)}},[n]),c=j.useCallback(()=>{t.mutate()},[t]),d=j.useCallback(b=>{r.mutate(b)},[r]);if(!e)return null;const p=t.isPending,m=a==="applying"||a==="restarting",y=e.update_available===!0,x=e.channel??"stable";return e.exempt?h.jsxs(Qe,{level:"low",className:"p-6 space-y-4",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Dz,{className:"h-4 w-4 text-primary"}),h.jsx(Bt,{children:"Updates"})]}),h.jsxs("p",{className:"font-sans text-sm text-on-surface-variant",children:["Updates are disabled in development mode."," ",h.jsx("span",{className:"font-mono text-xs text-outline",children:e.running_version})]})]}):h.jsxs(Qe,{level:"low",className:"p-6 space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(vb,{className:Te("h-4 w-4",y?"text-secondary":"text-primary")}),h.jsx(Bt,{children:"Updates"})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"font-mono text-xs text-outline",children:e.running_version}),y&&e.latest_version&&h.jsx(Ct,{variant:"warning",children:e.latest_version})]})]}),h.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[y?h.jsx(_e,{variant:"default",size:"sm",onClick:f,disabled:m,children:m?h.jsxs(h.Fragment,{children:[h.jsx(vo,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),a==="restarting"?"Restarting…":"Updating…"]}):h.jsxs(h.Fragment,{children:[h.jsx(vb,{className:"mr-1.5 h-3.5 w-3.5"}),"Update & Restart"]})}):h.jsxs("div",{className:"flex items-center gap-1.5 text-primary",children:[h.jsx(Sd,{className:"h-4 w-4"}),h.jsx("span",{className:"font-sans text-sm",children:"Up to date"})]}),h.jsxs(_e,{variant:"ghost",size:"sm",onClick:c,disabled:p||m,children:[h.jsx(vo,{className:Te("mr-1.5 h-3.5 w-3.5",p&&"animate-spin")}),"Check Now"]})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("div",{className:"flex items-center gap-1",children:Dre.map(b=>h.jsx(_e,{variant:x===b?"default":"ghost",className:"text-xs capitalize h-6 px-2",onClick:()=>d(b),disabled:r.isPending||m,children:b},b))}),h.jsxs("span",{className:"font-sans text-xs text-on-surface-variant",children:["Checked: ",Ore(e.last_check)]})]}),(a==="error"||e.error)&&h.jsxs("div",{className:"flex items-start gap-2 text-tertiary",children:[h.jsx(Ar,{className:"h-4 w-4 mt-0.5 flex-shrink-0"}),h.jsx("span",{className:"font-sans text-sm",children:l??e.error})]})]})}const _re=["sessions","spores","plans","artifacts"],DA="embedding",Bre=100,MA=2e3,Pre=40,OA=20,zre=[{id:"embedding",label:"Embedding"},{id:"system",label:"System"}],Ire=new Set(["embedding","system"]),s5="tab";function Fre(){const t=new URLSearchParams(window.location.search).get(s5);return t&&Ire.has(t)?t:"embedding"}function qre(e){const t=new URLSearchParams;e!=="embedding"&&t.set(s5,e);const n=t.toString(),r=n?`${window.location.pathname}?${n}`:window.location.pathname;window.history.replaceState(null,"",r)}function Ure(e){return e.provider.available?Object.values(e.pending).some(n=>n>0)?"processing":"idle":"unavailable"}function Vre(e){return e.provider.available?Object.values(e.pending).some(n=>n>0)?"bg-secondary":"bg-primary":"bg-tertiary"}function Hre(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0"),a=String(t.getSeconds()).padStart(2,"0");return`${n}:${r}:${a}`}function $re(e){return e.scrollHeight-e.scrollTop-e.clientHeight<=Pre}function Gre({data:e}){return h.jsx("div",{className:"overflow-x-auto",children:h.jsxs("table",{className:"w-full font-mono text-sm","aria-label":"Embedding namespace breakdown",children:[h.jsx("thead",{children:h.jsxs("tr",{className:"text-left text-on-surface-variant",children:[h.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest",scope:"col",children:"Namespace"}),h.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"Embedded"}),h.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"Pending"}),h.jsx("th",{className:"pb-2 pr-4 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"Stale"}),h.jsx("th",{className:"pb-2 font-sans font-medium text-xs uppercase tracking-widest text-right",scope:"col",children:"Total"})]})}),h.jsx("tbody",{children:_re.map((t,n)=>{const r=e.by_namespace[t],a=(r==null?void 0:r.embedded)??0,i=(r==null?void 0:r.stale)??0,l=e.pending[t]??0,o=a+l;return h.jsxs("tr",{className:Te("transition-colors hover:bg-surface-container-high/50",n%2===1?"bg-surface-container-low/30":""),children:[h.jsx("td",{className:"py-2.5 pr-4",children:t}),h.jsx("td",{className:"py-2.5 pr-4 text-right",children:a}),h.jsx("td",{className:"py-2.5 pr-4 text-right",children:l>0?h.jsx("span",{className:"text-secondary",children:l}):l}),h.jsx("td",{className:"py-2.5 pr-4 text-right",children:i>0?h.jsx("span",{className:"text-tertiary",children:i}):i}),h.jsx("td",{className:"py-2.5 text-right",children:o})]},t)})})]})})}function Kre({entry:e}){return h.jsxs("tr",{className:"hover:bg-surface-container-high/30 transition-colors",children:[h.jsx("td",{className:"whitespace-nowrap py-1.5 pl-4 pr-3 text-on-surface-variant/60 align-top w-[68px]",children:Hre(e.timestamp)}),h.jsx("td",{className:"whitespace-nowrap py-1.5 pr-3 align-top w-[20px]",children:h.jsx("div",{className:Te("h-2 w-2 rounded-full mt-1",R1(e.level))})}),h.jsx("td",{className:"whitespace-nowrap py-1.5 pr-3 align-top w-[54px]",children:h.jsx(Ct,{variant:GR(e.level),className:"px-1.5 py-0 text-[10px] uppercase",children:e.level})}),h.jsx("td",{className:"py-1.5 pr-4 text-on-surface align-top break-words",children:e.message})]})}function Yre({data:e}){const t=Vn(),[n,r]=j.useState(null),[a,i]=j.useState([]);j.useEffect(()=>{i(_=>{const P=[..._,e.total];return P.length>OA?P.slice(-OA):P})},[e]);const[l,o]=j.useState([]),[f,c]=j.useState(void 0),[d,p]=j.useState(!0),[m,y]=j.useState(!1),x=j.useRef(null),b=j.useRef(d);b.current=d;const S=j.useRef(f);S.current=f;const{data:w}=ca({queryKey:["embedding-logs"],queryFn:({signal:_})=>{const P=new URLSearchParams({limit:String(Bre),category:DA});return S.current&&P.set("since",S.current),ot(`/logs?${P.toString()}`,{signal:_})},refetchInterval:Rr.LOGS,pollCategory:"standard"});j.useEffect(()=>{w!=null&&w.entries.length&&(o(_=>{let P;if(w.cursor_reset){const H=new Set(_.map(V=>`${V.timestamp}|${V.message}`)),$=w.entries.filter(V=>!H.has(`${V.timestamp}|${V.message}`));P=$.length?[..._,...$]:_}else P=[..._,...w.entries];return P.length>MA?P.slice(-MA):P}),c(w.cursor),b.current||y(!0))},[w]),j.useEffect(()=>{!d||!x.current||(x.current.scrollTop=x.current.scrollHeight,y(!1))},[l,d]);const N=j.useCallback(()=>{const _=x.current;_&&($re(_)?(p(!0),y(!1)):p(!1))},[]),C=j.useCallback(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight,p(!0),y(!1))},[]),T=j.useMemo(()=>{const _=np.debug;return l.filter(P=>!(np[P.level]<_||P.category!==DA))},[l]);async function R(){r(null);try{const _=await kn("/embedding/reembed-stale");r({type:"success",text:`Re-embedded ${_.reembedded} stale vectors`}),t.invalidateQueries({queryKey:["embedding-details"]})}catch(_){r({type:"error",text:`Error: ${_.message}`})}}async function A(){if(confirm("This will re-embed all vectors. Continue?")){r(null);try{const _=await kn("/embedding/rebuild");r({type:"success",text:`Rebuild queued: ${_.queued} vectors to re-embed`}),t.invalidateQueries({queryKey:["embedding-details"]})}catch(_){r({type:"error",text:`Error: ${_.message}`})}}}async function D(){r(null);try{const _=await kn("/embedding/clean-orphans");r({type:"success",text:`Cleaned ${_.orphans_cleaned} orphan vectors`}),t.invalidateQueries({queryKey:["embedding-details"]})}catch(_){r({type:"error",text:`Error: ${_.message}`})}}async function L(){r(null);try{const _=await kn("/embedding/reconcile");r({type:"success",text:`Reconcile complete: ${_.embedded} embedded, ${_.orphans_cleaned} orphans cleaned (${_.duration_ms}ms)`}),t.invalidateQueries({queryKey:["embedding-details"]})}catch(_){r({type:"error",text:`Error: ${_.message}`})}}const B=Object.values(e.pending).reduce((_,P)=>_+P,0),M=Object.values(e.by_namespace).reduce((_,P)=>_+P.stale,0);return h.jsxs("div",{className:"space-y-6",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-4 font-sans text-sm",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(N1,{className:"h-4 w-4 text-primary"}),h.jsx("span",{className:"text-on-surface-variant",children:"Provider"}),h.jsx("span",{className:"font-mono text-on-surface",children:e.provider.name})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-on-surface-variant",children:"Model"}),h.jsx("span",{className:"font-mono text-xs text-on-surface truncate max-w-[200px]",title:e.provider.model,children:e.provider.model})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("div",{className:Te("h-2 w-2 rounded-full",Vre(e))}),h.jsx("span",{className:"text-on-surface-variant capitalize",children:Ure(e)})]})]}),h.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[h.jsx(sn,{label:"Total Vectors",value:String(e.total),sparklineData:a,accent:"sage"}),h.jsx(sn,{label:"Pending",value:String(B),accent:B>0?"ochre":"outline"}),h.jsx(sn,{label:"Stale",value:String(M),accent:M>0?"terracotta":"outline"})]}),h.jsxs(Qe,{level:"low",className:"p-6 space-y-4",children:[h.jsx(Bt,{children:"Namespace Breakdown"}),h.jsx(Gre,{data:e})]}),h.jsxs(Qe,{level:"low",className:"p-6 space-y-3",children:[h.jsx(Bt,{children:"Actions"}),h.jsxs("div",{className:"flex flex-wrap gap-2",children:[h.jsxs(_e,{variant:"ghost",size:"sm",onClick:R,children:[h.jsx(vo,{className:"mr-2 h-4 w-4"}),"Re-embed stale"]}),h.jsxs(_e,{variant:"ghost",size:"sm",onClick:D,children:[h.jsx(dl,{className:"mr-2 h-4 w-4"}),"Clean orphans"]}),h.jsxs(_e,{variant:"secondary",size:"sm",onClick:L,children:[h.jsx(Zu,{className:"mr-2 h-4 w-4"}),"Force reconcile"]}),h.jsxs(_e,{variant:"destructive",size:"sm",onClick:A,children:[h.jsx(k1,{className:"mr-2 h-4 w-4"}),"Rebuild all"]})]}),n&&h.jsx("p",{className:Te("font-sans text-sm",n.type==="success"?"text-primary":"text-tertiary"),children:n.text})]}),h.jsxs(Qe,{level:"low",className:"flex flex-col overflow-hidden",children:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4",children:[h.jsx(Bt,{children:"Activity Log"}),h.jsxs(_e,{size:"sm",variant:d?"default":"ghost",className:"h-7 gap-1.5 px-2 text-xs",onClick:()=>{d?p(!1):C()},title:d?"Pause auto-scroll":"Resume auto-scroll",children:[d?h.jsx(kz,{className:"h-3 w-3"}):h.jsx(Zu,{className:"h-3 w-3"}),d?"Pause":"Resume"]})]}),h.jsxs("div",{className:"relative flex-1 p-0",children:[h.jsx("div",{ref:x,onScroll:N,className:"h-64 overflow-y-auto font-mono text-xs bg-surface-container-lowest",children:T.length===0?h.jsx("div",{className:"flex h-32 items-center justify-center font-sans text-on-surface-variant",children:"No embedding log entries"}):h.jsx("table",{className:"w-full border-collapse","aria-label":"Embedding activity log",children:h.jsx("tbody",{children:T.map((_,P)=>h.jsx(Kre,{entry:_},`${_.timestamp}-${P}`))})})}),m&&!d&&h.jsxs("button",{type:"button",onClick:C,className:Te("absolute bottom-4 left-1/2 -translate-x-1/2","flex items-center gap-1.5 rounded-full","bg-surface-container-high px-3 py-1.5 text-xs font-medium shadow-ambient","text-on-surface-variant transition-colors hover:text-on-surface"),children:[h.jsx(az,{className:"h-3 w-3"}),"New entries below"]})]})]})]})}function Xre(){return h.jsxs("div",{className:"space-y-6",children:[h.jsx(Lre,{}),h.jsx(Rre,{})]})}const Qre={embedding:"Embedding health, maintenance actions, and activity log",system:"Software updates and backup management"};function Wre(){const{data:e,isLoading:t,isError:n,error:r}=jre(),[a,i]=j.useState(Fre),l=j.useCallback(o=>{const f=o;i(f),qre(f)},[]);return h.jsx(U1,{isLoading:t,error:n?r instanceof Error?r:new Error("Unable to reach daemon"):null,loadingText:"Loading operations...",children:e&&h.jsxs("div",{className:"flex h-full flex-col",children:[h.jsx("div",{className:"px-6 pt-6",children:h.jsx(yi,{title:"Operations",subtitle:Qre[a],tabs:zre,activeTab:a,onTabChange:l})}),h.jsx("div",{className:"flex-1 overflow-auto",children:h.jsxs("div",{className:"px-6 pb-6",children:[a==="embedding"&&h.jsx(Yre,{data:e}),a==="system"&&h.jsx(Xre,{})]})})]})})}function Zre(){return ca({queryKey:["team-status"],queryFn:({signal:e})=>ot("/team/status",{signal:e}),refetchInterval:Rr.STATS,pollCategory:"standard"})}function X0({label:e,value:t,mono:n=!0}){const[r,a]=j.useState(!1),i=j.useCallback(()=>{navigator.clipboard.writeText(t).then(()=>{a(!0),setTimeout(()=>a(!1),2e3)})},[t]);return h.jsxs("div",{className:"space-y-1",children:[h.jsx("span",{className:"text-xs text-on-surface-variant",children:e}),h.jsxs("div",{className:"flex items-center gap-2 group",children:[h.jsx("span",{className:`text-sm text-on-surface break-all ${n?"font-mono":""}`,children:t}),h.jsx("button",{type:"button",onClick:i,className:"flex-shrink-0 p-1 rounded text-on-surface-variant hover:text-on-surface opacity-0 group-hover:opacity-100 transition-opacity",title:"Copy to clipboard",children:r?h.jsx(wd,{className:"h-3.5 w-3.5 text-primary"}):h.jsx(PR,{className:"h-3.5 w-3.5"})})]})]})}function Jre({label:e,value:t}){const[n,r]=j.useState(!1),[a,i]=j.useState(!1),l=j.useCallback(()=>{navigator.clipboard.writeText(t).then(()=>{i(!0),setTimeout(()=>i(!1),2e3)})},[t]),o=`${t.slice(0,8)}${"*".repeat(Math.max(0,t.length-12))}${t.slice(-4)}`;return h.jsxs("div",{className:"space-y-1",children:[h.jsx("span",{className:"text-xs text-on-surface-variant",children:e}),h.jsxs("div",{className:"flex items-center gap-2 group",children:[h.jsx("span",{className:"text-sm text-on-surface font-mono break-all",children:n?t:o}),h.jsx("button",{type:"button",onClick:()=>r(!n),className:"flex-shrink-0 p-1 rounded text-on-surface-variant hover:text-on-surface transition-opacity",title:n?"Hide":"Reveal",children:n?h.jsx(fz,{className:"h-3.5 w-3.5"}):h.jsx(dz,{className:"h-3.5 w-3.5"})}),h.jsx("button",{type:"button",onClick:l,className:"flex-shrink-0 p-1 rounded text-on-surface-variant hover:text-on-surface opacity-0 group-hover:opacity-100 transition-opacity",title:"Copy to clipboard",children:a?h.jsx(wd,{className:"h-3.5 w-3.5 text-primary"}):h.jsx(PR,{className:"h-3.5 w-3.5"})})]})]})}function eae({onConnected:e}){const[t,n]=j.useState(""),[r,a]=j.useState(""),[i,l]=j.useState(null),[o,f]=j.useState(!1),c=async d=>{d.preventDefault(),l(null),f(!0);try{await kn("/team/connect",{url:t,api_key:r}),e()}catch(p){l(p instanceof Error?p.message:"Connection failed")}finally{f(!1)}};return h.jsxs(Qe,{level:"low",ghostBorder:!0,className:"p-6",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[h.jsx(zz,{className:"h-4 w-4 text-on-surface-variant"}),h.jsx(Bt,{children:"Connect to team"})]}),h.jsx("p",{className:"text-sm text-on-surface-variant mb-4",children:"Enter the URL and API key for your team's Cloudflare Worker to enable cross-machine knowledge sharing."}),h.jsxs("form",{onSubmit:c,className:"space-y-3",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-xs font-medium text-on-surface-variant mb-1",children:"Worker URL"}),h.jsx(cn,{type:"url",placeholder:"https://myco-team.your-account.workers.dev",value:t,onChange:d=>n(d.target.value),required:!0})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-xs font-medium text-on-surface-variant mb-1",children:"API Key"}),h.jsx(cn,{type:"password",placeholder:"your-api-key",value:r,onChange:d=>a(d.target.value),required:!0})]}),i&&h.jsx("p",{className:"text-sm text-tertiary",children:i}),h.jsx(_e,{type:"submit",size:"sm",disabled:o||!t||!r,children:o?h.jsxs(h.Fragment,{children:[h.jsx(vo,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}),"Connecting..."]}):"Connect"})]})]})}function tae({status:e}){const t=Vn(),[n,r]=j.useState(!1),[a,i]=j.useState(!1),[l,o]=j.useState(null),[f,c]=j.useState(!1),[d,p]=j.useState(null),[m,y]=j.useState(!1),[x,b]=j.useState(null),S=async()=>{r(!0);try{await kn("/team/disconnect"),t.invalidateQueries({queryKey:["team-status"]})}finally{r(!1)}},w=j.useCallback(async()=>{i(!0),o(null);try{const T=await kn("/team/backfill");o(T.enqueued>0?`Enqueued ${T.enqueued} records for sync. They'll push on the next flush cycle.`:"All records are already synced or enqueued."),t.invalidateQueries({queryKey:["team-status"]})}catch{o("Backfill failed.")}finally{i(!1)}},[t]),N=j.useCallback(async()=>{c(!0),p(null);try{const T=await kn("/team/upgrade-worker");T.success?(p(`Worker updated to v${T.version}`),t.invalidateQueries({queryKey:["team-status"]})):p(T.error??"Upgrade failed")}catch(T){p(T instanceof Error?T.message:"Upgrade failed")}finally{c(!1)}},[t]),C=j.useCallback(async()=>{y(!0),b(null);try{const T=await kn("/team/retry-failed");b(T.retried>0?`Re-queued ${T.retried} record${T.retried>1?"s":""} for sync.`:"No failed records to retry."),t.invalidateQueries({queryKey:["team-status"]})}catch{b("Retry failed.")}finally{y(!1)}},[t]);return h.jsxs("div",{className:"space-y-4",children:[e.worker_update_available&&h.jsxs(Qe,{level:"low",ghostBorder:!0,className:"p-4 border-l-2 border-l-ochre",children:[h.jsxs("div",{className:"flex items-center justify-between gap-4",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(vb,{className:"h-5 w-5 text-ochre flex-shrink-0"}),h.jsxs("div",{children:[h.jsx("p",{className:"text-sm font-medium text-on-surface",children:"Worker update available"}),h.jsxs("p",{className:"text-xs text-on-surface-variant",children:["Deployed: v",e.deployed_worker_version??"?"," — Local: v",e.package_version]})]})]}),h.jsx(_e,{variant:"default",size:"sm",onClick:N,disabled:f,children:f?h.jsxs(h.Fragment,{children:[h.jsx(vo,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}),"Deploying..."]}):"Update Worker"})]}),d&&h.jsx("p",{className:"text-xs text-on-surface-variant mt-2",children:d})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[h.jsx(sn,{label:"Status",value:e.healthy?"Connected":"Unhealthy",accent:e.healthy?"sage":"terracotta"}),h.jsx(sn,{label:"Pending sync",value:String(e.pending_sync_count),accent:e.dead_letter_count>0?"terracotta":"outline",sublabel:e.dead_letter_count>0?`${e.dead_letter_count} failed`:void 0,href:"/logs?component=team-sync"}),h.jsx(sn,{label:"Protocol",value:`v${e.sync_protocol_version}`,accent:"outline"}),h.jsx(sn,{label:"Schema",value:`v${e.schema_version}`,accent:"outline"})]}),h.jsxs(Qe,{level:"low",ghostBorder:!0,className:"p-5 space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx(Bt,{children:"Team Credentials"}),h.jsx(Ct,{variant:e.healthy?"default":"destructive",children:e.healthy?"healthy":"unhealthy"})]}),h.jsx("p",{className:"text-xs text-on-surface-variant",children:"Share these with teammates so they can connect from the Team page."}),h.jsxs("div",{className:"space-y-3",children:[e.worker_url&&h.jsx(X0,{label:"Worker URL",value:e.worker_url}),e.api_key&&h.jsx(Jre,{label:"API Key",value:e.api_key})]})]}),h.jsxs(Qe,{level:"low",ghostBorder:!0,className:"p-5 space-y-4",children:[h.jsx(Bt,{children:"This Node"}),h.jsxs("div",{className:"grid gap-3",children:[h.jsx(X0,{label:"Machine ID",value:e.machine_id}),h.jsx(X0,{label:"Package Version",value:e.package_version})]}),e.health_error&&h.jsx("p",{className:"text-sm text-tertiary mt-2",children:e.health_error})]}),h.jsxs(Qe,{level:"low",ghostBorder:!0,className:"p-5 space-y-3",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx(Bt,{children:"Sync"}),h.jsx(_e,{variant:"default",size:"sm",onClick:w,disabled:a,children:a?h.jsxs(h.Fragment,{children:[h.jsx(vo,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}),"Syncing..."]}):"Sync All"})]}),h.jsx("p",{className:"text-xs text-on-surface-variant",children:"Push all unsynced local knowledge to the team store. Records sync automatically on new writes, but historical data needs a one-time backfill."}),l&&h.jsx("p",{className:"text-sm text-primary",children:l}),e.dead_letter_count>0&&h.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-outline-variant/10",children:[h.jsxs("p",{className:"text-xs text-on-surface-variant",children:[h.jsxs("span",{className:"text-tertiary font-medium",children:[e.dead_letter_count," failed"]})," record",e.dead_letter_count>1?"s":""," — exceeded max retries."," ",h.jsx("a",{href:"/logs?component=team-sync&level=error",className:"underline hover:text-on-surface",children:"View logs"})]}),h.jsx(_e,{variant:"outline",size:"sm",onClick:C,disabled:m,children:m?"Retrying...":"Retry Failed"})]}),x&&h.jsx("p",{className:"text-xs text-primary",children:x})]}),h.jsx("div",{className:"flex justify-end",children:h.jsx(_e,{variant:"outline",size:"sm",onClick:S,disabled:n,children:n?"Disconnecting...":"Disconnect"})})]})}function nae(){const{data:e,isLoading:t}=Zre(),n=Vn();if(t)return h.jsx(U1,{isLoading:!0,error:null,children:h.jsx("span",{})});const r=(e==null?void 0:e.enabled)&&(e==null?void 0:e.worker_url);return h.jsxs("div",{className:"p-6 max-w-4xl",children:[h.jsx(yi,{title:"Team",subtitle:"Share knowledge across machines with team sync"}),r&&e?h.jsx(tae,{status:e}):h.jsxs("div",{className:"space-y-4",children:[h.jsxs(Qe,{level:"low",ghostBorder:!0,className:"p-6 space-y-4",children:[h.jsx(Bt,{children:"Getting Started"}),h.jsx("p",{className:"text-sm text-on-surface-variant",children:"Team sync lets multiple machines share captured knowledge through a Cloudflare Worker. One team member provisions the infrastructure, then shares the connection details."}),h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-sm font-medium text-on-surface mb-1",children:"1. Install Wrangler"}),h.jsx("code",{className:"block font-mono text-xs bg-surface-container rounded px-3 py-2 text-on-surface-variant",children:"npm install -g wrangler && wrangler login"})]}),h.jsxs("div",{children:[h.jsx("p",{className:"text-sm font-medium text-on-surface mb-1",children:"2. Provision the team"}),h.jsx("code",{className:"block font-mono text-xs bg-surface-container rounded px-3 py-2 text-on-surface-variant",children:"myco team init"}),h.jsx("p",{className:"text-xs text-on-surface-variant mt-1",children:"Creates a D1 database, Vectorize index, and deploys the sync worker. Outputs a Worker URL and API key to share with teammates."})]}),h.jsxs("div",{children:[h.jsx("p",{className:"text-sm font-medium text-on-surface mb-1",children:"3. Connect"}),h.jsxs("p",{className:"text-xs text-on-surface-variant",children:["Paste the Worker URL and API key below, or if you ran ",h.jsx("code",{className:"font-mono",children:"myco team init"}),", you're already connected."]})]})]})]}),h.jsx(eae,{onConnected:()=>n.invalidateQueries({queryKey:["team-status"]})})]})]})}const rae=[{value:"15m",label:"15m"},{value:"1h",label:"1h"},{value:"6h",label:"6h"},{value:"24h",label:"24h"},{value:"7d",label:"7d"},{value:"30d",label:"30d"}];function aae({mode:e,onModeChange:t,searchValue:n,onSearchChange:r,onSearchSubmit:a,activeLevel:i,onLevelChange:l,components:o,activeComponents:f,onComponentToggle:c,onComponentsClear:d,timeRange:p,onTimeRangeChange:m,totalResults:y}){return h.jsxs(Qe,{level:"default",className:"rounded-md p-3 space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsxs("div",{className:"flex items-center rounded-md bg-surface-container-low",children:[h.jsxs(_e,{size:"sm",variant:e==="live"?"default":"ghost",className:"h-7 gap-1.5 px-2.5 text-xs rounded-r-none",onClick:()=>t("live"),children:[h.jsx(FR,{className:"h-3 w-3"}),"Live"]}),h.jsxs(_e,{size:"sm",variant:e==="search"?"default":"ghost",className:"h-7 gap-1.5 px-2.5 text-xs rounded-l-none",onClick:()=>t("search"),children:[h.jsx(lc,{className:"h-3 w-3"}),"Search"]})]}),e==="search"&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-5 w-px bg-outline-variant/30"}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(BR,{className:"h-3 w-3 text-on-surface-variant/50"}),rae.map(x=>h.jsx(_e,{size:"sm",variant:p===x.value?"default":"ghost",className:"h-6 px-1.5 text-[10px]",onClick:()=>m(x.value),children:x.label},x.value))]})]}),h.jsx("form",{className:"ml-auto flex items-center gap-1.5",onSubmit:x=>{x.preventDefault(),a()},children:h.jsx(cn,{className:"h-7 w-56 text-xs",placeholder:e==="search"?"Search logs...":"Filter messages...",value:n,onChange:x=>r(x.target.value),"aria-label":"Search log messages"})}),e==="search"&&y!==void 0&&h.jsxs("span",{className:"text-[10px] font-mono text-on-surface-variant/50 tabular-nums whitespace-nowrap",children:[y.toLocaleString()," results"]})]}),h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:"flex items-center gap-1",children:Gz.map(x=>h.jsxs(_e,{size:"sm",variant:i===x?"default":"ghost",className:"h-6 px-2 text-[10px] capitalize gap-1.5",onClick:()=>l(x),children:[h.jsx("div",{className:Te("h-1.5 w-1.5 rounded-full",R1(x))}),x]},x))}),o.length>0&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-4 w-px bg-outline-variant/20"}),h.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[o.map(x=>h.jsx(_e,{size:"sm",variant:f.has(x)?"default":"ghost",className:"h-5 px-1.5 text-[10px]",onClick:()=>c(x),children:x},x)),f.size>0&&h.jsx(_e,{size:"sm",variant:"ghost",className:"h-5 px-1.5 text-[10px] text-on-surface-variant",onClick:d,children:"clear"})]})]})]})]})}const iae={debug:"border-l-outline/30",info:"border-l-primary/50",warn:"border-l-secondary/70",error:"border-l-tertiary/80"},sae={context:"text-primary/70",hooks:"text-on-surface-variant/70",agent:"text-secondary/80",daemon:"text-on-surface-variant/60",capture:"text-primary/60",processor:"text-on-surface-variant/70",lifecycle:"text-primary/50",embedding:"text-on-surface-variant/60",power:"text-on-surface-variant/50",server:"text-on-surface-variant/60"};function lae(e,t){if(t)return H1(e);const n=new Date(e),r=String(n.getHours()).padStart(2,"0"),a=String(n.getMinutes()).padStart(2,"0"),i=String(n.getSeconds()).padStart(2,"0");return`${r}:${a}:${i}`}function oae({entries:e,selectedId:t,onSelect:n,autoScroll:r=!1,relativeTime:a=!1,compact:i=!0}){const l=j.useRef(null);return j.useEffect(()=>{!r||!l.current||(l.current.scrollTop=l.current.scrollHeight)},[e,r]),h.jsx("div",{ref:l,className:"flex-1 overflow-y-auto bg-surface-container-lowest font-mono text-xs",children:e.length===0?h.jsx("div",{className:"flex h-full min-h-[200px] items-center justify-center text-on-surface-variant/50 font-sans text-sm",children:"No log entries"}):h.jsx("table",{className:"w-full border-collapse","aria-label":"Log entries",children:h.jsx("tbody",{children:e.map(o=>h.jsx(uae,{entry:o,selected:o.id===t,onSelect:n,relativeTime:a,compact:i},o.id))})})})}const uae=j.memo(function({entry:t,selected:n,onSelect:r,relativeTime:a,compact:i}){const l=i?"py-0.5":"py-1.5";return h.jsxs("tr",{className:Te("cursor-pointer transition-colors border-l-2",iae[t.level],n?"bg-primary/10":"hover:bg-surface-container-high/30"),onClick:()=>r(t),children:[h.jsx("td",{className:Te("whitespace-nowrap pl-3 pr-2 text-on-surface-variant/50 align-top w-[68px] tabular-nums",l),children:lae(t.timestamp,a)}),h.jsx("td",{className:Te("whitespace-nowrap pr-1 align-top w-[12px]",l),children:h.jsx("div",{className:Te("h-1.5 w-1.5 rounded-full mt-1",R1(t.level))})}),h.jsx("td",{className:Te("whitespace-nowrap pr-2 align-top w-[48px]",l),children:h.jsx(Ct,{variant:GR(t.level),className:"px-1 py-0 text-[9px] uppercase",children:t.level})}),h.jsx("td",{className:Te("whitespace-nowrap pr-2 align-top w-[90px] truncate max-w-[90px]",l,sae[t.component]??"text-on-surface-variant/60"),children:t.component}),h.jsx("td",{className:Te("pr-3 text-on-surface align-top break-words",l),children:t.message})]})});function cae({value:e}){const t=String(e),n=t.slice(0,8);return h.jsxs(Ra,{to:`/sessions/${t}`,className:"font-mono text-primary hover:underline",children:[n,"..."]})}function fae({value:e}){return Array.isArray(e)?h.jsx("span",{className:"flex flex-wrap gap-1",children:e.map((t,n)=>h.jsx(Ct,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:String(t)},n))}):h.jsx("span",{children:String(e)})}function dae({value:e}){return Array.isArray(e)?h.jsx("span",{className:"flex gap-1",children:e.map((t,n)=>h.jsx(Ct,{variant:"outline",className:"text-[10px] px-1.5 py-0 tabular-nums",children:String(t)},n))}):h.jsx("span",{children:String(e)})}function hae({value:e}){return h.jsx("span",{className:"rounded bg-tertiary/10 px-2 py-0.5 text-tertiary font-mono text-[11px]",children:String(e)})}function LA({value:e}){return h.jsx("pre",{className:"max-h-32 overflow-auto rounded bg-surface-container-lowest px-2 py-1 text-[11px] font-mono text-on-surface-variant whitespace-pre-wrap",children:String(e)})}function vae({value:e}){const t=new Date(String(e)),r=new Date().getTime()-t.getTime(),a=Math.floor(r/6e4),i=Math.floor(a/60),l=Math.floor(i/24);let o;return a<1?o="just now":a<60?o=`${a}m ago`:i<24?o=`${i}h ago`:o=`${l}d ago`,h.jsx("span",{className:"tabular-nums",title:t.toISOString(),children:o})}function pae({value:e}){return typeof e=="object"&&e!==null?h.jsx("pre",{className:"text-[11px] font-mono text-on-surface-variant whitespace-pre-wrap",children:JSON.stringify(e,null,2)}):h.jsx("span",{children:String(e)})}const mae={session_id:cae,spore_titles:fae,scores:dae,error:hae,preview:LA,generated_at:vae,text:LA},gae=new Set(["id","timestamp","level","kind","component","message"]);function _A(e,t){const n=mae[e]??pae;return h.jsx(n,{value:t})}function yae(e){return gae.has(e)}function xae(e){return e?Object.entries(e).filter(([t])=>!yae(t)):[]}const bae={debug:"text-on-surface-variant/60",info:"text-primary",warn:"text-secondary",error:"text-tertiary"};function wae({entry:e,resolved:t,onClose:n}){const r=xae(e.data);return h.jsxs("div",{className:"flex h-full flex-col bg-surface-container-low",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-outline-variant/10",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Ct,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-mono",children:e.kind}),h.jsx("span",{className:Te("text-xs font-medium",bae[e.level]),children:e.level.toUpperCase()})]}),h.jsx(_e,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:n,"aria-label":"Close detail panel",children:h.jsx(ns,{className:"h-3.5 w-3.5"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-4",children:[h.jsxs("div",{children:[h.jsx("div",{className:"text-[10px] uppercase tracking-wider text-on-surface-variant/50 mb-0.5",children:"Timestamp"}),h.jsx("div",{className:"font-mono text-xs tabular-nums",children:new Date(e.timestamp).toLocaleString()})]}),h.jsxs("div",{children:[h.jsx("div",{className:"text-[10px] uppercase tracking-wider text-on-surface-variant/50 mb-0.5",children:"Message"}),h.jsx("div",{className:"text-sm text-on-surface leading-relaxed",children:e.message})]}),e.session_id&&h.jsxs("div",{children:[h.jsx("div",{className:"text-[10px] uppercase tracking-wider text-on-surface-variant/50 mb-0.5",children:"Session"}),h.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[_A("session_id",e.session_id),!!(t!=null&&t.session_title)&&h.jsx("span",{className:"text-on-surface-variant/70",children:String(t.session_title)})]})]}),r.length>0&&h.jsxs("div",{children:[h.jsx("div",{className:"text-[10px] uppercase tracking-wider text-on-surface-variant/50 mb-1.5",children:"Metadata"}),h.jsx("div",{className:"space-y-2",children:r.map(([a,i])=>h.jsxs("div",{children:[h.jsx("div",{className:"text-[10px] text-on-surface-variant/40 mb-0.5",children:a}),h.jsx("div",{className:"text-xs",children:_A(a,i)})]},a))})]})]}),h.jsx("div",{className:"px-4 py-2 border-t border-outline-variant/10",children:h.jsxs("span",{className:"font-mono text-[10px] text-on-surface-variant/40 tabular-nums",children:["id: ",e.id]})})]})}const BA=5e3;function Sae(){const[e,t]=j.useState([]),n=j.useRef(0),{data:r}=tn({queryKey:["logs-stream"],queryFn:({signal:i})=>ot(`/logs/stream?since=${n.current}`,{signal:i}),refetchInterval:Rr.LOGS});j.useEffect(()=>{r!=null&&r.entries.length&&(n.current=r.cursor,t(i=>{const l=[...i,...r.entries];return l.length>BA?l.slice(-BA):l}))},[r]);const a=j.useCallback(()=>{t([])},[]);return{entries:e,clear:a}}function Eae(e,t){const n=new URLSearchParams;return e.q&&n.set("q",e.q),e.level&&n.set("level",e.level),e.component&&n.set("component",e.component),e.kind&&n.set("kind",e.kind),e.session_id&&n.set("session_id",e.session_id),e.from&&n.set("from",e.from),e.to&&n.set("to",e.to),e.page&&n.set("page",String(e.page)),e.page_size&&n.set("page_size",String(e.page_size)),tn({queryKey:["logs-search",Object.fromEntries(n)],queryFn:({signal:r})=>ot(`/logs/search?${n.toString()}`,{signal:r}),enabled:t})}function Cae(e){return tn({queryKey:["log-detail",e],queryFn:({signal:t})=>ot(`/logs/${e}`,{signal:t}),enabled:e!==null})}function Nae(e){const t=Date.now(),n={"15m":15*6e4,"1h":60*6e4,"6h":360*6e4,"24h":1440*6e4,"7d":10080*6e4,"30d":720*60*6e4};return new Date(t-(n[e]??1440*6e4)).toISOString()}function kae(){const e=j.useMemo(()=>{var F;const V=new URLSearchParams(window.location.search),I=((F=V.get("component"))==null?void 0:F.split(",").filter(Boolean))??[],U=V.get("level"),Y=V.get("q")??"",Q=I.length>0||!!U||!!Y;return{components:I,level:U,q:Y,hasFilters:Q}},[]),[t,n]=j.useState(e.hasFilters?"search":"live"),[r,a]=j.useState(e.q),[i,l]=j.useState(e.q),[o,f]=j.useState(e.level??"debug"),[c,d]=j.useState(new Set(e.components)),[p,m]=j.useState("24h"),[y,x]=j.useState(1),[b,S]=j.useState(null),{entries:w}=Sae(),N=j.useMemo(()=>({q:i||void 0,level:o!=="debug"?o:void 0,component:c.size>0?Array.from(c).join(","):void 0,from:Nae(p),page:y,page_size:$r}),[i,o,c,p,y]),{data:C}=Eae(N,t==="search"),{data:T}=Cae((b==null?void 0:b.id)??null),[R,A]=j.useState(e.components);j.useEffect(()=>{const V=t==="live"?w:(C==null?void 0:C.entries)??[];A(I=>{const U=new Set(I);let Y=!1;for(const Q of V)U.has(Q.component)||(U.add(Q.component),Y=!0);return Y?Array.from(U).sort():I})},[w,C,t]);const D=j.useMemo(()=>{const V=np[o]??0,I=r.trim().toLowerCase();return w.filter(U=>!((np[U.level]??0)<V||c.size>0&&!c.has(U.component)||I&&!U.message.toLowerCase().includes(I)))},[w,o,c,r]),L=t==="live"?D:(C==null?void 0:C.entries)??[],B=j.useCallback(V=>{n(V),S(null)},[]),M=j.useCallback(()=>{l(r),x(1)},[r]),_=j.useCallback(V=>{S(I=>(I==null?void 0:I.id)===V.id?null:V)},[]),P=j.useCallback(V=>{d(I=>{const U=new Set(I);return U.has(V)?U.delete(V):U.add(V),U}),x(1)},[]),H=j.useCallback(V=>{f(V),x(1)},[]),$=b!==null;return h.jsxs("div",{className:"flex h-full flex-col",children:[h.jsx("div",{className:"px-6 pt-6",children:h.jsx(yi,{title:"Logs",subtitle:"Daemon log explorer"})}),h.jsx("div",{className:"px-6 mb-3",children:h.jsx(aae,{mode:t,onModeChange:B,searchValue:r,onSearchChange:a,onSearchSubmit:M,activeLevel:o,onLevelChange:H,components:R,activeComponents:c,onComponentToggle:P,onComponentsClear:()=>{d(new Set),x(1)},timeRange:p,onTimeRangeChange:V=>{m(V),x(1)},totalResults:t==="search"?C==null?void 0:C.total:void 0})}),h.jsxs("div",{className:"flex flex-1 overflow-hidden mx-6 mb-6 rounded-lg border border-outline-variant/10",children:[h.jsxs("div",{className:Te("flex flex-col",$?"w-3/5":"w-full"),children:[h.jsx(oae,{entries:L,selectedId:(b==null?void 0:b.id)??null,onSelect:_,autoScroll:t==="live",relativeTime:t==="live",compact:!0}),t==="search"&&C&&h.jsx("div",{className:"border-t border-outline-variant/10 px-3 py-2 bg-surface-container-low",children:h.jsx(mc,{total:C.total,offset:(y-1)*$r,limit:$r,onPageChange:V=>x(Math.floor(V/$r)+1)})})]}),$&&b&&h.jsx("div",{className:"w-2/5 border-l border-outline-variant/10",children:h.jsx(wae,{entry:b,resolved:T==null?void 0:T.resolved,onClose:()=>S(null)})})]})]})}function Tae(){return h.jsx(lP,{children:h.jsxs(Ea,{element:h.jsx(aq,{}),children:[h.jsx(Ea,{path:"/",element:h.jsx(eU,{})}),h.jsx(Ea,{path:"/sessions",element:h.jsx(Ik,{})}),h.jsx(Ea,{path:"/sessions/:id",element:h.jsx(Ik,{})}),h.jsx(Ea,{path:"/mycelium",element:h.jsx(Xte,{})}),h.jsx(Ea,{path:"/agent",element:h.jsx(Hne,{})}),h.jsx(Ea,{path:"/skills",element:h.jsx(xre,{})}),h.jsx(Ea,{path:"/settings",element:h.jsx(Tre,{})}),h.jsx(Ea,{path:"/operations",element:h.jsx(Wre,{})}),h.jsx(Ea,{path:"/team",element:h.jsx(nae,{})}),h.jsx(Ea,{path:"/logs",element:h.jsx(kae,{})})]})})}const jae=new Y4({defaultOptions:{queries:{staleTime:$z}}});E4.createRoot(document.getElementById("root")).render(h.jsx($i.StrictMode,{children:h.jsx(VP,{children:h.jsx(XP,{children:h.jsx(JP,{children:h.jsx(X4,{client:jae,children:h.jsx(DP,{children:h.jsx(Tae,{})})})})})})}));
|
package/dist/ui/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Myco</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-7Vimyg7g.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-DlEQ8A8Y.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
@@ -2,7 +2,7 @@ import { createRequire as __cr } from 'node:module'; const require = __cr(import
|
|
|
2
2
|
import {
|
|
3
3
|
VAULT_GITIGNORE,
|
|
4
4
|
registerSymbionts
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-6GG2IVNV.js";
|
|
6
6
|
import "./chunk-SAKJMNSR.js";
|
|
7
7
|
import "./chunk-X5IXK5KO.js";
|
|
8
8
|
import "./chunk-HHZ3RTEI.js";
|
|
@@ -14,8 +14,8 @@ import "./chunk-MYX5NCRH.js";
|
|
|
14
14
|
import {
|
|
15
15
|
resolveVaultDir
|
|
16
16
|
} from "./chunk-5ZT2Q6P5.js";
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-4O3QNM5I.js";
|
|
18
|
+
import "./chunk-BFM6AM6R.js";
|
|
19
19
|
import {
|
|
20
20
|
loadManifests,
|
|
21
21
|
resolvePackageRoot
|
|
@@ -89,4 +89,4 @@ async function run(args) {
|
|
|
89
89
|
export {
|
|
90
90
|
run
|
|
91
91
|
};
|
|
92
|
-
//# sourceMappingURL=update-
|
|
92
|
+
//# sourceMappingURL=update-EG3N2EXI.js.map
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
} from "./chunk-5ZT2Q6P5.js";
|
|
12
12
|
import {
|
|
13
13
|
DaemonClient
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-4O3QNM5I.js";
|
|
15
|
+
import "./chunk-BFM6AM6R.js";
|
|
16
16
|
import "./chunk-SV6UCB2Z.js";
|
|
17
17
|
import "./chunk-LPUQPDC2.js";
|
|
18
18
|
import "./chunk-TRA3R4EC.js";
|
|
@@ -63,4 +63,4 @@ ${sessionLine}` : sessionLine;
|
|
|
63
63
|
export {
|
|
64
64
|
main
|
|
65
65
|
};
|
|
66
|
-
//# sourceMappingURL=user-prompt-submit-
|
|
66
|
+
//# sourceMappingURL=user-prompt-submit-7FFQ3ORA.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
createEmbeddingProvider
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-2QMDRZPJ.js";
|
|
5
5
|
import "./chunk-RBFECYNA.js";
|
|
6
6
|
import "./chunk-OKCSSDFC.js";
|
|
7
7
|
import "./chunk-5YQ6VOFZ.js";
|
|
@@ -42,4 +42,4 @@ async function run(_args, vaultDir) {
|
|
|
42
42
|
export {
|
|
43
43
|
run
|
|
44
44
|
};
|
|
45
|
-
//# sourceMappingURL=verify-
|
|
45
|
+
//# sourceMappingURL=verify-2M3DYHEY.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
getPluginVersion
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BFM6AM6R.js";
|
|
5
5
|
import "./chunk-LPUQPDC2.js";
|
|
6
6
|
import "./chunk-PZUWP5VK.js";
|
|
7
7
|
export {
|
|
8
8
|
getPluginVersion
|
|
9
9
|
};
|
|
10
|
-
//# sourceMappingURL=version-
|
|
10
|
+
//# sourceMappingURL=version-JUQU5W22.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goondocks/myco",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"description": "Collective agent intelligence — Claude Code plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@anthropic-ai/claude-agent-sdk": "^0.2.92",
|
|
38
|
-
"@anthropic-ai/sdk": "^0.
|
|
38
|
+
"@anthropic-ai/sdk": "^0.82.0",
|
|
39
39
|
"@inquirer/prompts": "^8.3.2",
|
|
40
40
|
"@modelcontextprotocol/sdk": "^1.28.0",
|
|
41
41
|
"better-sqlite3": "^12.8.0",
|