@agenthippo-ai/agenthippo 1.110.39 → 1.110.41
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/out/cli/index.js +168 -168
- package/out/extension.js +1 -1
- package/out/runtime/vscode/vscode-config-provider.js +1 -1
- package/package.json +1 -1
package/out/extension.js
CHANGED
|
@@ -21,7 +21,7 @@ This will open a pull request on the store repository.`:`Submit Spotlight view "
|
|
|
21
21
|
|
|
22
22
|
This will create a pull request from your fork.`,{modal:!0},"Submit PR")!=="Submit PR")return;const N=await vscode.window.withProgress({location:vscode.ProgressLocation.Window,title:`Publishing Spotlight view ${$.id} v${I}`,cancellable:!1},async P=>(P.report({message:b?`Publishing to ${a.owner}/${a.repo}...`:"Preparing fork..."}),await o({type:"view",slug:$.id,version:I,files:D,changelog:g},e)));await vscode.window.showInformationMessage(`Published Spotlight view "${$.name}" v${I}! PR created.`,"View PR")==="View PR"&&vscode.env.openExternal(vscode.Uri.parse(N.prUrl))}catch(f){const w=f instanceof Error?f.message:String(f);log(e,`[AgentIDE] Spotlight publish error: ${w}`),showError(`${branding_1.AGENTIDE_BRAND_NAME}: ${w}`)}})),t.subscriptions.push(vscode.commands.registerCommand("agentide.store.install",async n=>{await(0,githubStoreGate_js_1.ensureGitHubStoreAccess)(t);const{parseStoreUrl:s}=await import("./store/index.js");let c=n;if(c||(c=await vscode.window.showInputBox({prompt:"Enter store URL or GitHub link",placeHolder:"e.g., engine/gemini or https://github.com/.../engines/gemini",validateInput:i=>i.trim()?i.includes("/")?null:"Expected: type/slug, or GitHub URL":"Please enter a URL"})),!!c)try{const i=s(c);switch(i.type){case"pack":await vscode.commands.executeCommand("agentide.pack.storeInstall",i);break;case"skill":await vscode.commands.executeCommand("agentide.skill.install",i);break;case"mcp":await vscode.commands.executeCommand("agentide.mcp.install",i);break;case"engine":await vscode.commands.executeCommand("agentide.engine.install",i);break;case"view":await vscode.commands.executeCommand("agentide.view.install",i);break}}catch(i){const l=i instanceof Error?i.message:String(i);log(e,`[AgentIDE] Store install error: ${l}`),showError(`AgentIDE: ${l}`)}})),t.subscriptions.push(vscode.commands.registerCommand("agentide.store.find",async n=>{await(0,githubStoreGate_js_1.ensureGitHubStoreAccess)(t);const{isStoreUrl:s,parseStoreUrl:c,parseGitHubUrl:i,detectArtifactType:l}=await import("./store/index.js"),{searchMerged:u,listMergedArtifacts:d}=await import("./store/oramaIndex.js");let o,a="all";if(typeof n=="string"?o=n:n&&typeof n=="object"&&n.typeFilter&&(a=n.typeFilter),o)try{let b,v,N;if(s(o)){const R=c(o);b=R.type,v=R.slug,N=R.version}else{const R=i(o);b=await vscode.window.withProgress({location:vscode.ProgressLocation.Notification,title:"Detecting artifact type...",cancellable:!1},async()=>await l(R.owner,R.repo,R.ref,R.path,e));const P=(R.path||R.repo).split("/");v=P[P.length-1]||R.repo,N=R.ref}switch(b){case"pack":await vscode.commands.executeCommand("agentide.pack.storeInstall",{type:"pack",slug:v,version:N,sourceUrl:o});break;case"skill":await vscode.commands.executeCommand("agentide.skill.install",{type:"skill",slug:v,version:N,sourceUrl:o});break;case"mcp":await vscode.commands.executeCommand("agentide.mcp.install",{type:"mcp",slug:v,version:N,sourceUrl:o});break;case"engine":await vscode.commands.executeCommand("agentide.engine.install",{type:"engine",slug:v,version:N,sourceUrl:o});break;case"view":await vscode.commands.executeCommand("agentide.view.install",{type:"view",slug:v,version:N,sourceUrl:o});break}return}catch(b){const v=b instanceof Error?b.message:String(b);log(e,`[AgentIDE] Install error: ${v}`),showError(`AgentIDE: ${v}`);return}const{STORE_ICONS:p}=await import("./store/shared.js"),S={pack:p.pack,skill:p.skill,mcp:p.mcp,engine:p.engine,view:p.view},k=["all","pack","skill","mcp","engine","view"],y=vscode.window.createQuickPick();y.title=a==="view"?"Install Spotlight View":"Install Packs, Skills, MCP Tools, Engines, Spotlight Views",y.placeholder="Search or paste a GitHub URL to install...",y.matchOnDescription=!0,y.matchOnDetail=!0,y.busy=!0;let $=[],f=a,w;const I={local:p.local,remote:p.remote},g=b=>{const v=b??$,N=f==="all"?v:v.filter(_=>_.type===f),R=k.map(_=>({label:_==="all"?"$(list-flat) All":`${S[_]} ${_.charAt(0).toUpperCase()+_.slice(1)}s`,description:_===f?"$(check)":"",alwaysShow:!0,itemType:"filter",filter:_})),P=N.map(_=>{const L=_.source==="local"?I.local:I.remote,x=_.installed?"$(check)":"",U=[_.source==="local"?"Local":"Remote",_.type];x&&U.push(x);let O=_.description||_.path;return _.installedTo&&_.installedTo.length>0&&(O+=` \u2022 Installed to: ${_.installedTo.join(", ")}`),{label:`${L} ${S[_.type]} ${_.slug}`,description:U.join(" \u2022 "),detail:O,itemType:"artifact",artifact:_}});y.items=[...R,{label:"",kind:vscode.QuickPickItemKind.Separator,itemType:"filter"},...P]},D=async b=>{w&&clearTimeout(w);const v=b.trim();if(!v||v.startsWith("http")||v.startsWith("store://")||v.startsWith("github.com")){g($);return}w=setTimeout(async()=>{try{const P=(await u(v,{type:f==="all"?void 0:f,limit:50},e)).map(_=>({type:_.type,slug:_.slug,path:`${_.type}s/${_.slug}`,description:_.description,installed:_.installed,installedVersion:_.installedVersion,source:_.source,installedTo:_.installedTo}));g(P)}catch(N){log(e,`[AgentIDE] Search error: ${N instanceof Error?N.message:String(N)}`),g($)}},150)};y.onDidChangeValue(D);try{$=(await d(void 0,e)).map(v=>({type:v.type,slug:v.slug,path:`${v.type}s/${v.slug}`,description:v.description,installed:v.installed,installedVersion:v.installedVersion,source:v.source,installedTo:v.installedTo})),y.busy=!1,g(),$.length===0&&(y.placeholder="Store is empty or index not synced yet. Try again later!")}catch(b){const v=b instanceof Error?b.message:String(b);log(e,`[AgentIDE] Store browse error: ${v}`),y.hide(),showError(`AgentIDE: ${v}`);return}const M=b=>{const v=b.trim();return v.startsWith("https://")||v.startsWith("http://")||v.startsWith("github.com/")||v.startsWith("store://")};y.onDidAccept(async()=>{const b=y.selectedItems[0],v=y.value.trim();if(v&&M(v)){y.hide(),log(e,`[AgentIDE] Browse Store: detected URL input: ${v}`),await vscode.commands.executeCommand("agentide.store.find",v);return}if(b){if(b.itemType==="filter"&&b.filter){f=b.filter,g();return}if(b.itemType==="artifact"&&b.artifact){y.hide();const{artifact:N}=b;switch(N.type){case"pack":await vscode.commands.executeCommand("agentide.pack.storeInstall",{type:"pack",slug:N.slug});break;case"skill":await vscode.commands.executeCommand("agentide.skill.install",{type:"skill",slug:N.slug});break;case"mcp":await vscode.commands.executeCommand("agentide.mcp.install",{type:"mcp",slug:N.slug});break;case"engine":await vscode.commands.executeCommand("agentide.engine.install",{type:"engine",slug:N.slug});break;case"view":await vscode.commands.executeCommand("agentide.view.install",{type:"view",slug:N.slug});break}}}}),y.onDidHide(()=>y.dispose()),y.show()})),t.subscriptions.push(vscode.commands.registerCommand("agentide.store.search",async(n,s)=>{const{searchMerged:c}=await import("./store/oramaIndex.js");return c(n,s,e)})),t.subscriptions.push(vscode.commands.registerCommand("agentide.store.sync",async()=>{const{forceRefresh:n,getIndexMeta:s}=await import("./store/oramaIndex.js");await vscode.window.withProgress({location:vscode.ProgressLocation.Notification,title:"Syncing store index...",cancellable:!1},async()=>{await n(e)});const c=await s();c&&showInfo(`Store index synced: ${c.artifactCount} artifacts (updated ${new Date(c.generatedAt).toLocaleDateString()})`)})),t.subscriptions.push(vscode.commands.registerCommand("agentide.store.setup",async()=>{const{setupStoreAutomation:n}=await import("./store/github/setup.js"),s=await vscode.window.showInputBox({prompt:"Enter GitHub repository URL for your store",placeHolder:"https://github.com/owner/repo or owner/repo",validateInput:o=>o?o.match(/(?:github\.com\/)?([^/]+)\/([^/]+)/)?null:"Invalid format. Use: owner/repo or https://github.com/owner/repo":"Repository URL is required"});if(!s)return;const c=s.match(/(?:github\.com\/)?([^/]+)\/([^/]+)/);if(!c){showError("Invalid repository URL");return}const[,i,l]=c,u=l.replace(/\.git$/,""),d=await vscode.window.withProgress({location:vscode.ProgressLocation.Notification,title:`Setting up store automation for ${i}/${u}...`,cancellable:!1},async()=>await n(i,u,e));if(d.success&&d.pullRequestUrl){const o=vscode.workspace.getConfiguration("agentide"),a=`${i}/${u}`,p=o.get("storeRepo",""),S=o.get("store.indexUrl",""),k=`https://${i}.github.io/${u}`;let y="";if(p){const f=p.match(/^(?:https?:\/\/github\.com\/)?([^/]+)\/([^/]+?)(?:\.git)?$/);f&&(y=`https://${f[1]}.github.io/${f[2]}`)}await o.update("storeRepo",a,vscode.ConfigurationTarget.Global),(!S||y&&S===y)&&await o.update("store.indexUrl",k,vscode.ConfigurationTarget.Global);const $=await vscode.window.showInformationMessage(`\u{1F99B} ${d.message}`,"Open Pull Request","Copy URL");$==="Open Pull Request"?await vscode.env.openExternal(vscode.Uri.parse(d.pullRequestUrl)):$==="Copy URL"&&(await vscode.env.clipboard.writeText(d.pullRequestUrl),showInfo("Pull request URL copied to clipboard"))}else d.success||showError(`Setup failed: ${d.message}`)})),t.subscriptions.push(vscode.commands.registerCommand("agentide.pack.storeInstall",async n=>{const{workspaceRoot:s}=getWorkspaceRoot(e),{downloadFromStore:c,listStoreVersions:i}=await import("./store/index.js"),{getAgentRoot:l}=await import("./agentpack/paths.js"),u=n||{type:"pack",slug:"",version:void 0};if(!u.version){const y=await i("pack",u.slug);if(y.length===0)u.version="main";else{const $=await vscode.window.showQuickPick(y.map(f=>({label:f.version,description:f.isPrerelease?"(pre-release)":""})),{placeHolder:"Select version to install"});if(!$)return;u.version=$.label}}const d=l(s,u.slug);if(await fs_1.promises.access(d).then(()=>!0).catch(()=>!1)){if(await vscode.window.showWarningMessage(`Pack "${u.slug}" already exists. Overwrite?`,{modal:!0},"Overwrite","Cancel")!=="Overwrite")return;await fs_1.promises.rm(d,{recursive:!0,force:!0})}await vscode.window.withProgress({location:vscode.ProgressLocation.Window,title:`Installing pack "${u.slug}"`,cancellable:!1},async y=>{y.report({message:"Downloading from store..."});const $=await c({type:"pack",slug:u.slug,version:u.version},e);y.report({message:"Extracting files..."}),await fs_1.promises.mkdir(d,{recursive:!0});for(const f of $){const w=path.join(d,f.path);await fs_1.promises.mkdir(path.dirname(w),{recursive:!0}),await fs_1.promises.writeFile(w,f.content)}}),await vscode.commands.executeCommand("agentide.packsChanged");const{getRegistry:a}=await import("./registry/index.js");await a(e).registerPack({slug:u.slug,displayName:u.slug,latestVersion:u.version||"main",tags:[],stats:{installs:1,stars:0}});const{invalidateLocalIndex:S}=await import("./store/oramaIndex.js");S(),await vscode.window.showInformationMessage(`Installed pack "${u.slug}" v${u.version}`,"Activate")==="Activate"&&await vscode.commands.executeCommand("agentide.pack.switch",u.slug)})),t.subscriptions.push(vscode.commands.registerCommand("agentide.skill.install",async n=>{const{workspaceRoot:s}=getWorkspaceRoot(e),{downloadFromStore:c,downloadFromExternalGitHub:i,listStoreVersions:l,isStoreUrl:u,parseGitHubUrl:d}=await import("./store/index.js"),{AgentPackManager:o}=await import("./agentpack/index.js"),a=new o(m,()=>s,()=>E.storagePath,e);let p=n;if(!p){const b=await vscode.window.showInputBox({prompt:"Enter skill store URL or GitHub URL",placeHolder:"e.g., skills/typescript-testing@v1.0.0 or https://github.com/user/repo"});if(!b)return;const{parseStoreUrl:v}=await import("./store/index.js");p=v(b)}const S=p.sourceUrl&&!u(p.sourceUrl);if(!p.version&&!S){const b=await l("skill",p.slug);if(b.length===0)p.version="main";else{const v=await vscode.window.showQuickPick(b.map(N=>({label:N.version,description:N.isPrerelease?"(pre-release)":""})),{placeHolder:"Select version to install"});if(!v)return;p.version=v.label}}const k=await a.listInstalledWithCleanup();if(k.length===0){showError(`${branding_1.AGENTIDE_BRAND_NAME}: No agents found. Create an agent first.`);return}const y=await vscode.window.showQuickPick(k.map(b=>({label:b.id,description:`v${b.version}`})),{placeHolder:"Select agent to install skill to"});if(!y)return;const{getAgentRoot:$}=await import("./agentpack/paths.js"),f=$(s,y.label),w=path.join(f,"skills",p.slug);if(await fs_1.promises.access(w).then(()=>!0).catch(()=>!1)){if(await vscode.window.showWarningMessage(`Skill "${p.slug}" already exists in ${y.label}. Overwrite?`,{modal:!0},"Overwrite","Cancel")!=="Overwrite")return;await fs_1.promises.rm(w,{recursive:!0,force:!0})}await vscode.window.withProgress({location:vscode.ProgressLocation.Window,title:`Installing skill "${p.slug}"`,cancellable:!1},async b=>{let v;if(S&&p.sourceUrl){b.report({message:"Downloading from GitHub..."});const N=d(p.sourceUrl);v=await i({owner:N.owner,repo:N.repo,ref:N.ref||"main",path:N.path},e)}else b.report({message:"Downloading from store..."}),v=await c({type:"skill",slug:p.slug,version:p.version},e);b.report({message:"Extracting files..."}),await fs_1.promises.mkdir(w,{recursive:!0});for(const N of v){const R=path.join(w,N.path);await fs_1.promises.mkdir(path.dirname(R),{recursive:!0}),await fs_1.promises.writeFile(R,N.content)}});const{getRegistry:g}=await import("./registry/index.js");await g(e).registerSkill({slug:p.slug,displayName:p.slug,latestVersion:p.version||"main",tags:[],stats:{installs:1},agentPackId:y.label});const{invalidateLocalIndex:M}=await import("./store/oramaIndex.js");M(),showInfo(`Installed skill "${p.slug}" to ${y.label}`)})),t.subscriptions.push(vscode.commands.registerCommand("agentide.mcp.install",async n=>{const{workspaceRoot:s}=getWorkspaceRoot(e),{downloadFromStore:c,listStoreVersions:i}=await import("./store/index.js"),{AgentPackManager:l}=await import("./agentpack/index.js"),u=new l(m,()=>s,()=>E.storagePath,e);let d=n;if(!d){const y=await vscode.window.showInputBox({prompt:"Enter MCP store URL",placeHolder:"e.g., mcp/github@v1.0.0"});if(!y)return;const{parseStoreUrl:$}=await import("./store/index.js");d=$(y)}if(!d.version){const y=await i("mcp",d.slug);if(y.length===0)d.version="main";else{const $=await vscode.window.showQuickPick(y.map(f=>({label:f.version,description:f.isPrerelease?"(pre-release)":""})),{placeHolder:"Select version to install"});if(!$)return;d.version=$.label}}const o=await u.listInstalledWithCleanup();if(o.length===0){showError(`${branding_1.AGENTIDE_BRAND_NAME}: No agents found. Create an agent first.`);return}const a=await vscode.window.showQuickPick(o.map(y=>({label:y.id,description:`v${y.version}`})),{placeHolder:"Select agent to add MCP server to"});if(!a)return;await vscode.window.withProgress({location:vscode.ProgressLocation.Window,title:`Installing MCP "${d.slug}"`,cancellable:!1},async y=>{y.report({message:"Downloading from store..."});const $=await c({type:"mcp",slug:d.slug,version:d.version},e);y.report({message:"Merging MCP config..."});const f=$.find(v=>v.path==="mcp.json"||v.path.endsWith("/mcp.json"));if(!f)throw new Error("Downloaded MCP package missing mcp.json");const w=JSON.parse(f.content.toString()),{getAgentRoot:I}=await import("./agentpack/paths.js"),g=I(s,a.label),D=path.join(g,"mcp"),M=path.join(D,".mcp.json");await fs_1.promises.mkdir(D,{recursive:!0});let b={mcpServers:{}};try{const v=await fs_1.promises.readFile(M,"utf-8");b=JSON.parse(v),b.mcpServers||(b.mcpServers={})}catch{}b.mcpServers[d.slug]={transport:w.transport||"stdio",command:w.command,args:w.args,env:w.env,url:w.url,npmPackage:w.npmPackage,_version:d.version,_description:w.description},await fs_1.promises.writeFile(M,JSON.stringify(b,null,2));for(const v of $)if(v.path!=="mcp.json"&&!v.path.endsWith("/mcp.json")){const N=path.join(D,d.slug,v.path);await fs_1.promises.mkdir(path.dirname(N),{recursive:!0}),await fs_1.promises.writeFile(N,v.content)}});const{getRegistry:p}=await import("./registry/index.js");await p(e).registerMcp({slug:d.slug,displayName:d.slug,transport:"stdio",latestVersion:d.version||"main",tags:[],stats:{installs:1},agentPackId:a.label});const{invalidateLocalIndex:k}=await import("./store/oramaIndex.js");k(),showInfo(`Installed MCP "${d.slug}" v${d.version} to ${a.label}`)})),t.subscriptions.push(vscode.commands.registerCommand("agentide.engine.install",async n=>{const{downloadFromStore:s,downloadFromExternalGitHub:c,listStoreVersions:i,isStoreUrl:l,parseGitHubUrl:u,parseStoreUrl:d}=await import("./store/index.js"),{installCustomEngineFromFiles:o}=await import("./engines/install.js");let a=n;if(!a){const f=await vscode.window.showInputBox({prompt:"Enter custom engine store URL or GitHub URL",placeHolder:"e.g., engine/gemini or https://github.com/user/repo/tree/main/gemini"});if(!f)return;if(l(f))a=d(f);else{const w=u(f),I=(w.path||w.repo).split("/");a={type:"engine",slug:I[I.length-1]||w.repo,version:w.ref,sourceUrl:f}}}const p=a.sourceUrl&&!l(a.sourceUrl);if(!a.version&&!p){const f=await i("engine",a.slug);if(f.length===0)a.version="main";else{const w=await vscode.window.showQuickPick(f.map(I=>({label:I.version,description:I.isPrerelease?"(pre-release)":""})),{placeHolder:"Select version to install"});if(!w)return;a.version=w.label}}const S=async f=>await vscode.window.withProgress({location:vscode.ProgressLocation.Window,title:`Installing engine "${a.slug}"`,cancellable:!1},async w=>{let I;if(p&&a.sourceUrl){w.report({message:"Downloading from GitHub..."});const g=u(a.sourceUrl);I=await c({owner:g.owner,repo:g.repo,ref:g.ref||"main",path:g.path},e)}else w.report({message:"Downloading from store..."}),I=await s({type:"engine",slug:a.slug,version:a.version},e);return w.report({message:"Validating and installing..."}),await o(I,{slug:a.slug,version:a.version,sourceUrl:a.sourceUrl,overwrite:f,logger:e})});let k;try{k=await S(!1)}catch(f){const w=f instanceof Error?f.message:String(f);if(!w.includes("already exists")){log(e,`[AgentIDE] Engine install error: ${w}`),showError(`AgentIDE: ${w}`);return}if(await vscode.window.showWarningMessage(w,{modal:!0},"Overwrite","Cancel")!=="Overwrite")return;try{k=await S(!0)}catch(g){const D=g instanceof Error?g.message:String(g);log(e,`[AgentIDE] Engine install error: ${D}`),showError(`AgentIDE: ${D}`);return}}const{invalidateLocalIndex:y}=await import("./store/oramaIndex.js");if(y(),!k)return;clearCustomEngineRuntimeCache(r,k.id),await refreshCustomEnginePicker(e),await vscode.window.showInformationMessage(`Installed engine "${k.displayName}"`,"List Engines")==="List Engines"&&await vscode.commands.executeCommand("agentide.customEngine.list")})),t.subscriptions.push(vscode.commands.registerCommand("agentide.view.install",async n=>{const{workspaceRoot:s}=getWorkspaceRoot(e),{downloadFromStore:c,downloadFromExternalGitHub:i,listStoreVersions:l,isStoreUrl:u,parseGitHubUrl:d,parseStoreUrl:o}=await import("./store/index.js"),{installSpotlightViewFromFiles:a}=await import("./spotlight/install.js");let p=n;if(!p){const I=await vscode.window.showInputBox({prompt:"Enter Spotlight view store URL or GitHub URL",placeHolder:"e.g., view/cost-ops or https://github.com/user/repo/tree/main/spotlight/cost-ops"});if(!I)return;if(u(I))p=o(I);else{const g=d(I),D=(g.path||g.repo).split("/");p={type:"view",slug:D[D.length-1]||g.repo,version:g.ref,sourceUrl:I}}}const S=p.sourceUrl&&!u(p.sourceUrl);if(!p.version&&!S){const I=await l("view",p.slug);if(I.length===0)p.version="main";else{const g=await vscode.window.showQuickPick(I.map(D=>({label:D.version,description:D.isPrerelease?"(pre-release)":""})),{placeHolder:"Select version to install"});if(!g)return;p.version=g.label}}const k=async(I,g)=>await vscode.window.withProgress({location:vscode.ProgressLocation.Window,title:`Installing Spotlight view "${p.slug}"`,cancellable:!1},async D=>{let M;if(S&&p.sourceUrl){D.report({message:"Downloading from GitHub..."});const b=d(p.sourceUrl);M=(await i({owner:b.owner,repo:b.repo,ref:b.ref||"main",path:b.path},e)).map(N=>({path:N.path,content:N.content}))}else D.report({message:"Downloading from store..."}),M=await c({type:"view",slug:p.slug,version:p.version},e);return D.report({message:"Installing view..."}),await a(M,{slug:p.slug,version:p.version,overwrite:I,activate:g,workspaceRoot:s,logger:e})});let y;try{y=await k(!1,!1)}catch(I){const g=I instanceof Error?I.message:String(I);if(!g.includes("already exists")){log(e,`[AgentIDE] Spotlight view install error: ${g}`),showError(`AgentIDE: ${g}`);return}if(await vscode.window.showWarningMessage(g,{modal:!0},"Overwrite","Cancel")!=="Overwrite")return;try{y=await k(!0,!1)}catch(M){const b=M instanceof Error?M.message:String(M);log(e,`[AgentIDE] Spotlight view install error: ${b}`),showError(`AgentIDE: ${b}`);return}}const{invalidateLocalIndex:$}=await import("./store/oramaIndex.js");if($(),!y)return;const f=_state?.analyticsDashboard;f&&await f.refreshViewsFromDisk();const w=await vscode.window.showInformationMessage(`Installed Spotlight view "${y.id}" v${y.version||p.version||"main"}`,"Open Spotlight","Activate View");if(w==="Open Spotlight")await vscode.commands.executeCommand("agentide.analytics.openDashboard");else if(w==="Activate View"){const{setActiveSpotlightView:I}=await import("./spotlight/install.js");await I(y.viewsConfigPath,y.id);const g=_state?.analyticsDashboard;g&&await g.refreshViewsFromDisk(),await vscode.commands.executeCommand("agentide.analytics.openDashboard")}})),t.subscriptions.push(vscode.commands.registerCommand("agentide.pack.update",async()=>{const{workspaceRoot:n}=getWorkspaceRoot(e),{AgentPackManager:s}=await import("./agentpack/index.js"),c=new s(m,()=>n,()=>E.storagePath,e),i=await c.listInstalledWithCleanup(),l=[];for(const a of i){if(a.id==="default")continue;const p=await c.checkAgentUpdate(a.id);p&&l.push({id:a.id,version:a.version,newVersion:p})}if(l.length===0){showInfo(`${branding_1.AGENTIDE_BRAND_NAME}: All agents are up to date`);return}const u=l.map(a=>({label:a.id,description:`v${a.version} \u2192 v${a.newVersion}`})),d=await vscode.window.showQuickPick(u,{placeHolder:"Select an agent to update",title:"Update Agent from User Library"});if(!(!d||await vscode.window.showWarningMessage(`Update "${d.label}" from User Library? Current version will be backed up.`,{modal:!0},"Update","Cancel")!=="Update"))try{const a=await c.updateFromLibrary(d.label);showInfo(`AgentIDE: Updated "${d.label}" to v${a}`)}catch(a){const p=a instanceof Error?a.message:String(a);log(e,`[AgentIDE] Update error: ${p}`),showError(`AgentIDE: ${p}`)}})),t.subscriptions.push(vscode.commands.registerCommand("agentide.pack.duplicate",async()=>{const{workspaceRoot:n}=getWorkspaceRoot(e),{AgentPackManager:s}=await import("./agentpack/index.js"),c=new s(m,()=>n,()=>E.storagePath,e),i=await c.listInstalledWithCleanup();if(i.length===0){showInfo(`${branding_1.AGENTIDE_BRAND_NAME}: No agents to duplicate`);return}const l=i.map(d=>({label:d.id,description:`v${d.version}`})),u=await vscode.window.showQuickPick(l,{placeHolder:"Select an agent to duplicate",title:"Duplicate Agent"});if(u)try{const d=await c.duplicate(u.label);showInfo(`AgentIDE: Created "${d}" as copy of "${u.label}"`);const o=path.join((0,paths_1.getAgentideDir)(n),paths_1.AGENT_CONSTANTS.AGENTS_DIR,d,paths_1.AGENT_CONSTANTS.AGENTS_MD);if(await(0,utils_1.pathExists)(o)){const a=await vscode.workspace.openTextDocument(o);await vscode.window.showTextDocument(a)}}catch(d){const o=d instanceof Error?d.message:String(d);log(e,`[AgentIDE] Duplicate error: ${o}`),showError(`AgentIDE: ${o}`)}})),t.subscriptions.push(vscode.commands.registerCommand("agentide.pack.refresh",async()=>{const{workspaceRoot:n}=getWorkspaceRoot(e),{AgentPackManager:s}=await import("./agentpack/index.js"),c=new s(m,()=>n,()=>E.storagePath,e);try{const{registered:i}=await c.repairUnregisteredAgents();return i.length>0?showInfo(`AgentIDE: Discovered ${i.length} new pack(s): ${i.join(", ")}`):showInfo(`${branding_1.AGENTIDE_BRAND_NAME}: No new packs found`),{registered:i}}catch(i){const l=i instanceof Error?i.message:String(i);return log(e,`[AgentIDE] Pack refresh error: ${l}`),showError(`AgentIDE: ${l}`),{registered:[]}}})),t.subscriptions.push(vscode.commands.registerCommand("agentide.pack.resetDefault",async()=>{if(await vscode.window.showWarningMessage("Reset the default agent? This will restore it from bundled templates. Current default agent will be backed up.",{modal:!0},"Reset","Cancel")!=="Reset")return;const{workspaceRoot:s}=getWorkspaceRoot(e),{AgentPackManager:c}=await import("./agentpack/index.js"),i=new c(m,()=>s,()=>E.storagePath,e);try{await i.resetDefault(getBundledBasePromptsDir()),showInfo(`${branding_1.AGENTIDE_BRAND_NAME}: Default agent reset from bundled templates`),await m.flushAgentideRootUpdate(s,e,{force:!0,allowDuringActiveTurn:!0})}catch(l){const u=l instanceof Error?l.message:String(l);log(e,`[AgentIDE] Reset error: ${u}`),showError(`AgentIDE: ${u}`)}})),t.subscriptions.push(vscode.commands.registerCommand("agentide.chat",async n=>handleChatCommand(r,n))),t.subscriptions.push(vscode.commands.registerCommand("agentide.chat.cancel",async n=>{const s=n?.streamId;if(!s)return{cancelled:!1,error:"streamId is required"};const c=_activeRunsByStreamId.get(s);if(!c)return log(e,`[AgentIDE] Cancel ignored: no active run for streamId=${s}`),rejectPendingQuestionsForStream(s,"Run cancelled"),{cancelled:!1};log(e,`[AgentIDE] Cancel requested: streamId=${s}, engine=${c.engine}, ageMs=${Date.now()-c.startedAt}`);try{c.abortController.abort()}catch{}return rejectPendingQuestionsForStream(s,"Run cancelled"),{cancelled:!0}})),t.subscriptions.push(vscode.commands.registerCommand("agentide.chat.answerQuestion",async n=>{const s=n?.streamId,c=n?.questionId;if(!s||!c)return{ok:!1,error:"streamId and questionId are required"};const i=_pendingQuestionsById.get(c);if(!i||i.streamId!==s)return{ok:!1,error:"Question not found or already resolved"};const l=normalizeQuestionAnswer(n?.answer);return resolvePendingQuestion(c,l),{ok:!0}}))}function getUserPermissions(){return{fileAccess:vscode.workspace.getConfiguration("agentide").get("permissions.fileAccess","full")}}function getConfiguredAdditionalEngineDir(){return vscode.workspace.getConfiguration("agentide").get("additionalEngineDir")}function clearCustomEngineRuntimeCache(t,r){const e=t.engines.custom;try{e?.clearInstances?.(r)}catch(m){log(t.outputChannel,`[AgentIDE] Custom engine cache clear warning: ${m instanceof Error?m.message:String(m)}`)}}async function refreshCustomEnginePicker(t){try{await vscode.commands.executeCommand("agentide.engine.refresh")}catch(r){log(t,`[AgentIDE] Custom engine picker refresh warning: ${r instanceof Error?r.message:String(r)}`)}}const _sessionEventWriter=new sessionEvents_1.SessionEventWriter;async function handleChatCommand(t,r){const{outputChannel:e,engines:m,syncService:E,config:h}=t,{engine:C,streamId:A}=r;let{message:T}=r;const n=r.options??{};let s;const c=T.match(/^\[gw:(gw-[^\]]+)\]/);if(c){const P=c[1];T=T.slice(c[0].length),log(e,`[AgentIDE] Gateway request detected, token=${P.slice(0,20)}...`);const{GatewayService:_}=await import("./gateway/service.js");s=_.getGatewayEmitter(P),s?log(e,"[AgentIDE] Gateway emitter found, will stream to both Chat UI and Gateway"):log(e,`[AgentIDE] Gateway emitter NOT found for token ${P.slice(0,20)}...`)}const{workspaceRoot:i,additionalDirectories:l,isHomeFallback:u}=getWorkspaceRoot(e,n.workspaceRoot,n.additionalDirectories);A&&u&&await warnHomeFallbackOnce(e,A);const d=await E.getActiveAgentManifest(i,e,E.getActivePackId(i)??t.activePackId),o=d?.spec?.remote?.url?.trim();if(o)return(0,handleRemoteChat_js_1.handleRemoteServeChat)({outputChannel:e,syncService:E,sessionEventWriter:_sessionEventWriter,activeRunsByStreamId:_activeRunsByStreamId,rejectPendingQuestionsForStream,askQuestionViaWorkbenchTool,askQuestionFromChatUI,getServeAuth:async()=>{if(!_extensionContext)return;const P=await(0,provider_js_1.getAgentHippoAccessToken)(_extensionContext);if(P)return{accessToken:P.accessToken,userEmail:P.email}},ensureSignedIn:async()=>{if(!_extensionContext)return;const P=await(0,signInFlow_js_1.ensureAgentHippoSignedIn)(_extensionContext);if(P)return{accessToken:P.accessToken,userEmail:P.email}},log},{engine:C,message:T,options:r.options,streamId:A,sessionResource:r.sessionResource,requestId:r.requestId,remoteUrl:o,remoteManifest:d,workspaceRoot:i,incomingOptions:n,gatewayEmitter:s});let a={...n,workspaceRoot:i,additionalDirectories:l,agentPackId:t.activePackId};if(!A)return{error:"streamId is required - non-streaming mode is no longer supported"};let p=C,S=m[p];if(!S&&p!=="codex"&&p!=="claude"&&m.custom&&(a={...a,engineId:a.engineId??p},p="custom",S=m.custom,log(e,`[AgentIDE] Routing requested engine "${C}" through custom runtime loader`)),!S){const P=`Unknown engine: ${C}`;return log(e,`[AgentIDE] Error: ${P}`),{error:P}}log(e,`[AgentIDE] Chat request for engine=${C} (runtime=${p}), streamId: ${A}, useLiteLLM: ${a.useLiteLLM||!1}`);const k=new AbortController;_activeRunsByStreamId.set(A,{streamId:A,engine:p,startedAt:Date.now(),abortController:k});const y=(0,utils_1.createIPCStreamEmitter)(A),$=r.sessionResource,f=r.requestId,w={...y,async question(P){return $?await askQuestionViaWorkbenchTool($,f,P,k.signal):await askQuestionFromChatUI(A,P)}},I=s?{...w,async thinking(P){await y.thinking(P),await s.thinking(`<thinking>${P}</thinking>`)},async text(P){await y.text(P),await s.text(P)},async toolStart(P,_,L,x){await y.toolStart(P,_,L,x),await s.toolStart(P,_,L,x)},async toolEnd(P,_,L,x,U){await y.toolEnd(P,_,L,x,U),await s.toolEnd(P,_,L,x,U)},async progress(P){await y.progress(P),await s.progress(P)},async question(P){const _=await w.question(P);return await s.progress(`Question answered: ${questionPromptToHeader(P.prompt)}`),_},async error(P){await y.error(P),await s.error(P)},async done(){await y.done(),await s.done()}}:w,g=getTerminalLogInfo(a);await appendTerminalAttachmentsToLog(r.context,A,e,g?.uri),await persistImageAttachments(r.context,a,e),await persistFileAndDirectoryAttachments(r.context,a,e);const D=formatSdkContextSuffix(r.context,g?.relativePath),M=D?`${T}
|
|
23
23
|
|
|
24
|
-
${D}`:T,b=(0,base_1.generateRequestId)(),v=a.sessionId??`ide-${Date.now()}`,N=(0,sessionEvents_1.wrapEmitterWithObservability)(I,_sessionEventWriter,v,b);let R=null;try{E.incrementActiveAgentTurns(),await E.ensureAgentideProjectPrepared(i,l,e),await E.writeManagedPathsManifest(h.codexHome,h.claudeConfigDir,i,l,e);const P=await E.getActiveAgentManifest(i,e),_=(0,permissions_1.parseManifestPermissions)(P),L=getUserPermissions(),x=(0,permissions_1.enforcePermissions)(_,L);log(e,`[AgentIDE] Permissions: manifest(files=${_.fileAccess}) + user(files=${L.fileAccess}) = effective(files=${x.fileAccess})`);const U={...a,sessionId:v,permissions:x,agentPackVersion:P?.metadata?.version,requestId:b},O=new vscode_logger_1.VSCodeLogger(e),B=new permission_handler_1.AutoApprovePermissionHandler,W=vscode.workspace.getConfiguration("agentide").get("cli.path",""),F=await(0,runtime_1.getCliHealth)({configuredPath:W,extensionPath:_extensionContext?.extensionPath}),q=_extensionContext?.globalState?.get(BUNDLED_TOOLS_DIR_KEY),G=(0,runtime_1.buildCliEnvPatch)({cliPath:F.path,workspaceRoot:i,agentId:U.agentPackId??"default",chatSessionId:U.sessionId?.trim()||U.contextSessionId?.trim(),baseEnv:process.env,extensionPath:_extensionContext?.extensionPath,userInstalledToolsDir:q??void 0});G.AGENTHIPPO_TOOLS_DIR&&log(e,`[AgentIDE] Bundled tools dir available for runtime: ${G.AGENTHIPPO_TOOLS_DIR}`);{const j=E.getActiveAgentContext(i),H=await getIdeTurnScope(i,j.agentId,j.agentRoot,P,e);H&&(R=await H.beginTurn({sessionKey:v}),Object.assign(G,R.env))}const V={logger:O,editTracker:new vscode_edit_tracker_1.VSCodeEditTracker(new vscode_logger_1.VSCodeLogger(e,"[EditTracker]")),configProvider:new vscode_config_provider_1.VSCodeConfigProvider,permissionHandler:B,cliEnvPatch:G};return F.installed&&F.path?log(e,`[AgentIDE] CLI available for agent runtime: ${F.path}`):log(e,`[AgentIDE] CLI not detected for runtime (skills may rely on '${branding_1.AGENTIDE_CLI_NAME}' on PATH)`),log(e,`[AgentIDE] Analytics: session=${v}, request=${b}, agent=${U.agentPackId??"default"}, version=${U.agentPackVersion??"workspace"}`),await N.emitTurnStart(),await S.stream(M,U,N,V,k.signal),await N.emitTurnEnd(!0),{streaming:!0}}catch(P){const _=P instanceof Error?P.message:String(P);return log(e,`[AgentIDE] Error: ${_}`),await N.error(_),await N.emitTurnEnd(!1),{error:_}}finally{try{await R?.release()}catch{}rejectPendingQuestionsForStream(A,"Run finished"),_activeRunsByStreamId.delete(A),E.decrementActiveAgentTurns()}}function resolveWorkspaceRootUri(t){const r=vscode.workspace.workspaceFolders??[],e=r.find(E=>E.uri.fsPath===t);if(e)return e.uri;const m=r[0];return m&&t.startsWith("/")?vscode.Uri.from({scheme:m.uri.scheme,authority:m.uri.authority,path:t}):vscode.Uri.file(t)}function dirnameUri(t){const r=t.path.lastIndexOf("/");return r>=0?t.with({path:t.path.slice(0,r)}):t}function getTerminalLogInfo(t){const r=t.contextSessionId?.trim()||t.sessionId?.trim();if(!r)return;const e=resolveWorkspaceRootUri(t.workspaceRoot);return{uri:vscode.Uri.joinPath(e,paths_1.AGENT_CONSTANTS.AGENTIDE_DIR_NAME,paths_1.AGENT_CONSTANTS.SESSIONS_DIR,r,TERMINAL_LOG_FILE_NAME),relativePath:`${AGENTIDE_SESSIONS_DIR_NAME}/${r}/${TERMINAL_LOG_FILE_NAME}`}}function getSessionAttachmentsDirInfo(t){const r=t.contextSessionId?.trim()||t.sessionId?.trim();if(!r)return;const e=resolveWorkspaceRootUri(t.workspaceRoot);return{dirUri:vscode.Uri.joinPath(e,paths_1.AGENT_CONSTANTS.AGENTIDE_DIR_NAME,paths_1.AGENT_CONSTANTS.SESSIONS_DIR,r,ATTACHMENTS_DIR_NAME),relativeDirPath:`${AGENTIDE_SESSIONS_DIR_NAME}/${r}/${ATTACHMENTS_DIR_NAME}`}}function slugifyFileStem(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"attachment"}function imageExtensionFromMimeType(t){switch((t??"").toLowerCase()){case"image/png":return"png";case"image/jpeg":case"image/jpg":return"jpg";case"image/gif":return"gif";case"image/webp":return"webp";default:return"png"}}async function persistImageAttachments(t,r,e){const m=t?.variables??[];if(!t||m.length===0)return;const E=m.filter(A=>A.kind==="image"&&typeof A.dataBase64=="string"&&A.dataBase64.length>0);if(E.length===0)return;const h=getSessionAttachmentsDirInfo(r);if(!h){log(e,"[AgentIDE] Note: image attachment present but no contextSessionId; skipping persistence");return}try{await(0,terminalLogger_1.ensureDirectory)(h.dirUri)}catch(A){log(e,`[AgentIDE] Warning: failed to create session attachments dir: ${A instanceof Error?A.message:String(A)}`);return}let C=0;for(const A of E){C++;const T=slugifyFileStem(A.name||`image-${C}`),n=imageExtensionFromMimeType(A.mimeType),s=E.length>1?`${T}-${C}.${n}`:`${T}.${n}`,c=vscode.Uri.joinPath(h.dirUri,s);try{const i=Buffer.from(A.dataBase64,"base64");await vscode.workspace.fs.writeFile(c,i),A.uri=`${h.relativeDirPath}/${s}`,delete A.dataBase64}catch(i){log(e,`[AgentIDE] Warning: failed to persist image attachment "${A.name}": ${i instanceof Error?i.message:String(i)}`)}}}async function persistFileAndDirectoryAttachments(t,r,e){const m=t?.variables??[];if(!t||m.length===0)return;const E=m.filter(f=>(f.kind==="file"||f.kind==="directory")&&typeof f.uri=="string"&&f.uri.trim().length>0);if(E.length===0)return;const h=getSessionAttachmentsDirInfo(r);if(!h){log(e,"[AgentIDE] Note: file/folder attachment present but no contextSessionId; skipping persistence");return}try{await(0,terminalLogger_1.ensureDirectory)(h.dirUri)}catch(f){log(e,`[AgentIDE] Warning: failed to create session attachments dir: ${f instanceof Error?f.message:String(f)}`);return}const C=vscode.Uri.joinPath(h.dirUri,"manifest.json"),A=async()=>{try{const f=await vscode.workspace.fs.readFile(C),w=JSON.parse(Buffer.from(f).toString("utf8"));if(w&&w.version===1&&typeof w.files=="object"&&typeof w.directories=="object")return w}catch{}return{version:1,files:{},directories:{}}},T=async f=>{try{const w=Buffer.from(JSON.stringify(f,null,2),"utf8");await vscode.workspace.fs.writeFile(C,w)}catch{}},n=await A();let s=!1;const c=500,i=25*1024*1024,l=10*1024*1024;let u=0,d=0;const o=(f,w)=>{try{const I=path.resolve(f),g=path.resolve(w),D=path.relative(I,g);return D===""||!D.startsWith("..")&&!path.isAbsolute(D)}catch{return!1}},a=r.workspaceRoot,p=path.normalize(`${path.sep}${AGENTIDE_SESSIONS_DIR_NAME.split("/").join(path.sep)}${path.sep}`),S=async f=>{try{return await vscode.workspace.fs.stat(f),!0}catch{return!1}},k=async(f,w)=>{let I=w,g=1;for(;await S(vscode.Uri.joinPath(f,I));){g++;const D=path.extname(w);I=`${D?w.slice(0,-D.length):w}-${g}${D}`}return I},y=async(f,w)=>{const I=vscode.Uri.file(f);try{const g=await vscode.workspace.fs.stat(I);if(g.type!==vscode.FileType.File)return;const D=`${f}::${g.size}::${g.mtime}`,M=n.files[D];if(M){const P=vscode.Uri.joinPath(w,M.destName);if(await S(P))return M.destName}const b=path.basename(f),v=await k(w,b||"attachment"),N=vscode.Uri.joinPath(w,v);if(g.size>l){log(e,`[AgentIDE] Note: skipping large file attachment (${g.size} bytes): ${f}`);return}if(u+1>c||d+g.size>i){log(e,"[AgentIDE] Note: skipping additional file attachments due to size limits");return}const R=await vscode.workspace.fs.readFile(I);return await vscode.workspace.fs.writeFile(N,R),u+=1,d+=g.size,n.files[D]={destName:v,sourcePath:f,size:g.size,mtime:g.mtime},s=!0,v}catch(g){log(e,`[AgentIDE] Warning: failed to persist file attachment "${f}": ${g instanceof Error?g.message:String(g)}`);return}},$=async(f,w)=>{const I=await vscode.workspace.fs.readDirectory(f);for(const[g,D]of I){if(u>=c||d>=i)return;const M=vscode.Uri.joinPath(f,g),b=vscode.Uri.joinPath(w,g);if(D===vscode.FileType.Directory)await(0,terminalLogger_1.ensureDirectory)(b),await $(M,b);else if(D===vscode.FileType.File)try{const v=await vscode.workspace.fs.stat(M);if(v.size>l)continue;if(u+1>c||d+v.size>i)return;const N=await vscode.workspace.fs.readFile(M);await vscode.workspace.fs.writeFile(b,N),u+=1,d+=v.size}catch{}}};for(const f of E){const w=f.uri.trim();if(path.isAbsolute(w)&&!(a&&o(a,w))&&!path.normalize(w).includes(p))try{const I=vscode.Uri.file(w),g=await vscode.workspace.fs.stat(I);if(g.type===vscode.FileType.Directory&&f.kind==="directory"){const D=`${w}::${g.mtime}`,M=n.directories[D];if(M){const R=vscode.Uri.joinPath(h.dirUri,M.destName);if(await S(R)){f.uri=`${h.relativeDirPath}/${M.destName}`;continue}}const b=path.basename(w)||"folder",v=await k(h.dirUri,b),N=vscode.Uri.joinPath(h.dirUri,v);await(0,terminalLogger_1.ensureDirectory)(N),await $(I,N),n.directories[D]={destName:v,sourcePath:w,mtime:g.mtime},s=!0,f.uri=`${h.relativeDirPath}/${v}`}else if(g.type===vscode.FileType.File&&f.kind==="file"){const D=await y(w,h.dirUri);D&&(f.uri=`${h.relativeDirPath}/${D}`)}}catch{}}s&&await T(n)}async function appendTerminalAttachmentsToLog(t,r,e,m){if(!m)return;const E=t?.variables??[],h=E.filter(A=>A.kind==="terminalCommand"&&typeof A.output=="string"&&A.output.trim().length>0),C=E.filter(A=>A.kind==="generic"&&typeof A.text=="string"&&A.text.trim().length>0&&(A.isTerminalSelection||typeof A.id=="string"&&A.id.startsWith("terminal-selection-")));if(!(h.length===0&&C.length===0))try{await(0,terminalLogger_1.ensureDirectory)(dirnameUri(m));const A=new Date().toISOString(),T=[];T.push(`<!-- TERMINAL_ATTACHMENTS STREAM:${r} TIME:${A} -->`),T.push("");for(const n of h){const s=(n.command??n.name??"").toString().trim();T.push("## Terminal Command"),s&&T.push(`- Command: ${s}`),typeof n.exitCode=="number"&&T.push(`- Exit code: ${n.exitCode}`),n.uri&&T.push(`- Resource: ${n.uri}`),T.push(""),T.push("```text"),T.push(n.output??""),T.push("```"),T.push("")}for(const n of C){const s=n.name||"Terminal Selection";T.push(`## ${s}`),T.push(""),T.push("```text"),T.push(n.text??""),T.push("```"),T.push("")}T.push(`<!-- TERMINAL_ATTACHMENTS_END STREAM:${r} -->`),T.push(""),await(0,terminalLogger_1.appendTextFileWithRotation)(m,T.join(`
|
|
24
|
+
${D}`:T,b=(0,base_1.generateRequestId)(),v=a.sessionId??`ide-${Date.now()}`,N=(0,sessionEvents_1.wrapEmitterWithObservability)(I,_sessionEventWriter,v,b);let R=null;try{E.incrementActiveAgentTurns(),await E.ensureAgentideProjectPrepared(i,l,e),await E.writeManagedPathsManifest(h.codexHome,h.claudeConfigDir,i,l,e);const P=await E.getActiveAgentManifest(i,e),_=(0,permissions_1.parseManifestPermissions)(P),L=getUserPermissions(),x=(0,permissions_1.enforcePermissions)(_,L);log(e,`[AgentIDE] Permissions: manifest(files=${_.fileAccess}) + user(files=${L.fileAccess}) = effective(files=${x.fileAccess})`);const U={...a,sessionId:v,permissions:x,agentPackVersion:P?.metadata?.version,requestId:b},O=new vscode_logger_1.VSCodeLogger(e),B=new permission_handler_1.AutoApprovePermissionHandler,W=vscode.workspace.getConfiguration("agentide").get("cli.path",""),F=await(0,runtime_1.getCliHealth)({configuredPath:W,extensionPath:_extensionContext?.extensionPath}),q=_extensionContext?.globalState?.get(BUNDLED_TOOLS_DIR_KEY),G=(0,runtime_1.buildCliEnvPatch)({cliPath:F.path,workspaceRoot:i,agentId:U.agentPackId??"default",chatSessionId:U.sessionId?.trim()||U.contextSessionId?.trim(),baseEnv:process.env,extensionPath:_extensionContext?.extensionPath,userInstalledToolsDir:q??void 0});G.AGENTHIPPO_TOOLS_DIR&&log(e,`[AgentIDE] Bundled tools dir available for runtime: ${G.AGENTHIPPO_TOOLS_DIR}`);{const j=E.getActiveAgentContext(i),H=await getIdeTurnScope(i,j.agentId,j.agentRoot,P,e);H&&(R=await H.beginTurn({sessionKey:v}),Object.assign(G,R.env))}const V={logger:O,editTracker:new vscode_edit_tracker_1.VSCodeEditTracker(new vscode_logger_1.VSCodeLogger(e,"[EditTracker]")),configProvider:new vscode_config_provider_1.VSCodeConfigProvider(P?.spec?.effort),permissionHandler:B,cliEnvPatch:G};return F.installed&&F.path?log(e,`[AgentIDE] CLI available for agent runtime: ${F.path}`):log(e,`[AgentIDE] CLI not detected for runtime (skills may rely on '${branding_1.AGENTIDE_CLI_NAME}' on PATH)`),log(e,`[AgentIDE] Analytics: session=${v}, request=${b}, agent=${U.agentPackId??"default"}, version=${U.agentPackVersion??"workspace"}`),await N.emitTurnStart(),await S.stream(M,U,N,V,k.signal),await N.emitTurnEnd(!0),{streaming:!0}}catch(P){const _=P instanceof Error?P.message:String(P);return log(e,`[AgentIDE] Error: ${_}`),await N.error(_),await N.emitTurnEnd(!1),{error:_}}finally{try{await R?.release()}catch{}rejectPendingQuestionsForStream(A,"Run finished"),_activeRunsByStreamId.delete(A),E.decrementActiveAgentTurns()}}function resolveWorkspaceRootUri(t){const r=vscode.workspace.workspaceFolders??[],e=r.find(E=>E.uri.fsPath===t);if(e)return e.uri;const m=r[0];return m&&t.startsWith("/")?vscode.Uri.from({scheme:m.uri.scheme,authority:m.uri.authority,path:t}):vscode.Uri.file(t)}function dirnameUri(t){const r=t.path.lastIndexOf("/");return r>=0?t.with({path:t.path.slice(0,r)}):t}function getTerminalLogInfo(t){const r=t.contextSessionId?.trim()||t.sessionId?.trim();if(!r)return;const e=resolveWorkspaceRootUri(t.workspaceRoot);return{uri:vscode.Uri.joinPath(e,paths_1.AGENT_CONSTANTS.AGENTIDE_DIR_NAME,paths_1.AGENT_CONSTANTS.SESSIONS_DIR,r,TERMINAL_LOG_FILE_NAME),relativePath:`${AGENTIDE_SESSIONS_DIR_NAME}/${r}/${TERMINAL_LOG_FILE_NAME}`}}function getSessionAttachmentsDirInfo(t){const r=t.contextSessionId?.trim()||t.sessionId?.trim();if(!r)return;const e=resolveWorkspaceRootUri(t.workspaceRoot);return{dirUri:vscode.Uri.joinPath(e,paths_1.AGENT_CONSTANTS.AGENTIDE_DIR_NAME,paths_1.AGENT_CONSTANTS.SESSIONS_DIR,r,ATTACHMENTS_DIR_NAME),relativeDirPath:`${AGENTIDE_SESSIONS_DIR_NAME}/${r}/${ATTACHMENTS_DIR_NAME}`}}function slugifyFileStem(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"attachment"}function imageExtensionFromMimeType(t){switch((t??"").toLowerCase()){case"image/png":return"png";case"image/jpeg":case"image/jpg":return"jpg";case"image/gif":return"gif";case"image/webp":return"webp";default:return"png"}}async function persistImageAttachments(t,r,e){const m=t?.variables??[];if(!t||m.length===0)return;const E=m.filter(A=>A.kind==="image"&&typeof A.dataBase64=="string"&&A.dataBase64.length>0);if(E.length===0)return;const h=getSessionAttachmentsDirInfo(r);if(!h){log(e,"[AgentIDE] Note: image attachment present but no contextSessionId; skipping persistence");return}try{await(0,terminalLogger_1.ensureDirectory)(h.dirUri)}catch(A){log(e,`[AgentIDE] Warning: failed to create session attachments dir: ${A instanceof Error?A.message:String(A)}`);return}let C=0;for(const A of E){C++;const T=slugifyFileStem(A.name||`image-${C}`),n=imageExtensionFromMimeType(A.mimeType),s=E.length>1?`${T}-${C}.${n}`:`${T}.${n}`,c=vscode.Uri.joinPath(h.dirUri,s);try{const i=Buffer.from(A.dataBase64,"base64");await vscode.workspace.fs.writeFile(c,i),A.uri=`${h.relativeDirPath}/${s}`,delete A.dataBase64}catch(i){log(e,`[AgentIDE] Warning: failed to persist image attachment "${A.name}": ${i instanceof Error?i.message:String(i)}`)}}}async function persistFileAndDirectoryAttachments(t,r,e){const m=t?.variables??[];if(!t||m.length===0)return;const E=m.filter(f=>(f.kind==="file"||f.kind==="directory")&&typeof f.uri=="string"&&f.uri.trim().length>0);if(E.length===0)return;const h=getSessionAttachmentsDirInfo(r);if(!h){log(e,"[AgentIDE] Note: file/folder attachment present but no contextSessionId; skipping persistence");return}try{await(0,terminalLogger_1.ensureDirectory)(h.dirUri)}catch(f){log(e,`[AgentIDE] Warning: failed to create session attachments dir: ${f instanceof Error?f.message:String(f)}`);return}const C=vscode.Uri.joinPath(h.dirUri,"manifest.json"),A=async()=>{try{const f=await vscode.workspace.fs.readFile(C),w=JSON.parse(Buffer.from(f).toString("utf8"));if(w&&w.version===1&&typeof w.files=="object"&&typeof w.directories=="object")return w}catch{}return{version:1,files:{},directories:{}}},T=async f=>{try{const w=Buffer.from(JSON.stringify(f,null,2),"utf8");await vscode.workspace.fs.writeFile(C,w)}catch{}},n=await A();let s=!1;const c=500,i=25*1024*1024,l=10*1024*1024;let u=0,d=0;const o=(f,w)=>{try{const I=path.resolve(f),g=path.resolve(w),D=path.relative(I,g);return D===""||!D.startsWith("..")&&!path.isAbsolute(D)}catch{return!1}},a=r.workspaceRoot,p=path.normalize(`${path.sep}${AGENTIDE_SESSIONS_DIR_NAME.split("/").join(path.sep)}${path.sep}`),S=async f=>{try{return await vscode.workspace.fs.stat(f),!0}catch{return!1}},k=async(f,w)=>{let I=w,g=1;for(;await S(vscode.Uri.joinPath(f,I));){g++;const D=path.extname(w);I=`${D?w.slice(0,-D.length):w}-${g}${D}`}return I},y=async(f,w)=>{const I=vscode.Uri.file(f);try{const g=await vscode.workspace.fs.stat(I);if(g.type!==vscode.FileType.File)return;const D=`${f}::${g.size}::${g.mtime}`,M=n.files[D];if(M){const P=vscode.Uri.joinPath(w,M.destName);if(await S(P))return M.destName}const b=path.basename(f),v=await k(w,b||"attachment"),N=vscode.Uri.joinPath(w,v);if(g.size>l){log(e,`[AgentIDE] Note: skipping large file attachment (${g.size} bytes): ${f}`);return}if(u+1>c||d+g.size>i){log(e,"[AgentIDE] Note: skipping additional file attachments due to size limits");return}const R=await vscode.workspace.fs.readFile(I);return await vscode.workspace.fs.writeFile(N,R),u+=1,d+=g.size,n.files[D]={destName:v,sourcePath:f,size:g.size,mtime:g.mtime},s=!0,v}catch(g){log(e,`[AgentIDE] Warning: failed to persist file attachment "${f}": ${g instanceof Error?g.message:String(g)}`);return}},$=async(f,w)=>{const I=await vscode.workspace.fs.readDirectory(f);for(const[g,D]of I){if(u>=c||d>=i)return;const M=vscode.Uri.joinPath(f,g),b=vscode.Uri.joinPath(w,g);if(D===vscode.FileType.Directory)await(0,terminalLogger_1.ensureDirectory)(b),await $(M,b);else if(D===vscode.FileType.File)try{const v=await vscode.workspace.fs.stat(M);if(v.size>l)continue;if(u+1>c||d+v.size>i)return;const N=await vscode.workspace.fs.readFile(M);await vscode.workspace.fs.writeFile(b,N),u+=1,d+=v.size}catch{}}};for(const f of E){const w=f.uri.trim();if(path.isAbsolute(w)&&!(a&&o(a,w))&&!path.normalize(w).includes(p))try{const I=vscode.Uri.file(w),g=await vscode.workspace.fs.stat(I);if(g.type===vscode.FileType.Directory&&f.kind==="directory"){const D=`${w}::${g.mtime}`,M=n.directories[D];if(M){const R=vscode.Uri.joinPath(h.dirUri,M.destName);if(await S(R)){f.uri=`${h.relativeDirPath}/${M.destName}`;continue}}const b=path.basename(w)||"folder",v=await k(h.dirUri,b),N=vscode.Uri.joinPath(h.dirUri,v);await(0,terminalLogger_1.ensureDirectory)(N),await $(I,N),n.directories[D]={destName:v,sourcePath:w,mtime:g.mtime},s=!0,f.uri=`${h.relativeDirPath}/${v}`}else if(g.type===vscode.FileType.File&&f.kind==="file"){const D=await y(w,h.dirUri);D&&(f.uri=`${h.relativeDirPath}/${D}`)}}catch{}}s&&await T(n)}async function appendTerminalAttachmentsToLog(t,r,e,m){if(!m)return;const E=t?.variables??[],h=E.filter(A=>A.kind==="terminalCommand"&&typeof A.output=="string"&&A.output.trim().length>0),C=E.filter(A=>A.kind==="generic"&&typeof A.text=="string"&&A.text.trim().length>0&&(A.isTerminalSelection||typeof A.id=="string"&&A.id.startsWith("terminal-selection-")));if(!(h.length===0&&C.length===0))try{await(0,terminalLogger_1.ensureDirectory)(dirnameUri(m));const A=new Date().toISOString(),T=[];T.push(`<!-- TERMINAL_ATTACHMENTS STREAM:${r} TIME:${A} -->`),T.push("");for(const n of h){const s=(n.command??n.name??"").toString().trim();T.push("## Terminal Command"),s&&T.push(`- Command: ${s}`),typeof n.exitCode=="number"&&T.push(`- Exit code: ${n.exitCode}`),n.uri&&T.push(`- Resource: ${n.uri}`),T.push(""),T.push("```text"),T.push(n.output??""),T.push("```"),T.push("")}for(const n of C){const s=n.name||"Terminal Selection";T.push(`## ${s}`),T.push(""),T.push("```text"),T.push(n.text??""),T.push("```"),T.push("")}T.push(`<!-- TERMINAL_ATTACHMENTS_END STREAM:${r} -->`),T.push(""),await(0,terminalLogger_1.appendTextFileWithRotation)(m,T.join(`
|
|
25
25
|
`),MAX_TERMINAL_LOG_BYTES)}catch(A){log(e,`[AgentIDE] Warning: failed to persist terminal attachments for grep: ${A instanceof Error?A.message:String(A)}`)}}function formatSdkContextSuffix(t,r){if(!t)return"";const e=[];if(t.selection?.text&&t.selection.text.trim()){const h=[];if(t.selection.uri&&h.push(`**File:** \`${t.selection.uri}\``),t.selection.range){const A=t.selection.range;h.push(`**Range:** ${A.startLineNumber}:${A.startColumn}-${A.endLineNumber}:${A.endColumn}`)}e.push("## Currently Selected Code"),h.length&&(e.push(h.join(`
|
|
26
26
|
`)),e.push(""));const C=(t.selection.languageId??"").trim();e.push(`\`\`\`${C}`),e.push(t.selection.text),e.push("```")}const m=t.variables??[];if(m.length){e.push("## Attached Context");for(const h of m)switch(h.kind){case"terminalCommand":{const C=h.command?.trim()||h.name;if(e.push("### Terminal"),e.push(`**Command:** \`${C}\``),h.uri&&e.push(`**Resource:** \`${h.uri}\``),typeof h.exitCode=="number"&&e.push(`**Exit code:** ${h.exitCode}`),r)e.push(`**Output:** saved to \`${r}\` (use \`rg\`/ \`grep\`)`);else if(h.output&&h.output.trim()){const A=h.output.length>2e3?`\u2026(truncated)
|
|
27
27
|
${h.output.slice(-2e3)}`:h.output;e.push(""),e.push("```text"),e.push(A),e.push("```")}e.push("");break}case"paste":{const C=(h.language??"").trim(),A=h.name||"Paste";e.push(`### ${A}`),h.code&&h.code.trim()&&(e.push(`\`\`\`${C}`),e.push(h.code),e.push("```")),e.push("");break}case"file":case"directory":case"promptFile":{const C=h.uri??h.name;e.push(`- **${h.kind}**: \`${C}\``);break}case"image":case"notebookOutput":{const C=h.uri??h.name,A=h.mimeType?` (${h.mimeType})`:"";e.push(`- **${h.kind}**: \`${C}\`${A}`);break}case"implicit":{if(h.isSelection){const C=h.uri??h.name;e.push(`- **selection reference**: \`${C}\``)}else h.uri&&e.push(`- **reference**: \`${h.uri}\``);break}case"generic":{const C=h.name||"Context",A=!!h.isTerminalSelection||typeof h.id=="string"&&h.id.startsWith("terminal-selection-");if(e.push(`### ${C}`),A&&h.text&&h.text.trim()){if(r)e.push(`**Content:** saved to \`${r}\` (use \`rg\`/\`grep\`)`);else{const n=h.text.length>2e3?`\u2026(truncated)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! Copyright (c) 2026 AgentHippo.ai. All rights reserved. Proprietary; see LICENSE. */
|
|
2
|
-
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(
|
|
2
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(o,e,r,t){t===void 0&&(t=r);var n=Object.getOwnPropertyDescriptor(e,r);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(o,t,n)}):(function(o,e,r,t){t===void 0&&(t=r),o[t]=e[r]})),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?(function(o,e){Object.defineProperty(o,"default",{enumerable:!0,value:e})}):function(o,e){o.default=e}),__importStar=this&&this.__importStar||(function(){var o=function(e){return o=Object.getOwnPropertyNames||function(r){var t=[];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[t.length]=n);return t},o(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var t=o(e),n=0;n<t.length;n++)t[n]!=="default"&&__createBinding(r,e,t[n]);return __setModuleDefault(r,e),r}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.VSCodeConfigProvider=void 0,exports.getOverrideOpenAIBaseUrl=getOverrideOpenAIBaseUrl;const vscode=__importStar(require("vscode"));class VSCodeConfigProvider{packEffort;constructor(e){this.packEffort=e}get(e,r,t){return vscode.workspace.getConfiguration(e).get(r,t)}getCustomProviders(){return vscode.workspace.getConfiguration("agentide").get("providers.custom")||{}}getEngineSettings(){const e=vscode.workspace.getConfiguration("agentide"),r=(e.get("claude.cheapModel","")||"").trim();return{claudeMaxThinkingTokens:e.get("claude.maxThinkingTokens",0),...r?{claudeCheapModel:r}:{},...this.packEffort?.trim()?{effort:this.packEffort.trim()}:{}}}}exports.VSCodeConfigProvider=VSCodeConfigProvider;function getOverrideOpenAIBaseUrl(o,e){const r=o.getCustomProviders(),t=e.replace(/\/$/,"");for(const n of Object.values(r))if(n.baseUrl){const i=n.baseUrl.replace(/\/$/,"");if(t===i&&n.overrideOpenAIBaseUrl)return n.overrideOpenAIBaseUrl.trim()}}
|
package/package.json
CHANGED