@xopcai/xopc 0.0.462 → 0.0.463
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/_locales/en/messages.json +1 -0
- package/dist/browser-ext/_locales/zh_CN/messages.json +1 -0
- package/dist/browser-ext/dist/assets/{auth-CQmxIyWw.js → auth-YPMDpWOW.js} +32 -1
- package/dist/browser-ext/dist/background.js +24 -19
- package/dist/browser-ext/dist/sidepanel.html +1 -1
- package/dist/browser-ext/dist/sidepanel.js +7 -7
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/agent-plugin-dialog-C_rlXuEe.js +1 -0
- package/dist/gateway/static/root/assets/{apps-page-QLOYw2QR.js → apps-page-D1qzENN_.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-DpKnqajR.js → automations-page-HYFnPiNG.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-BXT_EDON.js → automations-workspace-JCQ1IXFk.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-page-CnU0htlO.js → capabilities-page-kPv2dOzf.js} +2 -2
- package/dist/gateway/static/root/assets/{chat-page-U2a7d6wP.js → chat-page-CalELOKj.js} +6 -6
- package/dist/gateway/static/root/assets/{connectors-page-Bs29RvXz.js → connectors-page-B9mpz_Rt.js} +1 -1
- package/dist/gateway/static/root/assets/{index-CEBDMkde.js → index-DUo6H0PC.js} +4 -4
- package/dist/gateway/static/root/assets/mcp-conversation-setup-page-DCIEL5bA.js +1 -0
- package/dist/gateway/static/root/assets/{note-detail-panel-D_l5jkV9.js → note-detail-panel-DsXb1qjW.js} +2 -2
- package/dist/gateway/static/root/assets/{notes-page-R4uJroeD.js → notes-page-BTpiOw67.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-BsONyPfQ.js → personal-page-I3IGVSJh.js} +1 -1
- package/dist/gateway/static/root/assets/{plugin-details-dialog-nSDw8sfo.js → plugin-details-dialog-F08k_k2u.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-xNSy6SAv.js → project-detail-page-Dy46uSEt.js} +1 -1
- package/dist/gateway/static/root/assets/{route-preload-Dwb_N8L-.js → route-preload-ChTaYgpA.js} +2 -2
- package/dist/gateway/static/root/assets/{service-recommendation-list-DDlMyPvC.js → service-recommendation-list-BmRtbJz2.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-8MiJzbbl.js → settings-page-C39lKVRv.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-DxKXoBbE.js → task-detail-page-D1dNWTnP.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-UvWbDUXi.js → work-discovery-overlay-BJ15p4rH.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-BM1HsYz6.js → work-discovery-page-8XciWNs5.js} +1 -1
- package/dist/gateway/static/root/index.html +6 -6
- package/dist/package.js +1 -1
- package/dist/src/agent/embedded/session-runner.js +2 -2
- package/dist/src/agent/external-tools/gateway-tools.js +8 -1
- package/dist/src/agent/mcp/connection-setup.js +46 -42
- package/dist/src/agent/mcp/conversation-setup.js +13 -8
- package/dist/src/agent/mcp/discovery.d.ts +22 -1
- package/dist/src/agent/mcp/discovery.js +19 -3
- package/dist/src/agent/mcp/managed-discovery.d.ts +8 -0
- package/dist/src/agent/mcp/managed-discovery.js +77 -0
- package/dist/src/agent/mcp/tool-catalog.js +1 -1
- package/dist/src/agent/prompt/conversational-configuration-guide.js +1 -1
- package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.d.ts +6 -2
- package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +10 -7
- package/dist/src/agent/tool-manuals/xopc-configuration.d.ts +1 -1
- package/dist/src/agent/tool-manuals/xopc-configuration.js +12 -4
- package/dist/src/cli/commands/extension-agent-plugin.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +2 -2
- package/dist/src/cli/commands/update.js +1 -1
- package/dist/src/connectors/connection-recovery-service.js +38 -5
- package/dist/src/connectors/excluded-connectors.d.ts +1 -0
- package/dist/src/connectors/excluded-connectors.js +5 -1
- package/dist/src/connectors/plugin-connection.d.ts +10 -0
- package/dist/src/connectors/plugin-connection.js +105 -0
- package/dist/src/extensions/agent-plugins/setup.js +1 -1
- package/dist/src/extensions/agent-plugins/skill-catalog.js +1 -1
- package/dist/src/gateway/hono/middleware/auth.js +1 -1
- package/dist/src/gateway/hono/routes/agent-plugins.js +2 -2
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/connectors.js +1 -1
- package/dist/src/gateway/hono/routes/desktop-host.js +1 -1
- package/dist/src/gateway/hono/routes/home.js +1 -1
- package/dist/src/gateway/hono/routes/imports.js +1 -1
- package/dist/src/gateway/hono/routes/personal-agent.js +3 -3
- package/dist/src/gateway/hono/routes/update.js +2 -2
- package/dist/src/gateway/index.js +1 -1
- package/dist/src/gateway/run-loop.js +2 -2
- package/dist/src/gateway/security/gateway-scopes.js +1 -0
- package/dist/src/gateway/service/agent-runner.js +1 -1
- package/dist/src/gateway/service/run-gateway-agent.js +1 -1
- package/dist/src/gateway/service.js +11 -11
- package/dist/src/home-intelligence/host.js +5 -5
- package/dist/src/infra/gateway-processes.js +1 -1
- package/dist/src/infra/update-restart.js +2 -2
- package/dist/src/infra/update-runner.js +2 -2
- package/dist/src/infra/update-startup.js +1 -1
- package/dist/src/notifications/service.js +2 -2
- package/dist/src/phone/stream-gateway.js +1 -1
- package/dist/src/tui/tui-management.js +2 -2
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agent-plugin-dialog-CikzCYAG.js +0 -1
- package/dist/gateway/static/root/assets/mcp-conversation-setup-page-CsTSmjmX.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{m as a,u as o}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{n as s}from"./locale-store-Dy1EByeG.js";import{t as c}from"./messages-BAnhwALN.js";import{t as l}from"./createLucideIcon-DPHK1VkS.js";import{t as u}from"./service-recommendation-list-DDlMyPvC.js";import{t as d}from"./calendar-days-hw_Y-g-s.js";import{t as f}from"./check-DUBLcKHA.js";import{t as p}from"./chevron-down-ccbiQQz_.js";import{t as m}from"./chevron-right-BweFrslA.js";import{i as h,t as g}from"./working-directory-picker-modal-BGZduAXV.js";import{t as _}from"./circle-check-C23XjkUj.js";import{t as ee}from"./clock-3-DnrAnuyZ.js";import{t as v}from"./database-CjjeZfRG.js";import{a as te,c as ne,d as re,f as y,i as b,l as x,m as S,n as C,o as w,p as T,r as E,s as D,t as O,u as k}from"./understanding-activity-store-BFc8PamJ.js";import{t as A}from"./file-text-D12HbeVy.js";import{t as j}from"./folder-open-CyzJ19I9.js";import{t as M}from"./git-branch-Dh9uxTot.js";import{t as N}from"./list-todo-CTVRto8O.js";import{t as P}from"./loader-circle-CifKLtgG.js";import{t as F}from"./messages-square-BckAJrEW.js";import{n as I,s as L,t as R}from"./install-connector-dialog-DxSv1wS2.js";import{t as z}from"./plug-zap-L8NMe3Sv.js";import{t as B}from"./plus-Q2yW6OE7.js";import{t as V}from"./shield-check-BU58siTV.js";import{t as ie}from"./sparkles-DHlfQFAF.js";import{t as ae}from"./x-B_N4OPjy.js";import{t as H}from"./cn-0WouolD0.js";import{t as oe}from"./skeleton-DzdOeGYz.js";import{t as U}from"./button-Cc4hUNTt.js";import{a as se,r as ce}from"./connectors-api-CTuVWwBf.js";import{t as le}from"./loopi-CNtmi9FU.js";import{t as ue}from"./use-directory-picker-C4p7AgWY.js";var W=l(`book-open-text`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M16 12h2`,key:`7q9ll5`}],[`path`,{d:`M16 8h2`,key:`msurwy`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}],[`path`,{d:`M6 12h2`,key:`32wvfc`}],[`path`,{d:`M6 8h2`,key:`30oboj`}]]),G=e(n(),1),K=new Set([`completed`,`failed`,`canceled`]);function de(){return new Promise(e=>window.setTimeout(e,1200))}async function fe(e,t){let n=[],r=t.wait??de;for(let i=0;i<e.length&&!t.shouldStop?.();i+=1){let a=e[i];if(a)try{await t.grantDirectory(a.rootPath);let o=await t.startRun(a.rootPath);for(t.onRun(o,i,e.length);!K.has(o.status)&&!t.shouldStop?.();)await r(),o=await t.fetchRun(o.id),t.onRun(o,i,e.length);if(n.push(o),o.status===`canceled`||t.shouldStop?.())break}catch(e){if(t.onError?.(e,a,i),t.shouldStop?.())break}}return n}var pe=r();function q(e,t){let n=e.result?.conversationStarter?.trim();if(n)return n;let r=e.result?.suggestions.find(t=>t.id===e.result?.primarySuggestionId)??e.result?.suggestions[0];if(r?.actionPrompt.trim())return r.actionPrompt.trim();let i=e.rootPath.split(/[\\/]/).filter(Boolean).at(-1)??e.rootPath;return t===`zh`?`请先结合 ${i} 当前目录和最近变更,帮我说明这个项目在做什么、现在最值得关注什么,以及建议我下一步从哪里开始。`:`Help me understand ${i}: explain what this project is doing, what matters most right now, and where I should start next.`}var J=i(),me={zh:{eyebrow:`当前理解`,summaryTitle:`我理解的是这样`,summaryQuestion:`可以继续,也可以随时修改。`,matches:`准确,继续`,adjust:`修改`,why:`查看依据`,evidenceHint:`这些内容只用于本次判断。`,current:`当前`,ongoing:`持续`,longTerm:`长期`,correctionTitle:`告诉我正确的重点`,correctionPlaceholder:`你现在真正想推进什么?`,continueWithCorrection:`按此继续`,starterTitle:`从这里开始`,starterHint:`可以修改后直接开始对话。`,startConversation:`进入对话`,cancel:`取消`},en:{eyebrow:`Current understanding`,summaryTitle:`Here’s how I understand it`,summaryQuestion:`Continue, or adjust this anytime.`,matches:`Accurate, continue`,adjust:`Edit`,why:`View sources`,evidenceHint:`These sources are only used for this assessment.`,current:`Current`,ongoing:`Ongoing`,longTerm:`Long term`,correctionTitle:`Tell me the right focus`,correctionPlaceholder:`What do you want to move forward right now?`,continueWithCorrection:`Continue`,starterTitle:`Start here`,starterHint:`Edit this if needed, then start the conversation.`,startConversation:`Start conversation`,cancel:`Cancel`}};function he(e){let t=(0,pe.c)(84),{run:n,language:r,busy:i,error:a,onFinish:o,onStartConversation:s}=e,c=me[r],l=n.result?.lowConfidence===!0,u;t[0]!==r||t[1]!==n?(u=q(n,r),t[0]=r,t[1]=n,t[2]=u):u=t[2];let d=u,[f,m]=(0,G.useState)(l),[h,g]=(0,G.useState)(l?d:``),[_,ee]=(0,G.useState)(!1),[v,te]=(0,G.useState)(!1),[ne,re]=(0,G.useState)(!1),y,b,x,S,C,w,T,E,D,O,k,A;if(t[3]!==i||t[4]!==v||t[5]!==h||t[6]!==f||t[7]!==a||t[8]!==ne||t[9]!==o||t[10]!==s||t[11]!==n.result||t[12]!==c.current||t[13]!==c.evidenceHint||t[14]!==c.eyebrow||t[15]!==c.longTerm||t[16]!==c.ongoing||t[17]!==c.summaryTitle||t[18]!==c.why){let e=n.result?.workThreads?.slice(0,3)??[],r=n.result?.suggestions.find(e=>e.id===n.result?.primarySuggestionId)??n.result?.suggestions[0],l;t[31]!==h||t[32]!==o?(l=async e=>{ee(!0),await o(e,e===`corrected`?h.trim():void 0)||ee(!1)},t[31]=h,t[32]=o,t[33]=l):l=t[33],y=l;let u;t[34]!==h||t[35]!==s?(u=async()=>{let e=h.trim();e&&(te(!0),await s(e,`corrected`)||te(!1))},t[34]=h,t[35]=s,t[36]=u):u=t[36],b=u,x=`xopc-understanding-reveal flex min-h-full flex-1 flex-col`,S=`polite`,D=`xopc-reveal-scene mx-auto flex w-full max-w-[40rem] flex-1 flex-col justify-center py-6 text-center sm:py-10`;let d=a?`care`:i||v?`work`:f?`listen`:`decision`;t[37]===d?O=t[38]:(O=(0,J.jsx)(le,{className:`mx-auto mb-3 size-28`,mood:d}),t[37]=d,t[38]=O),t[39]===c.eyebrow?k=t[40]:(k=(0,J.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-accent-fg`,children:c.eyebrow}),t[39]=c.eyebrow,t[40]=k),t[41]===c.summaryTitle?A=t[42]:(A=(0,J.jsx)(`h1`,{className:`mx-auto mt-4 max-w-[34rem] text-3xl font-semibold tracking-[-0.035em] text-fg sm:text-[2.25rem]`,children:c.summaryTitle}),t[41]=c.summaryTitle,t[42]=A),C=`xopc-understanding-hero-card relative mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel px-6 py-7 text-left shadow-surface sm:px-8`,t[43]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,J.jsx)(`div`,{className:`mb-5 flex size-9 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,"aria-hidden":!0,children:(0,J.jsx)(ie,{className:`size-[1.125rem]`})}),t[43]=w):w=t[43];let m=n.result?.projectSummary;t[44]===m?T=t[45]:(T=(0,J.jsx)(`p`,{className:`relative text-lg font-medium leading-8 text-fg sm:text-xl`,children:m}),t[44]=m,t[45]=T),E=n.result?.currentState||e.length||r?.evidence.length?(0,J.jsxs)(`div`,{className:`relative mt-5 border-t border-edge-subtle pt-4`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 text-xs font-medium text-fg-muted hover:text-fg`,onClick:()=>re(_e),children:[c.why,(0,J.jsx)(p,{className:H(`size-3.5 transition-transform`,ne&&`rotate-180`)})]}),ne?(0,J.jsxs)(`div`,{className:`mt-3 space-y-3 text-xs leading-5 text-fg-muted`,children:[(0,J.jsx)(`p`,{className:`text-fg-subtle`,children:c.evidenceHint}),n.result?.currentState?(0,J.jsx)(`p`,{children:n.result.currentState}):null,e.length?(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,J.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg`,children:e.title}),` · `,e.horizon===`current`?c.current:e.horizon===`ongoing`?c.ongoing:c.longTerm]},e.id))}):null,r?.evidence.slice(0,3).map(ge)]}):null]}):null,t[3]=i,t[4]=v,t[5]=h,t[6]=f,t[7]=a,t[8]=ne,t[9]=o,t[10]=s,t[11]=n.result,t[12]=c.current,t[13]=c.evidenceHint,t[14]=c.eyebrow,t[15]=c.longTerm,t[16]=c.ongoing,t[17]=c.summaryTitle,t[18]=c.why,t[19]=y,t[20]=b,t[21]=x,t[22]=S,t[23]=C,t[24]=w,t[25]=T,t[26]=E,t[27]=D,t[28]=O,t[29]=k,t[30]=A}else y=t[19],b=t[20],x=t[21],S=t[22],C=t[23],w=t[24],T=t[25],E=t[26],D=t[27],O=t[28],k=t[29],A=t[30];let j;t[46]!==C||t[47]!==w||t[48]!==T||t[49]!==E?(j=(0,J.jsxs)(`div`,{className:C,children:[w,T,E]}),t[46]=C,t[47]=w,t[48]=T,t[49]=E,t[50]=j):j=t[50];let M;t[51]!==y||t[52]!==i||t[53]!==v||t[54]!==h||t[55]!==f||t[56]!==l||t[57]!==b||t[58]!==_||t[59]!==c.adjust||t[60]!==c.cancel||t[61]!==c.continueWithCorrection||t[62]!==c.correctionPlaceholder||t[63]!==c.correctionTitle||t[64]!==c.matches||t[65]!==c.startConversation||t[66]!==c.starterHint||t[67]!==c.starterTitle||t[68]!==c.summaryQuestion?(M=f?(0,J.jsxs)(`div`,{className:`xopc-reveal-calibration mx-auto mt-7 w-full max-w-xl rounded-xl border border-edge bg-surface-panel p-5 text-left shadow-surface`,children:[(0,J.jsx)(`label`,{className:`text-sm font-semibold text-fg`,htmlFor:`understanding-correction`,children:l?c.starterTitle:c.correctionTitle}),l?(0,J.jsx)(`p`,{className:`mt-1.5 text-xs leading-5 text-fg-muted`,children:c.starterHint}):null,(0,J.jsx)(`textarea`,{id:`understanding-correction`,value:h,onChange:e=>g(e.target.value),placeholder:c.correctionPlaceholder,className:`mt-3 min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm leading-6 text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,J.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[l?null:(0,J.jsx)(U,{variant:`ghost`,disabled:_,onClick:()=>m(!1),children:c.cancel}),(0,J.jsx)(U,{variant:`primary`,disabled:i||v||!h.trim(),onClick:()=>void b(),children:l?c.startConversation:c.continueWithCorrection})]})]}):(0,J.jsxs)(`div`,{className:`mx-auto mt-8 w-full max-w-sm`,children:[(0,J.jsx)(`p`,{className:`text-base font-medium text-fg`,children:c.summaryQuestion}),(0,J.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,J.jsx)(U,{className:`h-11 flex-1`,variant:`primary`,disabled:_,onClick:()=>void y(`confirmed`),children:c.matches}),(0,J.jsx)(U,{className:`h-11 flex-1`,variant:`secondary`,disabled:_,onClick:()=>m(!0),children:c.adjust})]})]}),t[51]=y,t[52]=i,t[53]=v,t[54]=h,t[55]=f,t[56]=l,t[57]=b,t[58]=_,t[59]=c.adjust,t[60]=c.cancel,t[61]=c.continueWithCorrection,t[62]=c.correctionPlaceholder,t[63]=c.correctionTitle,t[64]=c.matches,t[65]=c.startConversation,t[66]=c.starterHint,t[67]=c.starterTitle,t[68]=c.summaryQuestion,t[69]=M):M=t[69];let N;t[70]===a?N=t[71]:(N=a?(0,J.jsx)(`p`,{className:`mt-5 text-sm text-danger`,role:`alert`,children:a}):null,t[70]=a,t[71]=N);let P;t[72]!==j||t[73]!==M||t[74]!==N||t[75]!==D||t[76]!==O||t[77]!==k||t[78]!==A?(P=(0,J.jsxs)(`div`,{className:D,children:[O,k,A,j,M,N]}),t[72]=j,t[73]=M,t[74]=N,t[75]=D,t[76]=O,t[77]=k,t[78]=A,t[79]=P):P=t[79];let F;return t[80]!==x||t[81]!==S||t[82]!==P?(F=(0,J.jsx)(`section`,{className:x,"aria-live":S,children:P}),t[80]=x,t[81]=S,t[82]=P,t[83]=F):F=t[83],F}function ge(e,t){return(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(M,{className:`mt-0.5 size-3.5 shrink-0 text-accent-fg`}),(0,J.jsxs)(`span`,{children:[e.path?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`code`,{className:`font-mono text-fg`,children:e.path}),`: `]}):null,e.observation]})]},`${t}-${e.path??e.observation}`)}function _e(e){return!e}var ve={folder:j,file:A,recent:S,git:M,calendar:d,task:N,note:W,mail:T,message:F,service:z,data:v};function ye(e){let t=(0,pe.c)(28),{signals:n,ariaLabel:r,centerLabel:i}=e,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==i||t[2]!==n){let e=n.slice(0,3);a=Math.max(0,n.length-e.length),c=`xopc-source-convergence mx-auto mt-9 w-full max-w-[34rem] overflow-hidden rounded-xl border border-edge bg-surface-panel px-5 py-6 shadow-surface sm:px-6`,l=`img`,u=r;let p;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,J.jsx)(le,{className:`size-24`,mood:`work`}),t[11]=p):p=t[11],t[12]===i?d=t[13]:(d=(0,J.jsxs)(`div`,{className:`flex flex-col items-center text-center`,"aria-hidden":!0,children:[p,(0,J.jsx)(`span`,{className:`mt-3 text-[11px] font-semibold tracking-[0.16em] text-fg-muted`,children:i})]}),t[12]=i,t[13]=d),t[14]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,J.jsx)(`div`,{className:`mt-5 h-1 overflow-hidden rounded-full bg-surface-hover`,"aria-hidden":!0,children:(0,J.jsx)(`span`,{className:`xopc-source-convergence-progress block h-full w-2/5 rounded-full bg-accent`})}),t[14]=f):f=t[14],o=`mt-5 divide-y divide-edge-subtle border-y border-edge-subtle`,s=e.map(be),t[0]=r,t[1]=i,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];let p;t[15]!==o||t[16]!==s?(p=(0,J.jsx)(`div`,{className:o,children:s}),t[15]=o,t[16]=s,t[17]=p):p=t[17];let m;t[18]===a?m=t[19]:(m=a>0?(0,J.jsxs)(`p`,{className:`mt-3 text-center text-xs text-fg-muted`,"aria-hidden":!0,children:[`+`,a]}):null,t[18]=a,t[19]=m);let h;return t[20]!==c||t[21]!==l||t[22]!==u||t[23]!==d||t[24]!==f||t[25]!==p||t[26]!==m?(h=(0,J.jsxs)(`div`,{className:c,role:l,"aria-label":u,children:[d,f,p,m]}),t[20]=c,t[21]=l,t[22]=u,t[23]=d,t[24]=f,t[25]=p,t[26]=m,t[27]=h):h=t[27],h}function be(e){let t=ve[e.kind];return(0,J.jsxs)(`div`,{className:`flex min-h-12 items-center gap-3 py-2.5 text-left`,"aria-hidden":!0,children:[(0,J.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,J.jsx)(t,{className:`size-4`})}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,title:e.detail,children:[(0,J.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.label}),e.meta?(0,J.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:e.meta}):null]}),(0,J.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-accent`})]},e.id)}var xe=[`gmail`,`googlecalendar`,`googledrive`,`github`,`linear`];function Y({toolkit:e,displayName:t,description:n,category:r,mode:i,bootstrapWindowDays:a,logoFileName:o=e}){return{id:`composio-${e}`,version:`sessions-v1`,displayName:t,description:n,category:r,kind:`composio`,source:`registry`,capabilities:[`tools`,`auth.oauth`,`events`,`context`,`memory_source`],benefits:[`understand`,`act`],understanding:{mode:i,bootstrapWindowDays:a,readOnly:!0},tags:[`composio`,e,`verified`],branding:{logoUrl:`/connector-icons/${o}.svg`,source:`builtin`},verificationLevel:`verified`,auth:{mode:`oauth`,provider:`composio`},setup:{},runtime:{type:`composio`,toolkit:e,role:`toolkit`},integrationStrategy:{lane:`composio`,workload:`long_tail`,preferred:!0}}}var Se=[Y({toolkit:`gmail`,displayName:`Gmail`,description:`Find and understand recent email, then draft or send with your approval.`,category:`automation`,mode:`activity`,bootstrapWindowDays:30}),Y({toolkit:`googlecalendar`,displayName:`Google Calendar`,description:`Understand your schedule and work with approved calendar events.`,category:`automation`,mode:`activity`,bootstrapWindowDays:90,logoFileName:`google-calendar`}),Y({toolkit:`googledrive`,displayName:`Google Drive`,description:`Search and understand approved files in Google Drive.`,category:`data`,mode:`inventory`,bootstrapWindowDays:90,logoFileName:`google-drive`}),Y({toolkit:`github`,displayName:`GitHub`,description:`Understand repositories, issues, pull requests, and reviews.`,category:`code`,mode:`activity`,bootstrapWindowDays:90}),Y({toolkit:`linear`,displayName:`Linear`,description:`Understand and work with Linear issues and projects.`,category:`code`,mode:`activity`,bootstrapWindowDays:60})];function Ce(e){return e.runtime.type===`composio`&&e.runtime.role===`toolkit`?e.runtime.toolkit.toLocaleLowerCase():``}function we(e){let t=new Map(xe.map((e,t)=>[e,t]));return e.filter(e=>e.understanding!=null&&Ce(e)).sort((e,n)=>(t.get(Ce(e))??2**53-1)-(t.get(Ce(n))??2**53-1)||e.displayName.localeCompare(n.displayName))}function Te(e,t){let n=new Map(e.map(e=>[e.id,e]));for(let e of t)n.set(e.id,e);return we([...n.values()])}var Ee=2500;function De(e){return!!(e?.enabled&&(e.status===`connected`||e.connectionStatus===`connected`||e.authStatus===`connected`))}function Oe(e){return e===`gmail`?`mail`:e===`googlecalendar`?`calendar`:e===`googledrive`?`data`:e===`github`?`git`:e===`linear`?`task`:`service`}function ke(e){let t=(0,pe.c)(59),{busy:n,onBack:r,onContinue:i,onSkip:a,onConnectedSignalsChange:o}=e,l=s(Pe),d=c(l),f=d.onboarding.workDiscovery,m=d.connectorsSettings,[g,ee]=(0,G.useState)(Ne),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],t[0]=v):v=t[0];let[te,ne]=(0,G.useState)(v),[re,y]=(0,G.useState)(!0),[b,x]=(0,G.useState)(null),[S,C]=(0,G.useState)(!1),[w,T]=(0,G.useState)(null),E;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(E=async()=>{let e=await se();return ne(e),e},t[1]=E):E=t[1];let D=E,O,k;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>{let e=!1,t=window.setTimeout(()=>{e||y(!1)},Ee);return se().then(t=>{e||ne(t)}).catch(t=>{e||x(t instanceof Error?t.message:String(t))}).finally(()=>{e||y(!1),window.clearTimeout(t)}),ce({page:1,pageSize:24,verification:`verified`}).then(t=>{e||ee(Te(Se,t.connectors))}).catch(Me),()=>{e=!0,window.clearTimeout(t)}},k=[],t[2]=O,t[3]=k):(O=t[2],k=t[3]),(0,G.useEffect)(O,k);let A;t[4]===te?A=t[5]:(A=new Map(te.map(je)),t[4]=te,t[5]=A);let j=A,M;if(t[6]!==g||t[7]!==j){let e;t[9]===j?e=t[10]:(e=e=>{if(!De(j.get(e.id)))return[];let t=Ce(e);return[{id:e.id,label:e.displayName,kind:Oe(t)}]},t[9]=j,t[10]=e),M=g.flatMap(e),t[6]=g,t[7]=j,t[8]=M}else M=t[8];let N=M,F,z;t[11]!==N||t[12]!==o?(F=()=>{o(N)},z=[N,o],t[11]=N,t[12]=o,t[13]=F,t[14]=z):(F=t[13],z=t[14]),(0,G.useEffect)(F,z);let V;t[15]!==g||t[16]!==S?(V=S?g:g.slice(0,3),t[15]=g,t[16]=S,t[17]=V):V=t[17];let ie=V,ae=N.length,H;t[18]!==g.length||t[19]!==m||t[20]!==f.connected||t[21]!==f.noWorkServices||t[22]!==f.showFewerServices||t[23]!==f.showMoreServices||t[24]!==S||t[25]!==j||t[26]!==re||t[27]!==l||t[28]!==D||t[29]!==C||t[30]!==T||t[31]!==ie?(H=l===`zh`?(0,J.jsx)(u,{onChanged:async()=>{await D()}}):(0,J.jsxs)(J.Fragment,{children:[ie.length?(0,J.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge-subtle bg-surface-base/55`,children:ie.map(e=>{let t=De(j.get(e.id));return(0,J.jsxs)(`article`,{className:`flex min-h-[4.75rem] items-center gap-3 px-3 py-3 sm:px-4`,children:[(0,J.jsx)(I,{connector:e,size:`sm`}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.displayName}),(0,J.jsx)(`p`,{className:`mt-1 line-clamp-1 text-xs text-fg-muted`,children:e.description})]}),t?(0,J.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-xs font-medium text-success`,children:[(0,J.jsx)(_,{className:`size-4`}),f.connected]}):re?(0,J.jsx)(oe,{className:`h-8 w-[4.5rem] shrink-0 rounded-lg`,"aria-label":m.loading}):(0,J.jsxs)(U,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 px-3 text-xs`,onClick:()=>T(L(e)),children:[(0,J.jsx)(B,{className:`size-3.5`}),m.connect]})]},e.id)})}):(0,J.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge px-4 py-8 text-center text-sm text-fg-muted`,children:f.noWorkServices}),g.length>3?(0,J.jsxs)(`button`,{type:`button`,className:`mx-auto mt-3 flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-accent-fg hover:underline`,onClick:()=>C(Ae),children:[S?(0,J.jsx)(h,{className:`size-3.5`}):(0,J.jsx)(p,{className:`size-3.5`}),S?f.showFewerServices:f.showMoreServices]}):null]}),t[18]=g.length,t[19]=m,t[20]=f.connected,t[21]=f.noWorkServices,t[22]=f.showFewerServices,t[23]=f.showMoreServices,t[24]=S,t[25]=j,t[26]=re,t[27]=l,t[28]=D,t[29]=C,t[30]=T,t[31]=ie,t[32]=H):H=t[32];let le;t[33]!==f.connectorLoadFailed||t[34]!==b?(le=b?(0,J.jsxs)(`p`,{className:`mt-3 text-center text-xs text-danger`,role:`alert`,children:[f.connectorLoadFailed,`: `,b]}):null,t[33]=f.connectorLoadFailed,t[34]=b,t[35]=le):le=t[35];let ue;t[36]===n?ue=t[37]:(ue=n?(0,J.jsx)(P,{className:`size-4 animate-spin`}):null,t[36]=n,t[37]=ue);let W;t[38]!==n||t[39]!==f.startUnderstanding||t[40]!==i||t[41]!==ue?(W=(0,J.jsxs)(U,{type:`button`,variant:`primary`,className:`h-11 flex-1`,disabled:n,onClick:i,children:[ue,f.startUnderstanding]}),t[38]=n,t[39]=f.startUnderstanding,t[40]=i,t[41]=ue,t[42]=W):W=t[42];let K;t[43]!==n||t[44]!==f.back||t[45]!==r?(K=(0,J.jsx)(U,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:n,onClick:r,children:f.back}),t[43]=n,t[44]=f.back,t[45]=r,t[46]=K):K=t[46];let de;t[47]!==W||t[48]!==K?(de=(0,J.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[W,K]}),t[47]=W,t[48]=K,t[49]=de):de=t[49];let fe;t[50]!==n||t[51]!==f.skipAndEnter||t[52]!==a?(fe=(0,J.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,disabled:n,onClick:a,children:f.skipAndEnter}),t[50]=n,t[51]=f.skipAndEnter,t[52]=a,t[53]=fe):fe=t[53];let q;return t[54]!==m||t[55]!==w||t[56]!==D||t[57]!==T?(q=w?(0,J.jsx)(R,{draft:w,onChange:T,onClose:()=>T(null),t:m,onInstalled:async()=>{await D(),T(null)}}):null,t[54]=m,t[55]=w,t[56]=D,t[57]=T,t[58]=q):q=t[58],(0,J.jsxs)(`section`,{className:`mx-auto flex w-full max-w-[42rem] flex-1 flex-col`,"aria-labelledby":`work-discovery-connectors-title`,children:[(0,J.jsxs)(`div`,{className:`text-center`,children:[(0,J.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:f.connectorStepEyebrow}),(0,J.jsx)(`h1`,{id:`work-discovery-connectors-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:f.connectorStepTitle}),(0,J.jsx)(`p`,{className:`mx-auto mt-3 max-w-[36rem] text-[0.95rem] leading-7 text-fg-muted`,children:f.connectorStepSubtitle})]}),(0,J.jsxs)(`div`,{className:`mt-7 rounded-xl border border-edge bg-surface-panel p-3 shadow-surface sm:p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-1 pb-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:f.popularWorkServices}),(0,J.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:f.connectorsOptional})]}),ae?(0,J.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 rounded-full bg-success-soft px-2.5 py-1 text-xs font-medium text-success`,children:[(0,J.jsx)(_,{className:`size-3.5`}),f.connectedCount.replace(`{{count}}`,String(ae))]}):null]}),H,le]}),de,fe,q]})}function Ae(e){return!e}function je(e){return[e.connectorId,e]}function Me(){}function Ne(){return we(Se)}function Pe(e){return e.language}var Fe=new Set([`local-recent-files`,`chromium-bookmarks`,`apple-notes`,`apple-mail`,`apple-calendar`,`apple-reminders`]);function Ie(e){return new Set(e.filter(e=>e.availability===`available`&&Fe.has(e.id)).map(e=>e.id))}var Le=t({WorkDiscoveryPage:()=>Ve}),Re=[`folder_structure`,`recent_progress`,`next_steps`];function X(e){return e instanceof Error?e.message:String(e)}function ze(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).slice(-2).join(`/`)||e}function Be(e,t){return e.replace(`{{count}}`,String(t))}function Ve({embedded:e=!1,onRequestClose:t,onNavigateAway:n}={}){let r=s(e=>e.language),i=c(r).onboarding.workDiscovery,l=c(r).chat.workingDirectory,u=o(),[d]=a(),h=d.get(`new`)===`1`,[_,v]=(0,G.useState)(`loading`),[S,T]=(0,G.useState)(null),[M,N]=(0,G.useState)(null),[F,I]=(0,G.useState)(null),[L,R]=(0,G.useState)(!1),[z,B]=(0,G.useState)(null),[ie,se]=(0,G.useState)(!1),[ce,W]=(0,G.useState)([]),[K,de]=(0,G.useState)(()=>new Set),[pe,q]=(0,G.useState)([]),[me,ge]=(0,G.useState)(!1),[_e,ve]=(0,G.useState)({current:0,total:0}),[be,xe]=(0,G.useState)([]),[Y,Se]=(0,G.useState)(()=>new Set),[Ce,we]=(0,G.useState)([]),Te=(0,G.useRef)(!1),Ee={recent_documents:`recent`,calendar:`calendar`,tasks:`task`,notes:`note`,mail:`mail`,messages:`message`,code_activity:`git`,files:`file`},De=F?.snapshot?.projectKind??S?.projectKind,Oe=De===`coding`?i.codingProject:De===`general`?i.generalProject:De===`unknown`?i.unknownProject:null,Ae=(F?.snapshot?.files??[]).slice(0,4).map(e=>({id:`snapshot-file:${e.relativePath}`,label:ze(e.relativePath),kind:e.source===`git_change`?`recent`:`file`,meta:e.source===`git_change`?i.sourceSignals.changedFile:e.source===`document`?i.sourceSignals.contextFile:i.sourceSignals.structureFile,detail:e.relativePath})),je=F?.rootPath??S?.canonicalRootPath,Me=Ae.length===0?(S?.fingerprint.recentAreas??[]).slice(0,2).map(e=>({id:`recent-area:${e}`,label:e,kind:`recent`,meta:i.sourceSignals.recentArea,detail:e})):[],Ne=Ae.length===0?Me.length>0?Me:[{id:`project-files`,label:i.sourceSignals.projectFiles,kind:`file`,meta:i.sourceSignals.scanningFiles},{id:`recent-changes`,label:i.sourceSignals.recentChanges,kind:`recent`,meta:i.sourceSignals.checkingChanges}]:[],Pe=F?.snapshot?.sampledPathCount,Fe=[Oe,Pe==null?null:Be(i.sourceSignals.filesScanned,Pe)].filter(e=>!!e).join(` · `),Le=F?.snapshot?.branch??S?.fingerprint.branch,Ve=F?.snapshot?.changedPathCount??S?.fingerprint.changedFileCount,He=[{id:`work-folder`,label:je?ze(je):i.sourceSignals.workFolder,kind:`folder`,...Fe?{meta:Fe}:{},...je?{detail:je}:{}},...Ae,...Ne,{id:`git-state`,label:Le??i.sourceSignals.gitState,kind:`git`,...Ve==null?{}:{meta:Be(i.sourceSignals.changedFiles,Ve)},...Le?{detail:`Git · ${Le}`}:{}},...be.filter(e=>Y.has(e.id)).map(e=>({id:e.id,label:e.displayName,kind:Ee[e.category]??`data`})),...Ce],Ue=e=>{Se(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};(0,G.useEffect)(()=>{let e=!1;return window.electronAPI?.understandingSources?.catalog().then(t=>{e||(xe(t),Se(Ie(t)))}),()=>{e=!0}},[]);let Z=(0,G.useCallback)(e=>{O.getState().updateDirectoryRun(e),I(e),e.status===`completed`?v(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?v(`error`):v(`running`)},[]),We=async()=>{R(!0),B(null);try{let e=await E();if(N(e.processingTarget),!e.candidates.length){B(i.noCandidates);return}W(e.candidates),de(new Set([e.candidates[0].rootPath])),v(`candidates`)}catch(e){B(X(e))}finally{R(!1)}},Ge=e=>{de(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ke=(0,G.useCallback)((e,t,n)=>{O.getState().updateDirectoryRun(e),I(e),ve({current:t+1,total:n}),q(n=>{let r=[...n];return r[t]=e,r}),v(`running`)},[]),qe=(0,G.useCallback)(e=>{q(t=>t.map(t=>t?.id===e.id?e:t))},[]),Je=async()=>{let e=ce.filter(e=>K.has(e.rootPath));if(!e.length)return;R(!0),B(null),q([]),ve({current:1,total:e.length}),ge(!0),Te.current=!1;let t=!1,n=M?.remoteModel?`remote_allowed`:`local_only`;try{let r=await fe(e,{grantDirectory:e=>D(e,n),startRun:re,fetchRun:w,shouldStop:()=>Te.current,onRun:(e,r,i)=>{Ke(e,r,i),t||(t=!0,O.getState().collectSources(e.id,[...Y],n))},onError:(t,n,r)=>{ve({current:r+1,total:e.length}),B(i.folderAnalysisFailed.replace(`{{folder}}`,n.displayName).replace(`{{error}}`,X(t)))}});if(Te.current)return;let a=r.find(e=>e.status===`completed`)??r.at(-1);a?Z(a):v(`candidates`)}catch(e){B(X(e)),v(`candidates`)}finally{ge(!1),R(!1)}},Q=ue({onPicked:(0,G.useCallback)(async e=>{R(!0),B(null);try{let t=await ne(e);T(t),N({provider:t.provider,remoteModel:t.remoteModel}),v(`consent`)}catch(e){B(X(e)),v(`intro`)}finally{R(!1)}},[])});(0,G.useEffect)(()=>{if(!h){let e=O.getState().directoryRun;if(e){Z(e);return}}let e=!1,n=window.setTimeout(()=>{e||v(`intro`)},4e3);return te().then(async({enabled:r,state:i})=>{if(!e){if(!r){window.clearTimeout(n),t?t():u(`/chat`,{replace:!0});return}if(!h&&i.activeRunId)try{let t=await w(i.activeRunId);e||(window.clearTimeout(n),Z(t));return}catch{}e||(window.clearTimeout(n),v(`intro`))}}).catch(t=>{window.clearTimeout(n),e||(B(X(t)),v(`intro`))}),()=>{e=!0,window.clearTimeout(n)}},[Z,u,t,h]),(0,G.useEffect)(()=>{if(!F||_!==`running`||me)return;let e=!1,t=async()=>{try{let t=await w(F.id);e||Z(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===F.id)&&t()};for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.addEventListener(e,r);return()=>{e=!0,window.clearInterval(n);for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.removeEventListener(e,r)}},[Z,me,_,F]);let Ye=async()=>{R(!0);try{await b()}finally{t?t():u(`/chat`,{replace:!0})}},Xe=async()=>{if(S){R(!0),B(null),q([]),ve({current:0,total:0});try{let e=S.remoteModel?`remote_allowed`:`local_only`;await D(S.canonicalRootPath,e);let t=await re(S.canonicalRootPath);Z(t),O.getState().collectSources(t.id,[...Y],e)}catch(e){B(X(e)),v(`consent`)}finally{R(!1)}}},Ze=(e,t,r=!1)=>{let i=new URLSearchParams;t&&i.set(`draft`,t),t&&r&&i.set(`autoSend`,`1`);let a=i.toString();n?.(),u(`/chat/${encodeURIComponent(e)}${a?`?${a}`:``}`)},Qe=e=>{I(e),se(!1),e.status===`completed`?v(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?v(`error`):v(`running`)},$e=async()=>{if(!F)return;Te.current=!0;let e=await C(F.id);Z(e)},et=()=>{n?.(),u(`/chat`)},tt=()=>{if(S){Xe();return}Je()},nt=()=>{v(S?`consent`:ce.length?`candidates`:`intro`)},rt=async(e,t)=>{if(!F)return;await k(F.id,e.id).catch(()=>{});let n=t?`${r===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${e.actionPrompt}`:e.actionPrompt;Ze(F.conversationId,n)},it=async(e,t)=>{if(!F)return!1;R(!0),B(null);try{let n=await y(F.id,e,t);return I(n),qe(n),v(`recommendation`),!0}catch(e){return B(X(e)),!1}finally{R(!1)}},at=async(e,t)=>{if(!F)return!1;R(!0),B(null);try{let n=await y(F.id,t,t===`corrected`?e:void 0);return I(n),qe(n),Ze(F.conversationId,e,!0),!0}catch(e){return B(X(e)),!1}finally{R(!1)}},$=F?.result?.suggestions.find(e=>e.id===F.result?.primarySuggestionId)??F?.result?.suggestions[0],ot=F?.result?.suggestions.filter(e=>e.id!==$?.id)??[],st=e=>e===`command`?i.riskCommand:e===`file_write`?i.riskFileWrite:i.riskAnalysis,ct=pe.filter(e=>e?.status===`completed`),lt=e&&_===`candidates`,ut=ct.length>1?(0,J.jsxs)(`div`,{className:`mt-6 rounded-xl border border-edge bg-surface-panel p-2`,children:[(0,J.jsx)(`p`,{className:`px-2 pb-2 text-xs font-medium text-fg-muted`,children:i.analysisResults}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ct.map(e=>{let t=ce.find(t=>t.rootPath===e.rootPath)?.displayName??e.rootPath.split(/[\\/]/).filter(Boolean).at(-1)??e.rootPath;return(0,J.jsx)(`button`,{type:`button`,className:`rounded-lg px-3 py-2 text-sm font-medium transition ${e.id===F?.id?`bg-accent text-on-accent`:`bg-surface-hover text-fg hover:bg-surface-active`}`,onClick:()=>Qe(e),children:t},e.id)})})]}):null;return(0,J.jsxs)(`div`,{className:e?`xopc-work-discovery-experience relative flex h-full min-h-0 flex-1 flex-col overflow-hidden`:`xopc-work-discovery-experience relative flex min-h-full flex-1 flex-col`,children:[(0,J.jsxs)(`main`,{className:e?`app-main-surface xopc-work-discovery-stage xopc-onboarding-scroll relative z-10 mx-auto my-3 flex min-h-0 w-[calc(100%_-_1.5rem)] ${_===`recognition`?`max-w-[58rem]`:`max-w-[46rem]`} flex-1 flex-col rounded-xl bg-surface-panel px-5 py-7 shadow-surface sm:my-4 sm:w-[calc(100%_-_2rem)] sm:px-8 sm:py-9 ${lt?`overflow-hidden`:`overflow-y-auto`}`:`app-main-surface mx-auto my-4 flex w-[calc(100%_-_2rem)] ${_===`recognition`?`max-w-[58rem]`:`max-w-[40rem]`} flex-1 flex-col rounded-xl bg-surface-panel px-5 py-10 shadow-surface sm:px-8 sm:py-16`,children:[_===`intro`?(0,J.jsx)(`div`,{className:H(`flex items-center justify-center`,e?`mb-7 sm:mb-9`:`mb-10`),children:(0,J.jsx)(le,{className:`size-28`,mood:`curious`})}):null,_===`loading`?(0,J.jsxs)(`section`,{className:`mx-auto flex min-h-[32rem] w-full max-w-md flex-1 flex-col items-center justify-center text-center`,"aria-busy":!0,"aria-label":i.loading,children:[(0,J.jsx)(oe,{className:`size-14 rounded-xl`}),(0,J.jsx)(oe,{className:`mt-7 h-5 w-44 rounded-full`}),(0,J.jsx)(oe,{className:`mt-3 h-3.5 w-64 max-w-full rounded-full`})]}):null,_===`intro`?(0,J.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,J.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,J.jsx)(`p`,{className:`mb-2 text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:i.sourceStepEyebrow}),(0,J.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:i.title}),(0,J.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:i.subtitle})]}),(0,J.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[be.length?(0,J.jsxs)(`div`,{className:`mb-5 overflow-hidden rounded-xl border border-edge bg-surface-panel text-left shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`px-4 py-3.5`,children:[(0,J.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.localSourcesTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:i.localSourcesSubtitle})]}),(0,J.jsx)(`div`,{className:`grid border-t border-edge-subtle sm:grid-cols-2`,children:be.map(e=>{let t=Y.has(e.id);return(0,J.jsxs)(`button`,{type:`button`,className:H(`flex min-h-12 items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3 text-left text-sm transition-colors last:border-b-0 sm:[&:nth-last-child(-n+2)]:border-b-0 sm:[&:nth-child(odd)]:border-r`,t?`bg-accent-soft/55 text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":t,onClick:()=>Ue(e.id),children:[(0,J.jsx)(`span`,{className:`truncate font-medium`,children:e.displayName}),(0,J.jsx)(`span`,{className:H(`flex size-5 shrink-0 items-center justify-center rounded-full border transition-colors`,t?`border-accent bg-accent text-on-accent`:`border-edge`),children:t?(0,J.jsx)(f,{className:`size-3`,"aria-hidden":!0}):null})]},e.id)})})]}):null,(0,J.jsxs)(U,{type:`button`,variant:`primary`,className:`h-12 w-full gap-2`,onClick:()=>void We(),disabled:L||Q.picking,children:[L?(0,J.jsx)(P,{className:`size-4 animate-spin`}):(0,J.jsx)(V,{className:`size-4`}),i.quickScan]}),(0,J.jsxs)(U,{type:`button`,variant:`secondary`,className:`mt-3 h-11 w-full gap-2`,onClick:Q.pick,disabled:L||Q.picking,children:[Q.picking?(0,J.jsx)(P,{className:`size-4 animate-spin`}):(0,J.jsx)(j,{className:`size-4`}),i.chooseFolderManually]}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,J.jsx)(V,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,J.jsx)(`span`,{children:i.quickScanNote})]}),z?(0,J.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:z}):null]}),(0,J.jsx)(`button`,{type:`button`,className:`mx-auto mt-auto pt-10 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void Ye(),disabled:L,children:i.skip})]}):null,_===`candidates`?(0,J.jsxs)(`section`,{className:e?`flex h-full min-h-0 flex-col`:void 0,"aria-labelledby":`work-discovery-candidates-title`,children:[(0,J.jsxs)(`div`,{className:e?`shrink-0 text-center`:`text-center`,children:[(0,J.jsx)(`p`,{className:`mb-2 text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:i.sourceStepEyebrow}),(0,J.jsx)(`h1`,{id:`work-discovery-candidates-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:i.candidatesTitle}),(0,J.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:i.candidatesSubtitle})]}),(0,J.jsx)(`div`,{className:e?`xopc-onboarding-scroll mt-5 min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain pr-1`:`mt-7 space-y-2`,children:ce.map((e,t)=>{let n=K.has(e.rootPath);return(0,J.jsxs)(`button`,{type:`button`,"aria-pressed":n,className:`flex w-full items-start gap-3 rounded-xl border p-4 text-left transition ${n?`border-accent bg-accent-soft/45`:`border-edge bg-surface-panel hover:border-edge-strong`}`,onClick:()=>Ge(e.rootPath),children:[(0,J.jsx)(`span`,{className:`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-md border ${n?`border-accent bg-accent text-on-accent`:`border-edge bg-surface-base text-transparent`}`,children:(0,J.jsx)(f,{className:`size-3.5`})}),(0,J.jsx)(j,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.displayName}),t===0?(0,J.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[0.7rem] font-medium text-accent-fg`,children:i.recommendedCandidate}):null]}),(0,J.jsx)(`span`,{className:`mt-1 block truncate font-mono text-xs text-fg-muted`,children:e.rootPath}),(0,J.jsxs)(`span`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,J.jsx)(`span`,{children:e.projectKind===`coding`?i.codingProject:e.projectKind===`general`?i.generalProject:i.unknownProject}),e.branch?(0,J.jsx)(`span`,{children:i.branchValue.replace(`{{branch}}`,e.branch)}):null,e.changedFileCount>0?(0,J.jsx)(`span`,{children:i.changedFiles.replace(`{{count}}`,String(e.changedFileCount))}):null]})]})]},e.id)})}),(0,J.jsxs)(`div`,{className:e?`shrink-0 border-t border-edge-subtle pt-4`:void 0,children:[(0,J.jsxs)(`div`,{className:`${e?``:`mt-5 `}flex items-start gap-2 rounded-xl bg-surface-hover/70 px-4 py-3 text-xs leading-5 text-fg-muted`,children:[(0,J.jsx)(V,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,J.jsxs)(`span`,{children:[i.multiFolderPrivacyNote,` `,M?.remoteModel?i.providerDisclosure.replace(`{{provider}}`,M.provider):i.localDisclosure]})]}),z?(0,J.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:z}):null,(0,J.jsxs)(`div`,{className:`${e?`mt-4`:`mt-7`} flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,J.jsx)(U,{type:`button`,variant:`primary`,className:`h-11 flex-1`,disabled:L||K.size===0,onClick:()=>v(`connectors`),children:i.continueToConnectors}),(0,J.jsx)(U,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:L,onClick:Q.pick,children:i.chooseFolderManually})]}),(0,J.jsx)(`button`,{type:`button`,className:`${e?`mt-3`:`mt-6`} mx-auto block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>v(`intro`),children:i.back})]})]}):null,_===`consent`&&S?(0,J.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,J.jsxs)(`div`,{className:`text-center`,children:[(0,J.jsx)(`p`,{className:`mb-2 text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:i.sourceStepEyebrow}),(0,J.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:i.selectedTitle}),(0,J.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:i.selectedSubtitle})]}),(0,J.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,J.jsx)(j,{className:`size-5 shrink-0 text-accent-fg`}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:S.displayName}),(0,J.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:S.canonicalRootPath})]}),(0,J.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:S.projectKind===`coding`?i.codingProject:S.projectKind===`general`?i.generalProject:i.unknownProject})]}),(0,J.jsxs)(`div`,{className:`grid gap-4 border-b border-edge-subtle bg-surface-base/35 p-4 sm:grid-cols-2`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.localFingerprint}),(0,J.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:S.fingerprint.branch?i.branchValue.replace(`{{branch}}`,S.fingerprint.branch):i.noGitBranch})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.recentActivity}),(0,J.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:i.changedFiles.replace(`{{count}}`,String(S.fingerprint.changedFileCount))})]}),S.fingerprint.recentAreas.length>0?(0,J.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,J.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.recentAreas}),(0,J.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:S.fingerprint.recentAreas.map(e=>(0,J.jsx)(`code`,{className:`rounded-md bg-surface-hover px-2 py-1 text-xs text-fg`,children:e},e))})]}):null]}),(0,J.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,J.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,J.jsx)(A,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.willRead}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:i.willReadValue})]})]}),(0,J.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,J.jsx)(ae,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.willIgnore}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:i.willIgnoreValue})]})]}),(0,J.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,J.jsx)(V,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,J.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:S.remoteModel?i.providerDisclosure.replace(`{{provider}}`,S.provider):i.localDisclosure})]})]})]}),z?(0,J.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:z}):null,(0,J.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,J.jsx)(U,{type:`button`,variant:`primary`,className:`h-11 flex-1`,disabled:L,onClick:()=>v(`connectors`),children:i.continueToConnectors}),(0,J.jsx)(U,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:L,onClick:Q.pick,children:i.changeFolder})]}),(0,J.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void Ye(),children:i.skip})]}):null,_===`connectors`?(0,J.jsx)(ke,{busy:L,onBack:nt,onContinue:tt,onSkip:()=>void Ye(),onConnectedSignalsChange:we}):null,_===`running`&&F?(0,J.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,J.jsxs)(`div`,{className:`text-center`,children:[(0,J.jsx)(`p`,{className:`mb-2 text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:i.understandingStepEyebrow}),(0,J.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:i.analyzingTitle}),(0,J.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:i.analyzingSubtitle}),_e.total>1?(0,J.jsx)(`p`,{className:`mt-2 text-sm font-medium text-accent-fg`,children:i.analyzingFolderProgress.replace(`{{current}}`,String(_e.current)).replace(`{{total}}`,String(_e.total))}):null]}),(0,J.jsx)(ye,{signals:He,ariaLabel:i.sourceSignals.ariaLabel,centerLabel:i.sourceSignals.centerLabel}),(0,J.jsx)(`div`,{className:`xopc-understanding-progress mx-auto mt-6 grid max-w-[34rem] grid-cols-3 gap-2`,children:Re.map((e,t)=>{let n=Math.max(0,Re.indexOf(F.stage??`folder_structure`)),r=t<n,a=t===n;return(0,J.jsxs)(`div`,{className:`xopc-understanding-step min-w-0 text-left`,"data-active":a||void 0,"data-complete":r||void 0,children:[(0,J.jsx)(`span`,{className:H(`block h-1 rounded-full`,a||r?`bg-accent`:`bg-surface-hover`)}),(0,J.jsx)(`span`,{className:H(`mt-2 block text-[11px] leading-4`,a?`font-medium text-fg`:`text-fg-muted`),children:i.stages[e]})]},e)})}),(0,J.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:F.rootPath}),(0,J.jsx)(`p`,{className:`mx-auto mt-4 max-w-lg text-center text-xs leading-5 text-fg-muted`,children:i.backgroundChoiceHint}),(0,J.jsxs)(`div`,{className:`mx-auto mt-5 flex max-w-md flex-col gap-3`,children:[(0,J.jsx)(U,{type:`button`,variant:`secondary`,className:`h-11 w-full`,onClick:et,children:i.continueInBackground}),(0,J.jsx)(`button`,{type:`button`,className:`mx-auto text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void $e(),children:i.cancelAnalysis})]})]}):null,_===`recognition`&&F?.result?(0,J.jsx)(he,{run:F,language:r,busy:L,error:z,onFinish:it,onStartConversation:at},F.id):null,_===`recommendation`&&F?.result&&$?(0,J.jsxs)(`section`,{"aria-labelledby":`work-discovery-recommendation-title`,children:[(0,J.jsxs)(`div`,{className:`text-center`,children:[(0,J.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:i.understandingConfirmed}),(0,J.jsx)(`h1`,{id:`work-discovery-recommendation-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:i.primaryRecommendationTitle})]}),ut,(0,J.jsx)(`article`,{className:`mt-7 rounded-xl border border-edge bg-surface-panel p-5 shadow-surface sm:p-7`,children:(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,J.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-surface-hover text-fg-muted`,children:(0,J.jsx)(m,{className:`size-5`})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:$.title}),(0,J.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:$.rationale}),(0,J.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 text-xs`,children:[(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-surface-hover px-2.5 py-1 text-fg-muted`,children:[(0,J.jsx)(ee,{className:`size-3.5`}),i.estimatedMinutes.replace(`{{count}}`,String($.estimatedMinutes))]}),(0,J.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-fg-muted`,children:st($.risk)})]}),(0,J.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base px-4 py-3`,children:[(0,J.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.expectedTask}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg`,children:$.expectedTask})]}),(0,J.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,J.jsx)(U,{variant:`primary`,className:`h-10 px-4`,onClick:()=>void rt($,!1),children:i.startRecommendedAction}),(0,J.jsx)(U,{className:`h-10 px-4`,variant:`secondary`,onClick:()=>void rt($,!0),children:i.explainFirst})]})]})]})}),ot.length>0?(0,J.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between py-2 text-sm font-medium text-fg-muted hover:text-fg`,onClick:()=>se(e=>!e),children:[i.otherDirections,(0,J.jsx)(p,{className:`size-4 transition-transform ${ie?`rotate-180`:``}`})]}),ie?(0,J.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-panel px-4`,children:ot.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 py-4 text-left`,onClick:()=>void rt(e,!0),children:[(0,J.jsx)(m,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title}),(0,J.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e.expectedTask})]})]},e.id))}):null]}):null,(0,J.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,J.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Ze(F.conversationId),children:i.doSomethingElse}),(0,J.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>v(`recognition`),children:i.correctUnderstanding})]})]}):null,_===`error`&&F?(0,J.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,J.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,J.jsx)(ae,{className:`size-5`})}),(0,J.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:i.errorTitle}),(0,J.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:F.errorMessage}),(0,J.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,J.jsx)(U,{variant:`primary`,className:`h-11 flex-1`,onClick:()=>void x(F.id).then(Z),children:i.retry}),(0,J.jsx)(U,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{I(null),T(null),v(`intro`)},children:i.chooseDifferent})]}),(0,J.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Ze(F.conversationId),children:i.openConversation})]}):null]},_),Q.hasNativePicker?null:(0,J.jsx)(g,{open:Q.modalOpen,onOpenChange:Q.setModalOpen,initialAbsolutePath:S?.canonicalRootPath,onConfirm:Q.confirmPick,wd:l})]})}export{Le as n,W as r,Ve as t};
|
|
1
|
+
import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{m as a,u as o}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{n as s}from"./locale-store-Dy1EByeG.js";import{t as c}from"./messages-BAnhwALN.js";import{t as l}from"./createLucideIcon-DPHK1VkS.js";import{t as u}from"./service-recommendation-list-BmRtbJz2.js";import{t as d}from"./calendar-days-hw_Y-g-s.js";import{t as f}from"./check-DUBLcKHA.js";import{t as p}from"./chevron-down-ccbiQQz_.js";import{t as m}from"./chevron-right-BweFrslA.js";import{i as h,t as g}from"./working-directory-picker-modal-BGZduAXV.js";import{t as _}from"./circle-check-C23XjkUj.js";import{t as ee}from"./clock-3-DnrAnuyZ.js";import{t as v}from"./database-CjjeZfRG.js";import{a as te,c as ne,d as re,f as y,i as b,l as x,m as S,n as C,o as w,p as T,r as E,s as D,t as O,u as k}from"./understanding-activity-store-BFc8PamJ.js";import{t as A}from"./file-text-D12HbeVy.js";import{t as j}from"./folder-open-CyzJ19I9.js";import{t as M}from"./git-branch-Dh9uxTot.js";import{t as N}from"./list-todo-CTVRto8O.js";import{t as P}from"./loader-circle-CifKLtgG.js";import{t as F}from"./messages-square-BckAJrEW.js";import{n as I,s as L,t as R}from"./install-connector-dialog-DxSv1wS2.js";import{t as z}from"./plug-zap-L8NMe3Sv.js";import{t as B}from"./plus-Q2yW6OE7.js";import{t as V}from"./shield-check-BU58siTV.js";import{t as ie}from"./sparkles-DHlfQFAF.js";import{t as ae}from"./x-B_N4OPjy.js";import{t as H}from"./cn-0WouolD0.js";import{t as oe}from"./skeleton-DzdOeGYz.js";import{t as U}from"./button-Cc4hUNTt.js";import{a as se,r as ce}from"./connectors-api-CTuVWwBf.js";import{t as le}from"./loopi-CNtmi9FU.js";import{t as ue}from"./use-directory-picker-C4p7AgWY.js";var W=l(`book-open-text`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M16 12h2`,key:`7q9ll5`}],[`path`,{d:`M16 8h2`,key:`msurwy`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}],[`path`,{d:`M6 12h2`,key:`32wvfc`}],[`path`,{d:`M6 8h2`,key:`30oboj`}]]),G=e(n(),1),K=new Set([`completed`,`failed`,`canceled`]);function de(){return new Promise(e=>window.setTimeout(e,1200))}async function fe(e,t){let n=[],r=t.wait??de;for(let i=0;i<e.length&&!t.shouldStop?.();i+=1){let a=e[i];if(a)try{await t.grantDirectory(a.rootPath);let o=await t.startRun(a.rootPath);for(t.onRun(o,i,e.length);!K.has(o.status)&&!t.shouldStop?.();)await r(),o=await t.fetchRun(o.id),t.onRun(o,i,e.length);if(n.push(o),o.status===`canceled`||t.shouldStop?.())break}catch(e){if(t.onError?.(e,a,i),t.shouldStop?.())break}}return n}var pe=r();function q(e,t){let n=e.result?.conversationStarter?.trim();if(n)return n;let r=e.result?.suggestions.find(t=>t.id===e.result?.primarySuggestionId)??e.result?.suggestions[0];if(r?.actionPrompt.trim())return r.actionPrompt.trim();let i=e.rootPath.split(/[\\/]/).filter(Boolean).at(-1)??e.rootPath;return t===`zh`?`请先结合 ${i} 当前目录和最近变更,帮我说明这个项目在做什么、现在最值得关注什么,以及建议我下一步从哪里开始。`:`Help me understand ${i}: explain what this project is doing, what matters most right now, and where I should start next.`}var J=i(),me={zh:{eyebrow:`当前理解`,summaryTitle:`我理解的是这样`,summaryQuestion:`可以继续,也可以随时修改。`,matches:`准确,继续`,adjust:`修改`,why:`查看依据`,evidenceHint:`这些内容只用于本次判断。`,current:`当前`,ongoing:`持续`,longTerm:`长期`,correctionTitle:`告诉我正确的重点`,correctionPlaceholder:`你现在真正想推进什么?`,continueWithCorrection:`按此继续`,starterTitle:`从这里开始`,starterHint:`可以修改后直接开始对话。`,startConversation:`进入对话`,cancel:`取消`},en:{eyebrow:`Current understanding`,summaryTitle:`Here’s how I understand it`,summaryQuestion:`Continue, or adjust this anytime.`,matches:`Accurate, continue`,adjust:`Edit`,why:`View sources`,evidenceHint:`These sources are only used for this assessment.`,current:`Current`,ongoing:`Ongoing`,longTerm:`Long term`,correctionTitle:`Tell me the right focus`,correctionPlaceholder:`What do you want to move forward right now?`,continueWithCorrection:`Continue`,starterTitle:`Start here`,starterHint:`Edit this if needed, then start the conversation.`,startConversation:`Start conversation`,cancel:`Cancel`}};function he(e){let t=(0,pe.c)(84),{run:n,language:r,busy:i,error:a,onFinish:o,onStartConversation:s}=e,c=me[r],l=n.result?.lowConfidence===!0,u;t[0]!==r||t[1]!==n?(u=q(n,r),t[0]=r,t[1]=n,t[2]=u):u=t[2];let d=u,[f,m]=(0,G.useState)(l),[h,g]=(0,G.useState)(l?d:``),[_,ee]=(0,G.useState)(!1),[v,te]=(0,G.useState)(!1),[ne,re]=(0,G.useState)(!1),y,b,x,S,C,w,T,E,D,O,k,A;if(t[3]!==i||t[4]!==v||t[5]!==h||t[6]!==f||t[7]!==a||t[8]!==ne||t[9]!==o||t[10]!==s||t[11]!==n.result||t[12]!==c.current||t[13]!==c.evidenceHint||t[14]!==c.eyebrow||t[15]!==c.longTerm||t[16]!==c.ongoing||t[17]!==c.summaryTitle||t[18]!==c.why){let e=n.result?.workThreads?.slice(0,3)??[],r=n.result?.suggestions.find(e=>e.id===n.result?.primarySuggestionId)??n.result?.suggestions[0],l;t[31]!==h||t[32]!==o?(l=async e=>{ee(!0),await o(e,e===`corrected`?h.trim():void 0)||ee(!1)},t[31]=h,t[32]=o,t[33]=l):l=t[33],y=l;let u;t[34]!==h||t[35]!==s?(u=async()=>{let e=h.trim();e&&(te(!0),await s(e,`corrected`)||te(!1))},t[34]=h,t[35]=s,t[36]=u):u=t[36],b=u,x=`xopc-understanding-reveal flex min-h-full flex-1 flex-col`,S=`polite`,D=`xopc-reveal-scene mx-auto flex w-full max-w-[40rem] flex-1 flex-col justify-center py-6 text-center sm:py-10`;let d=a?`care`:i||v?`work`:f?`listen`:`decision`;t[37]===d?O=t[38]:(O=(0,J.jsx)(le,{className:`mx-auto mb-3 size-28`,mood:d}),t[37]=d,t[38]=O),t[39]===c.eyebrow?k=t[40]:(k=(0,J.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-accent-fg`,children:c.eyebrow}),t[39]=c.eyebrow,t[40]=k),t[41]===c.summaryTitle?A=t[42]:(A=(0,J.jsx)(`h1`,{className:`mx-auto mt-4 max-w-[34rem] text-3xl font-semibold tracking-[-0.035em] text-fg sm:text-[2.25rem]`,children:c.summaryTitle}),t[41]=c.summaryTitle,t[42]=A),C=`xopc-understanding-hero-card relative mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel px-6 py-7 text-left shadow-surface sm:px-8`,t[43]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,J.jsx)(`div`,{className:`mb-5 flex size-9 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,"aria-hidden":!0,children:(0,J.jsx)(ie,{className:`size-[1.125rem]`})}),t[43]=w):w=t[43];let m=n.result?.projectSummary;t[44]===m?T=t[45]:(T=(0,J.jsx)(`p`,{className:`relative text-lg font-medium leading-8 text-fg sm:text-xl`,children:m}),t[44]=m,t[45]=T),E=n.result?.currentState||e.length||r?.evidence.length?(0,J.jsxs)(`div`,{className:`relative mt-5 border-t border-edge-subtle pt-4`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 text-xs font-medium text-fg-muted hover:text-fg`,onClick:()=>re(_e),children:[c.why,(0,J.jsx)(p,{className:H(`size-3.5 transition-transform`,ne&&`rotate-180`)})]}),ne?(0,J.jsxs)(`div`,{className:`mt-3 space-y-3 text-xs leading-5 text-fg-muted`,children:[(0,J.jsx)(`p`,{className:`text-fg-subtle`,children:c.evidenceHint}),n.result?.currentState?(0,J.jsx)(`p`,{children:n.result.currentState}):null,e.length?(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,J.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg`,children:e.title}),` · `,e.horizon===`current`?c.current:e.horizon===`ongoing`?c.ongoing:c.longTerm]},e.id))}):null,r?.evidence.slice(0,3).map(ge)]}):null]}):null,t[3]=i,t[4]=v,t[5]=h,t[6]=f,t[7]=a,t[8]=ne,t[9]=o,t[10]=s,t[11]=n.result,t[12]=c.current,t[13]=c.evidenceHint,t[14]=c.eyebrow,t[15]=c.longTerm,t[16]=c.ongoing,t[17]=c.summaryTitle,t[18]=c.why,t[19]=y,t[20]=b,t[21]=x,t[22]=S,t[23]=C,t[24]=w,t[25]=T,t[26]=E,t[27]=D,t[28]=O,t[29]=k,t[30]=A}else y=t[19],b=t[20],x=t[21],S=t[22],C=t[23],w=t[24],T=t[25],E=t[26],D=t[27],O=t[28],k=t[29],A=t[30];let j;t[46]!==C||t[47]!==w||t[48]!==T||t[49]!==E?(j=(0,J.jsxs)(`div`,{className:C,children:[w,T,E]}),t[46]=C,t[47]=w,t[48]=T,t[49]=E,t[50]=j):j=t[50];let M;t[51]!==y||t[52]!==i||t[53]!==v||t[54]!==h||t[55]!==f||t[56]!==l||t[57]!==b||t[58]!==_||t[59]!==c.adjust||t[60]!==c.cancel||t[61]!==c.continueWithCorrection||t[62]!==c.correctionPlaceholder||t[63]!==c.correctionTitle||t[64]!==c.matches||t[65]!==c.startConversation||t[66]!==c.starterHint||t[67]!==c.starterTitle||t[68]!==c.summaryQuestion?(M=f?(0,J.jsxs)(`div`,{className:`xopc-reveal-calibration mx-auto mt-7 w-full max-w-xl rounded-xl border border-edge bg-surface-panel p-5 text-left shadow-surface`,children:[(0,J.jsx)(`label`,{className:`text-sm font-semibold text-fg`,htmlFor:`understanding-correction`,children:l?c.starterTitle:c.correctionTitle}),l?(0,J.jsx)(`p`,{className:`mt-1.5 text-xs leading-5 text-fg-muted`,children:c.starterHint}):null,(0,J.jsx)(`textarea`,{id:`understanding-correction`,value:h,onChange:e=>g(e.target.value),placeholder:c.correctionPlaceholder,className:`mt-3 min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm leading-6 text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,J.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[l?null:(0,J.jsx)(U,{variant:`ghost`,disabled:_,onClick:()=>m(!1),children:c.cancel}),(0,J.jsx)(U,{variant:`primary`,disabled:i||v||!h.trim(),onClick:()=>void b(),children:l?c.startConversation:c.continueWithCorrection})]})]}):(0,J.jsxs)(`div`,{className:`mx-auto mt-8 w-full max-w-sm`,children:[(0,J.jsx)(`p`,{className:`text-base font-medium text-fg`,children:c.summaryQuestion}),(0,J.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,J.jsx)(U,{className:`h-11 flex-1`,variant:`primary`,disabled:_,onClick:()=>void y(`confirmed`),children:c.matches}),(0,J.jsx)(U,{className:`h-11 flex-1`,variant:`secondary`,disabled:_,onClick:()=>m(!0),children:c.adjust})]})]}),t[51]=y,t[52]=i,t[53]=v,t[54]=h,t[55]=f,t[56]=l,t[57]=b,t[58]=_,t[59]=c.adjust,t[60]=c.cancel,t[61]=c.continueWithCorrection,t[62]=c.correctionPlaceholder,t[63]=c.correctionTitle,t[64]=c.matches,t[65]=c.startConversation,t[66]=c.starterHint,t[67]=c.starterTitle,t[68]=c.summaryQuestion,t[69]=M):M=t[69];let N;t[70]===a?N=t[71]:(N=a?(0,J.jsx)(`p`,{className:`mt-5 text-sm text-danger`,role:`alert`,children:a}):null,t[70]=a,t[71]=N);let P;t[72]!==j||t[73]!==M||t[74]!==N||t[75]!==D||t[76]!==O||t[77]!==k||t[78]!==A?(P=(0,J.jsxs)(`div`,{className:D,children:[O,k,A,j,M,N]}),t[72]=j,t[73]=M,t[74]=N,t[75]=D,t[76]=O,t[77]=k,t[78]=A,t[79]=P):P=t[79];let F;return t[80]!==x||t[81]!==S||t[82]!==P?(F=(0,J.jsx)(`section`,{className:x,"aria-live":S,children:P}),t[80]=x,t[81]=S,t[82]=P,t[83]=F):F=t[83],F}function ge(e,t){return(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(M,{className:`mt-0.5 size-3.5 shrink-0 text-accent-fg`}),(0,J.jsxs)(`span`,{children:[e.path?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`code`,{className:`font-mono text-fg`,children:e.path}),`: `]}):null,e.observation]})]},`${t}-${e.path??e.observation}`)}function _e(e){return!e}var ve={folder:j,file:A,recent:S,git:M,calendar:d,task:N,note:W,mail:T,message:F,service:z,data:v};function ye(e){let t=(0,pe.c)(28),{signals:n,ariaLabel:r,centerLabel:i}=e,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==i||t[2]!==n){let e=n.slice(0,3);a=Math.max(0,n.length-e.length),c=`xopc-source-convergence mx-auto mt-9 w-full max-w-[34rem] overflow-hidden rounded-xl border border-edge bg-surface-panel px-5 py-6 shadow-surface sm:px-6`,l=`img`,u=r;let p;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,J.jsx)(le,{className:`size-24`,mood:`work`}),t[11]=p):p=t[11],t[12]===i?d=t[13]:(d=(0,J.jsxs)(`div`,{className:`flex flex-col items-center text-center`,"aria-hidden":!0,children:[p,(0,J.jsx)(`span`,{className:`mt-3 text-[11px] font-semibold tracking-[0.16em] text-fg-muted`,children:i})]}),t[12]=i,t[13]=d),t[14]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,J.jsx)(`div`,{className:`mt-5 h-1 overflow-hidden rounded-full bg-surface-hover`,"aria-hidden":!0,children:(0,J.jsx)(`span`,{className:`xopc-source-convergence-progress block h-full w-2/5 rounded-full bg-accent`})}),t[14]=f):f=t[14],o=`mt-5 divide-y divide-edge-subtle border-y border-edge-subtle`,s=e.map(be),t[0]=r,t[1]=i,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];let p;t[15]!==o||t[16]!==s?(p=(0,J.jsx)(`div`,{className:o,children:s}),t[15]=o,t[16]=s,t[17]=p):p=t[17];let m;t[18]===a?m=t[19]:(m=a>0?(0,J.jsxs)(`p`,{className:`mt-3 text-center text-xs text-fg-muted`,"aria-hidden":!0,children:[`+`,a]}):null,t[18]=a,t[19]=m);let h;return t[20]!==c||t[21]!==l||t[22]!==u||t[23]!==d||t[24]!==f||t[25]!==p||t[26]!==m?(h=(0,J.jsxs)(`div`,{className:c,role:l,"aria-label":u,children:[d,f,p,m]}),t[20]=c,t[21]=l,t[22]=u,t[23]=d,t[24]=f,t[25]=p,t[26]=m,t[27]=h):h=t[27],h}function be(e){let t=ve[e.kind];return(0,J.jsxs)(`div`,{className:`flex min-h-12 items-center gap-3 py-2.5 text-left`,"aria-hidden":!0,children:[(0,J.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,J.jsx)(t,{className:`size-4`})}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,title:e.detail,children:[(0,J.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.label}),e.meta?(0,J.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:e.meta}):null]}),(0,J.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-accent`})]},e.id)}var xe=[`gmail`,`googlecalendar`,`googledrive`,`github`,`linear`];function Y({toolkit:e,displayName:t,description:n,category:r,mode:i,bootstrapWindowDays:a,logoFileName:o=e}){return{id:`composio-${e}`,version:`sessions-v1`,displayName:t,description:n,category:r,kind:`composio`,source:`registry`,capabilities:[`tools`,`auth.oauth`,`events`,`context`,`memory_source`],benefits:[`understand`,`act`],understanding:{mode:i,bootstrapWindowDays:a,readOnly:!0},tags:[`composio`,e,`verified`],branding:{logoUrl:`/connector-icons/${o}.svg`,source:`builtin`},verificationLevel:`verified`,auth:{mode:`oauth`,provider:`composio`},setup:{},runtime:{type:`composio`,toolkit:e,role:`toolkit`},integrationStrategy:{lane:`composio`,workload:`long_tail`,preferred:!0}}}var Se=[Y({toolkit:`gmail`,displayName:`Gmail`,description:`Find and understand recent email, then draft or send with your approval.`,category:`automation`,mode:`activity`,bootstrapWindowDays:30}),Y({toolkit:`googlecalendar`,displayName:`Google Calendar`,description:`Understand your schedule and work with approved calendar events.`,category:`automation`,mode:`activity`,bootstrapWindowDays:90,logoFileName:`google-calendar`}),Y({toolkit:`googledrive`,displayName:`Google Drive`,description:`Search and understand approved files in Google Drive.`,category:`data`,mode:`inventory`,bootstrapWindowDays:90,logoFileName:`google-drive`}),Y({toolkit:`github`,displayName:`GitHub`,description:`Understand repositories, issues, pull requests, and reviews.`,category:`code`,mode:`activity`,bootstrapWindowDays:90}),Y({toolkit:`linear`,displayName:`Linear`,description:`Understand and work with Linear issues and projects.`,category:`code`,mode:`activity`,bootstrapWindowDays:60})];function Ce(e){return e.runtime.type===`composio`&&e.runtime.role===`toolkit`?e.runtime.toolkit.toLocaleLowerCase():``}function we(e){let t=new Map(xe.map((e,t)=>[e,t]));return e.filter(e=>e.understanding!=null&&Ce(e)).sort((e,n)=>(t.get(Ce(e))??2**53-1)-(t.get(Ce(n))??2**53-1)||e.displayName.localeCompare(n.displayName))}function Te(e,t){let n=new Map(e.map(e=>[e.id,e]));for(let e of t)n.set(e.id,e);return we([...n.values()])}var Ee=2500;function De(e){return!!(e?.enabled&&(e.status===`connected`||e.connectionStatus===`connected`||e.authStatus===`connected`))}function Oe(e){return e===`gmail`?`mail`:e===`googlecalendar`?`calendar`:e===`googledrive`?`data`:e===`github`?`git`:e===`linear`?`task`:`service`}function ke(e){let t=(0,pe.c)(59),{busy:n,onBack:r,onContinue:i,onSkip:a,onConnectedSignalsChange:o}=e,l=s(Pe),d=c(l),f=d.onboarding.workDiscovery,m=d.connectorsSettings,[g,ee]=(0,G.useState)(Ne),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],t[0]=v):v=t[0];let[te,ne]=(0,G.useState)(v),[re,y]=(0,G.useState)(!0),[b,x]=(0,G.useState)(null),[S,C]=(0,G.useState)(!1),[w,T]=(0,G.useState)(null),E;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(E=async()=>{let e=await se();return ne(e),e},t[1]=E):E=t[1];let D=E,O,k;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>{let e=!1,t=window.setTimeout(()=>{e||y(!1)},Ee);return se().then(t=>{e||ne(t)}).catch(t=>{e||x(t instanceof Error?t.message:String(t))}).finally(()=>{e||y(!1),window.clearTimeout(t)}),ce({page:1,pageSize:24,verification:`verified`}).then(t=>{e||ee(Te(Se,t.connectors))}).catch(Me),()=>{e=!0,window.clearTimeout(t)}},k=[],t[2]=O,t[3]=k):(O=t[2],k=t[3]),(0,G.useEffect)(O,k);let A;t[4]===te?A=t[5]:(A=new Map(te.map(je)),t[4]=te,t[5]=A);let j=A,M;if(t[6]!==g||t[7]!==j){let e;t[9]===j?e=t[10]:(e=e=>{if(!De(j.get(e.id)))return[];let t=Ce(e);return[{id:e.id,label:e.displayName,kind:Oe(t)}]},t[9]=j,t[10]=e),M=g.flatMap(e),t[6]=g,t[7]=j,t[8]=M}else M=t[8];let N=M,F,z;t[11]!==N||t[12]!==o?(F=()=>{o(N)},z=[N,o],t[11]=N,t[12]=o,t[13]=F,t[14]=z):(F=t[13],z=t[14]),(0,G.useEffect)(F,z);let V;t[15]!==g||t[16]!==S?(V=S?g:g.slice(0,3),t[15]=g,t[16]=S,t[17]=V):V=t[17];let ie=V,ae=N.length,H;t[18]!==g.length||t[19]!==m||t[20]!==f.connected||t[21]!==f.noWorkServices||t[22]!==f.showFewerServices||t[23]!==f.showMoreServices||t[24]!==S||t[25]!==j||t[26]!==re||t[27]!==l||t[28]!==D||t[29]!==C||t[30]!==T||t[31]!==ie?(H=l===`zh`?(0,J.jsx)(u,{onChanged:async()=>{await D()}}):(0,J.jsxs)(J.Fragment,{children:[ie.length?(0,J.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge-subtle bg-surface-base/55`,children:ie.map(e=>{let t=De(j.get(e.id));return(0,J.jsxs)(`article`,{className:`flex min-h-[4.75rem] items-center gap-3 px-3 py-3 sm:px-4`,children:[(0,J.jsx)(I,{connector:e,size:`sm`}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.displayName}),(0,J.jsx)(`p`,{className:`mt-1 line-clamp-1 text-xs text-fg-muted`,children:e.description})]}),t?(0,J.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-xs font-medium text-success`,children:[(0,J.jsx)(_,{className:`size-4`}),f.connected]}):re?(0,J.jsx)(oe,{className:`h-8 w-[4.5rem] shrink-0 rounded-lg`,"aria-label":m.loading}):(0,J.jsxs)(U,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 px-3 text-xs`,onClick:()=>T(L(e)),children:[(0,J.jsx)(B,{className:`size-3.5`}),m.connect]})]},e.id)})}):(0,J.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge px-4 py-8 text-center text-sm text-fg-muted`,children:f.noWorkServices}),g.length>3?(0,J.jsxs)(`button`,{type:`button`,className:`mx-auto mt-3 flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-accent-fg hover:underline`,onClick:()=>C(Ae),children:[S?(0,J.jsx)(h,{className:`size-3.5`}):(0,J.jsx)(p,{className:`size-3.5`}),S?f.showFewerServices:f.showMoreServices]}):null]}),t[18]=g.length,t[19]=m,t[20]=f.connected,t[21]=f.noWorkServices,t[22]=f.showFewerServices,t[23]=f.showMoreServices,t[24]=S,t[25]=j,t[26]=re,t[27]=l,t[28]=D,t[29]=C,t[30]=T,t[31]=ie,t[32]=H):H=t[32];let le;t[33]!==f.connectorLoadFailed||t[34]!==b?(le=b?(0,J.jsxs)(`p`,{className:`mt-3 text-center text-xs text-danger`,role:`alert`,children:[f.connectorLoadFailed,`: `,b]}):null,t[33]=f.connectorLoadFailed,t[34]=b,t[35]=le):le=t[35];let ue;t[36]===n?ue=t[37]:(ue=n?(0,J.jsx)(P,{className:`size-4 animate-spin`}):null,t[36]=n,t[37]=ue);let W;t[38]!==n||t[39]!==f.startUnderstanding||t[40]!==i||t[41]!==ue?(W=(0,J.jsxs)(U,{type:`button`,variant:`primary`,className:`h-11 flex-1`,disabled:n,onClick:i,children:[ue,f.startUnderstanding]}),t[38]=n,t[39]=f.startUnderstanding,t[40]=i,t[41]=ue,t[42]=W):W=t[42];let K;t[43]!==n||t[44]!==f.back||t[45]!==r?(K=(0,J.jsx)(U,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:n,onClick:r,children:f.back}),t[43]=n,t[44]=f.back,t[45]=r,t[46]=K):K=t[46];let de;t[47]!==W||t[48]!==K?(de=(0,J.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[W,K]}),t[47]=W,t[48]=K,t[49]=de):de=t[49];let fe;t[50]!==n||t[51]!==f.skipAndEnter||t[52]!==a?(fe=(0,J.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,disabled:n,onClick:a,children:f.skipAndEnter}),t[50]=n,t[51]=f.skipAndEnter,t[52]=a,t[53]=fe):fe=t[53];let q;return t[54]!==m||t[55]!==w||t[56]!==D||t[57]!==T?(q=w?(0,J.jsx)(R,{draft:w,onChange:T,onClose:()=>T(null),t:m,onInstalled:async()=>{await D(),T(null)}}):null,t[54]=m,t[55]=w,t[56]=D,t[57]=T,t[58]=q):q=t[58],(0,J.jsxs)(`section`,{className:`mx-auto flex w-full max-w-[42rem] flex-1 flex-col`,"aria-labelledby":`work-discovery-connectors-title`,children:[(0,J.jsxs)(`div`,{className:`text-center`,children:[(0,J.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:f.connectorStepEyebrow}),(0,J.jsx)(`h1`,{id:`work-discovery-connectors-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:f.connectorStepTitle}),(0,J.jsx)(`p`,{className:`mx-auto mt-3 max-w-[36rem] text-[0.95rem] leading-7 text-fg-muted`,children:f.connectorStepSubtitle})]}),(0,J.jsxs)(`div`,{className:`mt-7 rounded-xl border border-edge bg-surface-panel p-3 shadow-surface sm:p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-1 pb-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:f.popularWorkServices}),(0,J.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:f.connectorsOptional})]}),ae?(0,J.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 rounded-full bg-success-soft px-2.5 py-1 text-xs font-medium text-success`,children:[(0,J.jsx)(_,{className:`size-3.5`}),f.connectedCount.replace(`{{count}}`,String(ae))]}):null]}),H,le]}),de,fe,q]})}function Ae(e){return!e}function je(e){return[e.connectorId,e]}function Me(){}function Ne(){return we(Se)}function Pe(e){return e.language}var Fe=new Set([`local-recent-files`,`chromium-bookmarks`,`apple-notes`,`apple-mail`,`apple-calendar`,`apple-reminders`]);function Ie(e){return new Set(e.filter(e=>e.availability===`available`&&Fe.has(e.id)).map(e=>e.id))}var Le=t({WorkDiscoveryPage:()=>Ve}),Re=[`folder_structure`,`recent_progress`,`next_steps`];function X(e){return e instanceof Error?e.message:String(e)}function ze(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).slice(-2).join(`/`)||e}function Be(e,t){return e.replace(`{{count}}`,String(t))}function Ve({embedded:e=!1,onRequestClose:t,onNavigateAway:n}={}){let r=s(e=>e.language),i=c(r).onboarding.workDiscovery,l=c(r).chat.workingDirectory,u=o(),[d]=a(),h=d.get(`new`)===`1`,[_,v]=(0,G.useState)(`loading`),[S,T]=(0,G.useState)(null),[M,N]=(0,G.useState)(null),[F,I]=(0,G.useState)(null),[L,R]=(0,G.useState)(!1),[z,B]=(0,G.useState)(null),[ie,se]=(0,G.useState)(!1),[ce,W]=(0,G.useState)([]),[K,de]=(0,G.useState)(()=>new Set),[pe,q]=(0,G.useState)([]),[me,ge]=(0,G.useState)(!1),[_e,ve]=(0,G.useState)({current:0,total:0}),[be,xe]=(0,G.useState)([]),[Y,Se]=(0,G.useState)(()=>new Set),[Ce,we]=(0,G.useState)([]),Te=(0,G.useRef)(!1),Ee={recent_documents:`recent`,calendar:`calendar`,tasks:`task`,notes:`note`,mail:`mail`,messages:`message`,code_activity:`git`,files:`file`},De=F?.snapshot?.projectKind??S?.projectKind,Oe=De===`coding`?i.codingProject:De===`general`?i.generalProject:De===`unknown`?i.unknownProject:null,Ae=(F?.snapshot?.files??[]).slice(0,4).map(e=>({id:`snapshot-file:${e.relativePath}`,label:ze(e.relativePath),kind:e.source===`git_change`?`recent`:`file`,meta:e.source===`git_change`?i.sourceSignals.changedFile:e.source===`document`?i.sourceSignals.contextFile:i.sourceSignals.structureFile,detail:e.relativePath})),je=F?.rootPath??S?.canonicalRootPath,Me=Ae.length===0?(S?.fingerprint.recentAreas??[]).slice(0,2).map(e=>({id:`recent-area:${e}`,label:e,kind:`recent`,meta:i.sourceSignals.recentArea,detail:e})):[],Ne=Ae.length===0?Me.length>0?Me:[{id:`project-files`,label:i.sourceSignals.projectFiles,kind:`file`,meta:i.sourceSignals.scanningFiles},{id:`recent-changes`,label:i.sourceSignals.recentChanges,kind:`recent`,meta:i.sourceSignals.checkingChanges}]:[],Pe=F?.snapshot?.sampledPathCount,Fe=[Oe,Pe==null?null:Be(i.sourceSignals.filesScanned,Pe)].filter(e=>!!e).join(` · `),Le=F?.snapshot?.branch??S?.fingerprint.branch,Ve=F?.snapshot?.changedPathCount??S?.fingerprint.changedFileCount,He=[{id:`work-folder`,label:je?ze(je):i.sourceSignals.workFolder,kind:`folder`,...Fe?{meta:Fe}:{},...je?{detail:je}:{}},...Ae,...Ne,{id:`git-state`,label:Le??i.sourceSignals.gitState,kind:`git`,...Ve==null?{}:{meta:Be(i.sourceSignals.changedFiles,Ve)},...Le?{detail:`Git · ${Le}`}:{}},...be.filter(e=>Y.has(e.id)).map(e=>({id:e.id,label:e.displayName,kind:Ee[e.category]??`data`})),...Ce],Ue=e=>{Se(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};(0,G.useEffect)(()=>{let e=!1;return window.electronAPI?.understandingSources?.catalog().then(t=>{e||(xe(t),Se(Ie(t)))}),()=>{e=!0}},[]);let Z=(0,G.useCallback)(e=>{O.getState().updateDirectoryRun(e),I(e),e.status===`completed`?v(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?v(`error`):v(`running`)},[]),We=async()=>{R(!0),B(null);try{let e=await E();if(N(e.processingTarget),!e.candidates.length){B(i.noCandidates);return}W(e.candidates),de(new Set([e.candidates[0].rootPath])),v(`candidates`)}catch(e){B(X(e))}finally{R(!1)}},Ge=e=>{de(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ke=(0,G.useCallback)((e,t,n)=>{O.getState().updateDirectoryRun(e),I(e),ve({current:t+1,total:n}),q(n=>{let r=[...n];return r[t]=e,r}),v(`running`)},[]),qe=(0,G.useCallback)(e=>{q(t=>t.map(t=>t?.id===e.id?e:t))},[]),Je=async()=>{let e=ce.filter(e=>K.has(e.rootPath));if(!e.length)return;R(!0),B(null),q([]),ve({current:1,total:e.length}),ge(!0),Te.current=!1;let t=!1,n=M?.remoteModel?`remote_allowed`:`local_only`;try{let r=await fe(e,{grantDirectory:e=>D(e,n),startRun:re,fetchRun:w,shouldStop:()=>Te.current,onRun:(e,r,i)=>{Ke(e,r,i),t||(t=!0,O.getState().collectSources(e.id,[...Y],n))},onError:(t,n,r)=>{ve({current:r+1,total:e.length}),B(i.folderAnalysisFailed.replace(`{{folder}}`,n.displayName).replace(`{{error}}`,X(t)))}});if(Te.current)return;let a=r.find(e=>e.status===`completed`)??r.at(-1);a?Z(a):v(`candidates`)}catch(e){B(X(e)),v(`candidates`)}finally{ge(!1),R(!1)}},Q=ue({onPicked:(0,G.useCallback)(async e=>{R(!0),B(null);try{let t=await ne(e);T(t),N({provider:t.provider,remoteModel:t.remoteModel}),v(`consent`)}catch(e){B(X(e)),v(`intro`)}finally{R(!1)}},[])});(0,G.useEffect)(()=>{if(!h){let e=O.getState().directoryRun;if(e){Z(e);return}}let e=!1,n=window.setTimeout(()=>{e||v(`intro`)},4e3);return te().then(async({enabled:r,state:i})=>{if(!e){if(!r){window.clearTimeout(n),t?t():u(`/chat`,{replace:!0});return}if(!h&&i.activeRunId)try{let t=await w(i.activeRunId);e||(window.clearTimeout(n),Z(t));return}catch{}e||(window.clearTimeout(n),v(`intro`))}}).catch(t=>{window.clearTimeout(n),e||(B(X(t)),v(`intro`))}),()=>{e=!0,window.clearTimeout(n)}},[Z,u,t,h]),(0,G.useEffect)(()=>{if(!F||_!==`running`||me)return;let e=!1,t=async()=>{try{let t=await w(F.id);e||Z(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===F.id)&&t()};for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.addEventListener(e,r);return()=>{e=!0,window.clearInterval(n);for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.removeEventListener(e,r)}},[Z,me,_,F]);let Ye=async()=>{R(!0);try{await b()}finally{t?t():u(`/chat`,{replace:!0})}},Xe=async()=>{if(S){R(!0),B(null),q([]),ve({current:0,total:0});try{let e=S.remoteModel?`remote_allowed`:`local_only`;await D(S.canonicalRootPath,e);let t=await re(S.canonicalRootPath);Z(t),O.getState().collectSources(t.id,[...Y],e)}catch(e){B(X(e)),v(`consent`)}finally{R(!1)}}},Ze=(e,t,r=!1)=>{let i=new URLSearchParams;t&&i.set(`draft`,t),t&&r&&i.set(`autoSend`,`1`);let a=i.toString();n?.(),u(`/chat/${encodeURIComponent(e)}${a?`?${a}`:``}`)},Qe=e=>{I(e),se(!1),e.status===`completed`?v(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?v(`error`):v(`running`)},$e=async()=>{if(!F)return;Te.current=!0;let e=await C(F.id);Z(e)},et=()=>{n?.(),u(`/chat`)},tt=()=>{if(S){Xe();return}Je()},nt=()=>{v(S?`consent`:ce.length?`candidates`:`intro`)},rt=async(e,t)=>{if(!F)return;await k(F.id,e.id).catch(()=>{});let n=t?`${r===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${e.actionPrompt}`:e.actionPrompt;Ze(F.conversationId,n)},it=async(e,t)=>{if(!F)return!1;R(!0),B(null);try{let n=await y(F.id,e,t);return I(n),qe(n),v(`recommendation`),!0}catch(e){return B(X(e)),!1}finally{R(!1)}},at=async(e,t)=>{if(!F)return!1;R(!0),B(null);try{let n=await y(F.id,t,t===`corrected`?e:void 0);return I(n),qe(n),Ze(F.conversationId,e,!0),!0}catch(e){return B(X(e)),!1}finally{R(!1)}},$=F?.result?.suggestions.find(e=>e.id===F.result?.primarySuggestionId)??F?.result?.suggestions[0],ot=F?.result?.suggestions.filter(e=>e.id!==$?.id)??[],st=e=>e===`command`?i.riskCommand:e===`file_write`?i.riskFileWrite:i.riskAnalysis,ct=pe.filter(e=>e?.status===`completed`),lt=e&&_===`candidates`,ut=ct.length>1?(0,J.jsxs)(`div`,{className:`mt-6 rounded-xl border border-edge bg-surface-panel p-2`,children:[(0,J.jsx)(`p`,{className:`px-2 pb-2 text-xs font-medium text-fg-muted`,children:i.analysisResults}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ct.map(e=>{let t=ce.find(t=>t.rootPath===e.rootPath)?.displayName??e.rootPath.split(/[\\/]/).filter(Boolean).at(-1)??e.rootPath;return(0,J.jsx)(`button`,{type:`button`,className:`rounded-lg px-3 py-2 text-sm font-medium transition ${e.id===F?.id?`bg-accent text-on-accent`:`bg-surface-hover text-fg hover:bg-surface-active`}`,onClick:()=>Qe(e),children:t},e.id)})})]}):null;return(0,J.jsxs)(`div`,{className:e?`xopc-work-discovery-experience relative flex h-full min-h-0 flex-1 flex-col overflow-hidden`:`xopc-work-discovery-experience relative flex min-h-full flex-1 flex-col`,children:[(0,J.jsxs)(`main`,{className:e?`app-main-surface xopc-work-discovery-stage xopc-onboarding-scroll relative z-10 mx-auto my-3 flex min-h-0 w-[calc(100%_-_1.5rem)] ${_===`recognition`?`max-w-[58rem]`:`max-w-[46rem]`} flex-1 flex-col rounded-xl bg-surface-panel px-5 py-7 shadow-surface sm:my-4 sm:w-[calc(100%_-_2rem)] sm:px-8 sm:py-9 ${lt?`overflow-hidden`:`overflow-y-auto`}`:`app-main-surface mx-auto my-4 flex w-[calc(100%_-_2rem)] ${_===`recognition`?`max-w-[58rem]`:`max-w-[40rem]`} flex-1 flex-col rounded-xl bg-surface-panel px-5 py-10 shadow-surface sm:px-8 sm:py-16`,children:[_===`intro`?(0,J.jsx)(`div`,{className:H(`flex items-center justify-center`,e?`mb-7 sm:mb-9`:`mb-10`),children:(0,J.jsx)(le,{className:`size-28`,mood:`curious`})}):null,_===`loading`?(0,J.jsxs)(`section`,{className:`mx-auto flex min-h-[32rem] w-full max-w-md flex-1 flex-col items-center justify-center text-center`,"aria-busy":!0,"aria-label":i.loading,children:[(0,J.jsx)(oe,{className:`size-14 rounded-xl`}),(0,J.jsx)(oe,{className:`mt-7 h-5 w-44 rounded-full`}),(0,J.jsx)(oe,{className:`mt-3 h-3.5 w-64 max-w-full rounded-full`})]}):null,_===`intro`?(0,J.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,J.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,J.jsx)(`p`,{className:`mb-2 text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:i.sourceStepEyebrow}),(0,J.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:i.title}),(0,J.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:i.subtitle})]}),(0,J.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[be.length?(0,J.jsxs)(`div`,{className:`mb-5 overflow-hidden rounded-xl border border-edge bg-surface-panel text-left shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`px-4 py-3.5`,children:[(0,J.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.localSourcesTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:i.localSourcesSubtitle})]}),(0,J.jsx)(`div`,{className:`grid border-t border-edge-subtle sm:grid-cols-2`,children:be.map(e=>{let t=Y.has(e.id);return(0,J.jsxs)(`button`,{type:`button`,className:H(`flex min-h-12 items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3 text-left text-sm transition-colors last:border-b-0 sm:[&:nth-last-child(-n+2)]:border-b-0 sm:[&:nth-child(odd)]:border-r`,t?`bg-accent-soft/55 text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":t,onClick:()=>Ue(e.id),children:[(0,J.jsx)(`span`,{className:`truncate font-medium`,children:e.displayName}),(0,J.jsx)(`span`,{className:H(`flex size-5 shrink-0 items-center justify-center rounded-full border transition-colors`,t?`border-accent bg-accent text-on-accent`:`border-edge`),children:t?(0,J.jsx)(f,{className:`size-3`,"aria-hidden":!0}):null})]},e.id)})})]}):null,(0,J.jsxs)(U,{type:`button`,variant:`primary`,className:`h-12 w-full gap-2`,onClick:()=>void We(),disabled:L||Q.picking,children:[L?(0,J.jsx)(P,{className:`size-4 animate-spin`}):(0,J.jsx)(V,{className:`size-4`}),i.quickScan]}),(0,J.jsxs)(U,{type:`button`,variant:`secondary`,className:`mt-3 h-11 w-full gap-2`,onClick:Q.pick,disabled:L||Q.picking,children:[Q.picking?(0,J.jsx)(P,{className:`size-4 animate-spin`}):(0,J.jsx)(j,{className:`size-4`}),i.chooseFolderManually]}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,J.jsx)(V,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,J.jsx)(`span`,{children:i.quickScanNote})]}),z?(0,J.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:z}):null]}),(0,J.jsx)(`button`,{type:`button`,className:`mx-auto mt-auto pt-10 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void Ye(),disabled:L,children:i.skip})]}):null,_===`candidates`?(0,J.jsxs)(`section`,{className:e?`flex h-full min-h-0 flex-col`:void 0,"aria-labelledby":`work-discovery-candidates-title`,children:[(0,J.jsxs)(`div`,{className:e?`shrink-0 text-center`:`text-center`,children:[(0,J.jsx)(`p`,{className:`mb-2 text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:i.sourceStepEyebrow}),(0,J.jsx)(`h1`,{id:`work-discovery-candidates-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:i.candidatesTitle}),(0,J.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:i.candidatesSubtitle})]}),(0,J.jsx)(`div`,{className:e?`xopc-onboarding-scroll mt-5 min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain pr-1`:`mt-7 space-y-2`,children:ce.map((e,t)=>{let n=K.has(e.rootPath);return(0,J.jsxs)(`button`,{type:`button`,"aria-pressed":n,className:`flex w-full items-start gap-3 rounded-xl border p-4 text-left transition ${n?`border-accent bg-accent-soft/45`:`border-edge bg-surface-panel hover:border-edge-strong`}`,onClick:()=>Ge(e.rootPath),children:[(0,J.jsx)(`span`,{className:`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-md border ${n?`border-accent bg-accent text-on-accent`:`border-edge bg-surface-base text-transparent`}`,children:(0,J.jsx)(f,{className:`size-3.5`})}),(0,J.jsx)(j,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.displayName}),t===0?(0,J.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[0.7rem] font-medium text-accent-fg`,children:i.recommendedCandidate}):null]}),(0,J.jsx)(`span`,{className:`mt-1 block truncate font-mono text-xs text-fg-muted`,children:e.rootPath}),(0,J.jsxs)(`span`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,J.jsx)(`span`,{children:e.projectKind===`coding`?i.codingProject:e.projectKind===`general`?i.generalProject:i.unknownProject}),e.branch?(0,J.jsx)(`span`,{children:i.branchValue.replace(`{{branch}}`,e.branch)}):null,e.changedFileCount>0?(0,J.jsx)(`span`,{children:i.changedFiles.replace(`{{count}}`,String(e.changedFileCount))}):null]})]})]},e.id)})}),(0,J.jsxs)(`div`,{className:e?`shrink-0 border-t border-edge-subtle pt-4`:void 0,children:[(0,J.jsxs)(`div`,{className:`${e?``:`mt-5 `}flex items-start gap-2 rounded-xl bg-surface-hover/70 px-4 py-3 text-xs leading-5 text-fg-muted`,children:[(0,J.jsx)(V,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,J.jsxs)(`span`,{children:[i.multiFolderPrivacyNote,` `,M?.remoteModel?i.providerDisclosure.replace(`{{provider}}`,M.provider):i.localDisclosure]})]}),z?(0,J.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:z}):null,(0,J.jsxs)(`div`,{className:`${e?`mt-4`:`mt-7`} flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,J.jsx)(U,{type:`button`,variant:`primary`,className:`h-11 flex-1`,disabled:L||K.size===0,onClick:()=>v(`connectors`),children:i.continueToConnectors}),(0,J.jsx)(U,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:L,onClick:Q.pick,children:i.chooseFolderManually})]}),(0,J.jsx)(`button`,{type:`button`,className:`${e?`mt-3`:`mt-6`} mx-auto block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>v(`intro`),children:i.back})]})]}):null,_===`consent`&&S?(0,J.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,J.jsxs)(`div`,{className:`text-center`,children:[(0,J.jsx)(`p`,{className:`mb-2 text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:i.sourceStepEyebrow}),(0,J.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:i.selectedTitle}),(0,J.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:i.selectedSubtitle})]}),(0,J.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,J.jsx)(j,{className:`size-5 shrink-0 text-accent-fg`}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:S.displayName}),(0,J.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:S.canonicalRootPath})]}),(0,J.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:S.projectKind===`coding`?i.codingProject:S.projectKind===`general`?i.generalProject:i.unknownProject})]}),(0,J.jsxs)(`div`,{className:`grid gap-4 border-b border-edge-subtle bg-surface-base/35 p-4 sm:grid-cols-2`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.localFingerprint}),(0,J.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:S.fingerprint.branch?i.branchValue.replace(`{{branch}}`,S.fingerprint.branch):i.noGitBranch})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.recentActivity}),(0,J.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:i.changedFiles.replace(`{{count}}`,String(S.fingerprint.changedFileCount))})]}),S.fingerprint.recentAreas.length>0?(0,J.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,J.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.recentAreas}),(0,J.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:S.fingerprint.recentAreas.map(e=>(0,J.jsx)(`code`,{className:`rounded-md bg-surface-hover px-2 py-1 text-xs text-fg`,children:e},e))})]}):null]}),(0,J.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,J.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,J.jsx)(A,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.willRead}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:i.willReadValue})]})]}),(0,J.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,J.jsx)(ae,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.willIgnore}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:i.willIgnoreValue})]})]}),(0,J.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,J.jsx)(V,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,J.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:S.remoteModel?i.providerDisclosure.replace(`{{provider}}`,S.provider):i.localDisclosure})]})]})]}),z?(0,J.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:z}):null,(0,J.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,J.jsx)(U,{type:`button`,variant:`primary`,className:`h-11 flex-1`,disabled:L,onClick:()=>v(`connectors`),children:i.continueToConnectors}),(0,J.jsx)(U,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:L,onClick:Q.pick,children:i.changeFolder})]}),(0,J.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void Ye(),children:i.skip})]}):null,_===`connectors`?(0,J.jsx)(ke,{busy:L,onBack:nt,onContinue:tt,onSkip:()=>void Ye(),onConnectedSignalsChange:we}):null,_===`running`&&F?(0,J.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,J.jsxs)(`div`,{className:`text-center`,children:[(0,J.jsx)(`p`,{className:`mb-2 text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:i.understandingStepEyebrow}),(0,J.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:i.analyzingTitle}),(0,J.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:i.analyzingSubtitle}),_e.total>1?(0,J.jsx)(`p`,{className:`mt-2 text-sm font-medium text-accent-fg`,children:i.analyzingFolderProgress.replace(`{{current}}`,String(_e.current)).replace(`{{total}}`,String(_e.total))}):null]}),(0,J.jsx)(ye,{signals:He,ariaLabel:i.sourceSignals.ariaLabel,centerLabel:i.sourceSignals.centerLabel}),(0,J.jsx)(`div`,{className:`xopc-understanding-progress mx-auto mt-6 grid max-w-[34rem] grid-cols-3 gap-2`,children:Re.map((e,t)=>{let n=Math.max(0,Re.indexOf(F.stage??`folder_structure`)),r=t<n,a=t===n;return(0,J.jsxs)(`div`,{className:`xopc-understanding-step min-w-0 text-left`,"data-active":a||void 0,"data-complete":r||void 0,children:[(0,J.jsx)(`span`,{className:H(`block h-1 rounded-full`,a||r?`bg-accent`:`bg-surface-hover`)}),(0,J.jsx)(`span`,{className:H(`mt-2 block text-[11px] leading-4`,a?`font-medium text-fg`:`text-fg-muted`),children:i.stages[e]})]},e)})}),(0,J.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:F.rootPath}),(0,J.jsx)(`p`,{className:`mx-auto mt-4 max-w-lg text-center text-xs leading-5 text-fg-muted`,children:i.backgroundChoiceHint}),(0,J.jsxs)(`div`,{className:`mx-auto mt-5 flex max-w-md flex-col gap-3`,children:[(0,J.jsx)(U,{type:`button`,variant:`secondary`,className:`h-11 w-full`,onClick:et,children:i.continueInBackground}),(0,J.jsx)(`button`,{type:`button`,className:`mx-auto text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void $e(),children:i.cancelAnalysis})]})]}):null,_===`recognition`&&F?.result?(0,J.jsx)(he,{run:F,language:r,busy:L,error:z,onFinish:it,onStartConversation:at},F.id):null,_===`recommendation`&&F?.result&&$?(0,J.jsxs)(`section`,{"aria-labelledby":`work-discovery-recommendation-title`,children:[(0,J.jsxs)(`div`,{className:`text-center`,children:[(0,J.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:i.understandingConfirmed}),(0,J.jsx)(`h1`,{id:`work-discovery-recommendation-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:i.primaryRecommendationTitle})]}),ut,(0,J.jsx)(`article`,{className:`mt-7 rounded-xl border border-edge bg-surface-panel p-5 shadow-surface sm:p-7`,children:(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,J.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-surface-hover text-fg-muted`,children:(0,J.jsx)(m,{className:`size-5`})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:$.title}),(0,J.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:$.rationale}),(0,J.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 text-xs`,children:[(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-surface-hover px-2.5 py-1 text-fg-muted`,children:[(0,J.jsx)(ee,{className:`size-3.5`}),i.estimatedMinutes.replace(`{{count}}`,String($.estimatedMinutes))]}),(0,J.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-fg-muted`,children:st($.risk)})]}),(0,J.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base px-4 py-3`,children:[(0,J.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.expectedTask}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg`,children:$.expectedTask})]}),(0,J.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,J.jsx)(U,{variant:`primary`,className:`h-10 px-4`,onClick:()=>void rt($,!1),children:i.startRecommendedAction}),(0,J.jsx)(U,{className:`h-10 px-4`,variant:`secondary`,onClick:()=>void rt($,!0),children:i.explainFirst})]})]})]})}),ot.length>0?(0,J.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between py-2 text-sm font-medium text-fg-muted hover:text-fg`,onClick:()=>se(e=>!e),children:[i.otherDirections,(0,J.jsx)(p,{className:`size-4 transition-transform ${ie?`rotate-180`:``}`})]}),ie?(0,J.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-panel px-4`,children:ot.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 py-4 text-left`,onClick:()=>void rt(e,!0),children:[(0,J.jsx)(m,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title}),(0,J.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e.expectedTask})]})]},e.id))}):null]}):null,(0,J.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,J.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Ze(F.conversationId),children:i.doSomethingElse}),(0,J.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>v(`recognition`),children:i.correctUnderstanding})]})]}):null,_===`error`&&F?(0,J.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,J.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,J.jsx)(ae,{className:`size-5`})}),(0,J.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:i.errorTitle}),(0,J.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:F.errorMessage}),(0,J.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,J.jsx)(U,{variant:`primary`,className:`h-11 flex-1`,onClick:()=>void x(F.id).then(Z),children:i.retry}),(0,J.jsx)(U,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{I(null),T(null),v(`intro`)},children:i.chooseDifferent})]}),(0,J.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Ze(F.conversationId),children:i.openConversation})]}):null]},_),Q.hasNativePicker?null:(0,J.jsx)(g,{open:Q.modalOpen,onOpenChange:Q.setModalOpen,initialAbsolutePath:S?.canonicalRootPath,onConfirm:Q.confirmPick,wd:l})]})}export{Le as n,W as r,Ve as t};
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=20260910-1" />
|
|
12
12
|
<link rel="manifest" href="/site.webmanifest?v=20260910-1" />
|
|
13
13
|
<title>XOPC — Keep what matters moving.</title>
|
|
14
|
-
<script type="module" crossorigin src="/assets/index-
|
|
14
|
+
<script type="module" crossorigin src="/assets/index-DUo6H0PC.js"></script>
|
|
15
15
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-aKtaBQYM.js">
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assets/diagnostics-Bo0Z42P_.js">
|
|
17
17
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-BOUWij0V.js">
|
|
@@ -219,7 +219,7 @@
|
|
|
219
219
|
<link rel="modulepreload" crossorigin href="/assets/page-context-draft-Cr5GqS2D.js">
|
|
220
220
|
<link rel="modulepreload" crossorigin href="/assets/management-api-B5w5DdXH.js">
|
|
221
221
|
<link rel="modulepreload" crossorigin href="/assets/side-chat-shortcut-BIw-1TTD.js">
|
|
222
|
-
<link rel="modulepreload" crossorigin href="/assets/chat-page-
|
|
222
|
+
<link rel="modulepreload" crossorigin href="/assets/chat-page-CalELOKj.js">
|
|
223
223
|
<link rel="modulepreload" crossorigin href="/assets/arrow-right-DSSvoX71.js">
|
|
224
224
|
<link rel="modulepreload" crossorigin href="/assets/browser-notification-delivery-DmE2FgGc.js">
|
|
225
225
|
<link rel="modulepreload" crossorigin href="/assets/unlink-BEuthaaq.js">
|
|
@@ -229,12 +229,12 @@
|
|
|
229
229
|
<link rel="modulepreload" crossorigin href="/assets/capability-links-MZdYfPKx.js">
|
|
230
230
|
<link rel="modulepreload" crossorigin href="/assets/browser-BLJWD7WI.js">
|
|
231
231
|
<link rel="modulepreload" crossorigin href="/assets/capability-icon-CmvCZOJX.js">
|
|
232
|
-
<link rel="modulepreload" crossorigin href="/assets/agent-plugin-dialog-
|
|
232
|
+
<link rel="modulepreload" crossorigin href="/assets/agent-plugin-dialog-C_rlXuEe.js">
|
|
233
233
|
<link rel="modulepreload" crossorigin href="/assets/extension-marketplace-api-BIzkukYp.js">
|
|
234
|
-
<link rel="modulepreload" crossorigin href="/assets/service-recommendation-list-
|
|
234
|
+
<link rel="modulepreload" crossorigin href="/assets/service-recommendation-list-BmRtbJz2.js">
|
|
235
235
|
<link rel="modulepreload" crossorigin href="/assets/understanding-activity-store-BFc8PamJ.js">
|
|
236
236
|
<link rel="modulepreload" crossorigin href="/assets/plug-zap-L8NMe3Sv.js">
|
|
237
|
-
<link rel="modulepreload" crossorigin href="/assets/work-discovery-page-
|
|
237
|
+
<link rel="modulepreload" crossorigin href="/assets/work-discovery-page-8XciWNs5.js">
|
|
238
238
|
<link rel="modulepreload" crossorigin href="/assets/box-DvYoGszj.js">
|
|
239
239
|
<link rel="modulepreload" crossorigin href="/assets/braces-Cfmtagno.js">
|
|
240
240
|
<link rel="modulepreload" crossorigin href="/assets/understanding-refresh-store-CdEfR40A.js">
|
|
@@ -292,7 +292,7 @@
|
|
|
292
292
|
<link rel="modulepreload" crossorigin href="/assets/preference-select-fields-D1pZekPs.js">
|
|
293
293
|
<link rel="modulepreload" crossorigin href="/assets/navigation-ByOzYT0t.js">
|
|
294
294
|
<link rel="modulepreload" crossorigin href="/assets/page-tabs-oeTY7z3_.js">
|
|
295
|
-
<link rel="modulepreload" crossorigin href="/assets/route-preload-
|
|
295
|
+
<link rel="modulepreload" crossorigin href="/assets/route-preload-ChTaYgpA.js">
|
|
296
296
|
<link rel="modulepreload" crossorigin href="/assets/use-personal-profile-C1vqD9yV.js">
|
|
297
297
|
<link rel="modulepreload" crossorigin href="/assets/personal-avatar-BMRVyTrE.js">
|
|
298
298
|
<link rel="modulepreload" crossorigin href="/assets/project-understanding-Cg8WbBNB.js">
|
package/dist/package.js
CHANGED
|
@@ -5,10 +5,10 @@ import { abortEmbeddedRun } from "./runs.js";
|
|
|
5
5
|
import { filterExecutionTools, resolveExecutionToolPolicy } from "./execution-tool-policy.js";
|
|
6
6
|
import { deferredToolContract, getXopcToolMetadata } from "./tool-metadata.js";
|
|
7
7
|
import { isCodemodeCoreRead } from "../tools/codemode-permissions.js";
|
|
8
|
-
import { getExternalToolRegistry } from "../external-tools/tool-registry.js";
|
|
9
|
-
import { createEmbeddedModelRuntime, resolveEmbeddedProviderApiKeySync } from "./model-runtime.js";
|
|
10
8
|
import { getNativePiAgentDir } from "../mcp/native-mcp.js";
|
|
9
|
+
import { createEmbeddedModelRuntime, resolveEmbeddedProviderApiKeySync } from "./model-runtime.js";
|
|
11
10
|
import { createXopcMcpTransport } from "../mcp/transport.js";
|
|
11
|
+
import { getExternalToolRegistry } from "../external-tools/tool-registry.js";
|
|
12
12
|
import { createAutomationMcpSourceGuard } from "../../automations/mcp-source.js";
|
|
13
13
|
import { createXopcCodemodeExtension } from "./codemode-extension.js";
|
|
14
14
|
import { guardSessionManager } from "./session-tool-result-guard.js";
|
|
@@ -11,6 +11,7 @@ import { listConnectorInstances } from "../../connectors/instances.js";
|
|
|
11
11
|
import { parseExternalToolRef } from "./refs.js";
|
|
12
12
|
import { getStoreConnectorInstallPlan, parseStoreConnectorCandidateRef } from "../../capabilities/store-connector.js";
|
|
13
13
|
import { createPersonalRequestExecutionAuthorizer } from "../../personal-agent/request-access.js";
|
|
14
|
+
import { resolvePluginConnectionCandidate } from "../../connectors/plugin-connection.js";
|
|
14
15
|
import { resolveConnectionCandidate } from "../../connectors/connection-candidates.js";
|
|
15
16
|
import { ExternalToolService } from "./service.js";
|
|
16
17
|
import { EXTERNAL_TOOL_SOURCES } from "./types.js";
|
|
@@ -203,7 +204,7 @@ function createExternalToolGatewayTools(providers, getContext, getConfig, getExe
|
|
|
203
204
|
name: EXTERNAL_TOOL_NAMES.requireConnection,
|
|
204
205
|
label: "Connect app",
|
|
205
206
|
parameters: requireSchema,
|
|
206
|
-
description: "Use
|
|
207
|
+
description: "Use when the user asks to connect a specific integration, or a requested read cannot proceed because authorization, installation or account selection is required. Available authorized tools should be executed directly without asking the user to confirm the read. Request an exact connectionCandidates or installCandidates entry returned by tool_search, or an exact managedIntegrations entry returned by mcp_setup discover. Explain the verified need once before calling. This saves and pauses the objective, displays one action area above the input, and lets the host resume automatically after the required user action. Stop this turn after connection_required; never ask the user to reply continue after authorization. Never invent a candidate reference, return OAuth URLs, or repeat a skipped request. If another objective is waiting, do not create a duplicate objective.",
|
|
207
208
|
async execute(_id, params) {
|
|
208
209
|
const context = getContext?.();
|
|
209
210
|
if (!context) throw new Error("No active conversation.");
|
|
@@ -219,6 +220,7 @@ function createExternalToolGatewayTools(providers, getContext, getConfig, getExe
|
|
|
219
220
|
principalId: principal.principalId,
|
|
220
221
|
connectorId: need.target.connectorId
|
|
221
222
|
}).some((connection) => connection.id === need.connectionId && connection.status === "active");
|
|
223
|
+
if (need.target.type === "plugin") return need.key === item.candidateRef && Boolean(need.connectionId);
|
|
222
224
|
const storeTarget = parseStoreConnectorCandidateRef(item.candidateRef);
|
|
223
225
|
return Boolean(storeTarget && need.target.packageName === storeTarget.packageName && need.target.version === storeTarget.version && need.connectionId);
|
|
224
226
|
});
|
|
@@ -236,6 +238,11 @@ function createExternalToolGatewayTools(providers, getContext, getConfig, getExe
|
|
|
236
238
|
needs: await Promise.all(params.requirements.map(async (item) => {
|
|
237
239
|
const storeRef = parseStoreConnectorCandidateRef(item.candidateRef);
|
|
238
240
|
const config = getConfig?.();
|
|
241
|
+
const plugin = await resolvePluginConnectionCandidate(item.candidateRef, config);
|
|
242
|
+
if (plugin) {
|
|
243
|
+
if (item.accountId || item.accountSelector) throw new Error("Choose the plugin account in its connection form.");
|
|
244
|
+
return plugin;
|
|
245
|
+
}
|
|
239
246
|
const plan = storeRef && config ? await getStoreConnectorInstallPlan(config, storeRef.packageName, storeRef.version) : void 0;
|
|
240
247
|
if (plan && !plan.definition.provenance) throw new Error("Store Connector provenance is unavailable.");
|
|
241
248
|
const need = plan ? {
|
|
@@ -3,13 +3,14 @@ import { init_logger } from "../../utils/logger.js";
|
|
|
3
3
|
import { checkUrlSafety } from "../tools/url-safety.js";
|
|
4
4
|
import { isManagedConnectorServer } from "../../connectors/materialize.js";
|
|
5
5
|
import { resolveMcpSetupConfig } from "./effective-server.js";
|
|
6
|
+
import { classifyMcpConnectionError } from "./connection-errors.js";
|
|
6
7
|
import { prepareNativeMcpConfig } from "./native-mcp.js";
|
|
7
8
|
import { retryAfter } from "./transport.js";
|
|
8
9
|
import { McpAuthenticationRequiredError, discoverMcpTools, signInNativeMcp } from "./tool-catalog.js";
|
|
9
|
-
import { classifyMcpConnectionError } from "./connection-errors.js";
|
|
10
10
|
import { createHash, randomUUID } from "node:crypto";
|
|
11
11
|
import { lookup } from "node:dns";
|
|
12
12
|
import { Agent } from "undici";
|
|
13
|
+
import { buildAuthorizationServerDiscoveryUrls, parseWwwAuthenticate, selectResource } from "@earendil-works/pi-mcp/oauth";
|
|
13
14
|
//#region src/agent/mcp/connection-setup.ts
|
|
14
15
|
init_logger();
|
|
15
16
|
const log = createLogger("McpConnectionSetup");
|
|
@@ -79,7 +80,7 @@ async function metadata(url, endpoint, signal, publicOnly = false) {
|
|
|
79
80
|
await dispatcher.close();
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
|
-
async function authentication(config, workspace, serverId,
|
|
83
|
+
async function authentication(config, workspace, serverId, failure, options) {
|
|
83
84
|
const entry = (await prepareNativeMcpConfig(config, workspace)).servers.find((s) => s.name === serverId);
|
|
84
85
|
if (!entry || !("url" in entry.config)) return {
|
|
85
86
|
method: "unknown",
|
|
@@ -91,65 +92,68 @@ async function authentication(config, workspace, serverId, challenge, options) {
|
|
|
91
92
|
try {
|
|
92
93
|
if (typeof value !== "string") return false;
|
|
93
94
|
const issuer = httpUrl(value);
|
|
94
|
-
return issuer.protocol === "https:" && checkUrlSafety(issuer.href).safe || !publicOnly && issuer.origin === url.origin && [
|
|
95
|
+
return !issuer.hash && (issuer.protocol === "https:" && checkUrlSafety(issuer.href).safe || !publicOnly && issuer.origin === url.origin && [
|
|
95
96
|
"localhost",
|
|
96
97
|
"127.0.0.1",
|
|
97
98
|
"[::1]"
|
|
98
|
-
].includes(issuer.hostname);
|
|
99
|
+
].includes(issuer.hostname));
|
|
99
100
|
} catch {
|
|
100
101
|
return false;
|
|
101
102
|
}
|
|
102
103
|
};
|
|
103
|
-
challenge
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
new URL(`/.well-known/oauth-protected-resource${url.pathname === "/" ? "" : url.pathname}`, url),
|
|
108
|
-
new URL("/.well-known/oauth-protected-resource", url)
|
|
109
|
-
];
|
|
104
|
+
const challenge = failure?.challenge;
|
|
105
|
+
const { resourceMetadataUrl } = parseWwwAuthenticate(challenge);
|
|
106
|
+
const suffix = url.pathname.replace(/\/$/, "");
|
|
107
|
+
const candidates = resourceMetadataUrl ? [resourceMetadataUrl] : [new URL(`/.well-known/oauth-protected-resource${suffix}`, url), new URL("/.well-known/oauth-protected-resource", url)];
|
|
110
108
|
let state = "absent";
|
|
111
|
-
|
|
109
|
+
const unknown = (metadata, retryAt) => ({
|
|
110
|
+
method: "unknown",
|
|
111
|
+
metadata,
|
|
112
|
+
retryAt
|
|
113
|
+
});
|
|
114
|
+
const read = async (target) => {
|
|
112
115
|
options?.signal?.throwIfAborted();
|
|
113
116
|
options?.diagnostics?.beforeRequest?.({
|
|
114
117
|
method: "GET",
|
|
115
118
|
stage: "authorization_metadata"
|
|
116
119
|
});
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
return metadata(target, url, options?.signal, publicOnly);
|
|
121
|
+
};
|
|
122
|
+
let issuer;
|
|
123
|
+
for (const candidate of new Map(candidates.map((c) => [c.href, c])).values()) {
|
|
124
|
+
if (!allowedIssuer(candidate.href)) {
|
|
125
|
+
state = "invalid";
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const result = await read(candidate);
|
|
129
|
+
if (result.retryAt) return unknown(result.state, result.retryAt);
|
|
123
130
|
if (result.state !== "absent") state = result.state;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
if (!result.data) continue;
|
|
132
|
+
const { resource, authorization_servers: servers } = result.data;
|
|
133
|
+
const advertisedIssuer = Array.isArray(servers) ? servers[0] : void 0;
|
|
134
|
+
if (typeof resource === "string" && typeof advertisedIssuer === "string" && allowedIssuer(advertisedIssuer)) try {
|
|
135
|
+
selectResource(url, { resource });
|
|
136
|
+
issuer = advertisedIssuer;
|
|
137
|
+
break;
|
|
138
|
+
} catch {}
|
|
139
|
+
state = "invalid";
|
|
130
140
|
}
|
|
131
|
-
if (
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const result = await
|
|
137
|
-
if (result.retryAt) return
|
|
138
|
-
|
|
139
|
-
metadata: result.state,
|
|
140
|
-
retryAt: result.retryAt
|
|
141
|
-
};
|
|
141
|
+
if (!issuer && failure?.status === 401 && !resourceMetadataUrl && state === "absent" && /^\s*Bearer(?:\s|$)/i.test(challenge ?? "") && allowedIssuer(url.origin)) issuer = url.origin;
|
|
142
|
+
if (!issuer) return unknown(resourceMetadataUrl && state === "absent" ? "invalid" : state);
|
|
143
|
+
const fromResource = state === "valid";
|
|
144
|
+
state = "absent";
|
|
145
|
+
for (const { url: target } of buildAuthorizationServerDiscoveryUrls(issuer)) {
|
|
146
|
+
const result = await read(target);
|
|
147
|
+
if (result.retryAt) return unknown(result.state, result.retryAt);
|
|
148
|
+
if (result.state !== "absent") state = result.state;
|
|
142
149
|
const data = result.data;
|
|
143
|
-
if (data && data.issuer ===
|
|
150
|
+
if (data && typeof data.issuer === "string" && data.issuer.replace(/\/$/, "") === issuer.replace(/\/$/, "") && allowedIssuer(data.authorization_endpoint) && allowedIssuer(data.token_endpoint) && (!Array.isArray(data.code_challenge_methods_supported) || data.code_challenge_methods_supported.includes("S256"))) return {
|
|
144
151
|
method: "oauth",
|
|
145
152
|
metadata: "valid"
|
|
146
153
|
};
|
|
147
|
-
if (
|
|
154
|
+
if (data) return unknown("invalid");
|
|
148
155
|
}
|
|
149
|
-
return
|
|
150
|
-
method: "unknown",
|
|
151
|
-
metadata: state
|
|
152
|
-
};
|
|
156
|
+
return unknown(fromResource && state === "absent" ? "invalid" : state);
|
|
153
157
|
}
|
|
154
158
|
async function probeMcpConnection(config, workspace, serverId, options) {
|
|
155
159
|
config = resolveMcpSetupConfig(config, serverId);
|
|
@@ -204,7 +208,7 @@ async function probeMcpConnection(config, workspace, serverId, options) {
|
|
|
204
208
|
};
|
|
205
209
|
}
|
|
206
210
|
try {
|
|
207
|
-
const auth = await authentication(config, workspace, serverId,
|
|
211
|
+
const auth = await authentication(config, workspace, serverId, failed, options);
|
|
208
212
|
return {
|
|
209
213
|
state: auth.method === "oauth" ? "oauth_required" : "auth_unknown",
|
|
210
214
|
auth: {
|
|
@@ -13,6 +13,7 @@ import { McpConnectionDrafts, McpDraftError, mcpConfigRevision } from "./connect
|
|
|
13
13
|
import { weixinSetupScope } from "./weixin-setup-scope.js";
|
|
14
14
|
import { localExecutionSchema, secretFieldsSchema } from "./setup-plan.js";
|
|
15
15
|
import { McpDiscovery, createMcpResearch } from "./discovery.js";
|
|
16
|
+
import { findManagedMcpIntegrations } from "./managed-discovery.js";
|
|
16
17
|
import { createHash, randomUUID } from "node:crypto";
|
|
17
18
|
import { z } from "zod";
|
|
18
19
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
@@ -76,7 +77,7 @@ var McpConversationSetup = class {
|
|
|
76
77
|
readConfig: options.readConfig,
|
|
77
78
|
saveConfig: options.saveConfig
|
|
78
79
|
});
|
|
79
|
-
this.discovery = new McpDiscovery(options.research ?? createMcpResearch(options.readConfig));
|
|
80
|
+
this.discovery = new McpDiscovery(options.research ?? createMcpResearch(options.readConfig), (name, context) => findManagedMcpIntegrations(options.readConfig(), name, context.signal, !context.managementOrigin));
|
|
80
81
|
}
|
|
81
82
|
notify(goal) {
|
|
82
83
|
try {
|
|
@@ -111,7 +112,7 @@ var McpConversationSetup = class {
|
|
|
111
112
|
}
|
|
112
113
|
canProvideToken(goal) {
|
|
113
114
|
const url = new URL(goal.url);
|
|
114
|
-
return (goal.phase === "auth_unknown" || goal.phase === "blocked" && goal.errorCode === "access_denied") && !goal.tokenProvider && !goal.secretProviders && (url.protocol === "https:" || [
|
|
115
|
+
return !goal.publicOnly && (goal.phase === "auth_unknown" || goal.phase === "blocked" && goal.errorCode === "access_denied") && !goal.tokenProvider && !goal.secretProviders && (url.protocol === "https:" || [
|
|
115
116
|
"127.0.0.1",
|
|
116
117
|
"localhost",
|
|
117
118
|
"[::1]"
|
|
@@ -150,7 +151,7 @@ var McpConversationSetup = class {
|
|
|
150
151
|
managementPath: goal.channel ? `${goal.channel.origin}/#/capabilities/connectors?tab=connected` : "/capabilities/connectors?tab=connected",
|
|
151
152
|
continuationQueued: goal.resumed === true,
|
|
152
153
|
replyDelivery: goal.reply?.status,
|
|
153
|
-
instruction: goal.phase === "cancelled" ? "This setup is cancelled. Do not continue or revive it. Cancellation does not undo configuration already saved." : expired ? "This request expired. Start a new objective instead of reusing authorization." : goal.phase === "approval_required" ? goal.channel ? "Send the exact trusted interactionPath to the user. The paired Weixin user has requested this service; an authenticated Gateway owner must approve this exact request on that page before any probe, credential submission or configuration change. Never ask for keys, callback URLs or a continue reply in chat. The result returns to this original Weixin conversation automatically." : `Copy ${interactionLink} verbatim. The owner must review this exact publisher source or local execution plan before any probe, credential submission or execution. Do not ask for secrets or an additional continue reply in chat.` : this.canProvideToken(goal) ? `The service refused access. Copy this Markdown link verbatim for secure first-time Token input: ${interactionLink} . Never rewrite its destination as xopc://workspace or add an origin. A refusal alone does not prove a missing Token; service or account permissions may also block access. Do not request secrets in chat or repeatedly retry.` : goal.phase === "blocked" ? "The connection check failed. Report the safe error code and the remaining blocker. Do not repeatedly retry without resolving the cause." : goal.reloadRequired ? "Configuration is saved but runtime reload failed. Report the partial result and require a Gateway restart; do not claim the tools are active or tested." : goal.phase === "ready" ? "Configuration is saved. The host queues the original objective once in a fresh turn. If this is that continuation, discover native tools by the exact server namespace and finish the original objective; otherwise stop and let the queued continuation run. Do not repeat installation or invent a successful read." : goal.phase === "planned" ? "Continue automatic steps with advance and the returned version." : `Copy this Markdown link verbatim for authorization or Token input: ${interactionLink} . Never rewrite its destination as xopc://workspace or add an origin. Then stop this turn. The host resumes automatically; never ask for credentials, callback URLs or a continue reply in chat.`
|
|
154
|
+
instruction: goal.phase === "cancelled" ? "This setup is cancelled. Do not continue or revive it. Cancellation does not undo configuration already saved." : expired ? "This request expired. Start a new objective instead of reusing authorization." : goal.phase === "approval_required" ? goal.channel ? "Send the exact trusted interactionPath to the user. The paired Weixin user has requested this service; an authenticated Gateway owner must approve this exact request on that page before any probe, credential submission or configuration change. Never ask for keys, callback URLs or a continue reply in chat. The result returns to this original Weixin conversation automatically." : `Copy ${interactionLink} verbatim. The owner must review this exact publisher source or local execution plan before any probe, credential submission or execution. Do not ask for secrets or an additional continue reply in chat.` : this.canProvideToken(goal) ? `The service refused access. Copy this Markdown link verbatim for secure first-time Token input: ${interactionLink} . Never rewrite its destination as xopc://workspace or add an origin. A refusal alone does not prove a missing Token; service or account permissions may also block access. Do not request secrets in chat or repeatedly retry.` : goal.phase === "auth_unknown" ? `Authentication could not be verified. Link ${interactionLink} to review the connection, but do not ask for a Token or claim OAuth works. Check the official guide and exact endpoint.` : goal.phase === "blocked" ? "The connection check failed. Report the safe error code and the remaining blocker. Do not repeatedly retry without resolving the cause." : goal.reloadRequired ? "Configuration is saved but runtime reload failed. Report the partial result and require a Gateway restart; do not claim the tools are active or tested." : goal.phase === "ready" ? "Configuration is saved. The host queues the original objective once in a fresh turn. If this is that continuation, discover native tools by the exact server namespace and finish the original objective; otherwise stop and let the queued continuation run. Do not repeat installation or invent a successful read." : goal.phase === "planned" ? "Continue automatic steps with advance and the returned version." : `Copy this Markdown link verbatim for authorization or Token input: ${interactionLink} . Never rewrite its destination as xopc://workspace or add an origin. Then stop this turn. The host resumes automatically; never ask for credentials, callback URLs or a continue reply in chat.`
|
|
154
155
|
};
|
|
155
156
|
}
|
|
156
157
|
cancelGoal(goal) {
|
|
@@ -223,7 +224,10 @@ var McpConversationSetup = class {
|
|
|
223
224
|
dryRun: true,
|
|
224
225
|
instruction: "Discovery and candidate state were not changed."
|
|
225
226
|
};
|
|
226
|
-
return this.discovery.command(command, input,
|
|
227
|
+
return this.discovery.command(command, input, {
|
|
228
|
+
...context,
|
|
229
|
+
managementOrigin: channel?.origin
|
|
230
|
+
});
|
|
227
231
|
}
|
|
228
232
|
if (command === "inspect") {
|
|
229
233
|
z.object({}).strict().parse(input);
|
|
@@ -471,7 +475,8 @@ var McpConversationSetup = class {
|
|
|
471
475
|
this.save(goal);
|
|
472
476
|
}
|
|
473
477
|
}
|
|
474
|
-
|
|
478
|
+
const missingDocumentedCredential = goal.authentication === "bearer" && !goal.secretFields?.length && !goal.tokenProvider && !goal.secretProviders?.token || goal.secretFields?.some((field) => !goal.secretProviders?.[field.id]);
|
|
479
|
+
if (!goal.publicOnly && missingDocumentedCredential) {
|
|
475
480
|
goal.phase = "token_required";
|
|
476
481
|
goal.errorCode = void 0;
|
|
477
482
|
this.save(goal);
|
|
@@ -507,7 +512,7 @@ var McpConversationSetup = class {
|
|
|
507
512
|
this.current(goal);
|
|
508
513
|
const key = `${request?.method ?? "GET"}:${request?.stage ?? "metadata"}`;
|
|
509
514
|
goal.requestCounts ??= {};
|
|
510
|
-
if ((goal.requestCounts[key] ?? 0) >= 3) throw new Error("MCP retry budget exhausted for this protocol stage");
|
|
515
|
+
if ((goal.requestCounts[key] ?? 0) >= (request?.stage === "authorization_metadata" ? 8 : 3)) throw new Error("MCP retry budget exhausted for this protocol stage");
|
|
511
516
|
goal.requestCounts[key] = (goal.requestCounts[key] ?? 0) + 1;
|
|
512
517
|
this.goals.set(goal.id, goal);
|
|
513
518
|
} });
|
|
@@ -518,7 +523,7 @@ var McpConversationSetup = class {
|
|
|
518
523
|
recovery: probe.recovery
|
|
519
524
|
};
|
|
520
525
|
if (probe.state !== "connected") {
|
|
521
|
-
goal.phase = probe.state === "error" ? "blocked" : probe.state;
|
|
526
|
+
goal.phase = goal.publicOnly && missingDocumentedCredential && probe.state === "auth_unknown" && probe.auth?.metadata === "absent" && [401, 403].includes(probe.observation?.status ?? 0) && !probe.observation?.contentType.includes("html") ? "token_required" : probe.state === "error" ? "blocked" : probe.state;
|
|
522
527
|
goal.errorCode = probe.state === "token_required" && (goal.tokenProvider || goal.secretProviders) ? "credential_rejected" : probe.errorCode;
|
|
523
528
|
if ((probe.recovery?.kind === "wait" || [
|
|
524
529
|
"network",
|
|
@@ -833,7 +838,7 @@ var McpConversationSetup = class {
|
|
|
833
838
|
}
|
|
834
839
|
}
|
|
835
840
|
async resumePending(runtimeReloaded = false) {
|
|
836
|
-
for (const goal of this.goals.values().filter((item) => item.phase === "blocked" && item.nextRetryAt)) try {
|
|
841
|
+
for (const goal of this.goals.values().filter((item) => (item.phase === "blocked" || item.phase === "auth_unknown") && item.nextRetryAt)) try {
|
|
837
842
|
this.current(goal);
|
|
838
843
|
this.scheduleRetry(goal);
|
|
839
844
|
} catch {}
|