@opensumi/cli-engine 3.9.1-next-1761534197.0 → 3.9.1-next-1761715915.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.
@@ -32950,13 +32950,13 @@ ${JSON.stringify(r,null,2)}`);const l=n[o]();return new Language(INTERNAL,l)})}}
32950
32950
  User's intention: ${c.instructions}
32951
32951
  `:""}
32952
32952
  Provide the complete updated code.
32953
- `,{...await this.chatProxyService.getRequestOptions(),trimTexts:["<updated-code>","</updated-code>"],system:"You are a coding assistant that helps merge code updates, ensuring every modification is fully integrated."})}}};t.ApplyService=h,n.__decorate([(0,r.Autowired)(l.CommandService),n.__metadata("design:type",Object)],h.prototype,"commandService",void 0),n.__decorate([(0,r.Autowired)(_.IEditorDocumentModelService),n.__metadata("design:type",Object)],h.prototype,"modelService",void 0),n.__decorate([(0,r.Autowired)(o.AIBackSerivcePath),n.__metadata("design:type",Object)],h.prototype,"aiBackService",void 0),n.__decorate([(0,r.Autowired)(p.ChatProxyServiceToken),n.__metadata("design:type",g.ChatProxyService)],h.prototype,"chatProxyService",void 0),t.ApplyService=h=n.__decorate([(0,r.Injectable)()],h)},74055:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatAgentService=void 0;const n=e(85608),r=n.__importDefault(e(66652)),o=e(76003),l=e(43718),_=e(46044),v=e(73307),m=e(29770);let p=class extends l.Disposable{constructor(){super(),this.agents=new Map,this.initialUserMessageMap=new Map,this.shouldUpdateContext=!1,this._onDidChangeAgents=new l.Emitter,this.onDidChangeAgents=this._onDidChangeAgents.event,this._onDidSendMessage=new l.Emitter,this.onDidSendMessage=this._onDidSendMessage.event,this.addDispose(this._onDidChangeAgents),this.addDispose(this.llmContextService.onDidContextFilesChangeEvent(g=>{g.version!==this.contextVersion&&(this.contextVersion=g.version,this.shouldUpdateContext=!0)}))}registerAgent(g){if(this.agents.has(g.id))throw new Error(`Already registered an agent with id ${g.id}`);return this.agents.set(g.id,{agent:g,commands:[]}),this._onDidChangeAgents.fire(),(0,l.toDisposable)(()=>{this.agents.delete(g.id)&&this._onDidChangeAgents.fire()})}async updateAgent(g,a){const h=this.agents.get(g);if(!h)throw new Error(`No agent with id ${g} registered`);h.agent.metadata={...h.agent.metadata,...a},h.commands=await h.agent.provideSlashCommands(l.CancellationToken.None),a.isDefault&&(this.defaultAgentId=g);const u=await h.agent.provideChatWelcomeMessage(l.CancellationToken.None);if(u){const{content:c,sampleQuestions:E}=u;this.chatFeatureRegistry.registerWelcome(c,E)}this._onDidChangeAgents.fire()}getAgents(){return Array.from(this.agents.values(),g=>g.agent)}hasAgent(g){return this.agents.has(g)}getDefaultAgentId(){return this.defaultAgentId}getAgent(g){const a=this.agents.get(g);return a?.agent}async invokeAgent(g,a,h,u,c){const E=this.agents.get(g);if(!E)throw new Error(`No agent with id ${g}`);if(this.initialUserMessageMap.has(a.sessionId))(this.shouldUpdateContext||a.regenerate||u.length===0)&&(a.message=await this.provideContextMessage(a.message,a.sessionId),this.shouldUpdateContext=!1);else{this.initialUserMessageMap.set(a.sessionId,a.message);const d=a.message;a.message=await this.provideContextMessage(d,a.sessionId)}return await E.agent.invoke(a,h,u,c)}async provideContextMessage(g,a){const h=await this.llmContextService.serialize(),u=await this.promptProvider.provideContextPrompt(h,g);return this.aiReporter.send({msgType:l.AIServiceType.Chat,actionType:l.ActionTypeEnum.ContextEnhance,actionSource:l.ActionSourceEnum.Chat,sessionId:a,message:u}),u}populateChatInput(g,a){this.aiChatService.sendMessage({...a,agentId:g,immediate:!1})}getCommands(){return(0,r.default)(Array.from(this.agents.values(),({agent:g,commands:a})=>a.map(h=>({...h,agentId:g.id}))))}async getFollowups(g,a,h){const u=this.agents.get(g);if(!u)throw new Error(`No agent with id ${g}`);return u.agent.provideFollowups?u.agent.provideFollowups(a,h):[]}async getSampleQuestions(g,a){const h=this.agents.get(g);if(!h)throw new Error(`No agent with id ${g}`);return h.agent.provideSampleQuestions?h.agent.provideSampleQuestions(a):[]}async getAllSampleQuestions(){const g=await Promise.all(Array.from(this.agents.values()).map(async({agent:a})=>{try{return await this.getSampleQuestions(a.id,l.CancellationToken.None)}catch(h){return this.logger.error(h),[]}}));return(0,r.default)(g)}sendMessage(g){this._onDidSendMessage.fire(g)}parseMessage(g,a){var h;const u={agentId:"",command:"",message:g};let c=a;const E=this.getAgents(),f=new RegExp(`^@(${E.map(y=>y.id).join("|")})(?:\\s+|$)`,"i"),d=u.message.match(f);if(d){const y=E.find(b=>b.id.toLowerCase()===d[1].toLowerCase());if(!y)return u;c=y.id,u.agentId=c,u.message=u.message.replace(d[0],"")}if(c){const y=(h=this.agents.get(c))===null||h===void 0?void 0:h.commands;if(y?.length){const b=new RegExp(`^/\\s?(${y.map(S=>S.name).join("|")})(?:\\s+|$)`,"i"),A=u.message.match(b);if(A){const S=y.find(D=>D.name.toLowerCase()===A[1].toLowerCase());if(!S)return u;u.command=S.name,u.message=u.message.replace(A[0],"")}}}return u}};t.ChatAgentService=p,n.__decorate([(0,o.Autowired)(l.ILogger),n.__metadata("design:type",Object)],p.prototype,"logger",void 0),n.__decorate([(0,o.Autowired)(l.IAIReporter),n.__metadata("design:type",Object)],p.prototype,"aiReporter",void 0),n.__decorate([(0,o.Autowired)(_.LLMContextServiceToken),n.__metadata("design:type",Object)],p.prototype,"llmContextService",void 0),n.__decorate([(0,o.Autowired)(v.ChatAgentPromptProvider),n.__metadata("design:type",Object)],p.prototype,"promptProvider",void 0),n.__decorate([(0,o.Autowired)(l.ChatServiceToken),n.__metadata("design:type",m.ChatService)],p.prototype,"aiChatService",void 0),n.__decorate([(0,o.Autowired)(l.ChatFeatureRegistryToken),n.__metadata("design:type",Object)],p.prototype,"chatFeatureRegistry",void 0),t.ChatAgentService=p=n.__decorate([(0,o.Injectable)(),n.__metadata("design:paramtypes",[])],p)},84543:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatAgentViewService=void 0;const n=e(85608),r=e(76003),o=e(43718),l=e(19413),_=e(51081);let v=class{constructor(){this.componentsMap=new Map,this.componentsDeferredMap=new Map}registerChatComponent(p){return this.componentsMap.set(p.id,p),this.componentsDeferredMap.has(p.id)&&(this.componentsDeferredMap.get(p.id).resolve(p),this.componentsDeferredMap.delete(p.id)),{dispose:()=>{this.componentsMap.get(p.id)===p&&(this.componentsMap.delete(p.id),this.componentsDeferredMap.delete(p.id))}}}getChatComponent(p){return this.componentsMap.has(p)?this.componentsMap.get(p):(this.componentsDeferredMap.has(p)||this.componentsDeferredMap.set(p,new o.Deferred),null)}getChatComponentDeferred(p){return this.componentsDeferredMap.get(p)||null}getRenderAgents(){return this.chatAgentService.getAgents().filter(p=>p.id!==_.ChatProxyService.AGENT_ID)}};t.ChatAgentViewService=v,n.__decorate([(0,r.Autowired)(l.IChatAgentService),n.__metadata("design:type",Object)],v.prototype,"chatAgentService",void 0),t.ChatAgentViewService=v=n.__decorate([(0,r.Injectable)()],v)},98987:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatEditSchemeDocumentProvider=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(54414),_=e(96689),v=e(73974);let m=class{constructor(){this._onDidChangeContent=new o.Emitter,this.onDidChangeContent=this._onDidChangeContent.event}handlesScheme(s){return s===v.BaseApplyService.CHAT_EDITING_SOURCE_RESOLVER_SCHEME}async provideEditorDocumentModelContent(s,g){const{id:a,side:h}=s.getParsedQuery(),c=this.baseApplyService.getSessionCodeBlocks().find(f=>f.toolCallId===a);return(h==="left"?c?.originalCode:c?.updatedCode)||""}isReadonly(s){return!0}onDidDisposeModel(){}};t.ChatEditSchemeDocumentProvider=m,n.__decorate([(0,r.Autowired)(_.IEditorDocumentModelService),n.__metadata("design:type",Object)],m.prototype,"editorDocumentModelService",void 0),n.__decorate([(0,r.Autowired)(l.WorkbenchEditorService),n.__metadata("design:type",l.WorkbenchEditorService)],m.prototype,"workbenchEditorService",void 0),n.__decorate([(0,r.Autowired)(o.AppConfig),n.__metadata("design:type",Object)],m.prototype,"appConfig",void 0),n.__decorate([(0,r.Autowired)(o.IApplicationService),n.__metadata("design:type",Object)],m.prototype,"applicationService",void 0),n.__decorate([(0,r.Autowired)(v.BaseApplyService),n.__metadata("design:type",v.BaseApplyService)],m.prototype,"baseApplyService",void 0),n.__decorate([(0,r.Autowired)(o.PreferenceService),n.__metadata("design:type",Object)],m.prototype,"preferenceService",void 0),t.ChatEditSchemeDocumentProvider=m=n.__decorate([(0,r.Injectable)()],m)},61282:(P,t,e)=>{"use strict";var n,r;Object.defineProperty(t,"__esModule",{value:!0}),t.ChatManagerService=void 0;const o=e(85608),l=e(76003),_=e(41869),v=e(43718),m=e(65677),p=e(19413),s=e(44260),g=e(42033),a=e(11735),h=20;class u extends v.LRUCache{disposeKey(f){const d=this.get(f);d&&d.dispose(),this.delete(f)}dispose(){this.forEach(f=>{f.dispose()}),this.clear()}}let c=class extends v.Disposable{fromJSON(f){return f.filter(d=>d.history.messages.length>0).map(d=>{const y=new g.ChatModel(this.chatFeatureRegistry,{sessionId:d.sessionId,history:new s.MsgHistoryManager(this.chatFeatureRegistry,d.history),modelId:d.modelId}),b=d.requests.map(A=>new g.ChatRequestModel(A.requestId,y,A.message,new g.ChatResponseModel(A.requestId,y,A.message.agentId,{responseContents:A.response.responseContents,isComplete:!0,responseText:A.response.responseText,responseParts:A.response.responseParts,errorDetails:A.response.errorDetails,followups:A.response.followups,isCanceled:A.response.isCanceled})));return y.restoreRequests(b),y})}constructor(){super(),n.set(this,this.registerDispose(new u(h))),r.set(this,this.registerDispose(new v.DisposableMap)),this.storageInitEmitter=new v.Emitter,this.onStorageInit=this.storageInitEmitter.event}async init(){this._chatStorage=await this.storageProvider(v.STORAGE_NAMESPACE.CHAT);const f=this._chatStorage.get("sessionModels",[]);this.fromJSON(f).forEach(y=>{o.__classPrivateFieldGet(this,n,"f").set(y.sessionId,y),this.listenSession(y)}),await this.storageInitEmitter.fireAndAwait()}getSessions(){return Array.from(o.__classPrivateFieldGet(this,n,"f").values())}startSession(){const f=new g.ChatModel(this.chatFeatureRegistry);return o.__classPrivateFieldGet(this,n,"f").set(f.sessionId,f),this.listenSession(f),f}getSession(f){return o.__classPrivateFieldGet(this,n,"f").get(f)}clearSession(f){var d;if(!o.__classPrivateFieldGet(this,n,"f").get(f))throw new Error(`Unknown session: ${f}`);o.__classPrivateFieldGet(this,n,"f").disposeKey(f),(d=o.__classPrivateFieldGet(this,r,"f").get(f))===null||d===void 0||d.cancel(),o.__classPrivateFieldGet(this,r,"f").disposeKey(f),this.saveSessions()}createRequest(f,d,y,b,A){const S=this.getSession(f);if(!S)throw new Error(`Unknown session: ${f}`);if(!o.__classPrivateFieldGet(this,r,"f").has(f))return S.addRequest({prompt:d,agentId:y,command:b,images:A})}async sendRequest(f,d,y){const b=this.getSession(f);if(!b)throw new Error(`Unknown session: ${f}`);const A=b.modelId,S=this.preferenceService.get(v.AINativeSettingSectionsId.ModelID);if(!A)b.modelId=S;else if(A!==S)throw new Error("Model changed unexpectedly");const D=new v.CancellationTokenSource,I=D.token;o.__classPrivateFieldGet(this,r,"f").set(b.sessionId,D);const w=I.onCancellationRequested(()=>{d.response.cancel()}),T=this.preferenceService.get(v.AINativeSettingSectionsId.ContextWindow),R=b.getMessageHistory(T);try{const M=k=>{I.isCancellationRequested||b.acceptResponseProgress(d,k)},O={sessionId:f,requestId:d.requestId,message:d.message.prompt,command:d.message.command,images:d.message.images,regenerate:y},x=await this.chatAgentService.invokeAgent(d.message.agentId,O,M,R,I);I.isCancellationRequested||(x.errorDetails&&d.response.setErrorDetails(x.errorDetails),this.chatAgentService.getFollowups(d.message.agentId,f,v.CancellationToken.None).then(F=>{d.response.setFollowups(F),d.response.complete()}))}finally{w.dispose(),o.__classPrivateFieldGet(this,r,"f").disposeKey(b.sessionId),this.saveSessions()}}listenSession(f){this.addDispose(f.history.onMessageAdditionalChange(()=>{this.saveSessions()}))}saveSessions(){this._chatStorage.set("sessionModels",this.getSessions())}cancelRequest(f){var d;(d=o.__classPrivateFieldGet(this,r,"f").get(f))===null||d===void 0||d.cancel(),o.__classPrivateFieldGet(this,r,"f").disposeKey(f),this.saveSessions()}};t.ChatManagerService=c,n=new WeakMap,r=new WeakMap,o.__decorate([(0,l.Autowired)(l.INJECTOR_TOKEN),o.__metadata("design:type",l.Injector)],c.prototype,"injector",void 0),o.__decorate([(0,l.Autowired)(p.IChatAgentService),o.__metadata("design:type",Object)],c.prototype,"chatAgentService",void 0),o.__decorate([(0,l.Autowired)(v.StorageProvider),o.__metadata("design:type",Function)],c.prototype,"storageProvider",void 0),o.__decorate([(0,l.Autowired)(_.PreferenceService),o.__metadata("design:type",Object)],c.prototype,"preferenceService",void 0),o.__decorate([(0,l.Autowired)(m.ChatFeatureRegistryToken),o.__metadata("design:type",a.ChatFeatureRegistry)],c.prototype,"chatFeatureRegistry",void 0),o.__decorate([(0,v.debounce)(1e3),o.__metadata("design:type",Function),o.__metadata("design:paramtypes",[]),o.__metadata("design:returntype",void 0)],c.prototype,"saveSessions",null),t.ChatManagerService=c=o.__decorate([(0,l.Injectable)(),o.__metadata("design:paramtypes",[])],c)},42033:(P,t,e)=>{"use strict";var n,r,o,l,_,v,m,p,s,g,a,h,u,c,E,f,d;Object.defineProperty(t,"__esModule",{value:!0}),t.ChatSlashCommandItemModel=t.ChatWelcomeMessageModel=t.ChatModel=t.ChatRequestModel=t.ChatResponseModel=void 0;const y=e(85608),b=e(76003),A=e(43718),S=e(90684),D=e(19413),I=e(44260);class w extends A.Disposable{get responseParts(){return y.__classPrivateFieldGet(this,r,"f")}get responseContents(){return y.__classPrivateFieldGet(this,o,"f")}get isComplete(){return y.__classPrivateFieldGet(this,l,"f")}get isCanceled(){return y.__classPrivateFieldGet(this,_,"f")}get requestId(){return y.__classPrivateFieldGet(this,v,"f")}get responseText(){return y.__classPrivateFieldGet(this,m,"f")}get errorDetails(){return y.__classPrivateFieldGet(this,p,"f")}get followups(){return y.__classPrivateFieldGet(this,s,"f")}get onDidChange(){return y.__classPrivateFieldGet(this,g,"f").event}constructor(k,F,L,N){super(),n.add(this),this.session=F,this.agentId=L,r.set(this,[]),o.set(this,[]),l.set(this,!1),_.set(this,!1),v.set(this,void 0),m.set(this,""),p.set(this,void 0),s.set(this,void 0),g.set(this,this.registerDispose(new A.Emitter)),y.__classPrivateFieldSet(this,v,k,"f"),N&&(y.__classPrivateFieldSet(this,o,N.responseContents,"f"),y.__classPrivateFieldSet(this,r,N.responseParts||[],"f"),y.__classPrivateFieldSet(this,m,N.responseText,"f"),y.__classPrivateFieldSet(this,l,N.isComplete,"f"),y.__classPrivateFieldSet(this,_,N.isCanceled,"f"),y.__classPrivateFieldSet(this,p,N.errorDetails,"f"),y.__classPrivateFieldSet(this,s,N.followups,"f"))}updateContent(k,F){var L;const N=y.__classPrivateFieldGet(this,r,"f").length-1;if(k.kind==="content"||k.kind==="markdownContent"){const U=y.__classPrivateFieldGet(this,r,"f")[N];!U||U.kind!=="markdownContent"?k.kind==="content"?y.__classPrivateFieldGet(this,r,"f").push({content:new S.MarkdownString(k.content),kind:"markdownContent"}):y.__classPrivateFieldGet(this,r,"f").push(k):k.kind==="markdownContent"?y.__classPrivateFieldGet(this,r,"f")[N]={content:new S.MarkdownString(U.content.value+k.content.value),kind:"markdownContent"}:y.__classPrivateFieldGet(this,r,"f")[N]={content:new S.MarkdownString(U.content.value+k.content,U.content),kind:"markdownContent"},y.__classPrivateFieldGet(this,n,"m",a).call(this)}else if(k.kind==="reasoning"){const U=y.__classPrivateFieldGet(this,r,"f")[N];!U||U.kind!=="reasoning"?y.__classPrivateFieldGet(this,r,"f").push({content:k.content.replace(/^<think>/,""),kind:"reasoning"}):y.__classPrivateFieldGet(this,r,"f")[N]={content:U.content+k.content,kind:"reasoning"},y.__classPrivateFieldGet(this,n,"m",a).call(this)}else if(k.kind==="asyncContent"){const U=y.__classPrivateFieldGet(this,r,"f").push(k)-1;y.__classPrivateFieldGet(this,n,"m",a).call(this),(L=k.resolvedContent)===null||L===void 0||L.then(W=>{typeof W=="string"?y.__classPrivateFieldGet(this,r,"f")[U]={content:new S.MarkdownString(W),kind:"markdownContent"}:(0,S.isMarkdownString)(W)?y.__classPrivateFieldGet(this,r,"f")[U]={content:W,kind:"markdownContent"}:y.__classPrivateFieldGet(this,r,"f")[U]=W,y.__classPrivateFieldGet(this,n,"m",a).call(this,F)})}else if(k.kind==="treeData"||k.kind==="component")y.__classPrivateFieldGet(this,r,"f").push(k),y.__classPrivateFieldGet(this,n,"m",a).call(this,F);else if(k.kind==="toolCall"){const U=y.__classPrivateFieldGet(this,r,"f").findIndex(W=>W.kind==="toolCall"&&W.content.id===k.content.id);U!==-1?y.__classPrivateFieldGet(this,r,"f")[U]={kind:"toolCall",content:{...k.content}}:y.__classPrivateFieldGet(this,r,"f").push(k),y.__classPrivateFieldGet(this,n,"m",a).call(this,F)}}complete(){y.__classPrivateFieldSet(this,l,!0,"f"),y.__classPrivateFieldGet(this,g,"f").fire()}cancel(){y.__classPrivateFieldSet(this,l,!0,"f"),y.__classPrivateFieldSet(this,_,!0,"f"),y.__classPrivateFieldGet(this,g,"f").fire()}reset(){y.__classPrivateFieldSet(this,o,[],"f"),y.__classPrivateFieldSet(this,r,[],"f"),y.__classPrivateFieldSet(this,m,"","f"),y.__classPrivateFieldSet(this,_,!1,"f"),y.__classPrivateFieldSet(this,l,!1,"f"),y.__classPrivateFieldSet(this,p,void 0,"f"),y.__classPrivateFieldSet(this,s,void 0,"f"),y.__classPrivateFieldGet(this,g,"f").fire()}setErrorDetails(k){y.__classPrivateFieldSet(this,p,k,"f"),y.__classPrivateFieldGet(this,g,"f").fire()}setFollowups(k){y.__classPrivateFieldSet(this,s,k,"f"),y.__classPrivateFieldGet(this,g,"f").fire()}toJSON(){return{isCanceled:this.isCanceled,responseContents:this.responseContents,responseText:this.responseText,responseParts:this.responseParts,errorDetails:this.errorDetails,followups:this.followups}}}t.ChatResponseModel=w,r=new WeakMap,o=new WeakMap,l=new WeakMap,_=new WeakMap,v=new WeakMap,m=new WeakMap,p=new WeakMap,s=new WeakMap,g=new WeakMap,n=new WeakSet,a=function(k){y.__classPrivateFieldSet(this,m,y.__classPrivateFieldGet(this,r,"f").map(L=>L.kind==="asyncContent"?L.content:L.kind==="treeData"||L.kind==="component"?"":L.kind==="toolCall"?L.content.function.name:L.kind==="reasoning"?"":L.content.value).join(`
32953
+ `,{...await this.chatProxyService.getRequestOptions(),trimTexts:["<updated-code>","</updated-code>"],system:"You are a coding assistant that helps merge code updates, ensuring every modification is fully integrated."})}}};t.ApplyService=h,n.__decorate([(0,r.Autowired)(l.CommandService),n.__metadata("design:type",Object)],h.prototype,"commandService",void 0),n.__decorate([(0,r.Autowired)(_.IEditorDocumentModelService),n.__metadata("design:type",Object)],h.prototype,"modelService",void 0),n.__decorate([(0,r.Autowired)(o.AIBackSerivcePath),n.__metadata("design:type",Object)],h.prototype,"aiBackService",void 0),n.__decorate([(0,r.Autowired)(p.ChatProxyServiceToken),n.__metadata("design:type",g.ChatProxyService)],h.prototype,"chatProxyService",void 0),t.ApplyService=h=n.__decorate([(0,r.Injectable)()],h)},74055:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatAgentService=void 0;const n=e(85608),r=n.__importDefault(e(66652)),o=e(76003),l=e(43718),_=e(46044),v=e(73307),m=e(29770);let p=class extends l.Disposable{constructor(){super(),this.agents=new Map,this.initialUserMessageMap=new Map,this.shouldUpdateContext=!1,this._onDidChangeAgents=new l.Emitter,this.onDidChangeAgents=this._onDidChangeAgents.event,this._onDidSendMessage=new l.Emitter,this.onDidSendMessage=this._onDidSendMessage.event,this.addDispose(this._onDidChangeAgents),this.addDispose(this.llmContextService.onDidContextFilesChangeEvent(g=>{g.version!==this.contextVersion&&(this.contextVersion=g.version,this.shouldUpdateContext=!0)}))}registerAgent(g){if(this.agents.has(g.id))throw new Error(`Already registered an agent with id ${g.id}`);return this.agents.set(g.id,{agent:g,commands:[]}),this._onDidChangeAgents.fire(),(0,l.toDisposable)(()=>{this.agents.delete(g.id)&&this._onDidChangeAgents.fire()})}async updateAgent(g,a){const h=this.agents.get(g);if(!h)throw new Error(`No agent with id ${g} registered`);h.agent.metadata={...h.agent.metadata,...a},h.commands=await h.agent.provideSlashCommands(l.CancellationToken.None),a.isDefault&&(this.defaultAgentId=g);const u=await h.agent.provideChatWelcomeMessage(l.CancellationToken.None);if(u){const{content:c,sampleQuestions:E}=u;this.chatFeatureRegistry.registerWelcome(c,E)}this._onDidChangeAgents.fire()}getAgents(){return Array.from(this.agents.values(),g=>g.agent)}hasAgent(g){return this.agents.has(g)}getDefaultAgentId(){return this.defaultAgentId}getAgent(g){const a=this.agents.get(g);return a?.agent}async invokeAgent(g,a,h,u,c){const E=this.agents.get(g);if(!E)throw new Error(`No agent with id ${g}`);if(this.initialUserMessageMap.has(a.sessionId))(this.shouldUpdateContext||a.regenerate||u.length===0)&&(a.message=await this.provideContextMessage(a.message,a.sessionId),this.shouldUpdateContext=!1);else{this.initialUserMessageMap.set(a.sessionId,a.message);const d=a.message;a.message=await this.provideContextMessage(d,a.sessionId)}return await E.agent.invoke(a,h,u,c)}async provideContextMessage(g,a){const h=await this.llmContextService.serialize(),u=await this.promptProvider.provideContextPrompt(h,g);return this.aiReporter.send({msgType:l.AIServiceType.Chat,actionType:l.ActionTypeEnum.ContextEnhance,actionSource:l.ActionSourceEnum.Chat,sessionId:a,message:u}),u}populateChatInput(g,a){this.aiChatService.sendMessage({...a,agentId:g,immediate:!1})}getCommands(){return(0,r.default)(Array.from(this.agents.values(),({agent:g,commands:a})=>a.map(h=>({...h,agentId:g.id}))))}async getFollowups(g,a,h){const u=this.agents.get(g);if(!u)throw new Error(`No agent with id ${g}`);return u.agent.provideFollowups?u.agent.provideFollowups(a,h):[]}async getSampleQuestions(g,a){const h=this.agents.get(g);if(!h)throw new Error(`No agent with id ${g}`);return h.agent.provideSampleQuestions?h.agent.provideSampleQuestions(a):[]}async getAllSampleQuestions(){const g=await Promise.all(Array.from(this.agents.values()).map(async({agent:a})=>{try{return await this.getSampleQuestions(a.id,l.CancellationToken.None)}catch(h){return this.logger.error(h),[]}}));return(0,r.default)(g)}sendMessage(g){this._onDidSendMessage.fire(g)}parseMessage(g,a){var h;const u={agentId:"",command:"",message:g};let c=a;const E=this.getAgents(),f=new RegExp(`^@(${E.map(y=>y.id).join("|")})(?:\\s+|$)`,"i"),d=u.message.match(f);if(d){const y=E.find(b=>b.id.toLowerCase()===d[1].toLowerCase());if(!y)return u;c=y.id,u.agentId=c,u.message=u.message.replace(d[0],"")}if(c){const y=(h=this.agents.get(c))===null||h===void 0?void 0:h.commands;if(y?.length){const b=new RegExp(`^/\\s?(${y.map(S=>S.name).join("|")})(?:\\s+|$)`,"i"),A=u.message.match(b);if(A){const S=y.find(D=>D.name.toLowerCase()===A[1].toLowerCase());if(!S)return u;u.command=S.name,u.message=u.message.replace(A[0],"")}}}return u}};t.ChatAgentService=p,n.__decorate([(0,o.Autowired)(l.ILogger),n.__metadata("design:type",Object)],p.prototype,"logger",void 0),n.__decorate([(0,o.Autowired)(l.IAIReporter),n.__metadata("design:type",Object)],p.prototype,"aiReporter",void 0),n.__decorate([(0,o.Autowired)(_.LLMContextServiceToken),n.__metadata("design:type",Object)],p.prototype,"llmContextService",void 0),n.__decorate([(0,o.Autowired)(v.ChatAgentPromptProvider),n.__metadata("design:type",Object)],p.prototype,"promptProvider",void 0),n.__decorate([(0,o.Autowired)(l.ChatServiceToken),n.__metadata("design:type",m.ChatService)],p.prototype,"aiChatService",void 0),n.__decorate([(0,o.Autowired)(l.ChatFeatureRegistryToken),n.__metadata("design:type",Object)],p.prototype,"chatFeatureRegistry",void 0),t.ChatAgentService=p=n.__decorate([(0,o.Injectable)(),n.__metadata("design:paramtypes",[])],p)},84543:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatAgentViewService=void 0;const n=e(85608),r=e(76003),o=e(43718),l=e(19413),_=e(51081);let v=class{constructor(){this.componentsMap=new Map,this.componentsDeferredMap=new Map}registerChatComponent(p){return this.componentsMap.set(p.id,p),this.componentsDeferredMap.has(p.id)&&(this.componentsDeferredMap.get(p.id).resolve(p),this.componentsDeferredMap.delete(p.id)),{dispose:()=>{this.componentsMap.get(p.id)===p&&(this.componentsMap.delete(p.id),this.componentsDeferredMap.delete(p.id))}}}getChatComponent(p){return this.componentsMap.has(p)?this.componentsMap.get(p):(this.componentsDeferredMap.has(p)||this.componentsDeferredMap.set(p,new o.Deferred),null)}getChatComponentDeferred(p){return this.componentsDeferredMap.get(p)||null}getRenderAgents(){return this.chatAgentService.getAgents().filter(p=>p.id!==_.ChatProxyService.AGENT_ID)}};t.ChatAgentViewService=v,n.__decorate([(0,r.Autowired)(l.IChatAgentService),n.__metadata("design:type",Object)],v.prototype,"chatAgentService",void 0),t.ChatAgentViewService=v=n.__decorate([(0,r.Injectable)()],v)},98987:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatEditSchemeDocumentProvider=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(54414),_=e(96689),v=e(73974);let m=class{constructor(){this._onDidChangeContent=new o.Emitter,this.onDidChangeContent=this._onDidChangeContent.event}handlesScheme(s){return s===v.BaseApplyService.CHAT_EDITING_SOURCE_RESOLVER_SCHEME}async provideEditorDocumentModelContent(s,g){const{id:a,side:h}=s.getParsedQuery(),u=this.baseApplyService.getSessionCodeBlocks(),c=u?.find(f=>f.toolCallId===a);return(h==="left"?c?.originalCode:c?.updatedCode)||""}isReadonly(s){return!0}onDidDisposeModel(){}};t.ChatEditSchemeDocumentProvider=m,n.__decorate([(0,r.Autowired)(_.IEditorDocumentModelService),n.__metadata("design:type",Object)],m.prototype,"editorDocumentModelService",void 0),n.__decorate([(0,r.Autowired)(l.WorkbenchEditorService),n.__metadata("design:type",l.WorkbenchEditorService)],m.prototype,"workbenchEditorService",void 0),n.__decorate([(0,r.Autowired)(o.AppConfig),n.__metadata("design:type",Object)],m.prototype,"appConfig",void 0),n.__decorate([(0,r.Autowired)(o.IApplicationService),n.__metadata("design:type",Object)],m.prototype,"applicationService",void 0),n.__decorate([(0,r.Autowired)(v.BaseApplyService),n.__metadata("design:type",v.BaseApplyService)],m.prototype,"baseApplyService",void 0),n.__decorate([(0,r.Autowired)(o.PreferenceService),n.__metadata("design:type",Object)],m.prototype,"preferenceService",void 0),t.ChatEditSchemeDocumentProvider=m=n.__decorate([(0,r.Injectable)()],m)},61282:(P,t,e)=>{"use strict";var n,r;Object.defineProperty(t,"__esModule",{value:!0}),t.ChatManagerService=void 0;const o=e(85608),l=e(76003),_=e(41869),v=e(43718),m=e(65677),p=e(19413),s=e(44260),g=e(42033),a=e(11735),h=20;class u extends v.LRUCache{disposeKey(f){const d=this.get(f);d&&d.dispose(),this.delete(f)}dispose(){this.forEach(f=>{f.dispose()}),this.clear()}}let c=class extends v.Disposable{fromJSON(f){return f.filter(d=>d.history.messages.length>0).map(d=>{const y=new g.ChatModel(this.chatFeatureRegistry,{sessionId:d.sessionId,history:new s.MsgHistoryManager(this.chatFeatureRegistry,d.history),modelId:d.modelId}),b=d.requests.map(A=>new g.ChatRequestModel(A.requestId,y,A.message,new g.ChatResponseModel(A.requestId,y,A.message.agentId,{responseContents:A.response.responseContents,isComplete:!0,responseText:A.response.responseText,responseParts:A.response.responseParts,errorDetails:A.response.errorDetails,followups:A.response.followups,isCanceled:A.response.isCanceled})));return y.restoreRequests(b),y})}constructor(){super(),n.set(this,this.registerDispose(new u(h))),r.set(this,this.registerDispose(new v.DisposableMap)),this.storageInitEmitter=new v.Emitter,this.onStorageInit=this.storageInitEmitter.event}async init(){this._chatStorage=await this.storageProvider(v.STORAGE_NAMESPACE.CHAT);const f=this._chatStorage.get("sessionModels",[]);this.fromJSON(f).forEach(y=>{o.__classPrivateFieldGet(this,n,"f").set(y.sessionId,y),this.listenSession(y)}),await this.storageInitEmitter.fireAndAwait()}getSessions(){return Array.from(o.__classPrivateFieldGet(this,n,"f").values())}startSession(){const f=new g.ChatModel(this.chatFeatureRegistry);return o.__classPrivateFieldGet(this,n,"f").set(f.sessionId,f),this.listenSession(f),f}getSession(f){return o.__classPrivateFieldGet(this,n,"f").get(f)}clearSession(f){var d;if(!o.__classPrivateFieldGet(this,n,"f").get(f))throw new Error(`Unknown session: ${f}`);o.__classPrivateFieldGet(this,n,"f").disposeKey(f),(d=o.__classPrivateFieldGet(this,r,"f").get(f))===null||d===void 0||d.cancel(),o.__classPrivateFieldGet(this,r,"f").disposeKey(f),this.saveSessions()}createRequest(f,d,y,b,A){const S=this.getSession(f);if(!S)throw new Error(`Unknown session: ${f}`);if(!o.__classPrivateFieldGet(this,r,"f").has(f))return S.addRequest({prompt:d,agentId:y,command:b,images:A})}async sendRequest(f,d,y){const b=this.getSession(f);if(!b)throw new Error(`Unknown session: ${f}`);const A=b.modelId,S=this.preferenceService.get(v.AINativeSettingSectionsId.ModelID);if(!A)b.modelId=S;else if(A!==S)throw new Error("Model changed unexpectedly");const D=new v.CancellationTokenSource,I=D.token;o.__classPrivateFieldGet(this,r,"f").set(b.sessionId,D);const w=I.onCancellationRequested(()=>{d.response.cancel()}),T=this.preferenceService.get(v.AINativeSettingSectionsId.ContextWindow),R=b.getMessageHistory(T);try{const M=k=>{I.isCancellationRequested||b.acceptResponseProgress(d,k)},O={sessionId:f,requestId:d.requestId,message:d.message.prompt,command:d.message.command,images:d.message.images,regenerate:y},x=await this.chatAgentService.invokeAgent(d.message.agentId,O,M,R,I);I.isCancellationRequested||(x.errorDetails&&d.response.setErrorDetails(x.errorDetails),this.chatAgentService.getFollowups(d.message.agentId,f,v.CancellationToken.None).then(F=>{d.response.setFollowups(F),d.response.complete()}))}finally{w.dispose(),o.__classPrivateFieldGet(this,r,"f").disposeKey(b.sessionId),this.saveSessions()}}listenSession(f){this.addDispose(f.history.onMessageAdditionalChange(()=>{this.saveSessions()}))}saveSessions(){this._chatStorage.set("sessionModels",this.getSessions())}cancelRequest(f){var d;(d=o.__classPrivateFieldGet(this,r,"f").get(f))===null||d===void 0||d.cancel(),o.__classPrivateFieldGet(this,r,"f").disposeKey(f),this.saveSessions()}};t.ChatManagerService=c,n=new WeakMap,r=new WeakMap,o.__decorate([(0,l.Autowired)(l.INJECTOR_TOKEN),o.__metadata("design:type",l.Injector)],c.prototype,"injector",void 0),o.__decorate([(0,l.Autowired)(p.IChatAgentService),o.__metadata("design:type",Object)],c.prototype,"chatAgentService",void 0),o.__decorate([(0,l.Autowired)(v.StorageProvider),o.__metadata("design:type",Function)],c.prototype,"storageProvider",void 0),o.__decorate([(0,l.Autowired)(_.PreferenceService),o.__metadata("design:type",Object)],c.prototype,"preferenceService",void 0),o.__decorate([(0,l.Autowired)(m.ChatFeatureRegistryToken),o.__metadata("design:type",a.ChatFeatureRegistry)],c.prototype,"chatFeatureRegistry",void 0),o.__decorate([(0,v.debounce)(1e3),o.__metadata("design:type",Function),o.__metadata("design:paramtypes",[]),o.__metadata("design:returntype",void 0)],c.prototype,"saveSessions",null),t.ChatManagerService=c=o.__decorate([(0,l.Injectable)(),o.__metadata("design:paramtypes",[])],c)},42033:(P,t,e)=>{"use strict";var n,r,o,l,_,v,m,p,s,g,a,h,u,c,E,f,d;Object.defineProperty(t,"__esModule",{value:!0}),t.ChatSlashCommandItemModel=t.ChatWelcomeMessageModel=t.ChatModel=t.ChatRequestModel=t.ChatResponseModel=void 0;const y=e(85608),b=e(76003),A=e(43718),S=e(90684),D=e(19413),I=e(44260);class w extends A.Disposable{get responseParts(){return y.__classPrivateFieldGet(this,r,"f")}get responseContents(){return y.__classPrivateFieldGet(this,o,"f")}get isComplete(){return y.__classPrivateFieldGet(this,l,"f")}get isCanceled(){return y.__classPrivateFieldGet(this,_,"f")}get requestId(){return y.__classPrivateFieldGet(this,v,"f")}get responseText(){return y.__classPrivateFieldGet(this,m,"f")}get errorDetails(){return y.__classPrivateFieldGet(this,p,"f")}get followups(){return y.__classPrivateFieldGet(this,s,"f")}get onDidChange(){return y.__classPrivateFieldGet(this,g,"f").event}constructor(k,F,L,N){super(),n.add(this),this.session=F,this.agentId=L,r.set(this,[]),o.set(this,[]),l.set(this,!1),_.set(this,!1),v.set(this,void 0),m.set(this,""),p.set(this,void 0),s.set(this,void 0),g.set(this,this.registerDispose(new A.Emitter)),y.__classPrivateFieldSet(this,v,k,"f"),N&&(y.__classPrivateFieldSet(this,o,N.responseContents,"f"),y.__classPrivateFieldSet(this,r,N.responseParts||[],"f"),y.__classPrivateFieldSet(this,m,N.responseText,"f"),y.__classPrivateFieldSet(this,l,N.isComplete,"f"),y.__classPrivateFieldSet(this,_,N.isCanceled,"f"),y.__classPrivateFieldSet(this,p,N.errorDetails,"f"),y.__classPrivateFieldSet(this,s,N.followups,"f"))}updateContent(k,F){var L;const N=y.__classPrivateFieldGet(this,r,"f").length-1;if(k.kind==="content"||k.kind==="markdownContent"){const U=y.__classPrivateFieldGet(this,r,"f")[N];!U||U.kind!=="markdownContent"?k.kind==="content"?y.__classPrivateFieldGet(this,r,"f").push({content:new S.MarkdownString(k.content),kind:"markdownContent"}):y.__classPrivateFieldGet(this,r,"f").push(k):k.kind==="markdownContent"?y.__classPrivateFieldGet(this,r,"f")[N]={content:new S.MarkdownString(U.content.value+k.content.value),kind:"markdownContent"}:y.__classPrivateFieldGet(this,r,"f")[N]={content:new S.MarkdownString(U.content.value+k.content,U.content),kind:"markdownContent"},y.__classPrivateFieldGet(this,n,"m",a).call(this)}else if(k.kind==="reasoning"){const U=y.__classPrivateFieldGet(this,r,"f")[N];!U||U.kind!=="reasoning"?y.__classPrivateFieldGet(this,r,"f").push({content:k.content.replace(/^<think>/,""),kind:"reasoning"}):y.__classPrivateFieldGet(this,r,"f")[N]={content:U.content+k.content,kind:"reasoning"},y.__classPrivateFieldGet(this,n,"m",a).call(this)}else if(k.kind==="asyncContent"){const U=y.__classPrivateFieldGet(this,r,"f").push(k)-1;y.__classPrivateFieldGet(this,n,"m",a).call(this),(L=k.resolvedContent)===null||L===void 0||L.then(W=>{typeof W=="string"?y.__classPrivateFieldGet(this,r,"f")[U]={content:new S.MarkdownString(W),kind:"markdownContent"}:(0,S.isMarkdownString)(W)?y.__classPrivateFieldGet(this,r,"f")[U]={content:W,kind:"markdownContent"}:y.__classPrivateFieldGet(this,r,"f")[U]=W,y.__classPrivateFieldGet(this,n,"m",a).call(this,F)})}else if(k.kind==="treeData"||k.kind==="component")y.__classPrivateFieldGet(this,r,"f").push(k),y.__classPrivateFieldGet(this,n,"m",a).call(this,F);else if(k.kind==="toolCall"){const U=y.__classPrivateFieldGet(this,r,"f").findIndex(W=>W.kind==="toolCall"&&W.content.id===k.content.id);U!==-1?y.__classPrivateFieldGet(this,r,"f")[U]={kind:"toolCall",content:{...k.content}}:y.__classPrivateFieldGet(this,r,"f").push(k),y.__classPrivateFieldGet(this,n,"m",a).call(this,F)}}complete(){y.__classPrivateFieldSet(this,l,!0,"f"),y.__classPrivateFieldGet(this,g,"f").fire()}cancel(){y.__classPrivateFieldSet(this,l,!0,"f"),y.__classPrivateFieldSet(this,_,!0,"f"),y.__classPrivateFieldGet(this,g,"f").fire()}reset(){y.__classPrivateFieldSet(this,o,[],"f"),y.__classPrivateFieldSet(this,r,[],"f"),y.__classPrivateFieldSet(this,m,"","f"),y.__classPrivateFieldSet(this,_,!1,"f"),y.__classPrivateFieldSet(this,l,!1,"f"),y.__classPrivateFieldSet(this,p,void 0,"f"),y.__classPrivateFieldSet(this,s,void 0,"f"),y.__classPrivateFieldGet(this,g,"f").fire()}setErrorDetails(k){y.__classPrivateFieldSet(this,p,k,"f"),y.__classPrivateFieldGet(this,g,"f").fire()}setFollowups(k){y.__classPrivateFieldSet(this,s,k,"f"),y.__classPrivateFieldGet(this,g,"f").fire()}toJSON(){return{isCanceled:this.isCanceled,responseContents:this.responseContents,responseText:this.responseText,responseParts:this.responseParts,errorDetails:this.errorDetails,followups:this.followups}}}t.ChatResponseModel=w,r=new WeakMap,o=new WeakMap,l=new WeakMap,_=new WeakMap,v=new WeakMap,m=new WeakMap,p=new WeakMap,s=new WeakMap,g=new WeakMap,n=new WeakSet,a=function(k){y.__classPrivateFieldSet(this,m,y.__classPrivateFieldGet(this,r,"f").map(L=>L.kind==="asyncContent"?L.content:L.kind==="treeData"||L.kind==="component"?"":L.kind==="toolCall"?L.content.function.name:L.kind==="reasoning"?"":L.content.value).join(`
32954
32954
 
32955
32955
  `),"f");const F=[];for(const L of y.__classPrivateFieldGet(this,r,"f")){const N=F[F.length-1];L.kind==="markdownContent"&&N?.kind==="markdownContent"?F[F.length-1]={content:new S.MarkdownString(N.content.value+L.content.value,{isTrusted:N.content.isTrusted}),kind:"markdownContent"}:F.push(L)}y.__classPrivateFieldSet(this,o,F,"f"),k||y.__classPrivateFieldGet(this,g,"f").fire()};class T{get requestId(){return y.__classPrivateFieldGet(this,h,"f")}constructor(k,F,L,N){this.session=F,this.message=L,this.response=N,h.set(this,void 0),y.__classPrivateFieldSet(this,h,k,"f")}toJSON(){return{requestId:this.requestId,message:this.message,response:this.response}}}t.ChatRequestModel=T,h=new WeakMap;class R extends A.Disposable{constructor(k,F){var L,N;super(),this.chatFeatureRegistry=k,this.requestIdPool=0,u.set(this,void 0),c.set(this,new Map),E.set(this,0),f.set(this,void 0),y.__classPrivateFieldSet(this,u,(L=F?.sessionId)!==null&&L!==void 0?L:(0,A.uuid)(),"f"),this.history=(N=F?.history)!==null&&N!==void 0?N:new I.MsgHistoryManager(this.chatFeatureRegistry),y.__classPrivateFieldSet(this,f,F?.modelId,"f")}get sessionId(){return y.__classPrivateFieldGet(this,u,"f")}get requests(){return Array.from(y.__classPrivateFieldGet(this,c,"f").values())}restoreRequests(k){y.__classPrivateFieldSet(this,c,new Map(k.map(F=>[F.requestId,F])),"f"),this.requestIdPool=k.length}get slicedMessageCount(){return y.__classPrivateFieldGet(this,E,"f")}get modelId(){return y.__classPrivateFieldGet(this,f,"f")}set modelId(k){y.__classPrivateFieldSet(this,f,k,"f")}processMemorySummaries(){const k=this.history.getMemorySummaries();if(k.length===0)return[];const F=k.map(L=>{try{const N=JSON.parse(L.content);return N.memory||N.content||L.content}catch{return L.content}}).filter(L=>L&&L!=="no_memory_needed").filter((L,N,U)=>U.indexOf(L)===N);return F.length>0?[{role:"system",content:`\u4EE5\u4E0B\u662F\u4E4B\u524D\u5BF9\u8BDD\u7684\u603B\u7ED3\uFF1A
32956
32956
  `+F.join(`
32957
32957
 
32958
- `)}]:[]}processToolCall(k,F){F[F.length-1].role!=="assistant"&&F.push({role:"assistant",content:[]});const L=k.content.id,N={id:L,name:k.content.function.name,args:this.parseJsonSafely(k.content.function.arguments||"{}","tool call arguments"),result:this.parseJsonSafely(k.content.result||"{}","tool result")};this.history.addToolCall(N),this.history.setMessageAdditional(k.content.id,{toolCallId:L});const U=F[F.length-1];U.content=[{type:"tool-call",toolCallId:k.content.id,toolName:k.content.function.name,args:N.args}],F.push({role:"tool",content:[{type:"tool-result",toolCallId:k.content.id,toolName:k.content.function.name,result:N.result}]})}parseJsonSafely(k,F){try{return JSON.parse(k)}catch(L){return console.error(`[ChatModel] Failed to parse ${F}:`,L),{}}}processRecentMessages(){const k=[],F=this.history.getMessages().filter(L=>!L.isSummarized).slice(-this.history.memoryConfig.shortTermSize);for(const L of F){k.push({role:"user",content:L.content});const N=this.history.getMessageAdditional(L.id);if(N?.response){const U=N.response;U.kind==="toolCall"?this.processToolCall(U,k):k.push({role:"assistant",content:U.kind==="markdownContent"?U.content.value:U.content})}}return k}limitTokens(k,F){if(!F)return k;let L=k,N=JSON.stringify(L).length/3;for(;N>F&&L.length>1;)L[0].role==="system"&&L.length>2?L=[L[0],...L.slice(2)]:L=L.slice(1),N=JSON.stringify(L).length/3;return L}getMessageHistory(k){const F=this.processMemorySummaries(),L=this.processRecentMessages(),N=[...F,...L];return this.limitTokens(N,k)}addRequest(k){const F=k,L=`${this.sessionId}_request_${this.requestIdPool++}`,N=new w(L,this,F.agentId),U=new T(L,this,F,N);return y.__classPrivateFieldGet(this,c,"f").set(L,U),U}acceptResponseProgress(k,F,L){if(k.response.isComplete)throw new Error("acceptResponseProgress: Adding progress to a completed response");const{kind:N}=F;["content","markdownContent","asyncContent","treeData","component","toolCall","reasoning"].includes(N)?k.response.updateContent(F,L):console.error(`Couldn't handle progress: ${JSON.stringify(F)}`)}getRequest(k){return y.__classPrivateFieldGet(this,c,"f").get(k)}dispose(){super.dispose(),y.__classPrivateFieldGet(this,c,"f").forEach(k=>k.response.dispose())}toJSON(){return{sessionId:this.sessionId,modelId:this.modelId,history:this.history,requests:this.requests}}}t.ChatModel=R,u=new WeakMap,c=new WeakMap,E=new WeakMap,f=new WeakMap;let M=d=class extends A.Disposable{get id(){return this._id}constructor(k,F){super(),this.content=k,this.sampleQuestions=F,this._id="welcome_"+d.nextId++}};t.ChatWelcomeMessageModel=M,M.nextId=0,t.ChatWelcomeMessageModel=M=d=y.__decorate([(0,b.Injectable)({multiple:!0}),y.__metadata("design:paramtypes",[Object,Array])],M);let O=class extends A.Disposable{constructor(k,F,L){super(),this.chatCommand=k,this.command=F,this.agentId=L}get name(){return this.chatCommand.name}get isShortcut(){return!!this.chatCommand.isShortcut}get icon(){return this.chatCommand.icon}get description(){return this.chatCommand.description}get tooltip(){return this.chatCommand.tooltip}get nameWithSlash(){return this.name.startsWith(D.SLASH_SYMBOL)?this.name:`${D.SLASH_SYMBOL} ${this.name}`}};t.ChatSlashCommandItemModel=O,t.ChatSlashCommandItemModel=O=y.__decorate([(0,b.Injectable)({multiple:!0}),y.__metadata("design:paramtypes",[Object,String,String])],O)},42995:(P,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ChatMultiDiffSource=t.ChatMultiDiffResolver=void 0;const r=e(85608),o=e(76003),l=e(41869),_=e(64335),v=e(73974);let m=n=class{canHandleUri(a){return a.scheme===n.CHAT_EDITING_MULTI_DIFF_SOURCE_RESOLVER_SCHEME}resolveDiffSource(a){return Promise.resolve(new s(this.baseApplyService,this.appConfig))}};t.ChatMultiDiffResolver=m,m.CHAT_EDITING_MULTI_DIFF_SOURCE_RESOLVER_SCHEME="chat-editing-multi-diff-source",r.__decorate([(0,o.Autowired)(v.BaseApplyService),r.__metadata("design:type",v.BaseApplyService)],m.prototype,"baseApplyService",void 0),r.__decorate([(0,o.Autowired)(l.AppConfig),r.__metadata("design:type",Object)],m.prototype,"appConfig",void 0),t.ChatMultiDiffResolver=m=n=r.__decorate([(0,o.Injectable)()],m);const p=(g,a,h)=>l.URI.from({scheme:v.BaseApplyService.CHAT_EDITING_SOURCE_RESOLVER_SCHEME,path:g,query:l.URI.stringifyQuery({id:a,side:h})});class s{constructor(a,h){this.baseApplyService=a,this.appConfig=h,this.resources=(()=>{const u=this.baseApplyService,c=this.appConfig;return{get value(){return u.getSessionCodeBlocks().filter(E=>E.status==="success"||E.status==="pending").reduce((E,f)=>{const d=E.find(y=>y.relativePath===f.relativePath);return d?(f.version<d.oldVersion&&(d.oldVersion=f.version,d.oldBlockId=f.toolCallId),f.version>d.newVersion&&(d.newVersion=f.version,d.newBlockId=f.toolCallId)):E.push({relativePath:f.relativePath,oldBlockId:f.toolCallId,newBlockId:f.toolCallId,oldVersion:f.version,newVersion:f.version}),E},[]).map(E=>{const f=l.path.join(c.workspaceDir,E.relativePath);return new _.MultiDiffEditorItem(p(f,E.oldBlockId,"left"),p(f,E.newBlockId,"right"),l.URI.file(f))})},onDidChange:this.baseApplyService.onCodeBlockUpdate}})()}}t.ChatMultiDiffSource=s},51081:(P,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ChatProxyService=void 0;const r=e(85608),o=e(76003),l=e(41869),_=e(43718),v=e(27284),m=e(9447),p=e(72665),s=e(93062),g=e(19413),a=e(85907),h=e(34817),u=e(33108),c=e(11735);let E=n=class extends _.Disposable{constructor(){super(...arguments),this.chatDeferred=new _.Deferred}async getRequestOptions(){const d=this.preferenceService.get(v.AINativeSettingSectionsId.LLMModelSelection),y=this.preferenceService.get(v.AINativeSettingSectionsId.ModelID);let b="",A="";d==="deepseek"?b=this.preferenceService.get(v.AINativeSettingSectionsId.DeepseekApiKey,""):d==="openai"?b=this.preferenceService.get(v.AINativeSettingSectionsId.OpenaiApiKey,""):d==="anthropic"?b=this.preferenceService.get(v.AINativeSettingSectionsId.AnthropicApiKey,""):(b=this.preferenceService.get(v.AINativeSettingSectionsId.OpenaiApiKey,""),A=this.preferenceService.get(v.AINativeSettingSectionsId.OpenaiBaseURL,""));const S=this.preferenceService.get(v.AINativeSettingSectionsId.MaxTokens),D=this.chatAgentService.getAgent(n.AGENT_ID),I=await this.mcpConfigService.getDisabledTools();return{clientId:this.applicationService.clientId,model:d,modelId:y,apiKey:b,baseURL:A,maxTokens:S,system:D?.metadata.systemPrompt,disabledTools:I}}registerDefaultAgent(){this.chatAgentViewService.registerChatComponent({id:"toolCall",component:h.ChatToolRender,initialProps:{}}),this.applicationService.getBackendOS().then(()=>{this.addDispose(this.chatAgentService.registerAgent({id:n.AGENT_ID,metadata:{systemPrompt:this.preferenceService.get(v.AINativeSettingSectionsId.SystemPrompt,a.DEFAULT_SYSTEM_PROMPT)},invoke:async(d,y,b,A)=>{this.chatDeferred=new _.Deferred;const{message:S,command:D}=d;let I=S;if(D){const T=this.chatFeatureRegistry.getSlashCommandHandler(D);if(T&&T.providerPrompt){const R=this.monacoCommandRegistry.getActiveCodeEditor();I=await T.providerPrompt(S,R)}}const w=await this.aiBackService.requestStream(I,{requestId:d.requestId,sessionId:d.sessionId,history:b,images:d.images,...await this.getRequestOptions()},A);return(0,s.listenReadable)(w,{onData:T=>{y(T)},onEnd:()=>{this.chatDeferred.resolve()},onError:T=>{this.messageService.error(T.message),this.aiReporter.end(d.sessionId+"_"+d.requestId,{message:T.message,success:!1,command:D})}}),await this.chatDeferred.promise,{}},provideSlashCommands:async()=>this.chatFeatureRegistry.getAllSlashCommand().map(d=>({...d,name:d.name,description:d.description||""})),provideChatWelcomeMessage:async()=>{}}))}),queueMicrotask(()=>{this.chatAgentService.updateAgent(n.AGENT_ID,{})})}};t.ChatProxyService=E,E.AGENT_ID="Default_Chat_Agent",r.__decorate([(0,o.Autowired)(g.IChatAgentService),r.__metadata("design:type",Object)],E.prototype,"chatAgentService",void 0),r.__decorate([(0,o.Autowired)(_.AIBackSerivcePath),r.__metadata("design:type",Object)],E.prototype,"aiBackService",void 0),r.__decorate([(0,o.Autowired)(_.ChatFeatureRegistryToken),r.__metadata("design:type",c.ChatFeatureRegistry)],E.prototype,"chatFeatureRegistry",void 0),r.__decorate([(0,o.Autowired)(m.MonacoCommandRegistry),r.__metadata("design:type",m.MonacoCommandRegistry)],E.prototype,"monacoCommandRegistry",void 0),r.__decorate([(0,o.Autowired)(_.IAIReporter),r.__metadata("design:type",Object)],E.prototype,"aiReporter",void 0),r.__decorate([(0,o.Autowired)(_.ChatAgentViewServiceToken),r.__metadata("design:type",Object)],E.prototype,"chatAgentViewService",void 0),r.__decorate([(0,o.Autowired)(l.PreferenceService),r.__metadata("design:type",Object)],E.prototype,"preferenceService",void 0),r.__decorate([(0,o.Autowired)(_.IApplicationService),r.__metadata("design:type",Object)],E.prototype,"applicationService",void 0),r.__decorate([(0,o.Autowired)(p.IMessageService),r.__metadata("design:type",Object)],E.prototype,"messageService",void 0),r.__decorate([(0,o.Autowired)(_.MCPConfigServiceToken),r.__metadata("design:type",u.MCPConfigService)],E.prototype,"mcpConfigService",void 0),t.ChatProxyService=E=n=r.__decorate([(0,o.Injectable)()],E)},29770:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatService=void 0;const n=e(85608),r=e(76003),o=e(43718),l=e(63067),_=e(19413),v=e(59347);let m=class extends o.Disposable{constructor(){super(),this._onChatMessageLaunch=new o.Emitter,this.onChatMessageLaunch=this._onChatMessageLaunch.event,this._onChatReplyMessageLaunch=new o.Emitter,this.onChatReplyMessageLaunch=this._onChatReplyMessageLaunch.event,this._onChatMessageListLaunch=new o.Emitter,this.onChatMessageListLaunch=this._onChatMessageListLaunch.event,this._onScrollToBottom=new o.Emitter,this.onScrollToBottom=this._onScrollToBottom.event}showChatView(){this.mainLayoutService.toggleSlot(_.AI_CHAT_VIEW_ID,!0)}sendMessage(s){this.showChatView(),this._onChatMessageLaunch.fire(s)}clearHistoryMessages(){var s;(s=this.chatInternalService.sessionModel)===null||s===void 0||s.history.clearMessages()}sendReplyMessage(s){typeof s=="string"?this._onChatReplyMessageLaunch.fire({kind:"content",content:s}):this._onChatReplyMessageLaunch.fire(s)}sendMessageList(s){this._onChatMessageListLaunch.fire(s)}scrollToBottom(){this._onScrollToBottom.fire()}};t.ChatService=m,n.__decorate([(0,r.Autowired)(_.IChatInternalService),n.__metadata("design:type",v.ChatInternalService)],m.prototype,"chatInternalService",void 0),n.__decorate([(0,r.Autowired)(l.IMainLayoutService),n.__metadata("design:type",Object)],m.prototype,"mainLayoutService",void 0),t.ChatService=m=n.__decorate([(0,r.Injectable)(),n.__metadata("design:paramtypes",[])],m)},11735:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatFeatureRegistry=void 0;const n=e(85608),r=e(76003),o=e(43718),l=e(19413),_=e(42033),v=e(51081);let m=class extends o.Disposable{constructor(){super(...arguments),this.logger=(0,o.getDebugLogger)(),this.slashCommandsMap=new Map,this.slashCommandsHandlerMap=new Map,this._onDidWelcomeMessageChange=new o.Emitter,this.onDidWelcomeMessageChange=this._onDidWelcomeMessageChange.event}registerImageUploadProvider(s){this.imageUploadProvider=s}getImageUploadProvider(){return this.imageUploadProvider}registerMessageSummaryProvider(s){this.messageSummaryProvider=s}getMessageSummaryProvider(){return this.messageSummaryProvider}dispose(){super.dispose(),this.slashCommandsMap.clear(),this.slashCommandsHandlerMap.clear()}registerWelcome(s,g){this.chatWelcomeMessageModel=new _.ChatWelcomeMessageModel(s,g),this._onDidWelcomeMessageChange.fire()}registerSlashCommand(s,g){const{name:a}=s;if(this.slashCommandsMap.has(a)){this.logger.warn(`ChatFeatureRegistry: commands name ${a} already exists`);return}this.slashCommandsMap.set(a,new _.ChatSlashCommandItemModel(s,a,v.ChatProxyService.AGENT_ID)),this.slashCommandsHandlerMap.set(a,g)}getSlashCommandHandler(s){return this.slashCommandsHandlerMap.get(s)}getSlashCommand(s){return this.slashCommandsMap.get(s)}getSlashCommandHandlerBySlashName(s){const g=this.getAllSlashCommand().find(a=>a.nameWithSlash===s);if(g)return this.getSlashCommandHandler(g.name)}getSlashCommandBySlashName(s){const g=this.getAllSlashCommand().find(a=>a.nameWithSlash===s);if(g)return this.getSlashCommand(g.name)}getAllSlashCommand(){return Array.from(this.slashCommandsMap.values())}getAllShortcutSlashCommand(){return this.getAllSlashCommand().filter(s=>s.isShortcut===!0)}parseSlashCommand(s){if(s.startsWith(l.SLASH_SYMBOL)){const g=this.getAllSlashCommand();for(const a of g){const{nameWithSlash:h}=a;if(s.startsWith(h))return{value:s.slice(h.length),nameWithSlash:h}}}return{value:s,nameWithSlash:""}}};t.ChatFeatureRegistry=m,t.ChatFeatureRegistry=m=n.__decorate([(0,r.Injectable)()],m)},59347:(P,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ChatInternalService=void 0;const r=e(85608),o=e(76003),l=e(41869),_=e(43718),v=e(19413),m=e(61282);let p=class extends _.Disposable{constructor(){super(...arguments),this._onChangeRequestId=new _.Emitter,this.onChangeRequestId=this._onChangeRequestId.event,this._onChangeSession=new _.Emitter,this.onChangeSession=this._onChangeSession.event,this._onCancelRequest=new _.Emitter,this.onCancelRequest=this._onCancelRequest.event,this._onWillClearSession=new _.Emitter,this.onWillClearSession=this._onWillClearSession.event,this._onRegenerateRequest=new _.Emitter,this.onRegenerateRequest=this._onRegenerateRequest.event,n.set(this,void 0)}get latestRequestId(){return this._latestRequestId}get sessionModel(){return r.__classPrivateFieldGet(this,n,"f")}init(){this.chatManagerService.onStorageInit(()=>{const g=this.chatManagerService.getSessions();g.length>0?this.activateSession(g[g.length-1].sessionId):this.createSessionModel()})}setLatestRequestId(g){this._latestRequestId=g,this._onChangeRequestId.fire(g)}createRequest(g,a,h,u){return this.chatManagerService.createRequest(r.__classPrivateFieldGet(this,n,"f").sessionId,g,a,u,h)}sendRequest(g,a=!1){const h=this.chatManagerService.sendRequest(r.__classPrivateFieldGet(this,n,"f").sessionId,g,a);return a&&this._onRegenerateRequest.fire(),h}cancelRequest(){this.chatManagerService.cancelRequest(r.__classPrivateFieldGet(this,n,"f").sessionId),this._onCancelRequest.fire()}createSessionModel(){r.__classPrivateFieldSet(this,n,this.chatManagerService.startSession(),"f"),this._onChangeSession.fire(r.__classPrivateFieldGet(this,n,"f").sessionId)}clearSessionModel(g){g=g||r.__classPrivateFieldGet(this,n,"f").sessionId,this._onWillClearSession.fire(g),this.chatManagerService.clearSession(g),g===r.__classPrivateFieldGet(this,n,"f").sessionId&&r.__classPrivateFieldSet(this,n,this.chatManagerService.startSession(),"f"),this._onChangeSession.fire(r.__classPrivateFieldGet(this,n,"f").sessionId)}getSessions(){return this.chatManagerService.getSessions()}getSession(g){return this.chatManagerService.getSession(g)}activateSession(g){const a=this.chatManagerService.getSession(g);if(!a)throw new Error(`There is no session with session id ${g}`);r.__classPrivateFieldSet(this,n,a,"f"),this._onChangeSession.fire(r.__classPrivateFieldGet(this,n,"f").sessionId)}dispose(){var g;(g=r.__classPrivateFieldGet(this,n,"f"))===null||g===void 0||g.dispose(),super.dispose()}};t.ChatInternalService=p,n=new WeakMap,r.__decorate([(0,o.Autowired)(_.AIBackSerivcePath),r.__metadata("design:type",Object)],p.prototype,"aiBackService",void 0),r.__decorate([(0,o.Autowired)(l.PreferenceService),r.__metadata("design:type",Object)],p.prototype,"preferenceService",void 0),r.__decorate([(0,o.Autowired)(v.IChatManagerService),r.__metadata("design:type",m.ChatManagerService)],p.prototype,"chatManagerService",void 0),t.ChatInternalService=p=r.__decorate([(0,o.Injectable)()],p)},70394:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatRenderRegistry=void 0;const n=e(85608),r=e(76003),o=e(43718);let l=class extends o.Disposable{registerWelcomeRender(v){this.chatWelcomeRender=v}registerAIRoleRender(v){this.chatAIRoleRender=v}registerUserRoleRender(v){this.chatUserRoleRender=v}registerThinkingRender(v){this.chatThinkingRender=v}registerInputRender(v){this.chatInputRender=v}registerThinkingResultRender(v){this.chatThinkingResultRender=v}registerChatViewHeaderRender(v){this.chatViewHeaderRender=v}};t.ChatRenderRegistry=l,t.ChatRenderRegistry=l=n.__decorate([(0,r.Injectable)()],l)},76154:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AIChatView=void 0,t.DefaultChatViewHeader=U;const n=e(85608),r=n.__importStar(e(14041)),o=e(68392),l=e(41869),_=e(81878),v=e(89195),m=e(43718),p=e(54414),s=e(63067),g=e(72665);e(41937);const a=e(51500),h=e(19413),u=e(46044),c=e(98864),E=e(87785),f=e(25834),d=n.__importDefault(e(90103)),y=e(57987),b=e(56474),A=e(49601),S=e(15016),D=e(29039),I=e(78048),w=e(86556),T=e(73974),R=e(77633),M=e(42033),O=e(51081),x=n.__importDefault(e(77256)),k="chat_scroll",F=100,L=W=>W.map(j=>{var Q;const $=((Q=j.applyResult)===null||Q===void 0?void 0:Q.diff.split(`
32959
- `).reduce(([Z,G],V)=>(V.startsWith("-")?Z+=1:V.startsWith("+")&&(G+=1),[Z,G]),[0,0]))||[0,0];return{path:j.relativePath,additions:$[1],deletions:$[0],status:j.status}}).reduce((j,Q)=>{const $=j.find(Z=>Z.path===Q.path);return $?($.additions+=Q.additions,$.deletions+=Q.deletions,$.status=Q.status):j.push(Q),j},[]),N=()=>{const W=(0,l.useInjectable)(h.IChatInternalService),j=(0,l.useInjectable)(m.ChatServiceToken),Q=(0,l.useInjectable)(m.IAIReporter),$=(0,l.useInjectable)(h.IChatAgentService),Z=(0,l.useInjectable)(m.ChatFeatureRegistryToken),G=(0,l.useInjectable)(m.ChatRenderRegistryToken),V=(0,l.useInjectable)(R.TokenMCPServerRegistry),H=(0,l.useInjectable)(l.AINativeConfigService),K=(0,l.useInjectable)(u.LLMContextServiceToken),Y=(0,l.useInjectable)(s.IMainLayoutService),X=W.sessionModel.history,re=r.useRef(null),oe=r.useRef(!0),he=r.useRef(null),me=(0,l.useInjectable)(p.WorkbenchEditorService),q=(0,l.useInjectable)(l.AppConfig),Ae=(0,l.useInjectable)(T.BaseApplyService),ge=(0,l.useInjectable)(l.LabelService),te=(0,l.useInjectable)(a.IWorkspaceService),fe=(0,l.useInjectable)(m.CommandService),[Oe,Me]=r.useState([]),[Pe,Be]=r.useState(W.sessionModel.modelId),[De,_e]=r.useState(L(Ae.getSessionCodeBlocks())),[Ne,Te]=r.useReducer((Re,Le)=>{switch(Le.type){case"add":return[...Re,...Le.payload||[]];case"clear":return[];case"init":return Array.isArray(Le.payload)?Le.payload:[];default:return Re}},[]),[We,pe]=r.useState(!1),[ie,le]=r.useState(""),[Se,ye]=r.useState(""),[Ue,Ye]=r.useState(""),[Ve,pt]=r.useState(null);r.useEffect(()=>{Be(W.sessionModel.modelId)},[We,W.sessionModel]),r.useEffect(()=>{const Re=new m.Disposable,Le=()=>{const ze=L(Ae.getSessionCodeBlocks());_e(ze)};return Re.addDispose(W.onChangeSession(Le)),Re.addDispose(Ae.onCodeBlockUpdate(Le)),()=>Re.dispose()},[]),r.useEffect(()=>{const Re=Z.getAllShortcutSlashCommand(),Le=$.onDidChangeAgents(()=>{const ze=$.getCommands().filter(St=>St.isShortcut).map(St=>new M.ChatSlashCommandItemModel({icon:"",name:`${St.name} `,description:St.description,isShortcut:St.isShortcut},St.name,St.agentId));Me(Re.concat(ze))});return Me(Re),()=>Le.dispose()},[Z,$]),(0,l.useUpdateOnEvent)(W.onChangeSession);const vt=r.useMemo(()=>G.chatInputRender?G.chatInputRender:H.capabilities.supportsMCP?A.ChatMentionInput:y.ChatInput,[G.chatInputRender]),xt=r.useMemo(()=>(0,I.createMessageByAI)({id:(0,m.uuid)(6),relationId:"",text:r.createElement(w.WelcomeMessage,null)}),[]),lt=r.useCallback(Re=>{Re.deltaY<0?oe.current=!1:oe.current=!0},[oe]);r.useEffect(()=>{if(re.current)return re.current.addEventListener("wheel",lt),()=>{var Re;(Re=re.current)===null||Re===void 0||Re.removeEventListener("wheel",lt)}},[oe]);const wt=r.useCallback(()=>{if(re&&re.current&&oe.current){const Re=re.current.lastElementChild;Re&&Re.scrollIntoView({behavior:"smooth",block:"end"}),re.current.scrollHeight>re.current.clientHeight&&re.current.classList.add(k)}},[re,oe]),at=r.useCallback(Re=>{Te(Re),requestAnimationFrame(()=>{wt()})},[Te,wt]);r.useEffect(()=>{at({type:"init",payload:[xt]})},[]),r.useEffect(()=>{const Re=new m.Disposable;return Re.addDispose(j.onScrollToBottom(()=>{requestAnimationFrame(()=>{})})),Re.addDispose(j.onChatMessageLaunch(async Le=>{var ze;if(Le.immediate!==!1){if(We)return;await ui(Le.message,Le.images,Le.agentId,Le.command)}else Le.agentId&&le(Le.agentId),Le.command&&Ye(Le.command),(ze=he?.current)===null||ze===void 0||ze.setInputValue(Le.message)})),Re.addDispose(j.onChatReplyMessageLaunch(Le=>{if(Le.kind==="content"){const ze=Q.start(m.AIServiceType.CustomReply,{message:Le.content,sessionId:W.sessionModel.sessionId});X.addAssistantMessage({content:Le.content,relationId:ze}),Ut({chunk:Le.content,relationId:ze})}else{const ze=Q.start(m.AIServiceType.CustomReply,{message:"component#"+Le.component,sessionId:W.sessionModel.sessionId});X.addAssistantMessage({componentId:Le.component,componentValue:Le.value,content:"",relationId:ze}),_n({chunk:Le,relationId:ze})}})),Re.addDispose(j.onChatMessageListLaunch(Le=>{const ze=[];Le.forEach(St=>{const{role:$t}=St,On=Q.start(m.AIServiceType.Chat,{message:"",sessionId:W.sessionModel.sessionId});if($t==="assistant"){const Bn=St;ze.push((0,I.createMessageByAI)({id:(0,m.uuid)(6),relationId:On,text:r.createElement(S.ChatNotify,{requestId:On,chunk:Bn})},x.default.chat_notify))}if($t==="user"){const{message:Bn}=St,di=O.ChatProxyService.AGENT_ID,li=G.chatUserRoleRender,Ni=di===O.ChatProxyService.AGENT_ID?"":di;ze.push((0,I.createMessageByUser)({id:(0,m.uuid)(6),relationId:On,text:li?r.createElement(li,{content:Bn,agentId:Ni}):r.createElement(f.CodeBlockWrapperInput,{relationId:On,text:Bn,agentId:Ni,command:Ue,labelService:ge,workspaceService:te,commandService:fe})},x.default.chat_message_code))}}),at({type:"add",payload:ze}),setTimeout(wt,0)})),()=>Re.dispose()},[j,G.chatAIRoleRender,X]),r.useEffect(()=>{const Re=new m.Disposable;return Re.addDispose($.onDidSendMessage(Le=>{const ze=Le,St=Q.start(m.AIServiceType.Agent,{message:""}),$t=(0,I.createMessageByAI)({id:(0,m.uuid)(6),relationId:St,text:r.createElement(S.ChatNotify,{requestId:W.latestRequestId,chunk:ze})},x.default.chat_notify);at({type:"add",payload:[$t]})})),Re.addDispose($.onDidChangeAgents(async()=>{const Le=$.getDefaultAgentId();ye(Le??"")})),()=>Re.dispose()},[$,X,W]);const tt=r.useCallback(async Re=>{const{userMessage:Le,relationId:ze,requestId:St,render:$t,startTime:On,command:Bn,agentId:di}=Re;X.addAssistantMessage({type:"component",content:""});const li=(0,I.createMessageByAI)({id:(0,m.uuid)(6),relationId:ze,className:x.default.chat_with_more_actions,text:r.createElement(D.SlashCustomRender,{userMessage:Le,startTime:On,relationId:ze,requestId:St,renderContent:$t,command:Bn,agentId:di})});at({type:"add",payload:[li]})},[re,X]),st=r.useCallback(async Re=>{const Le=G.chatUserRoleRender,{message:ze,images:St,agentId:$t,relationId:On,command:Bn}=Re,di=$t===O.ChatProxyService.AGENT_ID?"":$t,li=(0,I.createMessageByUser)({id:(0,m.uuid)(6),relationId:On,text:Le?r.createElement(Le,{content:ze,images:St,agentId:di,command:Bn}):r.createElement(f.CodeBlockWrapperInput,{labelService:ge,relationId:On,text:ze,images:St,agentId:di,command:Bn,workspaceService:te,commandService:fe})},x.default.chat_message_code);at({type:"add",payload:[li]})},[G,G.chatUserRoleRender,X,wt]),At=r.useCallback(async Re=>{const{message:Le,agentId:ze,request:St,relationId:$t,command:On,startTime:Bn,msgId:di}=Re,li=ze===O.ChatProxyService.AGENT_ID?"":ze;if(ze===O.ChatProxyService.AGENT_ID&&On){const In=Z.getSlashCommandHandler(On);if(In&&In.providerRender)return pe(!1),tt({userMessage:Le,render:In.providerRender,relationId:$t,requestId:St.requestId,startTime:Bn,agentId:ze,command:On})}const Ni=(0,I.createMessageByAI)({id:(0,m.uuid)(6),relationId:$t,className:x.default.chat_with_more_actions,text:r.createElement(S.ChatReply,{relationId:$t,request:St,startTime:Bn,agentId:li,command:On,onDidChange:()=>{wt()},history:X,onDone:()=>{pe(!1)},onRegenerate:()=>{St&&W.sendRequest(St,!0)},msgId:di})});at({type:"add",payload:[Ni]})},[G,X,wt]),Ut=r.useCallback(Re=>{const{chunk:Le,relationId:ze}=Re;let St=r.createElement(b.ChatMarkdown,{markdown:Le,fillInIncompleteTokens:!0,agentId:ie,command:Ue});if(G.chatAIRoleRender){const On=G.chatAIRoleRender;St=r.createElement(On,{content:Le})}const $t=(0,I.createMessageByAI)({id:(0,m.uuid)(6),relationId:ze,text:St,className:x.default.chat_with_more_actions});at({type:"add",payload:[$t]})},[G,X,wt]),_n=r.useCallback(Re=>{const{chunk:Le,relationId:ze}=Re,St=(0,I.createMessageByAI)({id:(0,m.uuid)(6),relationId:ze,text:r.createElement(S.ChatNotify,{requestId:ze,chunk:Le})},x.default.chat_notify);at({type:"add",payload:[St]})},[G,X,wt]),Ln=r.useCallback(async Re=>{const{message:Le,images:ze,agentId:St,command:$t,reportExtra:On}=Re,{actionType:Bn,actionSource:di}=On||{},li=W.createRequest(Le.replaceAll(u.LLM_CONTEXT_KEY_REGEX,""),St,ze,$t);if(!li)return;pe(!0),W.setLatestRequestId(li.requestId);const Ni=Date.now(),In=O.ChatProxyService.AGENT_ID===St?m.AIServiceType.Chat:m.AIServiceType.Agent,Cn=Q.start($t||In,{agentId:St,userMessage:Le,actionType:Bn,actionSource:di,sessionId:W.sessionModel.sessionId},600*1e3);X.addUserMessage({content:Le,images:ze||[],agentId:St,agentCommand:$t,relationId:Cn}),await st({relationId:Cn,message:Le,images:ze,command:$t,agentId:St}),W.sendRequest(li);const $n=X.addAssistantMessage({content:"",relationId:Cn,requestId:li.requestId,replyStartTime:Ni});V.activeMessageInfo={messageId:$n,sessionId:W.sessionModel.sessionId},await At({startTime:Ni,relationId:Cn,message:Le,agentId:St,command:$t,request:li,msgId:$n})},[G,G.chatUserRoleRender,X,wt,We]),ui=r.useCallback(async(Re,Le,ze,St)=>{var $t,On,Bn;const di={actionSource:m.ActionSourceEnum.Chat,actionType:m.ActionTypeEnum.Send};ze=ze||O.ChatProxyService.AGENT_ID;let li=Re;const Ni=/\{\{@file:(.*?)\}\}/g,In=Re.match(Ni);if(In)for(const Kn of In){const Xt=Kn.replace(/\{\{@file:(.*?)\}\}/,"$1"),Qe=new m.URI(Xt),_t=(($t=await te.asRelativePath(Qe))===null||$t===void 0?void 0:$t.path)||Qe.displayName;li=li.replace(Kn,`\`${u.LLM_CONTEXT_KEY.AttachedFile}${_t}\``)}const Cn=/\{\{@folder:(.*?)\}\}/g,$n=li.match(Cn);if($n)for(const Kn of $n){const Xt=Kn.replace(/\{\{@folder:(.*?)\}\}/,"$1"),Qe=new m.URI(Xt),_t=((On=await te.asRelativePath(Qe))===null||On===void 0?void 0:On.path)||Qe.displayName;li=li.replace(Kn,`\`${u.LLM_CONTEXT_KEY.AttachedFolder}${_t}\``)}const Si=/\{\{@code:(.*?)\}\}/g,Ui=li.match(Si);if(Ui)for(const Kn of Ui){const Xt=Kn.replace(/\{\{@code:(.*?)\}\}/,"$1"),[Qe,_t]=Xt.split(":");let mt=[0,0];if(_t){const[Gt,Kt]=_t.slice(1).split("-");mt=[parseInt(Gt,10),parseInt(Kt,10)]}const gt=new m.URI(Qe),nn=((Bn=await te.asRelativePath(gt))===null||Bn===void 0?void 0:Bn.path)||gt.displayName;li=li.replace(Kn,`\`${u.LLM_CONTEXT_KEY.AttachedFile}${nn}:L${mt[0]}-${mt[1]}\``)}const bi=/\{\{@rule:(.*?)\}\}/g,hn=li.match(bi);if(hn)for(const Kn of hn){const Xt=Kn.replace(/\{\{@rule:(.*?)\}\}/,"$1"),Qe=new m.URI(Xt);li=li.replace(Kn,`\`${u.LLM_CONTEXT_KEY.AttachedFile}${Qe.displayName}\``)}return Ln({message:li,images:Le,agentId:ze,command:St,reportExtra:di})},[Ln]),Rn=r.useCallback(()=>{W.clearSessionModel(),j.clearHistoryMessages(),ln()},[Ne]),ln=r.useCallback(()=>{var Re;(Re=re?.current)===null||Re===void 0||Re.classList.remove(k),at({type:"init",payload:[xt]})},[Ne]),Un=Re=>{We||(pt(Re.nameWithSlash),le(Re.agentId),Ye(Re.command))},rn=r.useCallback(()=>{Y.toggleSlot(h.AI_CHAT_VIEW_ID)},[Y]),ct=G.chatViewHeaderRender||U,$e=r.useCallback(async Re=>{for(const Le of X.getMessages()){if(Re.isCancellationRequested)return;if(Le.role===1)await st({relationId:Le.relationId,message:Le.content,agentId:Le.agentId,command:Le.agentCommand,images:Le.images});else if(Le.role===2&&Le.requestId){const ze=W.sessionModel.getRequest(Le.requestId);ze&&!ze.response.isComplete&&pe(!0),await At({msgId:Le.id,relationId:Le.relationId,message:Le.content,agentId:Le.agentId,command:Le.agentCommand,startTime:Le.replyStartTime,request:ze})}else Le.role===2&&Le.content?await Ut({relationId:Le.relationId,chunk:Le.content}):Le.role===2&&Le.componentId&&await _n({relationId:Le.relationId,chunk:{kind:"component",component:Le.componentId,value:Le.componentValue}})}},[At]);return r.useEffect(()=>{ln();const Re=new m.CancellationTokenSource;return pe(!1),$e(Re.token),()=>{Re.cancel()}},[W.sessionModel]),r.createElement("div",{id:x.default.ai_chat_view},r.createElement("div",{className:x.default.header_container},r.createElement(ct,{handleClear:Rn,handleCloseChatView:rn})),r.createElement("div",{className:x.default.body_container},r.createElement("div",{className:x.default.left_bar,id:"ai_chat_left_container"},r.createElement("div",{className:x.default.chat_container,ref:re},r.createElement(o.MessageList,{className:x.default.message_list,lockable:!0,toBottomHeight:"100%",dataSource:Ne})),W.sessionModel.slicedMessageCount?r.createElement("div",{className:x.default.chat_tips_text},r.createElement("div",{className:x.default.chat_tips_container},(0,m.formatLocalize)("aiNative.chat.ai.assistant.limit.message",W.sessionModel.slicedMessageCount))):null,r.createElement("div",{className:x.default.chat_input_wrap},r.createElement("div",{className:x.default.header_operate},r.createElement("div",{className:x.default.header_operate_left},Oe.map(Re=>r.createElement(_.Popover,{id:`ai-chat-shortcut-${Re.name}`,key:`ai-chat-shortcut-${Re.name}`,title:Re.tooltip||Re.name},r.createElement("div",{className:x.default.tag,onClick:()=>Un(Re)},Re.name))))),De.length>0&&r.createElement(E.FileListDisplay,{files:De,hideActions:We,onFileClick:Re=>{me.open(m.URI.file(m.path.join(q.workspaceDir,Re)))},onRejectAll:()=>{Ae.processAll("reject")},onAcceptAll:()=>{Ae.processAll("accept")}}),r.createElement(vt,{onSend:ui,disabled:We,enableOptions:!0,theme:Ve,setTheme:pt,agentId:ie,setAgentId:le,defaultAgentId:Se,command:Ue,setCommand:Ye,contextService:K,ref:he,disableModelSelector:Pe!==void 0||We,sessionModelId:Pe})))))};t.AIChatView=N;function U({handleClear:W,handleCloseChatView:j}){const Q=(0,l.useInjectable)(h.IChatInternalService),$=(0,l.useInjectable)(g.IMessageService),Z=(0,l.useInjectable)(m.ChatFeatureRegistryToken),[G,V]=r.useState([]),[H,K]=r.useState(""),Y=r.useCallback(()=>{if(Q.sessionModel.history.getMessages().length>0)try{Q.createSessionModel()}catch(me){$.error(me.message)}},[Q]),X=r.useCallback(me=>{Q.activateSession(me.id)},[Q]),re=r.useCallback(me=>{Q.clearSessionModel(me.id)},[Q]),oe=r.useCallback(async(me,q,Ae)=>{if(!Ae)return q;try{const ge=await Ae.getMessageSummary(me);return ge?ge.slice(0,F):q}catch{return q}},[]),he=r.useRef(0);return r.useEffect(()=>{const me=async()=>{const ge=Q.sessionModel.history.getMessages(),te=[...ge].find(Me=>Me.role===1),fe=te?(0,c.cleanAttachedTextWrapper)(te.content).slice(0,F):"";K(fe);const Oe=ge.map(Me=>({role:Me.role,content:Me.content}));if(Oe.length>2){const Me=Date.now();he.current=Me;const Pe=Z.getMessageSummaryProvider(),Be=await oe(Oe,fe,Pe);Me===he.current&&Be&&K(Be)}V(Q.getSessions().map(Me=>{const Be=Me.history.getMessages(),De=Be.length>0?(0,c.cleanAttachedTextWrapper)(Be[0].content).slice(0,F):"",_e=Be.length>0&&Be[Be.length-1].replyStartTime||0;return{id:Me.sessionId,title:De,updatedAt:_e,loading:!1}}))};me();const q=new m.DisposableCollection,Ae=new Set;return q.push(Q.onChangeSession(ge=>{me(),!Ae.has(ge)&&(Ae.add(ge),q.push(Q.sessionModel.history.onMessageChange(()=>{me()})))})),q.push(Q.sessionModel.history.onMessageChange(()=>{me()})),()=>{q.dispose()}},[Q]),r.createElement("div",{className:x.default.header},r.createElement(d.default,{className:x.default.chat_history,currentId:Q.sessionModel.sessionId,title:H||(0,m.localize)("aiNative.chat.ai.assistant.name"),historyList:G,onNewChat:Y,onHistoryItemSelect:X,onHistoryItemDelete:re,onHistoryItemChange:()=>{}}),r.createElement(_.Popover,{overlayClassName:x.default.popover_icon,id:"ai-chat-header-clear",title:(0,m.localize)("aiNative.operate.clear.title")},r.createElement(v.EnhanceIcon,{wrapperClassName:x.default.action_btn,className:(0,l.getIcon)("clear"),onClick:W,tabIndex:0,role:"button",ariaLabel:(0,m.localize)("aiNative.operate.clear.title")})),r.createElement(_.Popover,{overlayClassName:x.default.popover_icon,id:"ai-chat-header-close",position:_.PopoverPosition.left,title:(0,m.localize)("aiNative.operate.close.title")},r.createElement(v.EnhanceIcon,{wrapperClassName:x.default.action_btn,className:(0,l.getIcon)("window-close"),onClick:j,tabIndex:0,role:"button",ariaLabel:(0,m.localize)("aiNative.operate.close.title")})))}},21967:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ApplyStatus=void 0;const n=e(85608),r=n.__importDefault(e(14041)),o=e(97267),l=n.__importDefault(e(6960)),_=({status:v,error:m})=>{const p=()=>{switch(v){case"generating":return r.default.createElement(o.Loading,null);case"pending":return r.default.createElement(o.Popover,{title:"Pending",id:"edit-file-tool-status-pending"},r.default.createElement(o.Icon,{iconClass:"codicon codicon-circle-large"}));case"success":return r.default.createElement(o.Popover,{title:"Success",id:"edit-file-tool-status-success"},r.default.createElement(o.Icon,{iconClass:"codicon codicon-pass"}));case"failed":return r.default.createElement(o.Popover,{title:`(${m||"Unknown error"})`,id:"edit-file-tool-status-failed"},r.default.createElement(o.Icon,{iconClass:"codicon codicon-error"}));case"cancelled":return r.default.createElement(o.Popover,{title:"Cancelled",id:"edit-file-tool-status-cancelled"},r.default.createElement(o.Icon,{iconClass:"codicon codicon-circle-slash",style:{color:"var(--input-placeholderForeground)"}}));default:return null}};return r.default.createElement("span",{className:l.default.status},p())};t.ApplyStatus=_},87785:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FileListDisplay=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(97267),l=e(41869),_=e(54414),v=e(42995),m=e(21967),p=n.__importDefault(e(80919)),s=g=>{const{files:a,onFileClick:h,onRejectAll:u,onAcceptAll:c,hideActions:E}=g,[f,d]=(0,r.useState)(!0),y=(0,l.useInjectable)(_.WorkbenchEditorService),b=(0,l.useInjectable)(l.LabelService),A=(0,r.useMemo)(()=>a.map(R=>{const M=l.URI.parse(R.path),O=b.getIcon(M);return r.default.createElement("span",{className:O})}),[a]),S=a.length,D=a.reduce((R,M)=>({additions:R.additions+M.additions,deletions:R.deletions+M.deletions}),{additions:0,deletions:0}),I=()=>{d(!f)},w=R=>R?r.default.createElement("span",{className:p.default.viewChanges,onClick:M=>{M.stopPropagation(),y.open(l.URI.from({scheme:v.ChatMultiDiffResolver.CHAT_EDITING_MULTI_DIFF_SOURCE_RESOLVER_SCHEME,path:"chat-editing-multi-diff-source"}),{label:(0,l.localize)("aiNative.chat.view-changes")})}},r.default.createElement(o.Icon,{icon:"unorderedlist",size:"small"}),(0,l.localize)("aiNative.chat.view-changes")):null,T=(R,M)=>{const O=[];return R>0&&O.push(r.default.createElement("span",{key:"add",className:p.default.additions},"+",R)),M>0&&(O.length>0&&O.push(" "),O.push(r.default.createElement("span",{key:"del",className:p.default.deletions},"-",M))),O.length===0&&O.push(r.default.createElement("span",{key:"no-change",className:p.default.noChange},"No changes")),O};return r.default.createElement("div",{className:p.default.container},r.default.createElement("div",{className:p.default.header},r.default.createElement("span",{className:p.default.title},r.default.createElement("button",{className:p.default.toggleButton,onClick:I},f?r.default.createElement(o.Icon,{icon:"down"}):r.default.createElement(o.Icon,{icon:"right"})," Changed Files(",S,")"),T(D.additions,D.deletions),!E&&w(a.length)),!E&&a.some(R=>R.status==="pending")&&r.default.createElement("div",{className:p.default.actions},r.default.createElement(o.Button,{type:"link",size:"small",onClick:R=>{R.stopPropagation(),u()}},"Reject"),r.default.createElement(o.Button,{size:"small",onClick:R=>{R.stopPropagation(),c()}},"Accept"))),r.default.createElement("ul",{className:`${p.default.fileList} ${f?"":p.default.collapsed}`},a.map((R,M)=>r.default.createElement("li",{key:M,className:p.default.fileItem,onClick:()=>h(R.path)},r.default.createElement("span",{className:p.default.fileIcon},A[M]||"\u{1F4C4}"),r.default.createElement("div",{className:p.default.fileInfo},r.default.createElement("div",{className:p.default.filePath},R.path),r.default.createElement("div",{className:p.default.fileStats},T(R.additions,R.deletions)),r.default.createElement(m.ApplyStatus,{status:R.status}))))))};t.FileListDisplay=s},25834:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CodeBlockWrapperInput=t.CodeBlockWrapper=t.CodeEditorWithHighlight=void 0;const n=e(85608),r=n.__importDefault(e(56005)),o=n.__importDefault(e(97331)),l=n.__importStar(e(14041)),_=n.__importDefault(e(10580)),v=e(46541),m=e(41869),p=e(81878),s=e(89195),g=e(43718),a=e(30526),h=e(9447),u=e(52416),c=n.__importDefault(e(6960)),E=e(83933),f=e(44692);e(38191);const d=S=>{const{input:D,language:I,relationId:w,agentId:T,command:R,hideInsert:M}=S,O=l.default.useRef(null),x=(0,m.useInjectable)(h.MonacoCommandRegistry),k=(0,m.useInjectable)(m.IClipboardService),F=(0,m.useInjectable)(u.IThemeService),L=(0,m.useInjectable)(g.IAIReporter),[N,U]=(0,l.useState)(!1),W=(0,l.useMemo)(()=>(0,m.uuid)(12),[O,O.current]);(0,l.useEffect)(()=>{const Z=H=>{H.type==="dark"||H.type==="hcDark"?e.e(622).then(e.bind(e,51622)):(H.type==="light"||H.type==="hcLight")&&e.e(412).then(e.bind(e,50412))},G=F.onThemeChange(H=>{Z(H)}),V=F.getCurrentThemeSync();return Z(V),()=>G.dispose()},[]);const j=(0,l.useRef)((0,o.default)(()=>{var Z;if(O.current){const G=O.current,V=(Z=G?.el)===null||Z===void 0?void 0:Z.querySelector("code"),H=V?.children;if(H){const K=H[H.length-1];K&&(K.scrollIntoViewIfNeeded?K.scrollIntoViewIfNeeded():K.scrollIntoView(!1))}}},150,{leading:!0,trailing:!0})).current;(0,l.useEffect)(()=>(j(),()=>{j.cancel()}),[D,j]);const Q=(0,l.useCallback)(async()=>{U(!0),await k.writeText(D),L.end(w,{copy:!0,code:D,language:I,agentId:T,command:R,actionSource:g.ActionSourceEnum.Chat,actionType:g.ActionTypeEnum.ChatCopyCode}),(0,g.runWhenIdle)(()=>{U(!1)},1e3)},[k,D,w]),$=(0,l.useCallback)(()=>{const Z=x.getActiveCodeEditor();if(Z){const G=Z.getSelection();G&&((0,a.insertSnippetWithMonacoEditor)(Z,D,[G],{undoStopBefore:!1,undoStopAfter:!1}),L.end(w,{insert:!0,code:D,language:I,agentId:T,command:R,actionSource:g.ActionSourceEnum.Chat,actionType:g.ActionTypeEnum.ChatInsertCode}))}},[x]);return l.default.createElement("div",{className:c.default.monaco_wrapper},l.default.createElement("div",{className:c.default.action_toolbar},!M&&l.default.createElement(p.Popover,{id:`ai-chat-inser-${W}`,title:(0,g.localize)("aiNative.chat.code.insert")},l.default.createElement(s.EnhanceIcon,{className:(0,m.getIcon)("insert"),onClick:()=>$(),tabIndex:0,role:"button",ariaLabel:(0,g.localize)("aiNative.chat.code.insert")})),l.default.createElement(p.Popover,{id:`ai-chat-copy-${W}`,title:(0,g.localize)(N?"aiNative.chat.code.copy.success":"aiNative.chat.code.copy")},l.default.createElement(s.EnhanceIcon,{className:(0,m.getIcon)("copy"),onClick:()=>Q(),tabIndex:0,role:"button",ariaLabel:(0,g.localize)("aiNative.chat.code.copy")}))),l.default.createElement(_.default,{language:I,ref:O,className:c.default.highlight_editor},D))};t.CodeEditorWithHighlight=d;const y=({content:S="",relationId:D,renderText:I,agentId:w="",command:T="",labelService:R,commandService:M,workspaceService:O})=>{const x=/`([^`]+)`/g,k=/```([^]+?)```/g,F=/```([^]+)?/g,L=/<attached_file>(.*)/g,N=/<attached_folder>(.*)/g,U=(0,l.useCallback)(async($,Z)=>{const G=await O?.roots;let V;if(G)for(const H of G){V=new g.URI(H.uri).resolve($);try{await M?.executeCommand(m.FILE_COMMANDS.REVEAL_IN_EXPLORER.id,V),Z===f.MentionType.FILE&&await M?.executeCommand(m.EDITOR_COMMANDS.OPEN_RESOURCE.id,V);break}catch{continue}}},[M,O]),W=($,Z=!1,G)=>l.default.createElement("span",{className:c.default.attachment,key:G,onClick:()=>U($,Z?f.MentionType.FOLDER:f.MentionType.FILE)},l.default.createElement(p.Icon,{iconClass:Z?(0,m.getIcon)("folder"):R?.getIcon(new g.URI($||"file"))}),l.default.createElement("span",{className:c.default.attachment_text},$)),j=$=>{const Z=$.split(`
32958
+ `)}]:[]}processToolCall(k,F){F[F.length-1].role!=="assistant"&&F.push({role:"assistant",content:[]});const L=k.content.id,N={id:L,name:k.content.function.name,args:this.parseJsonSafely(k.content.function.arguments||"{}","tool call arguments"),result:this.parseJsonSafely(k.content.result||"{}","tool result")};this.history.addToolCall(N),this.history.setMessageAdditional(k.content.id,{toolCallId:L});const U=F[F.length-1];U.content=[{type:"tool-call",toolCallId:k.content.id,toolName:k.content.function.name,args:N.args}],F.push({role:"tool",content:[{type:"tool-result",toolCallId:k.content.id,toolName:k.content.function.name,result:N.result}]})}parseJsonSafely(k,F){try{return JSON.parse(k)}catch(L){return console.error(`[ChatModel] Failed to parse ${F}:`,L),{}}}processRecentMessages(){const k=[],F=this.history.getMessages().filter(L=>!L.isSummarized).slice(-this.history.memoryConfig.shortTermSize);for(const L of F){k.push({role:"user",content:L.content});const N=this.history.getMessageAdditional(L.id);if(N?.response){const U=N.response;U.kind==="toolCall"?this.processToolCall(U,k):k.push({role:"assistant",content:U.kind==="markdownContent"?U.content.value:U.content})}}return k}limitTokens(k,F){if(!F)return k;let L=k,N=JSON.stringify(L).length/3;for(;N>F&&L.length>1;)L[0].role==="system"&&L.length>2?L=[L[0],...L.slice(2)]:L=L.slice(1),N=JSON.stringify(L).length/3;return L}getMessageHistory(k){const F=this.processMemorySummaries(),L=this.processRecentMessages(),N=[...F,...L];return this.limitTokens(N,k)}addRequest(k){const F=k,L=`${this.sessionId}_request_${this.requestIdPool++}`,N=new w(L,this,F.agentId),U=new T(L,this,F,N);return y.__classPrivateFieldGet(this,c,"f").set(L,U),U}acceptResponseProgress(k,F,L){if(k.response.isComplete)throw new Error("acceptResponseProgress: Adding progress to a completed response");const{kind:N}=F;["content","markdownContent","asyncContent","treeData","component","toolCall","reasoning"].includes(N)?k.response.updateContent(F,L):console.error(`Couldn't handle progress: ${JSON.stringify(F)}`)}getRequest(k){return y.__classPrivateFieldGet(this,c,"f").get(k)}dispose(){super.dispose(),y.__classPrivateFieldGet(this,c,"f").forEach(k=>k.response.dispose())}toJSON(){return{sessionId:this.sessionId,modelId:this.modelId,history:this.history,requests:this.requests}}}t.ChatModel=R,u=new WeakMap,c=new WeakMap,E=new WeakMap,f=new WeakMap;let M=d=class extends A.Disposable{get id(){return this._id}constructor(k,F){super(),this.content=k,this.sampleQuestions=F,this._id="welcome_"+d.nextId++}};t.ChatWelcomeMessageModel=M,M.nextId=0,t.ChatWelcomeMessageModel=M=d=y.__decorate([(0,b.Injectable)({multiple:!0}),y.__metadata("design:paramtypes",[Object,Array])],M);let O=class extends A.Disposable{constructor(k,F,L){super(),this.chatCommand=k,this.command=F,this.agentId=L}get name(){return this.chatCommand.name}get isShortcut(){return!!this.chatCommand.isShortcut}get icon(){return this.chatCommand.icon}get description(){return this.chatCommand.description}get tooltip(){return this.chatCommand.tooltip}get nameWithSlash(){return this.name.startsWith(D.SLASH_SYMBOL)?this.name:`${D.SLASH_SYMBOL} ${this.name}`}};t.ChatSlashCommandItemModel=O,t.ChatSlashCommandItemModel=O=y.__decorate([(0,b.Injectable)({multiple:!0}),y.__metadata("design:paramtypes",[Object,String,String])],O)},42995:(P,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ChatMultiDiffSource=t.ChatMultiDiffResolver=void 0;const r=e(85608),o=e(76003),l=e(41869),_=e(64335),v=e(73974);let m=n=class{canHandleUri(a){return a.scheme===n.CHAT_EDITING_MULTI_DIFF_SOURCE_RESOLVER_SCHEME}resolveDiffSource(a){return Promise.resolve(new s(this.baseApplyService,this.appConfig))}};t.ChatMultiDiffResolver=m,m.CHAT_EDITING_MULTI_DIFF_SOURCE_RESOLVER_SCHEME="chat-editing-multi-diff-source",r.__decorate([(0,o.Autowired)(v.BaseApplyService),r.__metadata("design:type",v.BaseApplyService)],m.prototype,"baseApplyService",void 0),r.__decorate([(0,o.Autowired)(l.AppConfig),r.__metadata("design:type",Object)],m.prototype,"appConfig",void 0),t.ChatMultiDiffResolver=m=n=r.__decorate([(0,o.Injectable)()],m);const p=(g,a,h)=>l.URI.from({scheme:v.BaseApplyService.CHAT_EDITING_SOURCE_RESOLVER_SCHEME,path:g,query:l.URI.stringifyQuery({id:a,side:h})});class s{constructor(a,h){this.baseApplyService=a,this.appConfig=h,this.resources=(()=>{const u=this.baseApplyService,c=this.appConfig;return{get value(){return(u.getSessionCodeBlocks()||[]).filter(E=>E.status==="success"||E.status==="pending").reduce((E,f)=>{const d=E.find(y=>y.relativePath===f.relativePath);return d?(f.version<d.oldVersion&&(d.oldVersion=f.version,d.oldBlockId=f.toolCallId),f.version>d.newVersion&&(d.newVersion=f.version,d.newBlockId=f.toolCallId)):E.push({relativePath:f.relativePath,oldBlockId:f.toolCallId,newBlockId:f.toolCallId,oldVersion:f.version,newVersion:f.version}),E},[]).map(E=>{const f=l.path.join(c.workspaceDir,E.relativePath);return new _.MultiDiffEditorItem(p(f,E.oldBlockId,"left"),p(f,E.newBlockId,"right"),l.URI.file(f))})},onDidChange:this.baseApplyService.onCodeBlockUpdate}})()}}t.ChatMultiDiffSource=s},51081:(P,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ChatProxyService=void 0;const r=e(85608),o=e(76003),l=e(41869),_=e(43718),v=e(27284),m=e(9447),p=e(72665),s=e(93062),g=e(19413),a=e(85907),h=e(34817),u=e(33108),c=e(11735);let E=n=class extends _.Disposable{constructor(){super(...arguments),this.chatDeferred=new _.Deferred}async getRequestOptions(){const d=this.preferenceService.get(v.AINativeSettingSectionsId.LLMModelSelection),y=this.preferenceService.get(v.AINativeSettingSectionsId.ModelID);let b="",A="";d==="deepseek"?b=this.preferenceService.get(v.AINativeSettingSectionsId.DeepseekApiKey,""):d==="openai"?b=this.preferenceService.get(v.AINativeSettingSectionsId.OpenaiApiKey,""):d==="anthropic"?b=this.preferenceService.get(v.AINativeSettingSectionsId.AnthropicApiKey,""):(b=this.preferenceService.get(v.AINativeSettingSectionsId.OpenaiApiKey,""),A=this.preferenceService.get(v.AINativeSettingSectionsId.OpenaiBaseURL,""));const S=this.preferenceService.get(v.AINativeSettingSectionsId.MaxTokens),D=this.chatAgentService.getAgent(n.AGENT_ID),I=await this.mcpConfigService.getDisabledTools();return{clientId:this.applicationService.clientId,model:d,modelId:y,apiKey:b,baseURL:A,maxTokens:S,system:D?.metadata.systemPrompt,disabledTools:I}}registerDefaultAgent(){this.chatAgentViewService.registerChatComponent({id:"toolCall",component:h.ChatToolRender,initialProps:{}}),this.applicationService.getBackendOS().then(()=>{this.addDispose(this.chatAgentService.registerAgent({id:n.AGENT_ID,metadata:{systemPrompt:this.preferenceService.get(v.AINativeSettingSectionsId.SystemPrompt,a.DEFAULT_SYSTEM_PROMPT)},invoke:async(d,y,b,A)=>{this.chatDeferred=new _.Deferred;const{message:S,command:D}=d;let I=S;if(D){const T=this.chatFeatureRegistry.getSlashCommandHandler(D);if(T&&T.providerPrompt){const R=this.monacoCommandRegistry.getActiveCodeEditor();I=await T.providerPrompt(S,R)}}const w=await this.aiBackService.requestStream(I,{requestId:d.requestId,sessionId:d.sessionId,history:b,images:d.images,...await this.getRequestOptions()},A);return(0,s.listenReadable)(w,{onData:T=>{y(T)},onEnd:()=>{this.chatDeferred.resolve()},onError:T=>{this.messageService.error(T.message),this.aiReporter.end(d.sessionId+"_"+d.requestId,{message:T.message,success:!1,command:D})}}),await this.chatDeferred.promise,{}},provideSlashCommands:async()=>this.chatFeatureRegistry.getAllSlashCommand().map(d=>({...d,name:d.name,description:d.description||""})),provideChatWelcomeMessage:async()=>{}}))}),queueMicrotask(()=>{this.chatAgentService.updateAgent(n.AGENT_ID,{})})}};t.ChatProxyService=E,E.AGENT_ID="Default_Chat_Agent",r.__decorate([(0,o.Autowired)(g.IChatAgentService),r.__metadata("design:type",Object)],E.prototype,"chatAgentService",void 0),r.__decorate([(0,o.Autowired)(_.AIBackSerivcePath),r.__metadata("design:type",Object)],E.prototype,"aiBackService",void 0),r.__decorate([(0,o.Autowired)(_.ChatFeatureRegistryToken),r.__metadata("design:type",c.ChatFeatureRegistry)],E.prototype,"chatFeatureRegistry",void 0),r.__decorate([(0,o.Autowired)(m.MonacoCommandRegistry),r.__metadata("design:type",m.MonacoCommandRegistry)],E.prototype,"monacoCommandRegistry",void 0),r.__decorate([(0,o.Autowired)(_.IAIReporter),r.__metadata("design:type",Object)],E.prototype,"aiReporter",void 0),r.__decorate([(0,o.Autowired)(_.ChatAgentViewServiceToken),r.__metadata("design:type",Object)],E.prototype,"chatAgentViewService",void 0),r.__decorate([(0,o.Autowired)(l.PreferenceService),r.__metadata("design:type",Object)],E.prototype,"preferenceService",void 0),r.__decorate([(0,o.Autowired)(_.IApplicationService),r.__metadata("design:type",Object)],E.prototype,"applicationService",void 0),r.__decorate([(0,o.Autowired)(p.IMessageService),r.__metadata("design:type",Object)],E.prototype,"messageService",void 0),r.__decorate([(0,o.Autowired)(_.MCPConfigServiceToken),r.__metadata("design:type",u.MCPConfigService)],E.prototype,"mcpConfigService",void 0),t.ChatProxyService=E=n=r.__decorate([(0,o.Injectable)()],E)},29770:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatService=void 0;const n=e(85608),r=e(76003),o=e(43718),l=e(63067),_=e(19413),v=e(59347);let m=class extends o.Disposable{constructor(){super(),this._onChatMessageLaunch=new o.Emitter,this.onChatMessageLaunch=this._onChatMessageLaunch.event,this._onChatReplyMessageLaunch=new o.Emitter,this.onChatReplyMessageLaunch=this._onChatReplyMessageLaunch.event,this._onChatMessageListLaunch=new o.Emitter,this.onChatMessageListLaunch=this._onChatMessageListLaunch.event,this._onScrollToBottom=new o.Emitter,this.onScrollToBottom=this._onScrollToBottom.event}showChatView(){this.mainLayoutService.toggleSlot(_.AI_CHAT_VIEW_ID,!0)}sendMessage(s){this.showChatView(),this._onChatMessageLaunch.fire(s)}clearHistoryMessages(){var s;(s=this.chatInternalService.sessionModel)===null||s===void 0||s.history.clearMessages()}sendReplyMessage(s){typeof s=="string"?this._onChatReplyMessageLaunch.fire({kind:"content",content:s}):this._onChatReplyMessageLaunch.fire(s)}sendMessageList(s){this._onChatMessageListLaunch.fire(s)}scrollToBottom(){this._onScrollToBottom.fire()}};t.ChatService=m,n.__decorate([(0,r.Autowired)(_.IChatInternalService),n.__metadata("design:type",v.ChatInternalService)],m.prototype,"chatInternalService",void 0),n.__decorate([(0,r.Autowired)(l.IMainLayoutService),n.__metadata("design:type",Object)],m.prototype,"mainLayoutService",void 0),t.ChatService=m=n.__decorate([(0,r.Injectable)(),n.__metadata("design:paramtypes",[])],m)},11735:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatFeatureRegistry=void 0;const n=e(85608),r=e(76003),o=e(43718),l=e(19413),_=e(42033),v=e(51081);let m=class extends o.Disposable{constructor(){super(...arguments),this.logger=(0,o.getDebugLogger)(),this.slashCommandsMap=new Map,this.slashCommandsHandlerMap=new Map,this._onDidWelcomeMessageChange=new o.Emitter,this.onDidWelcomeMessageChange=this._onDidWelcomeMessageChange.event}registerImageUploadProvider(s){this.imageUploadProvider=s}getImageUploadProvider(){return this.imageUploadProvider}registerMessageSummaryProvider(s){this.messageSummaryProvider=s}getMessageSummaryProvider(){return this.messageSummaryProvider}dispose(){super.dispose(),this.slashCommandsMap.clear(),this.slashCommandsHandlerMap.clear()}registerWelcome(s,g){this.chatWelcomeMessageModel=new _.ChatWelcomeMessageModel(s,g),this._onDidWelcomeMessageChange.fire()}registerSlashCommand(s,g){const{name:a}=s;if(this.slashCommandsMap.has(a)){this.logger.warn(`ChatFeatureRegistry: commands name ${a} already exists`);return}this.slashCommandsMap.set(a,new _.ChatSlashCommandItemModel(s,a,v.ChatProxyService.AGENT_ID)),this.slashCommandsHandlerMap.set(a,g)}getSlashCommandHandler(s){return this.slashCommandsHandlerMap.get(s)}getSlashCommand(s){return this.slashCommandsMap.get(s)}getSlashCommandHandlerBySlashName(s){const g=this.getAllSlashCommand().find(a=>a.nameWithSlash===s);if(g)return this.getSlashCommandHandler(g.name)}getSlashCommandBySlashName(s){const g=this.getAllSlashCommand().find(a=>a.nameWithSlash===s);if(g)return this.getSlashCommand(g.name)}getAllSlashCommand(){return Array.from(this.slashCommandsMap.values())}getAllShortcutSlashCommand(){return this.getAllSlashCommand().filter(s=>s.isShortcut===!0)}parseSlashCommand(s){if(s.startsWith(l.SLASH_SYMBOL)){const g=this.getAllSlashCommand();for(const a of g){const{nameWithSlash:h}=a;if(s.startsWith(h))return{value:s.slice(h.length),nameWithSlash:h}}}return{value:s,nameWithSlash:""}}};t.ChatFeatureRegistry=m,t.ChatFeatureRegistry=m=n.__decorate([(0,r.Injectable)()],m)},59347:(P,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ChatInternalService=void 0;const r=e(85608),o=e(76003),l=e(41869),_=e(43718),v=e(19413),m=e(61282);let p=class extends _.Disposable{constructor(){super(...arguments),this._onChangeRequestId=new _.Emitter,this.onChangeRequestId=this._onChangeRequestId.event,this._onChangeSession=new _.Emitter,this.onChangeSession=this._onChangeSession.event,this._onCancelRequest=new _.Emitter,this.onCancelRequest=this._onCancelRequest.event,this._onWillClearSession=new _.Emitter,this.onWillClearSession=this._onWillClearSession.event,this._onRegenerateRequest=new _.Emitter,this.onRegenerateRequest=this._onRegenerateRequest.event,n.set(this,void 0)}get latestRequestId(){return this._latestRequestId}get sessionModel(){return r.__classPrivateFieldGet(this,n,"f")}init(){this.chatManagerService.onStorageInit(()=>{const g=this.chatManagerService.getSessions();g.length>0?this.activateSession(g[g.length-1].sessionId):this.createSessionModel()})}setLatestRequestId(g){this._latestRequestId=g,this._onChangeRequestId.fire(g)}createRequest(g,a,h,u){return this.chatManagerService.createRequest(r.__classPrivateFieldGet(this,n,"f").sessionId,g,a,u,h)}sendRequest(g,a=!1){const h=this.chatManagerService.sendRequest(r.__classPrivateFieldGet(this,n,"f").sessionId,g,a);return a&&this._onRegenerateRequest.fire(),h}cancelRequest(){this.chatManagerService.cancelRequest(r.__classPrivateFieldGet(this,n,"f").sessionId),this._onCancelRequest.fire()}createSessionModel(){r.__classPrivateFieldSet(this,n,this.chatManagerService.startSession(),"f"),this._onChangeSession.fire(r.__classPrivateFieldGet(this,n,"f").sessionId)}clearSessionModel(g){g=g||r.__classPrivateFieldGet(this,n,"f").sessionId,this._onWillClearSession.fire(g),this.chatManagerService.clearSession(g),g===r.__classPrivateFieldGet(this,n,"f").sessionId&&r.__classPrivateFieldSet(this,n,this.chatManagerService.startSession(),"f"),this._onChangeSession.fire(r.__classPrivateFieldGet(this,n,"f").sessionId)}getSessions(){return this.chatManagerService.getSessions()}getSession(g){return this.chatManagerService.getSession(g)}activateSession(g){const a=this.chatManagerService.getSession(g);if(!a)throw new Error(`There is no session with session id ${g}`);r.__classPrivateFieldSet(this,n,a,"f"),this._onChangeSession.fire(r.__classPrivateFieldGet(this,n,"f").sessionId)}dispose(){var g;(g=r.__classPrivateFieldGet(this,n,"f"))===null||g===void 0||g.dispose(),super.dispose()}};t.ChatInternalService=p,n=new WeakMap,r.__decorate([(0,o.Autowired)(_.AIBackSerivcePath),r.__metadata("design:type",Object)],p.prototype,"aiBackService",void 0),r.__decorate([(0,o.Autowired)(l.PreferenceService),r.__metadata("design:type",Object)],p.prototype,"preferenceService",void 0),r.__decorate([(0,o.Autowired)(v.IChatManagerService),r.__metadata("design:type",m.ChatManagerService)],p.prototype,"chatManagerService",void 0),t.ChatInternalService=p=r.__decorate([(0,o.Injectable)()],p)},70394:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatRenderRegistry=void 0;const n=e(85608),r=e(76003),o=e(43718);let l=class extends o.Disposable{registerWelcomeRender(v){this.chatWelcomeRender=v}registerAIRoleRender(v){this.chatAIRoleRender=v}registerUserRoleRender(v){this.chatUserRoleRender=v}registerThinkingRender(v){this.chatThinkingRender=v}registerInputRender(v){this.chatInputRender=v}registerThinkingResultRender(v){this.chatThinkingResultRender=v}registerChatViewHeaderRender(v){this.chatViewHeaderRender=v}};t.ChatRenderRegistry=l,t.ChatRenderRegistry=l=n.__decorate([(0,r.Injectable)()],l)},76154:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AIChatView=void 0,t.DefaultChatViewHeader=U;const n=e(85608),r=n.__importStar(e(14041)),o=e(68392),l=e(41869),_=e(81878),v=e(89195),m=e(43718),p=e(54414),s=e(63067),g=e(72665);e(41937);const a=e(51500),h=e(19413),u=e(46044),c=e(98864),E=e(87785),f=e(25834),d=n.__importDefault(e(90103)),y=e(57987),b=e(56474),A=e(49601),S=e(15016),D=e(29039),I=e(78048),w=e(86556),T=e(73974),R=e(77633),M=e(42033),O=e(51081),x=n.__importDefault(e(77256)),k="chat_scroll",F=100,L=W=>W.map(j=>{var Q;const $=((Q=j.applyResult)===null||Q===void 0?void 0:Q.diff.split(`
32959
+ `).reduce(([Z,G],V)=>(V.startsWith("-")?Z+=1:V.startsWith("+")&&(G+=1),[Z,G]),[0,0]))||[0,0];return{path:j.relativePath,additions:$[1],deletions:$[0],status:j.status}}).reduce((j,Q)=>{const $=j.find(Z=>Z.path===Q.path);return $?($.additions+=Q.additions,$.deletions+=Q.deletions,$.status=Q.status):j.push(Q),j},[]),N=()=>{const W=(0,l.useInjectable)(h.IChatInternalService),j=(0,l.useInjectable)(m.ChatServiceToken),Q=(0,l.useInjectable)(m.IAIReporter),$=(0,l.useInjectable)(h.IChatAgentService),Z=(0,l.useInjectable)(m.ChatFeatureRegistryToken),G=(0,l.useInjectable)(m.ChatRenderRegistryToken),V=(0,l.useInjectable)(R.TokenMCPServerRegistry),H=(0,l.useInjectable)(l.AINativeConfigService),K=(0,l.useInjectable)(u.LLMContextServiceToken),Y=(0,l.useInjectable)(s.IMainLayoutService),X=W.sessionModel.history,re=r.useRef(null),oe=r.useRef(!0),he=r.useRef(null),me=(0,l.useInjectable)(p.WorkbenchEditorService),q=(0,l.useInjectable)(l.AppConfig),Ae=(0,l.useInjectable)(T.BaseApplyService),ge=(0,l.useInjectable)(l.LabelService),te=(0,l.useInjectable)(a.IWorkspaceService),fe=(0,l.useInjectable)(m.CommandService),[Oe,Me]=r.useState([]),[Pe,Be]=r.useState(W.sessionModel.modelId),[De,_e]=r.useState(L(Ae.getSessionCodeBlocks()||[])),[Ne,Te]=r.useReducer((Re,Le)=>{switch(Le.type){case"add":return[...Re,...Le.payload||[]];case"clear":return[];case"init":return Array.isArray(Le.payload)?Le.payload:[];default:return Re}},[]),[We,pe]=r.useState(!1),[ie,le]=r.useState(""),[Se,ye]=r.useState(""),[Ue,Ye]=r.useState(""),[Ve,pt]=r.useState(null);r.useEffect(()=>{Be(W.sessionModel.modelId)},[We,W.sessionModel]),r.useEffect(()=>{const Re=new m.Disposable,Le=()=>{const ze=L(Ae.getSessionCodeBlocks()||[]);_e(ze)};return Re.addDispose(W.onChangeSession(Le)),Re.addDispose(Ae.onCodeBlockUpdate(Le)),()=>Re.dispose()},[]),r.useEffect(()=>{const Re=Z.getAllShortcutSlashCommand(),Le=$.onDidChangeAgents(()=>{const ze=$.getCommands().filter(St=>St.isShortcut).map(St=>new M.ChatSlashCommandItemModel({icon:"",name:`${St.name} `,description:St.description,isShortcut:St.isShortcut},St.name,St.agentId));Me(Re.concat(ze))});return Me(Re),()=>Le.dispose()},[Z,$]),(0,l.useUpdateOnEvent)(W.onChangeSession);const vt=r.useMemo(()=>G.chatInputRender?G.chatInputRender:H.capabilities.supportsMCP?A.ChatMentionInput:y.ChatInput,[G.chatInputRender]),xt=r.useMemo(()=>(0,I.createMessageByAI)({id:(0,m.uuid)(6),relationId:"",text:r.createElement(w.WelcomeMessage,null)}),[]),lt=r.useCallback(Re=>{Re.deltaY<0?oe.current=!1:oe.current=!0},[oe]);r.useEffect(()=>{if(re.current)return re.current.addEventListener("wheel",lt),()=>{var Re;(Re=re.current)===null||Re===void 0||Re.removeEventListener("wheel",lt)}},[oe]);const wt=r.useCallback(()=>{if(re&&re.current&&oe.current){const Re=re.current.lastElementChild;Re&&Re.scrollIntoView({behavior:"smooth",block:"end"}),re.current.scrollHeight>re.current.clientHeight&&re.current.classList.add(k)}},[re,oe]),at=r.useCallback(Re=>{Te(Re),requestAnimationFrame(()=>{wt()})},[Te,wt]);r.useEffect(()=>{at({type:"init",payload:[xt]})},[]),r.useEffect(()=>{const Re=new m.Disposable;return Re.addDispose(j.onScrollToBottom(()=>{requestAnimationFrame(()=>{})})),Re.addDispose(j.onChatMessageLaunch(async Le=>{var ze;if(Le.immediate!==!1){if(We)return;await ui(Le.message,Le.images,Le.agentId,Le.command)}else Le.agentId&&le(Le.agentId),Le.command&&Ye(Le.command),(ze=he?.current)===null||ze===void 0||ze.setInputValue(Le.message)})),Re.addDispose(j.onChatReplyMessageLaunch(Le=>{if(Le.kind==="content"){const ze=Q.start(m.AIServiceType.CustomReply,{message:Le.content,sessionId:W.sessionModel.sessionId});X.addAssistantMessage({content:Le.content,relationId:ze}),Ut({chunk:Le.content,relationId:ze})}else{const ze=Q.start(m.AIServiceType.CustomReply,{message:"component#"+Le.component,sessionId:W.sessionModel.sessionId});X.addAssistantMessage({componentId:Le.component,componentValue:Le.value,content:"",relationId:ze}),_n({chunk:Le,relationId:ze})}})),Re.addDispose(j.onChatMessageListLaunch(Le=>{const ze=[];Le.forEach(St=>{const{role:$t}=St,On=Q.start(m.AIServiceType.Chat,{message:"",sessionId:W.sessionModel.sessionId});if($t==="assistant"){const Bn=St;ze.push((0,I.createMessageByAI)({id:(0,m.uuid)(6),relationId:On,text:r.createElement(S.ChatNotify,{requestId:On,chunk:Bn})},x.default.chat_notify))}if($t==="user"){const{message:Bn}=St,di=O.ChatProxyService.AGENT_ID,li=G.chatUserRoleRender,Ni=di===O.ChatProxyService.AGENT_ID?"":di;ze.push((0,I.createMessageByUser)({id:(0,m.uuid)(6),relationId:On,text:li?r.createElement(li,{content:Bn,agentId:Ni}):r.createElement(f.CodeBlockWrapperInput,{relationId:On,text:Bn,agentId:Ni,command:Ue,labelService:ge,workspaceService:te,commandService:fe})},x.default.chat_message_code))}}),at({type:"add",payload:ze}),setTimeout(wt,0)})),()=>Re.dispose()},[j,G.chatAIRoleRender,X]),r.useEffect(()=>{const Re=new m.Disposable;return Re.addDispose($.onDidSendMessage(Le=>{const ze=Le,St=Q.start(m.AIServiceType.Agent,{message:""}),$t=(0,I.createMessageByAI)({id:(0,m.uuid)(6),relationId:St,text:r.createElement(S.ChatNotify,{requestId:W.latestRequestId,chunk:ze})},x.default.chat_notify);at({type:"add",payload:[$t]})})),Re.addDispose($.onDidChangeAgents(async()=>{const Le=$.getDefaultAgentId();ye(Le??"")})),()=>Re.dispose()},[$,X,W]);const tt=r.useCallback(async Re=>{const{userMessage:Le,relationId:ze,requestId:St,render:$t,startTime:On,command:Bn,agentId:di}=Re;X.addAssistantMessage({type:"component",content:""});const li=(0,I.createMessageByAI)({id:(0,m.uuid)(6),relationId:ze,className:x.default.chat_with_more_actions,text:r.createElement(D.SlashCustomRender,{userMessage:Le,startTime:On,relationId:ze,requestId:St,renderContent:$t,command:Bn,agentId:di})});at({type:"add",payload:[li]})},[re,X]),st=r.useCallback(async Re=>{const Le=G.chatUserRoleRender,{message:ze,images:St,agentId:$t,relationId:On,command:Bn}=Re,di=$t===O.ChatProxyService.AGENT_ID?"":$t,li=(0,I.createMessageByUser)({id:(0,m.uuid)(6),relationId:On,text:Le?r.createElement(Le,{content:ze,images:St,agentId:di,command:Bn}):r.createElement(f.CodeBlockWrapperInput,{labelService:ge,relationId:On,text:ze,images:St,agentId:di,command:Bn,workspaceService:te,commandService:fe})},x.default.chat_message_code);at({type:"add",payload:[li]})},[G,G.chatUserRoleRender,X,wt]),At=r.useCallback(async Re=>{const{message:Le,agentId:ze,request:St,relationId:$t,command:On,startTime:Bn,msgId:di}=Re,li=ze===O.ChatProxyService.AGENT_ID?"":ze;if(ze===O.ChatProxyService.AGENT_ID&&On){const In=Z.getSlashCommandHandler(On);if(In&&In.providerRender)return pe(!1),tt({userMessage:Le,render:In.providerRender,relationId:$t,requestId:St.requestId,startTime:Bn,agentId:ze,command:On})}const Ni=(0,I.createMessageByAI)({id:(0,m.uuid)(6),relationId:$t,className:x.default.chat_with_more_actions,text:r.createElement(S.ChatReply,{relationId:$t,request:St,startTime:Bn,agentId:li,command:On,onDidChange:()=>{wt()},history:X,onDone:()=>{pe(!1)},onRegenerate:()=>{St&&W.sendRequest(St,!0)},msgId:di})});at({type:"add",payload:[Ni]})},[G,X,wt]),Ut=r.useCallback(Re=>{const{chunk:Le,relationId:ze}=Re;let St=r.createElement(b.ChatMarkdown,{markdown:Le,fillInIncompleteTokens:!0,agentId:ie,command:Ue});if(G.chatAIRoleRender){const On=G.chatAIRoleRender;St=r.createElement(On,{content:Le})}const $t=(0,I.createMessageByAI)({id:(0,m.uuid)(6),relationId:ze,text:St,className:x.default.chat_with_more_actions});at({type:"add",payload:[$t]})},[G,X,wt]),_n=r.useCallback(Re=>{const{chunk:Le,relationId:ze}=Re,St=(0,I.createMessageByAI)({id:(0,m.uuid)(6),relationId:ze,text:r.createElement(S.ChatNotify,{requestId:ze,chunk:Le})},x.default.chat_notify);at({type:"add",payload:[St]})},[G,X,wt]),Ln=r.useCallback(async Re=>{const{message:Le,images:ze,agentId:St,command:$t,reportExtra:On}=Re,{actionType:Bn,actionSource:di}=On||{},li=W.createRequest(Le.replaceAll(u.LLM_CONTEXT_KEY_REGEX,""),St,ze,$t);if(!li)return;pe(!0),W.setLatestRequestId(li.requestId);const Ni=Date.now(),In=O.ChatProxyService.AGENT_ID===St?m.AIServiceType.Chat:m.AIServiceType.Agent,Cn=Q.start($t||In,{agentId:St,userMessage:Le,actionType:Bn,actionSource:di,sessionId:W.sessionModel.sessionId},600*1e3);X.addUserMessage({content:Le,images:ze||[],agentId:St,agentCommand:$t,relationId:Cn}),await st({relationId:Cn,message:Le,images:ze,command:$t,agentId:St}),W.sendRequest(li);const $n=X.addAssistantMessage({content:"",relationId:Cn,requestId:li.requestId,replyStartTime:Ni});V.activeMessageInfo={messageId:$n,sessionId:W.sessionModel.sessionId},await At({startTime:Ni,relationId:Cn,message:Le,agentId:St,command:$t,request:li,msgId:$n})},[G,G.chatUserRoleRender,X,wt,We]),ui=r.useCallback(async(Re,Le,ze,St)=>{var $t,On,Bn;const di={actionSource:m.ActionSourceEnum.Chat,actionType:m.ActionTypeEnum.Send};ze=ze||O.ChatProxyService.AGENT_ID;let li=Re;const Ni=/\{\{@file:(.*?)\}\}/g,In=Re.match(Ni);if(In)for(const Kn of In){const Xt=Kn.replace(/\{\{@file:(.*?)\}\}/,"$1"),Qe=new m.URI(Xt),_t=(($t=await te.asRelativePath(Qe))===null||$t===void 0?void 0:$t.path)||Qe.displayName;li=li.replace(Kn,`\`${u.LLM_CONTEXT_KEY.AttachedFile}${_t}\``)}const Cn=/\{\{@folder:(.*?)\}\}/g,$n=li.match(Cn);if($n)for(const Kn of $n){const Xt=Kn.replace(/\{\{@folder:(.*?)\}\}/,"$1"),Qe=new m.URI(Xt),_t=((On=await te.asRelativePath(Qe))===null||On===void 0?void 0:On.path)||Qe.displayName;li=li.replace(Kn,`\`${u.LLM_CONTEXT_KEY.AttachedFolder}${_t}\``)}const Si=/\{\{@code:(.*?)\}\}/g,Ui=li.match(Si);if(Ui)for(const Kn of Ui){const Xt=Kn.replace(/\{\{@code:(.*?)\}\}/,"$1"),[Qe,_t]=Xt.split(":");let mt=[0,0];if(_t){const[Gt,Kt]=_t.slice(1).split("-");mt=[parseInt(Gt,10),parseInt(Kt,10)]}const gt=new m.URI(Qe),nn=((Bn=await te.asRelativePath(gt))===null||Bn===void 0?void 0:Bn.path)||gt.displayName;li=li.replace(Kn,`\`${u.LLM_CONTEXT_KEY.AttachedFile}${nn}:L${mt[0]}-${mt[1]}\``)}const bi=/\{\{@rule:(.*?)\}\}/g,hn=li.match(bi);if(hn)for(const Kn of hn){const Xt=Kn.replace(/\{\{@rule:(.*?)\}\}/,"$1"),Qe=new m.URI(Xt);li=li.replace(Kn,`\`${u.LLM_CONTEXT_KEY.AttachedFile}${Qe.displayName}\``)}return Ln({message:li,images:Le,agentId:ze,command:St,reportExtra:di})},[Ln]),Rn=r.useCallback(()=>{W.clearSessionModel(),j.clearHistoryMessages(),ln()},[Ne]),ln=r.useCallback(()=>{var Re;(Re=re?.current)===null||Re===void 0||Re.classList.remove(k),at({type:"init",payload:[xt]})},[Ne]),Un=Re=>{We||(pt(Re.nameWithSlash),le(Re.agentId),Ye(Re.command))},rn=r.useCallback(()=>{Y.toggleSlot(h.AI_CHAT_VIEW_ID)},[Y]),ct=G.chatViewHeaderRender||U,$e=r.useCallback(async Re=>{for(const Le of X.getMessages()){if(Re.isCancellationRequested)return;if(Le.role===1)await st({relationId:Le.relationId,message:Le.content,agentId:Le.agentId,command:Le.agentCommand,images:Le.images});else if(Le.role===2&&Le.requestId){const ze=W.sessionModel.getRequest(Le.requestId);ze&&!ze.response.isComplete&&pe(!0),await At({msgId:Le.id,relationId:Le.relationId,message:Le.content,agentId:Le.agentId,command:Le.agentCommand,startTime:Le.replyStartTime,request:ze})}else Le.role===2&&Le.content?await Ut({relationId:Le.relationId,chunk:Le.content}):Le.role===2&&Le.componentId&&await _n({relationId:Le.relationId,chunk:{kind:"component",component:Le.componentId,value:Le.componentValue}})}},[At]);return r.useEffect(()=>{ln();const Re=new m.CancellationTokenSource;return pe(!1),$e(Re.token),()=>{Re.cancel()}},[W.sessionModel]),r.createElement("div",{id:x.default.ai_chat_view},r.createElement("div",{className:x.default.header_container},r.createElement(ct,{handleClear:Rn,handleCloseChatView:rn})),r.createElement("div",{className:x.default.body_container},r.createElement("div",{className:x.default.left_bar,id:"ai_chat_left_container"},r.createElement("div",{className:x.default.chat_container,ref:re},r.createElement(o.MessageList,{className:x.default.message_list,lockable:!0,toBottomHeight:"100%",dataSource:Ne})),W.sessionModel.slicedMessageCount?r.createElement("div",{className:x.default.chat_tips_text},r.createElement("div",{className:x.default.chat_tips_container},(0,m.formatLocalize)("aiNative.chat.ai.assistant.limit.message",W.sessionModel.slicedMessageCount))):null,r.createElement("div",{className:x.default.chat_input_wrap},r.createElement("div",{className:x.default.header_operate},r.createElement("div",{className:x.default.header_operate_left},Oe.map(Re=>r.createElement(_.Popover,{id:`ai-chat-shortcut-${Re.name}`,key:`ai-chat-shortcut-${Re.name}`,title:Re.tooltip||Re.name},r.createElement("div",{className:x.default.tag,onClick:()=>Un(Re)},Re.name))))),De.length>0&&r.createElement(E.FileListDisplay,{files:De,hideActions:We,onFileClick:Re=>{me.open(m.URI.file(m.path.join(q.workspaceDir,Re)))},onRejectAll:()=>{Ae.processAll("reject")},onAcceptAll:()=>{Ae.processAll("accept")}}),r.createElement(vt,{onSend:ui,disabled:We,enableOptions:!0,theme:Ve,setTheme:pt,agentId:ie,setAgentId:le,defaultAgentId:Se,command:Ue,setCommand:Ye,contextService:K,ref:he,disableModelSelector:Pe!==void 0||We,sessionModelId:Pe})))))};t.AIChatView=N;function U({handleClear:W,handleCloseChatView:j}){const Q=(0,l.useInjectable)(h.IChatInternalService),$=(0,l.useInjectable)(g.IMessageService),Z=(0,l.useInjectable)(m.ChatFeatureRegistryToken),[G,V]=r.useState([]),[H,K]=r.useState(""),Y=r.useCallback(()=>{if(Q.sessionModel.history.getMessages().length>0)try{Q.createSessionModel()}catch(me){$.error(me.message)}},[Q]),X=r.useCallback(me=>{Q.activateSession(me.id)},[Q]),re=r.useCallback(me=>{Q.clearSessionModel(me.id)},[Q]),oe=r.useCallback(async(me,q,Ae)=>{if(!Ae)return q;try{const ge=await Ae.getMessageSummary(me);return ge?ge.slice(0,F):q}catch{return q}},[]),he=r.useRef(0);return r.useEffect(()=>{const me=async()=>{const ge=Q.sessionModel.history.getMessages(),te=[...ge].find(Me=>Me.role===1),fe=te?(0,c.cleanAttachedTextWrapper)(te.content).slice(0,F):"";K(fe);const Oe=ge.map(Me=>({role:Me.role,content:Me.content}));if(Oe.length>2){const Me=Date.now();he.current=Me;const Pe=Z.getMessageSummaryProvider(),Be=await oe(Oe,fe,Pe);Me===he.current&&Be&&K(Be)}V(Q.getSessions().map(Me=>{const Be=Me.history.getMessages(),De=Be.length>0?(0,c.cleanAttachedTextWrapper)(Be[0].content).slice(0,F):"",_e=Be.length>0&&Be[Be.length-1].replyStartTime||0;return{id:Me.sessionId,title:De,updatedAt:_e,loading:!1}}))};me();const q=new m.DisposableCollection,Ae=new Set;return q.push(Q.onChangeSession(ge=>{me(),!Ae.has(ge)&&(Ae.add(ge),q.push(Q.sessionModel.history.onMessageChange(()=>{me()})))})),q.push(Q.sessionModel.history.onMessageChange(()=>{me()})),()=>{q.dispose()}},[Q]),r.createElement("div",{className:x.default.header},r.createElement(d.default,{className:x.default.chat_history,currentId:Q.sessionModel.sessionId,title:H||(0,m.localize)("aiNative.chat.ai.assistant.name"),historyList:G,onNewChat:Y,onHistoryItemSelect:X,onHistoryItemDelete:re,onHistoryItemChange:()=>{}}),r.createElement(_.Popover,{overlayClassName:x.default.popover_icon,id:"ai-chat-header-clear",title:(0,m.localize)("aiNative.operate.clear.title")},r.createElement(v.EnhanceIcon,{wrapperClassName:x.default.action_btn,className:(0,l.getIcon)("clear"),onClick:W,tabIndex:0,role:"button",ariaLabel:(0,m.localize)("aiNative.operate.clear.title")})),r.createElement(_.Popover,{overlayClassName:x.default.popover_icon,id:"ai-chat-header-close",position:_.PopoverPosition.left,title:(0,m.localize)("aiNative.operate.close.title")},r.createElement(v.EnhanceIcon,{wrapperClassName:x.default.action_btn,className:(0,l.getIcon)("window-close"),onClick:j,tabIndex:0,role:"button",ariaLabel:(0,m.localize)("aiNative.operate.close.title")})))}},21967:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ApplyStatus=void 0;const n=e(85608),r=n.__importDefault(e(14041)),o=e(97267),l=n.__importDefault(e(6960)),_=({status:v,error:m})=>{const p=()=>{switch(v){case"generating":return r.default.createElement(o.Loading,null);case"pending":return r.default.createElement(o.Popover,{title:"Pending",id:"edit-file-tool-status-pending"},r.default.createElement(o.Icon,{iconClass:"codicon codicon-circle-large"}));case"success":return r.default.createElement(o.Popover,{title:"Success",id:"edit-file-tool-status-success"},r.default.createElement(o.Icon,{iconClass:"codicon codicon-pass"}));case"failed":return r.default.createElement(o.Popover,{title:`(${m||"Unknown error"})`,id:"edit-file-tool-status-failed"},r.default.createElement(o.Icon,{iconClass:"codicon codicon-error"}));case"cancelled":return r.default.createElement(o.Popover,{title:"Cancelled",id:"edit-file-tool-status-cancelled"},r.default.createElement(o.Icon,{iconClass:"codicon codicon-circle-slash",style:{color:"var(--input-placeholderForeground)"}}));default:return null}};return r.default.createElement("span",{className:l.default.status},p())};t.ApplyStatus=_},87785:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FileListDisplay=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(97267),l=e(41869),_=e(54414),v=e(42995),m=e(21967),p=n.__importDefault(e(80919)),s=g=>{const{files:a,onFileClick:h,onRejectAll:u,onAcceptAll:c,hideActions:E}=g,[f,d]=(0,r.useState)(!0),y=(0,l.useInjectable)(_.WorkbenchEditorService),b=(0,l.useInjectable)(l.LabelService),A=(0,r.useMemo)(()=>a.map(R=>{const M=l.URI.parse(R.path),O=b.getIcon(M);return r.default.createElement("span",{className:O})}),[a]),S=a.length,D=a.reduce((R,M)=>({additions:R.additions+M.additions,deletions:R.deletions+M.deletions}),{additions:0,deletions:0}),I=()=>{d(!f)},w=R=>R?r.default.createElement("span",{className:p.default.viewChanges,onClick:M=>{M.stopPropagation(),y.open(l.URI.from({scheme:v.ChatMultiDiffResolver.CHAT_EDITING_MULTI_DIFF_SOURCE_RESOLVER_SCHEME,path:"chat-editing-multi-diff-source"}),{label:(0,l.localize)("aiNative.chat.view-changes")})}},r.default.createElement(o.Icon,{icon:"unorderedlist",size:"small"}),(0,l.localize)("aiNative.chat.view-changes")):null,T=(R,M)=>{const O=[];return R>0&&O.push(r.default.createElement("span",{key:"add",className:p.default.additions},"+",R)),M>0&&(O.length>0&&O.push(" "),O.push(r.default.createElement("span",{key:"del",className:p.default.deletions},"-",M))),O.length===0&&O.push(r.default.createElement("span",{key:"no-change",className:p.default.noChange},"No changes")),O};return r.default.createElement("div",{className:p.default.container},r.default.createElement("div",{className:p.default.header},r.default.createElement("span",{className:p.default.title},r.default.createElement("button",{className:p.default.toggleButton,onClick:I},f?r.default.createElement(o.Icon,{icon:"down"}):r.default.createElement(o.Icon,{icon:"right"})," Changed Files(",S,")"),T(D.additions,D.deletions),!E&&w(a.length)),!E&&a.some(R=>R.status==="pending")&&r.default.createElement("div",{className:p.default.actions},r.default.createElement(o.Button,{type:"link",size:"small",onClick:R=>{R.stopPropagation(),u()}},"Reject"),r.default.createElement(o.Button,{size:"small",onClick:R=>{R.stopPropagation(),c()}},"Accept"))),r.default.createElement("ul",{className:`${p.default.fileList} ${f?"":p.default.collapsed}`},a.map((R,M)=>r.default.createElement("li",{key:M,className:p.default.fileItem,onClick:()=>h(R.path)},r.default.createElement("span",{className:p.default.fileIcon},A[M]||"\u{1F4C4}"),r.default.createElement("div",{className:p.default.fileInfo},r.default.createElement("div",{className:p.default.filePath},R.path),r.default.createElement("div",{className:p.default.fileStats},T(R.additions,R.deletions)),r.default.createElement(m.ApplyStatus,{status:R.status}))))))};t.FileListDisplay=s},25834:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CodeBlockWrapperInput=t.CodeBlockWrapper=t.CodeEditorWithHighlight=void 0;const n=e(85608),r=n.__importDefault(e(56005)),o=n.__importDefault(e(97331)),l=n.__importStar(e(14041)),_=n.__importDefault(e(10580)),v=e(46541),m=e(41869),p=e(81878),s=e(89195),g=e(43718),a=e(30526),h=e(9447),u=e(52416),c=n.__importDefault(e(6960)),E=e(83933),f=e(44692);e(38191);const d=S=>{const{input:D,language:I,relationId:w,agentId:T,command:R,hideInsert:M}=S,O=l.default.useRef(null),x=(0,m.useInjectable)(h.MonacoCommandRegistry),k=(0,m.useInjectable)(m.IClipboardService),F=(0,m.useInjectable)(u.IThemeService),L=(0,m.useInjectable)(g.IAIReporter),[N,U]=(0,l.useState)(!1),W=(0,l.useMemo)(()=>(0,m.uuid)(12),[O,O.current]);(0,l.useEffect)(()=>{const Z=H=>{H.type==="dark"||H.type==="hcDark"?e.e(622).then(e.bind(e,51622)):(H.type==="light"||H.type==="hcLight")&&e.e(412).then(e.bind(e,50412))},G=F.onThemeChange(H=>{Z(H)}),V=F.getCurrentThemeSync();return Z(V),()=>G.dispose()},[]);const j=(0,l.useRef)((0,o.default)(()=>{var Z;if(O.current){const G=O.current,V=(Z=G?.el)===null||Z===void 0?void 0:Z.querySelector("code"),H=V?.children;if(H){const K=H[H.length-1];K&&(K.scrollIntoViewIfNeeded?K.scrollIntoViewIfNeeded():K.scrollIntoView(!1))}}},150,{leading:!0,trailing:!0})).current;(0,l.useEffect)(()=>(j(),()=>{j.cancel()}),[D,j]);const Q=(0,l.useCallback)(async()=>{U(!0),await k.writeText(D),L.end(w,{copy:!0,code:D,language:I,agentId:T,command:R,actionSource:g.ActionSourceEnum.Chat,actionType:g.ActionTypeEnum.ChatCopyCode}),(0,g.runWhenIdle)(()=>{U(!1)},1e3)},[k,D,w]),$=(0,l.useCallback)(()=>{const Z=x.getActiveCodeEditor();if(Z){const G=Z.getSelection();G&&((0,a.insertSnippetWithMonacoEditor)(Z,D,[G],{undoStopBefore:!1,undoStopAfter:!1}),L.end(w,{insert:!0,code:D,language:I,agentId:T,command:R,actionSource:g.ActionSourceEnum.Chat,actionType:g.ActionTypeEnum.ChatInsertCode}))}},[x]);return l.default.createElement("div",{className:c.default.monaco_wrapper},l.default.createElement("div",{className:c.default.action_toolbar},!M&&l.default.createElement(p.Popover,{id:`ai-chat-inser-${W}`,title:(0,g.localize)("aiNative.chat.code.insert")},l.default.createElement(s.EnhanceIcon,{className:(0,m.getIcon)("insert"),onClick:()=>$(),tabIndex:0,role:"button",ariaLabel:(0,g.localize)("aiNative.chat.code.insert")})),l.default.createElement(p.Popover,{id:`ai-chat-copy-${W}`,title:(0,g.localize)(N?"aiNative.chat.code.copy.success":"aiNative.chat.code.copy")},l.default.createElement(s.EnhanceIcon,{className:(0,m.getIcon)("copy"),onClick:()=>Q(),tabIndex:0,role:"button",ariaLabel:(0,g.localize)("aiNative.chat.code.copy")}))),l.default.createElement(_.default,{language:I,ref:O,className:c.default.highlight_editor},D))};t.CodeEditorWithHighlight=d;const y=({content:S="",relationId:D,renderText:I,agentId:w="",command:T="",labelService:R,commandService:M,workspaceService:O})=>{const x=/`([^`]+)`/g,k=/```([^]+?)```/g,F=/```([^]+)?/g,L=/<attached_file>(.*)/g,N=/<attached_folder>(.*)/g,U=(0,l.useCallback)(async($,Z)=>{const G=await O?.roots;let V;if(G)for(const H of G){V=new g.URI(H.uri).resolve($);try{await M?.executeCommand(m.FILE_COMMANDS.REVEAL_IN_EXPLORER.id,V),Z===f.MentionType.FILE&&await M?.executeCommand(m.EDITOR_COMMANDS.OPEN_RESOURCE.id,V);break}catch{continue}}},[M,O]),W=($,Z=!1,G)=>l.default.createElement("span",{className:c.default.attachment,key:G,onClick:()=>U($,Z?f.MentionType.FOLDER:f.MentionType.FILE)},l.default.createElement(p.Icon,{iconClass:Z?(0,m.getIcon)("folder"):R?.getIcon(new g.URI($||"file"))}),l.default.createElement("span",{className:c.default.attachment_text},$)),j=$=>{const Z=$.split(`
32960
32960
  `)[0].trim().toLowerCase(),G=E.highLightLanguageSupport.find(V=>V===Z)||"plaintext";return $=$.replace(/.*?\n/,""),$=$.trim(),l.default.createElement("div",{className:c.default.code_block},l.default.createElement("div",{className:c.default.code_language},(0,r.default)(G)),l.default.createElement(t.CodeEditorWithHighlight,{input:$,language:Z,relationId:D,agentId:w,command:T}))},Q=(0,l.useMemo)(()=>{const $=S.split(k),Z=[];return $.map((G,V)=>{V%2===0?G.split(x).map((H,K)=>{if(K%2===0){if(H.includes("```")){const Y=H.split(F).filter(Boolean);if(Y.length===2){Z.push(Y[0]),Z.push(j(Y[1]));return}}I?Z.push(I(H)):Z.push(H)}else{const Y=H,X=[...H.matchAll(L)],re=[...H.matchAll(N)];if(X.length||re.length){let oe=0;const he=[],me=(q,Ae)=>{q.forEach((ge,te)=>{if(ge.index!==void 0){const fe=Y.slice(oe,ge.index);fe&&he.push(l.default.createElement("span",{key:`${K}-${te}-${Ae?"folder":"file"}`},fe)),he.push(W(ge[1],Ae,`${K}-tag-${te}-${Ae?"folder":"file"}`)),oe=ge.index+ge[0].length}})};me(X,!1),me(re,!0),he.push(Y.slice(oe)),Z.push(...he)}else Z.push(l.default.createElement("span",{className:c.default.code_inline,key:K},H))}}):Z.push(j(G))}),Z},[S,I]);return l.default.createElement(l.default.Fragment,null,Q)},b=({text:S,renderText:D,relationId:I,agentId:w,labelService:T,commandService:R,workspaceService:M})=>l.default.createElement("div",{className:c.default.ai_chat_code_wrapper},l.default.createElement("div",{className:c.default.render_text},l.default.createElement(y,{content:S,labelService:T,renderText:D,relationId:I,agentId:w,commandService:R,workspaceService:M})));t.CodeBlockWrapper=b;const A=({text:S,images:D,relationId:I,agentId:w,command:T,labelService:R,workspaceService:M,commandService:O})=>{const x=(0,m.useInjectable)(g.ChatFeatureRegistryToken),[k,F]=(0,l.useState)(""),[L,N]=(0,l.useState)(S);return l.default.useEffect(()=>{const{value:U,nameWithSlash:W}=x.parseSlashCommand(S);if(W){F(W),N(U);return}else N(S)},[S,x]),l.default.createElement("div",{className:c.default.ai_chat_code_wrapper},D?.map(U=>l.default.createElement("div",{className:c.default.image_wrapper},l.default.createElement(v.Image,{src:U}))),l.default.createElement("div",{className:c.default.render_text},k&&l.default.createElement("div",{className:c.default.tag_wrapper},l.default.createElement("span",{className:c.default.tag},k)),w&&l.default.createElement("div",{className:c.default.tag,style:{marginRight:4}},"@",w),T&&l.default.createElement("div",{className:c.default.tag},"/ ",T),l.default.createElement(y,{content:L,labelService:R,relationId:I,agentId:w,command:T,workspaceService:M,commandService:O})))};t.CodeBlockWrapperInput=A},90103:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=e(97267),_=e(41869),v=e(89195),m=n.__importDefault(e(35553)),p=100,s=(0,o.memo)(({title:g,historyList:a,currentId:h,onNewChat:u,onHistoryItemSelect:c,onHistoryItemChange:E,onHistoryItemDelete:f,className:d})=>{const[y,b]=(0,o.useState)(null),[A,S]=(0,o.useState)(""),D=(0,o.useRef)(null),I=(0,o.useCallback)(W=>{S(W.target.value)},[A]),w=(0,o.useCallback)(W=>{c(W),S("")},[c,A]),T=(0,o.useCallback)(W=>{b({[W.id]:!0})},[y]),R=(0,o.useCallback)((W,j)=>{b({[W.id]:!1}),E(W,j)},[E,y]),M=(0,o.useCallback)(W=>{b({[W.id]:!1})},[y]),O=(0,o.useCallback)(()=>{u()},[u]);(0,o.useEffect)(()=>{var W;y&&((W=D.current)===null||W===void 0||W.focus({cursor:"end"}))},[y]);const x=(0,o.useCallback)(W=>{f(W)},[f]),k=(0,o.useCallback)(W=>{if(W<60*60*1e3){const Q=Math.floor(W/6e4);return Q===0?"Just now":`${Q}m ago`}else{if(W<24*60*60*1e3)return`${Math.floor(W/36e5)}h ago`;if(W<7*24*60*60*1e3)return`${Math.floor(W/864e5)}d ago`;if(W<30*24*60*60*1e3)return`${Math.floor(W/6048e5)}w ago`;if(W<365*24*60*60*1e3)return`${Math.floor(W/2592e6)}mo ago`}return`${Math.floor(W/(365*24*60*60*1e3))}y ago`},[]),F=(0,o.useCallback)(W=>{const j=new Date,Q=[];return W.forEach($=>{const Z=new Date($.updatedAt),G=j.getTime()-Z.getTime(),V=k(G),H=Q.find(K=>K.key===V);H?H.items.push($):Q.push({key:V,items:[$]})}),Q},[k]),L=(0,o.useCallback)(W=>o.default.createElement("div",{key:W.id,className:(0,r.default)(m.default.chat_history_item,W.id===h?m.default.chat_history_item_selected:""),onClick:()=>w(W)},o.default.createElement("div",{className:m.default.chat_history_item_content},W.loading?o.default.createElement(l.Loading,null):o.default.createElement(l.Icon,{icon:"message",style:{width:"16px",height:"16px",marginRight:4}}),y?.[W.id]?o.default.createElement(l.Input,{className:m.default.chat_history_item_title,defaultValue:W.title,ref:D,onPressEnter:j=>{R(W,j.target.value)},onBlur:()=>M(W)}):o.default.createElement("span",{id:`chat-history-item-title-${W.id}`,className:m.default.chat_history_item_title},W.title)),o.default.createElement("div",{className:m.default.chat_history_item_actions},o.default.createElement(v.EnhanceIcon,{className:(0,r.default)(m.default.chat_history_item_actions_delete,(0,l.getIcon)("delete")),onClick:j=>{j.preventDefault(),j.stopPropagation(),x(W)},ariaLabel:(0,_.localize)("aiNative.operate.chatHistory.delete")}))),[y,w,R,M,T,x,h,D]),N=(0,o.useCallback)(()=>{const W=a.slice(-p).reverse().filter(Q=>Q.title&&Q.title.includes(A)),j=F(W);return o.default.createElement("div",null,o.default.createElement(l.Input,{placeholder:(0,_.localize)("aiNative.operate.chatHistory.searchPlaceholder"),className:m.default.chat_history_search,value:A,onChange:I}),o.default.createElement("div",{className:m.default.chat_history_list},j.map(Q=>o.default.createElement("div",{key:Q.key,style:{padding:"4px"}},o.default.createElement("div",{className:m.default.chat_history_time},Q.key),Q.items.map(L)))))},[a,A,F,I,L]),U=(0,o.useCallback)(W=>W.parentElement,[]);return o.default.createElement("div",{className:(0,r.default)(m.default.chat_history_header,d)},o.default.createElement("div",{className:m.default.chat_history_header_title},o.default.createElement("span",null,g)),o.default.createElement("div",{className:m.default.chat_history_header_actions},o.default.createElement(l.Popover,{id:"chat-history-header-actions-history",content:N(),trigger:l.PopoverTriggerType.click,position:l.PopoverPosition.bottomRight,title:(0,_.localize)("aiNative.operate.chatHistory.title"),getPopupContainer:U},o.default.createElement("div",{className:m.default.chat_history_header_actions_history,title:(0,_.localize)("aiNative.operate.chatHistory.title")},o.default.createElement(v.EnhanceIcon,{className:(0,r.default)(m.default.chat_history_header_actions_history,"codicon codicon-history")}))),o.default.createElement(l.Popover,{id:"ai-chat-header-new",position:l.PopoverPosition.top,title:(0,_.localize)("aiNative.operate.newChat.title")},o.default.createElement(v.EnhanceIcon,{className:(0,r.default)(m.default.chat_history_header_actions_new,(0,l.getIcon)("plus")),onClick:O}))))});t.default=s},57987:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatInput=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=e(41869),_=e(81878),v=e(89195),m=e(83913),p=e(43718),s=e(92323),g=e(9447),a=e(72665),h=e(19413),u=e(42033),c=e(51081),E=e(27397),f=e(30703),d=n.__importDefault(e(6960)),y=8,b=68,A=({icon:w,name:T,description:R,agentId:M,command:O,selectedAgentId:x})=>{const k=(0,o.useMemo)(()=>!x&&M&&M!==c.ChatProxyService.AGENT_ID&&O?o.default.createElement("span",{className:d.default.agent_label},"@",M):null,[]);return o.default.createElement("div",{className:d.default.block},w&&o.default.createElement(v.EnhanceIcon,{className:w}),T&&o.default.createElement("span",{className:d.default.name},T),R&&o.default.createElement("span",{className:d.default.text},R),k)},S=({onClick:w,bottom:T,trigger:R,agentId:M})=>{const O=(0,l.useInjectable)(h.IChatAgentService),x=(0,l.useInjectable)(p.ChatAgentViewServiceToken),k=(0,o.useMemo)(()=>R===h.AT_SIGN_SYMBOL?x.getRenderAgents().map(L=>new u.ChatSlashCommandItemModel({icon:"",name:`${h.AT_SIGN_SYMBOL}${L.id} `,description:L.metadata.description},"",L.id)):O.getCommands().map(L=>new u.ChatSlashCommandItemModel({icon:"",name:`${h.SLASH_SYMBOL} ${L.name} `,description:L.description},L.name,L.agentId)).filter(L=>!M||L.agentId===M),[R,O]),F=(0,o.useCallback)((L,N,U)=>{w&&w(L||"",N,U)},[w]);return k.length===0?null:o.default.createElement("div",{className:d.default.instruction_options_container,style:{bottom:T+"px"}},o.default.createElement("div",{className:d.default.options},o.default.createElement("ul",null,k.map(({icon:L,name:N,nameWithSlash:U,description:W,agentId:j,command:Q})=>o.default.createElement("li",{key:`${j||""}-${N}`,onMouseDown:()=>F(U,j,Q)},o.default.createElement(A,{icon:L,name:N,description:W,agentId:j,command:Q,selectedAgentId:M}))))))},D=({themeBlock:w})=>o.default.createElement("div",{className:d.default.theme_container},o.default.createElement("div",{className:d.default.theme_block},w)),I=({agentId:w,command:T})=>o.default.createElement("div",{className:d.default.theme_container},w!==c.ChatProxyService.AGENT_ID&&o.default.createElement("div",{className:d.default.theme_block,style:{marginRight:4}},"@",w),T&&o.default.createElement("div",{className:d.default.theme_block},h.SLASH_SYMBOL," ",T));t.ChatInput=o.default.forwardRef((w,T)=>{const{onSend:R,onValueChange:M,enableOptions:O=!1,disabled:x=!1,defaultHeight:k=32,autoFocus:F,setTheme:L,theme:N,setAgentId:U,agentId:W,defaultAgentId:j,setCommand:Q,command:$,sendBtnClassName:Z}=w,G=W||j,V=(0,o.useRef)(null),H=(0,o.useRef)(null),[K,Y]=(0,o.useState)(w.value||""),[X,re]=(0,o.useState)(!1),[oe,he]=(0,o.useState)(k),[me,q]=(0,o.useState)(!1),[Ae,ge]=(0,o.useState)(!1),[te,fe]=(0,o.useState)(!1),[Oe,Me]=(0,o.useState)((0,p.localize)("aiNative.chat.input.placeholder.default")),Pe=(0,l.useInjectable)(h.IChatInternalService),Be=(0,l.useInjectable)(a.IDialogService),De=(0,l.useInjectable)(l.AINativeConfigService),_e=(0,l.useInjectable)(h.TokenMCPServerProxyService),Ne=(0,l.useInjectable)(g.MonacoCommandRegistry),Te=(0,l.useInjectable)(h.IChatAgentService),We=(0,l.useInjectable)(p.ChatFeatureRegistryToken),pe=(0,l.useInjectable)(s.CommandService),ie=(0,l.useLatest)(G),le=o.default.useCallback(()=>{pe.executeCommand(E.MCPConfigCommands.OPEN_MCP_CONFIG.id)},[pe]),Se=o.default.useCallback(async()=>{const tt=await _e.getAllMCPTools();Be.open({message:o.default.createElement(f.MCPToolsDialog,{tools:tt}),type:p.MessageType.Empty,buttons:[(0,p.localize)("dialog.file.close")]})},[_e,Be]);(0,o.useImperativeHandle)(T,()=>({setInputValue:tt=>{Y(tt),(0,p.runWhenIdle)(()=>{var st;(st=V.current)===null||st===void 0||st.focus()},120)}})),(0,o.useEffect)(()=>{w.value!==K&&Y(w.value||"")},[w.value]),(0,o.useEffect)(()=>{var tt;(tt=V.current)===null||tt===void 0||tt.focus();const st=(0,p.localize)("aiNative.chat.input.placeholder.default"),At=We.getSlashCommandHandler($);if(At&&At.providerInputPlaceholder){const Ut=Ne.getActiveCodeEditor(),_n=At.providerInputPlaceholder(K,Ut);Me(_n||st)}else Me(st)},[We,$]),(0,o.useEffect)(()=>{Ve(N||"",G,$)},[N,G,$]),(0,o.useEffect)(()=>{var tt;V&&F&&((tt=V.current)===null||tt===void 0||tt.focus())},[V,F,w.value]),(0,o.useEffect)(()=>{if(O&&((K===h.SLASH_SYMBOL||K===h.AT_SIGN_SYMBOL&&Te.getAgents().length>0)&&!te?re(!0):re(!1)),K.startsWith(h.SLASH_SYMBOL)){const{value:tt,nameWithSlash:st}=We.parseSlashCommand(K);if(st){const At=We.getSlashCommandBySlashName(st);Y(tt),L(st),At&&(U(At.agentId),Q(At.command));return}}if(Te.getAgents().length){const tt=Te.parseMessage(K,ie.current);(tt.agentId||tt.command)&&(L(""),Y(tt.message),tt.agentId&&U(tt.agentId),tt.command&&Q(tt.command))}},[V,K,O,We]),(0,o.useEffect)(()=>{K||(he(k),ge(!1),fe(!1))},[K]);const ye=(0,o.useCallback)(tt=>{Y(tt),M&&M(tt)},[]),Ue=(0,o.useCallback)(()=>{Pe.cancelRequest()},[]),Ye=(0,o.useCallback)(async()=>{if(x)return;const tt=(st=K)=>{R(st,[],G,$),Y(""),L(""),U(""),Q("")};if($){const st=We.getSlashCommandHandler($);if(st&&st.execute){const At=Ne.getActiveCodeEditor();await st.execute(K,Ut=>tt(Ut),At);return}}tt()},[R,K,G,$,We]),Ve=(0,o.useCallback)((tt,st,At)=>{if(st){if(re(!1),L(""),U(st),Q(At||""),V?.current){const Ut=V.current.value;(Ut===h.AT_SIGN_SYMBOL||At&&Ut===h.SLASH_SYMBOL)&&Y(""),(0,p.runWhenIdle)(()=>V.current.focus())}}else if(tt){re(!1),U(""),Q("");const Ut=We.getSlashCommandBySlashName(tt);if(L(Ut?Ut.nameWithSlash:""),V&&V.current){const _n=V.current.value;_n.length===1&&_n.startsWith(h.SLASH_SYMBOL)&&Y(""),(0,p.runWhenIdle)(()=>V.current.focus())}}},[V,We]),pt=(0,o.useMemo)(()=>{const tt=y+oe;return te&&re(!1),tt},[oe]),vt=tt=>{var st,At;if(tt.key==="Backspace"&&((st=V.current)===null||st===void 0?void 0:st.selectionEnd)===0&&((At=V.current)===null||At===void 0?void 0:At.selectionStart)===0){if(L(""),G===c.ChatProxyService.AGENT_ID){Q(""),U("");return}G&&($?Q(""):U(""))}},xt=(0,o.useCallback)(tt=>{he(tt),tt>b?ge(!0):ge(!1)},[]),lt=(0,o.useCallback)(()=>{q(!1),re(!1)},[V]),wt=(0,o.useCallback)(()=>{q(!0)},[V]),at=(0,o.useCallback)(()=>{const tt=te;if(fe(!tt),tt)he(k),ge(!1);else{const At=document.querySelector("#ai_chat_left_container").clientHeight-68-(N?32:0)-16;he(At)}},[te]);return o.default.createElement("div",{className:(0,r.default)(d.default.chat_input_container,me?d.default.active:null)},X&&o.default.createElement("div",{ref:H},o.default.createElement(S,{onClick:Ve,bottom:pt,trigger:K,agentId:G})),N&&o.default.createElement(D,{themeBlock:N}),G&&o.default.createElement(I,{agentId:G,command:$}),Ae&&o.default.createElement("div",{className:d.default.expand_icon,onClick:()=>at()},o.default.createElement(_.Popover,{id:"ai_chat_input_expand",title:(0,p.localize)(te?"aiNative.chat.expand.unfullscreen":"aiNative.chat.expand.fullescreen")},o.default.createElement(_.Icon,{className:(0,r.default)(te?(0,_.getIcon)("unfullscreen"):(0,_.getIcon)("fullescreen"))}))),o.default.createElement(m.InteractiveInput,{ref:V,placeholder:Oe,value:K,onKeyDown:vt,onBlur:lt,onFocus:wt,onValueChange:ye,disabled:x,className:d.default.input_wrapper,onSend:Ye,onStop:Ue,sendBtnClassName:Z,onHeightChange:xt,height:oe,popoverPosition:_.PopoverPosition.left}),o.default.createElement("div",{className:d.default.chat_input_footer},De.capabilities.supportsMCP&&o.default.createElement("div",{className:d.default.mcp_desc},o.default.createElement(_.Popover,{overlayClassName:d.default.popover_icon,id:"ai-chat-header-mcp-server",position:_.PopoverPosition.left,title:"MCP Server"},o.default.createElement(v.EnhanceIcon,{wrapperClassName:d.default.action_btn,className:"codicon codicon-radio-tower",onClick:le,tabIndex:0,role:"button",ariaLabel:"MCP Server"})),o.default.createElement(_.Popover,{overlayClassName:d.default.popover_icon,id:"ai-chat-header-tools",position:_.PopoverPosition.left,title:(0,p.localize)("aiNative.operate.tools.title")},o.default.createElement(v.EnhanceIcon,{wrapperClassName:d.default.action_btn,className:(0,_.getIcon)("menubar-tool"),onClick:Se,tabIndex:0,role:"button",ariaLabel:(0,p.localize)("aiNative.operate.tools.title")})))))})},56474:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatMarkdown=void 0,t.postProcessCodeBlockLanguageId=a,t.fillInIncompleteTokens=h;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=e(13719),_=e(84605),v=e(41869),m=e(90684),p=e(25834),s=n.__importDefault(e(6960)),g=T=>{const R=(0,o.useRef)(null),M=(0,v.useInjectable)(v.AppConfig),[O,x]=(0,o.useState)(),[k,F]=(0,o.useState)();return(0,o.useEffect)(()=>{var L;if(!R.current)return;const U=typeof T.markdown=="string"?new m.MarkdownString(T.markdown):T.markdown,W=new l.MarkdownReactRenderer;W.code=(V,H)=>{const K=a(H);return o.default.createElement("div",{className:s.default.code},o.default.createElement(v.ConfigProvider,{value:M},o.default.createElement("div",{className:s.default.code_block},o.default.createElement("div",{className:(0,r.default)(s.default.code_language,"language-badge")},K),o.default.createElement(p.CodeEditorWithHighlight,{input:V,language:K,relationId:T.relationId||"",agentId:T.agentId,command:T.command,hideInsert:T.hideInsert}))))},W.codespan=V=>o.default.createElement("code",{className:s.default.code_inline},V);const j=new l.MarkdownReactParser({renderer:W}),Q={..._.marked.defaults,...T.markedOptions,renderer:j,smartypants:!1};let $=(L=U.value)!==null&&L!==void 0?L:"";$.length>1e5&&($=`${$.slice(0,1e5)}\u2026`);let Z,G;if(T.fillInIncompleteTokens){const V=_.marked.lexer($,Q),H=h(V);Z=_.marked.parser(H,Q),G=H}else{const V=_.marked.lexer($,Q);Z=_.marked.parser(V,Q),G=V}F(G),x(j)},[T.markdown]),o.default.createElement("div",{className:(0,r.default)(s.default.markdown_container,T.className),ref:R,tabIndex:0},k&&O&&O.parse(k))};t.ChatMarkdown=g;function a(T){if(!T)return"";const R=T.split(/[\s+|:|,|\{|\?]/,1);return R.length?R[0]:T}function h(T){let R,M;for(R=0;R<T.length;R++){const O=T[R];if(O.type==="paragraph"&&O.raw.match(/(\n|^)```/)){M=u(T.slice(R));break}if(O.type==="paragraph"&&O.raw.match(/(\n|^)\|/)){M=D(T.slice(R));break}if(O.type==="paragraph"&&R===T.length-1){const x=w(O);if(x){M=[x];break}}}if(M){const O=[...T.slice(0,R),...M];return O.links=T.links,O}return T}function u(T){const R=I(T);return _.marked.lexer(R+"\n```")}function c(T){return S(T,"`")}function E(T){return S(T,"*")}function f(T){return S(T,"_")}function d(T){return S(T,")")}function y(T){return S(T,"](about:blank)")}function b(T){return S(T,"**")}function A(T){return S(T,"__")}function S(T,R){const M=I(Array.isArray(T)?T:[T]);return _.marked.lexer(M+R)[0]}function D(T){const R=I(T),M=R.split(`
32961
32961
  `);let O=0,x=!1;for(let k=0;k<M.length;k++){const F=M[k].trim();if(typeof O>"u"&&F.match(/^\s*\|/)){const L=F.match(/(\|[^\|]+)(?=\||$)/g);L&&(O=L.length)}else if(typeof O=="number")if(F.match(/^\s*\|/)&&k===M.length-1)x=!0;else return}if(O>0){const k=x?M.slice(0,-1).join(`
32962
32962
  `):R,F=!!k.match(/\|\s*$/),L=k+(F?"":"|")+`
@@ -33071,10 +33071,10 @@ ${A.slice(1).join(`
33071
33071
  `).slice(c.startPosition.row);return`${f[0].slice(c.startPosition.column)}${f.length>1?`
33072
33072
  ${f.slice(1).join(`
33073
33073
  `)}`:""}`}}return a.text}findTypeIdentifier(a){let h=a;for(;h;){if(h.type==="type_identifier")return h.text;const u=h.child(1);if(!u)break;h=u}return""}async extractImportPaths(a){var h;const u=[],c=await this.parser.parse(a),E=c?.rootNode,f=[],d=[];if(E)for(let y=0;y<E?.childCount;y++){const b=E.child(y);if(b?.type==="import_statement")f.push(b);else if(b?.type==="type_annotation"){const A=b.child(1);A&&d.push(A.text)}else if(b?.type==="lexical_declaration"){const A=this.findTypeIdentifier(b);A&&d.push(A)}}for(const y of f)if(d.some(b=>y.text.includes(b))){let b=(h=y.child(3))===null||h===void 0?void 0:h.text;(b?.includes("'")||b?.includes('"'))&&(b=b.slice(1,-1)),b&&u.push(b)}return u}async extractInterfaceOrTypeCode(a){var h;const u=[];if(this.language==="typescript"){await this.parserLoaded.promise;const c=(h=this.parser)===null||h===void 0?void 0:h.parse(a),E=c?.rootNode;if(E)for(let f=0;f<E?.childCount;f++){const d=E.child(f);if(d?.type==="export_statement"){const y=d.child(1);(y?.type==="interface_declaration"||y?.type==="type_alias_declaration")&&u.push(y.text)}else(d?.type==="interface_declaration"||d?.type==="type_alias_declaration")&&u.push(d.text)}}return u}async findSyntaxErrorCount(a){var h;await this.parserLoaded.promise;const u=(h=this.parser)===null||h===void 0?void 0:h.parse(a),c=u?.rootNode;if(!c)return 0;let E=0;const f=d=>{(d.type==="function_declaration"||d.type==="class_declaration"||d.type==="variable_declarator"||d.type==="statement_block"||d.type==="expression_statement")&&(d.hasError||d.isMissing||d.type==="ERROR")&&E++;for(let b=0;b<d.childCount;b++){const A=d.child(b);A&&f(A)}};return f(c),E}async findNearestCodeBlockWithPosition(a,h){const u=await this.parser.parse(a);if(u){const{rootNode:c}=u,E=c.namedDescendantForIndex(h),f=this.findContainingCodeBlockWithPosition(E,h);if(!f)return null;let y=a.split(`
33074
- `).slice(0,f.startPosition.row).reduce((b,A)=>b+A.length,0);return y+=f.startPosition.row,y+=f.startPosition.column,{codeBlock:f.text,range:{start:{line:f.startPosition.row,character:0},end:{line:f.endPosition.row,character:1/0}},offset:y,type:f.startPosition.row===f.endPosition.row?_.NearestCodeBlockType.Line:_.NearestCodeBlockType.Block}}return null}dispose(){this.parser.delete(),this.lruCache.clear()}};t.LanguageParser=s,n.__decorate([(0,o.Autowired)(p.WasmModuleManager),n.__metadata("design:type",p.WasmModuleManager)],s.prototype,"wasmModuleManager",void 0),n.__decorate([(0,o.Autowired)(m.TreeSitterLanguageFacts),n.__metadata("design:type",m.TreeSitterLanguageFacts)],s.prototype,"languageFacts",void 0),t.LanguageParser=s=n.__decorate([(0,o.Injectable)({multiple:!0}),n.__metadata("design:paramtypes",[String])],s)},85679:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LanguageParserService=void 0;const n=e(85608),r=e(76003),o=e(3073),l=e(22486);let _=class{constructor(){this.pool=new Map}createParser(m){const p=l.parserNameMap[m];if(p)return this.pool.has(p)||this.pool.set(p,this.injector.get(o.LanguageParser,[p])),this.pool.get(p)}dispose(){this.pool.forEach(m=>m.dispose()),this.pool.clear()}};t.LanguageParserService=_,n.__decorate([(0,r.Autowired)(r.INJECTOR_TOKEN),n.__metadata("design:type",r.Injector)],_.prototype,"injector",void 0),t.LanguageParserService=_=n.__decorate([(0,r.Injectable)()],_)},53374:(P,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toMonacoRange=e;function e(n){return{startLineNumber:n.startPosition.row+1,startColumn:n.startPosition.column+1,endLineNumber:n.endPosition.row+1,endColumn:n.endPosition.column+1}}},19584:(P,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GolangLanguageFacts=void 0;const e=["function_declaration","method_declaration","block","if_statement","else_statement","switch_statement","case_clause","for_statement","range_clause","type_switch_statement","type_case_clause","comm_clause","select_statement","go_statement","defer_statement"],n=new Set(e);class r{constructor(){this.name="go",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return n}isCodeBlock(l){return n.has(l)}}t.GolangLanguageFacts=r},22486:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TreeSitterLanguageFacts=t.knownLanguageFacts=void 0;const n=e(85608);n.__exportStar(e(17973),t);const r=e(76003),o=e(19584),l=e(44606),_=e(82381),v=e(41486),m=e(98588),p=e(96436),s=e(2349),g=e(78542),a=new Set;t.knownLanguageFacts=[o.GolangLanguageFacts,l.JavaLanguageFacts,_.JavaScriptLanguageFacts,v.JavaScriptReactLanguageFacts,m.PythonLanguageFacts,p.RustLanguageFacts,s.TypeScriptLanguageFacts,g.TypeScriptReactLanguageFacts];let h=class{constructor(){this.langs=new Map,t.knownLanguageFacts.forEach(c=>{const E=new c;this.langs.set(E.name,E)})}isCodeBlock(c,E){const f=this.langs.get(c);return f&&f.isCodeBlock?f.isCodeBlock(E):!1}isFunctionCodeBlock(c,E){const f=this.langs.get(c);return f&&f.isFunctionCodeBlocks?f.isFunctionCodeBlocks(E):!1}provideFunctionInfo(c,E){const f=this.langs.get(c);return f&&f.provideFunctionInfo?f.provideFunctionInfo(E):null}getCodeBlockTypes(c){const E=this.langs.get(c);return E?E.provideCodeBlocks():a}};t.TreeSitterLanguageFacts=h,t.TreeSitterLanguageFacts=h=n.__decorate([(0,r.Injectable)(),n.__metadata("design:paramtypes",[])],h)},44606:(P,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JavaLanguageFacts=void 0;const e=["compilation_unit","class_declaration","interface_declaration","enum_declaration","method_declaration","constructor_declaration","block","static_initializer","instance_initializer","if_statement","switch_statement","while_statement","do_statement","for_statement","enhanced_for_statement","try_statement","catch_clause","finally_clause"],n=new Set(["method_declaration","constructor_declaration"]),r=new Set(e);class o{constructor(){this.name="java",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return r}isCodeBlock(_){return r.has(_)}isFunctionCodeBlocks(_){return n.has(_)}}t.JavaLanguageFacts=o},82381:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JavaScriptLanguageFacts=t.functionBlockCodeTypes=t.javascriptBlockCodeTypes=void 0;const n=e(53374);t.javascriptBlockCodeTypes=["function","function_declaration","function_expression","arrow_function","class_declaration","method_definition","if_statement","switch_case","while_statement","do_statement","for_statement","for_in_statement","try_statement","catch_clause","block","export_statement","lexical_declaration"],t.functionBlockCodeTypes=["function","function_declaration","function_expression","arrow_function","method_definition"];const r=new Set(t.functionBlockCodeTypes),o=new Set(t.javascriptBlockCodeTypes);class l{constructor(){this.name="javascript",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return o}isCodeBlock(v){return o.has(v)}isFunctionCodeBlocks(v){return r.has(v)}provideFunctionInfo(v){var m,p,s;switch(v.type){case"function_declaration":case"function_expression":return{infoCategory:"function",type:v.type,name:((m=v.firstNamedChild)===null||m===void 0?void 0:m.text)||"",signatures:v.children.filter(g=>g.type==="parameter").map(g=>{var a;return((a=g.firstChild)===null||a===void 0?void 0:a.text)||""}),range:(0,n.toMonacoRange)(v)};case"arrow_function":{const g=v.parent;return g&&g.type==="variable_declarator"&&g.parent&&(g.parent.type==="lexical_declaration"||g.parent.type==="export_statement"||g.parent.type==="variable_declaration")?{infoCategory:"function",type:v.type,name:((p=g.firstChild)===null||p===void 0?void 0:p.text)||"",signatures:v.children.filter(a=>a.type==="parameter").map(a=>{var h;return((h=a.firstChild)===null||h===void 0?void 0:h.text)||""}),range:(0,n.toMonacoRange)(g.parent)}:null}case"method_definition":return{infoCategory:"function",type:v.type,name:((s=v.firstNamedChild)===null||s===void 0?void 0:s.text)||"",signatures:v.children.filter(g=>g.type==="parameter").map(g=>{var a;return((a=g.firstChild)===null||a===void 0?void 0:a.text)||""}),range:(0,n.toMonacoRange)(v)}}return null}}t.JavaScriptLanguageFacts=l},41486:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JavaScriptReactLanguageFacts=t.javascriptreactBlockCodeTypes=void 0;const n=e(82381);t.javascriptreactBlockCodeTypes=[...n.javascriptBlockCodeTypes,"jsx_element","jsx_self_closing_element","jsx_expression","jsx_fragment"];const r=new Set(t.javascriptreactBlockCodeTypes);class o{constructor(){this.name="jsx",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return r}isCodeBlock(_){return r.has(_)}}t.JavaScriptReactLanguageFacts=o},98588:(P,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PythonLanguageFacts=t.pythonBlockCodeTypes=void 0,t.pythonBlockCodeTypes=["function_definition","class_definition","compound_statement","if_statement","elif_clause","else_clause","for_statement","while_statement","try_statement","except_clause","with_statement","decorated_definition"];const e=new Set(t.pythonBlockCodeTypes);class n{constructor(){this.name="python",this.listCommentStyle="# ",this.blockCommentStyle={start:"'''",end:"'''",linePrefix:""}}provideCodeBlocks(){return e}isCodeBlock(o){return e.has(o)}}t.PythonLanguageFacts=n},96436:(P,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RustLanguageFacts=t.rustBlockCodeTypes=void 0,t.rustBlockCodeTypes=["function_item","impl_item","trait_item","block","if_expression","match_expression","while_expression","loop_expression","for_expression","closure_expression","struct_item","enum_item","union_item","mod_item"];const e=new Set(t.rustBlockCodeTypes);class n{constructor(){this.name="rust",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return e}isCodeBlock(o){return e.has(o)}}t.RustLanguageFacts=n},17973:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parserIdentifierMap=t.parserNameMap=void 0;const r=e(85608).__importDefault(e(19891)),o={typescript:"typescript",typescriptreact:"tsx",javascript:"javascript",javascriptreact:"jsx",rust:"rust",python:"python",java:"java",go:"go"};t.parserNameMap=o,t.parserIdentifierMap=(0,r.default)(t.parserNameMap)},2349:(P,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TypeScriptLanguageFacts=t.typescriptBlockTypes=void 0,t.typescriptBlockTypes=["function","function_declaration","function_expression","arrow_function","class_declaration","interface_declaration","method_definition","method_signature","enum_declaration","type_alias_declaration","lexical_declaration","if_statement","switch_case","while_statement","do_statement","for_statement","for_in_statement","for_of_statement","try_statement","catch_clause","block","module","public_field_definition","private_field_definition","export_statement"];const e=new Set(t.typescriptBlockTypes);class n{constructor(){this.name="typescript",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return e}isCodeBlock(o){return e.has(o)}}t.TypeScriptLanguageFacts=n},78542:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TypeScriptReactLanguageFacts=t.typescriptreactBlockTypes=void 0;const n=e(2349);t.typescriptreactBlockTypes=[...n.typescriptBlockTypes,"jsx_element","jsx_self_closing_element","jsx_expression","jsx_fragment"];const r=new Set(t.typescriptreactBlockTypes);class o{constructor(){this.name="tsx",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return r}isCodeBlock(_){return r.has(_)}}t.TypeScriptReactLanguageFacts=o},67045:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WasmModuleManager=void 0;const n=e(85608),r=n.__importDefault(e(13833)),o=e(76003),l=e(6858),_=e(70392);let v=class{async resolveResourceUri(){const p=await this.rendererRuntime.provideResourceUri(l.EKnownResources.TreeSitterWasmDirectory);this.resolvedResourceUriDeferred.resolve(p)}constructor(){this.resolvedResourceUriDeferred=new _.Deferred,this.cachedRuntime=new Map,this.parserInitialized=!1,this.resolveResourceUri()}async initParser(){const p=await this.resolvedResourceUriDeferred.promise;let s;return p.endsWith("/")?s=`${p}tree-sitter.wasm`:s=`${p}/tree-sitter.wasm`,this.parserInitialized||(await r.default.init({locateFile:()=>s}),this.parserInitialized=!0),new r.default}async loadLanguage(p){if(!this.cachedRuntime.has(p)){const s=new _.Deferred;this.cachedRuntime.set(p,s);const g=await this.resolvedResourceUriDeferred.promise;let a;g.endsWith("/")?a=`${g}tree-sitter-${p}.wasm`:a=`${g}/tree-sitter-${p}.wasm`,fetch(a).then(h=>h.arrayBuffer()).then(h=>{s.resolve(h)})}return this.cachedRuntime.get(p).promise}};t.WasmModuleManager=v,n.__decorate([(0,o.Autowired)(l.RendererRuntime),n.__metadata("design:type",l.RendererRuntime)],v.prototype,"rendererRuntime",void 0),t.WasmModuleManager=v=n.__decorate([(0,o.Injectable)(),n.__metadata("design:paramtypes",[])],v)},4972:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AIRightTabRenderer=t.AILeftTabRenderer=t.AIChatTabRendererWithTab=t.AIChatTabRenderer=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=e(41869),_=e(89195),v=e(1149),m=e(43718),p=e(11090),s=e(63067),g=e(46245),a=e(66368),h=e(19951),u=e(752),c=e(19413),E=n.__importDefault(e(87708)),f=()=>o.default.createElement("div",{style:{width:0}},o.default.createElement(g.TabbarViewBase,{tabSize:0,MoreTabView:g.IconElipses,TabView:g.IconTabView,barSize:0,panelBorderSize:0})),d=({className:D,components:I})=>o.default.createElement(h.TabRendererBase,{side:c.AI_CHAT_VIEW_ID,direction:"left-to-right",id:E.default.ai_chat_panel,className:(0,r.default)(D,`${c.AI_CHAT_VIEW_ID}-slot`),components:I,TabbarView:()=>o.default.createElement(f,null),TabpanelView:()=>o.default.createElement(a.BaseTabPanelView,{PanelView:a.ContainerView,PanelViewProps:{className:E.default.ai_chat_view_container}})});t.AIChatTabRenderer=d;const y=({className:D,components:I})=>o.default.createElement(h.TabRendererBase,{side:c.AI_CHAT_VIEW_ID,direction:"right-to-left",id:E.default.ai_chat_panel,className:(0,r.default)(D,`${c.AI_CHAT_VIEW_ID}-slot`,"design_right_slot"),components:I,TabbarView:()=>o.default.createElement(g.ChatTabbarRenderer2,null),TabpanelView:()=>o.default.createElement(a.BaseTabPanelView,{PanelView:a.ContainerView,PanelViewProps:{className:E.default.ai_chat_view_container}})});t.AIChatTabRendererWithTab=y;const b=({className:D,components:I})=>o.default.createElement(p.DesignLeftTabRenderer,{className:D,components:I,tabbarView:A});t.AILeftTabRenderer=b;const A=()=>{const D=(0,l.useInjectable)(s.IMainLayoutService),I=(0,l.useInjectable)(u.TabbarServiceFactory)(l.SlotLocation.extendView),w=(0,l.useAutorun)(I.currentContainerId),T=o.default.useMemo(()=>D.getExtraMenu(),[D]),[R]=(0,l.useContextMenus)(T),M=(0,o.useCallback)(({renderContainers:O})=>{const x=I.visibleContainers.filter(k=>{var F;return!(!((F=k.options)===null||F===void 0)&&F.hideTab)});return o.default.createElement(o.default.Fragment,null,x.length>0&&o.default.createElement(_.HorizontalVertical,{margin:"8px auto 0px",width:"60%"}),x.map(k=>O(k,I,w)))},[w,I]);return o.default.createElement(g.LeftTabbarRenderer,{renderOtherVisibleContainers:M,isRenderExtraTopMenus:!1,renderExtraMenus:o.default.createElement("div",{className:E.default.extra_bottom_icon_container},R.length>=0?R.map(O=>o.default.createElement(_.EnhanceIconWithCtxMenu,{key:O.id,id:O.id,wrapperClassName:E.default.extra_bottom_icon,iconClass:O.icon,menuNodes:O.children,skew:{x:-8,y:-4}})):null)})},S=({components:D})=>{const I=(0,l.useInjectable)(u.TabbarServiceFactory)(l.SlotLocation.extendView),w=(0,l.useInjectable)(v.DesignLayoutConfig),T=(0,o.useCallback)(()=>{I.updateCurrentContainerId("")},[]),R=(0,o.useCallback)(O=>{const{component:x}=O,{options:k}=x;return o.default.createElement(a.ContainerView,{...O,customTitleBar:o.default.createElement("div",{className:E.default.header},o.default.createElement("span",{className:E.default.title},k&&k.title),o.default.createElement("div",{className:E.default.side},o.default.createElement(_.EnhancePopover,{id:"ai_right_panel_header_close",title:(0,m.localize)("editor.title.context.close")},o.default.createElement(_.EnhanceIcon,{icon:"close",onClick:T})))),renderContainerWrap:({children:F})=>o.default.createElement("div",{className:E.default.right_slot_container_wrap},o.default.createElement("div",{className:E.default.container},F))})},[]),M=(0,o.useMemo)(()=>w.useMergeRightWithLeftPanel?E.default.right_tab_renderer:"",[w]);return o.default.createElement(p.DesignRightTabRenderer,{components:D,className:M,tabbarView:()=>o.default.createElement(g.RightTabbarRenderer,{barSize:0,style:{width:0}}),tabpanelView:()=>o.default.createElement(a.BaseTabPanelView,{PanelView:R})})};t.AIRightTabRenderer=S},82983:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AIChatLogoAvatar=void 0;const n=e(85608),r=n.__importDefault(e(14041)),o=e(41869),l=e(89195),_=e(63067),v=e(19413),m=n.__importDefault(e(88473)),p=()=>{const s=(0,o.useInjectable)(_.IMainLayoutService),g=r.default.useCallback(()=>{s.toggleSlot(v.AI_CHAT_VIEW_ID)},[s]);return r.default.createElement("div",{className:m.default.ai_switch,onClick:g},r.default.createElement(l.AILogoAvatar,{iconClassName:m.default.avatar_icon_large}))};t.AIChatLogoAvatar=p},73974:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseApplyService=void 0;const n=e(85608),r=e(41429),o=e(76003),l=e(41869),_=e(54414),v=e(57517),m=e(55126),p=e(20868),s=e(70392),g=e(2261),a=e(19413),h=e(59347),u=e(40111),c=e(15989);class E extends l.WithEventBus{constructor(){super(),this.onCodeBlockUpdateEmitter=new s.Emitter,this.onCodeBlockUpdate=this.onCodeBlockUpdateEmitter.event,this.activePreviewerMap=this.registerDispose(new s.DisposableMap),this.editorListenerMap=this.registerDispose(new s.DisposableMap),this.addDispose(this.chatInternalService.onCancelRequest(()=>{const d=this.chatInternalService.sessionModel.history.lastMessageId;if(!d)return;const y=this.getMessageCodeBlocks(d);y&&Object.values(y).forEach(b=>{this.cancelApply(b)})})),this.currentSessionId=this.chatInternalService.sessionModel.sessionId,this.addDispose(this.chatInternalService.onChangeSession(d=>{d!==this.currentSessionId&&(this.cancelAllApply(),this.currentSessionId=d)})),this.addDispose(this.chatInternalService.onRegenerateRequest(()=>{const d=this.chatInternalService.sessionModel.history.getMessages(),y=d[d.length-1].id,b=this.getMessageCodeBlocks(y);b&&Object.values(b).forEach(A=>{this.cancelApply(A)})})),this.addDispose(this.chatInternalService.onWillClearSession(d=>{this.cancelAllApply(d)}))}getMessageCodeBlocks(d,y){y=y||this.chatInternalService.sessionModel.sessionId;const b=this.chatInternalService.getSession(y);if(!b)throw new Error(`Session ${y} not found`);const A=b.history.getMessageAdditional(d);return A?.codeBlockMap}onEditorGroupClose(d){const y=s.path.relative(this.appConfig.workspaceDir,d.payload.resource.uri.path.toString());this.activePreviewerMap.get(y)&&this.activePreviewerMap.disposeKey(y),this.editorListenerMap.disposeKey(d.payload.resource.uri.toString())}async onEditorGroupOpen(d){var y;const b=s.path.relative(this.appConfig.workspaceDir,d.payload.resource.uri.path.toString());if(this.duringApply||this.activePreviewerMap.has(b)||!this.chatInternalService.sessionModel.history.getMessages().length)return;const A=((y=this.getUriCodeBlocks(d.payload.resource.uri))===null||y===void 0?void 0:y.filter(S=>S.status==="pending"))||[];if(A.length>0&&A[0].updatedCode){const S=d.payload.group.codeEditor.monacoEditor;await this.renderApplyResult(S,A[0],A[0].updatedCode)}}get currentPreviewer(){var d;const y=(d=this.editorService.currentEditor)===null||d===void 0?void 0:d.currentUri;if(y)return this.activePreviewerMap.get(s.path.relative(this.appConfig.workspaceDir,y.path.toString()))}getUriCodeBlocks(d){const y=this.getSessionCodeBlocks(),b=s.path.relative(this.appConfig.workspaceDir,d.path.toString());return y.filter(A=>A.relativePath===b).sort((A,S)=>S.version-A.version)}getPendingPaths(d){return this.getSessionCodeBlocks(d).filter(b=>b.status==="pending").map(b=>b.relativePath)}getSessionCodeBlocks(d){const y=d?this.chatInternalService.getSession(d):this.chatInternalService.sessionModel;if(!y)throw new Error(`Session ${d} not found`);const b=y.history.sessionAdditionals;return Array.from(b.values()).map(A=>A.codeBlockMap||{}).reduce((A,S)=>(Object.values(S).forEach(D=>{A.push(D)}),A),[])}getCodeBlock(d,y){if(y=y||this.chatInternalService.sessionModel.history.lastMessageId,!y)throw new Error("Message ID is required");const b=this.getMessageCodeBlocks(y);if(b)return b[d]}updateCodeBlock(d){const y=d.messageId,b=this.getMessageCodeBlocks(y);if(!b)throw new Error("Code block not found");b[d.toolCallId]=d,this.chatInternalService.sessionModel.history.setMessageAdditional(y,{codeBlockMap:b}),this.onCodeBlockUpdateEmitter.fire(d)}async registerCodeBlock(d,y,b,A){var S,D;const I=this.chatInternalService.sessionModel.history.lastMessageId,w=this.getUriCodeBlocks(s.URI.file(s.path.join(this.appConfig.workspaceDir,d))),T=await this.editorDocumentModelService.createModelReference(s.URI.file(s.path.join(this.appConfig.workspaceDir,d))),R={codeEdit:y,relativePath:d,status:"generating",iterationCount:1,version:1,createdAt:Date.now(),toolCallId:b,messageId:I,instructions:A,originalCode:T.instance.getText()};if(w?.length){R.version=w.length+1;for(const O of w)if(O.relativePath===d&&(!((D=(S=O.applyResult)===null||S===void 0?void 0:S.diagnosticInfos)===null||D===void 0)&&D.length))R.iterationCount++;else break}const M=this.getMessageCodeBlocks(I)||{};return M[b]=R,this.chatInternalService.sessionModel.history.setMessageAdditional(I,{codeBlockMap:M}),this.onCodeBlockUpdateEmitter.fire(R),R}async apply(d){var y,b;try{if(this.duringApply=!0,d.iterationCount>3)throw new Error("Lint error max iteration count exceeded");const A=d.originalCode?await this.doApply(d):{result:d.codeEdit};if(!A.stream&&!A.result)return d.status="failed",this.updateCodeBlock(d),d;this.activePreviewerMap.has(d.relativePath)&&(this.editorListenerMap.disposeKey(s.URI.file(s.path.join(this.appConfig.workspaceDir,d.relativePath)).toString()),this.activePreviewerMap.disposeKey(d.relativePath));const S=await this.editorService.open(s.URI.file(s.path.join(this.appConfig.workspaceDir,d.relativePath)));if(!S)throw new Error("Failed to open file");const D=await this.renderApplyResult(S.group.codeEditor.monacoEditor,d,A.result||A.stream,A.range);if(d.updatedCode=D.updatedCode,d.status="pending",this.postApplyHandler&&typeof this.postApplyHandler=="function")try{await this.postApplyHandler(S.group.codeEditor.monacoEditor)}catch{}const I=S.group.codeEditor.monacoEditor.getModel(),w=this.getDiagnosticInfos(I.uri.toString(),((y=D.result)===null||y===void 0?void 0:y.rangesFromDiffHunk)||[]);return D.result&&(d.applyResult={diff:(b=D.result)===null||b===void 0?void 0:b.diff,diagnosticInfos:w}),this.updateCodeBlock(d),d}catch(A){throw d.status="failed",this.updateCodeBlock(d),A}finally{this.duringApply=!1}}async renderApplyResult(d,y,b,A){var S,D,I;const w=new s.Deferred,T=c.InlineDiffController.get(d);if(A=A||d.getModel().getFullModelRange(),typeof b=="string"){const R=b,M=d.getModel().getValue(),O=s.URI.file(s.path.join(this.appConfig.workspaceDir,y.relativePath)),x=this.editorDocumentModelService.getModelReference(O);(M!==R||x?.instance.dirty)&&((S=d.getModel())===null||S===void 0||S.pushEditOperations([],[g.EditOperation.replace(A,R)],()=>null),await this.editorService.save(O));const k=(D=this.getUriCodeBlocks(O))===null||D===void 0?void 0:D.filter(W=>W.status==="pending"),F=k?.[k.length-1];if(((I=F||y)===null||I===void 0?void 0:I.originalCode)===R)throw new Error("No changes applied");const L=T.createDiffPreviewer(d,p.Selection.fromRange(A,p.SelectionDirection.LTR),{disposeWhenEditorClosed:!0,renderRemovedWidgetImmediately:!0,reverse:!0});this.activePreviewerMap.set(y.relativePath,L),L.setValue(F?.originalCode||y.originalCode||`
33074
+ `).slice(0,f.startPosition.row).reduce((b,A)=>b+A.length,0);return y+=f.startPosition.row,y+=f.startPosition.column,{codeBlock:f.text,range:{start:{line:f.startPosition.row,character:0},end:{line:f.endPosition.row,character:1/0}},offset:y,type:f.startPosition.row===f.endPosition.row?_.NearestCodeBlockType.Line:_.NearestCodeBlockType.Block}}return null}dispose(){this.parser.delete(),this.lruCache.clear()}};t.LanguageParser=s,n.__decorate([(0,o.Autowired)(p.WasmModuleManager),n.__metadata("design:type",p.WasmModuleManager)],s.prototype,"wasmModuleManager",void 0),n.__decorate([(0,o.Autowired)(m.TreeSitterLanguageFacts),n.__metadata("design:type",m.TreeSitterLanguageFacts)],s.prototype,"languageFacts",void 0),t.LanguageParser=s=n.__decorate([(0,o.Injectable)({multiple:!0}),n.__metadata("design:paramtypes",[String])],s)},85679:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LanguageParserService=void 0;const n=e(85608),r=e(76003),o=e(3073),l=e(22486);let _=class{constructor(){this.pool=new Map}createParser(m){const p=l.parserNameMap[m];if(p)return this.pool.has(p)||this.pool.set(p,this.injector.get(o.LanguageParser,[p])),this.pool.get(p)}dispose(){this.pool.forEach(m=>m.dispose()),this.pool.clear()}};t.LanguageParserService=_,n.__decorate([(0,r.Autowired)(r.INJECTOR_TOKEN),n.__metadata("design:type",r.Injector)],_.prototype,"injector",void 0),t.LanguageParserService=_=n.__decorate([(0,r.Injectable)()],_)},53374:(P,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toMonacoRange=e;function e(n){return{startLineNumber:n.startPosition.row+1,startColumn:n.startPosition.column+1,endLineNumber:n.endPosition.row+1,endColumn:n.endPosition.column+1}}},19584:(P,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GolangLanguageFacts=void 0;const e=["function_declaration","method_declaration","block","if_statement","else_statement","switch_statement","case_clause","for_statement","range_clause","type_switch_statement","type_case_clause","comm_clause","select_statement","go_statement","defer_statement"],n=new Set(e);class r{constructor(){this.name="go",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return n}isCodeBlock(l){return n.has(l)}}t.GolangLanguageFacts=r},22486:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TreeSitterLanguageFacts=t.knownLanguageFacts=void 0;const n=e(85608);n.__exportStar(e(17973),t);const r=e(76003),o=e(19584),l=e(44606),_=e(82381),v=e(41486),m=e(98588),p=e(96436),s=e(2349),g=e(78542),a=new Set;t.knownLanguageFacts=[o.GolangLanguageFacts,l.JavaLanguageFacts,_.JavaScriptLanguageFacts,v.JavaScriptReactLanguageFacts,m.PythonLanguageFacts,p.RustLanguageFacts,s.TypeScriptLanguageFacts,g.TypeScriptReactLanguageFacts];let h=class{constructor(){this.langs=new Map,t.knownLanguageFacts.forEach(c=>{const E=new c;this.langs.set(E.name,E)})}isCodeBlock(c,E){const f=this.langs.get(c);return f&&f.isCodeBlock?f.isCodeBlock(E):!1}isFunctionCodeBlock(c,E){const f=this.langs.get(c);return f&&f.isFunctionCodeBlocks?f.isFunctionCodeBlocks(E):!1}provideFunctionInfo(c,E){const f=this.langs.get(c);return f&&f.provideFunctionInfo?f.provideFunctionInfo(E):null}getCodeBlockTypes(c){const E=this.langs.get(c);return E?E.provideCodeBlocks():a}};t.TreeSitterLanguageFacts=h,t.TreeSitterLanguageFacts=h=n.__decorate([(0,r.Injectable)(),n.__metadata("design:paramtypes",[])],h)},44606:(P,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JavaLanguageFacts=void 0;const e=["compilation_unit","class_declaration","interface_declaration","enum_declaration","method_declaration","constructor_declaration","block","static_initializer","instance_initializer","if_statement","switch_statement","while_statement","do_statement","for_statement","enhanced_for_statement","try_statement","catch_clause","finally_clause"],n=new Set(["method_declaration","constructor_declaration"]),r=new Set(e);class o{constructor(){this.name="java",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return r}isCodeBlock(_){return r.has(_)}isFunctionCodeBlocks(_){return n.has(_)}}t.JavaLanguageFacts=o},82381:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JavaScriptLanguageFacts=t.functionBlockCodeTypes=t.javascriptBlockCodeTypes=void 0;const n=e(53374);t.javascriptBlockCodeTypes=["function","function_declaration","function_expression","arrow_function","class_declaration","method_definition","if_statement","switch_case","while_statement","do_statement","for_statement","for_in_statement","try_statement","catch_clause","block","export_statement","lexical_declaration"],t.functionBlockCodeTypes=["function","function_declaration","function_expression","arrow_function","method_definition"];const r=new Set(t.functionBlockCodeTypes),o=new Set(t.javascriptBlockCodeTypes);class l{constructor(){this.name="javascript",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return o}isCodeBlock(v){return o.has(v)}isFunctionCodeBlocks(v){return r.has(v)}provideFunctionInfo(v){var m,p,s;switch(v.type){case"function_declaration":case"function_expression":return{infoCategory:"function",type:v.type,name:((m=v.firstNamedChild)===null||m===void 0?void 0:m.text)||"",signatures:v.children.filter(g=>g.type==="parameter").map(g=>{var a;return((a=g.firstChild)===null||a===void 0?void 0:a.text)||""}),range:(0,n.toMonacoRange)(v)};case"arrow_function":{const g=v.parent;return g&&g.type==="variable_declarator"&&g.parent&&(g.parent.type==="lexical_declaration"||g.parent.type==="export_statement"||g.parent.type==="variable_declaration")?{infoCategory:"function",type:v.type,name:((p=g.firstChild)===null||p===void 0?void 0:p.text)||"",signatures:v.children.filter(a=>a.type==="parameter").map(a=>{var h;return((h=a.firstChild)===null||h===void 0?void 0:h.text)||""}),range:(0,n.toMonacoRange)(g.parent)}:null}case"method_definition":return{infoCategory:"function",type:v.type,name:((s=v.firstNamedChild)===null||s===void 0?void 0:s.text)||"",signatures:v.children.filter(g=>g.type==="parameter").map(g=>{var a;return((a=g.firstChild)===null||a===void 0?void 0:a.text)||""}),range:(0,n.toMonacoRange)(v)}}return null}}t.JavaScriptLanguageFacts=l},41486:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JavaScriptReactLanguageFacts=t.javascriptreactBlockCodeTypes=void 0;const n=e(82381);t.javascriptreactBlockCodeTypes=[...n.javascriptBlockCodeTypes,"jsx_element","jsx_self_closing_element","jsx_expression","jsx_fragment"];const r=new Set(t.javascriptreactBlockCodeTypes);class o{constructor(){this.name="jsx",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return r}isCodeBlock(_){return r.has(_)}}t.JavaScriptReactLanguageFacts=o},98588:(P,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PythonLanguageFacts=t.pythonBlockCodeTypes=void 0,t.pythonBlockCodeTypes=["function_definition","class_definition","compound_statement","if_statement","elif_clause","else_clause","for_statement","while_statement","try_statement","except_clause","with_statement","decorated_definition"];const e=new Set(t.pythonBlockCodeTypes);class n{constructor(){this.name="python",this.listCommentStyle="# ",this.blockCommentStyle={start:"'''",end:"'''",linePrefix:""}}provideCodeBlocks(){return e}isCodeBlock(o){return e.has(o)}}t.PythonLanguageFacts=n},96436:(P,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RustLanguageFacts=t.rustBlockCodeTypes=void 0,t.rustBlockCodeTypes=["function_item","impl_item","trait_item","block","if_expression","match_expression","while_expression","loop_expression","for_expression","closure_expression","struct_item","enum_item","union_item","mod_item"];const e=new Set(t.rustBlockCodeTypes);class n{constructor(){this.name="rust",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return e}isCodeBlock(o){return e.has(o)}}t.RustLanguageFacts=n},17973:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parserIdentifierMap=t.parserNameMap=void 0;const r=e(85608).__importDefault(e(19891)),o={typescript:"typescript",typescriptreact:"tsx",javascript:"javascript",javascriptreact:"jsx",rust:"rust",python:"python",java:"java",go:"go"};t.parserNameMap=o,t.parserIdentifierMap=(0,r.default)(t.parserNameMap)},2349:(P,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TypeScriptLanguageFacts=t.typescriptBlockTypes=void 0,t.typescriptBlockTypes=["function","function_declaration","function_expression","arrow_function","class_declaration","interface_declaration","method_definition","method_signature","enum_declaration","type_alias_declaration","lexical_declaration","if_statement","switch_case","while_statement","do_statement","for_statement","for_in_statement","for_of_statement","try_statement","catch_clause","block","module","public_field_definition","private_field_definition","export_statement"];const e=new Set(t.typescriptBlockTypes);class n{constructor(){this.name="typescript",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return e}isCodeBlock(o){return e.has(o)}}t.TypeScriptLanguageFacts=n},78542:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TypeScriptReactLanguageFacts=t.typescriptreactBlockTypes=void 0;const n=e(2349);t.typescriptreactBlockTypes=[...n.typescriptBlockTypes,"jsx_element","jsx_self_closing_element","jsx_expression","jsx_fragment"];const r=new Set(t.typescriptreactBlockTypes);class o{constructor(){this.name="tsx",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return r}isCodeBlock(_){return r.has(_)}}t.TypeScriptReactLanguageFacts=o},67045:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WasmModuleManager=void 0;const n=e(85608),r=n.__importDefault(e(13833)),o=e(76003),l=e(6858),_=e(70392);let v=class{async resolveResourceUri(){const p=await this.rendererRuntime.provideResourceUri(l.EKnownResources.TreeSitterWasmDirectory);this.resolvedResourceUriDeferred.resolve(p)}constructor(){this.resolvedResourceUriDeferred=new _.Deferred,this.cachedRuntime=new Map,this.parserInitialized=!1,this.resolveResourceUri()}async initParser(){const p=await this.resolvedResourceUriDeferred.promise;let s;return p.endsWith("/")?s=`${p}tree-sitter.wasm`:s=`${p}/tree-sitter.wasm`,this.parserInitialized||(await r.default.init({locateFile:()=>s}),this.parserInitialized=!0),new r.default}async loadLanguage(p){if(!this.cachedRuntime.has(p)){const s=new _.Deferred;this.cachedRuntime.set(p,s);const g=await this.resolvedResourceUriDeferred.promise;let a;g.endsWith("/")?a=`${g}tree-sitter-${p}.wasm`:a=`${g}/tree-sitter-${p}.wasm`,fetch(a).then(h=>h.arrayBuffer()).then(h=>{s.resolve(h)})}return this.cachedRuntime.get(p).promise}};t.WasmModuleManager=v,n.__decorate([(0,o.Autowired)(l.RendererRuntime),n.__metadata("design:type",l.RendererRuntime)],v.prototype,"rendererRuntime",void 0),t.WasmModuleManager=v=n.__decorate([(0,o.Injectable)(),n.__metadata("design:paramtypes",[])],v)},4972:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AIRightTabRenderer=t.AILeftTabRenderer=t.AIChatTabRendererWithTab=t.AIChatTabRenderer=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=e(41869),_=e(89195),v=e(1149),m=e(43718),p=e(11090),s=e(63067),g=e(46245),a=e(66368),h=e(19951),u=e(752),c=e(19413),E=n.__importDefault(e(87708)),f=()=>o.default.createElement("div",{style:{width:0}},o.default.createElement(g.TabbarViewBase,{tabSize:0,MoreTabView:g.IconElipses,TabView:g.IconTabView,barSize:0,panelBorderSize:0})),d=({className:D,components:I})=>o.default.createElement(h.TabRendererBase,{side:c.AI_CHAT_VIEW_ID,direction:"left-to-right",id:E.default.ai_chat_panel,className:(0,r.default)(D,`${c.AI_CHAT_VIEW_ID}-slot`),components:I,TabbarView:()=>o.default.createElement(f,null),TabpanelView:()=>o.default.createElement(a.BaseTabPanelView,{PanelView:a.ContainerView,PanelViewProps:{className:E.default.ai_chat_view_container}})});t.AIChatTabRenderer=d;const y=({className:D,components:I})=>o.default.createElement(h.TabRendererBase,{side:c.AI_CHAT_VIEW_ID,direction:"right-to-left",id:E.default.ai_chat_panel,className:(0,r.default)(D,`${c.AI_CHAT_VIEW_ID}-slot`,"design_right_slot"),components:I,TabbarView:()=>o.default.createElement(g.ChatTabbarRenderer2,null),TabpanelView:()=>o.default.createElement(a.BaseTabPanelView,{PanelView:a.ContainerView,PanelViewProps:{className:E.default.ai_chat_view_container}})});t.AIChatTabRendererWithTab=y;const b=({className:D,components:I})=>o.default.createElement(p.DesignLeftTabRenderer,{className:D,components:I,tabbarView:A});t.AILeftTabRenderer=b;const A=()=>{const D=(0,l.useInjectable)(s.IMainLayoutService),I=(0,l.useInjectable)(u.TabbarServiceFactory)(l.SlotLocation.extendView),w=(0,l.useAutorun)(I.currentContainerId),T=o.default.useMemo(()=>D.getExtraMenu(),[D]),[R]=(0,l.useContextMenus)(T),M=(0,o.useCallback)(({renderContainers:O})=>{const x=I.visibleContainers.filter(k=>{var F;return!(!((F=k.options)===null||F===void 0)&&F.hideTab)});return o.default.createElement(o.default.Fragment,null,x.length>0&&o.default.createElement(_.HorizontalVertical,{margin:"8px auto 0px",width:"60%"}),x.map(k=>O(k,I,w)))},[w,I]);return o.default.createElement(g.LeftTabbarRenderer,{renderOtherVisibleContainers:M,isRenderExtraTopMenus:!1,renderExtraMenus:o.default.createElement("div",{className:E.default.extra_bottom_icon_container},R.length>=0?R.map(O=>o.default.createElement(_.EnhanceIconWithCtxMenu,{key:O.id,id:O.id,wrapperClassName:E.default.extra_bottom_icon,iconClass:O.icon,menuNodes:O.children,skew:{x:-8,y:-4}})):null)})},S=({components:D})=>{const I=(0,l.useInjectable)(u.TabbarServiceFactory)(l.SlotLocation.extendView),w=(0,l.useInjectable)(v.DesignLayoutConfig),T=(0,o.useCallback)(()=>{I.updateCurrentContainerId("")},[]),R=(0,o.useCallback)(O=>{const{component:x}=O,{options:k}=x;return o.default.createElement(a.ContainerView,{...O,customTitleBar:o.default.createElement("div",{className:E.default.header},o.default.createElement("span",{className:E.default.title},k&&k.title),o.default.createElement("div",{className:E.default.side},o.default.createElement(_.EnhancePopover,{id:"ai_right_panel_header_close",title:(0,m.localize)("editor.title.context.close")},o.default.createElement(_.EnhanceIcon,{icon:"close",onClick:T})))),renderContainerWrap:({children:F})=>o.default.createElement("div",{className:E.default.right_slot_container_wrap},o.default.createElement("div",{className:E.default.container},F))})},[]),M=(0,o.useMemo)(()=>w.useMergeRightWithLeftPanel?E.default.right_tab_renderer:"",[w]);return o.default.createElement(p.DesignRightTabRenderer,{components:D,className:M,tabbarView:()=>o.default.createElement(g.RightTabbarRenderer,{barSize:0,style:{width:0}}),tabpanelView:()=>o.default.createElement(a.BaseTabPanelView,{PanelView:R})})};t.AIRightTabRenderer=S},82983:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AIChatLogoAvatar=void 0;const n=e(85608),r=n.__importDefault(e(14041)),o=e(41869),l=e(89195),_=e(63067),v=e(19413),m=n.__importDefault(e(88473)),p=()=>{const s=(0,o.useInjectable)(_.IMainLayoutService),g=r.default.useCallback(()=>{s.toggleSlot(v.AI_CHAT_VIEW_ID)},[s]);return r.default.createElement("div",{className:m.default.ai_switch,onClick:g},r.default.createElement(l.AILogoAvatar,{iconClassName:m.default.avatar_icon_large}))};t.AIChatLogoAvatar=p},73974:(P,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseApplyService=void 0;const n=e(85608),r=e(41429),o=e(76003),l=e(41869),_=e(54414),v=e(57517),m=e(55126),p=e(20868),s=e(70392),g=e(2261),a=e(19413),h=e(59347),u=e(40111),c=e(15989);class E extends l.WithEventBus{constructor(){var d;super(),this.onCodeBlockUpdateEmitter=new s.Emitter,this.onCodeBlockUpdate=this.onCodeBlockUpdateEmitter.event,this.activePreviewerMap=this.registerDispose(new s.DisposableMap),this.editorListenerMap=this.registerDispose(new s.DisposableMap),this.addDispose(this.chatInternalService.onCancelRequest(()=>{const y=this.chatInternalService.sessionModel.history.lastMessageId;if(!y)return;const b=this.getMessageCodeBlocks(y);b&&Object.values(b).forEach(A=>{this.cancelApply(A)})})),this.currentSessionId=(d=this.chatInternalService.sessionModel)===null||d===void 0?void 0:d.sessionId,this.addDispose(this.chatInternalService.onChangeSession(y=>{y!==this.currentSessionId&&(this.cancelAllApply(),this.currentSessionId=y)})),this.addDispose(this.chatInternalService.onRegenerateRequest(()=>{var y;const b=(y=this.chatInternalService.sessionModel)===null||y===void 0?void 0:y.history.getMessages(),A=b[b.length-1].id,S=this.getMessageCodeBlocks(A);S&&Object.values(S).forEach(D=>{this.cancelApply(D)})})),this.addDispose(this.chatInternalService.onWillClearSession(y=>{this.cancelAllApply(y)}))}getMessageCodeBlocks(d,y){y=y||this.chatInternalService.sessionModel.sessionId;const b=this.chatInternalService.getSession(y);if(!b)throw new Error(`Session ${y} not found`);const A=b.history.getMessageAdditional(d);return A?.codeBlockMap}onEditorGroupClose(d){const y=s.path.relative(this.appConfig.workspaceDir,d.payload.resource.uri.path.toString());this.activePreviewerMap.get(y)&&this.activePreviewerMap.disposeKey(y),this.editorListenerMap.disposeKey(d.payload.resource.uri.toString())}async onEditorGroupOpen(d){var y,b;const A=s.path.relative(this.appConfig.workspaceDir,d.payload.resource.uri.path.toString());if(this.duringApply||this.activePreviewerMap.has(A)||!(!((y=this.chatInternalService.sessionModel)===null||y===void 0)&&y.history.getMessages().length))return;const S=((b=this.getUriCodeBlocks(d.payload.resource.uri))===null||b===void 0?void 0:b.filter(D=>D.status==="pending"))||[];if(S.length>0&&S[0].updatedCode){const D=d.payload.group.codeEditor.monacoEditor;await this.renderApplyResult(D,S[0],S[0].updatedCode)}}get currentPreviewer(){var d;const y=(d=this.editorService.currentEditor)===null||d===void 0?void 0:d.currentUri;if(y)return this.activePreviewerMap.get(s.path.relative(this.appConfig.workspaceDir,y.path.toString()))}getUriCodeBlocks(d){const y=this.getSessionCodeBlocks()||[],b=s.path.relative(this.appConfig.workspaceDir,d.path.toString());return y.filter(A=>A.relativePath===b).sort((A,S)=>S.version-A.version)}getPendingPaths(d){return this.getSessionCodeBlocks(d).filter(b=>b.status==="pending").map(b=>b.relativePath)}getSessionCodeBlocks(d){const y=d?this.chatInternalService.getSession(d):this.chatInternalService.sessionModel;if(!y)return[];const b=y.history.sessionAdditionals;return Array.from(b.values()).map(A=>A.codeBlockMap||{}).reduce((A,S)=>(Object.values(S).forEach(D=>{A.push(D)}),A),[])}getCodeBlock(d,y){if(y=y||this.chatInternalService.sessionModel.history.lastMessageId,!y)throw new Error("Message ID is required");const b=this.getMessageCodeBlocks(y);if(b)return b[d]}updateCodeBlock(d){const y=d.messageId,b=this.getMessageCodeBlocks(y);if(!b)throw new Error("Code block not found");b[d.toolCallId]=d,this.chatInternalService.sessionModel.history.setMessageAdditional(y,{codeBlockMap:b}),this.onCodeBlockUpdateEmitter.fire(d)}async registerCodeBlock(d,y,b,A){var S,D;const I=this.chatInternalService.sessionModel.history.lastMessageId,w=this.getUriCodeBlocks(s.URI.file(s.path.join(this.appConfig.workspaceDir,d))),T=await this.editorDocumentModelService.createModelReference(s.URI.file(s.path.join(this.appConfig.workspaceDir,d))),R={codeEdit:y,relativePath:d,status:"generating",iterationCount:1,version:1,createdAt:Date.now(),toolCallId:b,messageId:I,instructions:A,originalCode:T.instance.getText()};if(w?.length){R.version=w.length+1;for(const O of w)if(O.relativePath===d&&(!((D=(S=O.applyResult)===null||S===void 0?void 0:S.diagnosticInfos)===null||D===void 0)&&D.length))R.iterationCount++;else break}const M=this.getMessageCodeBlocks(I)||{};return M[b]=R,this.chatInternalService.sessionModel.history.setMessageAdditional(I,{codeBlockMap:M}),this.onCodeBlockUpdateEmitter.fire(R),R}async apply(d){var y,b;try{if(this.duringApply=!0,d.iterationCount>3)throw new Error("Lint error max iteration count exceeded");const A=d.originalCode?await this.doApply(d):{result:d.codeEdit};if(!A.stream&&!A.result)return d.status="failed",this.updateCodeBlock(d),d;this.activePreviewerMap.has(d.relativePath)&&(this.editorListenerMap.disposeKey(s.URI.file(s.path.join(this.appConfig.workspaceDir,d.relativePath)).toString()),this.activePreviewerMap.disposeKey(d.relativePath));const S=await this.editorService.open(s.URI.file(s.path.join(this.appConfig.workspaceDir,d.relativePath)));if(!S)throw new Error("Failed to open file");const D=await this.renderApplyResult(S.group.codeEditor.monacoEditor,d,A.result||A.stream,A.range);if(d.updatedCode=D.updatedCode,d.status="pending",this.postApplyHandler&&typeof this.postApplyHandler=="function")try{await this.postApplyHandler(S.group.codeEditor.monacoEditor)}catch{}const I=S.group.codeEditor.monacoEditor.getModel(),w=this.getDiagnosticInfos(I.uri.toString(),((y=D.result)===null||y===void 0?void 0:y.rangesFromDiffHunk)||[]);return D.result&&(d.applyResult={diff:(b=D.result)===null||b===void 0?void 0:b.diff,diagnosticInfos:w}),this.updateCodeBlock(d),d}catch(A){throw d.status="failed",this.updateCodeBlock(d),A}finally{this.duringApply=!1}}async renderApplyResult(d,y,b,A){var S,D,I;const w=new s.Deferred,T=c.InlineDiffController.get(d);if(A=A||d.getModel().getFullModelRange(),typeof b=="string"){const R=b,M=d.getModel().getValue(),O=s.URI.file(s.path.join(this.appConfig.workspaceDir,y.relativePath)),x=this.editorDocumentModelService.getModelReference(O);(M!==R||x?.instance.dirty)&&((S=d.getModel())===null||S===void 0||S.pushEditOperations([],[g.EditOperation.replace(A,R)],()=>null),await this.editorService.save(O));const k=(D=this.getUriCodeBlocks(O))===null||D===void 0?void 0:D.filter(W=>W.status==="pending"),F=k?.[k.length-1];if(((I=F||y)===null||I===void 0?void 0:I.originalCode)===R)throw new Error("No changes applied");const L=T.createDiffPreviewer(d,p.Selection.fromRange(A,p.SelectionDirection.LTR),{disposeWhenEditorClosed:!0,renderRemovedWidgetImmediately:!0,reverse:!0});this.activePreviewerMap.set(y.relativePath,L),L.setValue(F?.originalCode||y.originalCode||`
33075
33075
  `),this.eventBus.fire(new v.RegisterEditorSideComponentEvent),this.listenPartialEdit(d.getModel(),y).then(W=>{if(W){const j=this.getDiagnosticInfos(d.getModel().uri.toString(),U);y.applyResult={diff:W.diff,diagnosticInfos:j}}this.updateCodeBlock(y),this.editorService.save(s.URI.file(s.path.join(this.appConfig.workspaceDir,y.relativePath)))});const{diff:N,rangesFromDiffHunk:U}=this.getDiffResult(y.originalCode,R,y.relativePath);w.resolve({result:{diff:N,rangesFromDiffHunk:U},updatedCode:R})}else{const R=new u.InlineChatController;R.mountReadable(b);const M=T.showPreviewerByStream(d,{crossSelection:p.Selection.fromRange(A,p.SelectionDirection.LTR),chatResponse:R,previewerOptions:{disposeWhenEditorClosed:!0,renderRemovedWidgetImmediately:!1}});this.addDispose(R.onError(O=>{w.reject(O)})),this.addDispose(R.onAbort(()=>{w.reject(new Error("Apply aborted"))})),this.addDispose(M.getNode().onDiffFinished(async O=>{const x=O.newFullRangeTextLines.join(`
33076
- `);if(y.originalCode===x){M.dispose(),w.reject(new Error("no changes applied"));return}M.dispose();try{const k=await this.renderApplyResult(d,y,x);w.resolve(k)}catch(k){w.reject(k)}})),this.activePreviewerMap.set(y.relativePath,M)}return w.promise}cancelApply(d,y){var b,A;(d.status==="generating"||d.status==="pending")&&(this.editorListenerMap.disposeKey(s.URI.file(s.path.join(this.appConfig.workspaceDir,d.relativePath)).toString()),this.activePreviewerMap.has(d.relativePath)&&((A=(b=this.activePreviewerMap.get(d.relativePath))===null||b===void 0?void 0:b.getNode())===null||A===void 0||A.livePreviewDiffDecorationModel.discardUnProcessed(),this.activePreviewerMap.disposeKey(d.relativePath)),d.status="cancelled",this.updateCodeBlock(d))}cancelAllApply(d){this.getSessionCodeBlocks(d).forEach(b=>{this.cancelApply(b)})}revealApplyPosition(d){var y;const b=(y=d.applyResult)===null||y===void 0?void 0:y.diff.split(`
33077
- `).find(I=>I.startsWith("@@"));let A=0,S=0;if(b){const[,,,I,w]=b.match(/@@ -(\d+),(\d+) \+(\d+),(\d+) @@/);A=parseInt(I,10)-1,S=parseInt(w,10)-1}this.editorService.open(s.URI.file(s.path.join(this.appConfig.workspaceDir,d.relativePath)));const D=this.editorService.currentEditor;D&&D.setSelection(new p.Selection(A,0,S,0))}async processAll(d,y){var b;const A=y?(b=this.getUriCodeBlocks(y))===null||b===void 0?void 0:b.filter(w=>w.status==="pending"):this.getSessionCodeBlocks().filter(w=>w.status==="pending");if(!A?.length)throw new Error("No pending code block found");const S=y?[A[0].relativePath]:A.map(w=>w.relativePath).reduce((w,T)=>(w.includes(T)||w.push(T),w),[]),D=this.editorService.getAllOpenedUris(),I=S.filter(w=>!D.some(T=>T.codeUri.fsPath.endsWith(w))).map(w=>s.URI.file(s.path.join(this.appConfig.workspaceDir,w)));I.length&&await this.editorService.openUris(I),S.forEach(w=>{this.doProcess(d,w)}),A.forEach(w=>{w.status=d==="accept"?"success":"cancelled",this.updateCodeBlock(w)})}doProcess(d,y){var b,A;const S=(A=(b=this.activePreviewerMap.get(y))===null||b===void 0?void 0:b.getNode())===null||A===void 0?void 0:A.livePreviewDiffDecorationModel;if(!S)throw new Error("No active previewer found");d==="accept"?S.acceptUnProcessed():S.discardUnProcessed(),this.editorService.save(s.URI.file(s.path.join(this.appConfig.workspaceDir,y)))}listenPartialEdit(d,y){const b=new s.Deferred,A=d.uri.toString(),S=this.inlineDiffService.onPartialEdit(D=>{if(D.totalPartialEditCount===D.resolvedPartialEditCount&&D.uri.path===d.uri.path.toString()){if(D.acceptPartialEditCount>0){y.status="success";const I=d.getValue(),{diff:w,rangesFromDiffHunk:T}=this.getDiffResult(y.originalCode,I,y.relativePath),R=this.getDiagnosticInfos(d.uri.toString(),T);this.aiReporter.send({msgType:l.AIServiceType.Chat,actionType:l.ActionTypeEnum.Accept,actionSource:l.ActionSourceEnum.Chat,sessionId:this.chatInternalService.sessionModel.sessionId,isReceive:!0,isDrop:D.acceptPartialEditCount!==D.totalPartialEditCount,code:I,originCode:y.originalCode,message:JSON.stringify({diff:w,diagnosticInfos:R,instructions:y.instructions,codeEdit:y.codeEdit,partialEditCount:D.totalPartialEditCount,acceptPartialEditCount:D.acceptPartialEditCount,addedLinesCount:D.totalAddedLinesCount,deletedLinesCount:D.totalDeletedLinesCount})}),b.resolve({diff:w,rangesFromDiffHunk:T})}else y.status="cancelled",b.resolve(),this.aiReporter.send({msgType:l.AIServiceType.Chat,actionType:l.ActionTypeEnum.Discard,actionSource:l.ActionSourceEnum.Chat,sessionId:this.chatInternalService.sessionModel.sessionId,isReceive:!1,isDrop:!0,originCode:y.originalCode,message:JSON.stringify({instructions:y.instructions,codeEdit:y.codeEdit})});this.editorListenerMap.disposeKey(A)}});return this.editorListenerMap.set(A,S),b.promise}getDiffResult(d,y,b){const A=(0,r.createPatch)(b,d,y).split(`
33076
+ `);if(y.originalCode===x){M.dispose(),w.reject(new Error("no changes applied"));return}M.dispose();try{const k=await this.renderApplyResult(d,y,x);w.resolve(k)}catch(k){w.reject(k)}})),this.activePreviewerMap.set(y.relativePath,M)}return w.promise}cancelApply(d,y){var b,A;(d.status==="generating"||d.status==="pending")&&(this.editorListenerMap.disposeKey(s.URI.file(s.path.join(this.appConfig.workspaceDir,d.relativePath)).toString()),this.activePreviewerMap.has(d.relativePath)&&((A=(b=this.activePreviewerMap.get(d.relativePath))===null||b===void 0?void 0:b.getNode())===null||A===void 0||A.livePreviewDiffDecorationModel.discardUnProcessed(),this.activePreviewerMap.disposeKey(d.relativePath)),d.status="cancelled",this.updateCodeBlock(d))}cancelAllApply(d){(this.getSessionCodeBlocks(d)||[]).forEach(b=>{this.cancelApply(b)})}revealApplyPosition(d){var y;const b=(y=d.applyResult)===null||y===void 0?void 0:y.diff.split(`
33077
+ `).find(I=>I.startsWith("@@"));let A=0,S=0;if(b){const[,,,I,w]=b.match(/@@ -(\d+),(\d+) \+(\d+),(\d+) @@/);A=parseInt(I,10)-1,S=parseInt(w,10)-1}this.editorService.open(s.URI.file(s.path.join(this.appConfig.workspaceDir,d.relativePath)));const D=this.editorService.currentEditor;D&&D.setSelection(new p.Selection(A,0,S,0))}async processAll(d,y){var b,A;const S=y?(b=this.getUriCodeBlocks(y))===null||b===void 0?void 0:b.filter(T=>T.status==="pending"):(A=this.getSessionCodeBlocks())===null||A===void 0?void 0:A.filter(T=>T.status==="pending");if(!S?.length)throw new Error("No pending code block found");const D=y?[S[0].relativePath]:S.map(T=>T.relativePath).reduce((T,R)=>(T.includes(R)||T.push(R),T),[]),I=this.editorService.getAllOpenedUris(),w=D.filter(T=>!I.some(R=>R.codeUri.fsPath.endsWith(T))).map(T=>s.URI.file(s.path.join(this.appConfig.workspaceDir,T)));w.length&&await this.editorService.openUris(w),D.forEach(T=>{this.doProcess(d,T)}),S.forEach(T=>{T.status=d==="accept"?"success":"cancelled",this.updateCodeBlock(T)})}doProcess(d,y){var b,A;const S=(A=(b=this.activePreviewerMap.get(y))===null||b===void 0?void 0:b.getNode())===null||A===void 0?void 0:A.livePreviewDiffDecorationModel;if(!S)throw new Error("No active previewer found");d==="accept"?S.acceptUnProcessed():S.discardUnProcessed(),this.editorService.save(s.URI.file(s.path.join(this.appConfig.workspaceDir,y)))}listenPartialEdit(d,y){const b=new s.Deferred,A=d.uri.toString(),S=this.inlineDiffService.onPartialEdit(D=>{if(D.totalPartialEditCount===D.resolvedPartialEditCount&&D.uri.path===d.uri.path.toString()){if(D.acceptPartialEditCount>0){y.status="success";const I=d.getValue(),{diff:w,rangesFromDiffHunk:T}=this.getDiffResult(y.originalCode,I,y.relativePath),R=this.getDiagnosticInfos(d.uri.toString(),T);this.aiReporter.send({msgType:l.AIServiceType.Chat,actionType:l.ActionTypeEnum.Accept,actionSource:l.ActionSourceEnum.Chat,sessionId:this.chatInternalService.sessionModel.sessionId,isReceive:!0,isDrop:D.acceptPartialEditCount!==D.totalPartialEditCount,code:I,originCode:y.originalCode,message:JSON.stringify({diff:w,diagnosticInfos:R,instructions:y.instructions,codeEdit:y.codeEdit,partialEditCount:D.totalPartialEditCount,acceptPartialEditCount:D.acceptPartialEditCount,addedLinesCount:D.totalAddedLinesCount,deletedLinesCount:D.totalDeletedLinesCount})}),b.resolve({diff:w,rangesFromDiffHunk:T})}else y.status="cancelled",b.resolve(),this.aiReporter.send({msgType:l.AIServiceType.Chat,actionType:l.ActionTypeEnum.Discard,actionSource:l.ActionSourceEnum.Chat,sessionId:this.chatInternalService.sessionModel.sessionId,isReceive:!1,isDrop:!0,originCode:y.originalCode,message:JSON.stringify({instructions:y.instructions,codeEdit:y.codeEdit})});this.editorListenerMap.disposeKey(A)}});return this.editorListenerMap.set(A,S),b.promise}getDiffResult(d,y,b){const A=(0,r.createPatch)(b,d,y).split(`
33078
33078
  `).slice(4).join(`
33079
33079
  `),S=A.split(`
33080
33080
  `).map(D=>{if(D.startsWith("@@")){const[,,,I,w]=D.match(/@@ -(\d+),(\d+) \+(\d+),(\d+) @@/);return new p.Range(parseInt(I,10),0,parseInt(I,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:(P,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,I]=o.default.useState([]),w=(0,o.useCallback)(async()=>{const N=await a.getServers();u(N)},[a]),T=(0,o.useCallback)(async()=>{const N=await a.getDisabledTools();I(N)},[a]);o.default.useEffect(()=>{w(),T();const N=a.onMCPServersChange(U=>{U&&S(!0),w()});return()=>{N.dispose()}},[w,T]);const R=(0,o.useCallback)(async(N,U)=>{try{b(N),await a.controlServer(N,U),await w(),b(void 0)}catch{b(void 0)}},[a,w]),M=(0,o.useCallback)(()=>{d(void 0),E(!0)},[]),O=(0,o.useCallback)(async N=>{const U=await a.getServerConfigByName(N.name);U&&(d(U),E(!0))},[a]),x=(0,o.useCallback)(async N=>{await a.deleteServer(N),await w()},[a,w]),k=(0,o.useCallback)(async(N,U)=>{E(!1),await a.saveServer(N,U),N?.enabled&&(b(U.name),await a.controlServer(U.name,!0),b(void 0)),await w()},[a,w]),F=(0,o.useCallback)(async N=>{b(N.name),await a.syncServer(N.name),await w(),b(void 0)},[a,w]),L=(0,o.useCallback)(async N=>{await a.toggleToolEnabled(N),I(U=>U.includes(N)?U.filter(j=>j!==N):[...U,N])},[a]);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:M},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(N=>o.default.createElement("div",{key:N.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},N.name,o.default.createElement("span",{className:(0,r.default)(p.default.serverStatusIcon,N.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:N.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,N.isStarted&&p.default.active),onClick:()=>R(N.name,!N.isStarted)},o.default.createElement("i",{className:`codicon ${y===N.name||!A&&N.name!==m.BUILTIN_MCP_SERVER_NAME&&!N.isStarted?"codicon-loading kt-icon-loading":N.isStarted?"codicon-check":"codicon-circle"}`}),o.default.createElement("span",null,(0,v.localize)(N.isStarted?"ai.native.mcp.enabled":"ai.native.mcp.disabled")))),N.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:()=>O(N)}),N.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:()=>F(N)}),N.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:()=>x(N.name)}))),o.default.createElement("div",{className:p.default.serverDetail},N.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(N.type)))),N.tools&&N.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},N.tools.map((U,W)=>{const j=D.includes(U.name);return o.default.createElement(l.Badge,{key:W,className:(0,r.default)(p.default.toolTag,j&&p.default.disabledTool),title:`${U.description}${j?" (\u5DF2\u7981\u7528)":""}`,onClick:()=>L(U.name),style:{cursor:"pointer"}},U.name,j&&o.default.createElement("span",{style:{marginLeft:"4px",opacity:.6}},"\u2715"))})))),N.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},N.command))),N.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)},N.url)))))),o.default.createElement(s.MCPServerForm,{visible:c,initialData:f,servers:h,onSave:N=>k(f,N),onCancel:()=>E(!1)}))};t.MCPConfigView=g},51750:(P,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 N;return((N=c?.args)===null||N===void 0?void 0:N.join(" "))||""}),[I,w]=(0,o.useState)(()=>c?.env?Object.entries(c.env).map(([N,U])=>`${N}=${U}`).join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opensumi/cli-engine",
3
- "version": "3.9.1-next-1761534197.0",
3
+ "version": "3.9.1-next-1761715915.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-1761534197.0",
30
- "@opensumi/ide-core-common": "3.9.1-next-1761534197.0",
31
- "@opensumi/ide-core-node": "3.9.1-next-1761534197.0",
32
- "@opensumi/ide-express-file-server": "3.9.1-next-1761534197.0",
33
- "@opensumi/ide-extension": "3.9.1-next-1761534197.0",
34
- "@opensumi/ide-i18n": "3.9.1-next-1761534197.0",
35
- "@opensumi/ide-main-layout": "3.9.1-next-1761534197.0",
36
- "@opensumi/ide-startup": "3.9.1-next-1761534197.0",
29
+ "@opensumi/ide-core-browser": "3.9.1-next-1761715915.0",
30
+ "@opensumi/ide-core-common": "3.9.1-next-1761715915.0",
31
+ "@opensumi/ide-core-node": "3.9.1-next-1761715915.0",
32
+ "@opensumi/ide-express-file-server": "3.9.1-next-1761715915.0",
33
+ "@opensumi/ide-extension": "3.9.1-next-1761715915.0",
34
+ "@opensumi/ide-i18n": "3.9.1-next-1761715915.0",
35
+ "@opensumi/ide-main-layout": "3.9.1-next-1761715915.0",
36
+ "@opensumi/ide-startup": "3.9.1-next-1761715915.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": "b73c37c5396d4728873023981714496b2dc72a02"
75
+ "gitHead": "a93a359b778172a4b39f289be46aff49e4b5c24e"
76
76
  }