@opensumi/cli-engine 3.8.1-next-1740465035.0 → 3.8.1-next-1740467196.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.
- package/lib/browser/browser.js +4 -4
- package/package.json +10 -10
package/lib/browser/browser.js
CHANGED
|
@@ -29731,7 +29731,7 @@ Use the appropriate tools to fulfill the USER\u2019s request, ensuring all requi
|
|
|
29731
29731
|
|
|
29732
29732
|
<user_info>
|
|
29733
29733
|
The user's OS version is ${this.applicationService.frontendOS}. The absolute path of the user's workspace is ${this.appConfig.workspaceDir}.
|
|
29734
|
-
</user_info>`},invoke:async(f,c,b,y)=>{this.chatDeferred=new p.Deferred;const{message:S,command:A}=f;let w=S;if(A){const O=this.chatFeatureRegistry.getSlashCommandHandler(A);if(O&&O.providerPrompt){const P=this.monacoCommandRegistry.getActiveCodeEditor();w=await O.providerPrompt(S,P)}}const T=this.preferenceService.get(v.AINativeSettingSectionsId.LLMModelSelection);let D="",I="";T==="deepseek"?D=this.preferenceService.get(v.AINativeSettingSectionsId.DeepseekApiKey,""):T==="openai"?(D=this.preferenceService.get(v.AINativeSettingSectionsId.OpenaiApiKey,""),I=this.preferenceService.get(v.AINativeSettingSectionsId.OpenaiBaseURL,"")):D=this.preferenceService.get(v.AINativeSettingSectionsId.AnthropicApiKey,"");const M=await this.aiBackService.requestStream(w,{requestId:f.requestId,sessionId:f.sessionId,history:this.aiChatService.getHistoryMessages(30720),clientId:this.applicationService.clientId,apiKey:D,model:T,baseURL:I},y);return(0,s.listenReadable)(M,{onData:O=>{c(O)},onEnd:()=>{this.chatDeferred.resolve()},onError:O=>{this.messageService.error(O.message),this.aiReporter.end(f.sessionId+"_"+f.requestId,{message:O.message,success:!1,command:A})}}),await this.chatDeferred.promise,{}},provideSlashCommands:async f=>this.chatFeatureRegistry.getAllSlashCommand().map(c=>({...c,name:c.name,description:c.description||""})),provideChatWelcomeMessage:async f=>{}})),queueMicrotask(()=>{this.chatAgentService.updateAgent(n.AGENT_ID,{})})}};t.ChatProxyService=d,d.AGENT_ID="Default_Chat_Agent",r.__decorate([(0,o.Autowired)(g.IChatAgentService),r.__metadata("design:type",Object)],d.prototype,"chatAgentService",void 0),r.__decorate([(0,o.Autowired)(p.AIBackSerivcePath),r.__metadata("design:type",Object)],d.prototype,"aiBackService",void 0),r.__decorate([(0,o.Autowired)(p.ChatFeatureRegistryToken),r.__metadata("design:type",u.ChatFeatureRegistry)],d.prototype,"chatFeatureRegistry",void 0),r.__decorate([(0,o.Autowired)(m.MonacoCommandRegistry),r.__metadata("design:type",m.MonacoCommandRegistry)],d.prototype,"monacoCommandRegistry",void 0),r.__decorate([(0,o.Autowired)(p.ChatServiceToken),r.__metadata("design:type",h.ChatService)],d.prototype,"aiChatService",void 0),r.__decorate([(0,o.Autowired)(p.IAIReporter),r.__metadata("design:type",Object)],d.prototype,"aiReporter",void 0),r.__decorate([(0,o.Autowired)(p.ChatAgentViewServiceToken),r.__metadata("design:type",Object)],d.prototype,"chatAgentViewService",void 0),r.__decorate([(0,o.Autowired)(l.PreferenceService),r.__metadata("design:type",Object)],d.prototype,"preferenceService",void 0),r.__decorate([(0,o.Autowired)(p.IApplicationService),r.__metadata("design:type",Object)],d.prototype,"applicationService",void 0),r.__decorate([(0,o.Autowired)(_.IMessageService),r.__metadata("design:type",Object)],d.prototype,"messageService",void 0),r.__decorate([(0,o.Autowired)(l.AppConfig),r.__metadata("design:type",Object)],d.prototype,"appConfig",void 0),t.ChatProxyService=d=n=r.__decorate([(0,o.Injectable)()],d)},29770:(x,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),p=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(p.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)}getHistoryMessages(s){var g;return((g=this.chatInternalService.sessionModel)===null||g===void 0?void 0:g.history.getMessages(s))||[]}scrollToBottom(){this._onScrollToBottom.fire()}};t.ChatService=m,n.__decorate([(0,r.Autowired)(p.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:(x,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),p=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}dispose(){super.dispose(),this.slashCommandsMap.clear(),this.slashCommandsHandlerMap.clear()}registerWelcome(s,g){this.chatWelcomeMessageModel=new p.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 p.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:(x,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),p=e(43718),v=e(19413),m=e(61282);let _=class extends p.Disposable{constructor(){super(...arguments),this._onChangeRequestId=new p.Emitter,this.onChangeRequestId=this._onChangeRequestId.event,this._onChangeSession=new p.Emitter,this.onChangeSession=this._onChangeSession.event,this._onCancelRequest=new p.Emitter,this.onCancelRequest=this._onCancelRequest.event,this._onRegenerateRequest=new p.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){return this.chatManagerService.createRequest(r.__classPrivateFieldGet(this,n,"f").sessionId,g,a,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.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()}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=_,n=new WeakMap,r.__decorate([(0,o.Autowired)(p.AIBackSerivcePath),r.__metadata("design:type",Object)],_.prototype,"aiBackService",void 0),r.__decorate([(0,o.Autowired)(l.PreferenceService),r.__metadata("design:type",Object)],_.prototype,"preferenceService",void 0),r.__decorate([(0,o.Autowired)(v.IChatManagerService),r.__metadata("design:type",m.ChatManagerService)],_.prototype,"chatManagerService",void 0),t.ChatInternalService=_=r.__decorate([(0,o.Injectable)()],_)},70394:(x,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:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AIChatView=void 0,t.DefaultChatViewHeader=O;const n=e(85608),r=n.__importStar(e(14041)),o=e(68392),l=e(41869),p=e(81878),v=e(89195),m=e(43718),_=e(63067),s=e(72665);e(41937);const g=e(19413),a=e(27399),h=e(25834),u=n.__importDefault(e(90103)),d=e(57987),E=e(56474),f=e(92635),c=e(29039),b=e(78048),y=e(86556),S=e(27397),A=e(30703),w=e(42033),T=e(51081),D=n.__importDefault(e(77256)),I="chat_scroll",R=100,M=()=>{const P=(0,l.useInjectable)(g.IChatInternalService),k=(0,l.useInjectable)(m.ChatServiceToken),F=(0,l.useInjectable)(m.IAIReporter),L=(0,l.useInjectable)(g.IChatAgentService),B=(0,l.useInjectable)(m.ChatFeatureRegistryToken),U=(0,l.useInjectable)(m.ChatRenderRegistryToken),W=(0,l.useInjectable)(g.TokenMCPServerProxyService),j=(0,l.useInjectable)(_.IMainLayoutService),X=P.sessionModel.history,V=r.useRef(null),$=r.useRef(null),Q=(0,l.useInjectable)(s.IDialogService),G=(0,l.useInjectable)(l.CommandService),[H,K]=r.useState([]),[Z,Y]=r.useReducer((et,At)=>{switch(At.type){case"add":return[...et,...At.payload||[]];case"clear":return[];case"init":return Array.isArray(At.payload)?At.payload:[];default:return et}},[]),[oe,ie]=r.useState(!1),[he,_e]=r.useState(""),[q,Re]=r.useState(""),[ye,ne]=r.useState(""),[ge,Me]=r.useState(null);r.useEffect(()=>{const et=B.getAllShortcutSlashCommand(),At=L.onDidChangeAgents(()=>{const tt=L.getCommands().filter(yt=>yt.isShortcut).map(yt=>new w.ChatSlashCommandItemModel({icon:"",name:`${yt.name} `,description:yt.description,isShortcut:yt.isShortcut},yt.name,yt.agentId));K(et.concat(tt))});return K(et),()=>At.dispose()},[B,L]),(0,l.useUpdateOnEvent)(P.onChangeSession);const Le=r.useMemo(()=>U.chatInputRender?U.chatInputRender:d.ChatInput,[U.chatInputRender]),Ce=r.useMemo(()=>(0,b.createMessageByAI)({id:(0,m.uuid)(6),relationId:"",text:r.createElement(y.WelcomeMessage,null)}),[]),Ae=r.useCallback(()=>{if(V&&V.current){const et=V.current.lastElementChild;et&&et.scrollIntoView({behavior:"smooth",block:"end"}),V.current.scrollHeight>V.current.clientHeight&&V.current.classList.add(I)}},[V]),ve=r.useCallback(et=>{Y(et),requestAnimationFrame(()=>{Ae()})},[Y,Ae]);r.useEffect(()=>{ve({type:"init",payload:[Ce]})},[]),r.useEffect(()=>{const et=new m.Disposable;return et.addDispose(k.onScrollToBottom(()=>{requestAnimationFrame(()=>{Ae()})})),et.addDispose(k.onChatMessageLaunch(async At=>{var tt;if(At.immediate!==!1){if(oe)return;await le(At)}else At.agentId&&_e(At.agentId),At.command&&ne(At.command),(tt=$?.current)===null||tt===void 0||tt.setInputValue(At.message)})),et.addDispose(k.onChatReplyMessageLaunch(At=>{if(At.kind==="content"){const tt=F.start(m.AIServiceType.CustomReplay,{message:At.content});X.addAssistantMessage({content:At.content,relationId:tt}),Fe({chunk:At.content,relationId:tt})}else{const tt=F.start(m.AIServiceType.CustomReplay,{message:"component#"+At.component});X.addAssistantMessage({componentId:At.component,componentValue:At.value,content:"",relationId:tt}),pe({chunk:At,relationId:tt})}})),et.addDispose(k.onChatMessageListLaunch(At=>{const tt=[];At.forEach(yt=>{const{role:it}=yt,ct=F.start(m.AIServiceType.Chat,{message:""});if(it==="assistant"){const ht=yt;tt.push((0,b.createMessageByAI)({id:(0,m.uuid)(6),relationId:ct,text:r.createElement(f.ChatNotify,{requestId:ct,chunk:ht})},D.default.chat_notify))}if(it==="user"){const{message:ht}=yt,St=T.ChatProxyService.AGENT_ID,Vt=U.chatUserRoleRender,En=St===T.ChatProxyService.AGENT_ID?"":St;tt.push((0,b.createMessageByUser)({id:(0,m.uuid)(6),relationId:ct,text:Vt?r.createElement(Vt,{content:ht,agentId:En}):r.createElement(h.CodeBlockWrapperInput,{relationId:ct,text:ht,agentId:En,command:ye})},D.default.chat_message_code))}}),ve({type:"add",payload:tt}),setTimeout(Ae,0)})),()=>et.dispose()},[k,U.chatAIRoleRender,X]),r.useEffect(()=>{const et=new m.Disposable;return et.addDispose(L.onDidSendMessage(At=>{const tt=At,yt=F.start(m.AIServiceType.Agent,{message:""}),it=(0,b.createMessageByAI)({id:(0,m.uuid)(6),relationId:yt,text:r.createElement(f.ChatNotify,{requestId:P.latestRequestId,chunk:tt})},D.default.chat_notify);ve({type:"add",payload:[it]})})),et.addDispose(L.onDidChangeAgents(async()=>{const At=L.getDefaultAgentId();Re(At??"")})),()=>et.dispose()},[L,X,P]);const fe=r.useCallback(async et=>{const{userMessage:At,relationId:tt,requestId:yt,render:it,startTime:ct,command:ht,agentId:St}=et;X.addAssistantMessage({type:"component",content:""});const Vt=(0,b.createMessageByAI)({id:(0,m.uuid)(6),relationId:tt,className:D.default.chat_with_more_actions,text:r.createElement(c.SlashCustomRender,{userMessage:At,startTime:ct,relationId:tt,requestId:yt,renderContent:it,command:ht,agentId:St})});ve({type:"add",payload:[Vt]})},[V,X]),xe=r.useCallback(async et=>{const At=U.chatUserRoleRender,{message:tt,agentId:yt,relationId:it,command:ct}=et,ht=yt===T.ChatProxyService.AGENT_ID?"":yt,St=(0,b.createMessageByUser)({id:(0,m.uuid)(6),relationId:it,text:At?r.createElement(At,{content:tt,agentId:ht,command:ct}):r.createElement(h.CodeBlockWrapperInput,{relationId:it,text:tt,agentId:ht,command:ct})},D.default.chat_message_code);ve({type:"add",payload:[St]})},[U,U.chatUserRoleRender,X,Ae]),Te=r.useCallback(async et=>{const{message:At,agentId:tt,request:yt,relationId:it,command:ct,startTime:ht,msgId:St}=et,Vt=tt===T.ChatProxyService.AGENT_ID?"":tt;if(tt===T.ChatProxyService.AGENT_ID&&ct){const Wn=B.getSlashCommandHandler(ct);if(Wn&&Wn.providerRender)return ie(!1),fe({userMessage:At,render:Wn.providerRender,relationId:it,requestId:yt.requestId,startTime:ht,agentId:tt,command:ct})}const En=(0,b.createMessageByAI)({id:(0,m.uuid)(6),relationId:it,className:D.default.chat_with_more_actions,text:r.createElement(f.ChatReply,{relationId:it,request:yt,startTime:ht,agentId:Vt,command:ct,onDidChange:()=>{Ae()},history:X,onDone:()=>{ie(!1)},onRegenerate:()=>{yt&&P.sendRequest(yt,!0)},msgId:St})});ve({type:"add",payload:[En]})},[U,X,Ae]),Fe=r.useCallback(et=>{const{chunk:At,relationId:tt}=et;let yt=r.createElement(E.ChatMarkdown,{markdown:At,fillInIncompleteTokens:!0,agentId:he,command:ye});if(U.chatAIRoleRender){const ct=U.chatAIRoleRender;yt=r.createElement(ct,{content:At})}const it=(0,b.createMessageByAI)({id:(0,m.uuid)(6),relationId:tt,text:yt,className:D.default.chat_with_more_actions});ve({type:"add",payload:[it]})},[U,X,Ae]),pe=r.useCallback(et=>{const{chunk:At,relationId:tt}=et,yt=(0,b.createMessageByAI)({id:(0,m.uuid)(6),relationId:tt,text:r.createElement(f.ChatNotify,{requestId:tt,chunk:At})},D.default.chat_notify);ve({type:"add",payload:[yt]})},[U,X,Ae]),re=r.useCallback(async et=>{const{message:At,agentId:tt,command:yt,reportExtra:it}=et,{actionType:ct,actionSource:ht}=it||{},St=P.createRequest(At,tt,yt);if(!St)return;ie(!0),P.setLatestRequestId(St.requestId);const Vt=Date.now(),En=T.ChatProxyService.AGENT_ID===tt?m.AIServiceType.Chat:m.AIServiceType.Agent,Wn=F.start(yt||En,{message:At,agentId:tt,userMessage:At,actionType:ct,actionSource:ht});X.addUserMessage({content:At,agentId:tt,agentCommand:yt,relationId:Wn}),await xe({relationId:Wn,message:At,command:yt,agentId:tt}),P.sendRequest(St);const Ei=X.addAssistantMessage({content:"",relationId:Wn,requestId:St.requestId,replyStartTime:Vt});await Te({startTime:Vt,relationId:Wn,message:At,agentId:tt,command:yt,request:St,msgId:Ei})},[U,U.chatUserRoleRender,X,Ae]),le=r.useCallback(async et=>{const{message:At,command:tt,reportExtra:yt}=et,it=et.agentId?et.agentId:T.ChatProxyService.AGENT_ID;return re({message:At,agentId:it,command:tt,reportExtra:yt})},[re]),Ie=r.useCallback(()=>{P.clearSessionModel(),k.clearHistoryMessages(),Se()},[Z]),Se=r.useCallback(()=>{var et;(et=V?.current)===null||et===void 0||et.classList.remove(I),ve({type:"init",payload:[Ce]})},[Z]),We=et=>{oe||(Me(et.nameWithSlash),_e(et.agentId),ne(et.command))},$e=r.useCallback(()=>{j.toggleSlot(g.AI_CHAT_VIEW_ID)},[j]),Ve=U.chatViewHeaderRender||O,mt=r.useCallback(async et=>{for(const At of X.getMessages()){if(et.isCancellationRequested)return;if(At.role===1)await xe({relationId:At.relationId,message:At.content,agentId:At.agentId,command:At.agentCommand});else if(At.role===2&&At.requestId){const tt=P.sessionModel.getRequest(At.requestId);tt&&!tt.response.isComplete&&ie(!0),await Te({msgId:At.id,relationId:At.relationId,message:At.content,agentId:At.agentId,command:At.agentCommand,startTime:At.replyStartTime,request:tt})}else At.role===2&&At.content?await Fe({relationId:At.relationId,chunk:At.content}):At.role===2&&At.componentId&&await pe({relationId:At.relationId,chunk:{kind:"component",component:At.componentId,value:At.componentValue}})}},[Te]);return r.useEffect(()=>{Se();const et=new m.CancellationTokenSource;return ie(!1),mt(et.token),()=>{et.cancel()}},[P.sessionModel]),r.createElement("div",{id:D.default.ai_chat_view},r.createElement("div",{className:D.default.header_container},r.createElement(Ve,{handleClear:Ie,handleCloseChatView:$e})),r.createElement("div",{className:D.default.body_container},r.createElement("div",{className:D.default.left_bar,id:"ai_chat_left_container"},r.createElement("div",{className:D.default.chat_container,ref:V},r.createElement(o.MessageList,{className:D.default.message_list,lockable:!0,toBottomHeight:"100%",dataSource:Z})),X.slicedMessageCount?r.createElement("div",{className:D.default.chat_tips_text},r.createElement("div",{className:D.default.chat_tips_container},(0,m.formatLocalize)("aiNative.chat.ai.assistant.limit.message",X.slicedMessageCount))):null,r.createElement("div",{className:D.default.chat_input_wrap},r.createElement(a.ChatContext,null),r.createElement("div",{className:D.default.header_operate},r.createElement("div",{className:D.default.header_operate_left},H.map(et=>r.createElement(p.Popover,{id:`ai-chat-shortcut-${et.name}`,key:`ai-chat-shortcut-${et.name}`,title:et.tooltip||et.name},r.createElement("div",{className:D.default.tag,onClick:()=>We(et)},et.name))))),r.createElement(Le,{onSend:(et,At,tt)=>le({message:et,agentId:At,command:tt,reportExtra:{actionSource:m.ActionSourceEnum.Chat,actionType:m.ActionTypeEnum.Send}}),disabled:oe,enableOptions:!0,theme:ge,setTheme:Me,agentId:he,setAgentId:_e,defaultAgentId:q,command:ye,setCommand:ne,ref:$})))))};t.AIChatView=M;function O({handleClear:P,handleCloseChatView:k}){const F=(0,l.useInjectable)(s.IDialogService),L=(0,l.useInjectable)(l.AINativeConfigService),B=(0,l.useInjectable)(g.TokenMCPServerProxyService),U=(0,l.useInjectable)(g.IChatInternalService),W=(0,l.useInjectable)(l.CommandService),[j,X]=r.useState([]),[V,$]=r.useState(""),Q=r.useCallback(()=>{U.sessionModel.history.getMessages().length>0&&U.createSessionModel()},[U]),G=r.useCallback(Y=>{U.activateSession(Y.id)},[U]),H=r.useCallback(Y=>{U.clearSessionModel(Y.id)},[U]),K=r.useCallback(()=>{W.executeCommand(S.OPEN_MCP_CONFIG_COMMAND.id)},[W]),Z=r.useCallback(async()=>{const Y=await B.getAllMCPTools();F.open({message:r.createElement(A.MCPToolsDialog,{tools:Y}),type:m.MessageType.Empty,buttons:["\u5173\u95ED"]})},[B,F]);return r.useEffect(()=>{const Y=()=>{const he=U.sessionModel.history.getMessages();$(he.length>0?he[he.length-1].content.slice(0,R):""),X(U.getSessions().map(_e=>{const Re=_e.history.getMessages(),ye=Re.length>0?Re[0].content.slice(0,R):"",ne=Re.length>0&&Re[Re.length-1].replyStartTime||0;return{id:_e.sessionId,title:ye,updatedAt:ne,loading:!1}}))};Y();const oe=new m.DisposableCollection,ie=new Set;return oe.push(U.onChangeSession(he=>{Y(),!ie.has(he)&&(ie.add(he),oe.push(U.sessionModel.history.onMessageChange(()=>{Y()})))})),oe.push(U.sessionModel.history.onMessageChange(()=>{Y()})),()=>{oe.dispose()}},[U]),r.createElement("div",{className:D.default.header},r.createElement(u.default,{className:D.default.chat_history,currentId:U.sessionModel.sessionId,title:V||(0,m.localize)("aiNative.chat.ai.assistant.name"),historyList:j,onNewChat:Q,onHistoryItemSelect:G,onHistoryItemDelete:H,onHistoryItemChange:()=>{}}),r.createElement(p.Popover,{overlayClassName:D.default.popover_icon,id:"ai-chat-header-clear",title:(0,m.localize)("aiNative.operate.clear.title")},r.createElement(v.EnhanceIcon,{wrapperClassName:D.default.action_btn,className:(0,l.getIcon)("clear"),onClick:P,tabIndex:0,role:"button",ariaLabel:(0,m.localize)("aiNative.operate.clear.title")})),L.capabilities.supportsMCP&&r.createElement(r.Fragment,null,r.createElement(p.Popover,{overlayClassName:D.default.popover_icon,id:"ai-chat-header-mcp-server",position:p.PopoverPosition.left,title:"MCP Server"},r.createElement(v.EnhanceIcon,{wrapperClassName:D.default.action_btn,className:"codicon codicon-server-environment",onClick:K,tabIndex:0,role:"button",ariaLabel:"MCP Server"})),r.createElement(p.Popover,{overlayClassName:D.default.popover_icon,id:"ai-chat-header-tools",position:p.PopoverPosition.left,title:(0,m.localize)("aiNative.operate.tools.title")},r.createElement(v.EnhanceIcon,{wrapperClassName:D.default.action_btn,className:(0,l.getIcon)("menubar-tool"),onClick:Z,tabIndex:0,role:"button",ariaLabel:(0,m.localize)("aiNative.operate.tools.title")}))),r.createElement(p.Popover,{overlayClassName:D.default.popover_icon,id:"ai-chat-header-close",position:p.PopoverPosition.left,title:(0,m.localize)("aiNative.operate.close.title")},r.createElement(v.EnhanceIcon,{wrapperClassName:D.default.action_btn,className:(0,l.getIcon)("window-close"),onClick:k,tabIndex:0,role:"button",ariaLabel:(0,m.localize)("aiNative.operate.close.title")})))}},55369:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContextSelector=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=e(45250),l=n.__importStar(e(14041)),p=e(58998),v=e(41869),m=e(81878),_=e(95263),s=e(95422),g=e(15625),a=e(70392),h=n.__importDefault(e(97431)),u=(0,l.memo)(({uri:d,active:E,selected:f,onDidSelect:c,onDidDeselect:b})=>{var y;const S=(0,s.useInjectable)(v.LabelService),A=(0,s.useInjectable)(v.AppConfig),w=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(E&&w.current){const T={behavior:"instant",block:"end"};w.current.scrollIntoView(T)}},[E,w.current]),l.default.createElement("div",{className:(0,r.default)(h.default.candidate_file,E&&h.default.active),ref:T=>w.current=T,onClick:()=>f?b(d):c(d)},l.default.createElement(m.Icon,{iconClass:S.getIcon(d)}),l.default.createElement("span",{className:h.default.basename},d.path.base),l.default.createElement("span",{className:h.default.dir},(y=a.URI.file(A.workspaceDir).relative(d.parent))===null||y===void 0?void 0:y.toString()),f&&l.default.createElement(m.Icon,{icon:"check",style:{marginLeft:"auto",color:"var(--editorGutter-addedBackground)"}}))});t.ContextSelector=(0,l.memo)(({addedFiles:d,onDidDeselect:E,onDidSelect:f,onDidClose:c})=>{const[b,y]=(0,l.useState)([]),[S,A]=(0,l.useState)(null),[w,T]=(0,l.useState)(!1),[D,I]=(0,l.useState)([]),R=(0,s.useInjectable)(_.RecentFilesManager),M=(0,s.useInjectable)(v.AppConfig),O=(0,s.useInjectable)(g.FileSearchServicePath),P=(0,l.useRef)();(0,l.useEffect)(()=>{b.length===0&&R.getMostRecentlyOpenedFiles().then(L=>{const B=d.map(W=>W.uri),U=L.filter(W=>!B.includes(new a.URI(W))).map(W=>new a.URI(W));y(U),A(U[0]||null)})},[d]);const k=(0,l.useCallback)((0,o.debounce)(L=>{if(L.target.value.trim()===""){I([]),A(b[0]);return}T(!0),O.find(L.target.value,{rootUris:[M.workspaceDir],limit:200,useGitIgnore:!0,noIgnoreParent:!0,fuzzyMatch:!0}).then(B=>{const U=B.map(W=>new a.URI(W));I(U),A(U[0])}).finally(()=>{T(!1)})},500),[]),F=(0,l.useCallback)(L=>{const{key:B}=L;if(B==="Escape"){c();return}if(B==="Enter"&&S){f(S);return}if(!["ArrowUp","ArrowDown"].includes(B))return;const W=D.length>0?D:b;if(W.length===0)return;const j=W.indexOf(S),X=j===-1?0:j,V=W.length-1,$=B==="ArrowUp"?X>0?X-1:V:X<V?X+1:0;A(W[$])},[S,D,b]);return l.default.createElement(p.ClickOutside,{mouseEvents:["click","contextmenu"],onOutsideClick:()=>c()},l.default.createElement("div",{className:h.default.context_selector,onKeyDown:F,tabIndex:-1},l.default.createElement("div",{style:{padding:"4px"}},l.default.createElement(m.Input,{placeholder:"Search files by name",autoFocus:!0,onInput:k})),l.default.createElement(m.Scrollbars,{forwardedRef:L=>L?P.current=L.ref:null},l.default.createElement("div",{className:h.default.context_list},w&&l.default.createElement("div",{className:h.default.context_search_layer}),l.default.createElement("span",{className:h.default.list_desc},D.length>0?"Search Results":"Recent Opened Files"),(D.length>0?D:b).map(L=>l.default.createElement(u,{key:L.toString(),uri:L,active:S===L,onDidSelect:f,onDidDeselect:E,selected:!!d.find(B=>B.uri.isEqual(L))}))))))})},27399:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatContext=void 0;const n=e(85608),r=n.__importStar(e(1171)),o=n.__importStar(e(14041));e(628);const l=e(80564),p=e(81878),v=e(89195),m=e(95422),_=e(11050),s=e(63214),g=e(33783),a=e(86560),h=e(82196),u=e(46044),d=e(55369),E=n.__importDefault(e(97431)),f=()=>({height:0,opacity:0}),c=S=>({height:S.scrollHeight,opacity:1}),b=S=>({height:S.offsetHeight}),y=(S,A)=>A.propertyName==="height";t.ChatContext=(0,o.memo)(()=>{const[S,A]=(0,o.useState)([]),[w,T]=(0,o.useState)(!1),D=(0,m.useInjectable)(s.LabelService),I=(0,m.useInjectable)(_.AppConfig),R=(0,m.useInjectable)(h.WorkbenchEditorService),M=(0,m.useInjectable)(u.LLMContextServiceToken);(0,o.useEffect)(()=>{const U=a.Event.debounce(M.onDidContextFilesChangeEvent,(W,j)=>j,50)(W=>{W&&A([...W.attached])},M);return()=>{U.dispose()}},[]);const O=(0,o.useCallback)(()=>{T(!0)},[S]),P=(0,o.useCallback)(U=>{M.addFileToContext(U,void 0,!0)},[]),k=(0,o.useCallback)(U=>{M.removeFileFromContext(U,!0)},[]),F=(0,o.useCallback)(U=>{R.open(U)},[]),L=(0,o.useCallback)(U=>{U.stopPropagation(),U.preventDefault(),M.cleanFileContext()},[]),B=(0,o.useCallback)((U,W)=>{U.stopPropagation(),U.preventDefault(),k(W)},[]);return o.default.createElement("div",{className:E.default.chat_context},o.default.createElement(r.default,{expandIcon:({isActive:U})=>U?o.default.createElement(l.Icon,{icon:"down"}):o.default.createElement(l.Icon,{icon:"right"}),openMotion:{motionName:"rc-collapse-motion",onEnterStart:f,onEnterActive:c,onLeaveStart:b,onLeaveActive:f,onEnterEnd:y,onLeaveEnd:y,motionDeadline:100,leavedClassName:E.default.collapse_hide}},o.default.createElement(r.Panel,{header:o.default.createElement("div",{className:E.default.context_header},o.default.createElement("h3",{className:E.default.chat_context_title},"Context ",S.length>0?` (${S.length} files)`:""),o.default.createElement(p.Popover,{overlayClassName:E.default.popover_icon,id:"ai-context-header-clear",title:(0,g.localize)("aiNative.operate.clear.title")},o.default.createElement(v.EnhanceIcon,{wrapperClassName:E.default.action_btn,className:(0,p.getIcon)("clear"),onClick:L,tabIndex:0,role:"button",ariaLabel:(0,g.localize)("aiNative.operate.clear.title")}))),key:"context-panel"},o.default.createElement("div",{className:E.default.file_list},S.map(U=>{var W;return o.default.createElement("div",{className:E.default.selected_item,key:U.uri.toString(),onClick:()=>F(U.uri)},o.default.createElement(l.Icon,{iconClass:D.getIcon(U.uri)}),o.default.createElement("span",{className:E.default.basename},U.uri.path.base,U.selection?` (${U.selection[0]}-${U.selection[1]})`:""),o.default.createElement("span",{className:E.default.dir},(W=a.URI.file(I.workspaceDir).relative(U.uri.parent))===null||W===void 0?void 0:W.toString()),o.default.createElement(l.Icon,{icon:"close",className:E.default.close_icon,onClick:j=>B(j,U.uri)}))})),o.default.createElement("div",{className:E.default.add_context,onClick:O},o.default.createElement(l.Icon,{icon:"add"}),"Add Files"))),w&&o.default.createElement(d.ContextSelector,{onDidClose:()=>T(!1),onDidDeselect:k,onDidSelect:P,addedFiles:S}))})},25834:(x,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.__importStar(e(14041)),l=n.__importDefault(e(10580)),p=e(41869),v=e(81878),m=e(89195),_=e(43718),s=e(71624),g=e(9447),a=e(52416),h=n.__importDefault(e(6960)),u=e(83933);e(38191);const d=b=>{const{input:y,language:S,relationId:A,agentId:w,command:T,hideInsert:D}=b,I=o.default.useRef(null),R=(0,p.useInjectable)(g.MonacoCommandRegistry),M=(0,p.useInjectable)(p.IClipboardService),O=(0,p.useInjectable)(a.IThemeService),P=(0,p.useInjectable)(_.IAIReporter),[k,F]=(0,o.useState)(!1),L=(0,o.useMemo)(()=>(0,p.uuid)(12),[I,I.current]);(0,o.useEffect)(()=>{const W=V=>{V.type==="dark"||V.type==="hcDark"?e.e(622).then(e.bind(e,51622)):(V.type==="light"||V.type==="hcLight")&&e.e(412).then(e.bind(e,50412))},j=O.onThemeChange(V=>{W(V)}),X=O.getCurrentThemeSync();return W(X),()=>j.dispose()},[]);const B=(0,o.useCallback)(async()=>{F(!0),await M.writeText(y),P.end(A,{copy:!0,code:y,language:S,agentId:w,command:T,actionSource:_.ActionSourceEnum.Chat,actionType:_.ActionTypeEnum.ChatCopyCode}),(0,_.runWhenIdle)(()=>{F(!1)},1e3)},[M,y,A]),U=(0,o.useCallback)(()=>{const W=R.getActiveCodeEditor();if(W){const j=W.getSelection();j&&((0,s.insertSnippetWithMonacoEditor)(W,y,[j],{undoStopBefore:!1,undoStopAfter:!1}),P.end(A,{insert:!0,code:y,language:S,agentId:w,command:T,actionSource:_.ActionSourceEnum.Chat,actionType:_.ActionTypeEnum.ChatInsertCode}))}},[R]);return o.default.createElement("div",{className:h.default.monaco_wrapper},o.default.createElement("div",{className:h.default.action_toolbar},!D&&o.default.createElement(v.Popover,{id:`ai-chat-inser-${L}`,title:(0,_.localize)("aiNative.chat.code.insert")},o.default.createElement(m.EnhanceIcon,{className:(0,p.getIcon)("insert"),onClick:()=>U(),tabIndex:0,role:"button",ariaLabel:(0,_.localize)("aiNative.chat.code.insert")})),o.default.createElement(v.Popover,{id:`ai-chat-copy-${L}`,title:(0,_.localize)(k?"aiNative.chat.code.copy.success":"aiNative.chat.code.copy")},o.default.createElement(m.EnhanceIcon,{className:(0,p.getIcon)("copy"),onClick:()=>B(),tabIndex:0,role:"button",ariaLabel:(0,_.localize)("aiNative.chat.code.copy")}))),o.default.createElement(l.default,{language:S,ref:I,className:h.default.editor},y))};t.CodeEditorWithHighlight=d;const E=({content:b="",relationId:y,renderText:S,agentId:A="",command:w=""})=>{const T=/`([^`]+)`/g,D=/```([^]+?)```/g,I=/```([^]+)?/g,R=O=>{const P=O.split(`
|
|
29734
|
+
</user_info>`},invoke:async(f,c,b,y)=>{this.chatDeferred=new p.Deferred;const{message:S,command:A}=f;let w=S;if(A){const O=this.chatFeatureRegistry.getSlashCommandHandler(A);if(O&&O.providerPrompt){const P=this.monacoCommandRegistry.getActiveCodeEditor();w=await O.providerPrompt(S,P)}}const T=this.preferenceService.get(v.AINativeSettingSectionsId.LLMModelSelection);let D="",I="";T==="deepseek"?D=this.preferenceService.get(v.AINativeSettingSectionsId.DeepseekApiKey,""):T==="openai"?(D=this.preferenceService.get(v.AINativeSettingSectionsId.OpenaiApiKey,""),I=this.preferenceService.get(v.AINativeSettingSectionsId.OpenaiBaseURL,"")):D=this.preferenceService.get(v.AINativeSettingSectionsId.AnthropicApiKey,"");const M=await this.aiBackService.requestStream(w,{requestId:f.requestId,sessionId:f.sessionId,history:this.aiChatService.getHistoryMessages(30720),clientId:this.applicationService.clientId,apiKey:D,model:T,baseURL:I},y);return(0,s.listenReadable)(M,{onData:O=>{c(O)},onEnd:()=>{this.chatDeferred.resolve()},onError:O=>{this.messageService.error(O.message),this.aiReporter.end(f.sessionId+"_"+f.requestId,{message:O.message,success:!1,command:A})}}),await this.chatDeferred.promise,{}},provideSlashCommands:async f=>this.chatFeatureRegistry.getAllSlashCommand().map(c=>({...c,name:c.name,description:c.description||""})),provideChatWelcomeMessage:async f=>{}})),queueMicrotask(()=>{this.chatAgentService.updateAgent(n.AGENT_ID,{})})}};t.ChatProxyService=d,d.AGENT_ID="Default_Chat_Agent",r.__decorate([(0,o.Autowired)(g.IChatAgentService),r.__metadata("design:type",Object)],d.prototype,"chatAgentService",void 0),r.__decorate([(0,o.Autowired)(p.AIBackSerivcePath),r.__metadata("design:type",Object)],d.prototype,"aiBackService",void 0),r.__decorate([(0,o.Autowired)(p.ChatFeatureRegistryToken),r.__metadata("design:type",u.ChatFeatureRegistry)],d.prototype,"chatFeatureRegistry",void 0),r.__decorate([(0,o.Autowired)(m.MonacoCommandRegistry),r.__metadata("design:type",m.MonacoCommandRegistry)],d.prototype,"monacoCommandRegistry",void 0),r.__decorate([(0,o.Autowired)(p.ChatServiceToken),r.__metadata("design:type",h.ChatService)],d.prototype,"aiChatService",void 0),r.__decorate([(0,o.Autowired)(p.IAIReporter),r.__metadata("design:type",Object)],d.prototype,"aiReporter",void 0),r.__decorate([(0,o.Autowired)(p.ChatAgentViewServiceToken),r.__metadata("design:type",Object)],d.prototype,"chatAgentViewService",void 0),r.__decorate([(0,o.Autowired)(l.PreferenceService),r.__metadata("design:type",Object)],d.prototype,"preferenceService",void 0),r.__decorate([(0,o.Autowired)(p.IApplicationService),r.__metadata("design:type",Object)],d.prototype,"applicationService",void 0),r.__decorate([(0,o.Autowired)(_.IMessageService),r.__metadata("design:type",Object)],d.prototype,"messageService",void 0),r.__decorate([(0,o.Autowired)(l.AppConfig),r.__metadata("design:type",Object)],d.prototype,"appConfig",void 0),t.ChatProxyService=d=n=r.__decorate([(0,o.Injectable)()],d)},29770:(x,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),p=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(p.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)}getHistoryMessages(s){var g;return((g=this.chatInternalService.sessionModel)===null||g===void 0?void 0:g.history.getMessages(s))||[]}scrollToBottom(){this._onScrollToBottom.fire()}};t.ChatService=m,n.__decorate([(0,r.Autowired)(p.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:(x,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),p=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}dispose(){super.dispose(),this.slashCommandsMap.clear(),this.slashCommandsHandlerMap.clear()}registerWelcome(s,g){this.chatWelcomeMessageModel=new p.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 p.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:(x,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),p=e(43718),v=e(19413),m=e(61282);let _=class extends p.Disposable{constructor(){super(...arguments),this._onChangeRequestId=new p.Emitter,this.onChangeRequestId=this._onChangeRequestId.event,this._onChangeSession=new p.Emitter,this.onChangeSession=this._onChangeSession.event,this._onCancelRequest=new p.Emitter,this.onCancelRequest=this._onCancelRequest.event,this._onRegenerateRequest=new p.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){return this.chatManagerService.createRequest(r.__classPrivateFieldGet(this,n,"f").sessionId,g,a,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.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()}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=_,n=new WeakMap,r.__decorate([(0,o.Autowired)(p.AIBackSerivcePath),r.__metadata("design:type",Object)],_.prototype,"aiBackService",void 0),r.__decorate([(0,o.Autowired)(l.PreferenceService),r.__metadata("design:type",Object)],_.prototype,"preferenceService",void 0),r.__decorate([(0,o.Autowired)(v.IChatManagerService),r.__metadata("design:type",m.ChatManagerService)],_.prototype,"chatManagerService",void 0),t.ChatInternalService=_=r.__decorate([(0,o.Injectable)()],_)},70394:(x,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:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AIChatView=void 0,t.DefaultChatViewHeader=O;const n=e(85608),r=n.__importStar(e(14041)),o=e(68392),l=e(41869),p=e(81878),v=e(89195),m=e(43718),_=e(63067),s=e(72665);e(41937);const g=e(19413),a=e(27399),h=e(25834),u=n.__importDefault(e(90103)),d=e(57987),E=e(56474),f=e(92635),c=e(29039),b=e(78048),y=e(86556),S=e(27397),A=e(30703),w=e(42033),T=e(51081),D=n.__importDefault(e(77256)),I="chat_scroll",R=100,M=()=>{const P=(0,l.useInjectable)(g.IChatInternalService),k=(0,l.useInjectable)(m.ChatServiceToken),F=(0,l.useInjectable)(m.IAIReporter),L=(0,l.useInjectable)(g.IChatAgentService),B=(0,l.useInjectable)(m.ChatFeatureRegistryToken),U=(0,l.useInjectable)(m.ChatRenderRegistryToken),W=(0,l.useInjectable)(g.TokenMCPServerProxyService),j=(0,l.useInjectable)(_.IMainLayoutService),X=P.sessionModel.history,V=r.useRef(null),$=r.useRef(null),Q=(0,l.useInjectable)(s.IDialogService),G=(0,l.useInjectable)(l.CommandService),[H,K]=r.useState([]),[Z,Y]=r.useReducer((et,At)=>{switch(At.type){case"add":return[...et,...At.payload||[]];case"clear":return[];case"init":return Array.isArray(At.payload)?At.payload:[];default:return et}},[]),[oe,ie]=r.useState(!1),[he,_e]=r.useState(""),[q,Re]=r.useState(""),[ye,ne]=r.useState(""),[ge,Me]=r.useState(null);r.useEffect(()=>{const et=B.getAllShortcutSlashCommand(),At=L.onDidChangeAgents(()=>{const tt=L.getCommands().filter(yt=>yt.isShortcut).map(yt=>new w.ChatSlashCommandItemModel({icon:"",name:`${yt.name} `,description:yt.description,isShortcut:yt.isShortcut},yt.name,yt.agentId));K(et.concat(tt))});return K(et),()=>At.dispose()},[B,L]),(0,l.useUpdateOnEvent)(P.onChangeSession);const Le=r.useMemo(()=>U.chatInputRender?U.chatInputRender:d.ChatInput,[U.chatInputRender]),Ce=r.useMemo(()=>(0,b.createMessageByAI)({id:(0,m.uuid)(6),relationId:"",text:r.createElement(y.WelcomeMessage,null)}),[]),Ae=r.useCallback(()=>{if(V&&V.current){const et=V.current.lastElementChild;et&&et.scrollIntoView({behavior:"smooth",block:"end"}),V.current.scrollHeight>V.current.clientHeight&&V.current.classList.add(I)}},[V]),ve=r.useCallback(et=>{Y(et),requestAnimationFrame(()=>{Ae()})},[Y,Ae]);r.useEffect(()=>{ve({type:"init",payload:[Ce]})},[]),r.useEffect(()=>{const et=new m.Disposable;return et.addDispose(k.onScrollToBottom(()=>{requestAnimationFrame(()=>{Ae()})})),et.addDispose(k.onChatMessageLaunch(async At=>{var tt;if(At.immediate!==!1){if(oe)return;await le(At)}else At.agentId&&_e(At.agentId),At.command&&ne(At.command),(tt=$?.current)===null||tt===void 0||tt.setInputValue(At.message)})),et.addDispose(k.onChatReplyMessageLaunch(At=>{if(At.kind==="content"){const tt=F.start(m.AIServiceType.CustomReplay,{message:At.content});X.addAssistantMessage({content:At.content,relationId:tt}),Fe({chunk:At.content,relationId:tt})}else{const tt=F.start(m.AIServiceType.CustomReplay,{message:"component#"+At.component});X.addAssistantMessage({componentId:At.component,componentValue:At.value,content:"",relationId:tt}),pe({chunk:At,relationId:tt})}})),et.addDispose(k.onChatMessageListLaunch(At=>{const tt=[];At.forEach(yt=>{const{role:it}=yt,ct=F.start(m.AIServiceType.Chat,{message:""});if(it==="assistant"){const ht=yt;tt.push((0,b.createMessageByAI)({id:(0,m.uuid)(6),relationId:ct,text:r.createElement(f.ChatNotify,{requestId:ct,chunk:ht})},D.default.chat_notify))}if(it==="user"){const{message:ht}=yt,St=T.ChatProxyService.AGENT_ID,Vt=U.chatUserRoleRender,En=St===T.ChatProxyService.AGENT_ID?"":St;tt.push((0,b.createMessageByUser)({id:(0,m.uuid)(6),relationId:ct,text:Vt?r.createElement(Vt,{content:ht,agentId:En}):r.createElement(h.CodeBlockWrapperInput,{relationId:ct,text:ht,agentId:En,command:ye})},D.default.chat_message_code))}}),ve({type:"add",payload:tt}),setTimeout(Ae,0)})),()=>et.dispose()},[k,U.chatAIRoleRender,X]),r.useEffect(()=>{const et=new m.Disposable;return et.addDispose(L.onDidSendMessage(At=>{const tt=At,yt=F.start(m.AIServiceType.Agent,{message:""}),it=(0,b.createMessageByAI)({id:(0,m.uuid)(6),relationId:yt,text:r.createElement(f.ChatNotify,{requestId:P.latestRequestId,chunk:tt})},D.default.chat_notify);ve({type:"add",payload:[it]})})),et.addDispose(L.onDidChangeAgents(async()=>{const At=L.getDefaultAgentId();Re(At??"")})),()=>et.dispose()},[L,X,P]);const fe=r.useCallback(async et=>{const{userMessage:At,relationId:tt,requestId:yt,render:it,startTime:ct,command:ht,agentId:St}=et;X.addAssistantMessage({type:"component",content:""});const Vt=(0,b.createMessageByAI)({id:(0,m.uuid)(6),relationId:tt,className:D.default.chat_with_more_actions,text:r.createElement(c.SlashCustomRender,{userMessage:At,startTime:ct,relationId:tt,requestId:yt,renderContent:it,command:ht,agentId:St})});ve({type:"add",payload:[Vt]})},[V,X]),xe=r.useCallback(async et=>{const At=U.chatUserRoleRender,{message:tt,agentId:yt,relationId:it,command:ct}=et,ht=yt===T.ChatProxyService.AGENT_ID?"":yt,St=(0,b.createMessageByUser)({id:(0,m.uuid)(6),relationId:it,text:At?r.createElement(At,{content:tt,agentId:ht,command:ct}):r.createElement(h.CodeBlockWrapperInput,{relationId:it,text:tt,agentId:ht,command:ct})},D.default.chat_message_code);ve({type:"add",payload:[St]})},[U,U.chatUserRoleRender,X,Ae]),Te=r.useCallback(async et=>{const{message:At,agentId:tt,request:yt,relationId:it,command:ct,startTime:ht,msgId:St}=et,Vt=tt===T.ChatProxyService.AGENT_ID?"":tt;if(tt===T.ChatProxyService.AGENT_ID&&ct){const Wn=B.getSlashCommandHandler(ct);if(Wn&&Wn.providerRender)return ie(!1),fe({userMessage:At,render:Wn.providerRender,relationId:it,requestId:yt.requestId,startTime:ht,agentId:tt,command:ct})}const En=(0,b.createMessageByAI)({id:(0,m.uuid)(6),relationId:it,className:D.default.chat_with_more_actions,text:r.createElement(f.ChatReply,{relationId:it,request:yt,startTime:ht,agentId:Vt,command:ct,onDidChange:()=>{Ae()},history:X,onDone:()=>{ie(!1)},onRegenerate:()=>{yt&&P.sendRequest(yt,!0)},msgId:St})});ve({type:"add",payload:[En]})},[U,X,Ae]),Fe=r.useCallback(et=>{const{chunk:At,relationId:tt}=et;let yt=r.createElement(E.ChatMarkdown,{markdown:At,fillInIncompleteTokens:!0,agentId:he,command:ye});if(U.chatAIRoleRender){const ct=U.chatAIRoleRender;yt=r.createElement(ct,{content:At})}const it=(0,b.createMessageByAI)({id:(0,m.uuid)(6),relationId:tt,text:yt,className:D.default.chat_with_more_actions});ve({type:"add",payload:[it]})},[U,X,Ae]),pe=r.useCallback(et=>{const{chunk:At,relationId:tt}=et,yt=(0,b.createMessageByAI)({id:(0,m.uuid)(6),relationId:tt,text:r.createElement(f.ChatNotify,{requestId:tt,chunk:At})},D.default.chat_notify);ve({type:"add",payload:[yt]})},[U,X,Ae]),re=r.useCallback(async et=>{const{message:At,agentId:tt,command:yt,reportExtra:it}=et,{actionType:ct,actionSource:ht}=it||{},St=P.createRequest(At,tt,yt);if(!St)return;ie(!0),P.setLatestRequestId(St.requestId);const Vt=Date.now(),En=T.ChatProxyService.AGENT_ID===tt?m.AIServiceType.Chat:m.AIServiceType.Agent,Wn=F.start(yt||En,{message:At,agentId:tt,userMessage:At,actionType:ct,actionSource:ht});X.addUserMessage({content:At,agentId:tt,agentCommand:yt,relationId:Wn}),await xe({relationId:Wn,message:At,command:yt,agentId:tt}),P.sendRequest(St);const Ei=X.addAssistantMessage({content:"",relationId:Wn,requestId:St.requestId,replyStartTime:Vt});await Te({startTime:Vt,relationId:Wn,message:At,agentId:tt,command:yt,request:St,msgId:Ei})},[U,U.chatUserRoleRender,X,Ae]),le=r.useCallback(async et=>{const{message:At,command:tt,reportExtra:yt}=et,it=et.agentId?et.agentId:T.ChatProxyService.AGENT_ID;return re({message:At,agentId:it,command:tt,reportExtra:yt})},[re]),Ie=r.useCallback(()=>{P.clearSessionModel(),k.clearHistoryMessages(),Se()},[Z]),Se=r.useCallback(()=>{var et;(et=V?.current)===null||et===void 0||et.classList.remove(I),ve({type:"init",payload:[Ce]})},[Z]),We=et=>{oe||(Me(et.nameWithSlash),_e(et.agentId),ne(et.command))},$e=r.useCallback(()=>{j.toggleSlot(g.AI_CHAT_VIEW_ID)},[j]),Ve=U.chatViewHeaderRender||O,mt=r.useCallback(async et=>{for(const At of X.getMessages()){if(et.isCancellationRequested)return;if(At.role===1)await xe({relationId:At.relationId,message:At.content,agentId:At.agentId,command:At.agentCommand});else if(At.role===2&&At.requestId){const tt=P.sessionModel.getRequest(At.requestId);tt&&!tt.response.isComplete&&ie(!0),await Te({msgId:At.id,relationId:At.relationId,message:At.content,agentId:At.agentId,command:At.agentCommand,startTime:At.replyStartTime,request:tt})}else At.role===2&&At.content?await Fe({relationId:At.relationId,chunk:At.content}):At.role===2&&At.componentId&&await pe({relationId:At.relationId,chunk:{kind:"component",component:At.componentId,value:At.componentValue}})}},[Te]);return r.useEffect(()=>{Se();const et=new m.CancellationTokenSource;return ie(!1),mt(et.token),()=>{et.cancel()}},[P.sessionModel]),r.createElement("div",{id:D.default.ai_chat_view},r.createElement("div",{className:D.default.header_container},r.createElement(Ve,{handleClear:Ie,handleCloseChatView:$e})),r.createElement("div",{className:D.default.body_container},r.createElement("div",{className:D.default.left_bar,id:"ai_chat_left_container"},r.createElement("div",{className:D.default.chat_container,ref:V},r.createElement(o.MessageList,{className:D.default.message_list,lockable:!0,toBottomHeight:"100%",dataSource:Z})),X.slicedMessageCount?r.createElement("div",{className:D.default.chat_tips_text},r.createElement("div",{className:D.default.chat_tips_container},(0,m.formatLocalize)("aiNative.chat.ai.assistant.limit.message",X.slicedMessageCount))):null,r.createElement("div",{className:D.default.chat_input_wrap},r.createElement(a.ChatContext,null),r.createElement("div",{className:D.default.header_operate},r.createElement("div",{className:D.default.header_operate_left},H.map(et=>r.createElement(p.Popover,{id:`ai-chat-shortcut-${et.name}`,key:`ai-chat-shortcut-${et.name}`,title:et.tooltip||et.name},r.createElement("div",{className:D.default.tag,onClick:()=>We(et)},et.name))))),r.createElement(Le,{onSend:(et,At,tt)=>le({message:et,agentId:At,command:tt,reportExtra:{actionSource:m.ActionSourceEnum.Chat,actionType:m.ActionTypeEnum.Send}}),disabled:oe,enableOptions:!0,theme:ge,setTheme:Me,agentId:he,setAgentId:_e,defaultAgentId:q,command:ye,setCommand:ne,ref:$})))))};t.AIChatView=M;function O({handleClear:P,handleCloseChatView:k}){const F=(0,l.useInjectable)(s.IDialogService),L=(0,l.useInjectable)(l.AINativeConfigService),B=(0,l.useInjectable)(g.TokenMCPServerProxyService),U=(0,l.useInjectable)(g.IChatInternalService),W=(0,l.useInjectable)(l.CommandService),[j,X]=r.useState([]),[V,$]=r.useState(""),Q=r.useCallback(()=>{U.sessionModel.history.getMessages().length>0&&U.createSessionModel()},[U]),G=r.useCallback(Y=>{U.activateSession(Y.id)},[U]),H=r.useCallback(Y=>{U.clearSessionModel(Y.id)},[U]),K=r.useCallback(()=>{W.executeCommand(S.OPEN_MCP_CONFIG_COMMAND.id)},[W]),Z=r.useCallback(async()=>{const Y=await B.getAllMCPTools();F.open({message:r.createElement(A.MCPToolsDialog,{tools:Y}),type:m.MessageType.Empty,buttons:["\u5173\u95ED"]})},[B,F]);return r.useEffect(()=>{const Y=()=>{const he=U.sessionModel.history.getMessages();$(he.length>0?he[he.length-1].content.slice(0,R):""),X(U.getSessions().map(_e=>{const Re=_e.history.getMessages(),ye=Re.length>0?Re[0].content.slice(0,R):"",ne=Re.length>0&&Re[Re.length-1].replyStartTime||0;return{id:_e.sessionId,title:ye,updatedAt:ne,loading:!1}}))};Y();const oe=new m.DisposableCollection,ie=new Set;return oe.push(U.onChangeSession(he=>{Y(),!ie.has(he)&&(ie.add(he),oe.push(U.sessionModel.history.onMessageChange(()=>{Y()})))})),oe.push(U.sessionModel.history.onMessageChange(()=>{Y()})),()=>{oe.dispose()}},[U]),r.createElement("div",{className:D.default.header},r.createElement(u.default,{className:D.default.chat_history,currentId:U.sessionModel.sessionId,title:V||(0,m.localize)("aiNative.chat.ai.assistant.name"),historyList:j,onNewChat:Q,onHistoryItemSelect:G,onHistoryItemDelete:H,onHistoryItemChange:()=>{}}),r.createElement(p.Popover,{overlayClassName:D.default.popover_icon,id:"ai-chat-header-clear",title:(0,m.localize)("aiNative.operate.clear.title")},r.createElement(v.EnhanceIcon,{wrapperClassName:D.default.action_btn,className:(0,l.getIcon)("clear"),onClick:P,tabIndex:0,role:"button",ariaLabel:(0,m.localize)("aiNative.operate.clear.title")})),L.capabilities.supportsMCP&&r.createElement(r.Fragment,null,r.createElement(p.Popover,{overlayClassName:D.default.popover_icon,id:"ai-chat-header-mcp-server",position:p.PopoverPosition.left,title:"MCP Server"},r.createElement(v.EnhanceIcon,{wrapperClassName:D.default.action_btn,className:"codicon codicon-server",onClick:K,tabIndex:0,role:"button",ariaLabel:"MCP Server"})),r.createElement(p.Popover,{overlayClassName:D.default.popover_icon,id:"ai-chat-header-tools",position:p.PopoverPosition.left,title:(0,m.localize)("aiNative.operate.tools.title")},r.createElement(v.EnhanceIcon,{wrapperClassName:D.default.action_btn,className:(0,l.getIcon)("menubar-tool"),onClick:Z,tabIndex:0,role:"button",ariaLabel:(0,m.localize)("aiNative.operate.tools.title")}))),r.createElement(p.Popover,{overlayClassName:D.default.popover_icon,id:"ai-chat-header-close",position:p.PopoverPosition.left,title:(0,m.localize)("aiNative.operate.close.title")},r.createElement(v.EnhanceIcon,{wrapperClassName:D.default.action_btn,className:(0,l.getIcon)("window-close"),onClick:k,tabIndex:0,role:"button",ariaLabel:(0,m.localize)("aiNative.operate.close.title")})))}},55369:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContextSelector=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=e(45250),l=n.__importStar(e(14041)),p=e(58998),v=e(41869),m=e(81878),_=e(95263),s=e(95422),g=e(15625),a=e(70392),h=n.__importDefault(e(97431)),u=(0,l.memo)(({uri:d,active:E,selected:f,onDidSelect:c,onDidDeselect:b})=>{var y;const S=(0,s.useInjectable)(v.LabelService),A=(0,s.useInjectable)(v.AppConfig),w=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(E&&w.current){const T={behavior:"instant",block:"end"};w.current.scrollIntoView(T)}},[E,w.current]),l.default.createElement("div",{className:(0,r.default)(h.default.candidate_file,E&&h.default.active),ref:T=>w.current=T,onClick:()=>f?b(d):c(d)},l.default.createElement(m.Icon,{iconClass:S.getIcon(d)}),l.default.createElement("span",{className:h.default.basename},d.path.base),l.default.createElement("span",{className:h.default.dir},(y=a.URI.file(A.workspaceDir).relative(d.parent))===null||y===void 0?void 0:y.toString()),f&&l.default.createElement(m.Icon,{icon:"check",style:{marginLeft:"auto",color:"var(--editorGutter-addedBackground)"}}))});t.ContextSelector=(0,l.memo)(({addedFiles:d,onDidDeselect:E,onDidSelect:f,onDidClose:c})=>{const[b,y]=(0,l.useState)([]),[S,A]=(0,l.useState)(null),[w,T]=(0,l.useState)(!1),[D,I]=(0,l.useState)([]),R=(0,s.useInjectable)(_.RecentFilesManager),M=(0,s.useInjectable)(v.AppConfig),O=(0,s.useInjectable)(g.FileSearchServicePath),P=(0,l.useRef)();(0,l.useEffect)(()=>{b.length===0&&R.getMostRecentlyOpenedFiles().then(L=>{const B=d.map(W=>W.uri),U=L.filter(W=>!B.includes(new a.URI(W))).map(W=>new a.URI(W));y(U),A(U[0]||null)})},[d]);const k=(0,l.useCallback)((0,o.debounce)(L=>{if(L.target.value.trim()===""){I([]),A(b[0]);return}T(!0),O.find(L.target.value,{rootUris:[M.workspaceDir],limit:200,useGitIgnore:!0,noIgnoreParent:!0,fuzzyMatch:!0}).then(B=>{const U=B.map(W=>new a.URI(W));I(U),A(U[0])}).finally(()=>{T(!1)})},500),[]),F=(0,l.useCallback)(L=>{const{key:B}=L;if(B==="Escape"){c();return}if(B==="Enter"&&S){f(S);return}if(!["ArrowUp","ArrowDown"].includes(B))return;const W=D.length>0?D:b;if(W.length===0)return;const j=W.indexOf(S),X=j===-1?0:j,V=W.length-1,$=B==="ArrowUp"?X>0?X-1:V:X<V?X+1:0;A(W[$])},[S,D,b]);return l.default.createElement(p.ClickOutside,{mouseEvents:["click","contextmenu"],onOutsideClick:()=>c()},l.default.createElement("div",{className:h.default.context_selector,onKeyDown:F,tabIndex:-1},l.default.createElement("div",{style:{padding:"4px"}},l.default.createElement(m.Input,{placeholder:"Search files by name",autoFocus:!0,onInput:k})),l.default.createElement(m.Scrollbars,{forwardedRef:L=>L?P.current=L.ref:null},l.default.createElement("div",{className:h.default.context_list},w&&l.default.createElement("div",{className:h.default.context_search_layer}),l.default.createElement("span",{className:h.default.list_desc},D.length>0?"Search Results":"Recent Opened Files"),(D.length>0?D:b).map(L=>l.default.createElement(u,{key:L.toString(),uri:L,active:S===L,onDidSelect:f,onDidDeselect:E,selected:!!d.find(B=>B.uri.isEqual(L))}))))))})},27399:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatContext=void 0;const n=e(85608),r=n.__importStar(e(1171)),o=n.__importStar(e(14041));e(628);const l=e(80564),p=e(81878),v=e(89195),m=e(95422),_=e(11050),s=e(63214),g=e(33783),a=e(86560),h=e(82196),u=e(46044),d=e(55369),E=n.__importDefault(e(97431)),f=()=>({height:0,opacity:0}),c=S=>({height:S.scrollHeight,opacity:1}),b=S=>({height:S.offsetHeight}),y=(S,A)=>A.propertyName==="height";t.ChatContext=(0,o.memo)(()=>{const[S,A]=(0,o.useState)([]),[w,T]=(0,o.useState)(!1),D=(0,m.useInjectable)(s.LabelService),I=(0,m.useInjectable)(_.AppConfig),R=(0,m.useInjectable)(h.WorkbenchEditorService),M=(0,m.useInjectable)(u.LLMContextServiceToken);(0,o.useEffect)(()=>{const U=a.Event.debounce(M.onDidContextFilesChangeEvent,(W,j)=>j,50)(W=>{W&&A([...W.attached])},M);return()=>{U.dispose()}},[]);const O=(0,o.useCallback)(()=>{T(!0)},[S]),P=(0,o.useCallback)(U=>{M.addFileToContext(U,void 0,!0)},[]),k=(0,o.useCallback)(U=>{M.removeFileFromContext(U,!0)},[]),F=(0,o.useCallback)(U=>{R.open(U)},[]),L=(0,o.useCallback)(U=>{U.stopPropagation(),U.preventDefault(),M.cleanFileContext()},[]),B=(0,o.useCallback)((U,W)=>{U.stopPropagation(),U.preventDefault(),k(W)},[]);return o.default.createElement("div",{className:E.default.chat_context},o.default.createElement(r.default,{expandIcon:({isActive:U})=>U?o.default.createElement(l.Icon,{icon:"down"}):o.default.createElement(l.Icon,{icon:"right"}),openMotion:{motionName:"rc-collapse-motion",onEnterStart:f,onEnterActive:c,onLeaveStart:b,onLeaveActive:f,onEnterEnd:y,onLeaveEnd:y,motionDeadline:100,leavedClassName:E.default.collapse_hide}},o.default.createElement(r.Panel,{header:o.default.createElement("div",{className:E.default.context_header},o.default.createElement("h3",{className:E.default.chat_context_title},"Context ",S.length>0?` (${S.length} files)`:""),o.default.createElement(p.Popover,{overlayClassName:E.default.popover_icon,id:"ai-context-header-clear",title:(0,g.localize)("aiNative.operate.clear.title")},o.default.createElement(v.EnhanceIcon,{wrapperClassName:E.default.action_btn,className:(0,p.getIcon)("clear"),onClick:L,tabIndex:0,role:"button",ariaLabel:(0,g.localize)("aiNative.operate.clear.title")}))),key:"context-panel"},o.default.createElement("div",{className:E.default.file_list},S.map(U=>{var W;return o.default.createElement("div",{className:E.default.selected_item,key:U.uri.toString(),onClick:()=>F(U.uri)},o.default.createElement(l.Icon,{iconClass:D.getIcon(U.uri)}),o.default.createElement("span",{className:E.default.basename},U.uri.path.base,U.selection?` (${U.selection[0]}-${U.selection[1]})`:""),o.default.createElement("span",{className:E.default.dir},(W=a.URI.file(I.workspaceDir).relative(U.uri.parent))===null||W===void 0?void 0:W.toString()),o.default.createElement(l.Icon,{icon:"close",className:E.default.close_icon,onClick:j=>B(j,U.uri)}))})),o.default.createElement("div",{className:E.default.add_context,onClick:O},o.default.createElement(l.Icon,{icon:"add"}),"Add Files"))),w&&o.default.createElement(d.ContextSelector,{onDidClose:()=>T(!1),onDidDeselect:k,onDidSelect:P,addedFiles:S}))})},25834:(x,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.__importStar(e(14041)),l=n.__importDefault(e(10580)),p=e(41869),v=e(81878),m=e(89195),_=e(43718),s=e(71624),g=e(9447),a=e(52416),h=n.__importDefault(e(6960)),u=e(83933);e(38191);const d=b=>{const{input:y,language:S,relationId:A,agentId:w,command:T,hideInsert:D}=b,I=o.default.useRef(null),R=(0,p.useInjectable)(g.MonacoCommandRegistry),M=(0,p.useInjectable)(p.IClipboardService),O=(0,p.useInjectable)(a.IThemeService),P=(0,p.useInjectable)(_.IAIReporter),[k,F]=(0,o.useState)(!1),L=(0,o.useMemo)(()=>(0,p.uuid)(12),[I,I.current]);(0,o.useEffect)(()=>{const W=V=>{V.type==="dark"||V.type==="hcDark"?e.e(622).then(e.bind(e,51622)):(V.type==="light"||V.type==="hcLight")&&e.e(412).then(e.bind(e,50412))},j=O.onThemeChange(V=>{W(V)}),X=O.getCurrentThemeSync();return W(X),()=>j.dispose()},[]);const B=(0,o.useCallback)(async()=>{F(!0),await M.writeText(y),P.end(A,{copy:!0,code:y,language:S,agentId:w,command:T,actionSource:_.ActionSourceEnum.Chat,actionType:_.ActionTypeEnum.ChatCopyCode}),(0,_.runWhenIdle)(()=>{F(!1)},1e3)},[M,y,A]),U=(0,o.useCallback)(()=>{const W=R.getActiveCodeEditor();if(W){const j=W.getSelection();j&&((0,s.insertSnippetWithMonacoEditor)(W,y,[j],{undoStopBefore:!1,undoStopAfter:!1}),P.end(A,{insert:!0,code:y,language:S,agentId:w,command:T,actionSource:_.ActionSourceEnum.Chat,actionType:_.ActionTypeEnum.ChatInsertCode}))}},[R]);return o.default.createElement("div",{className:h.default.monaco_wrapper},o.default.createElement("div",{className:h.default.action_toolbar},!D&&o.default.createElement(v.Popover,{id:`ai-chat-inser-${L}`,title:(0,_.localize)("aiNative.chat.code.insert")},o.default.createElement(m.EnhanceIcon,{className:(0,p.getIcon)("insert"),onClick:()=>U(),tabIndex:0,role:"button",ariaLabel:(0,_.localize)("aiNative.chat.code.insert")})),o.default.createElement(v.Popover,{id:`ai-chat-copy-${L}`,title:(0,_.localize)(k?"aiNative.chat.code.copy.success":"aiNative.chat.code.copy")},o.default.createElement(m.EnhanceIcon,{className:(0,p.getIcon)("copy"),onClick:()=>B(),tabIndex:0,role:"button",ariaLabel:(0,_.localize)("aiNative.chat.code.copy")}))),o.default.createElement(l.default,{language:S,ref:I,className:h.default.editor},y))};t.CodeEditorWithHighlight=d;const E=({content:b="",relationId:y,renderText:S,agentId:A="",command:w=""})=>{const T=/`([^`]+)`/g,D=/```([^]+?)```/g,I=/```([^]+)?/g,R=O=>{const P=O.split(`
|
|
29735
29735
|
`)[0].trim().toLowerCase(),k=u.highLightLanguageSupport.find(F=>F===P)||"plaintext";return O=O.replace(/.*?\n/,""),O=O.trim(),o.default.createElement("div",{className:h.default.code_block},o.default.createElement("div",{className:h.default.code_language},(0,r.default)(k)),o.default.createElement(t.CodeEditorWithHighlight,{input:O,language:P,relationId:y,agentId:A,command:w}))},M=(0,o.useMemo)(()=>{const O=b.split(D),P=[];return O.map((k,F)=>{F%2===0?k.split(T).map((L,B)=>{if(B%2===0){if(L.includes("```")){const U=L.split(I).filter(Boolean);if(U.length===2){P.push(U[0]),P.push(R(U[1]));return}}S?P.push(S(L)):P.push(L)}else P.push(o.default.createElement("span",{className:h.default.code_inline,key:B},L))}):P.push(R(k))}),P},[b,S]);return o.default.createElement(o.default.Fragment,null,M)},f=({text:b,renderText:y,relationId:S,agentId:A})=>o.default.createElement("div",{className:h.default.ai_chat_code_wrapper},o.default.createElement("div",{className:h.default.render_text},o.default.createElement(E,{content:b,renderText:y,relationId:S,agentId:A})));t.CodeBlockWrapper=f;const c=({text:b,relationId:y,agentId:S,command:A})=>{const w=(0,p.useInjectable)(_.ChatFeatureRegistryToken),[T,D]=(0,o.useState)(""),[I,R]=(0,o.useState)(b);return o.default.useEffect(()=>{const{value:M,nameWithSlash:O}=w.parseSlashCommand(b);if(O){D(O),R(M);return}else R(b)},[b,w]),o.default.createElement("div",{className:h.default.ai_chat_code_wrapper},o.default.createElement("div",{className:h.default.render_text},T&&o.default.createElement("div",{className:h.default.tag_wrapper},o.default.createElement("span",{className:h.default.tag},T)),S&&o.default.createElement("div",{className:h.default.tag,style:{marginRight:4}},"@",S),A&&o.default.createElement("div",{className:h.default.tag},"/ ",A),o.default.createElement(E,{content:I,relationId:y,agentId:S,command:A})))};t.CodeBlockWrapperInput=c},90103:(x,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(84183);const p=e(41869),v=e(89195),m=100,_=(0,o.memo)(({title:s,historyList:g,currentId:a,onNewChat:h,onHistoryItemSelect:u,onHistoryItemChange:d,onHistoryItemDelete:E,className:f})=>{const[c,b]=(0,o.useState)(null),[y,S]=(0,o.useState)(""),A=(0,o.useRef)(null),w=(0,o.useCallback)(U=>{S(U.target.value)},[y]),T=(0,o.useCallback)(U=>{u(U),S("")},[u,y]),D=(0,o.useCallback)(U=>{b({[U.id]:!0})},[c]),I=(0,o.useCallback)((U,W)=>{b({[U.id]:!1}),d(U,W)},[d,c]),R=(0,o.useCallback)(U=>{b({[U.id]:!1})},[c]),M=(0,o.useCallback)(()=>{h()},[h]);(0,o.useEffect)(()=>{var U;c&&((U=A.current)===null||U===void 0||U.focus({cursor:"end"}))},[c]);const O=(0,o.useCallback)(U=>{E(U)},[E]),P=(0,o.useCallback)(U=>{if(U<60*60*1e3){const j=Math.floor(U/6e4);return j===0?"Just now":`${j}m ago`}else{if(U<24*60*60*1e3)return`${Math.floor(U/36e5)}h ago`;if(U<7*24*60*60*1e3)return`${Math.floor(U/864e5)}d ago`;if(U<30*24*60*60*1e3)return`${Math.floor(U/6048e5)}w ago`;if(U<365*24*60*60*1e3)return`${Math.floor(U/2592e6)}mo ago`}return`${Math.floor(U/(365*24*60*60*1e3))}y ago`},[]),k=(0,o.useCallback)(U=>{const W=new Date,j=[];return U.forEach(X=>{const V=new Date(X.updatedAt),$=W.getTime()-V.getTime(),Q=P($),G=j.find(H=>H.key===Q);G?G.items.push(X):j.push({key:Q,items:[X]})}),j},[P]),F=(0,o.useCallback)(U=>o.default.createElement("div",{key:U.id,className:(0,r.default)("dm-chat-history-item",U.id===a?"dm-chat-history-item-selected":""),onClick:()=>T(U)},o.default.createElement("div",{className:"dm-chat-history-item-content"},U.loading?o.default.createElement(l.Loading,null):o.default.createElement(l.Icon,{icon:"message",style:{width:"16px",height:"16px",marginRight:4}}),c?.[U.id]?o.default.createElement(l.Input,{className:"dm-chat-history-item-title",defaultValue:U.title,ref:A,onPressEnter:W=>{I(U,W.target.value)},onBlur:()=>R(U)}):o.default.createElement("span",{id:`dm-chat-history-item-title-${U.id}`,className:"dm-chat-history-item-title"},U.title)),o.default.createElement("div",{className:"dm-chat-history-item-actions"},o.default.createElement(v.EnhanceIcon,{className:(0,r.default)("dm-chat-history-item-actions-delete",(0,l.getIcon)("delete")),onClick:W=>{W.preventDefault(),W.stopPropagation(),O(U)},ariaLabel:(0,p.localize)("aiNative.operate.chatHistory.delete")}))),[c,T,I,R,D,O,a,A]),L=(0,o.useCallback)(()=>{const U=g.slice(0,m).filter(j=>j.title&&j.title.includes(y)),W=k(U);return o.default.createElement("div",null,o.default.createElement(l.Input,{placeholder:(0,p.localize)("aiNative.operate.chatHistory.searchPlaceholder"),style:{width:"100%",maxWidth:"100%"},value:y,onChange:w}),o.default.createElement("div",{className:"dm-chat-history-list"},W.map(j=>o.default.createElement("div",{key:j.key,style:{padding:"4px"}},o.default.createElement("div",{className:"dm-chat-history-time"},j.key),j.items.map(F)))))},[g,y,k,w,F]),B=(0,o.useCallback)(U=>U.parentElement,[]);return o.default.createElement("div",{className:(0,r.default)("dm-chat-history-header",f)},o.default.createElement("div",{className:"dm-chat-history-header-title"},o.default.createElement("span",null,s)),o.default.createElement("div",{className:"dm-chat-history-header-actions"},o.default.createElement(l.Popover,{id:"dm-chat-history-header-actions-history",content:L(),trigger:l.PopoverTriggerType.click,position:l.PopoverPosition.bottomRight,title:(0,p.localize)("aiNative.operate.chatHistory.title"),getPopupContainer:B},o.default.createElement("div",{className:"dm-chat-history-header-actions-history",title:(0,p.localize)("aiNative.operate.chatHistory.title")},o.default.createElement(v.EnhanceIcon,{className:(0,r.default)("dm-chat-history-header-actions-history","codicon codicon-history")}))),o.default.createElement(l.Popover,{id:"ai-chat-header-close",position:l.PopoverPosition.top,title:(0,p.localize)("aiNative.operate.newChat.title")},o.default.createElement(v.EnhanceIcon,{className:(0,r.default)("dm-chat-history-header-actions-new",(0,l.getIcon)("plus")),onClick:M}))))});t.default=_},57987:(x,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),p=e(81878),v=e(89195),m=e(83913),_=e(43718),s=e(9447),g=e(19413),a=e(42033),h=e(51081),u=n.__importDefault(e(6960)),d=8,E=68,f=({icon:S,name:A,description:w,agentId:T,command:D,selectedAgentId:I})=>{const R=(0,o.useMemo)(()=>!I&&T&&T!==h.ChatProxyService.AGENT_ID&&D?o.default.createElement("span",{className:u.default.agent_label},"@",T):null,[]);return o.default.createElement("div",{className:u.default.block},S&&o.default.createElement(v.EnhanceIcon,{className:S}),A&&o.default.createElement("span",{className:u.default.name},A),w&&o.default.createElement("span",{className:u.default.text},w),R)},c=({onClick:S,bottom:A,trigger:w,agentId:T})=>{const D=(0,l.useInjectable)(g.IChatAgentService),I=(0,l.useInjectable)(_.ChatAgentViewServiceToken),R=(0,o.useMemo)(()=>w===g.AT_SIGN_SYMBOL?I.getRenderAgents().map(O=>new a.ChatSlashCommandItemModel({icon:"",name:`${g.AT_SIGN_SYMBOL}${O.id} `,description:O.metadata.description},"",O.id)):D.getCommands().map(O=>new a.ChatSlashCommandItemModel({icon:"",name:`${g.SLASH_SYMBOL} ${O.name} `,description:O.description},O.name,O.agentId)).filter(O=>!T||O.agentId===T),[w,D]),M=(0,o.useCallback)((O,P,k)=>{S&&S(O||"",P,k)},[S]);return R.length===0?null:o.default.createElement("div",{className:u.default.instruction_options_container,style:{bottom:A+"px"}},o.default.createElement("div",{className:u.default.options},o.default.createElement("ul",null,R.map(({icon:O,name:P,nameWithSlash:k,description:F,agentId:L,command:B})=>o.default.createElement("li",{key:`${L||""}-${P}`,onMouseDown:()=>M(k,L,B)},o.default.createElement(f,{icon:O,name:P,description:F,agentId:L,command:B,selectedAgentId:T}))))))},b=({themeBlock:S})=>o.default.createElement("div",{className:u.default.theme_container},o.default.createElement("div",{className:u.default.theme_block},S)),y=({agentId:S,command:A})=>o.default.createElement("div",{className:u.default.theme_container},S!==h.ChatProxyService.AGENT_ID&&o.default.createElement("div",{className:u.default.theme_block,style:{marginRight:4}},"@",S),A&&o.default.createElement("div",{className:u.default.theme_block},g.SLASH_SYMBOL," ",A));t.ChatInput=o.default.forwardRef((S,A)=>{const{onSend:w,onValueChange:T,enableOptions:D=!1,disabled:I=!1,defaultHeight:R=32,autoFocus:M,setTheme:O,theme:P,setAgentId:k,agentId:F,defaultAgentId:L,setCommand:B,command:U,sendBtnClassName:W}=S,j=F||L,X=(0,o.useRef)(null),V=(0,o.useRef)(null),[$,Q]=(0,o.useState)(S.value||""),[G,H]=(0,o.useState)(!1),[K,Z]=(0,o.useState)(R),[Y,oe]=(0,o.useState)(!1),[ie,he]=(0,o.useState)(!1),[_e,q]=(0,o.useState)(!1),[Re,ye]=(0,o.useState)((0,_.localize)("aiNative.chat.input.placeholder.default")),ne=(0,l.useInjectable)(s.MonacoCommandRegistry),ge=(0,l.useInjectable)(g.IChatAgentService),Me=(0,l.useInjectable)(_.ChatFeatureRegistryToken),Le=(0,l.useLatest)(j);(0,o.useImperativeHandle)(A,()=>({setInputValue:le=>{Q(le),(0,_.runWhenIdle)(()=>{var Ie;(Ie=X.current)===null||Ie===void 0||Ie.focus()},120)}})),(0,o.useEffect)(()=>{S.value!==$&&Q(S.value||"")},[S.value]),(0,o.useEffect)(()=>{var le;(le=X.current)===null||le===void 0||le.focus();const Ie=(0,_.localize)("aiNative.chat.input.placeholder.default"),Se=Me.getSlashCommandHandler(U);if(Se&&Se.providerInputPlaceholder){const We=ne.getActiveCodeEditor(),$e=Se.providerInputPlaceholder($,We);ye($e||Ie)}else ye(Ie)},[Me,U]),(0,o.useEffect)(()=>{ve(P||"",j,U)},[P,j,U]),(0,o.useEffect)(()=>{var le;X&&M&&((le=X.current)===null||le===void 0||le.focus())},[X,M,S.value]),(0,o.useEffect)(()=>{if(D&&(($===g.SLASH_SYMBOL||$===g.AT_SIGN_SYMBOL&&ge.getAgents().length>0)&&!_e?H(!0):H(!1)),$.startsWith(g.SLASH_SYMBOL)){const{value:le,nameWithSlash:Ie}=Me.parseSlashCommand($);if(Ie){const Se=Me.getSlashCommandBySlashName(Ie);Q(le),O(Ie),Se&&(k(Se.agentId),B(Se.command));return}}if(ge.getAgents().length){const le=ge.parseMessage($,Le.current);(le.agentId||le.command)&&(O(""),Q(le.message),le.agentId&&k(le.agentId),le.command&&B(le.command))}},[X,$,D,Me]),(0,o.useEffect)(()=>{$||(Z(R),he(!1),q(!1))},[$]);const Ce=(0,o.useCallback)(le=>{Q(le),T&&T(le)},[]),Ae=(0,o.useCallback)(async()=>{if(I)return;const le=(Ie=$)=>{w(Ie,j,U),Q(""),O(""),k(""),B("")};if(U){const Ie=Me.getSlashCommandHandler(U);if(Ie&&Ie.execute){const Se=ne.getActiveCodeEditor();await Ie.execute($,We=>le(We),Se);return}}le()},[w,$,j,U,Me]),ve=(0,o.useCallback)((le,Ie,Se)=>{if(Ie){if(H(!1),O(""),k(Ie),B(Se||""),X?.current){const We=X.current.value;(We===g.AT_SIGN_SYMBOL||Se&&We===g.SLASH_SYMBOL)&&Q(""),(0,_.runWhenIdle)(()=>X.current.focus())}}else if(le){H(!1),k(""),B("");const We=Me.getSlashCommandBySlashName(le);if(O(We?We.nameWithSlash:""),X&&X.current){const $e=X.current.value;$e.length===1&&$e.startsWith(g.SLASH_SYMBOL)&&Q(""),(0,_.runWhenIdle)(()=>X.current.focus())}}},[X,Me]),fe=(0,o.useMemo)(()=>{const le=d+K;return _e&&H(!1),le},[K]),xe=le=>{var Ie,Se;if(le.key==="Backspace"&&((Ie=X.current)===null||Ie===void 0?void 0:Ie.selectionEnd)===0&&((Se=X.current)===null||Se===void 0?void 0:Se.selectionStart)===0){if(O(""),j===h.ChatProxyService.AGENT_ID){B(""),k("");return}j&&(U?B(""):k(""))}},Te=(0,o.useCallback)(le=>{Z(le),le>E?he(!0):he(!1)},[]),Fe=(0,o.useCallback)(()=>{oe(!1),H(!1)},[X]),pe=(0,o.useCallback)(()=>{oe(!0)},[X]),re=(0,o.useCallback)(()=>{const le=_e;if(q(!le),le)Z(R),he(!1);else{const Se=document.querySelector("#ai_chat_left_container").clientHeight-68-(P?32:0)-16;Z(Se)}},[_e]);return o.default.createElement("div",{className:(0,r.default)(u.default.chat_input_container,Y?u.default.active:null)},G&&o.default.createElement("div",{ref:V},o.default.createElement(c,{onClick:ve,bottom:fe,trigger:$,agentId:j})),P&&o.default.createElement(b,{themeBlock:P}),j&&o.default.createElement(y,{agentId:j,command:U}),ie&&o.default.createElement("div",{className:u.default.expand_icon,onClick:()=>re()},o.default.createElement(p.Popover,{id:"ai_chat_input_expand",title:(0,_.localize)(_e?"aiNative.chat.expand.unfullscreen":"aiNative.chat.expand.fullescreen")},o.default.createElement(p.Icon,{className:(0,r.default)(_e?(0,p.getIcon)("unfullscreen"):(0,p.getIcon)("fullescreen"))}))),o.default.createElement(m.InteractiveInput,{ref:X,placeholder:Re,value:$,onKeyDown:xe,onBlur:Fe,onFocus:pe,onValueChange:Ce,disabled:I,className:u.default.input_wrapper,onSend:Ae,sendBtnClassName:W,onHeightChange:Te,height:K,popoverPosition:p.PopoverPosition.left}))})},56474:(x,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),p=e(84605),v=e(41869),m=e(90684),_=e(25834),s=n.__importDefault(e(6960)),g=I=>{const R=(0,o.useRef)(null),M=(0,v.useInjectable)(v.AppConfig),[O,P]=(0,o.useState)(),[k,F]=(0,o.useState)();return(0,o.useEffect)(()=>{var L,B;if(!R.current)return;const W=typeof I.markdown=="string"?new m.MarkdownString(I.markdown):I.markdown,j=new l.MarkdownReactRenderer;j.code=(H,K)=>{const Z=a(K);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")},Z),o.default.createElement(_.CodeEditorWithHighlight,{input:H,language:Z,relationId:I.relationId||"",agentId:I.agentId,command:I.command,hideInsert:I.hideInsert}))))},j.codespan=H=>o.default.createElement("code",{className:s.default.code_inline},H);const X=new l.MarkdownReactParser({renderer:j}),V=(L=I.markedOptions)!==null&&L!==void 0?L:{};V.renderer=X;let $=(B=W.value)!==null&&B!==void 0?B:"";$.length>1e5&&($=`${$.slice(0,1e5)}\u2026`);let Q,G;if(I.fillInIncompleteTokens){const H={...p.marked.defaults,...V},K=p.marked.lexer($,H),Z=h(K);Q=p.marked.parser(Z,H),G=Z}else{const H=p.marked.lexer($,p.marked.defaults);Q=p.marked.parser(H,V),G=H}F(G),P(X)},[I.markdown]),o.default.createElement("div",{className:(0,r.default)(s.default.markdown_container,I.className),ref:R,tabIndex:0},k&&O&&O.parse(k))};t.ChatMarkdown=g;function a(I){if(!I)return"";const R=I.split(/[\s+|:|,|\{|\?]/,1);return R.length?R[0]:I}function h(I){let R,M;for(R=0;R<I.length;R++){const O=I[R];if(O.type==="paragraph"&&O.raw.match(/(\n|^)```/)){M=u(I.slice(R));break}if(O.type==="paragraph"&&O.raw.match(/(\n|^)\|/)){M=w(I.slice(R));break}if(O.type==="paragraph"&&R===I.length-1){const P=D(O);if(P){M=[P];break}}}if(M){const O=[...I.slice(0,R),...M];return O.links=I.links,O}return I}function u(I){const R=T(I);return p.marked.lexer(R+"\n```")}function d(I){return A(I,"`")}function E(I){return A(I,"*")}function f(I){return A(I,"_")}function c(I){return A(I,")")}function b(I){return A(I,"](about:blank)")}function y(I){return A(I,"**")}function S(I){return A(I,"__")}function A(I,R){const M=T(Array.isArray(I)?I:[I]);return p.marked.lexer(M+R)[0]}function w(I){const R=T(I),M=R.split(`
|
|
29736
29736
|
`);let O=0,P=!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)P=!0;else return}if(O>0){const k=P?M.slice(0,-1).join(`
|
|
29737
29737
|
`):R,F=!!k.match(/\|\s*$/),L=k+(F?"":"|")+`
|
|
@@ -29825,7 +29825,7 @@ ${f.slice(1).join(`
|
|
|
29825
29825
|
${D}
|
|
29826
29826
|
\`\`\``,hideInsert:!0})),M.applyResult&&M.applyResult.diagnosticInfos.length>0&&o.default.createElement("div",{className:h.default["edit-file-tool-diagnostic-errors"],key:`edit-file-tool-diagnostic-errors-${M.id}`},o.default.createElement("div",{className:h.default.title},"Found Lints:"),(f=M.applyResult)===null||f===void 0?void 0:f.diagnosticInfos.map(k=>o.default.createElement("div",{key:k.message,className:(0,r.default)({[h.default.error]:k.severity===p.MarkerSeverity.Error,[h.default.warning]:k.severity===p.MarkerSeverity.Warning})},o.default.createElement(l.Icon,{className:`codicon codicon-${k.severity===p.MarkerSeverity.Error?"error":"warning"}`}),k.message.split(`
|
|
29827
29827
|
`)[0])))]};t.EditFileToolComponent=d},47263:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GrepSearchToolComponent=t.FileSearchToolComponent=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(41869),l=e(54414),p=e(51500),v=e(19413),m=n.__importDefault(e(51601)),_=({args:a,toolCallId:h,messageId:u})=>r.default.createElement(g,{args:a,toolCallId:h,messageId:u,toolName:"fileSearch"});t.FileSearchToolComponent=_;const s=({args:a,toolCallId:h,messageId:u})=>r.default.createElement(g,{args:a,toolCallId:h,messageId:u,toolName:"grepSearch"});t.GrepSearchToolComponent=s;const g=({args:a,toolCallId:h,toolName:u,messageId:d})=>{var E,f;const[c,b]=(0,r.useState)(!1),y=(0,o.useInjectable)(o.LabelService),S=(0,o.useInjectable)(l.WorkbenchEditorService),A=(0,o.useInjectable)(p.IWorkspaceService),w=(0,r.useMemo)(()=>{var O,P;return o.URI.parse((P=(O=A.tryGetRoots())===null||O===void 0?void 0:O[0])===null||P===void 0?void 0:P.uri)},[]),T=(0,o.useInjectable)(v.IChatInternalService),[D,I]=(0,r.useState)(((f=(E=T.sessionModel.history.getMessageAdditional(d))===null||E===void 0?void 0:E[h])===null||f===void 0?void 0:f.files)||[]);(0,r.useEffect)(()=>{const O=T.sessionModel.history.onMessageAdditionalChange(P=>{var k;I(((k=P[h])===null||k===void 0?void 0:k.files)||[])});return()=>{O.dispose()}},[]);const R=O=>{S.open(O)},M=(0,r.useMemo)(()=>D.map(O=>{const P=o.URI.parse(O);return{iconClass:y.getIcon(P),name:P.path.base,path:o.path.relative(w.codeUri.fsPath,P.path.dir.toString())}}),[D]);return r.default.createElement("div",{className:m.default.container},r.default.createElement("div",{className:m.default.header,onClick:()=>b(!c)},r.default.createElement("span",{style:{transform:`rotate(${c?"90deg":"0deg"})`}},"\u25B6"),r.default.createElement("span",null,u==="fileSearch"?`Searched files "${a.query}"`:`Grepped codebase "${a.query}"`," \xB7"," ",D.length," files")),c&&r.default.createElement("ul",{className:m.default.fileList},M.map((O,P)=>r.default.createElement("li",{key:P,className:m.default.fileItem,onClick:()=>R(o.URI.file(o.path.join(w.codeUri.fsPath,O.path,O.name)))},r.default.createElement("span",{className:O.iconClass}),r.default.createElement("span",{style:{flex:1}},O.name),r.default.createElement("span",{className:m.default.filePath},O.path)))))}},24706:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TerminalToolComponent=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(41869),l=e(81878),p=e(43718),v=e(22559),m=n.__importDefault(e(51601));function _(s){const g={};try{const a=JSON.parse(s);return a.isError&&(g.isError=a.isError),a.content&&(g.text=a.content.map(h=>h.text).join(`
|
|
29828
|
-
`)),g}catch{return null}}t.TerminalToolComponent=(0,r.memo)(s=>{const{args:g,toolCallId:a}=s,h=(0,o.useInjectable)(v.RunCommandHandler),[u,d]=(0,r.useState)(!1),E=(0,r.useCallback)(c=>{a&&(h.handleApproval(a,c),d(!0))},[]),f=(0,r.useMemo)(()=>s.result?_(s.result):null,[s]);return r.default.createElement("div",{className:m.default.run_cmd_tool},s.state==="result"&&r.default.createElement("div",null,r.default.createElement("div",{className:m.default.command_title},r.default.createElement(l.Icon,{icon:"terminal"}),r.default.createElement("span",null,(0,p.localize)("ai.native.mcp.terminal.output"))),f?r.default.createElement("div",{className:m.default.command_content},r.default.createElement("code",null,f.text)):""),s.state==="complete"&&g?.require_user_approval&&r.default.createElement("div",null,r.default.createElement("div",{className:m.default.command_title},r.default.createElement(l.Icon,{icon:"terminal"}),r.default.createElement("span",null,(0,p.localize)("ai.native.mcp.terminal.allow-question"))),r.default.createElement("p",{className:m.default.command_content},r.default.createElement("code",null,"$ ",g.command)),r.default.createElement("p",{className:m.default.comand_description},g.explanation),r.default.createElement("div",{className:m.default.cmmand_footer},r.default.createElement(l.Button,{type:"link",size:"small",disabled:u,onClick:()=>E(!0)},(0,p.localize)("ai.native.mcp.terminal.allow")),r.default.createElement(l.Button,{type:"link",size:"small",disabled:u,onClick:()=>E(!1)},(0,p.localize)("ai.native.mcp.terminal.deny")))))})},7228:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateNewFileWithTextTool=void 0;const n=e(85608),r=e(75995),o=e(76003),l=e(43718),p=e(14951),v=e(51500),m=e(77633),_=r.z.object({pathInProject:r.z.string().describe("The relative path where the file should be created"),text:r.z.string().describe("The content to write into the new file")});let s=class{registerMCPServer(a){a.registerMCPTool(this.getToolDefinition())}getToolDefinition(){return{name:"create_new_file_with_text",description:`Creates a new file at the specified path within the project directory and populates it with the provided text. Use this tool to generate new files in your project structure. Requires two parameters: - pathInProject: The relative path where the file should be created - text: The content to write into the new file Returns one of two possible responses: "ok" if the file was successfully created and populated, "can't find project dir" if the project directory cannot be determined. Note: Creates any necessary parent directories automatically.`,inputSchema:_,handler:this.handler.bind(this)}}async handler(a,h){try{const u=this.workspaceService.tryGetRoots();if(!u||u.length===0)return h.appendLine("Error: Cannot determine project directory"),{content:[{type:"text",text:"can't find project dir"}],isError:!0};const d=l.URI.parse(u[0].uri),E=l.path.join(d.codeUri.fsPath,a.pathInProject),f=l.URI.file(E),c=l.path.dirname(E),b=l.URI.file(c);return await this.fileService.createFolder(b.toString()),await this.fileService.createFile(f.toString(),{content:a.text}),h.appendLine(`Successfully created file at: ${a.pathInProject}`),{content:[{type:"text",text:"ok"}]}}catch(u){return h.appendLine(`Error during file creation: ${u}`),{content:[{type:"text",text:"unknown error"}],isError:!0}}}};t.CreateNewFileWithTextTool=s,n.__decorate([(0,o.Autowired)(v.IWorkspaceService),n.__metadata("design:type",Object)],s.prototype,"workspaceService",void 0),n.__decorate([(0,o.Autowired)(p.IFileServiceClient),n.__metadata("design:type",Object)],s.prototype,"fileService",void 0),t.CreateNewFileWithTextTool=s=n.__decorate([(0,l.Domain)(m.MCPServerContribution)],s)},90977:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditFileTool=void 0;const n=e(85608),r=e(75995),o=e(76003),l=e(43718),p=e(77633),v=e(58260),m=e(9343),_=r.z.object({target_file:r.z.string().describe("The target file to modify. Always specify the target file as the first argument and use the relative path in the workspace of the file to edit"),instructions:r.z.string().optional().describe("A single sentence instruction describing what you are going to do for the sketched edit. This is used to assist the less intelligent model in applying the edit. Please use the first person to describe what you are going to do. Dont repeat what you have said previously in normal messages. And use it to disambiguate uncertainty in the edit."),code_edit:r.z.string().describe("Specify ONLY the precise lines of code that you wish to edit. **NEVER specify or write out unchanged code**. Instead, represent all unchanged code using the comment of the language you're editing in - example: `// ... existing code ...`")}).transform(g=>({targetFile:g.target_file,instructions:g.instructions,codeEdit:g.code_edit}));let s=class{registerMCPServer(a){a.registerMCPTool(this.getToolDefinition()),a.registerToolComponent("edit_file",v.EditFileToolComponent)}getToolDefinition(){return{name:"edit_file",label:"Edit File",description:`Use this tool to propose an edit to an existing file.
|
|
29828
|
+
`)),g}catch{return null}}t.TerminalToolComponent=(0,r.memo)(s=>{const{args:g,toolCallId:a}=s,h=(0,o.useInjectable)(v.RunCommandHandler),[u,d]=(0,r.useState)(!1),E=(0,r.useCallback)(c=>{a&&(h.handleApproval(a,c),d(!0))},[]),f=(0,r.useMemo)(()=>s.result?_(s.result):null,[s]);return r.default.createElement("div",{className:m.default.run_cmd_tool},s.state==="result"&&r.default.createElement("div",null,r.default.createElement("div",{className:m.default.command_title},r.default.createElement(l.Icon,{icon:"terminal"}),r.default.createElement("span",null,(0,p.localize)("ai.native.mcp.terminal.output"))),f?r.default.createElement("div",{className:m.default.command_content},r.default.createElement("code",null,f.text)):""),s.state==="complete"&&g?.require_user_approval&&r.default.createElement("div",null,r.default.createElement("div",{className:m.default.command_title},r.default.createElement(l.Icon,{icon:"terminal"}),r.default.createElement("span",null,(0,p.localize)("ai.native.mcp.terminal.allow-question"))),r.default.createElement("p",{className:m.default.command_content},r.default.createElement("code",null,"$ ",g.command)),r.default.createElement("p",{className:m.default.comand_description},g.explanation),r.default.createElement("div",{className:m.default.cmmand_footer},r.default.createElement(l.Button,{type:"link",size:"small",disabled:u,onClick:()=>E(!0)},(0,p.localize)("ai.native.mcp.terminal.allow")),r.default.createElement(l.Button,{type:"link",size:"small",disabled:u,onClick:()=>E(!1)},(0,p.localize)("ai.native.mcp.terminal.deny")))))})},7228:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateNewFileWithTextTool=void 0;const n=e(85608),r=e(75995),o=e(76003),l=e(43718),p=e(14951),v=e(51500),m=e(77633),_=r.z.object({pathInProject:r.z.string().describe("The relative path where the file should be created"),text:r.z.string().describe("The content to write into the new file")});let s=class{registerMCPServer(a){a.registerMCPTool(this.getToolDefinition())}getToolDefinition(){return{name:"create_new_file_with_text",label:"Create File",description:`Creates a new file at the specified path within the project directory and populates it with the provided text. Use this tool to generate new files in your project structure. Requires two parameters: - pathInProject: The relative path where the file should be created - text: The content to write into the new file Returns one of two possible responses: "ok" if the file was successfully created and populated, "can't find project dir" if the project directory cannot be determined. Note: Creates any necessary parent directories automatically.`,inputSchema:_,handler:this.handler.bind(this)}}async handler(a,h){try{const u=this.workspaceService.tryGetRoots();if(!u||u.length===0)return h.appendLine("Error: Cannot determine project directory"),{content:[{type:"text",text:"can't find project dir"}],isError:!0};const d=l.URI.parse(u[0].uri),E=l.path.join(d.codeUri.fsPath,a.pathInProject),f=l.URI.file(E),c=l.path.dirname(E),b=l.URI.file(c);return await this.fileService.createFolder(b.toString()),await this.fileService.createFile(f.toString(),{content:a.text}),h.appendLine(`Successfully created file at: ${a.pathInProject}`),{content:[{type:"text",text:"ok"}]}}catch(u){return h.appendLine(`Error during file creation: ${u}`),{content:[{type:"text",text:"unknown error"}],isError:!0}}}};t.CreateNewFileWithTextTool=s,n.__decorate([(0,o.Autowired)(v.IWorkspaceService),n.__metadata("design:type",Object)],s.prototype,"workspaceService",void 0),n.__decorate([(0,o.Autowired)(p.IFileServiceClient),n.__metadata("design:type",Object)],s.prototype,"fileService",void 0),t.CreateNewFileWithTextTool=s=n.__decorate([(0,l.Domain)(m.MCPServerContribution)],s)},90977:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditFileTool=void 0;const n=e(85608),r=e(75995),o=e(76003),l=e(43718),p=e(77633),v=e(58260),m=e(9343),_=r.z.object({target_file:r.z.string().describe("The target file to modify. Always specify the target file as the first argument and use the relative path in the workspace of the file to edit"),instructions:r.z.string().optional().describe("A single sentence instruction describing what you are going to do for the sketched edit. This is used to assist the less intelligent model in applying the edit. Please use the first person to describe what you are going to do. Dont repeat what you have said previously in normal messages. And use it to disambiguate uncertainty in the edit."),code_edit:r.z.string().describe("Specify ONLY the precise lines of code that you wish to edit. **NEVER specify or write out unchanged code**. Instead, represent all unchanged code using the comment of the language you're editing in - example: `// ... existing code ...`")}).transform(g=>({targetFile:g.target_file,instructions:g.instructions,codeEdit:g.code_edit}));let s=class{registerMCPServer(a){a.registerMCPTool(this.getToolDefinition()),a.registerToolComponent("edit_file",v.EditFileToolComponent)}getToolDefinition(){return{name:"edit_file",label:"Edit File",description:`Use this tool to propose an edit to an existing file.
|
|
29829
29829
|
This will be read by a less intelligent model, which will quickly apply the edit. You should make it clear what the edit is, while also minimizing the unchanged code you write.
|
|
29830
29830
|
When writing the edit, you should specify each edit in sequence, with the special comment \`// ... existing code ...\` to represent unchanged code in between edited lines.
|
|
29831
29831
|
For example:
|
|
@@ -29855,7 +29855,7 @@ ${u.applyResult.diagnosticInfos.map(d=>`Line ${d.startLineNumber}: ${d.message.s
|
|
|
29855
29855
|
Please fix the linter errors if it is clear how to (or you can easily figure out how to). Do not make uneducated guesses. And do not loop more than 3 times on fixing linter errors on the same file.`:""}`:"User cancelled the edit."}]}}};t.EditFileTool=s,n.__decorate([(0,o.Autowired)(m.EditFileHandler),n.__metadata("design:type",m.EditFileHandler)],s.prototype,"editFileHandler",void 0),t.EditFileTool=s=n.__decorate([(0,l.Domain)(p.MCPServerContribution)],s)},80173:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FileSearchTool=void 0;const n=e(85608),r=e(75995),o=e(76003),l=e(43718),p=e(84660),v=e(51500),m=e(19413),_=e(59347),s=e(77633),g=e(47263),a=r.z.object({query:r.z.string().describe("Fuzzy filename to search for"),explanation:r.z.string().describe("One sentence explanation as to why this tool is being used, and how it contributes to the goal.")}),h=10;let u=class{registerMCPServer(E){E.registerMCPTool(this.getToolDefinition()),E.registerToolComponent("file_search",g.FileSearchToolComponent)}getToolDefinition(){return{name:"file_search",label:"Search Files",description:"Fast file search based on fuzzy matching against file path. Use if you know part of the file path but don't know where it's located exactly. Response will be capped to 10 results. Make your query more specific if need to filter results further.",inputSchema:a,handler:this.handler.bind(this)}}async handler(E,f){if(!E.query)throw new Error("No fileSearch parameters provided. Need to give a query.");const c=this.workspaceService.tryGetRoots();if(!c||c.length===0)throw new Error("Cannot determine project directory");const b=E.query,y=await this.fileSearchService.find(b,{rootUris:[new l.URI(c[0].uri).codeUri.fsPath],excludePatterns:["**/node_modules/**"],limit:100,useGitIgnore:!0,noIgnoreParent:!0,fuzzyMatch:!0}),S=y.slice(0,h).map(w=>l.URI.parse(w).codeUri.fsPath),A=this.chatInternalService.sessionModel.history.getMessages();return this.chatInternalService.sessionModel.history.setMessageAdditional(A[A.length-1].id,{[E.toolCallId]:{files:S}}),f.appendLine(`Found ${S.length} files matching "${E.query}"`),{content:[{type:"text",text:`${S.join(`
|
|
29856
29856
|
`)}
|
|
29857
29857
|
${y.length>h?`
|
|
29858
|
-
Found ${y.length} files matching "${E.query}", only return the first ${h} results`:""}`}]}}};t.FileSearchTool=u,n.__decorate([(0,o.Autowired)(v.IWorkspaceService),n.__metadata("design:type",Object)],u.prototype,"workspaceService",void 0),n.__decorate([(0,o.Autowired)(p.FileSearchServicePath),n.__metadata("design:type",Object)],u.prototype,"fileSearchService",void 0),n.__decorate([(0,o.Autowired)(m.IChatInternalService),n.__metadata("design:type",_.ChatInternalService)],u.prototype,"chatInternalService",void 0),t.FileSearchTool=u=n.__decorate([(0,l.Domain)(s.MCPServerContribution)],u)},30645:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GetDiagnosticsByPathTool=void 0;const n=e(85608),r=n.__importStar(e(64756)),o=e(75995),l=e(76003),p=e(43718),v=e(51500),m=e(26592),_=e(34835),s=e(77633),g=o.z.object({filePathInProject:o.z.string().describe("The relative path to the file to get diagnostics for")});let a=class{registerMCPServer(u){u.registerMCPTool(this.getToolDefinition())}getToolDefinition(){return{name:"get_diagnostics_by_path",description:`Retrieves diagnostic information (errors, warnings, etc.) from a specific file in the project. Use this tool to get information about problems in any project file. IMPORTANT: This tool should be called after any code generation or modification operations to verify and fix potential issues. Requires a filePathInProject parameter specifying the target file path relative to project root. Returns a JSON-formatted list of diagnostics, where each entry contains: - path: The file path where the diagnostic was found - line: The line number (1-based) of the diagnostic - severity: The severity level ("error", "warning", "information", or "hint") - message: The diagnostic message Returns an empty list ([]) if no diagnostics are found or the file doesn't exist. Best Practice: Always check diagnostics after code generation to ensure code quality and fix any issues immediately. Use this tool in combination with get_open_in_editor_file_diagnostics to verify all affected files after code changes. Diagnostic Severity Handling Guidelines: - "error": Must be fixed immediately as they indicate critical issues that will prevent code from working correctly. - "warning": For user code, preserve unless the warning indicates a clear improvement opportunity. For generated code, optimize to remove warnings. - "information"/"hint": For user code, preserve as they might reflect intentional patterns. For generated code, optimize if it improves code quality without changing functionality.`,inputSchema:g,handler:this.handler.bind(this)}}async handler(u,d){try{const E=this.workspaceService.tryGetRoots();if(!E||E.length===0)return d.appendLine("Error: Cannot determine project directory"),{content:[{type:"text",text:"[]"}],isError:!0};const f=p.URI.parse(E[0].uri),c=r.join(f.codeUri.fsPath,u.filePathInProject),b=m.URI.file(c),y=r.relative(f.codeUri.fsPath,c);if(y.startsWith("..")||r.isAbsolute(y))return d.appendLine("Error: File is outside of project scope"),{content:[{type:"text",text:"[]"}],isError:!0};const A=this.markerService.read({resource:b}).map(T=>({path:u.filePathInProject,line:T.startLineNumber,severity:this.getSeverityString(T.severity),message:T.message})),w=JSON.stringify(A,null,2);return d.appendLine(`Found ${A.length} diagnostics in ${u.filePathInProject}`),{content:[{type:"text",text:w}]}}catch(E){return d.appendLine(`Error getting diagnostics: ${E}`),{content:[{type:"text",text:"[]"}],isError:!0}}}getSeverityString(u){switch(u){case _.MarkerSeverity.Error:return"error";case _.MarkerSeverity.Warning:return"warning";case _.MarkerSeverity.Info:return"information";case _.MarkerSeverity.Hint:return"hint";default:return"unknown"}}};t.GetDiagnosticsByPathTool=a,n.__decorate([(0,l.Autowired)(v.IWorkspaceService),n.__metadata("design:type",Object)],a.prototype,"workspaceService",void 0),n.__decorate([(0,l.Autowired)(_.IMarkerService),n.__metadata("design:type",Object)],a.prototype,"markerService",void 0),t.GetDiagnosticsByPathTool=a=n.__decorate([(0,p.Domain)(s.MCPServerContribution)],a)},82078:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GetOpenEditorFileDiagnosticsTool=void 0;const n=e(85608),r=n.__importStar(e(64756)),o=e(75995),l=e(76003),p=e(43718),v=e(54414),m=e(51500),_=e(26592),s=e(34835),g=e(77633),a=o.z.object({});let h=class{registerMCPServer(d){d.registerMCPTool(this.getToolDefinition())}getToolDefinition(){return{name:"get_open_in_editor_file_diagnostics",description:'Retrieves diagnostic information (errors, warnings, etc.) from the currently active file in VS Code editor. Use this tool to get information about problems in your current file. IMPORTANT: This tool should be called after any code generation or modification operations to verify and fix potential issues. Returns a JSON-formatted list of diagnostics, where each entry contains: - path: The file path where the diagnostic was found - line: The line number (1-based) of the diagnostic - severity: The severity level ("error", "warning", "information", or "hint") - message: The diagnostic message Returns an empty list ([]) if no diagnostics are found or no file is open. Best Practice: Always check diagnostics after code generation to ensure code quality and fix any issues immediately. Diagnostic Severity Handling Guidelines: - "error": Must be fixed immediately as they indicate critical issues that will prevent code from working correctly. - "warning": For user code, preserve unless the warning indicates a clear improvement opportunity. For generated code, optimize to remove warnings. - "information"/"hint": For user code, preserve as they might reflect intentional patterns. For generated code, optimize if it improves code quality without changing functionality.',inputSchema:a,handler:this.handler.bind(this)}}async handler(d,E){try{const f=this.editorService.currentEditor;if(!f||!f.currentUri)return E.appendLine("Error: No active text editor found"),{content:[{type:"text",text:"[]"}],isError:!0};const c=this.workspaceService.tryGetRoots();if(!c||c.length===0)return E.appendLine("Error: Cannot determine project directory"),{content:[{type:"text",text:"[]"}],isError:!0};const b=_.URI.parse(f.currentUri.toString()),y=this.markerService.read({resource:b}),S=p.URI.parse(c[0].uri),A=r.relative(S.codeUri.fsPath,f.currentUri.codeUri.fsPath),w=y.map(D=>({path:A,line:D.startLineNumber,severity:this.getSeverityString(D.severity),message:D.message})),T=JSON.stringify(w,null,2);return E.appendLine(`Found ${w.length} diagnostics in current file`),{content:[{type:"text",text:T}]}}catch(f){return E.appendLine(`Error getting diagnostics: ${f}`),{content:[{type:"text",text:"[]"}],isError:!0}}}getSeverityString(d){switch(d){case s.MarkerSeverity.Error:return"error";case s.MarkerSeverity.Warning:return"warning";case s.MarkerSeverity.Info:return"information";case s.MarkerSeverity.Hint:return"hint";default:return"unknown"}}};t.GetOpenEditorFileDiagnosticsTool=h,n.__decorate([(0,l.Autowired)(v.WorkbenchEditorService),n.__metadata("design:type",v.WorkbenchEditorService)],h.prototype,"editorService",void 0),n.__decorate([(0,l.Autowired)(m.IWorkspaceService),n.__metadata("design:type",Object)],h.prototype,"workspaceService",void 0),n.__decorate([(0,l.Autowired)(s.IMarkerService),n.__metadata("design:type",Object)],h.prototype,"markerService",void 0),t.GetOpenEditorFileDiagnosticsTool=h=n.__decorate([(0,p.Domain)(g.MCPServerContribution)],h)},39855:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GrepSearchTool=void 0;const n=e(85608),r=e(75995),o=e(76003),l=e(43718),p=e(13439),v=e(51495),m=e(51500),_=e(19413),s=e(59347),g=e(77633),a=e(47263),h=r.z.object({query:r.z.string().describe("The regex pattern to search for"),case_sensitive:r.z.boolean().optional().describe("Whether the search should be case sensitive"),include_pattern:r.z.string().optional().describe('Glob pattern for files to include (e.g. "*.ts" for TypeScript files)'),exclude_pattern:r.z.string().optional().describe("Glob pattern for files to exclude"),explanation:r.z.string().optional().describe("One sentence explanation as to why this tool is being used, and how it contributes to the goal.")}),u=50;let d=class{registerMCPServer(f){f.registerMCPTool(this.getToolDefinition()),f.registerToolComponent("grep_search",a.GrepSearchToolComponent)}getToolDefinition(){return{name:"grep_search",label:"Search Contents",description:`Fast text-based regex search that finds exact pattern matches within files or directories, utilizing the ripgrep command for efficient searching.
|
|
29858
|
+
Found ${y.length} files matching "${E.query}", only return the first ${h} results`:""}`}]}}};t.FileSearchTool=u,n.__decorate([(0,o.Autowired)(v.IWorkspaceService),n.__metadata("design:type",Object)],u.prototype,"workspaceService",void 0),n.__decorate([(0,o.Autowired)(p.FileSearchServicePath),n.__metadata("design:type",Object)],u.prototype,"fileSearchService",void 0),n.__decorate([(0,o.Autowired)(m.IChatInternalService),n.__metadata("design:type",_.ChatInternalService)],u.prototype,"chatInternalService",void 0),t.FileSearchTool=u=n.__decorate([(0,l.Domain)(s.MCPServerContribution)],u)},30645:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GetDiagnosticsByPathTool=void 0;const n=e(85608),r=n.__importStar(e(64756)),o=e(75995),l=e(76003),p=e(43718),v=e(51500),m=e(26592),_=e(34835),s=e(77633),g=o.z.object({filePathInProject:o.z.string().describe("The relative path to the file to get diagnostics for")});let a=class{registerMCPServer(u){u.registerMCPTool(this.getToolDefinition())}getToolDefinition(){return{name:"get_diagnostics_by_path",label:"Get Diagnostics",description:`Retrieves diagnostic information (errors, warnings, etc.) from a specific file in the project. Use this tool to get information about problems in any project file. IMPORTANT: This tool should be called after any code generation or modification operations to verify and fix potential issues. Requires a filePathInProject parameter specifying the target file path relative to project root. Returns a JSON-formatted list of diagnostics, where each entry contains: - path: The file path where the diagnostic was found - line: The line number (1-based) of the diagnostic - severity: The severity level ("error", "warning", "information", or "hint") - message: The diagnostic message Returns an empty list ([]) if no diagnostics are found or the file doesn't exist. Best Practice: Always check diagnostics after code generation to ensure code quality and fix any issues immediately. Use this tool in combination with get_open_in_editor_file_diagnostics to verify all affected files after code changes. Diagnostic Severity Handling Guidelines: - "error": Must be fixed immediately as they indicate critical issues that will prevent code from working correctly. - "warning": For user code, preserve unless the warning indicates a clear improvement opportunity. For generated code, optimize to remove warnings. - "information"/"hint": For user code, preserve as they might reflect intentional patterns. For generated code, optimize if it improves code quality without changing functionality.`,inputSchema:g,handler:this.handler.bind(this)}}async handler(u,d){try{const E=this.workspaceService.tryGetRoots();if(!E||E.length===0)return d.appendLine("Error: Cannot determine project directory"),{content:[{type:"text",text:"[]"}],isError:!0};const f=p.URI.parse(E[0].uri),c=r.join(f.codeUri.fsPath,u.filePathInProject),b=m.URI.file(c),y=r.relative(f.codeUri.fsPath,c);if(y.startsWith("..")||r.isAbsolute(y))return d.appendLine("Error: File is outside of project scope"),{content:[{type:"text",text:"[]"}],isError:!0};const A=this.markerService.read({resource:b}).map(T=>({path:u.filePathInProject,line:T.startLineNumber,severity:this.getSeverityString(T.severity),message:T.message})),w=JSON.stringify(A,null,2);return d.appendLine(`Found ${A.length} diagnostics in ${u.filePathInProject}`),{content:[{type:"text",text:w}]}}catch(E){return d.appendLine(`Error getting diagnostics: ${E}`),{content:[{type:"text",text:"[]"}],isError:!0}}}getSeverityString(u){switch(u){case _.MarkerSeverity.Error:return"error";case _.MarkerSeverity.Warning:return"warning";case _.MarkerSeverity.Info:return"information";case _.MarkerSeverity.Hint:return"hint";default:return"unknown"}}};t.GetDiagnosticsByPathTool=a,n.__decorate([(0,l.Autowired)(v.IWorkspaceService),n.__metadata("design:type",Object)],a.prototype,"workspaceService",void 0),n.__decorate([(0,l.Autowired)(_.IMarkerService),n.__metadata("design:type",Object)],a.prototype,"markerService",void 0),t.GetDiagnosticsByPathTool=a=n.__decorate([(0,p.Domain)(s.MCPServerContribution)],a)},82078:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GetOpenEditorFileDiagnosticsTool=void 0;const n=e(85608),r=n.__importStar(e(64756)),o=e(75995),l=e(76003),p=e(43718),v=e(54414),m=e(51500),_=e(26592),s=e(34835),g=e(77633),a=o.z.object({});let h=class{registerMCPServer(d){d.registerMCPTool(this.getToolDefinition())}getToolDefinition(){return{name:"get_open_in_editor_file_diagnostics",description:'Retrieves diagnostic information (errors, warnings, etc.) from the currently active file in VS Code editor. Use this tool to get information about problems in your current file. IMPORTANT: This tool should be called after any code generation or modification operations to verify and fix potential issues. Returns a JSON-formatted list of diagnostics, where each entry contains: - path: The file path where the diagnostic was found - line: The line number (1-based) of the diagnostic - severity: The severity level ("error", "warning", "information", or "hint") - message: The diagnostic message Returns an empty list ([]) if no diagnostics are found or no file is open. Best Practice: Always check diagnostics after code generation to ensure code quality and fix any issues immediately. Diagnostic Severity Handling Guidelines: - "error": Must be fixed immediately as they indicate critical issues that will prevent code from working correctly. - "warning": For user code, preserve unless the warning indicates a clear improvement opportunity. For generated code, optimize to remove warnings. - "information"/"hint": For user code, preserve as they might reflect intentional patterns. For generated code, optimize if it improves code quality without changing functionality.',inputSchema:a,handler:this.handler.bind(this)}}async handler(d,E){try{const f=this.editorService.currentEditor;if(!f||!f.currentUri)return E.appendLine("Error: No active text editor found"),{content:[{type:"text",text:"[]"}],isError:!0};const c=this.workspaceService.tryGetRoots();if(!c||c.length===0)return E.appendLine("Error: Cannot determine project directory"),{content:[{type:"text",text:"[]"}],isError:!0};const b=_.URI.parse(f.currentUri.toString()),y=this.markerService.read({resource:b}),S=p.URI.parse(c[0].uri),A=r.relative(S.codeUri.fsPath,f.currentUri.codeUri.fsPath),w=y.map(D=>({path:A,line:D.startLineNumber,severity:this.getSeverityString(D.severity),message:D.message})),T=JSON.stringify(w,null,2);return E.appendLine(`Found ${w.length} diagnostics in current file`),{content:[{type:"text",text:T}]}}catch(f){return E.appendLine(`Error getting diagnostics: ${f}`),{content:[{type:"text",text:"[]"}],isError:!0}}}getSeverityString(d){switch(d){case s.MarkerSeverity.Error:return"error";case s.MarkerSeverity.Warning:return"warning";case s.MarkerSeverity.Info:return"information";case s.MarkerSeverity.Hint:return"hint";default:return"unknown"}}};t.GetOpenEditorFileDiagnosticsTool=h,n.__decorate([(0,l.Autowired)(v.WorkbenchEditorService),n.__metadata("design:type",v.WorkbenchEditorService)],h.prototype,"editorService",void 0),n.__decorate([(0,l.Autowired)(m.IWorkspaceService),n.__metadata("design:type",Object)],h.prototype,"workspaceService",void 0),n.__decorate([(0,l.Autowired)(s.IMarkerService),n.__metadata("design:type",Object)],h.prototype,"markerService",void 0),t.GetOpenEditorFileDiagnosticsTool=h=n.__decorate([(0,p.Domain)(g.MCPServerContribution)],h)},39855:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GrepSearchTool=void 0;const n=e(85608),r=e(75995),o=e(76003),l=e(43718),p=e(13439),v=e(51495),m=e(51500),_=e(19413),s=e(59347),g=e(77633),a=e(47263),h=r.z.object({query:r.z.string().describe("The regex pattern to search for"),case_sensitive:r.z.boolean().optional().describe("Whether the search should be case sensitive"),include_pattern:r.z.string().optional().describe('Glob pattern for files to include (e.g. "*.ts" for TypeScript files)'),exclude_pattern:r.z.string().optional().describe("Glob pattern for files to exclude"),explanation:r.z.string().optional().describe("One sentence explanation as to why this tool is being used, and how it contributes to the goal.")}),u=50;let d=class{registerMCPServer(f){f.registerMCPTool(this.getToolDefinition()),f.registerToolComponent("grep_search",a.GrepSearchToolComponent)}getToolDefinition(){return{name:"grep_search",label:"Search Contents",description:`Fast text-based regex search that finds exact pattern matches within files or directories, utilizing the ripgrep command for efficient searching.
|
|
29859
29859
|
Results will be formatted in the style of ripgrep and can be configured to include line numbers and content.
|
|
29860
29860
|
To avoid overwhelming output, the results are capped at 50 matches.
|
|
29861
29861
|
Use the include or exclude patterns to filter the search scope by file type or specific paths.
|
|
@@ -29894,7 +29894,7 @@ ${h.contents}
|
|
|
29894
29894
|
|
|
29895
29895
|
\`\`\`
|
|
29896
29896
|
${h.contents}
|
|
29897
|
-
\`\`\``}]}}};t.ReadFileTool=_,n.__decorate([(0,o.Autowired)(v.FileHandler),n.__metadata("design:type",v.FileHandler)],_.prototype,"fileHandler",void 0),t.ReadFileTool=_=n.__decorate([(0,l.Domain)(p.MCPServerContribution)],_)},42232:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RunTerminalCommandTool=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(43718),p=e(7473),v=e(77633),m=e(24706),_=e(22559);let s=class{registerMCPServer(a){a.registerMCPTool(this.getToolDefinition()),a.registerToolComponent("run_terminal_cmd",m.TerminalToolComponent)}getToolDefinition(){return{name:"run_terminal_cmd",description:`PROPOSE a command to run on behalf of the user.
|
|
29897
|
+
\`\`\``}]}}};t.ReadFileTool=_,n.__decorate([(0,o.Autowired)(v.FileHandler),n.__metadata("design:type",v.FileHandler)],_.prototype,"fileHandler",void 0),t.ReadFileTool=_=n.__decorate([(0,l.Domain)(p.MCPServerContribution)],_)},42232:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RunTerminalCommandTool=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(43718),p=e(7473),v=e(77633),m=e(24706),_=e(22559);let s=class{registerMCPServer(a){a.registerMCPTool(this.getToolDefinition()),a.registerToolComponent("run_terminal_cmd",m.TerminalToolComponent)}getToolDefinition(){return{name:"run_terminal_cmd",label:"Run Command",description:`PROPOSE a command to run on behalf of the user.
|
|
29898
29898
|
If you have this tool, note that you DO have the ability to run commands directly on the USER's system.
|
|
29899
29899
|
|
|
29900
29900
|
Adhere to these rules:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/cli-engine",
|
|
3
|
-
"version": "3.8.1-next-
|
|
3
|
+
"version": "3.8.1-next-1740467196.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.8.1-next-
|
|
30
|
-
"@opensumi/ide-core-common": "3.8.1-next-
|
|
31
|
-
"@opensumi/ide-core-node": "3.8.1-next-
|
|
32
|
-
"@opensumi/ide-express-file-server": "3.8.1-next-
|
|
33
|
-
"@opensumi/ide-extension": "3.8.1-next-
|
|
34
|
-
"@opensumi/ide-i18n": "3.8.1-next-
|
|
35
|
-
"@opensumi/ide-main-layout": "3.8.1-next-
|
|
36
|
-
"@opensumi/ide-startup": "3.8.1-next-
|
|
29
|
+
"@opensumi/ide-core-browser": "3.8.1-next-1740467196.0",
|
|
30
|
+
"@opensumi/ide-core-common": "3.8.1-next-1740467196.0",
|
|
31
|
+
"@opensumi/ide-core-node": "3.8.1-next-1740467196.0",
|
|
32
|
+
"@opensumi/ide-express-file-server": "3.8.1-next-1740467196.0",
|
|
33
|
+
"@opensumi/ide-extension": "3.8.1-next-1740467196.0",
|
|
34
|
+
"@opensumi/ide-i18n": "3.8.1-next-1740467196.0",
|
|
35
|
+
"@opensumi/ide-main-layout": "3.8.1-next-1740467196.0",
|
|
36
|
+
"@opensumi/ide-startup": "3.8.1-next-1740467196.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": "
|
|
75
|
+
"gitHead": "680fd98e0403bcf95ee00a27dc48999590ff9aa0"
|
|
76
76
|
}
|