@opensumi/cli-engine 3.9.1-next-1749023860.0 → 3.9.1-next-1749115679.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/browser/browser.js +14 -14
  2. package/package.json +10 -10
@@ -32477,7 +32477,7 @@ ${f.slice(1).join(`
32477
32477
  `).map(D=>{if(D.startsWith("@@")){const[,,,T,w]=D.match(/@@ -(\d+),(\d+) \+(\d+),(\d+) @@/);return new p.Range(parseInt(T,10),0,parseInt(T,10)+parseInt(w,10)-1,0)}return null}).filter(D=>D!==null);return{diff:A,rangesFromDiffHunk:S}}getDiagnosticInfos(d,y){return this.markerService.getManager().getMarkers({resource:d}).filter(A=>A.severity>=l.MarkerSeverity.Warning&&y.some(S=>S.containsPosition(new p.Position(A.startLineNumber,A.startColumn))))}}t.BaseApplyService=E,E.CHAT_EDITING_SOURCE_RESOLVER_SCHEME="chat-editing-source",n.__decorate([(0,o.Autowired)(a.IChatInternalService),n.__metadata("design:type",h.ChatInternalService)],E.prototype,"chatInternalService",void 0),n.__decorate([(0,o.Autowired)(l.AppConfig),n.__metadata("design:type",Object)],E.prototype,"appConfig",void 0),n.__decorate([(0,o.Autowired)(_.WorkbenchEditorService),n.__metadata("design:type",_.WorkbenchEditorService)],E.prototype,"editorService",void 0),n.__decorate([(0,o.Autowired)(a.InlineDiffServiceToken),n.__metadata("design:type",Object)],E.prototype,"inlineDiffService",void 0),n.__decorate([(0,o.Autowired)(m.IMarkerService),n.__metadata("design:type",Object)],E.prototype,"markerService",void 0),n.__decorate([(0,o.Autowired)(v.IEditorDocumentModelService),n.__metadata("design:type",Object)],E.prototype,"editorDocumentModelService",void 0),n.__decorate([(0,o.Autowired)(l.IAIReporter),n.__metadata("design:type",Object)],E.prototype,"aiReporter",void 0),n.__decorate([(0,l.OnEvent)(v.EditorGroupCloseEvent),n.__metadata("design:type",Function),n.__metadata("design:paramtypes",[v.EditorGroupCloseEvent]),n.__metadata("design:returntype",void 0)],E.prototype,"onEditorGroupClose",null),n.__decorate([(0,l.OnEvent)(v.EditorGroupOpenEvent),n.__metadata("design:type",Function),n.__metadata("design:paramtypes",[v.EditorGroupOpenEvent]),n.__metadata("design:returntype",Promise)],E.prototype,"onEditorGroupOpen",null)},75279:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPConfigView=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=e(97267),_=e(41869),v=e(43718),m=e(19413),p=n.__importDefault(e(76599)),s=e(51750),g=()=>{const a=(0,_.useInjectable)(v.MCPConfigServiceToken),[h,u]=o.default.useState([]),[c,E]=o.default.useState(!1),[f,d]=o.default.useState(),[y,b]=o.default.useState(),[A,S]=o.default.useState(a.isInitialized),D=(0,o.useCallback)(async()=>{const M=await a.getServers();u(M)},[a]);o.default.useEffect(()=>{D();const M=a.onMCPServersChange(k=>{k&&S(!0),D()});return()=>{M.dispose()}},[D]);const T=(0,o.useCallback)(async(M,k)=>{try{b(M),await a.controlServer(M,k),await D(),b(void 0)}catch{b(void 0)}},[a,D]),w=(0,o.useCallback)(()=>{d(void 0),E(!0)},[]),I=(0,o.useCallback)(async M=>{const k=await a.getServerConfigByName(M.name);k&&(d(k),E(!0))},[a]),O=(0,o.useCallback)(async M=>{await a.deleteServer(M),await D()},[a,D]),P=(0,o.useCallback)(async(M,k)=>{E(!1),await a.saveServer(M,k),M?.enabled&&(b(k.name),await a.controlServer(k.name,!0),b(void 0)),await D()},[a,D]),R=(0,o.useCallback)(async M=>{b(M.name),await a.syncServer(M.name),await D(),b(void 0)},[a,D]);return o.default.createElement("div",{className:p.default.container},o.default.createElement("div",{className:p.default.header},o.default.createElement("div",null,o.default.createElement("h2",{className:p.default.title},"MCP Servers"),o.default.createElement("p",{className:p.default.description},(0,v.localize)("ai.native.mcp.manage.connections"))),o.default.createElement("button",{className:p.default.actionButton,onClick:w},o.default.createElement(l.Icon,{icon:"plus",className:p.default.actionButtonIcon}),(0,v.localize)("ai.native.mcp.addMCPServer.title"))),o.default.createElement("div",{className:p.default.serversList},h.map(M=>o.default.createElement("div",{key:M.name,className:p.default.serverItem},o.default.createElement("div",{className:p.default.serverHeader},o.default.createElement("div",{className:p.default.serverTitleRow},o.default.createElement("h3",{className:p.default.serverName},M.name,o.default.createElement("span",{className:(0,r.default)(p.default.serverStatusIcon,M.isStarted?p.default.active:p.default.inactive)}))),o.default.createElement("div",{className:p.default.serverActions},o.default.createElement(l.Popover,{id:"mcp-server-action-popover",trigger:l.PopoverTriggerType.hover,content:M.isStarted?(0,v.localize)("ai.native.mcp.disable.title"):(0,v.localize)("ai.native.mcp.enable.title")},o.default.createElement(l.Button,{type:"default",className:(0,r.default)(p.default.serverActionButton,M.isStarted&&p.default.active),onClick:()=>T(M.name,!M.isStarted)},o.default.createElement("i",{className:`codicon ${y===M.name||!A&&M.name!==m.BUILTIN_MCP_SERVER_NAME&&!M.isStarted?"codicon-loading kt-icon-loading":M.isStarted?"codicon-check":"codicon-circle"}`}),o.default.createElement("span",null,(0,v.localize)(M.isStarted?"ai.native.mcp.enabled":"ai.native.mcp.disabled")))),M.name!==m.BUILTIN_MCP_SERVER_NAME&&o.default.createElement(l.Button,{type:"icon",iconClass:"codicon codicon-edit",className:p.default.iconButton,title:(0,v.localize)("ai.native.mcp.tool.action.edit"),onClick:()=>I(M)}),M.name!==m.BUILTIN_MCP_SERVER_NAME&&o.default.createElement(l.Button,{type:"icon",iconClass:"codicon codicon-sync",className:p.default.iconButton,title:(0,v.localize)("ai.native.mcp.tool.action.sync"),onClick:()=>R(M)}),M.name!==m.BUILTIN_MCP_SERVER_NAME&&o.default.createElement(l.Button,{type:"icon",iconClass:"codicon codicon-trash",className:p.default.iconButton,title:(0,v.localize)("ai.native.mcp.tool.action.delete"),onClick:()=>O(M.name)}))),o.default.createElement("div",{className:p.default.serverDetail},M.type&&o.default.createElement("div",{className:p.default.detailRow},o.default.createElement("span",{className:p.default.detailLabel},"Type:"),o.default.createElement(l.Badge,{className:(0,r.default)(p.default.serverType,p.default.typeTag)},a.getReadableServerType(M.type)))),M.tools&&M.tools.length>0&&o.default.createElement("div",{className:p.default.serverDetail},o.default.createElement("div",{className:p.default.detailRow},o.default.createElement("span",{className:p.default.detailLabel},"Tools:"),o.default.createElement("span",{className:p.default.detailContent},M.tools.map((k,F)=>o.default.createElement(l.Badge,{key:F,className:p.default.toolTag,title:k.description},k.name))))),M.command&&o.default.createElement("div",{className:p.default.serverDetail},o.default.createElement("div",{className:p.default.detailRow},o.default.createElement("span",{className:p.default.detailLabel},"Command:"),o.default.createElement("span",{className:p.default.detailContent},M.command))),M.url&&o.default.createElement("div",{className:p.default.serverDetail},o.default.createElement("div",{className:p.default.detailRow},o.default.createElement("span",{className:p.default.detailLabel},"Server Link:"),o.default.createElement("span",{className:(0,r.default)(p.default.detailContent,p.default.link)},M.url)))))),o.default.createElement(s.MCPServerForm,{visible:c,initialData:f,servers:h,onSave:M=>P(f,M),onCancel:()=>E(!1)}))};t.MCPConfigView=g},51750:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPServerForm=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=e(97267),_=e(48412),v=e(53017),m=e(41869),p=e(43718),s=e(72665),g=e(69820),a=n.__importDefault(e(83761)),h=({visible:u,initialData:c,onSave:E,onCancel:f,servers:d})=>{const[y,b]=(0,o.useState)(()=>({name:"",command:"",args:[],env:{},type:g.MCP_SERVER_TYPE.STDIO,...c})),A=(0,m.useInjectable)(s.IMessageService),[S,D]=(0,o.useState)(()=>{var B;return((B=c?.args)===null||B===void 0?void 0:B.join(" "))||""}),[T,w]=(0,o.useState)(()=>c?.env?Object.entries(c.env).map(([B,U])=>`${B}=${U}`).join(`
32478
32478
  `):"");(0,o.useEffect)(()=>{var B;b({name:"",command:"",args:[],env:{},type:g.MCP_SERVER_TYPE.STDIO,...c}),D(((B=c?.args)===null||B===void 0?void 0:B.join(" "))||""),w(c?.env?Object.entries(c.env).map(([U,W])=>`${U}=${W}`).join(`
32479
32479
  `):"")},[c]);const I=(0,o.useCallback)(B=>{var U,W;if(B.name.trim()==="")return A.error((0,p.localize)("ai.native.mcp.name.isRequired")),!1;if(!c&&d.some(Q=>Q.name.toLocaleLowerCase()===B.name.toLocaleLowerCase()))return A.error((0,p.formatLocalize)("ai.native.mcp.serverNameExists",B.name)),!1;if(B.type===g.MCP_SERVER_TYPE.SSE){const Q=((U=B.url)===null||U===void 0?void 0:U.trim())!=="";return Q||A.error((0,p.localize)("ai.native.mcp.url.isRequired")),Q}const j=((W=B.command)===null||W===void 0?void 0:W.trim())!=="";return j||A.error((0,p.localize)("ai.native.mcp.command.isRequired")),j},[d,c]),O=(0,o.useCallback)(B=>{var U;if(B.preventDefault(),!I(y))return;const j={...y};if(j.command&&(j.command=j.command.trim()),j.url&&(j.url=j.url.trim()),y.type===g.MCP_SERVER_TYPE.SSE)j.url=(U=j.url)===null||U===void 0?void 0:U.trim();else{const Q=S.split(" ").filter(Boolean),G=T.split(`
32480
- `).filter(Boolean).reduce((Z,$)=>{const[V,H]=$.split("=");return V&&H&&(Z[V.trim()]=H.trim()),Z},{});j.args=Q,j.env=G}b({...y,name:"",command:"",url:"",args:[],env:{}}),E(j)},[y,S,T,E,I]),P=(0,o.useCallback)(B=>{b({...y,command:B.target.value})},[y,S]),R=(0,o.useCallback)(B=>{D(B.target.value)},[S]),M=(0,o.useCallback)(B=>{w(B.target.value)},[T]),k=(0,o.useCallback)(B=>{b({...y,url:B.target.value})},[y]),F=(0,o.useCallback)(B=>{b({...y,type:B,command:"",args:[],env:{},url:""})},[y]),L=(0,o.useCallback)(()=>y?.type===g.MCP_SERVER_TYPE.STDIO?o.default.createElement(o.default.Fragment,null,o.default.createElement("div",{className:a.default.formItem},o.default.createElement("label",null,(0,p.localize)("ai.native.mcp.command")),o.default.createElement("input",{type:"text",value:y.command,onChange:P,placeholder:(0,p.localize)("ai.native.mcp.command.placeHolder"),required:!0})),o.default.createElement("div",{className:a.default.formItem},o.default.createElement("label",null,(0,p.localize)("ai.native.mcp.args")),o.default.createElement("textarea",{value:S,onChange:R,placeholder:(0,p.localize)("ai.native.mcp.args.placeHolder"),rows:3})),o.default.createElement("div",{className:a.default.formItem},o.default.createElement("label",null,(0,p.localize)("ai.native.mcp.env")),o.default.createElement("textarea",{value:T,onChange:M,placeholder:(0,p.localize)("ai.native.mcp.env.placeHolder"),rows:3}))):o.default.createElement(o.default.Fragment,null,o.default.createElement("div",{className:a.default.formItem},o.default.createElement("label",null,(0,p.localize)("ai.native.mcp.url")),o.default.createElement("textarea",{value:y.url,onChange:k,placeholder:(0,p.localize)("ai.native.mcp.url.placeHolder"),rows:3}))),[y,S,T]);return o.default.createElement(v.Modal,{title:c?(0,p.localize)("ai.native.mcp.editMCPServer.title"):(0,p.localize)("ai.native.mcp.addMCPServer.title"),visible:u,onCancel:f,centered:!0,width:600,footer:null,style:{background:"var(--editor-background)"}},o.default.createElement("form",{className:a.default.form,onSubmit:B=>B.preventDefault()},o.default.createElement("div",{className:a.default.formRow},o.default.createElement("div",{className:(0,r.default)(a.default.formItem,a.default.formItemName)},o.default.createElement("label",null,(0,p.localize)("ai.native.mcp.name")),o.default.createElement("input",{type:"text",value:y.name,onChange:B=>b({...y,name:B.target.value}),placeholder:(0,p.localize)("ai.native.mcp.name.placeHolder"),required:!0})),o.default.createElement("div",{className:(0,r.default)(a.default.formItem,a.default.formItemType)},o.default.createElement("label",null,(0,p.localize)("ai.native.mcp.type")),o.default.createElement(l.Select,{size:"large",value:y.type,options:[{label:(0,p.localize)("ai.native.mcp.stdio"),value:g.MCP_SERVER_TYPE.STDIO},{label:(0,p.localize)("ai.native.mcp.sse"),value:g.MCP_SERVER_TYPE.SSE}],className:a.default.formItemSelect,onChange:F}))),L(),o.default.createElement("div",{className:a.default.formActions},o.default.createElement(_.Button,{onClick:f,type:"primary",className:a.default.secondaryButton},(0,p.localize)("ai.native.mcp.buttonCancel")),o.default.createElement(_.Button,{onClick:O,type:"primary"},c?(0,p.localize)("ai.native.mcp.buttonUpdate"):(0,p.localize)("ai.native.mcp.buttonSave")))))};t.MCPServerForm=h},27397:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPConfigCommandContribution=t.MCPConfigCommands=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(43718),_=e(54414),v=e(5297),m=e(33108);var p;(function(g){g.OPEN_MCP_CONFIG={id:"mcp.openConfig",label:"Open MCP Configuration"},g.OPEN_MCP_CONFIG_FILE={id:"mcp.openConfigFile",label:"Open MCP Configuration (JSON)"}})(p||(t.MCPConfigCommands=p={}));let s=class{registerCommands(a){a.registerCommand(p.OPEN_MCP_CONFIG,{execute:()=>{const h=new o.URI().withScheme(v.MCP_CONFIG_COMPONENTS_SCHEME_ID);this.editorService.open(h,{preview:!1,focus:!0})}}),a.registerCommand(p.OPEN_MCP_CONFIG_FILE,{execute:()=>{this.mcpConfigService.openConfigFile()}})}};t.MCPConfigCommandContribution=s,n.__decorate([(0,r.Autowired)(_.WorkbenchEditorService),n.__metadata("design:type",_.WorkbenchEditorService)],s.prototype,"editorService",void 0),n.__decorate([(0,r.Autowired)(l.MCPConfigServiceToken),n.__metadata("design:type",m.MCPConfigService)],s.prototype,"mcpConfigService",void 0),t.MCPConfigCommandContribution=s=n.__decorate([(0,l.Domain)(o.CommandContribution)],s)},5297:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPConfigContribution=t.MCP_CONFIG_COMPONENTS_SCHEME_ID=void 0;const n=e(85608),r=e(76003),o=e(97267),l=e(93899),_=e(39496),v=e(26542),m=e(43718),p=e(82196),s=e(7443),g=e(10560),a=e(75279),h=e(27397),u="opensumi-mcp-config-viewer";t.MCP_CONFIG_COMPONENTS_SCHEME_ID="mcp-config";let c=class{registerEditorComponent(f){f.registerEditorComponent({uid:u,scheme:t.MCP_CONFIG_COMPONENTS_SCHEME_ID,component:a.MCPConfigView,renderMode:p.EditorComponentRenderMode.ONE_PER_WORKBENCH}),f.registerEditorComponentResolver(t.MCP_CONFIG_COMPONENTS_SCHEME_ID,(d,y)=>{y.push({type:"component",componentId:u})})}registerResource(f){f.registerResourceProvider({scheme:t.MCP_CONFIG_COMPONENTS_SCHEME_ID,provideResource:async d=>{const{configType:y}=d.getParsedQuery();return{uri:d,name:(0,m.localize)("ai.native.mcp.config.title"),icon:(0,o.getIcon)("mcp"),metadata:{configType:y}}}})}registerMenus(f){f.registerMenuItem(_.MenuId.EditorTitle,{command:h.MCPConfigCommands.OPEN_MCP_CONFIG_FILE.id,iconClass:(0,o.getIcon)("open"),group:"navigation",order:4,when:`resourceScheme == ${t.MCP_CONFIG_COMPONENTS_SCHEME_ID}`}),f.registerMenuItem(_.MenuId.EditorTitle,{command:h.MCPConfigCommands.OPEN_MCP_CONFIG.id,iconClass:(0,o.getIcon)("open"),group:"navigation",order:4,when:"resourceFilename =~ /mcp.json/"})}};t.MCPConfigContribution=c,n.__decorate([(0,r.Autowired)(g.IWorkspaceService),n.__metadata("design:type",Object)],c.prototype,"workspaceService",void 0),n.__decorate([(0,r.Autowired)(s.IconService),n.__metadata("design:type",s.IconService)],c.prototype,"iconService",void 0),n.__decorate([(0,r.Autowired)(),n.__metadata("design:type",v.LabelService)],c.prototype,"labelService",void 0),t.MCPConfigContribution=c=n.__decorate([(0,m.Domain)(p.BrowserEditorContribution,l.MenuContribution)],c)},33108:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPConfigService=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(78132),_=e(43718),v=e(54414),m=e(72665),p=e(19413),s=e(64811),g=e(69820),a=e(45331);let h=class extends _.Disposable{constructor(){super(),this.whenReadyDeferred=new _.Deferred,this._isInitialized=!1,this.mcpServersChangeEventEmitter=new _.Emitter,this.init(),this.disposables.push(this.mcpServerProxyService.onChangeMCPServers(()=>{this.fireMCPServersChange()})),this.disposables.push(this.preferenceService.onSpecificPreferenceChange("mcp",()=>{this.fireMCPServersChange()}))}async init(){this.chatStorage=await this.storageProvider(_.STORAGE_NAMESPACE.CHAT),this.whenReadyDeferred.resolve()}get whenReady(){return this.whenReadyDeferred.promise}get isInitialized(){return this._isInitialized}get onMCPServersChange(){return this.mcpServersChangeEventEmitter.event}fireMCPServersChange(c=!1){c&&(this._isInitialized=!0),this.mcpServersChangeEventEmitter.fire(c)}async getServers(){const{value:c,scope:E}=this.preferenceService.resolve("mcp",{mcpServers:{}},void 0);if(E===_.PreferenceScope.Default){const S=(await this.mcpServerProxyService.$getServers()).find(D=>D.name===p.BUILTIN_MCP_SERVER_NAME);return S?[S]:[]}const f=Object.keys(c.mcpServers).map(A=>{const S=c.mcpServers[A];return S.url?{name:A,type:g.MCP_SERVER_TYPE.SSE,url:S.url}:{name:A,type:g.MCP_SERVER_TYPE.STDIO,command:S.command,args:S.args,env:S.env}}),d=await this.mcpServerProxyService.$getServers(),y=d.find(A=>A.name===p.BUILTIN_MCP_SERVER_NAME),b=f?.map(A=>{const S=d.find(D=>D.name===A.name);return S||this.sumiMCPServerBackendProxy.$addOrUpdateServer(A),{...A,isStarted:S?.isStarted||!1,tools:S?.tools||[]}});return y&&b.unshift(y),b}async controlServer(c,E){try{E?await this.mcpServerProxyService.$startServer(c):await this.mcpServerProxyService.$stopServer(c);const f=this.chatStorage.get(s.MCPServersEnabledKey,[p.BUILTIN_MCP_SERVER_NAME]),d=new Set(f);E?d.add(c):d.delete(c),this.chatStorage.set(s.MCPServersEnabledKey,Array.from(d))}catch(f){const d=f.message||f;throw this.logger.error(`Failed to ${E?"start":"stop"} server ${c}:`,d),this.messageService.error(d),f}}async saveServer(c,E){await this.whenReady;const{value:f}=this.preferenceService.resolve("mcp",{mcpServers:{}},void 0),d=f.mcpServers;let y;E.type===g.MCP_SERVER_TYPE.SSE?y={url:E.url}:y={command:E.command,args:E.args,env:E.env},c?.name&&delete d[c.name],d[E.name]=y,await this.preferenceService.set("mcp",{mcpServers:d}),c?.enabled&&this.sumiMCPServerBackendProxy.$removeServer(c.name),this.sumiMCPServerBackendProxy.$addOrUpdateServer(E)}async deleteServer(c){const{value:E}=this.preferenceService.resolve("mcp",{mcpServers:{}},void 0),f=E.mcpServers;f[c]&&(delete f[c],await this.sumiMCPServerBackendProxy.$removeServer(c),await this.preferenceService.set("mcp",{mcpServers:f}))}async syncServer(c){try{await this.sumiMCPServerBackendProxy.$syncServer(c)}catch(E){this.logger.error(`Failed to sync server ${c}:`,E),this.messageService.error(E.message||E)}}async getServerConfigByName(c){const{value:E}=this.preferenceService.resolve("mcp",{mcpServers:{}},void 0);await this.whenReady;const f=this.chatStorage.get(s.MCPServersEnabledKey,[p.BUILTIN_MCP_SERVER_NAME]),d=E.mcpServers[c];if(d)return d.url?{name:c,type:g.MCP_SERVER_TYPE.SSE,url:d.url,enabled:f.includes(c)}:{name:c,type:g.MCP_SERVER_TYPE.STDIO,command:d.command,args:d.args,env:d.env,enabled:f.includes(c)}}getReadableServerType(c){switch(c){case g.MCP_SERVER_TYPE.STDIO:return(0,_.localize)("ai.native.mcp.type.stdio");case g.MCP_SERVER_TYPE.SSE:return(0,_.localize)("ai.native.mcp.type.sse");case g.MCP_SERVER_TYPE.BUILTIN:return(0,_.localize)("ai.native.mcp.type.builtin");default:return c}}async openConfigFile(){let c=this.preferenceService.resolve("mcp",{mcpServers:{}},void 0);c.scope===_.PreferenceScope.Default&&(await this.preferenceService.set("mcp",{mcpServers:{}},_.PreferenceScope.Workspace),c=this.preferenceService.resolve("mcp",{mcpServers:{}},void 0));const E=c.configUri;E&&this.workbenchEditorService.open(E,{preview:!1})}};t.MCPConfigService=h,n.__decorate([(0,r.Autowired)(p.SumiMCPServerProxyServicePath),n.__metadata("design:type",Object)],h.prototype,"sumiMCPServerBackendProxy",void 0),n.__decorate([(0,r.Autowired)(a.MCPServerProxyService),n.__metadata("design:type",a.MCPServerProxyService)],h.prototype,"mcpServerProxyService",void 0),n.__decorate([(0,r.Autowired)(l.PreferenceService),n.__metadata("design:type",Object)],h.prototype,"preferenceService",void 0),n.__decorate([(0,r.Autowired)(m.IMessageService),n.__metadata("design:type",Object)],h.prototype,"messageService",void 0),n.__decorate([(0,r.Autowired)(_.StorageProvider),n.__metadata("design:type",Function)],h.prototype,"storageProvider",void 0),n.__decorate([(0,r.Autowired)(v.WorkbenchEditorService),n.__metadata("design:type",v.WorkbenchEditorService)],h.prototype,"workbenchEditorService",void 0),n.__decorate([(0,r.Autowired)(o.ILogger),n.__metadata("design:type",Object)],h.prototype,"logger",void 0),t.MCPConfigService=h=n.__decorate([(0,r.Injectable)(),n.__metadata("design:paramtypes",[])],h)},33368:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPFolderPreferenceProvider=void 0;const n=e(85608),r=e(76003),o=e(91825);let l=class extends o.FolderFilePreferenceProvider{parse(v){const m=super.parse(v);if(m!==void 0)return{mcp:{...m}}}getPath(v){if(v==="mcp")return[];if(v.startsWith("mcp."))return[v.substr(4)]}};t.MCPFolderPreferenceProvider=l,t.MCPFolderPreferenceProvider=l=n.__decorate([(0,r.Injectable)()],l)},55003:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPPreferencesContribution=t.MCPResourceProvider=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(57517),_=e(924);let v=class{provideResource(s){return{supportsRevive:!0,name:(0,o.localize)("menu-bar.title.debug"),icon:(0,o.getIcon)("debug"),uri:s}}provideResourceSubname(){return null}async shouldCloseResource(){return!0}};t.MCPResourceProvider=v,t.MCPResourceProvider=v=n.__decorate([(0,r.Injectable)()],v);let m=class{constructor(){this.schema=_.MCPPreferencesSchema,this.name="mcp"}registerResource(s){s.registerResourceProvider(this.prefResourceProvider)}registerSchema(s){s.registerSchema(_.MCPSchemaUri,_.MCPSchema,["mcp.json"])}};t.MCPPreferencesContribution=m,n.__decorate([(0,r.Autowired)(v),n.__metadata("design:type",v)],m.prototype,"prefResourceProvider",void 0),t.MCPPreferencesContribution=m=n.__decorate([(0,o.Domain)(o.PreferenceContribution,o.PreferenceConfiguration,l.BrowserEditorContribution,o.JsonSchemaContribution)],m)},924:(x,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPSchema=t.MCPPreferencesSchema=t.MCPSchemaUri=void 0,t.MCPSchemaUri="vscode://schemas/mcp/user",t.MCPPreferencesSchema={type:"object",scope:"resource",properties:{mcp:{$ref:t.MCPSchemaUri,description:"MCP configuration for Workspace.",defaultValue:{mcpServers:{}}}}},t.MCPSchema={$id:t.MCPSchemaUri,type:"object",title:"MCP",required:[],default:{mcpServers:{}},properties:{mcpServers:{type:"object",description:"List of MCP Servers. Add new servers or edit existing ones by using IntelliSense.",additionalProperties:{type:"object",properties:{command:{type:"string",description:"The command to start the MCP server."},args:{type:"array",description:"The arguments for the command to start the MCP server.",items:{type:"string"}},env:{type:"object",description:"The environment variables for the command to start the MCP server.",additionalProperties:{type:"string"}},url:{type:"string",description:"The SSE URL for the MCP server."}},oneOf:[{required:["command"]},{required:["url"]}]}}}}},45331:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPServerProxyService=void 0;const n=e(85608),r=e(48085),o=e(76003),l=e(41869),_=e(43718),v=e(19413),m=e(36059),p=e(77633);let s=class{constructor(){this._onChangeMCPServers=new _.Emitter,this.onChangeMCPServers=this._onChangeMCPServers.event}$callMCPTool(a,h){return this.mcpServerRegistry.callMCPTool(a,h)}async $getBuiltinMCPTools(){const a=await this.mcpServerRegistry.getMCPTools().map(h=>({name:h.name,description:h.description,inputSchema:(0,r.zodToJsonSchema)(h.inputSchema),providerName:v.BUILTIN_MCP_SERVER_NAME}));return this.logger.log("SUMI MCP tools",a),a}async $updateMCPServers(){this._onChangeMCPServers.fire("update")}async getAllMCPTools(){return this.sumiMCPServerProxyService.$getAllMCPTools()}async $getServers(){return this.sumiMCPServerProxyService.$getServers()}async $startServer(a){await this.sumiMCPServerProxyService.$startServer(a)}async $stopServer(a){await this.sumiMCPServerProxyService.$stopServer(a)}async $compressToolResult(a,h){return(0,m.compressToolResultSmart)(a,h)}};t.MCPServerProxyService=s,n.__decorate([(0,o.Autowired)(p.TokenMCPServerRegistry),n.__metadata("design:type",Object)],s.prototype,"mcpServerRegistry",void 0),n.__decorate([(0,o.Autowired)(l.ILogger),n.__metadata("design:type",Object)],s.prototype,"logger",void 0),n.__decorate([(0,o.Autowired)(v.SumiMCPServerProxyServicePath),n.__metadata("design:type",Object)],s.prototype,"sumiMCPServerProxyService",void 0),t.MCPServerProxyService=s=n.__decorate([(0,o.Injectable)()],s)},79502:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPServerRegistry=void 0;const n=e(85608),r=e(76003),o=e(43718),l=e(19413),_=e(98864);class v{constructor(s){this.logger=s}appendLine(s){this.logger.log(s)}}let m=class{constructor(){this.tools=[],this.toolComponents={}}get logger(){return new v(this.baseLogger)}set activeMessageInfo(s){this._activeMessageInfo=s}getMCPTool(s,g=l.BUILTIN_MCP_SERVER_NAME){return this.tools.find(a=>(0,_.getToolName)(a.name,g)===s)}registerMCPTool(s){this.tools.push(s)}registerToolComponent(s,g,a=l.BUILTIN_MCP_SERVER_NAME){this.toolComponents[(0,_.getToolName)(s,a)]=g}getToolComponent(s){return this.toolComponents[s]}getMCPTools(){return this.tools.sort((s,g)=>{var a,h;return((a=s.order)!==null&&a!==void 0?a:1/0)-((h=g.order)!==null&&h!==void 0?h:1/0)})}async callMCPTool(s,g){try{const a=this.tools.find(c=>c.name===s);if(!a)throw new Error(`MCP tool ${s} not found`);const h=g.toolCallId;g=a.inputSchema.parse(g);const u=await a.handler({...g,toolCallId:h},this.logger);return this.reportToolCall(s,g,u,h),u}catch(a){return console.error("callMCPTool error:",a),this.reportToolCall(s,g,a,g.toolCallId),{content:[{type:"text",text:`The tool ${s} failed to execute. Error: ${a}`}],isError:!0}}}reportToolCall(s,g,a,h){if(!this.tools.find(c=>c.name===s))throw new Error(`MCP tool ${s} not found`);this.aiReporter.send({msgType:o.AIServiceType.ToolCall,message:JSON.stringify({args:g,name:s,result:a}),messageId:this._activeMessageInfo.messageId,sessionId:this._activeMessageInfo.sessionId,relationId:h})}};t.MCPServerRegistry=m,n.__decorate([(0,r.Autowired)(o.ILogger),n.__metadata("design:type",Object)],m.prototype,"baseLogger",void 0),n.__decorate([(0,r.Autowired)(o.IAIReporter),n.__metadata("design:type",Object)],m.prototype,"aiReporter",void 0),t.MCPServerRegistry=m=n.__decorate([(0,r.Injectable)()],m)},30703:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPToolsDialog=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=n.__importDefault(e(49783)),l=({tools:_})=>r.createElement("div",{className:o.default.mcp_tools_dialog},r.createElement("div",{className:o.default.dialog_title},"MCP Tools"),r.createElement("div",{className:o.default.tools_list},_.map(v=>r.createElement("div",{key:v.name,className:o.default.tool_item},r.createElement("div",{className:o.default.tool_name},v.name),r.createElement("div",{className:o.default.tool_description},v.description),v.providerName&&r.createElement("div",{className:o.default.tool_provider},"Provider: ",v.providerName)))));t.MCPToolsDialog=l},58260:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditFileToolComponent=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=e(97267),_=e(41869),v=e(54414),m=e(14162),p=e(87822),s=e(16781),g=e(21967),a=e(56474),h=e(73974),u=n.__importDefault(e(51601)),c=E=>{var f,d,y;const{args:b,messageId:A,toolCallId:S}=E,[D,T]=(0,o.useState)("code"),w=(0,_.useInjectable)(_.LabelService),I=(0,_.useInjectable)(_.AppConfig),O=(0,_.useInjectable)(h.BaseApplyService),P=(0,_.useInjectable)(v.WorkbenchEditorService),{target_file:R="",code_edit:M,instructions:k}=b||{},F=_.path.join(I.workspaceDir,R),[L,B]=(0,o.useState)(O.getCodeBlock(S,A)),U=(0,o.useMemo)(()=>R?`file-icon ${w.getIcon(_.URI.file(F))}`:void 0,[R,F]),W=(0,o.useMemo)(()=>{if(!R)return;const G=s.StandaloneServices.get(p.IModelService),Z=s.StandaloneServices.get(m.ILanguageService);return(0,_.detectModeId)(G,Z,_.Uri.file(F))},[R,F]),j=(0,o.useMemo)(()=>{var G,Z;if(L?.status==="failed")try{return(Z=(G=JSON.parse(E.result||"{}").content)===null||G===void 0?void 0:G[0])===null||Z===void 0?void 0:Z.text}catch{return""}},[E.result,L]);(0,o.useEffect)(()=>{const G=O.onCodeBlockUpdate(Z=>{Z.toolCallId===S&&B({...Z})});return()=>{G.dispose()}},[]);const Q=G=>{G.stopPropagation(),T(D==="code"?"diff":"code")};return!b||!L?null:[k&&o.default.createElement("p",{key:"edit-file-tool-instructions"},k),o.default.createElement("div",{className:u.default["edit-file-tool"],key:"edit-file-tool"},o.default.createElement("div",{className:(0,r.default)(u.default["edit-file-tool-header"],{clickable:L.status==="pending"||L.status==="success"}),onClick:()=>{L.status==="pending"?P.open(_.URI.file(F)):L.status==="success"&&O.revealApplyPosition(L)}},o.default.createElement("div",{className:u.default.left},U&&o.default.createElement("span",{className:U}),o.default.createElement("span",{className:u.default["edit-file-tool-file-name"]},R),L.iterationCount>1&&o.default.createElement("span",{className:u.default["edit-file-tool-iteration-count"]},L.iterationCount,"/3"),o.default.createElement(g.ApplyStatus,{status:L.status,error:j})),o.default.createElement("div",{className:u.default.right},o.default.createElement(l.Popover,{title:"Show Code",id:"edit-file-tool-show-code"},o.default.createElement(l.Icon,{iconClass:"codicon codicon-file-code",onClick:Q})),((f=L.applyResult)===null||f===void 0?void 0:f.diff)&&o.default.createElement(l.Popover,{title:"Show Diff",id:"edit-file-tool-show-diff"},o.default.createElement(l.Icon,{iconClass:"codicon codicon-diff-multiple",onClick:Q})))),o.default.createElement(a.ChatMarkdown,{markdown:D==="code"?`\`\`\`${W||""}
32480
+ `).filter(Boolean).reduce((Z,$)=>{const[V,H]=$.split("=");return V&&H&&(Z[V.trim()]=H.trim()),Z},{});j.args=Q,j.env=G}b({...y,name:"",command:"",url:"",args:[],env:{}}),E(j)},[y,S,T,E,I]),P=(0,o.useCallback)(B=>{b({...y,command:B.target.value})},[y,S]),R=(0,o.useCallback)(B=>{D(B.target.value)},[S]),M=(0,o.useCallback)(B=>{w(B.target.value)},[T]),k=(0,o.useCallback)(B=>{b({...y,url:B.target.value})},[y]),F=(0,o.useCallback)(B=>{b({...y,type:B,command:"",args:[],env:{},url:""})},[y]),L=(0,o.useCallback)(()=>y?.type===g.MCP_SERVER_TYPE.STDIO?o.default.createElement(o.default.Fragment,null,o.default.createElement("div",{className:a.default.formItem},o.default.createElement("label",null,(0,p.localize)("ai.native.mcp.command")),o.default.createElement("input",{type:"text",value:y.command,onChange:P,placeholder:(0,p.localize)("ai.native.mcp.command.placeHolder"),required:!0})),o.default.createElement("div",{className:a.default.formItem},o.default.createElement("label",null,(0,p.localize)("ai.native.mcp.args")),o.default.createElement("textarea",{value:S,onChange:R,placeholder:(0,p.localize)("ai.native.mcp.args.placeHolder"),rows:3})),o.default.createElement("div",{className:a.default.formItem},o.default.createElement("label",null,(0,p.localize)("ai.native.mcp.env")),o.default.createElement("textarea",{value:T,onChange:M,placeholder:(0,p.localize)("ai.native.mcp.env.placeHolder"),rows:3}))):o.default.createElement(o.default.Fragment,null,o.default.createElement("div",{className:a.default.formItem},o.default.createElement("label",null,(0,p.localize)("ai.native.mcp.url")),o.default.createElement("textarea",{value:y.url,onChange:k,placeholder:(0,p.localize)("ai.native.mcp.url.placeHolder"),rows:3}))),[y,S,T]);return o.default.createElement(v.Modal,{title:c?(0,p.localize)("ai.native.mcp.editMCPServer.title"):(0,p.localize)("ai.native.mcp.addMCPServer.title"),visible:u,onCancel:f,centered:!0,width:600,footer:null,style:{background:"var(--editor-background)"}},o.default.createElement("form",{className:a.default.form,onSubmit:B=>B.preventDefault()},o.default.createElement("div",{className:a.default.formRow},o.default.createElement("div",{className:(0,r.default)(a.default.formItem,a.default.formItemName)},o.default.createElement("label",null,(0,p.localize)("ai.native.mcp.name")),o.default.createElement("input",{type:"text",value:y.name,onChange:B=>b({...y,name:B.target.value}),placeholder:(0,p.localize)("ai.native.mcp.name.placeHolder"),required:!0})),o.default.createElement("div",{className:(0,r.default)(a.default.formItem,a.default.formItemType)},o.default.createElement("label",null,(0,p.localize)("ai.native.mcp.type")),o.default.createElement(l.Select,{size:"large",value:y.type,options:[{label:(0,p.localize)("ai.native.mcp.stdio"),value:g.MCP_SERVER_TYPE.STDIO},{label:(0,p.localize)("ai.native.mcp.sse"),value:g.MCP_SERVER_TYPE.SSE}],className:a.default.formItemSelect,onChange:F}))),L(),o.default.createElement("div",{className:a.default.formActions},o.default.createElement(_.Button,{onClick:f,type:"primary",className:a.default.secondaryButton},(0,p.localize)("ai.native.mcp.buttonCancel")),o.default.createElement(_.Button,{onClick:O,type:"primary"},c?(0,p.localize)("ai.native.mcp.buttonUpdate"):(0,p.localize)("ai.native.mcp.buttonSave")))))};t.MCPServerForm=h},27397:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPConfigCommandContribution=t.MCPConfigCommands=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(43718),_=e(54414),v=e(5297),m=e(33108);var p;(function(g){g.OPEN_MCP_CONFIG={id:"mcp.openConfig",label:"Open MCP Configuration"},g.OPEN_MCP_CONFIG_FILE={id:"mcp.openConfigFile",label:"Open MCP Configuration (JSON)"}})(p||(t.MCPConfigCommands=p={}));let s=class{registerCommands(a){a.registerCommand(p.OPEN_MCP_CONFIG,{execute:()=>{const h=new o.URI().withScheme(v.MCP_CONFIG_COMPONENTS_SCHEME_ID);this.editorService.open(h,{preview:!1,focus:!0})}}),a.registerCommand(p.OPEN_MCP_CONFIG_FILE,{execute:()=>{this.mcpConfigService.openConfigFile()}})}};t.MCPConfigCommandContribution=s,n.__decorate([(0,r.Autowired)(_.WorkbenchEditorService),n.__metadata("design:type",_.WorkbenchEditorService)],s.prototype,"editorService",void 0),n.__decorate([(0,r.Autowired)(l.MCPConfigServiceToken),n.__metadata("design:type",m.MCPConfigService)],s.prototype,"mcpConfigService",void 0),t.MCPConfigCommandContribution=s=n.__decorate([(0,l.Domain)(o.CommandContribution)],s)},5297:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPConfigContribution=t.MCP_CONFIG_COMPONENTS_SCHEME_ID=void 0;const n=e(85608),r=e(76003),o=e(97267),l=e(93899),_=e(39496),v=e(26542),m=e(43718),p=e(82196),s=e(7443),g=e(10560),a=e(75279),h=e(27397),u="opensumi-mcp-config-viewer";t.MCP_CONFIG_COMPONENTS_SCHEME_ID="mcp-config";let c=class{registerEditorComponent(f){f.registerEditorComponent({uid:u,scheme:t.MCP_CONFIG_COMPONENTS_SCHEME_ID,component:a.MCPConfigView,renderMode:p.EditorComponentRenderMode.ONE_PER_WORKBENCH}),f.registerEditorComponentResolver(t.MCP_CONFIG_COMPONENTS_SCHEME_ID,(d,y)=>{y.push({type:"component",componentId:u})})}registerResource(f){f.registerResourceProvider({scheme:t.MCP_CONFIG_COMPONENTS_SCHEME_ID,provideResource:async d=>{const{configType:y}=d.getParsedQuery();return{uri:d,name:(0,m.localize)("ai.native.mcp.config.title"),icon:(0,o.getIcon)("mcp"),metadata:{configType:y}}}})}registerMenus(f){f.registerMenuItem(_.MenuId.EditorTitle,{command:h.MCPConfigCommands.OPEN_MCP_CONFIG_FILE.id,iconClass:(0,o.getIcon)("open"),group:"navigation",order:4,when:`resourceScheme == ${t.MCP_CONFIG_COMPONENTS_SCHEME_ID}`}),f.registerMenuItem(_.MenuId.EditorTitle,{command:h.MCPConfigCommands.OPEN_MCP_CONFIG.id,iconClass:(0,o.getIcon)("open"),group:"navigation",order:4,when:"resourceFilename =~ /mcp.json/"})}};t.MCPConfigContribution=c,n.__decorate([(0,r.Autowired)(g.IWorkspaceService),n.__metadata("design:type",Object)],c.prototype,"workspaceService",void 0),n.__decorate([(0,r.Autowired)(s.IconService),n.__metadata("design:type",s.IconService)],c.prototype,"iconService",void 0),n.__decorate([(0,r.Autowired)(),n.__metadata("design:type",v.LabelService)],c.prototype,"labelService",void 0),t.MCPConfigContribution=c=n.__decorate([(0,m.Domain)(p.BrowserEditorContribution,l.MenuContribution)],c)},33108:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPConfigService=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(78132),_=e(43718),v=e(54414),m=e(72665),p=e(19413),s=e(64811),g=e(69820),a=e(45331);let h=class extends _.Disposable{constructor(){super(),this.whenReadyDeferred=new _.Deferred,this._isInitialized=!1,this.mcpServersChangeEventEmitter=new _.Emitter,this.init(),this.disposables.push(this.mcpServerProxyService.onChangeMCPServers(()=>{this.fireMCPServersChange()})),this.disposables.push(this.preferenceService.onSpecificPreferenceChange("mcp",()=>{this.fireMCPServersChange()}))}async init(){this.chatStorage=await this.storageProvider(_.STORAGE_NAMESPACE.CHAT),this.whenReadyDeferred.resolve()}get whenReady(){return this.whenReadyDeferred.promise}get isInitialized(){return this._isInitialized}get onMCPServersChange(){return this.mcpServersChangeEventEmitter.event}fireMCPServersChange(c=!1){c&&(this._isInitialized=!0),this.mcpServersChangeEventEmitter.fire(c)}async getServers(){const{value:c,scope:E}=this.preferenceService.resolve("mcp",{mcpServers:{}},void 0);if(E===_.PreferenceScope.Default){const S=(await this.mcpServerProxyService.$getServers()).find(D=>D.name===p.BUILTIN_MCP_SERVER_NAME);return S?[S]:[]}const f=Object.keys(c.mcpServers).map(A=>{const S=c.mcpServers[A];return S.url?{name:A,type:g.MCP_SERVER_TYPE.SSE,url:S.url}:{name:A,type:g.MCP_SERVER_TYPE.STDIO,command:S.command,args:S.args,env:S.env}}),d=await this.mcpServerProxyService.$getServers(),y=d.find(A=>A.name===p.BUILTIN_MCP_SERVER_NAME),b=f?.map(A=>{const S=d.find(D=>D.name===A.name);return S||this.sumiMCPServerBackendProxy.$addOrUpdateServer(A),{...A,isStarted:S?.isStarted||!1,tools:S?.tools||[]}});return y&&b.unshift(y),b}async controlServer(c,E){try{E?await this.mcpServerProxyService.$startServer(c):await this.mcpServerProxyService.$stopServer(c);const f=this.chatStorage.get(s.MCPServersEnabledKey,[p.BUILTIN_MCP_SERVER_NAME]),d=new Set(f);E?d.add(c):d.delete(c),this.chatStorage.set(s.MCPServersEnabledKey,Array.from(d))}catch(f){const d=f.message||f;throw this.logger.error(`Failed to ${E?"start":"stop"} server ${c}:`,d),this.messageService.error(d),f}}async saveServer(c,E){await this.whenReady;const{value:f}=this.preferenceService.resolve("mcp",{mcpServers:{}},void 0),d=f.mcpServers;let y;E.type===g.MCP_SERVER_TYPE.SSE?y={url:E.url}:y={command:E.command,args:E.args,env:E.env},c?.name&&delete d[c.name],d[E.name]=y,await this.preferenceService.set("mcp",{mcpServers:d}),c?.enabled&&this.sumiMCPServerBackendProxy.$removeServer(c.name),this.sumiMCPServerBackendProxy.$addOrUpdateServer(E)}async deleteServer(c){const{value:E}=this.preferenceService.resolve("mcp",{mcpServers:{}},void 0),f=E.mcpServers;f[c]&&(delete f[c],await this.sumiMCPServerBackendProxy.$removeServer(c),await this.preferenceService.set("mcp",{mcpServers:f}))}async syncServer(c){try{await this.sumiMCPServerBackendProxy.$syncServer(c)}catch(E){this.logger.error(`Failed to sync server ${c}:`,E),this.messageService.error(E.message||E)}}async getServerConfigByName(c){const{value:E}=this.preferenceService.resolve("mcp",{mcpServers:{}},void 0);await this.whenReady;const f=this.chatStorage.get(s.MCPServersEnabledKey,[p.BUILTIN_MCP_SERVER_NAME]),d=E.mcpServers[c];if(d)return d.url?{name:c,type:g.MCP_SERVER_TYPE.SSE,url:d.url,enabled:f.includes(c)}:{name:c,type:g.MCP_SERVER_TYPE.STDIO,command:d.command,args:d.args,env:d.env,enabled:f.includes(c)}}getReadableServerType(c){switch(c){case g.MCP_SERVER_TYPE.STDIO:return(0,_.localize)("ai.native.mcp.type.stdio");case g.MCP_SERVER_TYPE.SSE:return(0,_.localize)("ai.native.mcp.type.sse");case g.MCP_SERVER_TYPE.BUILTIN:return(0,_.localize)("ai.native.mcp.type.builtin");default:return c}}async openConfigFile(){let c=this.preferenceService.resolve("mcp",{mcpServers:{}},void 0);c.scope===_.PreferenceScope.Default&&(await this.preferenceService.set("mcp",{mcpServers:{}},_.PreferenceScope.Workspace),c=this.preferenceService.resolve("mcp",{mcpServers:{}},void 0));const E=c.configUri;E&&this.workbenchEditorService.open(E,{preview:!1})}};t.MCPConfigService=h,n.__decorate([(0,r.Autowired)(p.SumiMCPServerProxyServicePath),n.__metadata("design:type",Object)],h.prototype,"sumiMCPServerBackendProxy",void 0),n.__decorate([(0,r.Autowired)(a.MCPServerProxyService),n.__metadata("design:type",a.MCPServerProxyService)],h.prototype,"mcpServerProxyService",void 0),n.__decorate([(0,r.Autowired)(l.PreferenceService),n.__metadata("design:type",Object)],h.prototype,"preferenceService",void 0),n.__decorate([(0,r.Autowired)(m.IMessageService),n.__metadata("design:type",Object)],h.prototype,"messageService",void 0),n.__decorate([(0,r.Autowired)(_.StorageProvider),n.__metadata("design:type",Function)],h.prototype,"storageProvider",void 0),n.__decorate([(0,r.Autowired)(v.WorkbenchEditorService),n.__metadata("design:type",v.WorkbenchEditorService)],h.prototype,"workbenchEditorService",void 0),n.__decorate([(0,r.Autowired)(o.ILogger),n.__metadata("design:type",Object)],h.prototype,"logger",void 0),t.MCPConfigService=h=n.__decorate([(0,r.Injectable)(),n.__metadata("design:paramtypes",[])],h)},33368:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPFolderPreferenceProvider=void 0;const n=e(85608),r=e(76003),o=e(91825);let l=class extends o.FolderFilePreferenceProvider{parse(v){const m=super.parse(v);if(m!==void 0)return{mcp:{...m}}}getPath(v){if(v==="mcp")return[];if(v.startsWith("mcp."))return[v.substr(4)]}};t.MCPFolderPreferenceProvider=l,t.MCPFolderPreferenceProvider=l=n.__decorate([(0,r.Injectable)()],l)},55003:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPPreferencesContribution=t.MCPResourceProvider=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(57517),_=e(924);let v=class{provideResource(s){return{supportsRevive:!0,name:(0,o.localize)("menu-bar.title.debug"),icon:(0,o.getIcon)("debug"),uri:s}}provideResourceSubname(){return null}async shouldCloseResource(){return!0}};t.MCPResourceProvider=v,t.MCPResourceProvider=v=n.__decorate([(0,r.Injectable)()],v);let m=class{constructor(){this.schema=_.MCPPreferencesSchema,this.name="mcp"}registerResource(s){s.registerResourceProvider(this.prefResourceProvider)}registerSchema(s){s.registerSchema(_.MCPSchemaUri,_.MCPSchema,["mcp.json"])}};t.MCPPreferencesContribution=m,n.__decorate([(0,r.Autowired)(v),n.__metadata("design:type",v)],m.prototype,"prefResourceProvider",void 0),t.MCPPreferencesContribution=m=n.__decorate([(0,o.Domain)(o.PreferenceContribution,o.PreferenceConfiguration,l.BrowserEditorContribution,o.JsonSchemaContribution)],m)},924:(x,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPSchema=t.MCPPreferencesSchema=t.MCPSchemaUri=void 0,t.MCPSchemaUri="vscode://schemas/mcp/user",t.MCPPreferencesSchema={type:"object",scope:"resource",properties:{mcp:{$ref:t.MCPSchemaUri,description:"MCP configuration for Workspace.",defaultValue:{mcpServers:{}}}}},t.MCPSchema={$id:t.MCPSchemaUri,type:"object",title:"MCP",required:[],default:{mcpServers:{}},properties:{mcpServers:{type:"object",description:"List of MCP Servers. Add new servers or edit existing ones by using IntelliSense.",additionalProperties:{type:"object",properties:{command:{type:"string",description:"The command to start the MCP server."},args:{type:"array",description:"The arguments for the command to start the MCP server.",items:{type:"string"}},env:{type:"object",description:"The environment variables for the command to start the MCP server.",additionalProperties:{type:"string"}},url:{type:"string",description:"The SSE URL for the MCP server."}},oneOf:[{required:["command"]},{required:["url"]}]}}}}},45331:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPServerProxyService=void 0;const n=e(85608),r=e(48085),o=e(76003),l=e(41869),_=e(43718),v=e(19413),m=e(36059),p=e(77633);let s=class{constructor(){this._onChangeMCPServers=new _.Emitter,this.onChangeMCPServers=this._onChangeMCPServers.event}$callMCPTool(a,h){return this.mcpServerRegistry.callMCPTool(a,h)}async $getBuiltinMCPTools(){const a=await this.mcpServerRegistry.getMCPTools().map(h=>({name:h.name,description:h.description,inputSchema:(0,r.zodToJsonSchema)(h.inputSchema),providerName:v.BUILTIN_MCP_SERVER_NAME}));return this.logger.log("SUMI MCP tools",a),a}async $updateMCPServers(){this._onChangeMCPServers.fire("update")}async getAllMCPTools(){return this.sumiMCPServerProxyService.$getAllMCPTools()}async $getServers(){return this.sumiMCPServerProxyService.$getServers()}async $startServer(a){await this.sumiMCPServerProxyService.$startServer(a)}async $stopServer(a){await this.sumiMCPServerProxyService.$stopServer(a)}async $compressToolResult(a,h){return(0,m.compressToolResultSmart)(a,h)}};t.MCPServerProxyService=s,n.__decorate([(0,o.Autowired)(p.TokenMCPServerRegistry),n.__metadata("design:type",Object)],s.prototype,"mcpServerRegistry",void 0),n.__decorate([(0,o.Autowired)(l.ILogger),n.__metadata("design:type",Object)],s.prototype,"logger",void 0),n.__decorate([(0,o.Autowired)(v.SumiMCPServerProxyServicePath),n.__metadata("design:type",Object)],s.prototype,"sumiMCPServerProxyService",void 0),t.MCPServerProxyService=s=n.__decorate([(0,o.Injectable)()],s)},79502:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPServerRegistry=void 0;const n=e(85608),r=e(76003),o=e(43718),l=e(19413),_=e(98864);class v{constructor(s){this.logger=s}appendLine(s){this.logger.log(s)}}let m=class{constructor(){this.tools=[],this.toolComponents={}}get logger(){return new v(this.baseLogger)}set activeMessageInfo(s){this._activeMessageInfo=s}getMCPTool(s,g=l.BUILTIN_MCP_SERVER_NAME){return this.tools.find(a=>(0,_.getToolName)(a.name,g)===s)}registerMCPTool(s){const g=this.tools.findIndex(a=>a.name===s.name);g!==-1?this.tools[g]=s:this.tools.push(s)}registerToolComponent(s,g,a=l.BUILTIN_MCP_SERVER_NAME){this.toolComponents[(0,_.getToolName)(s,a)]=g}getToolComponent(s){return this.toolComponents[s]}getMCPTools(){return this.tools.sort((s,g)=>{var a,h;return((a=s.order)!==null&&a!==void 0?a:1/0)-((h=g.order)!==null&&h!==void 0?h:1/0)})}async callMCPTool(s,g){try{const a=this.tools.find(c=>c.name===s);if(!a)throw new Error(`MCP tool ${s} not found`);const h=g.toolCallId;g=a.inputSchema.parse(g);const u=await a.handler({...g,toolCallId:h},this.logger);return this.reportToolCall(s,g,u,h),u}catch(a){return console.error("callMCPTool error:",a),this.reportToolCall(s,g,a,g.toolCallId),{content:[{type:"text",text:`The tool ${s} failed to execute. Error: ${a}`}],isError:!0}}}reportToolCall(s,g,a,h){if(!this.tools.find(c=>c.name===s))throw new Error(`MCP tool ${s} not found`);this.aiReporter.send({msgType:o.AIServiceType.ToolCall,message:JSON.stringify({args:g,name:s,result:a}),messageId:this._activeMessageInfo.messageId,sessionId:this._activeMessageInfo.sessionId,relationId:h})}};t.MCPServerRegistry=m,n.__decorate([(0,r.Autowired)(o.ILogger),n.__metadata("design:type",Object)],m.prototype,"baseLogger",void 0),n.__decorate([(0,r.Autowired)(o.IAIReporter),n.__metadata("design:type",Object)],m.prototype,"aiReporter",void 0),t.MCPServerRegistry=m=n.__decorate([(0,r.Injectable)()],m)},30703:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MCPToolsDialog=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=n.__importDefault(e(49783)),l=({tools:_})=>r.createElement("div",{className:o.default.mcp_tools_dialog},r.createElement("div",{className:o.default.dialog_title},"MCP Tools"),r.createElement("div",{className:o.default.tools_list},_.map(v=>r.createElement("div",{key:v.name,className:o.default.tool_item},r.createElement("div",{className:o.default.tool_name},v.name),r.createElement("div",{className:o.default.tool_description},v.description),v.providerName&&r.createElement("div",{className:o.default.tool_provider},"Provider: ",v.providerName)))));t.MCPToolsDialog=l},58260:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditFileToolComponent=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=e(97267),_=e(41869),v=e(54414),m=e(14162),p=e(87822),s=e(16781),g=e(21967),a=e(56474),h=e(73974),u=n.__importDefault(e(51601)),c=E=>{var f,d,y;const{args:b,messageId:A,toolCallId:S}=E,[D,T]=(0,o.useState)("code"),w=(0,_.useInjectable)(_.LabelService),I=(0,_.useInjectable)(_.AppConfig),O=(0,_.useInjectable)(h.BaseApplyService),P=(0,_.useInjectable)(v.WorkbenchEditorService),{target_file:R="",code_edit:M,instructions:k}=b||{},F=_.path.join(I.workspaceDir,R),[L,B]=(0,o.useState)(O.getCodeBlock(S,A)),U=(0,o.useMemo)(()=>R?`file-icon ${w.getIcon(_.URI.file(F))}`:void 0,[R,F]),W=(0,o.useMemo)(()=>{if(!R)return;const G=s.StandaloneServices.get(p.IModelService),Z=s.StandaloneServices.get(m.ILanguageService);return(0,_.detectModeId)(G,Z,_.Uri.file(F))},[R,F]),j=(0,o.useMemo)(()=>{var G,Z;if(L?.status==="failed")try{return(Z=(G=JSON.parse(E.result||"{}").content)===null||G===void 0?void 0:G[0])===null||Z===void 0?void 0:Z.text}catch{return""}},[E.result,L]);(0,o.useEffect)(()=>{const G=O.onCodeBlockUpdate(Z=>{Z.toolCallId===S&&B({...Z})});return()=>{G.dispose()}},[]);const Q=G=>{G.stopPropagation(),T(D==="code"?"diff":"code")};return!b||!L?null:[k&&o.default.createElement("p",{key:"edit-file-tool-instructions"},k),o.default.createElement("div",{className:u.default["edit-file-tool"],key:"edit-file-tool"},o.default.createElement("div",{className:(0,r.default)(u.default["edit-file-tool-header"],{clickable:L.status==="pending"||L.status==="success"}),onClick:()=>{L.status==="pending"?P.open(_.URI.file(F)):L.status==="success"&&O.revealApplyPosition(L)}},o.default.createElement("div",{className:u.default.left},U&&o.default.createElement("span",{className:U}),o.default.createElement("span",{className:u.default["edit-file-tool-file-name"]},R),L.iterationCount>1&&o.default.createElement("span",{className:u.default["edit-file-tool-iteration-count"]},L.iterationCount,"/3"),o.default.createElement(g.ApplyStatus,{status:L.status,error:j})),o.default.createElement("div",{className:u.default.right},o.default.createElement(l.Popover,{title:"Show Code",id:"edit-file-tool-show-code"},o.default.createElement(l.Icon,{iconClass:"codicon codicon-file-code",onClick:Q})),((f=L.applyResult)===null||f===void 0?void 0:f.diff)&&o.default.createElement(l.Popover,{title:"Show Diff",id:"edit-file-tool-show-diff"},o.default.createElement(l.Icon,{iconClass:"codicon codicon-diff-multiple",onClick:Q})))),o.default.createElement(a.ChatMarkdown,{markdown:D==="code"?`\`\`\`${W||""}
32481
32481
  ${M}
32482
32482
  \`\`\``:`\`\`\`diff
32483
32483
  ${(d=L.applyResult)===null||d===void 0?void 0:d.diff}
@@ -32485,7 +32485,7 @@ ${(d=L.applyResult)===null||d===void 0?void 0:d.diff}
32485
32485
  `)[0])))]};t.EditFileToolComponent=c},95292:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ListDirToolComponent=t.GrepSearchToolComponent=t.FileSearchToolComponent=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(80564),l=e(41869),_=e(54414),v=e(51500),m=e(19413),p=n.__importDefault(e(51601)),s=({args:u,toolCallId:c,messageId:E})=>r.default.createElement(h,{args:u,toolCallId:c,messageId:E,toolName:"fileSearch",headerText:`Searched files "${u.query}"`});t.FileSearchToolComponent=s;const g=({args:u,toolCallId:c,messageId:E})=>r.default.createElement(h,{args:u,toolCallId:c,messageId:E,toolName:"grepSearch",headerText:`Grepped codebase "${u.query}"`});t.GrepSearchToolComponent=g;const a=({args:u,toolCallId:c,messageId:E})=>r.default.createElement(h,{args:u,toolCallId:c,messageId:E,toolName:"listDir",headerText:`Listed directory "${u.relative_workspace_path}"`});t.ListDirToolComponent=a;const h=({args:u,toolCallId:c,toolName:E,messageId:f,headerText:d})=>{const[y,b]=(0,r.useState)(!1),A=(0,l.useInjectable)(l.LabelService),S=(0,l.useInjectable)(_.WorkbenchEditorService),D=(0,l.useInjectable)(v.IWorkspaceService),T=(0,l.useInjectable)(l.CommandService),w=(0,r.useMemo)(()=>{var k,F;return l.URI.parse((F=(k=D.tryGetRoots())===null||k===void 0?void 0:k[0])===null||F===void 0?void 0:F.uri)},[]),I=(0,l.useInjectable)(m.IChatInternalService),[O,P]=(0,r.useState)([]);(0,r.useEffect)(()=>{const k=I.sessionModel.history.onMessageAdditionalChange(F=>{F[c]&&P(F[c].files||[])});return()=>{k.dispose()}},[]);const R=async k=>{if(!k.isDirectory)S.open(l.URI.parse(k.uri));else{const F=l.URI.parse(k.uri);T.executeCommand("filetree.location",F)}},M=(0,r.useMemo)(()=>O.map(k=>{const F=l.URI.parse(k.uri);return{iconClass:A.getIcon(F,{isDirectory:k.isDirectory}),name:F.path.base,path:l.path.relative(w.codeUri.fsPath,F.path.dir.toString()),uri:k.uri,isDirectory:k.isDirectory}}),[O]);return r.default.createElement("div",{className:p.default.container},r.default.createElement("div",{className:p.default.header,onClick:()=>b(!y)},r.default.createElement("span",{style:{transform:`rotate(${y?"90deg":"0deg"})`,display:"flex"}},r.default.createElement(o.Icon,{iconClass:"codicon codicon-chevron-right"})),r.default.createElement("span",null,d," \xB7 ",O.length," files")),y&&r.default.createElement("ul",{className:p.default.fileList},M.map((k,F)=>r.default.createElement("li",{key:F,className:p.default.fileItem,onClick:()=>R({uri:k.uri,isDirectory:k.isDirectory})},r.default.createElement("span",{className:k.iconClass}),r.default.createElement("span",{style:{flex:1}},k.name),r.default.createElement("span",{className:p.default.filePath},k.path)))))}},24706:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TerminalToolComponent=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(41869),l=e(81878),_=e(52141),v=e(89897),m=e(43718),p=e(71990),s=e(83854),g=e(22559),a=e(62471),h=n.__importDefault(e(51601));function u(f){const d={};try{const y=JSON.parse(f);return y.isError&&(d.isError=y.isError),y.content&&(d.text=y.content.map(b=>b.text).join(`
32486
32486
  `)),d}catch{return null}}const c={[s.ETerminalAutoExecutionPolicy.always]:"ai.native.terminal.autorun.always",[s.ETerminalAutoExecutionPolicy.auto]:"ai.native.terminal.autorun.auto",[s.ETerminalAutoExecutionPolicy.off]:"ai.native.terminal.autorun.off"};function E(f){return(0,m.localize)(c[f])}t.TerminalToolComponent=(0,r.memo)(f=>{const{args:d,toolCallId:y}=f,b=(0,o.useInjectable)(g.RunCommandHandler),A=(0,o.useInjectable)(o.PreferenceService),S=(0,o.useInjectable)(m.CommandService),[D,T]=(0,r.useState)(!1),w=A.get(p.AINativeSettingSectionsId.TerminalAutoRun),I=(0,r.useMemo)(()=>{var M;return!!(w===s.ETerminalAutoExecutionPolicy.off||w===s.ETerminalAutoExecutionPolicy.auto&&(!((M=f.args)===null||M===void 0)&&M.require_user_approval))},[f.args]);(0,r.useEffect)(()=>{f.state==="result"?T(!1):I||T(!0)},[f]);const O=(0,r.useCallback)(()=>{S.executeCommand("workbench.action.openSettings","ai.native.terminal.autorun")},[]),P=(0,r.useCallback)(M=>{y&&(b.handleApproval(y,M),T(!0))},[]),R=(0,r.useMemo)(()=>f.result?u(f.result):null,[f]);return r.default.createElement("div",{className:h.default.run_cmd_tool},r.default.createElement("div",null,r.default.createElement("div",{className:h.default.command_title},r.default.createElement(l.Icon,{icon:"terminal"}),r.default.createElement("span",null,I?(0,m.localize)("ai.native.mcp.terminal.allow-question"):(0,m.localize)("ai.native.mcp.terminal.command"))),r.default.createElement("p",{className:h.default.command_content},r.default.createElement("code",null,"$ ",d?.command)),r.default.createElement("p",{className:h.default.comand_description},d?.explanation),f.state==="complete"&&I&&d&&!D&&r.default.createElement("div",{className:h.default.cmmand_footer},r.default.createElement(l.Button,{type:"link",size:"small",onClick:()=>P(!0)},(0,m.localize)("ai.native.mcp.terminal.allow")),r.default.createElement(l.Button,{type:"link",size:"small",onClick:()=>P(!1)},(0,m.localize)("ai.native.mcp.terminal.deny"))),f.state==="result"&&R&&r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{className:h.default.command_content},r.default.createElement(l.Icon,{icon:"output"}),r.default.createElement("code",{dangerouslySetInnerHTML:{__html:(0,a.computeAnsiLogString)(R.text||"")}})),r.default.createElement("div",{className:h.default.auto_execution_policy},r.default.createElement("span",{className:h.default.auto_execution_policy_label},E(w||s.ETerminalAutoExecutionPolicy.auto)),r.default.createElement(_.EnhancePopover,{id:"policy-config-popover",title:(0,m.localize)("ai.native.terminal.autorun.command")},r.default.createElement(l.Icon,{size:"small",iconClass:"codicon codicon-settings-gear",onClick:O}))))),D&&r.default.createElement("div",{className:h.default.running},r.default.createElement(v.Loading,null),r.default.createElement("span",null,(0,m.localize)("ai.native.terminal.autorun.running"))))})},62471:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.computeAnsiLogString=_;const n=e(85608),r=n.__importDefault(e(30002)),o=n.__importDefault(e(39718)),l=new r.default;function _(v,m=!0,p=!1){const s=v.split(`
32487
32487
  `);let g=m?(0,o.default)(s):s;return p&&(g=g.map(h=>h.replace("\r","")).filter(h=>!!h)),g.map(h=>l.ansi_to_html(h)).join(`
32488
- `)}},39718:(x,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cursorUp=t.eraseEndLine=t.eraseLine=t.ESC=void 0,t.default=n,t.ESC="\x1B[",t.eraseLine=t.ESC+"2K",t.eraseEndLine=t.ESC+"K";const e=(r=1)=>t.ESC+r+"A";t.cursorUp=e;function n(r){const o=(0,t.cursorUp)(1)+t.eraseLine,l=t.eraseLine,_=`\r${t.eraseEndLine}`,v=["\\r","\\u001b\\[G","\\u001b\\[1G"],m=new RegExp(`${v.join("|")}`);return r.reduce((s,g)=>{let a=0;const h=o.length;for(;a=g.indexOf(o,a),a>=0;)a+=h,s.pop();let u=g.lastIndexOf(l);u<0&&(u=g.lastIndexOf(_)),u>0&&(g=g.slice(u));const c=g.split(m).filter(E=>!!E);return c.length>1&&(g=c.reduce((E,f)=>{const d=E.slice(f.length);return f+d},"")),s.push(g),s},[])}},7228:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateNewFileWithTextTool=void 0;const n=e(85608),r=e(75995),o=e(76003),l=e(43718),_=e(14951),v=e(51500),m=e(77633),p=e(73974),s=e(58260),g=r.z.object({target_file:r.z.string().describe("The relative path where the file should be created"),code_edit:r.z.string().describe("The content to write into the new file")});let a=class{registerMCPServer(u){u.registerMCPTool(this.getToolDefinition()),u.registerToolComponent("create_new_file_with_text",s.EditFileToolComponent)}getToolDefinition(){return{name:"create_new_file_with_text",label:"Create File",order:7,description:`Creates a new file at the specified path within the project directory and populates it with the provided text. Use this tool to generate new files in your project structure. Returns one of two possible responses: "ok" if the file was successfully created and populated, "can't find project dir" if the project directory cannot be determined. Note: This tool creates any necessary parent directories automatically.`,inputSchema:g,handler:this.handler.bind(this)}}async handler(u,c){try{const E=this.workspaceService.tryGetRoots();if(!E||E.length===0)return c.appendLine("Error: Cannot determine project directory"),{content:[{type:"text",text:"can't find project dir"}],isError:!0};const f=l.URI.parse(E[0].uri),d=l.path.join(f.codeUri.fsPath,u.target_file),y=l.URI.file(d),b=l.path.dirname(d),A=l.URI.file(b);await this.fileService.createFolder(A.toString()),await this.fileService.createFile(y.toString());const S=await this.applyService.registerCodeBlock(u.target_file,u.code_edit,u.toolCallId);return await this.applyService.apply(S),c.appendLine(`Successfully created file at: ${u.target_file}`),{content:[{type:"text",text:"ok"}]}}catch(E){return c.appendLine(`Error during file creation: ${E}`),{content:[{type:"text",text:E.message}],isError:!0}}}};t.CreateNewFileWithTextTool=a,n.__decorate([(0,o.Autowired)(v.IWorkspaceService),n.__metadata("design:type",Object)],a.prototype,"workspaceService",void 0),n.__decorate([(0,o.Autowired)(_.IFileServiceClient),n.__metadata("design:type",Object)],a.prototype,"fileService",void 0),n.__decorate([(0,o.Autowired)(p.BaseApplyService),n.__metadata("design:type",p.BaseApplyService)],a.prototype,"applyService",void 0),t.CreateNewFileWithTextTool=a=n.__decorate([(0,l.Domain)(m.MCPServerContribution)],a)},90977:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditFileTool=void 0;const n=e(85608),r=e(75995),o=e(76003),l=e(43718),_=e(77633),v=e(58260),m=e(9343),p=r.z.object({target_file:r.z.string().describe("The target file to modify. Always specify the target file as the first argument and use the relative path in the workspace of the file to edit"),instructions:r.z.string().optional().describe("A single sentence instruction describing what you are going to do for the sketched edit. This is used to assist the less intelligent model in applying the edit. Please use the first person to describe what you are going to do. Dont repeat what you have said previously in normal messages. And use it to disambiguate uncertainty in the edit."),code_edit:r.z.string().describe("Specify ONLY the precise lines of code that you wish to edit. **NEVER specify or write out unchanged code**. Instead, represent all unchanged code using the comment of the language you're editing in - example: `// ... existing code ...`")}).transform(g=>({targetFile:g.target_file,instructions:g.instructions,codeEdit:g.code_edit}));let s=class{registerMCPServer(a){a.registerMCPTool(this.getToolDefinition()),a.registerToolComponent("edit_file",v.EditFileToolComponent)}getToolDefinition(){return{name:"edit_file",label:"Edit File",order:5,description:`Use this tool to propose an edit to an existing file.
32488
+ `)}},39718:(x,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cursorUp=t.eraseEndLine=t.eraseLine=t.ESC=void 0,t.default=n,t.ESC="\x1B[",t.eraseLine=t.ESC+"2K",t.eraseEndLine=t.ESC+"K";const e=(r=1)=>t.ESC+r+"A";t.cursorUp=e;function n(r){const o=(0,t.cursorUp)(1)+t.eraseLine,l=t.eraseLine,_=`\r${t.eraseEndLine}`,v=["\\r","\\u001b\\[G","\\u001b\\[1G"],m=new RegExp(`${v.join("|")}`);return r.reduce((s,g)=>{let a=0;const h=o.length;for(;a=g.indexOf(o,a),a>=0;)a+=h,s.pop();let u=g.lastIndexOf(l);u<0&&(u=g.lastIndexOf(_)),u>0&&(g=g.slice(u));const c=g.split(m).filter(E=>!!E);return c.length>1&&(g=c.reduce((E,f)=>{const d=E.slice(f.length);return f+d},"")),s.push(g),s},[])}},7228:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateNewFileWithTextTool=void 0;const n=e(85608),r=e(75995),o=e(76003),l=e(43718),_=e(77633),v=e(58260),m=e(79346),p=r.z.object({target_file:r.z.string().describe("The relative path where the file should be created"),code_edit:r.z.string().describe("The content to write into the new file")}).transform(g=>({targetFile:g.target_file,codeEdit:g.code_edit}));let s=class{registerMCPServer(a){a.registerMCPTool(this.getToolDefinition()),a.registerToolComponent("create_new_file_with_text",v.EditFileToolComponent)}getToolDefinition(){return{name:"create_new_file_with_text",label:"Create File",order:7,description:`Creates a new file at the specified path within the project directory and populates it with the provided text. Use this tool to generate new files in your project structure. Returns one of two possible responses: "ok" if the file was successfully created and populated, "can't find project dir" if the project directory cannot be determined. Note: This tool creates any necessary parent directories automatically.`,inputSchema:p,handler:this.handler.bind(this)}}async handler(a,h){try{return await this.createNewFileWithTextHandler.handler(a,a.toolCallId),h.appendLine(`Successfully created file at: ${a.targetFile}`),{content:[{type:"text",text:"create file with text success"}]}}catch(u){return h.appendLine(`Error during file creation: ${u}`),{content:[{type:"text",text:u.message}],isError:!0}}}};t.CreateNewFileWithTextTool=s,n.__decorate([(0,o.Autowired)(m.CreateNewFileWithTextHandler),n.__metadata("design:type",m.CreateNewFileWithTextHandler)],s.prototype,"createNewFileWithTextHandler",void 0),t.CreateNewFileWithTextTool=s=n.__decorate([(0,l.Domain)(_.MCPServerContribution)],s)},90977:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditFileTool=void 0;const n=e(85608),r=e(75995),o=e(76003),l=e(43718),_=e(77633),v=e(58260),m=e(9343),p=r.z.object({target_file:r.z.string().describe("The target file to modify. Always specify the target file as the first argument and use the relative path in the workspace of the file to edit"),instructions:r.z.string().optional().describe("A single sentence instruction describing what you are going to do for the sketched edit. This is used to assist the less intelligent model in applying the edit. Please use the first person to describe what you are going to do. Dont repeat what you have said previously in normal messages. And use it to disambiguate uncertainty in the edit."),code_edit:r.z.string().describe("Specify ONLY the precise lines of code that you wish to edit. **NEVER specify or write out unchanged code**. Instead, represent all unchanged code using the comment of the language you're editing in - example: `// ... existing code ...`")}).transform(g=>({targetFile:g.target_file,instructions:g.instructions,codeEdit:g.code_edit}));let s=class{registerMCPServer(a){a.registerMCPTool(this.getToolDefinition()),a.registerToolComponent("edit_file",v.EditFileToolComponent)}getToolDefinition(){return{name:"edit_file",label:"Edit File",order:5,description:`Use this tool to propose an edit to an existing file.
32489
32489
  This will be read by a less intelligent model, which will quickly apply the edit. You should make it clear what the edit is, while also minimizing the unchanged code you write.
32490
32490
  When writing the edit, you should specify each edit in sequence, with the special comment \`// ... existing code ...\` to represent unchanged code in between edited lines.
32491
32491
  For example:
@@ -32512,27 +32512,27 @@ ${u.applyResult.diagnosticInfos.map(c=>`Line ${c.startLineNumber}: ${c.message.s
32512
32512
  `)[0]}`).join(`
32513
32513
  `)}
32514
32514
 
32515
- Please fix the linter errors if it is clear how to (or you can easily figure out how to). Do not make uneducated guesses. And do not loop more than 3 times on fixing linter errors on the same file.`:""}`:u.status==="cancelled"?"User cancelled the edit.":"The apply model made no changes to the file."}]}}};t.EditFileTool=s,n.__decorate([(0,o.Autowired)(m.EditFileHandler),n.__metadata("design:type",m.EditFileHandler)],s.prototype,"editFileHandler",void 0),t.EditFileTool=s=n.__decorate([(0,l.Domain)(_.MCPServerContribution)],s)},80173:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FileSearchTool=void 0;const n=e(85608),r=e(75995),o=e(76003),l=e(79240),_=e(43718),v=e(87863),m=e(84660),p=e(51500),s=e(19413),g=e(59347),a=e(77633),h=e(95292),u=r.z.object({query:r.z.string().describe("Fuzzy filename to search for"),explanation:r.z.string().describe("One sentence explanation as to why this tool is being used, and how it contributes to the goal.")}),c=10;let E=class{registerMCPServer(d){d.registerMCPTool(this.getToolDefinition()),d.registerToolComponent("file_search",h.FileSearchToolComponent)}getToolDefinition(){return{name:"file_search",label:"Search Files",order:6,description:"Fast file search based on fuzzy matching against file path. Use if you know part of the file path but don't know where it's located exactly. Response will be capped to 10 results. Make your query more specific if need to filter results further.",inputSchema:u,handler:this.handler.bind(this)}}async handler(d,y){if(!d.query)throw new Error("No fileSearch parameters provided. Need to give a query.");const b=this.workspaceService.tryGetRoots();if(!b||b.length===0)throw new Error("Cannot determine project directory");const A=this.normalizeQuery(d.query),S=await this.fileSearchService.find(A,{rootUris:[new _.URI(b[0].uri).codeUri.fsPath],excludePatterns:Object.keys(v.defaultFilesWatcherExcludes),limit:100,useGitIgnore:!0,noIgnoreParent:!0,fuzzyMatch:!0}),D=S.slice(0,c).map(w=>({uri:_.URI.parse(w).codeUri.fsPath,isDirectory:!1})),T=this.chatInternalService.sessionModel.history.getMessages();return this.chatInternalService.sessionModel.history.setMessageAdditional(T[T.length-1].id,{[d.toolCallId]:{files:D}}),y.appendLine(`Found ${D.length} files matching "${d.query}"`),{content:[{type:"text",text:`${D.map(w=>w.uri).join(`
32515
+ Please fix the linter errors if it is clear how to (or you can easily figure out how to). Do not make uneducated guesses. And do not loop more than 3 times on fixing linter errors on the same file.`:""}`:u.status==="cancelled"?"User cancelled the edit.":"The apply model made no changes to the file."}]}}};t.EditFileTool=s,n.__decorate([(0,o.Autowired)(m.EditFileHandler),n.__metadata("design:type",m.EditFileHandler)],s.prototype,"editFileHandler",void 0),t.EditFileTool=s=n.__decorate([(0,l.Domain)(_.MCPServerContribution)],s)},80173:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FileSearchTool=void 0;const n=e(85608),r=e(75995),o=e(76003),l=e(79240),_=e(43718),v=e(87863),m=e(84660),p=e(51500),s=e(19413),g=e(59347),a=e(77633),h=e(95292),u=r.z.object({query:r.z.string().describe("Fuzzy filename to search for"),explanation:r.z.string().describe("One sentence explanation as to why this tool is being used, and how it contributes to the goal.")}),c=10;let E=class{registerMCPServer(d){d.registerMCPTool(this.getToolDefinition()),d.registerToolComponent("file_search",h.FileSearchToolComponent)}getToolDefinition(){return{name:"file_search",label:"Search Files",order:6,description:"Fast file search based on fuzzy matching against file path. Use if you know part of the file path but don't know where it's located exactly. Response will be capped to 10 results. Make your query more specific if need to filter results further.",inputSchema:u,handler:this.handler.bind(this)}}async handler(d,y){var b;if(!d.query)throw new Error("No fileSearch parameters provided. Need to give a query.");const A=this.workspaceService.tryGetRoots();if(!A||A.length===0)throw new Error("Cannot determine project directory");const S=this.normalizeQuery(d.query),D=await this.fileSearchService.find(S,{rootUris:[new _.URI(A[0].uri).codeUri.fsPath],excludePatterns:Object.keys(v.defaultFilesWatcherExcludes),limit:100,useGitIgnore:!0,noIgnoreParent:!0,fuzzyMatch:!0}),T=D.slice(0,c).map(O=>({uri:_.URI.parse(O).codeUri.fsPath,isDirectory:!1})),w=this.chatInternalService.sessionModel.history.getMessages(),I=(b=w[w.length-1])===null||b===void 0?void 0:b.id;return I&&this.chatInternalService.sessionModel.history.setMessageAdditional(I,{[d.toolCallId]:{files:T}}),y.appendLine(`Found ${T.length} files matching "${d.query}"`),{content:[{type:"text",text:`${T.map(O=>O.uri).join(`
32516
32516
  `)}
32517
- ${S.length>c?`
32518
- Found ${S.length} files matching "${d.query}", only return the first ${c} results`:""}`}]}}normalizeQuery(d){const y=d.trim().replace(/\s/g,"");return(0,l.getValidateInput)(y)}};t.FileSearchTool=E,n.__decorate([(0,o.Autowired)(p.IWorkspaceService),n.__metadata("design:type",Object)],E.prototype,"workspaceService",void 0),n.__decorate([(0,o.Autowired)(m.FileSearchServicePath),n.__metadata("design:type",Object)],E.prototype,"fileSearchService",void 0),n.__decorate([(0,o.Autowired)(s.IChatInternalService),n.__metadata("design:type",g.ChatInternalService)],E.prototype,"chatInternalService",void 0),t.FileSearchTool=E=n.__decorate([(0,_.Domain)(a.MCPServerContribution)],E)},30645:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GetDiagnosticsByPathTool=void 0;const n=e(85608),r=n.__importStar(e(64756)),o=e(75995),l=e(76003),_=e(43718),v=e(51500),m=e(26592),p=e(34835),s=e(77633),g=o.z.object({filePathInProject:o.z.string().describe("The relative path to the file to get diagnostics for")});let a=class{registerMCPServer(u){u.registerMCPTool(this.getToolDefinition())}getToolDefinition(){return{name:"get_diagnostics_by_path",label:"Get Diagnostics By Path",order:9,description:`Retrieves diagnostic information (errors, warnings, etc.) from a specific file in the project. Use this tool to get information about problems in any project file. IMPORTANT: This tool should be called after any code generation or modification operations to verify and fix potential issues. Requires a filePathInProject parameter specifying the target file path relative to project root. Returns a JSON-formatted list of diagnostics, where each entry contains: - path: The file path where the diagnostic was found - line: The line number (1-based) of the diagnostic - severity: The severity level ("error", "warning", "information", or "hint") - message: The diagnostic message Returns an empty list ([]) if no diagnostics are found or the file doesn't exist. Best Practice: Always check diagnostics after code generation to ensure code quality and fix any issues immediately. Use this tool in combination with get_open_in_editor_file_diagnostics to verify all affected files after code changes. Diagnostic Severity Handling Guidelines: - "error": Must be fixed immediately as they indicate critical issues that will prevent code from working correctly. - "warning": For user code, preserve unless the warning indicates a clear improvement opportunity. For generated code, optimize to remove warnings. - "information"/"hint": For user code, preserve as they might reflect intentional patterns. For generated code, optimize if it improves code quality without changing functionality.`,inputSchema:g,handler:this.handler.bind(this)}}async handler(u,c){try{const E=this.workspaceService.tryGetRoots();if(!E||E.length===0)return c.appendLine("Error: Cannot determine project directory"),{content:[{type:"text",text:"[]"}],isError:!0};const f=_.URI.parse(E[0].uri),d=r.join(f.codeUri.fsPath,u.filePathInProject),y=m.URI.file(d),b=r.relative(f.codeUri.fsPath,d);if(b.startsWith("..")||r.isAbsolute(b))return c.appendLine("Error: File is outside of project scope"),{content:[{type:"text",text:"[]"}],isError:!0};const S=this.markerService.read({resource:y}).map(T=>({path:u.filePathInProject,line:T.startLineNumber,severity:this.getSeverityString(T.severity),message:T.message})),D=JSON.stringify(S,null,2);return c.appendLine(`Found ${S.length} diagnostics in ${u.filePathInProject}`),{content:[{type:"text",text:D}]}}catch(E){return c.appendLine(`Error getting diagnostics: ${E}`),{content:[{type:"text",text:"[]"}],isError:!0}}}getSeverityString(u){switch(u){case p.MarkerSeverity.Error:return"error";case p.MarkerSeverity.Warning:return"warning";case p.MarkerSeverity.Info:return"information";case p.MarkerSeverity.Hint:return"hint";default:return"unknown"}}};t.GetDiagnosticsByPathTool=a,n.__decorate([(0,l.Autowired)(v.IWorkspaceService),n.__metadata("design:type",Object)],a.prototype,"workspaceService",void 0),n.__decorate([(0,l.Autowired)(p.IMarkerService),n.__metadata("design:type",Object)],a.prototype,"markerService",void 0),t.GetDiagnosticsByPathTool=a=n.__decorate([(0,_.Domain)(s.MCPServerContribution)],a)},82078:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GetOpenEditorFileDiagnosticsTool=void 0;const n=e(85608),r=n.__importStar(e(64756)),o=e(75995),l=e(76003),_=e(43718),v=e(54414),m=e(51500),p=e(26592),s=e(34835),g=e(77633),a=o.z.object({});let h=class{registerMCPServer(c){c.registerMCPTool(this.getToolDefinition())}getToolDefinition(){return{name:"get_open_in_editor_file_diagnostics",label:"Get Current Editor Diagnostics",order:8,description:'Retrieves diagnostic information (errors, warnings, etc.) from the currently active file in VS Code editor. Use this tool to get information about problems in your current file. IMPORTANT: This tool should be called after any code generation or modification operations to verify and fix potential issues. Returns a JSON-formatted list of diagnostics, where each entry contains: - path: The file path where the diagnostic was found - line: The line number (1-based) of the diagnostic - severity: The severity level ("error", "warning", "information", or "hint") - message: The diagnostic message Returns an empty list ([]) if no diagnostics are found or no file is open. Best Practice: Always check diagnostics after code generation to ensure code quality and fix any issues immediately. Diagnostic Severity Handling Guidelines: - "error": Must be fixed immediately as they indicate critical issues that will prevent code from working correctly. - "warning": For user code, preserve unless the warning indicates a clear improvement opportunity. For generated code, optimize to remove warnings. - "information"/"hint": For user code, preserve as they might reflect intentional patterns. For generated code, optimize if it improves code quality without changing functionality.',inputSchema:a,handler:this.handler.bind(this)}}async handler(c,E){try{const f=this.editorService.currentEditor;if(!f||!f.currentUri)return E.appendLine("Error: No active text editor found"),{content:[{type:"text",text:"[]"}],isError:!0};const d=this.workspaceService.tryGetRoots();if(!d||d.length===0)return E.appendLine("Error: Cannot determine project directory"),{content:[{type:"text",text:"[]"}],isError:!0};const y=p.URI.parse(f.currentUri.toString()),b=this.markerService.read({resource:y}),A=_.URI.parse(d[0].uri),S=r.relative(A.codeUri.fsPath,f.currentUri.codeUri.fsPath),D=b.map(w=>({path:S,line:w.startLineNumber,severity:this.getSeverityString(w.severity),message:w.message})),T=JSON.stringify(D,null,2);return E.appendLine(`Found ${D.length} diagnostics in current file`),{content:[{type:"text",text:T}]}}catch(f){return E.appendLine(`Error getting diagnostics: ${f}`),{content:[{type:"text",text:"[]"}],isError:!0}}}getSeverityString(c){switch(c){case s.MarkerSeverity.Error:return"error";case s.MarkerSeverity.Warning:return"warning";case s.MarkerSeverity.Info:return"information";case s.MarkerSeverity.Hint:return"hint";default:return"unknown"}}};t.GetOpenEditorFileDiagnosticsTool=h,n.__decorate([(0,l.Autowired)(v.WorkbenchEditorService),n.__metadata("design:type",v.WorkbenchEditorService)],h.prototype,"editorService",void 0),n.__decorate([(0,l.Autowired)(m.IWorkspaceService),n.__metadata("design:type",Object)],h.prototype,"workspaceService",void 0),n.__decorate([(0,l.Autowired)(s.IMarkerService),n.__metadata("design:type",Object)],h.prototype,"markerService",void 0),t.GetOpenEditorFileDiagnosticsTool=h=n.__decorate([(0,_.Domain)(g.MCPServerContribution)],h)},39855:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GrepSearchTool=void 0;const n=e(85608),r=e(75995),o=e(76003),l=e(43718),_=e(13439),v=e(51495),m=e(51500),p=e(19413),s=e(59347),g=e(77633),a=e(95292),h=r.z.object({query:r.z.string().describe("The regex pattern to search for"),case_sensitive:r.z.boolean().optional().describe("Whether the search should be case sensitive"),include_pattern:r.z.string().optional().describe('Glob pattern for files to include (e.g. "*.ts" for TypeScript files)'),exclude_pattern:r.z.string().optional().describe("Glob pattern for files to exclude"),explanation:r.z.string().optional().describe("One sentence explanation as to why this tool is being used, and how it contributes to the goal.")}),u=50;let c=class{registerMCPServer(f){f.registerMCPTool(this.getToolDefinition()),f.registerToolComponent("grep_search",a.GrepSearchToolComponent)}getToolDefinition(){return{name:"grep_search",label:"Search Contents",order:4,description:`Fast text-based regex search that finds exact pattern matches within files or directories, utilizing the ripgrep command for efficient searching.
32517
+ ${D.length>c?`
32518
+ Found ${D.length} files matching "${d.query}", only return the first ${c} results`:""}`}]}}normalizeQuery(d){const y=d.trim().replace(/\s/g,"");return(0,l.getValidateInput)(y)}};t.FileSearchTool=E,n.__decorate([(0,o.Autowired)(p.IWorkspaceService),n.__metadata("design:type",Object)],E.prototype,"workspaceService",void 0),n.__decorate([(0,o.Autowired)(m.FileSearchServicePath),n.__metadata("design:type",Object)],E.prototype,"fileSearchService",void 0),n.__decorate([(0,o.Autowired)(s.IChatInternalService),n.__metadata("design:type",g.ChatInternalService)],E.prototype,"chatInternalService",void 0),t.FileSearchTool=E=n.__decorate([(0,_.Domain)(a.MCPServerContribution)],E)},30645:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GetDiagnosticsByPathTool=void 0;const n=e(85608),r=n.__importStar(e(64756)),o=e(75995),l=e(76003),_=e(43718),v=e(51500),m=e(26592),p=e(34835),s=e(77633),g=o.z.object({filePathInProject:o.z.string().describe("The relative path to the file to get diagnostics for")});let a=class{registerMCPServer(u){u.registerMCPTool(this.getToolDefinition())}getToolDefinition(){return{name:"get_diagnostics_by_path",label:"Get Diagnostics By Path",order:9,description:`Retrieves diagnostic information (errors, warnings, etc.) from a specific file in the project. Use this tool to get information about problems in any project file. IMPORTANT: This tool should be called after any code generation or modification operations to verify and fix potential issues. Requires a filePathInProject parameter specifying the target file path relative to project root. Returns a JSON-formatted list of diagnostics, where each entry contains: - path: The file path where the diagnostic was found - line: The line number (1-based) of the diagnostic - severity: The severity level ("error", "warning", "information", or "hint") - message: The diagnostic message Returns an empty list ([]) if no diagnostics are found or the file doesn't exist. Best Practice: Always check diagnostics after code generation to ensure code quality and fix any issues immediately. Use this tool in combination with get_open_in_editor_file_diagnostics to verify all affected files after code changes. Diagnostic Severity Handling Guidelines: - "error": Must be fixed immediately as they indicate critical issues that will prevent code from working correctly. - "warning": For user code, preserve unless the warning indicates a clear improvement opportunity. For generated code, optimize to remove warnings. - "information"/"hint": For user code, preserve as they might reflect intentional patterns. For generated code, optimize if it improves code quality without changing functionality.`,inputSchema:g,handler:this.handler.bind(this)}}async handler(u,c){try{const E=this.workspaceService.tryGetRoots();if(!E||E.length===0)return c.appendLine("Error: Cannot determine project directory"),{content:[{type:"text",text:"[]"}],isError:!0};const f=_.URI.parse(E[0].uri),d=r.join(f.codeUri.fsPath,u.filePathInProject),y=m.URI.file(d),b=r.relative(f.codeUri.fsPath,d);if(b.startsWith("..")||r.isAbsolute(b))return c.appendLine("Error: File is outside of project scope"),{content:[{type:"text",text:"[]"}],isError:!0};const S=this.markerService.read({resource:y}).map(T=>({path:u.filePathInProject,line:T.startLineNumber,severity:this.getSeverityString(T.severity),message:T.message})),D=JSON.stringify(S,null,2);return c.appendLine(`Found ${S.length} diagnostics in ${u.filePathInProject}`),{content:[{type:"text",text:D}]}}catch(E){return c.appendLine(`Error getting diagnostics: ${E}`),{content:[{type:"text",text:"[]"}],isError:!0}}}getSeverityString(u){switch(u){case p.MarkerSeverity.Error:return"error";case p.MarkerSeverity.Warning:return"warning";case p.MarkerSeverity.Info:return"information";case p.MarkerSeverity.Hint:return"hint";default:return"unknown"}}};t.GetDiagnosticsByPathTool=a,n.__decorate([(0,l.Autowired)(v.IWorkspaceService),n.__metadata("design:type",Object)],a.prototype,"workspaceService",void 0),n.__decorate([(0,l.Autowired)(p.IMarkerService),n.__metadata("design:type",Object)],a.prototype,"markerService",void 0),t.GetDiagnosticsByPathTool=a=n.__decorate([(0,_.Domain)(s.MCPServerContribution)],a)},82078:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GetOpenEditorFileDiagnosticsTool=void 0;const n=e(85608),r=n.__importStar(e(64756)),o=e(75995),l=e(76003),_=e(43718),v=e(54414),m=e(51500),p=e(26592),s=e(34835),g=e(77633),a=o.z.object({});let h=class{registerMCPServer(c){c.registerMCPTool(this.getToolDefinition())}getToolDefinition(){return{name:"get_open_in_editor_file_diagnostics",label:"Get Current Editor Diagnostics",order:8,description:'Retrieves diagnostic information (errors, warnings, etc.) from the currently active file in VS Code editor. Use this tool to get information about problems in your current file. IMPORTANT: This tool should be called after any code generation or modification operations to verify and fix potential issues. Returns a JSON-formatted list of diagnostics, where each entry contains: - path: The file path where the diagnostic was found - line: The line number (1-based) of the diagnostic - severity: The severity level ("error", "warning", "information", or "hint") - message: The diagnostic message Returns an empty list ([]) if no diagnostics are found or no file is open. Best Practice: Always check diagnostics after code generation to ensure code quality and fix any issues immediately. Diagnostic Severity Handling Guidelines: - "error": Must be fixed immediately as they indicate critical issues that will prevent code from working correctly. - "warning": For user code, preserve unless the warning indicates a clear improvement opportunity. For generated code, optimize to remove warnings. - "information"/"hint": For user code, preserve as they might reflect intentional patterns. For generated code, optimize if it improves code quality without changing functionality.',inputSchema:a,handler:this.handler.bind(this)}}async handler(c,E){try{const f=this.editorService.currentEditor;if(!f||!f.currentUri)return E.appendLine("Error: No active text editor found"),{content:[{type:"text",text:"[]"}],isError:!0};const d=this.workspaceService.tryGetRoots();if(!d||d.length===0)return E.appendLine("Error: Cannot determine project directory"),{content:[{type:"text",text:"[]"}],isError:!0};const y=p.URI.parse(f.currentUri.toString()),b=this.markerService.read({resource:y}),A=_.URI.parse(d[0].uri),S=r.relative(A.codeUri.fsPath,f.currentUri.codeUri.fsPath),D=b.map(w=>({path:S,line:w.startLineNumber,severity:this.getSeverityString(w.severity),message:w.message})),T=JSON.stringify(D,null,2);return E.appendLine(`Found ${D.length} diagnostics in current file`),{content:[{type:"text",text:T}]}}catch(f){return E.appendLine(`Error getting diagnostics: ${f}`),{content:[{type:"text",text:"[]"}],isError:!0}}}getSeverityString(c){switch(c){case s.MarkerSeverity.Error:return"error";case s.MarkerSeverity.Warning:return"warning";case s.MarkerSeverity.Info:return"information";case s.MarkerSeverity.Hint:return"hint";default:return"unknown"}}};t.GetOpenEditorFileDiagnosticsTool=h,n.__decorate([(0,l.Autowired)(v.WorkbenchEditorService),n.__metadata("design:type",v.WorkbenchEditorService)],h.prototype,"editorService",void 0),n.__decorate([(0,l.Autowired)(m.IWorkspaceService),n.__metadata("design:type",Object)],h.prototype,"workspaceService",void 0),n.__decorate([(0,l.Autowired)(s.IMarkerService),n.__metadata("design:type",Object)],h.prototype,"markerService",void 0),t.GetOpenEditorFileDiagnosticsTool=h=n.__decorate([(0,_.Domain)(g.MCPServerContribution)],h)},39855:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GrepSearchTool=void 0;const n=e(85608),r=e(75995),o=e(76003),l=e(43718),_=e(13439),v=e(51495),m=e(51500),p=e(19413),s=e(59347),g=e(77633),a=e(95292),h=r.z.object({query:r.z.string().describe("The regex pattern to search for"),case_sensitive:r.z.boolean().optional().describe("Whether the search should be case sensitive"),include_pattern:r.z.string().optional().describe('Glob pattern for files to include (e.g. "*.ts" for TypeScript files)'),exclude_pattern:r.z.string().optional().describe("Glob pattern for files to exclude"),explanation:r.z.string().optional().describe("One sentence explanation as to why this tool is being used, and how it contributes to the goal.")}).transform(E=>({query:E.query,caseSensitive:E.case_sensitive,includePattern:E.include_pattern,excludePattern:E.exclude_pattern,explanation:E.explanation})),u=50;let c=class{registerMCPServer(f){f.registerMCPTool(this.getToolDefinition()),f.registerToolComponent("grep_search",a.GrepSearchToolComponent)}getToolDefinition(){return{name:"grep_search",label:"Search Contents",order:4,description:`Fast text-based regex search that finds exact pattern matches within files or directories, utilizing the ripgrep command for efficient searching.
32519
32519
  Results will be formatted in the style of ripgrep and can be configured to include line numbers and content.
32520
32520
  To avoid overwhelming output, the results are capped at 50 matches.
32521
32521
  Use the include or exclude patterns to filter the search scope by file type or specific paths.
32522
32522
 
32523
- This is best for finding exact text matches or regex patterns.`,inputSchema:h,handler:this.handler.bind(this)}}async handler(f,d){var y,b;if(!f.query)throw new Error("No ripgrep search parameters provided. Need to give at least a query.");const A=this.workspaceService.tryGetRoots();if(!A||A.length===0)throw new Error("Cannot determine project directory");const S=f.query;await this.searchService.doSearch(S,{isMatchCase:!!f.case_sensitive,include:(y=f.include_pattern)===null||y===void 0?void 0:y.split(","),exclude:(b=f.exclude_pattern)===null||b===void 0?void 0:b.split(","),maxResults:u,isUseRegexp:!0,isToggleOpen:!1,isDetailOpen:!1,isWholeWord:!1,isOnlyOpenEditors:!1,isIncludeIgnored:!1},l.CancellationToken.None);const D=new l.Deferred;return this.searchService.onDidChange(()=>{if(this.searchService.isSearching)return;const w=[],I=[];for(const[P,R]of this.searchService.searchResults.entries())w.push(`File: ${P}
32524
- ${R.reduce((M,k)=>M.find(F=>F.line===k.line)?M:[...M,k],[]).map(M=>`Line: ${M.line}
32525
- Content: ${M.lineText||M.renderLineText}`).join(`
32526
- `)}`),I.push({uri:P,isDirectory:!1});D.resolve(w.join(`
32523
+ This is best for finding exact text matches or regex patterns.`,inputSchema:h,handler:this.handler.bind(this)}}async handler(f,d){var y,b;if(!f.query)throw new Error("No ripgrep search parameters provided. Need to give at least a query.");const A=this.workspaceService.tryGetRoots();if(!A||A.length===0)throw new Error("Cannot determine project directory");const S=f.query;await this.searchService.doSearch(S,{isMatchCase:!!f.caseSensitive,include:(y=f.includePattern)===null||y===void 0?void 0:y.split(","),exclude:(b=f.excludePattern)===null||b===void 0?void 0:b.split(","),maxResults:u,isUseRegexp:!0,isToggleOpen:!1,isDetailOpen:!1,isWholeWord:!1,isOnlyOpenEditors:!1,isIncludeIgnored:!1},l.CancellationToken.None);const D=new l.Deferred;return this.searchService.onDidChange(()=>{var w;if(this.searchService.isSearching)return;const I=[],O=[];for(const[M,k]of this.searchService.searchResults.entries())I.push(`File: ${M}
32524
+ ${k.reduce((F,L)=>F.find(B=>B.line===L.line)?F:[...F,L],[]).map(F=>`Line: ${F.line}
32525
+ Content: ${F.lineText||F.renderLineText}`).join(`
32526
+ `)}`),O.push({uri:M,isDirectory:!1});D.resolve(I.join(`
32527
32527
 
32528
- `));const O=this.chatInternalService.sessionModel.history.getMessages();this.chatInternalService.sessionModel.history.setMessageAdditional(O[O.length-1].id,{[f.toolCallId]:{files:I}})}),{content:[{type:"text",text:await D.promise}]}}};t.GrepSearchTool=c,n.__decorate([(0,o.Autowired)(m.IWorkspaceService),n.__metadata("design:type",Object)],c.prototype,"workspaceService",void 0),n.__decorate([(0,o.Autowired)(_.IContentSearchClientService),n.__metadata("design:type",v.ContentSearchClientService)],c.prototype,"searchService",void 0),n.__decorate([(0,o.Autowired)(p.IChatInternalService),n.__metadata("design:type",s.ChatInternalService)],c.prototype,"chatInternalService",void 0),t.GrepSearchTool=c=n.__decorate([(0,l.Domain)(g.MCPServerContribution)],c)},9343:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditFileHandler=void 0;const n=e(85608),r=e(76003),o=e(73974);let l=class{async handler(v,m){const{targetFile:p,codeEdit:s,instructions:g}=v,a=await this.applyService.registerCodeBlock(p,s,m,g);return await this.applyService.apply(a)}};t.EditFileHandler=l,n.__decorate([(0,r.Autowired)(o.BaseApplyService),n.__metadata("design:type",o.BaseApplyService)],l.prototype,"applyService",void 0),t.EditFileHandler=l=n.__decorate([(0,r.Injectable)()],l)},64942:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ListDirHandler=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(14951);class _{constructor(p){this.maxConcurrent=p,this.currentCount=0,this.pendingQueue=[]}async execute(p){this.currentCount>=this.maxConcurrent&&await new Promise(s=>this.pendingQueue.push(s)),this.currentCount++;try{return await p()}finally{if(this.currentCount--,this.pendingQueue.length>0){const s=this.pendingQueue.shift();s?.()}}}}let v=class{constructor(){this.MAX_FILE_SIZE=1024*1024,this.MAX_INDEXED_FILES=50}getWorkspaceDir(){return this.appConfig.workspaceDir}async handler(p){var s,g;const{relativeWorkspacePath:a}=p;if(!a)throw new Error("No list dir parameters provided. Need to give at least the path.");const h=`${this.appConfig.workspaceDir}/${a}`,u=await this.fileSystemService.getFileStat(h,!0);if(!u||!u.isDirectory)throw new Error(`Could not find file ${a} in the workspace.`);const c=((s=u.children)===null||s===void 0?void 0:s.filter(y=>!y.isDirectory&&y.size!==void 0&&y.size<=this.MAX_FILE_SIZE).slice(0,this.MAX_INDEXED_FILES))||[],E=new Set(c.map(y=>new o.URI(y.uri).displayName)),f=new _(4);return{files:await Promise.all(((g=u.children)===null||g===void 0?void 0:g.sort((y,b)=>b.lastModification-y.lastModification).map(async y=>{var b;const A=new o.URI(y.uri),S=`${h}/${A.displayName}`;let D;return E.has(A.displayName)&&(D=await f.execute(async()=>this.countFileLines(S))),{name:A.displayName,isDirectory:y.isDirectory,size:y.size,lastModified:y.lastModification,numChildren:(b=y.children)===null||b===void 0?void 0:b.length,numLines:D}}))||[]),directoryRelativeWorkspacePath:a}}async countFileLines(p){return(await this.fileSystemService.readFile(o.URI.file(p).toString())).toString().split(`
32528
+ `));const P=this.chatInternalService.sessionModel.history.getMessages(),R=(w=P[P.length-1])===null||w===void 0?void 0:w.id;R&&this.chatInternalService.sessionModel.history.setMessageAdditional(R,{[f.toolCallId]:{files:O}})}),{content:[{type:"text",text:await D.promise}]}}};t.GrepSearchTool=c,n.__decorate([(0,o.Autowired)(m.IWorkspaceService),n.__metadata("design:type",Object)],c.prototype,"workspaceService",void 0),n.__decorate([(0,o.Autowired)(_.IContentSearchClientService),n.__metadata("design:type",v.ContentSearchClientService)],c.prototype,"searchService",void 0),n.__decorate([(0,o.Autowired)(p.IChatInternalService),n.__metadata("design:type",s.ChatInternalService)],c.prototype,"chatInternalService",void 0),t.GrepSearchTool=c=n.__decorate([(0,l.Domain)(g.MCPServerContribution)],c)},79346:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateNewFileWithTextHandler=void 0;const n=e(85608),r=e(76003),o=e(43718),l=e(14951),_=e(51500),v=e(73974);let m=class{async handler(s,g){const a=this.workspaceService.tryGetRoots();if(!a||a.length===0)throw new Error("can't find project dir");const h=o.URI.parse(a[0].uri),u=o.path.join(h.codeUri.fsPath,s.targetFile),c=o.URI.file(u),E=o.path.dirname(u),f=o.URI.file(E);await this.fileService.createFolder(f.toString()),await this.fileService.createFile(c.toString());const d=await this.applyService.registerCodeBlock(s.targetFile,s.codeEdit,g);return await this.applyService.apply(d),d}};t.CreateNewFileWithTextHandler=m,n.__decorate([(0,r.Autowired)(_.IWorkspaceService),n.__metadata("design:type",Object)],m.prototype,"workspaceService",void 0),n.__decorate([(0,r.Autowired)(l.IFileServiceClient),n.__metadata("design:type",Object)],m.prototype,"fileService",void 0),n.__decorate([(0,r.Autowired)(v.BaseApplyService),n.__metadata("design:type",v.BaseApplyService)],m.prototype,"applyService",void 0),t.CreateNewFileWithTextHandler=m=n.__decorate([(0,r.Injectable)()],m)},9343:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditFileHandler=void 0;const n=e(85608),r=e(76003),o=e(73974);let l=class{async handler(v,m){const{targetFile:p,codeEdit:s,instructions:g}=v,a=await this.applyService.registerCodeBlock(p,s,m,g);return await this.applyService.apply(a)}};t.EditFileHandler=l,n.__decorate([(0,r.Autowired)(o.BaseApplyService),n.__metadata("design:type",o.BaseApplyService)],l.prototype,"applyService",void 0),t.EditFileHandler=l=n.__decorate([(0,r.Injectable)()],l)},64942:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ListDirHandler=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(14951);class _{constructor(p){this.maxConcurrent=p,this.currentCount=0,this.pendingQueue=[]}async execute(p){this.currentCount>=this.maxConcurrent&&await new Promise(s=>this.pendingQueue.push(s)),this.currentCount++;try{return await p()}finally{if(this.currentCount--,this.pendingQueue.length>0){const s=this.pendingQueue.shift();s?.()}}}}let v=class{constructor(){this.MAX_FILE_SIZE=1024*1024,this.MAX_INDEXED_FILES=50}getWorkspaceDir(){return this.appConfig.workspaceDir}async handler(p){var s,g;const{relativeWorkspacePath:a}=p;if(!a)throw new Error("No list dir parameters provided. Need to give at least the path.");const h=o.path.join(this.appConfig.workspaceDir,a),u=await this.fileSystemService.getFileStat(h,!0);if(!u||!u.isDirectory)throw new Error(`Could not find file ${a} in the workspace.`);const c=((s=u.children)===null||s===void 0?void 0:s.filter(y=>!y.isDirectory&&y.size!==void 0&&y.size<=this.MAX_FILE_SIZE).slice(0,this.MAX_INDEXED_FILES))||[],E=new Set(c.map(y=>new o.URI(y.uri).displayName)),f=new _(4);return{files:await Promise.all(((g=u.children)===null||g===void 0?void 0:g.sort((y,b)=>b.lastModification-y.lastModification).map(async y=>{var b;const A=new o.URI(y.uri),S=`${h}/${A.displayName}`;let D;return E.has(A.displayName)&&(D=await f.execute(async()=>this.countFileLines(S))),{name:A.displayName,isDirectory:y.isDirectory,size:y.size,lastModified:y.lastModification,numChildren:(b=y.children)===null||b===void 0?void 0:b.length,numLines:D}}))||[]),directoryRelativeWorkspacePath:a}}async countFileLines(p){return(await this.fileSystemService.readFile(o.URI.file(p).toString())).toString().split(`
32529
32529
  `).length}};t.ListDirHandler=v,n.__decorate([(0,r.Autowired)(o.AppConfig),n.__metadata("design:type",Object)],v.prototype,"appConfig",void 0),n.__decorate([(0,r.Autowired)(l.IFileServiceClient),n.__metadata("design:type",Object)],v.prototype,"fileSystemService",void 0),t.ListDirHandler=v=n.__decorate([(0,r.Injectable)()],v)},707:(x,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.FileHandler=void 0;const r=e(85608),o=e(76003),l=e(79240),_=e(41869),v=e(43718),m=e(57517),p=e(14951);let s=n=class{constructor(){this.fileResultMap=new Map}async findSimilarFiles(a,h){return(await this.fileSearchQuickCommandHandler.getQueryFiles(a,new Set,v.CancellationToken.None)).slice(0,h).map(c=>{var E;return(E=c.getUri())===null||E===void 0?void 0:E.codeUri.fsPath}).filter(Boolean)}createFileNotFoundError(a,h){const u=h.length>0?`Could not find file '${a}'. Did you mean one of:
32530
32530
  ${h.map(c=>`- ${c}`).join(`
32531
- `)}`:`Could not find file '${a}' in the workspace.`;return new Error(JSON.stringify({clientVisibleErrorMessage:u,modelVisibleErrorMessage:u,actualErrorMessage:`File not found: ${a}`}))}createFileTooLargeError(a,h){return new Error(JSON.stringify({clientVisibleErrorMessage:`File is too large, >${a}MB`,modelVisibleErrorMessage:`The file is too large to read, was >${a}MB`,actualErrorMessage:`File is too large to read, was >${a}MB, size: ${h} bytes`}))}trimContent(a,h){return a.slice(0,h).split(n.NEWLINE).slice(0,-1).join(n.NEWLINE)}getLineRange(a,h){var u,c;let E=(u=a.startLineOneIndexed)!==null&&u!==void 0?u:1,f=(c=a.endLineOneIndexedInclusive)!==null&&c!==void 0?c:E+n.MAX_LINES-1,d=!1,y=!1;return h?{start:E,end:f,didShorten:d,didSetDefault:y}:(a.endLineOneIndexedInclusive===void 0||a.startLineOneIndexed===void 0?(E=1,f=n.MAX_LINES,y=!0):a.endLineOneIndexedInclusive-a.startLineOneIndexed>n.MAX_LINES&&(f=a.startLineOneIndexed+n.MAX_LINES,d=!0),{start:E,end:f,didShorten:d,didSetDefault:y})}async readFile(a){if(!a)throw new Error("No read file parameters provided. Need to give at least the path.");const h=new v.URI(`${this.appConfig.workspaceDir}/${a.relativeWorkspacePath}`);if(!h){const f=await this.findSimilarFiles(a.relativeWorkspacePath,3);throw this.createFileNotFoundError(a.relativeWorkspacePath,f)}const u=(n.MAX_FILE_SIZE_BYTES/1e6).toFixed(2),c=await this.fileSystemService.getFileStat(h.toString());if(c?.size&&c.size>n.MAX_FILE_SIZE_BYTES)throw this.createFileTooLargeError(u,c.size);let E;try{E=await this.modelService.createModelReference(h);const f=E.instance.getMonacoModel().getValue(),d=f.split(n.NEWLINE),y=!(a.readEntireFile&&a.fileIsAllowedToBeReadEntirely),b=a.readEntireFile&&!a.fileIsAllowedToBeReadEntirely;let A=!1;if(y){const{start:D,end:T,didShorten:w,didSetDefault:I}=this.getLineRange(a,b),O=Math.max(D,1),P=Math.min(T,d.length);let R=d.slice(O-1,P).join(n.NEWLINE);return R.length>n.MAX_CHARS&&(A=!0,R=this.trimContent(R,n.MAX_CHARS)),w&&this.fileResultMap.set(a.relativeWorkspacePath,{content:R,startLineOneIndexed:O,endLineOneIndexedInclusive:P}),{contents:R,didDowngradeToLineRange:b,didShortenLineRange:w,didShortenCharRange:A,didSetDefaultLineRange:I,fullFileContents:f,startLineOneIndexed:O,endLineOneIndexedInclusive:P,relativeWorkspacePath:a.relativeWorkspacePath}}let S=f;return S.length>n.MAX_CHARS&&(A=!0,S=this.trimContent(S,n.MAX_CHARS)),{contents:S,fullFileContents:f,didDowngradeToLineRange:!1,didShortenCharRange:A}}finally{E?.dispose()}}getFileReadResult(a){return this.fileResultMap.get(a)}};t.FileHandler=s,s.MAX_FILE_SIZE_BYTES=2e6,s.MAX_LINES=250,s.MAX_CHARS=1e5,s.NEWLINE=`
32532
- `,r.__decorate([(0,o.Autowired)(m.IEditorDocumentModelService),r.__metadata("design:type",Object)],s.prototype,"modelService",void 0),r.__decorate([(0,o.Autowired)(l.FileSearchQuickCommandHandler),r.__metadata("design:type",l.FileSearchQuickCommandHandler)],s.prototype,"fileSearchQuickCommandHandler",void 0),r.__decorate([(0,o.Autowired)(_.AppConfig),r.__metadata("design:type",Object)],s.prototype,"appConfig",void 0),r.__decorate([(0,o.Autowired)(p.IFileServiceClient),r.__metadata("design:type",Object)],s.prototype,"fileSystemService",void 0),t.FileHandler=s=n=r.__decorate([(0,o.Injectable)()],s)},22559:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RunCommandHandler=t.inputSchema=void 0;const n=e(85608),r=n.__importDefault(e(75995)),o=e(76003),l=e(41869),_=e(6487),v=e(69448),m=e(83854),p={italic:"\x1B[3m",reset:"\x1B[0m"};t.inputSchema=r.default.object({command:r.default.string().describe("The terminal command to execute"),is_background:r.default.boolean().describe("Whether the command should be run in the background"),explanation:r.default.string().describe("One sentence explanation as to why this command needs to be run and how it contributes to the goal."),require_user_approval:r.default.boolean().describe("Whether the user must approve the command before it is executed. Only set this to false if the command is safe and if it matches the user's requirements for commands that should be executed automatically.")});let s=class{constructor(){this.approvalDeferredMap=new Map,this.terminalId=0}getShellLaunchConfig(a){return{name:`MCP:Terminal_${this.terminalId++}`,cwd:this.appConfig.workspaceDir,args:["-c",a]}}isAlwaysApproval(a){const h=this.preferenceService.get(l.AINativeSettingSectionsId.TerminalAutoRun);return!!(h===m.ETerminalAutoExecutionPolicy.off||h===m.ETerminalAutoExecutionPolicy.auto&&a)}async handler(a,h){if(h.appendLine(`Executing command: ${a.command}`),this.isAlwaysApproval(a.require_user_approval)){const f=new v.Deferred;if(this.approvalDeferredMap.set(a.toolCallId,f),!await f.promise)return{isError:!1,content:[{type:"text",text:"User rejection"}]}}const u=await this.terminalController.createTerminalWithWidget({config:this.getShellLaunchConfig(a.command),closeWhenExited:!1});this.terminalController.showTerminalPanel();const c=[],E=new v.Deferred;return a.is_background&&E.resolve({isError:!1,content:[{type:"text",text:`Successful run command ${a.command} in background.`}]}),u.onOutput(f=>{c.push({type:"text",text:f.data.toString()})}),u.onExit(f=>{const d=f.code!==0;E.resolve({isError:d,content:c}),h.appendLine(`Command ${a.command} finished with exit code: ${f.code}`),u.term.writeln(`
32531
+ `)}`:`Could not find file '${a}' in the workspace.`;return new Error(JSON.stringify({clientVisibleErrorMessage:u,modelVisibleErrorMessage:u,actualErrorMessage:`File not found: ${a}`}))}createFileTooLargeError(a,h){return new Error(JSON.stringify({clientVisibleErrorMessage:`File is too large, >${a}MB`,modelVisibleErrorMessage:`The file is too large to read, was >${a}MB`,actualErrorMessage:`File is too large to read, was >${a}MB, size: ${h} bytes`}))}trimContent(a,h){return a.slice(0,h).split(n.NEWLINE).slice(0,-1).join(n.NEWLINE)}getLineRange(a,h){var u,c;let E=(u=a.startLineOneIndexed)!==null&&u!==void 0?u:1,f=(c=a.endLineOneIndexedInclusive)!==null&&c!==void 0?c:E+n.MAX_LINES-1,d=!1,y=!1;return h?{start:E,end:f,didShorten:d,didSetDefault:y}:(a.endLineOneIndexedInclusive===void 0||a.startLineOneIndexed===void 0?(E=1,f=n.MAX_LINES,y=!0):a.endLineOneIndexedInclusive-a.startLineOneIndexed>n.MAX_LINES&&(f=a.startLineOneIndexed+n.MAX_LINES,d=!0),{start:E,end:f,didShorten:d,didSetDefault:y})}async readFile(a){if(!a)throw new Error("No read file parameters provided. Need to give at least the path.");const h=new v.URI(v.path.join(this.appConfig.workspaceDir,a.relativeWorkspacePath));if(!h){const f=await this.findSimilarFiles(a.relativeWorkspacePath,3);throw this.createFileNotFoundError(a.relativeWorkspacePath,f)}const u=(n.MAX_FILE_SIZE_BYTES/1e6).toFixed(2),c=await this.fileSystemService.getFileStat(h.toString());if(c?.size&&c.size>n.MAX_FILE_SIZE_BYTES)throw this.createFileTooLargeError(u,c.size);let E;try{E=await this.modelService.createModelReference(h);const f=E.instance.getMonacoModel().getValue(),d=f.split(n.NEWLINE),y=!(a.readEntireFile&&a.fileIsAllowedToBeReadEntirely),b=a.readEntireFile&&!a.fileIsAllowedToBeReadEntirely;let A=!1;if(y){const{start:D,end:T,didShorten:w,didSetDefault:I}=this.getLineRange(a,b),O=Math.max(D,1),P=Math.min(T,d.length);let R=d.slice(O-1,P).join(n.NEWLINE);return R.length>n.MAX_CHARS&&(A=!0,R=this.trimContent(R,n.MAX_CHARS)),w&&this.fileResultMap.set(a.relativeWorkspacePath,{content:R,startLineOneIndexed:O,endLineOneIndexedInclusive:P}),{contents:R,didDowngradeToLineRange:b,didShortenLineRange:w,didShortenCharRange:A,didSetDefaultLineRange:I,fullFileContents:f,startLineOneIndexed:O,endLineOneIndexedInclusive:P,relativeWorkspacePath:a.relativeWorkspacePath}}let S=f;return S.length>n.MAX_CHARS&&(A=!0,S=this.trimContent(S,n.MAX_CHARS)),{contents:S,fullFileContents:f,didDowngradeToLineRange:!1,didShortenCharRange:A}}finally{E?.dispose()}}getFileReadResult(a){return this.fileResultMap.get(a)}};t.FileHandler=s,s.MAX_FILE_SIZE_BYTES=2e6,s.MAX_LINES=250,s.MAX_CHARS=1e5,s.NEWLINE=`
32532
+ `,r.__decorate([(0,o.Autowired)(m.IEditorDocumentModelService),r.__metadata("design:type",Object)],s.prototype,"modelService",void 0),r.__decorate([(0,o.Autowired)(l.FileSearchQuickCommandHandler),r.__metadata("design:type",l.FileSearchQuickCommandHandler)],s.prototype,"fileSearchQuickCommandHandler",void 0),r.__decorate([(0,o.Autowired)(_.AppConfig),r.__metadata("design:type",Object)],s.prototype,"appConfig",void 0),r.__decorate([(0,o.Autowired)(p.IFileServiceClient),r.__metadata("design:type",Object)],s.prototype,"fileSystemService",void 0),t.FileHandler=s=n=r.__decorate([(0,o.Injectable)()],s)},22559:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RunCommandHandler=t.inputSchema=void 0;const n=e(85608),r=n.__importDefault(e(75995)),o=e(76003),l=e(41869),_=e(6487),v=e(69448),m=e(83854),p={italic:"\x1B[3m",reset:"\x1B[0m"};t.inputSchema=r.default.object({command:r.default.string().describe("The terminal command to execute"),is_background:r.default.boolean().describe("Whether the command should be run in the background"),explanation:r.default.string().describe("One sentence explanation as to why this command needs to be run and how it contributes to the goal."),require_user_approval:r.default.boolean().describe("Whether the user must approve the command before it is executed. Only set this to false if the command is safe and if it matches the user's requirements for commands that should be executed automatically.")}).transform(g=>({command:g.command,isBackground:g.is_background,explanation:g.explanation,requireUserApproval:g.require_user_approval}));let s=class{constructor(){this.approvalDeferredMap=new Map,this.terminalId=0}getShellLaunchConfig(a){return{name:`MCP:Terminal_${this.terminalId++}`,cwd:this.appConfig.workspaceDir,args:["-c",a]}}isAlwaysApproval(a){const h=this.preferenceService.get(l.AINativeSettingSectionsId.TerminalAutoRun);return!!(h===m.ETerminalAutoExecutionPolicy.off||h===m.ETerminalAutoExecutionPolicy.auto&&a)}async handler(a,h){if(h.appendLine(`Executing command: ${a.command}`),this.isAlwaysApproval(a.requireUserApproval)){const f=new v.Deferred;if(this.approvalDeferredMap.set(a.toolCallId,f),!await f.promise)return{isError:!1,content:[{type:"text",text:"User rejection"}]}}const u=await this.terminalController.createTerminalWithWidget({config:this.getShellLaunchConfig(a.command),closeWhenExited:!1});this.terminalController.showTerminalPanel();const c=[],E=new v.Deferred;return a.isBackground&&E.resolve({isError:!1,content:[{type:"text",text:`Successful run command ${a.command} in background.`}]}),u.onOutput(f=>{c.push({type:"text",text:f.data.toString()})}),u.onExit(f=>{const d=f.code!==0;E.resolve({isError:d,content:c}),h.appendLine(`Command ${a.command} finished with exit code: ${f.code}`),u.term.writeln(`
32533
32533
  ${p.italic}> Command ${a.command} executed successfully. Terminal will close in ${3e3/1e3} seconds.${p.reset}
32534
- `),setTimeout(()=>{u.dispose(),this.terminalView.removeWidget(u.id)},3e3)}),E.promise}handleApproval(a,h){if(!this.approvalDeferredMap.has(a))return;const u=this.approvalDeferredMap.get(a);u?.resolve(h)}};t.RunCommandHandler=s,n.__decorate([(0,o.Autowired)(_.ITerminalController),n.__metadata("design:type",Object)],s.prototype,"terminalController",void 0),n.__decorate([(0,o.Autowired)(l.AppConfig),n.__metadata("design:type",Object)],s.prototype,"appConfig",void 0),n.__decorate([(0,o.Autowired)(_.ITerminalGroupViewService),n.__metadata("design:type",Object)],s.prototype,"terminalView",void 0),n.__decorate([(0,o.Autowired)(l.PreferenceService),n.__metadata("design:type",Object)],s.prototype,"preferenceService",void 0),t.RunCommandHandler=s=n.__decorate([(0,o.Injectable)()],s)},82248:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ListDirTool=void 0;const n=e(85608),r=e(75995),o=e(76003),l=e(43718),_=e(19413),v=e(59347),m=e(77633),p=e(95292),s=e(64942),g=r.z.object({relative_workspace_path:r.z.string().describe("Path to list contents of, relative to the workspace root. Ex: './' is the root of the workspace"),explanation:r.z.string().optional().describe("One sentence explanation as to why this tool is being used, and how it contributes to the goal.")}).transform(h=>({relativeWorkspacePath:h.relative_workspace_path}));let a=class{registerMCPServer(u){u.registerMCPTool(this.getToolDefinition()),u.registerToolComponent("list_dir",p.ListDirToolComponent)}getToolDefinition(){return{name:"list_dir",label:"List Directory",order:3,description:"List the contents of a directory. The quick tool to use for discovery, before using more targeted tools like semantic search or file reading. Useful to try to understand the file structure before diving deeper into specific files. Can be used to explore the codebase.",inputSchema:g,handler:this.handler.bind(this)}}async handler(u,c){const E=await this.listDirHandler.handler(u),f=E.files.map(y=>({uri:`${this.listDirHandler.getWorkspaceDir()}/${E.directoryRelativeWorkspacePath}/${y.name}`,isDirectory:y.isDirectory})),d=this.chatInternalService.sessionModel.history.getMessages();return this.chatInternalService.sessionModel.history.setMessageAdditional(d[d.length-1].id,{[u.toolCallId]:{files:f,title:`Listed directory "${u.relativeWorkspacePath}"`,details:E.files.map(y=>{var b;return{type:y.isDirectory?"dir":"file",name:y.name,info:y.isDirectory?`${(b=y.numChildren)!==null&&b!==void 0?b:"?"} items`:`${y.size}KB, ${y.numLines} lines`,lastModified:y.lastModified}})}}),c.appendLine(`Listed ${f.length} files in directory "${u.relativeWorkspacePath}"`),{content:[{type:"text",text:`Contents of directory "${u.relativeWorkspacePath}":
32535
- ${E.files.map(y=>{var b;return`[${y.isDirectory?"dir":"file"}] ${y.name} ${y.isDirectory?`(${(b=y.numChildren)!==null&&b!==void 0?b:"?"} items)`:`(${y.size}KB, ${y.numLines} lines)`} - ${new Date(y.lastModified).toLocaleString()}`}).join(`
32534
+ `),setTimeout(()=>{u.dispose(),this.terminalView.removeWidget(u.id)},3e3)}),E.promise}handleApproval(a,h){if(!this.approvalDeferredMap.has(a))return;const u=this.approvalDeferredMap.get(a);u?.resolve(h)}};t.RunCommandHandler=s,n.__decorate([(0,o.Autowired)(_.ITerminalController),n.__metadata("design:type",Object)],s.prototype,"terminalController",void 0),n.__decorate([(0,o.Autowired)(l.AppConfig),n.__metadata("design:type",Object)],s.prototype,"appConfig",void 0),n.__decorate([(0,o.Autowired)(_.ITerminalGroupViewService),n.__metadata("design:type",Object)],s.prototype,"terminalView",void 0),n.__decorate([(0,o.Autowired)(l.PreferenceService),n.__metadata("design:type",Object)],s.prototype,"preferenceService",void 0),t.RunCommandHandler=s=n.__decorate([(0,o.Injectable)()],s)},82248:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ListDirTool=void 0;const n=e(85608),r=e(75995),o=e(76003),l=e(43718),_=e(19413),v=e(59347),m=e(77633),p=e(95292),s=e(64942),g=r.z.object({relative_workspace_path:r.z.string().describe("Path to list contents of, relative to the workspace root. Ex: './' is the root of the workspace"),explanation:r.z.string().optional().describe("One sentence explanation as to why this tool is being used, and how it contributes to the goal.")}).transform(h=>({relativeWorkspacePath:h.relative_workspace_path}));let a=class{registerMCPServer(u){u.registerMCPTool(this.getToolDefinition()),u.registerToolComponent("list_dir",p.ListDirToolComponent)}getToolDefinition(){return{name:"list_dir",label:"List Directory",order:3,description:"List the contents of a directory. The quick tool to use for discovery, before using more targeted tools like semantic search or file reading. Useful to try to understand the file structure before diving deeper into specific files. Can be used to explore the codebase.",inputSchema:g,handler:this.handler.bind(this)}}async handler(u,c){var E;const f=await this.listDirHandler.handler(u),d=f.files.map(A=>({uri:`${this.listDirHandler.getWorkspaceDir()}/${f.directoryRelativeWorkspacePath}/${A.name}`,isDirectory:A.isDirectory})),y=this.chatInternalService.sessionModel.history.getMessages(),b=(E=y[y.length-1])===null||E===void 0?void 0:E.id;return b&&this.chatInternalService.sessionModel.history.setMessageAdditional(b,{[u.toolCallId]:{files:d,title:`Listed directory "${u.relativeWorkspacePath}"`,details:f.files.map(A=>{var S;return{type:A.isDirectory?"dir":"file",name:A.name,info:A.isDirectory?`${(S=A.numChildren)!==null&&S!==void 0?S:"?"} items`:`${A.size}KB, ${A.numLines} lines`,lastModified:A.lastModified}})}}),c.appendLine(`Listed ${d.length} files in directory "${u.relativeWorkspacePath}"`),{content:[{type:"text",text:`Contents of directory "${u.relativeWorkspacePath}":
32535
+ ${f.files.map(A=>{var S;return`[${A.isDirectory?"dir":"file"}] ${A.name} ${A.isDirectory?`(${(S=A.numChildren)!==null&&S!==void 0?S:"?"} items)`:`(${A.size}KB, ${A.numLines} lines)`} - ${new Date(A.lastModified).toLocaleString()}`}).join(`
32536
32536
  `)}`}]}}};t.ListDirTool=a,n.__decorate([(0,o.Autowired)(s.ListDirHandler),n.__metadata("design:type",s.ListDirHandler)],a.prototype,"listDirHandler",void 0),n.__decorate([(0,o.Autowired)(_.IChatInternalService),n.__metadata("design:type",v.ChatInternalService)],a.prototype,"chatInternalService",void 0),t.ListDirTool=a=n.__decorate([(0,l.Domain)(m.MCPServerContribution)],a)},36977:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReadFileTool=void 0;const n=e(85608),r=e(75995),o=e(76003),l=e(43718),_=e(77633),v=e(707),m=r.z.object({relative_workspace_path:r.z.string().describe("The path of the file to read, relative to the workspace root."),should_read_entire_file:r.z.boolean().describe("Whether to read the entire file. Defaults to false."),start_line_one_indexed:r.z.number().describe("The one-indexed line number to start reading from (inclusive)."),end_line_one_indexed_inclusive:r.z.number().describe("The one-indexed line number to end reading at (inclusive)."),explanation:r.z.string().optional().describe("One sentence explanation as to why this tool is being used, and how it contributes to the goal.")}).transform(s=>({relativeWorkspacePath:s.relative_workspace_path,readEntireFile:s.should_read_entire_file,startLineOneIndexed:s.start_line_one_indexed,endLineOneIndexedInclusive:s.end_line_one_indexed_inclusive}));let p=class{registerMCPServer(g){g.registerMCPTool(this.getToolDefinition())}getToolDefinition(){return{name:"read_file",label:"Read File",order:1,description:`Read the contents of a file (and the outline).
32537
32537
 
32538
32538
  When using this tool to gather information, it's your responsibility to ensure you have the COMPLETE context. Each time you call this command you should:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opensumi/cli-engine",
3
- "version": "3.9.1-next-1749023860.0",
3
+ "version": "3.9.1-next-1749115679.0",
4
4
  "description": "Integration engine runtime for opensumi-cli and opensumi extension",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -26,14 +26,14 @@
26
26
  "dependencies": {
27
27
  "@koa/cors": "^5.0.0",
28
28
  "@opensumi/di": "^1.8.0",
29
- "@opensumi/ide-core-browser": "3.9.1-next-1749023860.0",
30
- "@opensumi/ide-core-common": "3.9.1-next-1749023860.0",
31
- "@opensumi/ide-core-node": "3.9.1-next-1749023860.0",
32
- "@opensumi/ide-express-file-server": "3.9.1-next-1749023860.0",
33
- "@opensumi/ide-extension": "3.9.1-next-1749023860.0",
34
- "@opensumi/ide-i18n": "3.9.1-next-1749023860.0",
35
- "@opensumi/ide-main-layout": "3.9.1-next-1749023860.0",
36
- "@opensumi/ide-startup": "3.9.1-next-1749023860.0",
29
+ "@opensumi/ide-core-browser": "3.9.1-next-1749115679.0",
30
+ "@opensumi/ide-core-common": "3.9.1-next-1749115679.0",
31
+ "@opensumi/ide-core-node": "3.9.1-next-1749115679.0",
32
+ "@opensumi/ide-express-file-server": "3.9.1-next-1749115679.0",
33
+ "@opensumi/ide-extension": "3.9.1-next-1749115679.0",
34
+ "@opensumi/ide-i18n": "3.9.1-next-1749115679.0",
35
+ "@opensumi/ide-main-layout": "3.9.1-next-1749115679.0",
36
+ "@opensumi/ide-startup": "3.9.1-next-1749115679.0",
37
37
  "chalk": "^4.1.2",
38
38
  "ejs": "^3.1.7",
39
39
  "ip": "^1.1.8",
@@ -72,5 +72,5 @@
72
72
  "webpack": "^5.90.0",
73
73
  "webpack-cli": "^5.1.4"
74
74
  },
75
- "gitHead": "281361fe77302b65dbe00dfd8fca9eebb1cdac19"
75
+ "gitHead": "960b0142283d8722c44d3afea828e33a5e8b56b5"
76
76
  }