@ainyc/canonry 4.13.3 → 4.14.0
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.
|
@@ -113,7 +113,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
113
113
|
`)){if(!k.startsWith("data:"))continue;const O=k.slice(5).trim();if(O)try{o(JSON.parse(O))}catch{}}w=m.indexOf(`
|
|
114
114
|
|
|
115
115
|
`)}}}finally{a?.removeEventListener("abort",y);try{f.releaseLock()}catch{}}}function u3(e){return!e||e.role!=="assistant"?"":e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}const Woe=[{label:"Status",prompt:"Quick status overview for this project — latest runs, current health, anything unusual."},{label:"Top insights",prompt:"Walk me through the 3 most severe active insights and what to do about each."},{label:"Last failed run",prompt:"If the latest run failed, dig into it and tell me what went wrong plus how to fix it."},{label:"Schedule",prompt:"What is the current sweep schedule, and is it appropriate given recent volatility?"}],Xoe=[{command:"/status",label:"Status",hint:"Latest runs, health, anything unusual",prompt:"Quick status overview for this project — latest runs, current health, anything unusual."},{command:"/insights",label:"Top insights",hint:"Walk through the most severe active insights",prompt:"Walk me through the 3 most severe active insights and what to do about each."},{command:"/last-run",label:"Last run",hint:"Summarize the latest sweep",prompt:"Summarize the latest run for this project — provider mix, visibility changes, and anything that moved."},{command:"/last-failed",label:"Last failed run",hint:"Diagnose the most recent failure",prompt:"If the latest run failed, dig into it and tell me what went wrong plus how to fix it."},{command:"/run-sweep",label:"Run sweep now",hint:"Trigger a new visibility sweep",prompt:"Run a new answer-visibility sweep for this project now and tell me when it lands."},{command:"/schedule",label:"Schedule",hint:"Review the sweep schedule",prompt:"What is the current sweep schedule, and is it appropriate given recent volatility?"},{command:"/queries",label:"Queries",hint:"List tracked queries",prompt:"List the tracked queries for this project and flag any that are obvious duplicates or underperformers."},{command:"/competitors",label:"Competitors",hint:"List tracked competitors",prompt:"List this project's tracked competitors and call out which ones are showing up in answer citations."},{command:"/clear",label:"Clear conversation",hint:"Wipe transcript and start fresh",action:"clear"}],wm=e=>`canonry:aero:provider:${e}`,mT=e=>`canonry:aero:scope:${e}`;function Joe({projectName:e}){const[t,n]=b.useState(!1),[r,i]=b.useState(!1),[a,o]=b.useState([]),[u,d]=b.useState(""),[f,p]=b.useState(!1),[m,y]=b.useState([]),[v,S]=b.useState(""),[w,j]=b.useState(null),[k,O]=b.useState(()=>typeof window>"u"?null:window.localStorage.getItem(wm(e))??null),[_,A]=b.useState(()=>typeof window>"u"?"read-only":window.localStorage.getItem(mT(e))==="all"?"all":"read-only"),T=b.useRef(null),C=b.useRef(null),z=b.useRef(null),[R,B]=b.useState(0),F=b.useMemo(()=>{const U=u.trimStart();if(!U.startsWith("/"))return[];if(/\s/.test(U))return[];const D=U.toLowerCase();return Xoe.filter(G=>G.command.startsWith(D)||G.label.toLowerCase().includes(D.slice(1)))},[u]);b.useEffect(()=>{B(U=>F.length===0?0:Math.min(U,F.length-1))},[F.length]);const q=ta({queryKey:$e.agent.providers(e),queryFn:()=>Qoe(e),enabled:t,staleTime:6e4}),$=b.useMemo(()=>{const U=q.data?.providers??[];if(k){const G=U.find(ae=>ae.id===k&&ae.configured);if(G)return G}const D=q.data?.defaultProvider;return D?U.find(G=>G.id===D)??null:null},[k,q.data]);b.useEffect(()=>{if(!q.data||!k)return;q.data.providers.find(D=>D.id===k&&D.configured)||(O(null),window.localStorage.removeItem(wm(e)))},[q.data,k,e]);const V=b.useCallback(U=>{O(U),!(typeof window>"u")&&(U?window.localStorage.setItem(wm(e),U):window.localStorage.removeItem(wm(e)))},[e]),te=b.useCallback(()=>{A(U=>{const D=U==="all"?"read-only":"all";return typeof window<"u"&&window.localStorage.setItem(mT(e),D),D})},[e]);b.useEffect(()=>{if(!t)return;const U=D=>{D.key==="Escape"&&(r?i(!1):n(!1))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[t,r]),b.useEffect(()=>{if(!t)return;let U=!1;j(null);const D=()=>{U||f||pT(e).then(ne=>{U||o(ne.messages)}).catch(ne=>{U||j(ne instanceof Error?ne.message:"Failed to load transcript")})};D();const ae=window.setInterval(D,15e3);return()=>{U=!0,window.clearInterval(ae)}},[t,e,f]),b.useEffect(()=>()=>{T.current?.abort()},[e]),b.useEffect(()=>{const U=C.current;U&&(U.scrollTop=U.scrollHeight)},[a,v,m]);async function W(U){const D=U.trim();if(!D||f)return;j(null),d(""),p(!0),S(""),y([]);const G={role:"user",content:D,timestamp:Date.now()};o(ne=>[...ne,G]);const ae=new AbortController;T.current=ae;try{await Yoe({project:e,prompt:D,provider:k??void 0,scope:_,signal:ae.signal,onEvent:H});const ne=await pT(e);o(ne.messages)}catch(ne){ne.name!=="AbortError"&&j(ne instanceof Error?ne.message:"Prompt failed")}finally{p(!1),S(""),T.current=null}}function H(U){switch(U.type){case"message_update":S(u3(U.message));break;case"message_end":U.message.role==="assistant"&&S("");break;case"tool_execution_start":y(D=>[...D,{id:U.toolCallId,name:U.toolName,args:U.args,startedAt:Date.now()}]);break;case"tool_execution_end":y(D=>D.map(G=>G.id===U.toolCallId?{...G,endedAt:Date.now(),isError:U.isError,result:U.result}:G));break;case"error":j(U.message);break}}async function ee(){T.current?.abort();try{await Zoe(e),o([]),j(null)}catch(U){j(U instanceof Error?U.message:"Reset failed")}}const ce=a.length===0,Se=t&&r?"pointer-events-auto fixed inset-0 z-40 flex items-stretch justify-center bg-zinc-950/70 p-4 sm:p-8 backdrop-blur-sm":"pointer-events-none fixed inset-x-0 bottom-0 z-40 flex justify-center p-3",L=r?"pointer-events-auto flex h-full w-full max-w-5xl flex-col overflow-hidden rounded-2xl border border-zinc-800/80 bg-zinc-950/95 shadow-2xl":"pointer-events-auto w-full max-w-3xl",I=r?"flex-1 overflow-y-auto px-6 py-5 text-sm text-zinc-200":"max-h-[40vh] min-h-[120px] overflow-y-auto px-4 py-3 text-sm text-zinc-200";return l.jsx("div",{className:Se,onClick:U=>{r&&U.target===U.currentTarget&&i(!1)},children:l.jsx("div",{className:L,children:t?l.jsxs("div",{className:r?"flex h-full flex-col":"flex flex-col overflow-hidden rounded-2xl border border-zinc-800/80 bg-zinc-950/95 shadow-xl backdrop-blur",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-zinc-800/70 px-4 py-2.5",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Az,{className:"h-4 w-4 text-emerald-400","aria-hidden":"true"}),l.jsx("span",{className:"text-sm font-medium text-zinc-100",children:"Aero"}),l.jsx("span",{className:"text-[10px] uppercase tracking-wider text-zinc-500",children:f?"working…":e})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(ele,{providers:q.data?.providers??[],active:$,override:k,onPick:V,disabled:f}),l.jsx("button",{type:"button",onClick:ee,className:"rounded-md p-1.5 text-zinc-500 transition hover:bg-zinc-800/60 hover:text-zinc-200","aria-label":"Reset conversation",title:"Reset conversation",children:l.jsx(gL,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),l.jsx("button",{type:"button",onClick:()=>i(U=>!U),className:"rounded-md p-1.5 text-zinc-500 transition hover:bg-zinc-800/60 hover:text-zinc-200","aria-label":r?"Collapse":"Expand",title:r?"Collapse":"Expand",children:r?l.jsx(uV,{className:"h-3.5 w-3.5","aria-hidden":"true"}):l.jsx(sV,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),l.jsx("button",{type:"button",onClick:()=>{i(!1),n(!1)},className:"rounded-md p-1.5 text-zinc-500 transition hover:bg-zinc-800/60 hover:text-zinc-200","aria-label":"Close Aero",children:l.jsx(xh,{className:"h-4 w-4","aria-hidden":"true"})})]})]}),l.jsxs("div",{ref:C,className:I,children:[w&&l.jsx("div",{className:"mb-2 rounded-md border border-rose-700/40 bg-rose-950/40 px-3 py-2 text-xs text-rose-200",children:w}),ce&&!f&&l.jsxs("div",{className:"flex flex-col gap-3 py-2",children:[l.jsxs("p",{className:"text-xs text-zinc-500",children:["Ask anything about ",l.jsx("span",{className:"text-zinc-300",children:e}),", or start with:"]}),l.jsx("div",{className:"flex flex-wrap gap-1.5",children:Woe.map(U=>l.jsx("button",{type:"button",onClick:()=>W(U.prompt),className:"rounded-full border border-zinc-800 bg-zinc-900/70 px-3 py-1 text-xs text-zinc-300 transition hover:border-zinc-700 hover:bg-zinc-800/70 hover:text-zinc-100",children:U.label},U.label))})]}),ale(a,e,k,_),m.length>0&&l.jsx("div",{className:"mt-3 space-y-1.5",children:m.map(U=>l.jsx(d3,{trail:U},U.id))}),f&&v&&l.jsxs("div",{className:"mt-3",children:[l.jsx("div",{className:"mb-0.5 text-[10px] uppercase tracking-wider text-emerald-400",children:"Aero"}),l.jsx(f3,{content:v})]}),f&&!v&&m.every(U=>U.endedAt!==void 0)&&l.jsx(cle,{})]}),l.jsx(tle,{projectName:e,activeProvider:$,scope:_,onToggleScope:te,disabled:f}),l.jsxs("div",{className:"relative",children:[F.length>0&&l.jsx(nle,{matches:F,selectedIndex:R,onHover:B,onPick:U=>{d(""),z.current?.focus(),U.action==="clear"?ee():W(U.prompt)}}),l.jsxs("form",{className:"flex items-end gap-2 border-t border-zinc-800/70 bg-zinc-950/80 px-3 py-2.5",onSubmit:U=>{if(U.preventDefault(),F.length>0){const D=F[R];d(""),D.action==="clear"?ee():W(D.prompt);return}W(u)},children:[l.jsx("textarea",{ref:z,value:u,onChange:U=>d(U.target.value),onKeyDown:U=>{if(F.length>0){if(U.key==="ArrowDown"){U.preventDefault(),B(D=>(D+1)%F.length);return}if(U.key==="ArrowUp"){U.preventDefault(),B(D=>(D-1+F.length)%F.length);return}if(U.key==="Tab"){U.preventDefault();const D=F[R];d(`${D.command} `);return}if(U.key==="Escape"){U.preventDefault(),d("");return}}if(U.key==="Enter"&&!U.shiftKey)if(U.preventDefault(),F.length>0){const D=F[R];d(""),D.action==="clear"?ee():W(D.prompt)}else W(u)},placeholder:"Ask Aero, or / for commands…",disabled:f,rows:r?3:1,className:"flex-1 resize-none bg-transparent text-sm text-zinc-100 placeholder:text-zinc-600 focus:outline-none disabled:opacity-60"}),l.jsx("button",{type:"submit",disabled:f||!u.trim(),className:"inline-flex h-7 w-7 items-center justify-center rounded-md bg-emerald-500 text-zinc-950 transition hover:bg-emerald-400 disabled:opacity-40","aria-label":"Send",children:l.jsx(PG,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]})]}):l.jsxs("button",{type:"button",onClick:()=>n(!0),className:"flex w-full items-center justify-between rounded-full border border-zinc-800/80 bg-zinc-950/95 px-4 py-2 text-left text-sm text-zinc-400 shadow-lg backdrop-blur transition hover:border-zinc-700 hover:bg-zinc-900/90 hover:text-zinc-200",children:[l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(Az,{className:"h-4 w-4 text-emerald-400","aria-hidden":"true"}),"Ask Aero about ",e,"…"]}),l.jsx("span",{className:"text-[10px] uppercase tracking-wider text-zinc-600",children:"Enter"})]})})})}function ele({providers:e,active:t,override:n,onPick:r,disabled:i}){const[a,o]=b.useState(!1),u=b.useRef(null);if(b.useEffect(()=>{if(!a)return;const p=y=>{u.current?.contains(y.target)||o(!1)},m=y=>{y.key==="Escape"&&o(!1)};return window.addEventListener("mousedown",p),window.addEventListener("keydown",m),()=>{window.removeEventListener("mousedown",p),window.removeEventListener("keydown",m)}},[a]),e.length===0)return null;const d=t?.label.replace(/\s+\(.+\)$/,"")??"No provider",f=t?.defaultModel;return l.jsxs("div",{ref:u,className:"relative",children:[l.jsxs("button",{type:"button",onClick:()=>o(p=>!p),disabled:i,className:"flex items-center gap-1 rounded-md px-1.5 py-1 text-[11px] text-zinc-400 transition hover:bg-zinc-800/60 hover:text-zinc-200 disabled:opacity-50","aria-label":"Switch agent model","aria-haspopup":"listbox","aria-expanded":a,title:t?`${t.label} · ${t.defaultModel}`:"Pick a provider",children:[l.jsx("span",{className:"font-medium text-zinc-200",children:d}),f&&l.jsx("span",{className:"hidden font-mono text-[10px] text-zinc-500 sm:inline",children:f}),l.jsx(LG,{className:"h-3 w-3","aria-hidden":"true"})]}),a&&l.jsxs("div",{role:"listbox",className:"absolute right-0 top-full z-50 mt-1 w-64 overflow-hidden rounded-lg border border-zinc-800 bg-zinc-950 shadow-xl",children:[l.jsx("div",{className:"border-b border-zinc-800/60 px-3 py-2 text-[10px] uppercase tracking-wider text-zinc-500",children:"Aero provider"}),l.jsx("ul",{className:"max-h-72 overflow-y-auto py-1",children:e.map(p=>{const m=t?.id===p.id,y=n===p.id;return l.jsx("li",{children:l.jsxs("button",{type:"button",role:"option","aria-selected":m,disabled:!p.configured,onClick:()=>{p.configured&&(r(y?null:p.id),o(!1))},className:"flex w-full items-start gap-2 px-3 py-2 text-left text-xs transition enabled:hover:bg-zinc-900 disabled:cursor-not-allowed disabled:opacity-50",children:[l.jsx("span",{className:"mt-0.5 flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:m?l.jsx(dL,{className:"h-3 w-3 text-emerald-400","aria-hidden":"true"}):null}),l.jsxs("span",{className:"flex-1",children:[l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"font-medium text-zinc-100",children:p.label}),y&&l.jsx("span",{className:"rounded-full border border-emerald-800/60 bg-emerald-950/60 px-1.5 text-[9px] uppercase tracking-wider text-emerald-300",children:"Pinned"}),!p.configured&&l.jsx("span",{className:"rounded-full border border-zinc-800 px-1.5 text-[9px] uppercase tracking-wider text-zinc-500",children:"Key missing"})]}),l.jsx("span",{className:"mt-0.5 block font-mono text-[10px] text-zinc-500",children:p.defaultModel}),p.keySource==="env"&&l.jsx("span",{className:"mt-0.5 block text-[10px] text-zinc-600",children:"via env var"}),!p.configured&&l.jsxs("span",{className:"mt-0.5 block text-[10px] text-zinc-600",children:["Add key in config.yaml or export"," ",l.jsx("code",{className:"font-mono text-zinc-400",children:rle(p.id)})]})]})]})},p.id)})}),n&&l.jsx("button",{type:"button",onClick:()=>{r(null),o(!1)},className:"w-full border-t border-zinc-800/60 px-3 py-2 text-left text-[11px] text-zinc-400 transition hover:bg-zinc-900 hover:text-zinc-100",children:"Reset to auto-detected default"})]})]})}function tle({projectName:e,activeProvider:t,scope:n,onToggleScope:r,disabled:i}){const a=t?.label.replace(/\s+\(.+\)$/,"")??null,o=n==="all";return l.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-zinc-800/70 bg-zinc-950/80 px-3 pt-2",children:[l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-zinc-800 bg-zinc-900/70 px-2 py-0.5 text-[10px] text-zinc-400",children:[l.jsx("span",{className:"text-zinc-600",children:"project"}),l.jsx("span",{className:"font-medium text-zinc-200",children:e})]}),a&&l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-zinc-800 bg-zinc-900/70 px-2 py-0.5 text-[10px] text-zinc-400",children:[l.jsx("span",{className:"text-zinc-600",children:"model"}),l.jsx("span",{className:"font-medium text-zinc-200",children:a})]}),l.jsxs("button",{type:"button",onClick:r,disabled:i,className:`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] transition disabled:opacity-50 ${o?"border-amber-800/60 bg-amber-950/40 text-amber-300 hover:border-amber-700 hover:text-amber-200":"border-zinc-800 bg-zinc-900/70 text-zinc-400 hover:border-zinc-700 hover:text-zinc-200"}`,title:o?"Aero can invoke write tools (run sweep, dismiss insight, etc). Click to restrict.":"Aero is restricted to read-only tools. Click to allow writes.",children:[l.jsx("span",{className:o?"text-amber-500":"text-zinc-600",children:"scope"}),l.jsx("span",{className:"font-medium",children:o?"all tools":"read-only"})]})]})}function nle({matches:e,selectedIndex:t,onHover:n,onPick:r}){return l.jsxs("div",{className:"absolute inset-x-3 bottom-full mb-2 overflow-hidden rounded-lg border border-zinc-800 bg-zinc-950/98 shadow-2xl",children:[l.jsx("div",{className:"border-b border-zinc-800/60 px-3 py-1.5 text-[10px] uppercase tracking-wider text-zinc-500",children:"Commands"}),l.jsx("ul",{role:"listbox",className:"max-h-72 overflow-y-auto py-1",children:e.map((i,a)=>{const o=a===t;return l.jsx("li",{children:l.jsxs("button",{type:"button",role:"option","aria-selected":o,onMouseEnter:()=>n(a),onClick:()=>r(i),className:`flex w-full items-center gap-3 px-3 py-1.5 text-left text-xs transition ${o?"bg-zinc-900 text-zinc-100":"text-zinc-300 hover:bg-zinc-900/60"}`,children:[l.jsx("span",{className:"font-mono text-[11px] text-emerald-400",children:i.command}),l.jsx("span",{className:"font-medium",children:i.label}),l.jsx("span",{className:"ml-auto text-[10px] text-zinc-500",children:i.hint})]})},i.command)})}),l.jsxs("div",{className:"border-t border-zinc-800/60 px-3 py-1.5 text-[10px] text-zinc-600",children:[l.jsx("span",{className:"mr-3",children:"↑↓ to select"}),l.jsx("span",{className:"mr-3",children:"Enter to run"}),l.jsx("span",{children:"Tab to autocomplete"})]})]})}function rle(e){switch(e){case"claude":return"ANTHROPIC_API_KEY";case"openai":return"OPENAI_API_KEY";case"gemini":return"GOOGLE_API_KEY";case"zai":return"ZAI_API_KEY"}}function ile(e,t){const n=e.timestamp??0;return`${e.role}:${n}:${t}`}function ale(e,t,n,r){const i=[];for(let a=0;a<e.length;a++){const o=e[a],u=ile(o,a);if(o.role==="user"){const d=typeof o.content=="string"?o.content:JSON.stringify(o.content);if(d.startsWith("[system]"))continue;i.push(l.jsx(sle,{text:d,projectName:t,providerOverride:n,scope:r},u));continue}if(o.role==="assistant"){const d=new Map;let f=a+1;for(;f<e.length&&e[f].role==="toolResult";){const y=e[f];d.set(y.toolCallId,y),f++}const p=lle(o,d,o.timestamp??0),m=u3(o);i.push(l.jsxs(b.Fragment,{children:[p.length>0&&l.jsx("div",{className:"mt-3 space-y-1.5",children:p.map(y=>l.jsx(d3,{trail:y},y.id))}),m.trim()&&l.jsxs("div",{className:"mt-3",children:[l.jsx("div",{className:"mb-0.5 text-[10px] uppercase tracking-wider text-emerald-400",children:"Aero"}),l.jsx(f3,{content:m})]})]},u)),a=f-1;continue}}return i}function sle({text:e,projectName:t,providerOverride:n,scope:r}){const[i,a]=b.useState(!1),o=b.useMemo(()=>ole(t,e,n,r),[t,e,n,r]);async function u(){try{await navigator.clipboard.writeText(o),a(!0),window.setTimeout(()=>a(!1),1500)}catch{}}return l.jsxs("div",{className:"group relative mt-3 rounded-md bg-zinc-900/60 px-3 py-2 text-zinc-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-wider text-zinc-500",children:"You"}),l.jsx("button",{type:"button",onClick:u,className:"inline-flex items-center gap-1 rounded border border-zinc-800/70 bg-zinc-950/60 px-1.5 py-0.5 text-[10px] text-zinc-400 opacity-0 transition hover:border-zinc-700 hover:text-zinc-100 group-hover:opacity-100 focus:opacity-100","aria-label":"Copy as CLI command",title:o,children:i?l.jsxs(l.Fragment,{children:[l.jsx(dL,{className:"h-2.5 w-2.5 text-emerald-400","aria-hidden":"true"}),"Copied"]}):l.jsxs(l.Fragment,{children:[l.jsx(KG,{className:"h-2.5 w-2.5","aria-hidden":"true"}),"Copy as CLI"]})})]}),l.jsx("div",{className:"whitespace-pre-wrap",children:e})]})}function ole(e,t,n,r){const i=["canonry","agent","ask",gT(e),gT(t)];return n&&i.push("--provider",n),r==="read-only"&&i.push("--scope","read-only"),i.join(" ")}function gT(e){return`'${e.replace(/'/g,"'\\''")}'`}function lle(e,t,n){const r=[];for(const i of e.content){if(i.type!=="toolCall")continue;const a=i,o=t.get(a.id);r.push({id:a.id,name:a.name,args:a.arguments,startedAt:n,endedAt:o?.timestamp,isError:o?.isError,result:o?.content})}return r}function d3({trail:e}){const[t,n]=b.useState(!1),r=e.endedAt===void 0,i=!r&&e.isError===!0,a=e.endedAt!=null?e.endedAt-e.startedAt:null,o=a==null||a<0?null:a<1e3?`${a}ms`:`${(a/1e3).toFixed(1)}s`,u=i?"border-rose-800/50":r?"border-emerald-800/50":"border-zinc-800/70",d=i?"bg-rose-950/20":r?"bg-emerald-950/20":"bg-zinc-900/40";return l.jsxs("div",{className:`rounded-md border ${u} ${d} font-mono`,children:[l.jsxs("button",{type:"button",onClick:()=>n(f=>!f),className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left","aria-expanded":t,children:[l.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:r?l.jsx(mL,{className:"h-3 w-3 animate-spin text-emerald-400","aria-hidden":"true"}):i?l.jsx(Ng,{className:"h-3 w-3 text-rose-400","aria-hidden":"true"}):l.jsx(EV,{className:"h-3 w-3 text-zinc-500","aria-hidden":"true"})}),l.jsx("span",{className:"text-[11px] font-semibold text-zinc-100",children:e.name}),l.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-zinc-500",children:[r?l.jsx("span",{className:"text-emerald-400",children:"running…"}):l.jsxs(l.Fragment,{children:[l.jsx("span",{children:i?"failed":"ok"}),o&&l.jsx("span",{children:o})]}),l.jsx(vh,{className:`h-3 w-3 transition-transform ${t?"rotate-90":""}`,"aria-hidden":"true"})]})]}),t&&l.jsxs("div",{className:"border-t border-zinc-800/60 px-2.5 py-2 text-[11px] text-zinc-400",children:[l.jsx("div",{className:"mb-1 text-[9px] uppercase tracking-wider text-zinc-600",children:"Args"}),l.jsx("pre",{className:"mb-2 overflow-x-auto whitespace-pre-wrap break-all text-[10px] text-zinc-300",children:yT(e.args)}),!r&&e.result!==void 0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"mb-1 text-[9px] uppercase tracking-wider text-zinc-600",children:i?"Error":"Result"}),l.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-all text-[10px] text-zinc-300",children:yT(e.result)})]})]})]})}function yT(e){try{const t=typeof e=="string"?e:JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}
|
|
116
|
-
… (${t.length-2e3} more chars)`:t}catch{return String(e)}}function f3({content:e}){return l.jsx("div",{className:"aero-markdown text-zinc-100",children:l.jsx(qoe,{components:{h1:t=>l.jsx("h1",{...t,className:"mt-3 mb-2 text-base font-semibold text-zinc-50"}),h2:t=>l.jsx("h2",{...t,className:"mt-3 mb-2 text-sm font-semibold text-zinc-50"}),h3:t=>l.jsx("h3",{...t,className:"mt-3 mb-1.5 text-sm font-semibold text-zinc-100"}),h4:t=>l.jsx("h4",{...t,className:"mt-2 mb-1 text-xs font-semibold uppercase tracking-wide text-zinc-300"}),p:t=>l.jsx("p",{...t,className:"mb-2 leading-relaxed"}),ul:t=>l.jsx("ul",{...t,className:"mb-2 ml-4 list-disc space-y-1"}),ol:t=>l.jsx("ol",{...t,className:"mb-2 ml-4 list-decimal space-y-1"}),li:t=>l.jsx("li",{...t,className:"marker:text-zinc-600"}),strong:t=>l.jsx("strong",{...t,className:"font-semibold text-zinc-50"}),em:t=>l.jsx("em",{...t,className:"text-zinc-200"}),code:({children:t,...n})=>l.jsx("code",{...n,className:"rounded bg-zinc-800/70 px-1 py-0.5 font-mono text-[12px] text-emerald-200",children:t}),pre:t=>l.jsx("pre",{...t,className:"mb-2 overflow-x-auto rounded-md border border-zinc-800 bg-zinc-900/70 p-3 font-mono text-xs text-zinc-200"}),a:t=>l.jsx("a",{...t,className:"text-emerald-400 underline decoration-emerald-700 hover:decoration-emerald-400",target:"_blank",rel:"noopener noreferrer"}),table:t=>l.jsx("div",{className:"mb-2 overflow-x-auto",children:l.jsx("table",{...t,className:"w-full border-collapse text-xs"})}),thead:t=>l.jsx("thead",{...t,className:"border-b border-zinc-800"}),th:t=>l.jsx("th",{...t,className:"px-2 py-1 text-left font-semibold text-zinc-300"}),tr:t=>l.jsx("tr",{...t,className:"border-b border-zinc-900"}),td:t=>l.jsx("td",{...t,className:"px-2 py-1 text-zinc-200"}),blockquote:t=>l.jsx("blockquote",{...t,className:"mb-2 border-l-2 border-zinc-700 pl-3 italic text-zinc-400"}),hr:()=>l.jsx("hr",{className:"my-3 border-zinc-800"})},children:e})})}function cle(){return l.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-wider text-emerald-400",children:"Aero"}),l.jsxs("div",{className:"flex items-center gap-1","aria-label":"Aero is thinking",children:[l.jsx("span",{className:"aero-dot h-1.5 w-1.5 rounded-full bg-emerald-400/80"}),l.jsx("span",{className:"aero-dot aero-dot-2 h-1.5 w-1.5 rounded-full bg-emerald-400/60"}),l.jsx("span",{className:"aero-dot aero-dot-3 h-1.5 w-1.5 rounded-full bg-emerald-400/40"})]})]})}function ule(){const e=QI(),t=/^\/projects\/([^/]+)/.exec(e.pathname),n=t?decodeURIComponent(t[1]):null,r=ta({queryKey:$e.projects.all,queryFn:eN,enabled:n!==null,staleTime:6e4});if(!n)return null;const i=r.data??[],a=i.find(o=>o.id===n)??i.find(o=>o.name===n);return a?l.jsx(Joe,{projectName:a.name},a.name):null}function ov(e,t,n){switch(e.invalidateQueries({queryKey:$e.runs.all}),e.invalidateQueries({queryKey:$e.projects.all}),t){case kt["answer-visibility"]:case kt["site-audit"]:case kt["backlink-extract"]:return;case kt["gsc-sync"]:case kt["inspect-sitemap"]:e.invalidateQueries({queryKey:$e.gsc.project(n)});return;case kt["ga-sync"]:case kt["traffic-sync"]:e.invalidateQueries({queryKey:$e.traffic.project(n)});return;case kt["bing-inspect"]:case kt["bing-inspect-sitemap"]:e.invalidateQueries({queryKey:$e.bing.project(n)});return;default:return t}}const vT=[{label:"GitHub",href:"https://github.com/AINYC/canonry",Icon:XG},{label:"Docs",href:"https://github.com/AINYC/canonry/tree/main/docs",Icon:DG},{label:"Changelog",href:"https://github.com/AINYC/canonry/releases",Icon:YG}],xT=e=>({label:e,state:"checking",detail:"Checking service health"}),dle={apiStatus:xT("API"),workerStatus:xT("Worker")};function fle(e){switch(e){case kt["answer-visibility"]:return"Visibility sweep";case kt["gsc-sync"]:return"GSC sync";case kt["inspect-sitemap"]:return"Sitemap inspection";case kt["ga-sync"]:return"GA sync";case kt["traffic-sync"]:return"Traffic sync";case kt["bing-inspect"]:return"Bing URL inspection";case kt["bing-inspect-sitemap"]:return"Bing sitemap inspection";case kt["site-audit"]:return"Site audit";case kt["backlink-extract"]:return"Backlink extract"}}function hle(e){return e==="completed"?"positive":e==="partial"?"caution":"negative"}function ple(e){const t=fle(e.kind);return e.status==="completed"?`${t} completed`:e.status==="partial"?`${t} completed with partial results`:e.status==="cancelled"?`${t} cancelled`:`${t} failed`}function mle(e,t){return e.error?`${t}: ${hN(e.error)}`:e.location?`${t} · ${e.location}`:t}function gle(e,t,n){if(t)return t;const r=n.find(i=>i.id===e);return r?.displayName||r?.name||e}function yle(e,t){return[e.completed>0?`${e.completed} completed`:null,e.partial>0?`${e.partial} partial`:null,e.failed>0?`${e.failed} failed`:null,e.cancelled>0?`${e.cancelled} cancelled`:null,t>0?`${t} skipped at queue time`:null].filter(Boolean).join(", ")}function vle(e){return e.failed>0||e.cancelled>0?"negative":e.partial>0?"caution":"positive"}function xle(){const e=ai(),t=b.useSyncExternalStore(eee,Il,Il),n=Object.keys(t.runs).length>0||Object.keys(t.batches).length>0,r=ta({queryKey:$e.runs.all,queryFn:WI,enabled:n,staleTime:i1,refetchInterval:3e3}),i=ta({queryKey:$e.projects.all,queryFn:eN,enabled:n}),a=b.useRef({}),o=b.useCallback(()=>{r.refetch()},[r.refetch]);return b.useEffect(()=>{n&&o()},[n,o]),b.useEffect(()=>{if(!n||typeof window>"u")return;const u=()=>{document.visibilityState==="visible"&&o()};return window.addEventListener("focus",o),document.addEventListener("visibilitychange",u),()=>{window.removeEventListener("focus",o),document.removeEventListener("visibilitychange",u)}},[n,o]),b.useEffect(()=>{const u=r.data??[],d=i.data??[],f=Object.fromEntries(u.map(m=>[m.id,m])),p=Object.fromEntries(u.map(m=>[m.id,m.status]));for(const m of Object.values(t.runs)){const y=f[m.runId];if(!y||!vN(y.status)||(a.current[y.id]??m.lastAnnouncedStatus)===y.status)continue;const S=d.find(j=>j.id===y.projectId);if(S&&ov(e,y.kind,S.name),m.sourceAction==="run-all"){n2(y.id);continue}const w=gle(y.projectId,m.projectLabel,d);xt({title:ple(y),detail:mle(y,w),tone:hle(y.status),dedupeKey:`run:${y.id}`,dedupeMode:"replace",cta:{label:"View run",intent:"open-run-drawer",runId:y.id}}),n2(y.id)}for(const m of Object.values(t.batches)){const y=ree(m.runIds,f);y.finished&&(xt({title:"Run-all batch finished",detail:yle(y,m.skippedCount),tone:vle(y),dedupeKey:`batch:${m.batchId}`,dedupeMode:"replace",cta:{label:"View runs",intent:"go-to-runs"}}),nee(m.batchId))}a.current=p},[i.data,r.data,t,e]),null}function ble(){const e=bh(),{dashboard:t,isLoading:n,refetch:r}=ec(),o=nv(!e,e?.health).data??e?.health??dle,u=QI(),{runId:d,evidenceId:f,closeDrawer:p}=Ku(),[m,y]=b.useState(!1),v=jre(d),S=v.data??null,w=v.isLoading;b.useEffect(()=>{S&&S.status!=="running"&&S.status!=="queued"&&r()},[S?.status,r]),b.useEffect(()=>{y(!1)},[u.pathname]),b.useEffect(()=>{if(typeof window>"u"||!d&&!f)return;const A=T=>{T.key==="Escape"&&p()};return window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A)}},[d,f,p]);const j=t??e?.dashboard??null,k=d&&j?Jne(j,d):void 0,O=f&&j?ere(j,f):void 0,_=(()=>{const A=u.pathname;if(A==="/")return"Portfolio";if(A==="/projects")return"Projects";if(A==="/runs")return"Runs";if(A==="/settings")return"Settings";if(A==="/setup")return"Setup";if(A==="/backlinks")return"Backlinks";if(A.startsWith("/projects/")){const C=A.split("/").filter(Boolean)[1];if(C&&j){const z=j.projects.find(R=>R.project.id===C);if(z)return z.project.name}return"Project"}return"Not found"})();return l.jsxs("div",{className:"app-shell",children:[l.jsx("a",{className:"skip-link",href:"#content",children:"Skip to content"}),l.jsxs("aside",{className:"sidebar","aria-label":"Primary navigation",children:[l.jsx("div",{className:"sidebar-brand",children:l.jsx(f2,{version:o.apiStatus.version})}),l.jsxs("nav",{className:"sidebar-nav",children:[l.jsxs(Qt,{to:"/",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(nV,{className:"sidebar-icon"}),l.jsx("span",{children:"Overview"})]}),l.jsxs(Qt,{to:"/projects",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!1},children:[l.jsx(eV,{className:"sidebar-icon"}),l.jsx("span",{children:"Projects"})]}),l.jsxs(Qt,{to:"/runs",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(jg,{className:"sidebar-icon"}),l.jsx("span",{children:"Runs"})]}),l.jsxs(Qt,{to:"/backlinks",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(pL,{className:"sidebar-icon"}),l.jsx("span",{children:"Backlinks"})]}),l.jsxs(Qt,{to:"/settings",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(bV,{className:"sidebar-icon"}),l.jsx("span",{children:"Settings"})]}),n?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"sidebar-section-title",children:"Projects"}),[1,2,3].map(A=>l.jsxs("div",{className:"sidebar-skeleton-item",children:[l.jsx("span",{className:"skeleton-circle size-2"}),l.jsx("span",{className:"skeleton-text flex-1",style:{width:`${50+A*15}%`}})]},A))]}):j&&j.projects.length>0?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"sidebar-section-title",children:"Projects"}),j.projects.map(A=>{const T=A.visibilitySummary.tone;return l.jsxs(Qt,{to:"/projects/$projectId",params:{projectId:A.project.id},className:"sidebar-project",activeProps:{className:"sidebar-project sidebar-project-active"},children:[l.jsx("span",{className:`sidebar-dot sidebar-dot-${T}`}),l.jsx("span",{children:A.project.name})]},A.project.id)})]}):n?null:l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"sidebar-section-title",children:"Resources"}),l.jsxs(Qt,{to:"/setup",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(yV,{className:"sidebar-icon"}),l.jsx("span",{children:"Setup"})]})]})]}),l.jsx("div",{className:"sidebar-footer",children:vT.map(({label:A,href:T,Icon:C})=>l.jsx("a",{className:"sidebar-footer-icon",href:T,target:"_blank",rel:"noopener noreferrer",title:A,"aria-label":A,children:l.jsx(C,{className:"size-4"})},T))})]}),l.jsxs("div",{className:"main-area",children:[l.jsxs("header",{className:"topbar",children:[l.jsxs("div",{className:"topbar-left",children:[l.jsx("div",{className:"topbar-brand-mobile",children:l.jsx(f2,{compact:!0})}),l.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[l.jsx(Qt,{to:"/",children:"Home"}),l.jsx(vh,{className:"breadcrumb-sep size-3"}),l.jsx("span",{className:"breadcrumb-current",children:_})]})]}),l.jsxs("div",{className:"topbar-actions",children:[l.jsxs("div",{className:"health-pill-row",children:[l.jsxs("span",{className:`health-pill health-pill-${o.apiStatus.state}`,title:ko(o.apiStatus),children:["API ",o.apiStatus.state==="ok"?"ok":o.apiStatus.state]}),l.jsxs("span",{className:`health-pill health-pill-${o.workerStatus.state}`,title:ko(o.workerStatus),children:["Worker ",o.workerStatus.state==="ok"?"ok":o.workerStatus.state]})]}),l.jsxs(ye,{className:"nav-toggle",variant:"secondary",size:"icon",type:"button","aria-expanded":m,"aria-controls":"mobile-nav",onClick:()=>y(A=>!A),children:[l.jsx(lV,{className:"size-4"}),l.jsx("span",{className:"sr-only",children:"Open navigation"})]})]})]}),l.jsxs("div",{id:"mobile-nav",className:`mobile-nav ${m?"mobile-nav-open":""}`,children:[l.jsxs(ye,{className:"mobile-nav-close",variant:"ghost",size:"icon",type:"button",onClick:()=>y(!1),children:[l.jsx(xh,{className:"size-5"}),l.jsx("span",{className:"sr-only",children:"Close navigation"})]}),l.jsx(Qt,{to:"/",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Overview"}),l.jsx(Qt,{to:"/projects",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!1},children:"Projects"}),l.jsx(Qt,{to:"/runs",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Runs"}),l.jsx(Qt,{to:"/settings",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Settings"}),j&&j.projects.length>0?l.jsxs("div",{className:"mobile-nav-section",children:[l.jsx("p",{className:"mobile-nav-section-title",children:"Projects"}),j.projects.map(A=>l.jsx(Qt,{to:"/projects/$projectId",params:{projectId:A.project.id},className:"mobile-nav-link",children:A.project.name},A.project.id))]}):null]}),l.jsx("main",{id:"content",className:"page-shell",children:n&&!e?l.jsxs("div",{className:"page-skeleton",children:[l.jsxs("div",{className:"page-skeleton-header",children:[l.jsx("div",{className:"skeleton-text h-6 w-40"}),l.jsx("div",{className:"skeleton-text-sm w-72"})]}),l.jsx("div",{className:"page-skeleton-grid",children:[1,2,3].map(A=>l.jsxs("div",{className:"page-skeleton-card",children:[l.jsx("div",{className:"skeleton-text w-24"}),l.jsx("div",{className:"skeleton-text w-full"}),l.jsx("div",{className:"skeleton-text-sm w-3/4"})]},A))}),l.jsx("div",{className:"page-skeleton-grid",style:{gridTemplateColumns:"1fr 1fr"},children:[1,2].map(A=>l.jsxs("div",{className:"page-skeleton-card",children:[l.jsx("div",{className:"skeleton-text w-20"}),l.jsx("div",{className:"space-y-2",children:[1,2,3].map(T=>l.jsx("div",{className:"skeleton-text-sm w-full"},T))})]},A))})]}):l.jsx(Jj,{})}),l.jsxs("footer",{className:"footer",children:[l.jsxs("span",{className:"footer-brand",children:[l.jsx("span",{children:"Canonry"}),o.apiStatus.version&&o.apiStatus.version!=="unknown"?l.jsxs("span",{className:"footer-version",children:["v",o.apiStatus.version]}):null]}),l.jsx("div",{className:"footer-links",children:vT.map(({label:A,href:T,Icon:C})=>l.jsx("a",{href:T,target:"_blank",rel:"noopener noreferrer",title:A,"aria-label":A,className:"footer-icon",children:l.jsx(C,{className:"size-3.5"})},T))})]})]}),k?l.jsxs(qne,{open:k!==void 0,title:k.summary,subtitle:`${k.projectName} · ${k.kindLabel}`,onClose:p,children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-1 text-sm",children:[l.jsx(Wy,{status:k.status}),l.jsx("span",{className:"text-zinc-400",children:k.startedAt}),l.jsx("span",{className:"text-zinc-500",children:k.duration}),l.jsx("span",{className:"text-zinc-600",children:k.triggerLabel})]}),k.status==="failed"&&k.statusDetail&&l.jsx("p",{className:"text-sm text-rose-300/80 mt-2",children:k.statusDetail}),l.jsxs("div",{className:"mt-4",children:[l.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-zinc-500 mb-2",children:"Activity Log"}),w?l.jsx("p",{className:"text-sm text-zinc-500",children:"Loading run details..."}):S&&S.snapshots.length>0?l.jsxs("div",{className:"space-y-2",children:[S.snapshots.map(A=>l.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/30 p-3",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[l.jsx("p",{className:"text-sm font-medium text-zinc-200 truncate",children:A.query??"Unknown query"}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(Ll,{provider:A.provider}),l.jsx($5,{variant:A.citationState===Zf.cited?"success":"neutral",children:A.citationState})]})]}),A.model&&l.jsx("p",{className:"text-[11px] text-zinc-500 font-mono",children:A.model}),A.citedDomains.length>0&&l.jsxs("p",{className:"text-xs text-zinc-500 mt-1",children:[l.jsx("span",{className:"text-zinc-400",children:"Sources:"})," ",A.citedDomains.join(", ")]}),A.competitorOverlap.length>0&&l.jsxs("p",{className:"text-xs text-rose-400/80 mt-0.5",children:["Competitor cited: ",A.competitorOverlap.join(", ")]}),A.groundingSources&&A.groundingSources.length>0&&l.jsxs("details",{className:"mt-2",children:[l.jsxs("summary",{className:"text-xs text-zinc-500 cursor-pointer hover:text-zinc-400",children:[A.groundingSources.length," grounding source",A.groundingSources.length!==1?"s":""]}),l.jsx("ul",{className:"mt-1 space-y-0.5",children:A.groundingSources.map((T,C)=>l.jsx("li",{className:"text-xs text-zinc-500 truncate",children:l.jsx("a",{href:T.uri,target:"_blank",rel:"noopener noreferrer",className:"hover:text-zinc-300",children:T.title||T.uri})},C))})]}),A.answerText&&l.jsxs("details",{className:"mt-1",children:[l.jsx("summary",{className:"text-xs text-zinc-500 cursor-pointer hover:text-zinc-400",children:"Answer preview"}),l.jsx("p",{className:"mt-1 text-xs text-zinc-400 leading-relaxed whitespace-pre-wrap",children:A.answerText})]})]},A.id)),S.status==="running"&&l.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-zinc-500",children:[l.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-amber-500 animate-pulse"}),"Running remaining queries..."]})]}):S&&S.status==="running"?l.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-zinc-500",children:[l.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-amber-500 animate-pulse"}),"Waiting for first query result..."]}):S&&S.status==="queued"?l.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-zinc-500",children:[l.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-zinc-500 animate-pulse"}),"Run queued, waiting for execution slot..."]}):S&&S.error?l.jsxs("div",{className:"rounded-lg border border-rose-800/40 bg-rose-950/20 p-3",children:[l.jsx("p",{className:"text-sm font-medium text-rose-300 mb-2",children:"Run failed"}),l.jsx("pre",{className:"text-xs text-rose-300/80 whitespace-pre-wrap break-words max-h-48 overflow-y-auto font-mono leading-5",children:UJ(S.error)})]}):l.jsx("p",{className:"text-sm text-zinc-500",children:"No snapshot data available."})]})]}):null,O?l.jsx(Gne,{evidence:O.evidence,project:O.project,onClose:p}):null,l.jsx(xle,{}),l.jsx(Cre,{}),l.jsx(ule,{})]})}class wle extends b.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[ErrorBoundary]",t,n.componentStack)}handleReset=()=>{this.setState({error:null})};render(){return this.state.error?l.jsx("div",{className:"page-container",children:l.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 py-20 text-center",children:[l.jsx("div",{className:"rounded-full bg-rose-950/40 p-3",children:l.jsx(Ng,{className:"size-6 text-rose-400"})}),l.jsx("h2",{className:"text-lg font-semibold text-zinc-100",children:"Something went wrong"}),l.jsx("p",{className:"text-sm text-zinc-400 max-w-md",children:this.state.error.message||"An unexpected error occurred while rendering this page."}),l.jsxs("div",{className:"flex gap-3 mt-2",children:[l.jsxs(ye,{variant:"secondary",size:"sm",onClick:this.handleReset,children:[l.jsx(gL,{className:"size-3.5 mr-1.5"}),"Try again"]}),l.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>{const t=window.__CANONRY_CONFIG__?.basePath?.replace(/\/$/,"")??"";window.location.href=t||"/"},children:"Go home"})]})]})}):this.props.children}}const Ie=b.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:$i("rounded-xl border border-zinc-800 bg-zinc-950/75 shadow-[0_0_0_1px_rgba(255,255,255,0.01)] backdrop-blur",e),...t}));Ie.displayName="Card";const N1=b.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:$i("flex flex-col gap-1.5 p-5",e),...t}));N1.displayName="CardHeader";const k1=b.forwardRef(({className:e,...t},n)=>l.jsx("h3",{ref:n,className:$i("font-medium tracking-tight text-zinc-50",e),...t}));k1.displayName="CardTitle";const C1=b.forwardRef(({className:e,...t},n)=>l.jsx("p",{ref:n,className:$i("text-sm text-zinc-500",e),...t}));C1.displayName="CardDescription";const ng=b.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:$i("p-5 pt-0",e),...t}));ng.displayName="CardContent";function Sle({points:e,tone:t}){const n=b.useId();if(e.length===0)return null;const r=42,i=132,a=5,o=Math.min(...e),d=Math.max(...e)-o||1,f=i-a*2,p=r-a*2,m=e.map((y,v)=>{const S=a+v/Math.max(e.length-1,1)*f,w=a+(1-(y-o)/d)*p;return`${S},${w}`}).join(" ");return l.jsxs("svg",{className:`sparkline sparkline-${t}`,viewBox:`0 0 ${i} ${r}`,"aria-hidden":"true",children:[l.jsx("defs",{children:l.jsx("clipPath",{id:n,children:l.jsx("rect",{x:a,y:a,width:f,height:p,rx:"8"})})}),l.jsx("line",{className:"sparkline-guide",x1:a,x2:i-a,y1:r-a,y2:r-a}),l.jsx("polyline",{clipPath:`url(#${n})`,points:m,vectorEffect:"non-scaling-stroke"})]})}function jle({project:e}){return l.jsxs(Qt,{to:"/projects/$projectId",params:{projectId:e.project.id},className:"project-row cursor-pointer",children:[l.jsxs("div",{className:"project-row-primary",children:[l.jsxs("div",{children:[l.jsx("p",{className:"project-name",children:e.project.name}),l.jsx("p",{className:"project-domain",children:e.project.canonicalDomain})]}),l.jsx("p",{className:"project-insight",children:e.insight})]}),l.jsx("div",{className:"project-row-stat",children:l.jsxs("div",{className:"metric-inline-block",children:[l.jsx("p",{className:"metric-inline-label",children:"Answer Visibility"}),l.jsx("p",{className:`metric-inline-value ${e.visibilityTone==="caution"?"text-amber-400":""}`,children:e.visibilityScore}),l.jsx("p",{className:"metric-inline-delta",children:e.visibilityDelta}),e.providerCoverage&&l.jsx("p",{className:"text-[10px] font-medium text-amber-400/80",children:e.providerCoverage})]})}),l.jsx("div",{className:"project-row-stat",children:l.jsxs("div",{className:"metric-inline-block",children:[l.jsx("p",{className:"metric-inline-label",children:"Competitor Pressure"}),l.jsx("p",{className:"metric-inline-value",children:e.competitorPressureLabel}),l.jsxs("p",{className:"metric-inline-delta",children:[e.lastRun.kindLabel," · ",Qy(e.lastRun.status)]})]})}),l.jsx("div",{className:"project-row-chart",children:l.jsx(Sle,{points:e.trend,tone:v5(e.lastRun.status)})}),l.jsx("span",{className:"project-row-link",children:l.jsx(vh,{className:"h-4 w-4 text-zinc-500"})})]})}function Nle(){const e=bh(),{dashboard:t,isLoading:n}=ec(),r=t??e?.dashboard;if(!r||n)return l.jsxs("div",{className:"page-skeleton",children:[l.jsxs("div",{className:"page-skeleton-header",children:[l.jsx("div",{className:"skeleton-text h-6 w-32"}),l.jsx("div",{className:"skeleton-text-sm w-64"})]}),l.jsx("div",{className:"space-y-3",children:[1,2,3].map(p=>l.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 p-4 flex items-center gap-4",children:[l.jsxs("div",{className:"flex-1 space-y-2",children:[l.jsx("div",{className:"skeleton-text w-36"}),l.jsx("div",{className:"skeleton-text-sm w-48"})]}),l.jsx("div",{className:"skeleton-text w-16"}),l.jsx("div",{className:"skeleton-text w-16"}),l.jsx("div",{className:"skeleton h-8 w-20 rounded"})]},p))})]});const i=r.portfolioOverview,u=nv(!e,e?.health).data??e?.health??{apiStatus:{label:"API",state:"checking",detail:"Checking service health"},workerStatus:{label:"Worker",state:"checking",detail:"Checking service health"}},d=VJ(i.systemHealth,u,r.settings),{openRun:f}=Ku();return l.jsxs("div",{className:"page-container",children:[l.jsxs("div",{className:"page-header",children:[l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Portfolio"}),l.jsx("p",{className:"page-subtitle",children:"Visibility and execution state across all projects"})]}),l.jsx("div",{className:"page-header-right",children:l.jsx("p",{className:"text-[11px] text-zinc-600",children:i.lastUpdatedAt})})]}),i.projects.length>0?l.jsx("div",{className:"project-list project-list-scrollable",children:i.projects.map(p=>l.jsx(jle,{project:p},p.project.id))}):l.jsxs(Ie,{className:"surface-card empty-card",children:[l.jsx("h3",{children:i.emptyState?.title??"No projects yet"}),l.jsx("p",{className:"supporting-copy",children:i.emptyState?.detail}),l.jsx(ye,{size:"sm",asChild:!0,children:l.jsx(Qt,{to:i.emptyState?.ctaHref==="/setup"||!i.emptyState?.ctaHref?"/setup":"/",children:i.emptyState?.ctaLabel??"Launch setup"})})]}),l.jsxs("div",{className:"overview-secondary-grid",children:[i.attentionItems.length>0&&l.jsxs("section",{className:"overview-secondary-section",children:[l.jsx("div",{className:"section-head section-head-inline",children:l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Needs attention"}),l.jsx("h2",{className:"section-title-sm",children:"What changed"})]})}),l.jsx("div",{className:"attention-list attention-list-scrollable",children:i.attentionItems.map(p=>l.jsxs(Qt,{to:p.href,className:`attention-item attention-item-${p.tone}`,children:[l.jsxs("div",{children:[l.jsx("p",{className:"attention-title",children:p.title}),l.jsx("p",{className:"attention-detail",children:p.detail})]}),l.jsx("span",{className:"attention-action",children:p.actionLabel})]},p.id))})]}),l.jsxs("section",{className:"overview-secondary-section",children:[l.jsx("div",{className:"section-head section-head-inline",children:l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Recent runs"}),l.jsx("h2",{className:"section-title-sm",children:"Activity"})]})}),l.jsx("div",{className:"compact-stack compact-stack-scrollable",children:i.recentRuns.length>0?i.recentRuns.map(p=>l.jsxs("button",{className:"compact-run",type:"button",onClick:()=>f(p.id),children:[l.jsxs("div",{children:[l.jsx("p",{className:"compact-run-title",children:p.projectName}),l.jsx("p",{className:"compact-run-detail",children:p.summary})]}),l.jsx(Wy,{status:p.status})]},p.id)):l.jsx("p",{className:"supporting-copy",children:"Run history appears here after the first launch."})})]})]}),l.jsxs("section",{className:"page-section",children:[l.jsx("div",{className:"section-head section-head-inline",children:l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"System health"}),l.jsx("h2",{className:"section-title-sm",children:"Infrastructure"})]})}),l.jsx("div",{className:"health-grid",children:d.map(p=>l.jsxs(Ie,{className:"surface-card compact-card",children:[l.jsxs("div",{className:"section-head",children:[l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:p.label}),l.jsx("h3",{children:p.detail})]}),l.jsx(vt,{tone:p.tone,title:p.id==="api"?ko(u.apiStatus):p.id==="worker"?ko(u.workerStatus):void 0,children:p.label})]}),l.jsx("p",{className:"supporting-copy",children:p.meta})]},p.id))})]})]})}const FN=Symbol.for("yaml.alias"),_1=Symbol.for("yaml.document"),xo=Symbol.for("yaml.map"),h3=Symbol.for("yaml.pair"),Oa=Symbol.for("yaml.scalar"),Qu=Symbol.for("yaml.seq"),Di=Symbol.for("yaml.node.type"),nc=e=>!!e&&typeof e=="object"&&e[Di]===FN,lv=e=>!!e&&typeof e=="object"&&e[Di]===_1,jh=e=>!!e&&typeof e=="object"&&e[Di]===xo,_n=e=>!!e&&typeof e=="object"&&e[Di]===h3,Wt=e=>!!e&&typeof e=="object"&&e[Di]===Oa,Nh=e=>!!e&&typeof e=="object"&&e[Di]===Qu;function kn(e){if(e&&typeof e=="object")switch(e[Di]){case xo:case Qu:return!0}return!1}function Cn(e){if(e&&typeof e=="object")switch(e[Di]){case FN:case xo:case Oa:case Qu:return!0}return!1}const p3=e=>(Wt(e)||kn(e))&&!!e.anchor,dl=Symbol("break visit"),kle=Symbol("skip children"),If=Symbol("remove node");function Zu(e,t){const n=Cle(t);lv(e)?ou(null,e.contents,n,Object.freeze([e]))===If&&(e.contents=null):ou(null,e,n,Object.freeze([]))}Zu.BREAK=dl;Zu.SKIP=kle;Zu.REMOVE=If;function ou(e,t,n,r){const i=_le(e,t,n,r);if(Cn(i)||_n(i))return Ale(e,r,i),ou(e,i,n,r);if(typeof i!="symbol"){if(kn(t)){r=Object.freeze(r.concat(t));for(let a=0;a<t.items.length;++a){const o=ou(a,t.items[a],n,r);if(typeof o=="number")a=o-1;else{if(o===dl)return dl;o===If&&(t.items.splice(a,1),a-=1)}}}else if(_n(t)){r=Object.freeze(r.concat(t));const a=ou("key",t.key,n,r);if(a===dl)return dl;a===If&&(t.key=null);const o=ou("value",t.value,n,r);if(o===dl)return dl;o===If&&(t.value=null)}}return i}function Cle(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function _le(e,t,n,r){if(typeof n=="function")return n(e,t,r);if(jh(t))return n.Map?.(e,t,r);if(Nh(t))return n.Seq?.(e,t,r);if(_n(t))return n.Pair?.(e,t,r);if(Wt(t))return n.Scalar?.(e,t,r);if(nc(t))return n.Alias?.(e,t,r)}function Ale(e,t,n){const r=t[t.length-1];if(kn(r))r.items[e]=n;else if(_n(r))e==="key"?r.key=n:r.value=n;else if(lv(r))r.contents=n;else{const i=nc(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}const Ele={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Ole=e=>e.replace(/[!,[\]{}]/g,t=>Ele[t]);class br{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},br.defaultYaml,t),this.tags=Object.assign({},br.defaultTags,n)}clone(){const t=new br(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){const t=new br(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:br.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},br.defaultTags);break}return t}add(t,n){this.atNextDocument&&(this.yaml={explicit:br.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},br.defaultTags),this.atNextDocument=!1);const r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case"%TAG":{if(r.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;const[a,o]=r;return this.tags[a]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;const[a]=r;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{const o=/^\d+\.\d+$/.test(a);return n(6,`Unsupported YAML version ${a}`,o),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(t,n){if(t==="!")return"!";if(t[0]!=="!")return n(`Not a valid tag: ${t}`),null;if(t[1]==="<"){const o=t.slice(2,-1);return o==="!"||o==="!!"?(n(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&n("Verbatim tags must end with a >"),o)}const[,r,i]=t.match(/^(.*!)([^!]*)$/s);i||n(`The ${t} tag has no suffix`);const a=this.tags[r];if(a)try{return a+decodeURIComponent(i)}catch(o){return n(String(o)),null}return r==="!"?t:(n(`Could not resolve tag: ${t}`),null)}tagString(t){for(const[n,r]of Object.entries(this.tags))if(t.startsWith(r))return n+Ole(t.substring(r.length));return t[0]==="!"?t:`!<${t}>`}toString(t){const n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags);let i;if(t&&r.length>0&&Cn(t.contents)){const a={};Zu(t.contents,(o,u)=>{Cn(u)&&u.tag&&(a[u.tag]=!0)}),i=Object.keys(a)}else i=[];for(const[a,o]of r)a==="!!"&&o==="tag:yaml.org,2002:"||(!t||i.some(u=>u.startsWith(o)))&&n.push(`%TAG ${a} ${o}`);return n.join(`
|
|
116
|
+
… (${t.length-2e3} more chars)`:t}catch{return String(e)}}function f3({content:e}){return l.jsx("div",{className:"aero-markdown text-zinc-100",children:l.jsx(qoe,{components:{h1:t=>l.jsx("h1",{...t,className:"mt-3 mb-2 text-base font-semibold text-zinc-50"}),h2:t=>l.jsx("h2",{...t,className:"mt-3 mb-2 text-sm font-semibold text-zinc-50"}),h3:t=>l.jsx("h3",{...t,className:"mt-3 mb-1.5 text-sm font-semibold text-zinc-100"}),h4:t=>l.jsx("h4",{...t,className:"mt-2 mb-1 text-xs font-semibold uppercase tracking-wide text-zinc-300"}),p:t=>l.jsx("p",{...t,className:"mb-2 leading-relaxed"}),ul:t=>l.jsx("ul",{...t,className:"mb-2 ml-4 list-disc space-y-1"}),ol:t=>l.jsx("ol",{...t,className:"mb-2 ml-4 list-decimal space-y-1"}),li:t=>l.jsx("li",{...t,className:"marker:text-zinc-600"}),strong:t=>l.jsx("strong",{...t,className:"font-semibold text-zinc-50"}),em:t=>l.jsx("em",{...t,className:"text-zinc-200"}),code:({children:t,...n})=>l.jsx("code",{...n,className:"rounded bg-zinc-800/70 px-1 py-0.5 font-mono text-[12px] text-emerald-200",children:t}),pre:t=>l.jsx("pre",{...t,className:"mb-2 overflow-x-auto rounded-md border border-zinc-800 bg-zinc-900/70 p-3 font-mono text-xs text-zinc-200"}),a:t=>l.jsx("a",{...t,className:"text-emerald-400 underline decoration-emerald-700 hover:decoration-emerald-400",target:"_blank",rel:"noopener noreferrer"}),table:t=>l.jsx("div",{className:"mb-2 overflow-x-auto",children:l.jsx("table",{...t,className:"w-full border-collapse text-xs"})}),thead:t=>l.jsx("thead",{...t,className:"border-b border-zinc-800"}),th:t=>l.jsx("th",{...t,className:"px-2 py-1 text-left font-semibold text-zinc-300"}),tr:t=>l.jsx("tr",{...t,className:"border-b border-zinc-900"}),td:t=>l.jsx("td",{...t,className:"px-2 py-1 text-zinc-200"}),blockquote:t=>l.jsx("blockquote",{...t,className:"mb-2 border-l-2 border-zinc-700 pl-3 italic text-zinc-400"}),hr:()=>l.jsx("hr",{className:"my-3 border-zinc-800"})},children:e})})}function cle(){return l.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-wider text-emerald-400",children:"Aero"}),l.jsxs("div",{className:"flex items-center gap-1","aria-label":"Aero is thinking",children:[l.jsx("span",{className:"aero-dot h-1.5 w-1.5 rounded-full bg-emerald-400/80"}),l.jsx("span",{className:"aero-dot aero-dot-2 h-1.5 w-1.5 rounded-full bg-emerald-400/60"}),l.jsx("span",{className:"aero-dot aero-dot-3 h-1.5 w-1.5 rounded-full bg-emerald-400/40"})]})]})}function ule(){const e=QI(),t=/^\/projects\/([^/]+)/.exec(e.pathname),n=t?decodeURIComponent(t[1]):null,r=ta({queryKey:$e.projects.all,queryFn:eN,enabled:n!==null,staleTime:6e4});if(!n)return null;const i=r.data??[],a=i.find(o=>o.id===n)??i.find(o=>o.name===n);return a?l.jsx(Joe,{projectName:a.name},a.name):null}function ov(e,t,n){switch(e.invalidateQueries({queryKey:$e.runs.all}),e.invalidateQueries({queryKey:$e.projects.all}),t){case kt["answer-visibility"]:case kt["site-audit"]:case kt["backlink-extract"]:return;case kt["gsc-sync"]:case kt["inspect-sitemap"]:e.invalidateQueries({queryKey:$e.gsc.project(n)});return;case kt["ga-sync"]:case kt["traffic-sync"]:e.invalidateQueries({queryKey:$e.traffic.project(n)});return;case kt["bing-inspect"]:case kt["bing-inspect-sitemap"]:e.invalidateQueries({queryKey:$e.bing.project(n)});return;default:return t}}const vT=[{label:"GitHub",href:"https://github.com/AINYC/canonry",Icon:XG},{label:"Docs",href:"https://github.com/AINYC/canonry/tree/main/docs",Icon:DG},{label:"Changelog",href:"https://github.com/AINYC/canonry/releases",Icon:YG}],xT=e=>({label:e,state:"checking",detail:"Checking service health"}),dle={apiStatus:xT("API"),workerStatus:xT("Worker")};function fle(e){switch(e){case kt["answer-visibility"]:return"Visibility sweep";case kt["gsc-sync"]:return"GSC sync";case kt["inspect-sitemap"]:return"Sitemap inspection";case kt["ga-sync"]:return"GA sync";case kt["traffic-sync"]:return"Traffic sync";case kt["bing-inspect"]:return"Bing URL inspection";case kt["bing-inspect-sitemap"]:return"Bing sitemap inspection";case kt["site-audit"]:return"Site audit";case kt["backlink-extract"]:return"Backlink extract"}}function hle(e){return e==="completed"?"positive":e==="partial"?"caution":"negative"}function ple(e){const t=fle(e.kind);return e.status==="completed"?`${t} completed`:e.status==="partial"?`${t} completed with partial results`:e.status==="cancelled"?`${t} cancelled`:`${t} failed`}function mle(e,t){return e.error?`${t}: ${hN(e.error)}`:e.location?`${t} · ${e.location}`:t}function gle(e,t,n){if(t)return t;const r=n.find(i=>i.id===e);return r?.displayName||r?.name||e}function yle(e,t){return[e.completed>0?`${e.completed} completed`:null,e.partial>0?`${e.partial} partial`:null,e.failed>0?`${e.failed} failed`:null,e.cancelled>0?`${e.cancelled} cancelled`:null,t>0?`${t} skipped at queue time`:null].filter(Boolean).join(", ")}function vle(e){return e.failed>0||e.cancelled>0?"negative":e.partial>0?"caution":"positive"}function xle(){const e=ai(),t=b.useSyncExternalStore(eee,Il,Il),n=Object.keys(t.runs).length>0||Object.keys(t.batches).length>0,r=ta({queryKey:$e.runs.all,queryFn:WI,enabled:n,staleTime:i1,refetchInterval:3e3}),i=ta({queryKey:$e.projects.all,queryFn:eN,enabled:n}),a=b.useRef({}),o=b.useCallback(()=>{r.refetch()},[r.refetch]);return b.useEffect(()=>{n&&o()},[n,o]),b.useEffect(()=>{if(!n||typeof window>"u")return;const u=()=>{document.visibilityState==="visible"&&o()};return window.addEventListener("focus",o),document.addEventListener("visibilitychange",u),()=>{window.removeEventListener("focus",o),document.removeEventListener("visibilitychange",u)}},[n,o]),b.useEffect(()=>{const u=r.data??[],d=i.data??[],f=Object.fromEntries(u.map(m=>[m.id,m])),p=Object.fromEntries(u.map(m=>[m.id,m.status]));for(const m of Object.values(t.runs)){const y=f[m.runId];if(!y||!vN(y.status)||(a.current[y.id]??m.lastAnnouncedStatus)===y.status)continue;const S=d.find(j=>j.id===y.projectId);if(S&&ov(e,y.kind,S.name),m.sourceAction==="run-all"){n2(y.id);continue}const w=gle(y.projectId,m.projectLabel,d);xt({title:ple(y),detail:mle(y,w),tone:hle(y.status),dedupeKey:`run:${y.id}`,dedupeMode:"replace",cta:{label:"View run",intent:"open-run-drawer",runId:y.id}}),n2(y.id)}for(const m of Object.values(t.batches)){const y=ree(m.runIds,f);y.finished&&(xt({title:"Run-all batch finished",detail:yle(y,m.skippedCount),tone:vle(y),dedupeKey:`batch:${m.batchId}`,dedupeMode:"replace",cta:{label:"View runs",intent:"go-to-runs"}}),nee(m.batchId))}a.current=p},[i.data,r.data,t,e]),null}function ble(){const e=bh(),{dashboard:t,isLoading:n,refetch:r}=ec(),o=nv(!e,e?.health).data??e?.health??dle,u=QI(),{runId:d,evidenceId:f,closeDrawer:p}=Ku(),[m,y]=b.useState(!1),v=jre(d),S=v.data??null,w=v.isLoading;b.useEffect(()=>{S&&S.status!=="running"&&S.status!=="queued"&&r()},[S?.status,r]),b.useEffect(()=>{y(!1)},[u.pathname]),b.useEffect(()=>{if(typeof window>"u"||!d&&!f)return;const A=T=>{T.key==="Escape"&&p()};return window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A)}},[d,f,p]);const j=t??e?.dashboard??null,k=d&&j?Jne(j,d):void 0,O=f&&j?ere(j,f):void 0,_=(()=>{const A=u.pathname;if(A==="/")return"Portfolio";if(A==="/projects")return"Projects";if(A==="/runs")return"Runs";if(A==="/settings")return"Settings";if(A==="/setup")return"Setup";if(A==="/backlinks")return"Backlinks";if(A.startsWith("/projects/")){const C=A.split("/").filter(Boolean)[1];if(C&&j){const z=j.projects.find(R=>R.project.id===C);if(z)return z.project.name}return"Project"}return"Not found"})();return l.jsxs("div",{className:"app-shell",children:[l.jsx("a",{className:"skip-link",href:"#content",children:"Skip to content"}),l.jsxs("aside",{className:"sidebar","aria-label":"Primary navigation",children:[l.jsx("div",{className:"sidebar-brand",children:l.jsx(f2,{version:o.apiStatus.version})}),l.jsxs("nav",{className:"sidebar-nav",children:[l.jsxs(Qt,{to:"/",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(nV,{className:"sidebar-icon"}),l.jsx("span",{children:"Overview"})]}),l.jsxs(Qt,{to:"/projects",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!1},children:[l.jsx(eV,{className:"sidebar-icon"}),l.jsx("span",{children:"Projects"})]}),l.jsxs(Qt,{to:"/runs",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(jg,{className:"sidebar-icon"}),l.jsx("span",{children:"Runs"})]}),l.jsxs(Qt,{to:"/backlinks",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(pL,{className:"sidebar-icon"}),l.jsx("span",{children:"Backlinks"})]}),l.jsxs(Qt,{to:"/settings",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(bV,{className:"sidebar-icon"}),l.jsx("span",{children:"Settings"})]}),n?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"sidebar-section-title",children:"Projects"}),[1,2,3].map(A=>l.jsxs("div",{className:"sidebar-skeleton-item",children:[l.jsx("span",{className:"skeleton-circle size-2"}),l.jsx("span",{className:"skeleton-text flex-1",style:{width:`${50+A*15}%`}})]},A))]}):j&&j.projects.length>0?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"sidebar-section-title",children:"Projects"}),j.projects.map(A=>{const T=A.visibilitySummary.tone;return l.jsxs(Qt,{to:"/projects/$projectId",params:{projectId:A.project.id},className:"sidebar-project",activeProps:{className:"sidebar-project sidebar-project-active"},children:[l.jsx("span",{className:`sidebar-dot sidebar-dot-${T}`}),l.jsx("span",{children:A.project.name})]},A.project.id)})]}):n?null:l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"sidebar-section-title",children:"Resources"}),l.jsxs(Qt,{to:"/setup",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(yV,{className:"sidebar-icon"}),l.jsx("span",{children:"Setup"})]})]})]}),l.jsx("div",{className:"sidebar-footer",children:vT.map(({label:A,href:T,Icon:C})=>l.jsx("a",{className:"sidebar-footer-icon",href:T,target:"_blank",rel:"noopener noreferrer",title:A,"aria-label":A,children:l.jsx(C,{className:"size-4"})},T))})]}),l.jsxs("div",{className:"main-area",children:[l.jsxs("header",{className:"topbar",children:[l.jsxs("div",{className:"topbar-left",children:[l.jsx("div",{className:"topbar-brand-mobile",children:l.jsx(f2,{compact:!0})}),l.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[l.jsx(Qt,{to:"/",children:"Home"}),l.jsx(vh,{className:"breadcrumb-sep size-3"}),l.jsx("span",{className:"breadcrumb-current",children:_})]})]}),l.jsxs("div",{className:"topbar-actions",children:[l.jsxs("div",{className:"health-pill-row",children:[l.jsxs("span",{className:`health-pill health-pill-${o.apiStatus.state}`,title:ko(o.apiStatus),children:["API ",o.apiStatus.state==="ok"?"ok":o.apiStatus.state]}),l.jsxs("span",{className:`health-pill health-pill-${o.workerStatus.state}`,title:ko(o.workerStatus),children:["Worker ",o.workerStatus.state==="ok"?"ok":o.workerStatus.state]})]}),l.jsxs(ye,{className:"nav-toggle",variant:"secondary",size:"icon",type:"button","aria-expanded":m,"aria-controls":"mobile-nav",onClick:()=>y(A=>!A),children:[l.jsx(lV,{className:"size-4"}),l.jsx("span",{className:"sr-only",children:"Open navigation"})]})]})]}),l.jsxs("div",{id:"mobile-nav",className:`mobile-nav ${m?"mobile-nav-open":""}`,children:[l.jsxs(ye,{className:"mobile-nav-close",variant:"ghost",size:"icon",type:"button",onClick:()=>y(!1),children:[l.jsx(xh,{className:"size-5"}),l.jsx("span",{className:"sr-only",children:"Close navigation"})]}),l.jsx(Qt,{to:"/",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Overview"}),l.jsx(Qt,{to:"/projects",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!1},children:"Projects"}),l.jsx(Qt,{to:"/runs",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Runs"}),l.jsx(Qt,{to:"/settings",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Settings"}),j&&j.projects.length>0?l.jsxs("div",{className:"mobile-nav-section",children:[l.jsx("p",{className:"mobile-nav-section-title",children:"Projects"}),j.projects.map(A=>l.jsx(Qt,{to:"/projects/$projectId",params:{projectId:A.project.id},className:"mobile-nav-link",children:A.project.name},A.project.id))]}):null]}),l.jsx("main",{id:"content",className:"page-shell",children:n&&!e?l.jsxs("div",{className:"page-skeleton",children:[l.jsxs("div",{className:"page-skeleton-header",children:[l.jsx("div",{className:"skeleton-text h-6 w-40"}),l.jsx("div",{className:"skeleton-text-sm w-72"})]}),l.jsx("div",{className:"page-skeleton-grid",children:[1,2,3].map(A=>l.jsxs("div",{className:"page-skeleton-card",children:[l.jsx("div",{className:"skeleton-text w-24"}),l.jsx("div",{className:"skeleton-text w-full"}),l.jsx("div",{className:"skeleton-text-sm w-3/4"})]},A))}),l.jsx("div",{className:"page-skeleton-grid",style:{gridTemplateColumns:"1fr 1fr"},children:[1,2].map(A=>l.jsxs("div",{className:"page-skeleton-card",children:[l.jsx("div",{className:"skeleton-text w-20"}),l.jsx("div",{className:"space-y-2",children:[1,2,3].map(T=>l.jsx("div",{className:"skeleton-text-sm w-full"},T))})]},A))})]}):l.jsx(Jj,{})}),l.jsxs("footer",{className:"footer",children:[l.jsxs("span",{className:"footer-brand",children:[l.jsx("span",{children:l.jsx("a",{href:"https://canonry.ai",children:"Canonry"})}),o.apiStatus.version&&o.apiStatus.version!=="unknown"?l.jsxs("span",{className:"footer-version",children:["v",o.apiStatus.version]}):null]}),l.jsx("div",{className:"footer-links",children:vT.map(({label:A,href:T,Icon:C})=>l.jsx("a",{href:T,target:"_blank",rel:"noopener noreferrer",title:A,"aria-label":A,className:"footer-icon",children:l.jsx(C,{className:"size-3.5"})},T))})]})]}),k?l.jsxs(qne,{open:k!==void 0,title:k.summary,subtitle:`${k.projectName} · ${k.kindLabel}`,onClose:p,children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-1 text-sm",children:[l.jsx(Wy,{status:k.status}),l.jsx("span",{className:"text-zinc-400",children:k.startedAt}),l.jsx("span",{className:"text-zinc-500",children:k.duration}),l.jsx("span",{className:"text-zinc-600",children:k.triggerLabel})]}),k.status==="failed"&&k.statusDetail&&l.jsx("p",{className:"text-sm text-rose-300/80 mt-2",children:k.statusDetail}),l.jsxs("div",{className:"mt-4",children:[l.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-zinc-500 mb-2",children:"Activity Log"}),w?l.jsx("p",{className:"text-sm text-zinc-500",children:"Loading run details..."}):S&&S.snapshots.length>0?l.jsxs("div",{className:"space-y-2",children:[S.snapshots.map(A=>l.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/30 p-3",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[l.jsx("p",{className:"text-sm font-medium text-zinc-200 truncate",children:A.query??"Unknown query"}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(Ll,{provider:A.provider}),l.jsx($5,{variant:A.citationState===Zf.cited?"success":"neutral",children:A.citationState})]})]}),A.model&&l.jsx("p",{className:"text-[11px] text-zinc-500 font-mono",children:A.model}),A.citedDomains.length>0&&l.jsxs("p",{className:"text-xs text-zinc-500 mt-1",children:[l.jsx("span",{className:"text-zinc-400",children:"Sources:"})," ",A.citedDomains.join(", ")]}),A.competitorOverlap.length>0&&l.jsxs("p",{className:"text-xs text-rose-400/80 mt-0.5",children:["Competitor cited: ",A.competitorOverlap.join(", ")]}),A.groundingSources&&A.groundingSources.length>0&&l.jsxs("details",{className:"mt-2",children:[l.jsxs("summary",{className:"text-xs text-zinc-500 cursor-pointer hover:text-zinc-400",children:[A.groundingSources.length," grounding source",A.groundingSources.length!==1?"s":""]}),l.jsx("ul",{className:"mt-1 space-y-0.5",children:A.groundingSources.map((T,C)=>l.jsx("li",{className:"text-xs text-zinc-500 truncate",children:l.jsx("a",{href:T.uri,target:"_blank",rel:"noopener noreferrer",className:"hover:text-zinc-300",children:T.title||T.uri})},C))})]}),A.answerText&&l.jsxs("details",{className:"mt-1",children:[l.jsx("summary",{className:"text-xs text-zinc-500 cursor-pointer hover:text-zinc-400",children:"Answer preview"}),l.jsx("p",{className:"mt-1 text-xs text-zinc-400 leading-relaxed whitespace-pre-wrap",children:A.answerText})]})]},A.id)),S.status==="running"&&l.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-zinc-500",children:[l.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-amber-500 animate-pulse"}),"Running remaining queries..."]})]}):S&&S.status==="running"?l.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-zinc-500",children:[l.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-amber-500 animate-pulse"}),"Waiting for first query result..."]}):S&&S.status==="queued"?l.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-zinc-500",children:[l.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-zinc-500 animate-pulse"}),"Run queued, waiting for execution slot..."]}):S&&S.error?l.jsxs("div",{className:"rounded-lg border border-rose-800/40 bg-rose-950/20 p-3",children:[l.jsx("p",{className:"text-sm font-medium text-rose-300 mb-2",children:"Run failed"}),l.jsx("pre",{className:"text-xs text-rose-300/80 whitespace-pre-wrap break-words max-h-48 overflow-y-auto font-mono leading-5",children:UJ(S.error)})]}):l.jsx("p",{className:"text-sm text-zinc-500",children:"No snapshot data available."})]})]}):null,O?l.jsx(Gne,{evidence:O.evidence,project:O.project,onClose:p}):null,l.jsx(xle,{}),l.jsx(Cre,{}),l.jsx(ule,{})]})}class wle extends b.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[ErrorBoundary]",t,n.componentStack)}handleReset=()=>{this.setState({error:null})};render(){return this.state.error?l.jsx("div",{className:"page-container",children:l.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 py-20 text-center",children:[l.jsx("div",{className:"rounded-full bg-rose-950/40 p-3",children:l.jsx(Ng,{className:"size-6 text-rose-400"})}),l.jsx("h2",{className:"text-lg font-semibold text-zinc-100",children:"Something went wrong"}),l.jsx("p",{className:"text-sm text-zinc-400 max-w-md",children:this.state.error.message||"An unexpected error occurred while rendering this page."}),l.jsxs("div",{className:"flex gap-3 mt-2",children:[l.jsxs(ye,{variant:"secondary",size:"sm",onClick:this.handleReset,children:[l.jsx(gL,{className:"size-3.5 mr-1.5"}),"Try again"]}),l.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>{const t=window.__CANONRY_CONFIG__?.basePath?.replace(/\/$/,"")??"";window.location.href=t||"/"},children:"Go home"})]})]})}):this.props.children}}const Ie=b.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:$i("rounded-xl border border-zinc-800 bg-zinc-950/75 shadow-[0_0_0_1px_rgba(255,255,255,0.01)] backdrop-blur",e),...t}));Ie.displayName="Card";const N1=b.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:$i("flex flex-col gap-1.5 p-5",e),...t}));N1.displayName="CardHeader";const k1=b.forwardRef(({className:e,...t},n)=>l.jsx("h3",{ref:n,className:$i("font-medium tracking-tight text-zinc-50",e),...t}));k1.displayName="CardTitle";const C1=b.forwardRef(({className:e,...t},n)=>l.jsx("p",{ref:n,className:$i("text-sm text-zinc-500",e),...t}));C1.displayName="CardDescription";const ng=b.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:$i("p-5 pt-0",e),...t}));ng.displayName="CardContent";function Sle({points:e,tone:t}){const n=b.useId();if(e.length===0)return null;const r=42,i=132,a=5,o=Math.min(...e),d=Math.max(...e)-o||1,f=i-a*2,p=r-a*2,m=e.map((y,v)=>{const S=a+v/Math.max(e.length-1,1)*f,w=a+(1-(y-o)/d)*p;return`${S},${w}`}).join(" ");return l.jsxs("svg",{className:`sparkline sparkline-${t}`,viewBox:`0 0 ${i} ${r}`,"aria-hidden":"true",children:[l.jsx("defs",{children:l.jsx("clipPath",{id:n,children:l.jsx("rect",{x:a,y:a,width:f,height:p,rx:"8"})})}),l.jsx("line",{className:"sparkline-guide",x1:a,x2:i-a,y1:r-a,y2:r-a}),l.jsx("polyline",{clipPath:`url(#${n})`,points:m,vectorEffect:"non-scaling-stroke"})]})}function jle({project:e}){return l.jsxs(Qt,{to:"/projects/$projectId",params:{projectId:e.project.id},className:"project-row cursor-pointer",children:[l.jsxs("div",{className:"project-row-primary",children:[l.jsxs("div",{children:[l.jsx("p",{className:"project-name",children:e.project.name}),l.jsx("p",{className:"project-domain",children:e.project.canonicalDomain})]}),l.jsx("p",{className:"project-insight",children:e.insight})]}),l.jsx("div",{className:"project-row-stat",children:l.jsxs("div",{className:"metric-inline-block",children:[l.jsx("p",{className:"metric-inline-label",children:"Answer Visibility"}),l.jsx("p",{className:`metric-inline-value ${e.visibilityTone==="caution"?"text-amber-400":""}`,children:e.visibilityScore}),l.jsx("p",{className:"metric-inline-delta",children:e.visibilityDelta}),e.providerCoverage&&l.jsx("p",{className:"text-[10px] font-medium text-amber-400/80",children:e.providerCoverage})]})}),l.jsx("div",{className:"project-row-stat",children:l.jsxs("div",{className:"metric-inline-block",children:[l.jsx("p",{className:"metric-inline-label",children:"Competitor Pressure"}),l.jsx("p",{className:"metric-inline-value",children:e.competitorPressureLabel}),l.jsxs("p",{className:"metric-inline-delta",children:[e.lastRun.kindLabel," · ",Qy(e.lastRun.status)]})]})}),l.jsx("div",{className:"project-row-chart",children:l.jsx(Sle,{points:e.trend,tone:v5(e.lastRun.status)})}),l.jsx("span",{className:"project-row-link",children:l.jsx(vh,{className:"h-4 w-4 text-zinc-500"})})]})}function Nle(){const e=bh(),{dashboard:t,isLoading:n}=ec(),r=t??e?.dashboard;if(!r||n)return l.jsxs("div",{className:"page-skeleton",children:[l.jsxs("div",{className:"page-skeleton-header",children:[l.jsx("div",{className:"skeleton-text h-6 w-32"}),l.jsx("div",{className:"skeleton-text-sm w-64"})]}),l.jsx("div",{className:"space-y-3",children:[1,2,3].map(p=>l.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 p-4 flex items-center gap-4",children:[l.jsxs("div",{className:"flex-1 space-y-2",children:[l.jsx("div",{className:"skeleton-text w-36"}),l.jsx("div",{className:"skeleton-text-sm w-48"})]}),l.jsx("div",{className:"skeleton-text w-16"}),l.jsx("div",{className:"skeleton-text w-16"}),l.jsx("div",{className:"skeleton h-8 w-20 rounded"})]},p))})]});const i=r.portfolioOverview,u=nv(!e,e?.health).data??e?.health??{apiStatus:{label:"API",state:"checking",detail:"Checking service health"},workerStatus:{label:"Worker",state:"checking",detail:"Checking service health"}},d=VJ(i.systemHealth,u,r.settings),{openRun:f}=Ku();return l.jsxs("div",{className:"page-container",children:[l.jsxs("div",{className:"page-header",children:[l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Portfolio"}),l.jsx("p",{className:"page-subtitle",children:"Visibility and execution state across all projects"})]}),l.jsx("div",{className:"page-header-right",children:l.jsx("p",{className:"text-[11px] text-zinc-600",children:i.lastUpdatedAt})})]}),i.projects.length>0?l.jsx("div",{className:"project-list project-list-scrollable",children:i.projects.map(p=>l.jsx(jle,{project:p},p.project.id))}):l.jsxs(Ie,{className:"surface-card empty-card",children:[l.jsx("h3",{children:i.emptyState?.title??"No projects yet"}),l.jsx("p",{className:"supporting-copy",children:i.emptyState?.detail}),l.jsx(ye,{size:"sm",asChild:!0,children:l.jsx(Qt,{to:i.emptyState?.ctaHref==="/setup"||!i.emptyState?.ctaHref?"/setup":"/",children:i.emptyState?.ctaLabel??"Launch setup"})})]}),l.jsxs("div",{className:"overview-secondary-grid",children:[i.attentionItems.length>0&&l.jsxs("section",{className:"overview-secondary-section",children:[l.jsx("div",{className:"section-head section-head-inline",children:l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Needs attention"}),l.jsx("h2",{className:"section-title-sm",children:"What changed"})]})}),l.jsx("div",{className:"attention-list attention-list-scrollable",children:i.attentionItems.map(p=>l.jsxs(Qt,{to:p.href,className:`attention-item attention-item-${p.tone}`,children:[l.jsxs("div",{children:[l.jsx("p",{className:"attention-title",children:p.title}),l.jsx("p",{className:"attention-detail",children:p.detail})]}),l.jsx("span",{className:"attention-action",children:p.actionLabel})]},p.id))})]}),l.jsxs("section",{className:"overview-secondary-section",children:[l.jsx("div",{className:"section-head section-head-inline",children:l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Recent runs"}),l.jsx("h2",{className:"section-title-sm",children:"Activity"})]})}),l.jsx("div",{className:"compact-stack compact-stack-scrollable",children:i.recentRuns.length>0?i.recentRuns.map(p=>l.jsxs("button",{className:"compact-run",type:"button",onClick:()=>f(p.id),children:[l.jsxs("div",{children:[l.jsx("p",{className:"compact-run-title",children:p.projectName}),l.jsx("p",{className:"compact-run-detail",children:p.summary})]}),l.jsx(Wy,{status:p.status})]},p.id)):l.jsx("p",{className:"supporting-copy",children:"Run history appears here after the first launch."})})]})]}),l.jsxs("section",{className:"page-section",children:[l.jsx("div",{className:"section-head section-head-inline",children:l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"System health"}),l.jsx("h2",{className:"section-title-sm",children:"Infrastructure"})]})}),l.jsx("div",{className:"health-grid",children:d.map(p=>l.jsxs(Ie,{className:"surface-card compact-card",children:[l.jsxs("div",{className:"section-head",children:[l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:p.label}),l.jsx("h3",{children:p.detail})]}),l.jsx(vt,{tone:p.tone,title:p.id==="api"?ko(u.apiStatus):p.id==="worker"?ko(u.workerStatus):void 0,children:p.label})]}),l.jsx("p",{className:"supporting-copy",children:p.meta})]},p.id))})]})]})}const FN=Symbol.for("yaml.alias"),_1=Symbol.for("yaml.document"),xo=Symbol.for("yaml.map"),h3=Symbol.for("yaml.pair"),Oa=Symbol.for("yaml.scalar"),Qu=Symbol.for("yaml.seq"),Di=Symbol.for("yaml.node.type"),nc=e=>!!e&&typeof e=="object"&&e[Di]===FN,lv=e=>!!e&&typeof e=="object"&&e[Di]===_1,jh=e=>!!e&&typeof e=="object"&&e[Di]===xo,_n=e=>!!e&&typeof e=="object"&&e[Di]===h3,Wt=e=>!!e&&typeof e=="object"&&e[Di]===Oa,Nh=e=>!!e&&typeof e=="object"&&e[Di]===Qu;function kn(e){if(e&&typeof e=="object")switch(e[Di]){case xo:case Qu:return!0}return!1}function Cn(e){if(e&&typeof e=="object")switch(e[Di]){case FN:case xo:case Oa:case Qu:return!0}return!1}const p3=e=>(Wt(e)||kn(e))&&!!e.anchor,dl=Symbol("break visit"),kle=Symbol("skip children"),If=Symbol("remove node");function Zu(e,t){const n=Cle(t);lv(e)?ou(null,e.contents,n,Object.freeze([e]))===If&&(e.contents=null):ou(null,e,n,Object.freeze([]))}Zu.BREAK=dl;Zu.SKIP=kle;Zu.REMOVE=If;function ou(e,t,n,r){const i=_le(e,t,n,r);if(Cn(i)||_n(i))return Ale(e,r,i),ou(e,i,n,r);if(typeof i!="symbol"){if(kn(t)){r=Object.freeze(r.concat(t));for(let a=0;a<t.items.length;++a){const o=ou(a,t.items[a],n,r);if(typeof o=="number")a=o-1;else{if(o===dl)return dl;o===If&&(t.items.splice(a,1),a-=1)}}}else if(_n(t)){r=Object.freeze(r.concat(t));const a=ou("key",t.key,n,r);if(a===dl)return dl;a===If&&(t.key=null);const o=ou("value",t.value,n,r);if(o===dl)return dl;o===If&&(t.value=null)}}return i}function Cle(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function _le(e,t,n,r){if(typeof n=="function")return n(e,t,r);if(jh(t))return n.Map?.(e,t,r);if(Nh(t))return n.Seq?.(e,t,r);if(_n(t))return n.Pair?.(e,t,r);if(Wt(t))return n.Scalar?.(e,t,r);if(nc(t))return n.Alias?.(e,t,r)}function Ale(e,t,n){const r=t[t.length-1];if(kn(r))r.items[e]=n;else if(_n(r))e==="key"?r.key=n:r.value=n;else if(lv(r))r.contents=n;else{const i=nc(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}const Ele={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Ole=e=>e.replace(/[!,[\]{}]/g,t=>Ele[t]);class br{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},br.defaultYaml,t),this.tags=Object.assign({},br.defaultTags,n)}clone(){const t=new br(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){const t=new br(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:br.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},br.defaultTags);break}return t}add(t,n){this.atNextDocument&&(this.yaml={explicit:br.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},br.defaultTags),this.atNextDocument=!1);const r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case"%TAG":{if(r.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;const[a,o]=r;return this.tags[a]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;const[a]=r;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{const o=/^\d+\.\d+$/.test(a);return n(6,`Unsupported YAML version ${a}`,o),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(t,n){if(t==="!")return"!";if(t[0]!=="!")return n(`Not a valid tag: ${t}`),null;if(t[1]==="<"){const o=t.slice(2,-1);return o==="!"||o==="!!"?(n(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&n("Verbatim tags must end with a >"),o)}const[,r,i]=t.match(/^(.*!)([^!]*)$/s);i||n(`The ${t} tag has no suffix`);const a=this.tags[r];if(a)try{return a+decodeURIComponent(i)}catch(o){return n(String(o)),null}return r==="!"?t:(n(`Could not resolve tag: ${t}`),null)}tagString(t){for(const[n,r]of Object.entries(this.tags))if(t.startsWith(r))return n+Ole(t.substring(r.length));return t[0]==="!"?t:`!<${t}>`}toString(t){const n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags);let i;if(t&&r.length>0&&Cn(t.contents)){const a={};Zu(t.contents,(o,u)=>{Cn(u)&&u.tag&&(a[u.tag]=!0)}),i=Object.keys(a)}else i=[];for(const[a,o]of r)a==="!!"&&o==="tag:yaml.org,2002:"||(!t||i.some(u=>u.startsWith(o)))&&n.push(`%TAG ${a} ${o}`);return n.join(`
|
|
117
117
|
`)}}br.defaultYaml={explicit:!1,version:"1.2"};br.defaultTags={"!!":"tag:yaml.org,2002:"};function m3(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){const n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(n)}return!0}function g3(e){const t=new Set;return Zu(e,{Value(n,r){r.anchor&&t.add(r.anchor)}}),t}function y3(e,t){for(let n=1;;++n){const r=`${e}${n}`;if(!t.has(r))return r}}function zle(e,t){const n=[],r=new Map;let i=null;return{onAnchor:a=>{n.push(a),i??(i=g3(e));const o=y3(t,i);return i.add(o),o},setAnchors:()=>{for(const a of n){const o=r.get(a);if(typeof o=="object"&&o.anchor&&(Wt(o.node)||kn(o.node)))o.node.anchor=o.anchor;else{const u=new Error("Failed to resolve repeated object (this should not happen)");throw u.source=a,u}}},sourceObjects:r}}function lu(e,t,n,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let i=0,a=r.length;i<a;++i){const o=r[i],u=lu(e,r,String(i),o);u===void 0?delete r[i]:u!==o&&(r[i]=u)}else if(r instanceof Map)for(const i of Array.from(r.keys())){const a=r.get(i),o=lu(e,r,i,a);o===void 0?r.delete(i):o!==a&&r.set(i,o)}else if(r instanceof Set)for(const i of Array.from(r)){const a=lu(e,r,i,i);a===void 0?r.delete(i):a!==i&&(r.delete(i),r.add(a))}else for(const[i,a]of Object.entries(r)){const o=lu(e,r,i,a);o===void 0?delete r[i]:o!==a&&(r[i]=o)}return e.call(t,n,r)}function Ti(e,t,n){if(Array.isArray(e))return e.map((r,i)=>Ti(r,String(i),n));if(e&&typeof e.toJSON=="function"){if(!n||!p3(e))return e.toJSON(t,n);const r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=a=>{r.res=a,delete n.onCreate};const i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e=="bigint"&&!n?.keep?Number(e):e}class HN{constructor(t){Object.defineProperty(this,Di,{value:t})}clone(){const t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){if(!lv(t))throw new TypeError("A document argument is required");const o={anchors:new Map,doc:t,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},u=Ti(this,"",o);if(typeof i=="function")for(const{count:d,res:f}of o.anchors.values())i(f,d);return typeof a=="function"?lu(a,{"":u},"",u):u}}class KN extends HN{constructor(t){super(FN),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,n){let r;n?.aliasResolveCache?r=n.aliasResolveCache:(r=[],Zu(t,{Node:(a,o)=>{(nc(o)||p3(o))&&r.push(o)}}),n&&(n.aliasResolveCache=r));let i;for(const a of r){if(a===this)break;a.anchor===this.source&&(i=a)}return i}toJSON(t,n){if(!n)return{source:this.source};const{anchors:r,doc:i,maxAliasCount:a}=n,o=this.resolve(i,n);if(!o){const d=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(d)}let u=r.get(o);if(u||(Ti(o,null,n),u=r.get(o)),u?.res===void 0){const d="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(d)}if(a>=0&&(u.count+=1,u.aliasCount===0&&(u.aliasCount=rg(i,o,r)),u.count*u.aliasCount>a)){const d="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(d)}return u.res}toString(t,n,r){const i=`*${this.source}`;if(t){if(m3(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){const a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(a)}if(t.implicitKey)return`${i} `}return i}}function rg(e,t,n){if(nc(t)){const r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(kn(t)){let r=0;for(const i of t.items){const a=rg(e,i,n);a>r&&(r=a)}return r}else if(_n(t)){const r=rg(e,t.key,n),i=rg(e,t.value,n);return Math.max(r,i)}return 1}const v3=e=>!e||typeof e!="function"&&typeof e!="object";class at extends HN{constructor(t){super(Oa),this.value=t}toJSON(t,n){return n?.keep?this.value:Ti(this.value,t,n)}toString(){return String(this.value)}}at.BLOCK_FOLDED="BLOCK_FOLDED";at.BLOCK_LITERAL="BLOCK_LITERAL";at.PLAIN="PLAIN";at.QUOTE_DOUBLE="QUOTE_DOUBLE";at.QUOTE_SINGLE="QUOTE_SINGLE";const Tle="tag:yaml.org,2002:";function Ple(e,t,n){if(t){const r=n.filter(a=>a.tag===t),i=r.find(a=>!a.format)??r[0];if(!i)throw new Error(`Tag ${t} not found`);return i}return n.find(r=>r.identify?.(e)&&!r.format)}function Jf(e,t,n){if(lv(e)&&(e=e.contents),Cn(e))return e;if(_n(e)){const m=n.schema[xo].createNode?.(n.schema,null,n);return m.items.push(e),m}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());const{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:u}=n;let d;if(r&&e&&typeof e=="object"){if(d=u.get(e),d)return d.anchor??(d.anchor=i(e)),new KN(d.anchor);d={anchor:null,node:null},u.set(e,d)}t?.startsWith("!!")&&(t=Tle+t.slice(2));let f=Ple(e,t,o.tags);if(!f){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){const m=new at(e);return d&&(d.node=m),m}f=e instanceof Map?o[xo]:Symbol.iterator in Object(e)?o[Qu]:o[xo]}a&&(a(f),delete n.onTagObj);const p=f?.createNode?f.createNode(n.schema,e,n):typeof f?.nodeClass?.from=="function"?f.nodeClass.from(n.schema,e,n):new at(e);return t?p.tag=t:f.default||(p.tag=f.tag),d&&(d.node=p),p}function Ig(e,t,n){let r=n;for(let i=t.length-1;i>=0;--i){const a=t[i];if(typeof a=="number"&&Number.isInteger(a)&&a>=0){const o=[];o[a]=r,r=o}else r=new Map([[a,r]])}return Jf(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}const _f=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done;class x3 extends HN{constructor(t,n){super(t),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(t){const n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(n.schema=t),n.items=n.items.map(r=>Cn(r)||_n(r)?r.clone(t):r),this.range&&(n.range=this.range.slice()),n}addIn(t,n){if(_f(t))this.add(n);else{const[r,...i]=t,a=this.get(r,!0);if(kn(a))a.addIn(i,n);else if(a===void 0&&this.schema)this.set(r,Ig(this.schema,i,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}deleteIn(t){const[n,...r]=t;if(r.length===0)return this.delete(n);const i=this.get(n,!0);if(kn(i))return i.deleteIn(r);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}getIn(t,n){const[r,...i]=t,a=this.get(r,!0);return i.length===0?!n&&Wt(a)?a.value:a:kn(a)?a.getIn(i,n):void 0}hasAllNullValues(t){return this.items.every(n=>{if(!_n(n))return!1;const r=n.value;return r==null||t&&Wt(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(t){const[n,...r]=t;if(r.length===0)return this.has(n);const i=this.get(n,!0);return kn(i)?i.hasIn(r):!1}setIn(t,n){const[r,...i]=t;if(i.length===0)this.set(r,n);else{const a=this.get(r,!0);if(kn(a))a.setIn(i,n);else if(a===void 0&&this.schema)this.set(r,Ig(this.schema,i,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}}const Rle=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function us(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}const xl=(e,t,n)=>e.endsWith(`
|
|
118
118
|
`)?us(n,t):n.includes(`
|
|
119
119
|
`)?`
|
package/assets/index.html
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<link rel="icon" type="image/png" sizes="32x32" href="./favicon-32.png" />
|
|
13
13
|
<link rel="apple-touch-icon" href="./apple-touch-icon.png" />
|
|
14
14
|
<title>Canonry</title>
|
|
15
|
-
<script type="module" crossorigin src="./assets/index-
|
|
15
|
+
<script type="module" crossorigin src="./assets/index-B6Mi9Fd1.js"></script>
|
|
16
16
|
<link rel="stylesheet" crossorigin href="./assets/index-D0EPNRDs.css">
|
|
17
17
|
</head>
|
|
18
18
|
<body>
|
|
@@ -155,11 +155,14 @@ import {
|
|
|
155
155
|
|
|
156
156
|
// src/telemetry.ts
|
|
157
157
|
import crypto from "crypto";
|
|
158
|
+
import os from "os";
|
|
158
159
|
import { createRequire } from "module";
|
|
159
160
|
var _require = createRequire(import.meta.url);
|
|
160
161
|
var { version: VERSION } = _require("../package.json");
|
|
161
162
|
var TELEMETRY_ENDPOINT = "https://ainyc.ai/api/telemetry";
|
|
162
163
|
var TIMEOUT_MS = 3e3;
|
|
164
|
+
var ANON_ID_ENV_VAR = "CANONRY_ANONYMOUS_ID";
|
|
165
|
+
var ANON_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
163
166
|
function isTelemetryEnabled() {
|
|
164
167
|
if (process.env.CANONRY_TELEMETRY_DISABLED === "1") return false;
|
|
165
168
|
if (process.env.DO_NOT_TRACK === "1") return false;
|
|
@@ -173,18 +176,66 @@ function isTelemetryEnabled() {
|
|
|
173
176
|
}
|
|
174
177
|
}
|
|
175
178
|
function getOrCreateAnonymousId() {
|
|
176
|
-
|
|
179
|
+
const fromEnv = readEnvAnonymousId();
|
|
180
|
+
if (fromEnv) return fromEnv;
|
|
181
|
+
if (configExists()) {
|
|
182
|
+
try {
|
|
183
|
+
const config = loadConfig();
|
|
184
|
+
if (config.anonymousId) return config.anonymousId;
|
|
185
|
+
const id = crypto.randomUUID();
|
|
186
|
+
config.anonymousId = id;
|
|
187
|
+
try {
|
|
188
|
+
saveConfigPatch(config);
|
|
189
|
+
} catch {
|
|
190
|
+
return getDeterministicAnonymousId();
|
|
191
|
+
}
|
|
192
|
+
return id;
|
|
193
|
+
} catch {
|
|
194
|
+
return getDeterministicAnonymousId();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return getDeterministicAnonymousId();
|
|
198
|
+
}
|
|
199
|
+
function readEnvAnonymousId() {
|
|
200
|
+
const raw = process.env[ANON_ID_ENV_VAR]?.trim();
|
|
201
|
+
if (!raw) return void 0;
|
|
202
|
+
if (!ANON_ID_PATTERN.test(raw)) {
|
|
203
|
+
return void 0;
|
|
204
|
+
}
|
|
205
|
+
return raw.toLowerCase();
|
|
206
|
+
}
|
|
207
|
+
function getDeterministicAnonymousId() {
|
|
177
208
|
try {
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
209
|
+
const hostname = os.hostname() || "";
|
|
210
|
+
const mac = firstNonInternalMac();
|
|
211
|
+
const seed = `canonry-anon:${hostname}:${mac}`;
|
|
212
|
+
const hex = crypto.createHash("sha256").update(seed).digest("hex");
|
|
213
|
+
const a = hex.slice(0, 8);
|
|
214
|
+
const b = hex.slice(8, 12);
|
|
215
|
+
const c = "5" + hex.slice(13, 16);
|
|
216
|
+
const dHi = (parseInt(hex.slice(16, 18), 16) & 63 | 128).toString(16).padStart(2, "0");
|
|
217
|
+
const d = dHi + hex.slice(18, 20);
|
|
218
|
+
const e = hex.slice(20, 32);
|
|
219
|
+
return `${a}-${b}-${c}-${d}-${e}`;
|
|
184
220
|
} catch {
|
|
185
221
|
return void 0;
|
|
186
222
|
}
|
|
187
223
|
}
|
|
224
|
+
function firstNonInternalMac() {
|
|
225
|
+
try {
|
|
226
|
+
const interfaces = os.networkInterfaces();
|
|
227
|
+
for (const ifaces of Object.values(interfaces)) {
|
|
228
|
+
if (!ifaces) continue;
|
|
229
|
+
for (const iface of ifaces) {
|
|
230
|
+
if (iface.internal) continue;
|
|
231
|
+
if (!iface.mac || iface.mac === "00:00:00:00:00:00") continue;
|
|
232
|
+
return iface.mac;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
} catch {
|
|
236
|
+
}
|
|
237
|
+
return "no-mac";
|
|
238
|
+
}
|
|
188
239
|
function isFirstRun() {
|
|
189
240
|
if (!configExists()) return false;
|
|
190
241
|
try {
|
|
@@ -12476,10 +12527,10 @@ async function bingRoutes(app, opts) {
|
|
|
12476
12527
|
// ../api-routes/src/cdp.ts
|
|
12477
12528
|
import fs from "fs";
|
|
12478
12529
|
import path from "path";
|
|
12479
|
-
import
|
|
12530
|
+
import os2 from "os";
|
|
12480
12531
|
import { eq as eq20, and as and8 } from "drizzle-orm";
|
|
12481
12532
|
function getScreenshotDir() {
|
|
12482
|
-
return path.join(
|
|
12533
|
+
return path.join(os2.homedir(), ".canonry", "screenshots");
|
|
12483
12534
|
}
|
|
12484
12535
|
async function cdpRoutes(app, opts) {
|
|
12485
12536
|
app.get("/screenshots/:snapshotId", async (request, reply) => {
|
|
@@ -15106,13 +15157,13 @@ import crypto18 from "crypto";
|
|
|
15106
15157
|
import { and as and11, asc as asc2, desc as desc11, eq as eq22, sql as sql6 } from "drizzle-orm";
|
|
15107
15158
|
|
|
15108
15159
|
// ../integration-commoncrawl/src/constants.ts
|
|
15109
|
-
import
|
|
15160
|
+
import os3 from "os";
|
|
15110
15161
|
import path2 from "path";
|
|
15111
15162
|
var CC_BASE_URL = "https://data.commoncrawl.org/projects/hyperlinkgraph";
|
|
15112
|
-
var PLUGIN_DIR = path2.join(
|
|
15163
|
+
var PLUGIN_DIR = path2.join(os3.homedir(), ".canonry", "plugins");
|
|
15113
15164
|
var PLUGIN_PKG_JSON = path2.join(PLUGIN_DIR, "package.json");
|
|
15114
15165
|
var DUCKDB_SPEC = process.env.CANONRY_DUCKDB_SPEC ?? "@duckdb/node-api@1.4.4-r.3";
|
|
15115
|
-
var CC_CACHE_DIR = process.env.CANONRY_CC_CACHE_DIR ?? path2.join(
|
|
15166
|
+
var CC_CACHE_DIR = process.env.CANONRY_CC_CACHE_DIR ?? path2.join(os3.homedir(), ".canonry", "cache", "commoncrawl");
|
|
15116
15167
|
var RELEASE_ID_REGEX = /^cc-main-(\d{4})-(jan-feb-mar|apr-may-jun|jul-aug-sep|oct-nov-dec)$/;
|
|
15117
15168
|
function ccReleasePaths(release) {
|
|
15118
15169
|
const base = `${CC_BASE_URL}/${release}/domain`;
|
|
@@ -17629,7 +17680,7 @@ async function apiRoutes(app, opts) {
|
|
|
17629
17680
|
}
|
|
17630
17681
|
|
|
17631
17682
|
// src/server.ts
|
|
17632
|
-
import
|
|
17683
|
+
import os6 from "os";
|
|
17633
17684
|
|
|
17634
17685
|
// ../provider-gemini/src/normalize.ts
|
|
17635
17686
|
import { GoogleGenAI } from "@google/genai";
|
|
@@ -19018,7 +19069,7 @@ var localAdapter = {
|
|
|
19018
19069
|
|
|
19019
19070
|
// ../provider-cdp/src/adapter.ts
|
|
19020
19071
|
import path8 from "path";
|
|
19021
|
-
import
|
|
19072
|
+
import os4 from "os";
|
|
19022
19073
|
|
|
19023
19074
|
// ../provider-cdp/src/connection.ts
|
|
19024
19075
|
import CDP from "chrome-remote-interface";
|
|
@@ -19482,7 +19533,7 @@ function getConnection(config) {
|
|
|
19482
19533
|
return conn;
|
|
19483
19534
|
}
|
|
19484
19535
|
function getScreenshotDir2() {
|
|
19485
|
-
return path8.join(
|
|
19536
|
+
return path8.join(os4.homedir(), ".canonry", "screenshots");
|
|
19486
19537
|
}
|
|
19487
19538
|
var cdpChatgptAdapter = {
|
|
19488
19539
|
name: "cdp:chatgpt",
|
|
@@ -20117,7 +20168,7 @@ function removeWordpressConnection(config, projectName) {
|
|
|
20117
20168
|
import crypto21 from "crypto";
|
|
20118
20169
|
import fs7 from "fs";
|
|
20119
20170
|
import path9 from "path";
|
|
20120
|
-
import
|
|
20171
|
+
import os5 from "os";
|
|
20121
20172
|
import { and as and12, eq as eq24, inArray as inArray7, sql as sql8 } from "drizzle-orm";
|
|
20122
20173
|
|
|
20123
20174
|
// src/citation-utils.ts
|
|
@@ -20366,6 +20417,50 @@ function resolveProviderFanout() {
|
|
|
20366
20417
|
const parsed = Number.parseInt(raw, 10);
|
|
20367
20418
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : PROVIDER_FANOUT_DEFAULT;
|
|
20368
20419
|
}
|
|
20420
|
+
function classifyRunAbortReason(message) {
|
|
20421
|
+
if (/^No providers configured\b/.test(message)) return "no_provider";
|
|
20422
|
+
if (/^Project [^ ]+ not found$/.test(message)) return "project_not_found";
|
|
20423
|
+
if (/^Daily quota exceeded\b/.test(message)) return "quota_exceeded";
|
|
20424
|
+
if (/^Run [^ ]+ not found$/.test(message)) return "run_not_found";
|
|
20425
|
+
if (/^Run [^ ]+ is not executable\b/.test(message)) return "run_not_executable";
|
|
20426
|
+
return void 0;
|
|
20427
|
+
}
|
|
20428
|
+
function classifyProviderErrors(errors) {
|
|
20429
|
+
const codes = /* @__PURE__ */ new Set();
|
|
20430
|
+
for (const message of errors.values()) {
|
|
20431
|
+
codes.add(classifyOneProviderError(message));
|
|
20432
|
+
}
|
|
20433
|
+
const priority = [
|
|
20434
|
+
"PROVIDER_AUTH",
|
|
20435
|
+
"RATE_LIMITED",
|
|
20436
|
+
"TIMEOUT",
|
|
20437
|
+
"NETWORK",
|
|
20438
|
+
"PARSE_ERROR",
|
|
20439
|
+
"UNKNOWN"
|
|
20440
|
+
];
|
|
20441
|
+
for (const code of priority) {
|
|
20442
|
+
if (codes.has(code)) return code;
|
|
20443
|
+
}
|
|
20444
|
+
return "UNKNOWN";
|
|
20445
|
+
}
|
|
20446
|
+
function classifyOneProviderError(message) {
|
|
20447
|
+
if (/\b401\b|\b403\b|unauthorized|forbidden|invalid[_ -]?api[_ -]?key|missing[_ -]?api[_ -]?key|authentication/i.test(message)) {
|
|
20448
|
+
return "PROVIDER_AUTH";
|
|
20449
|
+
}
|
|
20450
|
+
if (/\b429\b|rate[_ -]?limit|too many requests|quota[_ -]?exceeded/i.test(message)) {
|
|
20451
|
+
return "RATE_LIMITED";
|
|
20452
|
+
}
|
|
20453
|
+
if (/timeout|timed out|ETIMEDOUT/i.test(message)) {
|
|
20454
|
+
return "TIMEOUT";
|
|
20455
|
+
}
|
|
20456
|
+
if (/ECONNRESET|ECONNREFUSED|ENOTFOUND|EAI_AGAIN|network|fetch failed|socket hang up/i.test(message)) {
|
|
20457
|
+
return "NETWORK";
|
|
20458
|
+
}
|
|
20459
|
+
if (/parse|unexpected token|invalid json|malformed|JSON\.parse/i.test(message)) {
|
|
20460
|
+
return "PARSE_ERROR";
|
|
20461
|
+
}
|
|
20462
|
+
return "UNKNOWN";
|
|
20463
|
+
}
|
|
20369
20464
|
var JobRunner = class {
|
|
20370
20465
|
db;
|
|
20371
20466
|
registry;
|
|
@@ -20508,7 +20603,7 @@ var JobRunner = class {
|
|
|
20508
20603
|
let screenshotRelPath = null;
|
|
20509
20604
|
if (raw.screenshotPath && fs7.existsSync(raw.screenshotPath)) {
|
|
20510
20605
|
const snapshotId = crypto21.randomUUID();
|
|
20511
|
-
const screenshotDir = path9.join(
|
|
20606
|
+
const screenshotDir = path9.join(os5.homedir(), ".canonry", "screenshots", runId);
|
|
20512
20607
|
if (!fs7.existsSync(screenshotDir)) fs7.mkdirSync(screenshotDir, { recursive: true });
|
|
20513
20608
|
const destPath = path9.join(screenshotDir, `${snapshotId}.png`);
|
|
20514
20609
|
fs7.renameSync(raw.screenshotPath, destPath);
|
|
@@ -20597,12 +20692,14 @@ var JobRunner = class {
|
|
|
20597
20692
|
}
|
|
20598
20693
|
this.flushProviderUsage(projectId, providerDispatchCounts);
|
|
20599
20694
|
const finalStatus = allFailed ? "failed" : someFailed ? "partial" : "completed";
|
|
20695
|
+
const failureCode = providerErrors.size > 0 ? classifyProviderErrors(providerErrors) : void 0;
|
|
20600
20696
|
trackEvent("run.completed", {
|
|
20601
20697
|
status: finalStatus,
|
|
20602
20698
|
providerCount: executionContext.providerCount,
|
|
20603
20699
|
providers: executionContext.providers,
|
|
20604
20700
|
queryCount: executionContext.queryCount,
|
|
20605
20701
|
durationMs: Date.now() - startTime,
|
|
20702
|
+
...failureCode ? { errorCode: failureCode } : {},
|
|
20606
20703
|
...executionContext.location ? { location: executionContext.location } : {}
|
|
20607
20704
|
});
|
|
20608
20705
|
this.incrementUsage(projectId, "runs", 1);
|
|
@@ -20630,14 +20727,27 @@ var JobRunner = class {
|
|
|
20630
20727
|
error: errorMessage
|
|
20631
20728
|
}).where(eq24(runs.id, runId)).run();
|
|
20632
20729
|
this.flushProviderUsage(projectId, providerDispatchCounts);
|
|
20633
|
-
|
|
20634
|
-
|
|
20635
|
-
|
|
20636
|
-
|
|
20637
|
-
|
|
20638
|
-
|
|
20639
|
-
|
|
20640
|
-
|
|
20730
|
+
const abortReason = classifyRunAbortReason(errorMessage);
|
|
20731
|
+
if (abortReason) {
|
|
20732
|
+
trackEvent("run.aborted", {
|
|
20733
|
+
reason: abortReason,
|
|
20734
|
+
providerCount: executionContext.providerCount,
|
|
20735
|
+
providers: executionContext.providers,
|
|
20736
|
+
queryCount: executionContext.queryCount,
|
|
20737
|
+
durationMs: Date.now() - startTime,
|
|
20738
|
+
...executionContext.location ? { location: executionContext.location } : {}
|
|
20739
|
+
});
|
|
20740
|
+
} else {
|
|
20741
|
+
trackEvent("run.completed", {
|
|
20742
|
+
status: "failed",
|
|
20743
|
+
errorCode: "UNKNOWN",
|
|
20744
|
+
providerCount: executionContext.providerCount,
|
|
20745
|
+
providers: executionContext.providers,
|
|
20746
|
+
queryCount: executionContext.queryCount,
|
|
20747
|
+
durationMs: Date.now() - startTime,
|
|
20748
|
+
...executionContext.location ? { location: executionContext.location } : {}
|
|
20749
|
+
});
|
|
20750
|
+
}
|
|
20641
20751
|
if (this.onRunCompleted) {
|
|
20642
20752
|
this.onRunCompleted(runId, projectId).catch((notifErr) => {
|
|
20643
20753
|
log.error("notification.callback-failed", { runId, error: notifErr instanceof Error ? notifErr.message : String(notifErr) });
|
|
@@ -24129,7 +24239,7 @@ async function createServer(opts) {
|
|
|
24129
24239
|
);
|
|
24130
24240
|
jobRunner.onRunCompleted = (runId, projectId) => runCoordinator.onRunCompleted(runId, projectId);
|
|
24131
24241
|
const snapshotService = new SnapshotService(registry);
|
|
24132
|
-
const orphanedOpenClawDir = path14.join(
|
|
24242
|
+
const orphanedOpenClawDir = path14.join(os6.homedir(), ".openclaw-aero");
|
|
24133
24243
|
if (fs12.existsSync(orphanedOpenClawDir)) {
|
|
24134
24244
|
app.log.warn(
|
|
24135
24245
|
{ path: orphanedOpenClawDir },
|
package/dist/cli.js
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
setGoogleAuthConfig,
|
|
19
19
|
showFirstRunNotice,
|
|
20
20
|
trackEvent
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-UQHWSCTE.js";
|
|
22
22
|
import {
|
|
23
23
|
CliError,
|
|
24
24
|
EXIT_SYSTEM_ERROR,
|
|
@@ -8368,6 +8368,7 @@ async function initCommand(opts) {
|
|
|
8368
8368
|
skillsTip = 'Run "canonry skills install" in a project directory to add the canonry + Aero playbook to .claude/skills/ and .codex/skills/.';
|
|
8369
8369
|
}
|
|
8370
8370
|
}
|
|
8371
|
+
const nextSteps = buildNextSteps();
|
|
8371
8372
|
if (format === "json") {
|
|
8372
8373
|
console.log(JSON.stringify({
|
|
8373
8374
|
initialized: true,
|
|
@@ -8378,7 +8379,8 @@ async function initCommand(opts) {
|
|
|
8378
8379
|
providers: providerNames,
|
|
8379
8380
|
googleConfigured: !!google,
|
|
8380
8381
|
skills: skillsSummary,
|
|
8381
|
-
skillsTip
|
|
8382
|
+
skillsTip,
|
|
8383
|
+
nextSteps
|
|
8382
8384
|
}, null, 2));
|
|
8383
8385
|
} else {
|
|
8384
8386
|
console.log(`
|
|
@@ -8419,14 +8421,44 @@ ${skillsTip}`);
|
|
|
8419
8421
|
}
|
|
8420
8422
|
if (format !== "json") {
|
|
8421
8423
|
showFirstRunNotice();
|
|
8422
|
-
console.log(
|
|
8424
|
+
console.log("\nNext steps:");
|
|
8425
|
+
for (const line of nextSteps) {
|
|
8426
|
+
console.log(` ${line}`);
|
|
8427
|
+
}
|
|
8423
8428
|
}
|
|
8424
8429
|
trackEvent("cli.init", {
|
|
8425
8430
|
providerCount: providerNames.length,
|
|
8426
|
-
providers: providerNames
|
|
8431
|
+
providers: providerNames,
|
|
8432
|
+
setupState: encodeSetupState({
|
|
8433
|
+
hasProvider: !!hasProvider,
|
|
8434
|
+
hasGoogle: !!google,
|
|
8435
|
+
hasAgent: !!agentLLM
|
|
8436
|
+
}),
|
|
8437
|
+
skillsInstalled: !!skillsSummary
|
|
8427
8438
|
});
|
|
8428
8439
|
return agentLLM;
|
|
8429
8440
|
}
|
|
8441
|
+
function buildNextSteps() {
|
|
8442
|
+
return [
|
|
8443
|
+
"1. Create a project for the domain you want to track:",
|
|
8444
|
+
" canonry project create my-site --domain example.com --country US --language en",
|
|
8445
|
+
"",
|
|
8446
|
+
"2. Add the questions your customers ask AI assistants:",
|
|
8447
|
+
' canonry query add my-site "best <category> for <use case>"',
|
|
8448
|
+
"",
|
|
8449
|
+
"3. Run your first sweep:",
|
|
8450
|
+
" canonry run my-site",
|
|
8451
|
+
"",
|
|
8452
|
+
'Tip: "canonry doctor" verifies your setup. "canonry serve" opens the dashboard.'
|
|
8453
|
+
];
|
|
8454
|
+
}
|
|
8455
|
+
function encodeSetupState(state) {
|
|
8456
|
+
const flags = [];
|
|
8457
|
+
if (state.hasProvider) flags.push("provider");
|
|
8458
|
+
if (state.hasGoogle) flags.push("google");
|
|
8459
|
+
if (state.hasAgent) flags.push("agent");
|
|
8460
|
+
return flags.length > 0 ? flags.sort().join("|") : "none";
|
|
8461
|
+
}
|
|
8430
8462
|
|
|
8431
8463
|
// src/commands/serve.ts
|
|
8432
8464
|
function resolveServePort(envPort, configPort) {
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ainyc/canonry",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.14.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Agent-first open-source AEO operating platform - track how answer engines cite your domain",
|
|
6
6
|
"license": "FSL-1.1-ALv2",
|
|
@@ -59,22 +59,22 @@
|
|
|
59
59
|
"@types/node-cron": "^3.0.11",
|
|
60
60
|
"tsup": "^8.5.1",
|
|
61
61
|
"tsx": "^4.19.0",
|
|
62
|
-
"@ainyc/canonry-contracts": "0.0.0",
|
|
63
62
|
"@ainyc/canonry-api-routes": "0.0.0",
|
|
64
|
-
"@ainyc/canonry-db": "0.0.0",
|
|
65
|
-
"@ainyc/canonry-intelligence": "0.0.0",
|
|
66
63
|
"@ainyc/canonry-config": "0.0.0",
|
|
67
|
-
"@ainyc/canonry-
|
|
64
|
+
"@ainyc/canonry-intelligence": "0.0.0",
|
|
65
|
+
"@ainyc/canonry-contracts": "0.0.0",
|
|
66
|
+
"@ainyc/canonry-db": "0.0.0",
|
|
68
67
|
"@ainyc/canonry-integration-cloud-run": "0.0.0",
|
|
69
|
-
"@ainyc/canonry-integration-
|
|
68
|
+
"@ainyc/canonry-integration-bing": "0.0.0",
|
|
70
69
|
"@ainyc/canonry-integration-commoncrawl": "0.0.0",
|
|
70
|
+
"@ainyc/canonry-integration-google": "0.0.0",
|
|
71
71
|
"@ainyc/canonry-integration-traffic": "0.0.0",
|
|
72
|
+
"@ainyc/canonry-provider-claude": "0.0.0",
|
|
73
|
+
"@ainyc/canonry-provider-cdp": "0.0.0",
|
|
72
74
|
"@ainyc/canonry-integration-wordpress": "0.0.0",
|
|
73
75
|
"@ainyc/canonry-provider-gemini": "0.0.0",
|
|
74
|
-
"@ainyc/canonry-provider-cdp": "0.0.0",
|
|
75
76
|
"@ainyc/canonry-provider-local": "0.0.0",
|
|
76
77
|
"@ainyc/canonry-provider-openai": "0.0.0",
|
|
77
|
-
"@ainyc/canonry-provider-claude": "0.0.0",
|
|
78
78
|
"@ainyc/canonry-provider-perplexity": "0.0.0"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|