@opensumi/cli-engine 3.0.4-next-1717074121.0 → 3.0.4
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 +1 -1
- package/package.json +10 -10
package/lib/browser/browser.js
CHANGED
|
@@ -27279,7 +27279,7 @@ WARNING: This link could potentially be dangerous`)){const r=window.open();if(r)
|
|
|
27279
27279
|
`);this.addDecoration(d,s,c,h),this.report(s.matcher.type,c,h),this.resetState(d)}addDecoration(d,s,l,r){const c=this.terminalController.clients.get(d),h=c?.term,v=this.clientCurrentMarker.get(d);if(h&&r&&v){const f=r?.split(`
|
|
27280
27280
|
`).length;this.terminalDecorations.addZoneDecoration(h,v,f,{operationList:[s.action],onClickItem:()=>{const W=this.inlineChatFeatureRegistry.getTerminalHandler(s.action.id);W&&W.execute(r,l||"",s.matcher)}})}}resolveDelControl(d=""){const s=d.split("");let l=0;for(;l<s.length;)if(s[l].charCodeAt(0)===127){const r=Math.max(l-1,0);s.splice(r,1),l=r}else l++;return s.join("")}report(d,s,l){}registerMarker(d,s){const l=this.terminalController.clients.get(d);if(l){const r=l.term.registerMarker(s);this.clientCurrentMarker.set(d,r),this.disposables.push(r)}}handleClientInput(d,s){const l=s.toString(),r=this.inputRecordMap.get(d);/[\r\n]/.test(l)?(this.isTyping=!1,r?.push({text:this.inputCache})):(this.inputCache+=l,this.isTyping=!0)}};n.__decorate([(0,a.Autowired)(I.ITerminalController),n.__metadata("design:type",Object)],m.prototype,"terminalController",void 0),n.__decorate([(0,a.Autowired)(u.AITerminalDecorationService),n.__metadata("design:type",u.AITerminalDecorationService)],m.prototype,"terminalDecorations",void 0),n.__decorate([(0,a.Autowired)(o.InlineChatFeatureRegistryToken),n.__metadata("design:type",g.InlineChatFeatureRegistry)],m.prototype,"inlineChatFeatureRegistry",void 0),m=n.__decorate([(0,a.Injectable)()],m),e.AITerminalService=m},37632:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AITerminalPrompt=e.KeyboardSelectableList=void 0;const n=t(85608),a=t(45250),o=n.__importStar(t(14041)),I=t(41869),g=t(81878),u=t(89195),G=n.__importDefault(t(37887)),p=b=>{const{items:d,handleSuggestionClick:s,noListen:l=!1,controller:r}=b,[c,h]=(0,o.useState)(-1),v=f=>{switch(f.key){case"ArrowUp":h(W=>Math.max(W-1,0));break;case"ArrowDown":h(W=>Math.min(W+1,d.length-1));break;case"Enter":d[c]&&s(d[c].command);break;default:break}};return(0,o.useEffect)(()=>{if(!l)return window.addEventListener("keydown",v),()=>{window.removeEventListener("keydown",v)}},[d,c]),(0,o.useEffect)(()=>{if(!r)return;const f=r.event(W=>{W==="ArrowUp"&&h(N=>Math.max(N-1,0)),(W==="ArrowDown"||W==="Tab")&&h(N=>Math.min(N+1,d.length-1)),W==="Enter"&&d[c]&&s(d[c].command)});return()=>{f.dispose()}},[r,c,d]),(0,o.useEffect)(()=>{h(0)},[d]),o.default.createElement("div",{className:G.default.suggestions},d.map((f,W)=>o.default.createElement("div",{key:W,className:G.default.suggestionItem,style:{backgroundColor:W===c?"var(--selection-background)":""},onClick:()=>s(f.command)},o.default.createElement("div",{className:G.default.suggestionItemContainer},o.default.createElement("div",{className:G.default.suggestionDesc},f.description),o.default.createElement("div",{className:G.default.suggestionCmd},f.command)))))};e.KeyboardSelectableList=p;const m=b=>{const{onEscTriggered:d,onSuggestionClick:s,getAICommandSuggestions:l,cancelAIRequst:r}=b,[c,h]=(0,o.useState)(""),[v,f]=(0,o.useState)([]),[W,N]=(0,o.useState)(!1),[Z,y]=(0,o.useState)((0,I.localize)("terminal.ai.escClose")),E=(0,o.useRef)(null),R=(0,o.useCallback)(async Y=>{N(!0),y((0,I.localize)("terminal.ai.requesting")),l(Y,()=>{N(!1),y((0,I.localize)("terminal.ai.selectHint"))},()=>{N(!0),y((0,I.localize)("terminal.ai.thinking"))},_=>{f([..._].reverse())})},[v]),A=(0,o.useCallback)((0,a.debounce)(Y=>{R(Y)},1e3),[]);(0,o.useEffect)(()=>{const Y=_=>{(_.key==="Escape"||_.keyCode===27)&&d()};return document.addEventListener("keydown",Y),()=>{document.removeEventListener("keydown",Y)}},[]),(0,o.useEffect)(()=>{const Y=_=>{E.current&&!E.current.contains(_.target)&&d()};return document.addEventListener("mousedown",Y),()=>{document.removeEventListener("mousedown",Y)}},[d]);const w=Y=>{const _=Y.target.value;h(_),_.length>0&&!_.includes("'")&&A(_),_.length===0&&(f([]),y((0,I.localize)("terminal.ai.escClose")),r&&r())},F=(0,o.useCallback)(()=>{R(c)},[c]),V=Y=>{s(Y)};return o.default.createElement("div",{className:G.default.container,ref:E},o.default.createElement("div",{className:G.default.header},o.default.createElement("div",{style:{flex:"1"}},(0,I.localize)("terminal.ai.headerHint")),o.default.createElement("div",null,o.default.createElement(u.EnhanceIcon,{className:(0,g.getIcon)("close1"),onClick:()=>{d()}}))),o.default.createElement("div",{style:{position:"relative",marginLeft:"-14px"}},v.length>0&&o.default.createElement(e.KeyboardSelectableList,{items:v,handleSuggestionClick:V})),o.default.createElement("div",{className:G.default.inputContainer},o.default.createElement(g.Input,{type:"text",value:c,onKeyDown:Y=>{(Y.key==="ArrowUp"||Y.key==="ArrowDown")&&Y.preventDefault()},onChange:w,onPressEnter:()=>F(),placeholder:(0,I.localize)("terminal.ai.inputHint"),className:G.default.input,autoFocus:!0}),W?o.default.createElement("div",{className:G.default.ai_loading},o.default.createElement("div",{className:G.default.loader}),o.default.createElement("div",{className:G.default.loader}),o.default.createElement("div",{className:G.default.loader})):o.default.createElement(u.EnhanceIcon,{wrapperClassName:G.default.send_icon,className:(0,g.getIcon)("send-solid"),onClick:()=>{A(c)}})),o.default.createElement("div",{className:G.default.statusContainer},Z))};e.AITerminalPrompt=m},55232:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TerminalInlineWidgetForDetection=e.TerminalInlineWidgetForSelection=void 0;const n=t(85608),a=n.__importStar(t(14041)),o=t(89195),I=n.__importDefault(t(48655)),g=({actions:G,onClickItem:p})=>a.default.createElement("div",{className:I.default.terminal_inline_chat},a.default.createElement(o.AIAction,{operationList:G,onClickItem:p}));e.TerminalInlineWidgetForSelection=g;const u=({actions:G,onClickItem:p})=>{const[m,b]=(0,a.useState)(!1);return a.default.createElement("div",{onMouseOver:d=>{b(!0),d.currentTarget.style.backgroundColor="rgba(255, 0, 0, 0.1)"},onMouseOut:d=>{b(!1),d.currentTarget.style.backgroundColor=""},style:{width:"100%",height:"100%"}},a.default.createElement("div",{className:I.default.terminal_inline_chat,style:{display:m?"block":"none"}},a.default.createElement(o.AIAction,{operationList:G,onClickItem:p})))};e.TerminalInlineWidgetForDetection=u},87656:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AITerminalDecorationService=void 0;const n=t(85608),a=n.__importDefault(t(14041)),o=t(25873),I=t(76003),g=t(43718),u=t(6487),G=t(2281),p=t(55232);let m=class extends g.Disposable{constructor(){super(...arguments),this.decorationList=[],this.decorationRootMap=new Map}active(){this.disposables.push(this.terminalController.onDidOpenTerminal(({id:d})=>this.doSelectionDecoration(d)))}addZoneDecoration(d,s,l,r){const c=d.registerDecoration({marker:s,width:d.cols,height:l});if(!c){console.error("Failed to create decoration for line",s);return}let h;c.onRender(v=>{h||(h=(0,o.createRoot)(v)),h.render(a.default.createElement(p.TerminalInlineWidgetForDetection,{actions:r.operationList,onClickItem:()=>{r.onClickItem()}}))}),c.onDispose(()=>{h&&h.unmount()})}doSelectionDecoration(d){const s=this.terminalController.clients.get(d),l=s?.term;l&&this.addDispose(l.onSelectionChange(()=>{const r=this.decorationList.pop();r&&(0,g.runWhenIdle)(()=>{r?.dispose()});const c=l.getSelectionPosition(),h=l.getSelection().trim();if(c&&h.length>0){const v=c.end.y,f=c.start.y,W=l.buffer.active.cursorY+l.buffer.active.baseY,N=f-W,Z=v-f+1,y=l.registerMarker(N);if(y){const E=l.registerDecoration({marker:y,width:l.cols,height:Z});if(E){let R;E.onRender(A=>{R||(R=(0,o.createRoot)(A));const F=this.inlineChatFeatureRegistry.getTerminalActions().filter(V=>{var Y;return((Y=this.inlineChatFeatureRegistry.getTerminalHandler(V.id))===null||Y===void 0?void 0:Y.triggerRules)==="selection"});R.render(a.default.createElement(p.TerminalInlineWidgetForSelection,{actions:F,onClickItem:V=>{const Y=this.inlineChatFeatureRegistry.getTerminalHandler(V);Y&&Y.execute(h,"")}}))}),E.onDispose(()=>{R&&R.unmount()}),this.decorationList.push(E)}}}}))}};n.__decorate([(0,I.Autowired)(u.ITerminalController),n.__metadata("design:type",Object)],m.prototype,"terminalController",void 0),n.__decorate([(0,I.Autowired)(g.InlineChatFeatureRegistryToken),n.__metadata("design:type",G.InlineChatFeatureRegistry)],m.prototype,"inlineChatFeatureRegistry",void 0),m=n.__decorate([(0,I.Injectable)()],m),e.AITerminalDecorationService=m},83798:(L,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BaseTerminalDetectionLineMatcher=e.MatcherType=void 0;var t;(function(a){a[a.base=0]="base",a[a.npm=1]="npm",a[a.typescript=2]="typescript",a[a.node=3]="node",a[a.shell=4]="shell",a[a.java=5]="java"})(t=e.MatcherType||(e.MatcherType={}));class n{constructor(){this.type=t.base,this.isMultiLine=!1,this.isMatched=!1,this.maxSpaceLine=0,this.currentSpaceLine=0}match(o){return this.doMatch(o)?(this.isMatched=!0,this.currentSpaceLine=0,!0):this.isMultiLine&&this.isMatched&&this.currentSpaceLine<this.maxSpaceLine?(this.currentSpaceLine++,!0):(this.isMatched=!1,!1)}}e.BaseTerminalDetectionLineMatcher=n},99931:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.JavaMatcher=e.ShellMatcher=e.NPMMatcher=e.TSCMatcher=e.NodeMatcher=void 0,t(85608).__exportStar(t(83798),e);var a=t(29563);Object.defineProperty(e,"NodeMatcher",{enumerable:!0,get:function(){return a.NodeMatcher}});var o=t(1061);Object.defineProperty(e,"TSCMatcher",{enumerable:!0,get:function(){return o.TSCMatcher}});var I=t(67570);Object.defineProperty(e,"NPMMatcher",{enumerable:!0,get:function(){return I.NPMMatcher}});var g=t(83053);Object.defineProperty(e,"ShellMatcher",{enumerable:!0,get:function(){return g.ShellMatcher}});var u=t(43903);Object.defineProperty(e,"JavaMatcher",{enumerable:!0,get:function(){return u.JavaMatcher}})},43903:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.JavaMatcher=void 0;const n=t(83798);class a extends n.BaseTerminalDetectionLineMatcher{constructor(){super(...arguments),this.type=n.MatcherType.java,this.isMultiLine=!0}doMatch(I){return this.isErrorStack(I)||this.isCasuseByError(I)||this.isExceptionError(I)}isErrorStack(I){return this.isMatched&&!!I.find(g=>/^\s+at\s/i.test(g.content))}isCasuseByError(I){return!!I.find(g=>/caused\sby:/i.test(g.content))}isExceptionError(I){return!!I.find(g=>/\w+Exception:/i.test(g.content))}}e.JavaMatcher=a},29563:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.NodeMatcher=void 0;const n=t(85933),a=t(83798);class o extends a.BaseTerminalDetectionLineMatcher{constructor(){super(...arguments),this.type=a.MatcherType.node,this.isMultiLine=!0,this.maxSpaceLine=1}doMatch(g){return this.isSingleLineError(g)||this.isMultiPartError(g)}isSingleLineError(g){return g.length===1&&(0,n.isRedColor)(g[0])&&(this.isMatched||!this.isExcludeContent(g[0].content))}isMultiPartError(g){return g.length>1&&!g.some(u=>!(0,n.isRedColor)(u))}isExcludeContent(g){return g.length<20||/mfsu/i.test(g)||/\s-\s/.test(g)}}e.NodeMatcher=o},67570:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.NPMMatcher=void 0;const n=t(85933),a=t(83798);class o extends a.BaseTerminalDetectionLineMatcher{constructor(){super(...arguments),this.type=a.MatcherType.npm,this.isMultiLine=!0,this.maxSpaceLine=1}doMatch(g){return!!g.find(u=>/ERR/.test(u.content)&&(0,n.isRedColor)(u))}}e.NPMMatcher=o},83053:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ShellMatcher=void 0;const n=t(83798);class a extends n.BaseTerminalDetectionLineMatcher{constructor(){super(...arguments),this.type=n.MatcherType.shell,this.isMultiLine=!1}doMatch(I){return!!I.find(g=>/command\snot\sfound/.test(g.content))}}e.ShellMatcher=a},1061:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TSCMatcher=void 0;const n=t(85933),a=t(83798);class o extends a.BaseTerminalDetectionLineMatcher{constructor(){super(...arguments),this.type=a.MatcherType.typescript,this.isMultiLine=!0}doMatch(g){let u=!1,G=!1,p=!1;return g.forEach(m=>{/error/i.test(m.content)&&(0,n.isRedColor)(m)&&(u=!0),/TS\d+/.test(m.content)&&(G=!0),/Error:/i.test(m.content)&&(p=!0)}),u||G||p||this.isErrorStack(g)}isErrorStack(g){return this.isMatched&&!!g.find(u=>/^\s+at\s/i.test(u.content))}}e.TSCMatcher=o},68222:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PS1TerminalService=void 0;const n=t(85608),a=n.__importDefault(t(124)),o=n.__importDefault(t(14041)),I=t(25873),g=t(76003),u=t(41869),G=t(43718),p=t(6487),m=t(93062),b=t(37632),d=t(51903);var s;(function(r){r.PromptStarted="PS",r.PromptEnded="PE",r.CurrentWorkingDirectory="CWD"})(s||(s={}));let l=class extends G.Disposable{constructor(){super(...arguments),this.cancelToken=new G.CancellationTokenSource}active(){this.initContainer(),this.disposables.push(this.terminalController.onDidOpenTerminal(({id:c})=>this.listenTerminalEvent(c)))}listenTerminalEvent(c){const h=this.terminalController.clients.get(c);h&&setTimeout(()=>{this.listenPromptState(h.term)},0)}initContainer(){this.popupContainer=document.createElement("div"),document.body.appendChild(this.popupContainer)}listenPromptState(c){c.parser.registerOscHandler(6973,h=>{const v=h.indexOf(";");switch(v===-1?h:h.substring(0,v)){case s.PromptEnded:this.handlePromptEnd(c);break;default:return!1}return!1})}handlePromptEnd(c){this.promptEndMarker&&this.promptEndMarker.dispose(),this.promptEndDecoration&&this.promptEndDecoration.dispose(),this.promptEndMarker=c.registerMarker(0);const h=c.buffer.active.cursorX;this.onDataDisposable&&this.onDataDisposable.dispose();const v=c.registerDecoration({marker:this.promptEndMarker,width:c.cols,height:1,x:h+2,layer:"top"});v?.onRender(f=>{f.innerText=(0,u.localize)("terminal.ai.inputSharpToGetHint"),f.style.opacity="0.3"}),this.onDataDisposable=c.onData(f=>{var W;const N=c.buffer.active,Z=N.cursorX,y=N.cursorY;v?.dispose(),f==="#"&&y+N.baseY===((W=this.promptEndMarker)===null||W===void 0?void 0:W.line)&&(Z===h||Z===h+1)&&this.showAICommandPopup(c,h)})}showAICommandPopup(c,h){var v,f,W;if(!this.promptEndMarker)return;this.promptEndDecoration=c.registerDecoration({marker:this.promptEndMarker,width:1,height:1,backgroundColor:"#2472C8",x:h,layer:"top"});const N=c._addonManager._addons.find(y=>{var E;return!!(!((E=y?.instance)===null||E===void 0)&&E.connection)}),Z=(v=N?.instance)===null||v===void 0?void 0:v.connection;if(!Z){console.error((0,u.localize)("terminal.ai.cannotGetTerminalConnection"));return}(f=this.promptEndDecoration)===null||f===void 0||f.onRender(y=>{const E=y.clientWidth;this.promptEndReactRoot&&this.promptEndReactRoot.unmount(),this.promptEndReactRoot=(0,I.createRoot)(this.popupContainer),this.promptEndReactRoot.render(o.default.createElement(b.AITerminalPrompt,{onEscTriggered:()=>{setTimeout(()=>{var R;Z.sendData("\b"),(R=this.promptEndDecoration)===null||R===void 0||R.dispose()},0)},onSuggestionClick:R=>{setTimeout(()=>{var A;Z.sendData("\b"),Z.sendData(R),(A=this.promptEndDecoration)===null||A===void 0||A.dispose()},0)},getAICommandSuggestions:this.getAICommandSuggestions.bind(this),cancelAIRequst:this.stopAIStreamRequest.bind(this)})),(0,a.default)(this.popupContainer,y,{points:["bl","bl"],offset:[-E-6,0],targetOffset:[0,0],overflow:{adjustX:!1,adjustY:!1}})}),(W=this.promptEndDecoration)===null||W===void 0||W.onDispose(()=>{this.stopAIStreamRequest(),this.promptEndReactRoot&&this.promptEndReactRoot.unmount(),c.focus()})}async stopAIStreamRequest(){this.cancelToken.cancel(),this.cancelToken=new G.CancellationTokenSource}async getAICommandSuggestions(c,h,v,f){await this.stopAIStreamRequest();const W=this.aiReporter.start("terminalAICommand",{message:c}),N=await this.terminalFeatureRegistry.readableCommandSuggestions(c,this.cancelToken.token),Z=[];(0,m.listenReadable)(N,{onData:y=>{Z.push(y),f(Z)},onEnd:()=>{h(),this.aiReporter.end(W,{message:c,success:!0})}})}};n.__decorate([(0,g.Autowired)(p.ITerminalController),n.__metadata("design:type",Object)],l.prototype,"terminalController",void 0),n.__decorate([(0,g.Autowired)(G.TerminalRegistryToken),n.__metadata("design:type",d.TerminalFeatureRegistry)],l.prototype,"terminalFeatureRegistry",void 0),n.__decorate([(0,g.Autowired)(G.IAIReporter),n.__metadata("design:type",Object)],l.prototype,"aiReporter",void 0),l=n.__decorate([(0,g.Injectable)()],l),e.PS1TerminalService=l},74788:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TerminalAIContribution=void 0;const n=t(85608),a=t(76003),o=t(41869),I=t(43718),g=t(57550),u=t(87656),G=t(68222),p=t(51903);let m=class{onDidStart(){this.aiNativeConfigService.capabilities.supportsTerminalDetection&&(this.aiTerminalService.active(),this.aiTerminalDecorationService.active()),this.aiNativeConfigService.capabilities.supportsTerminalCommandSuggest&&this.terminalFeatureRegistry.hasProvider()&&this.ps1TerminalService.active()}};n.__decorate([(0,a.Autowired)(g.AITerminalService),n.__metadata("design:type",g.AITerminalService)],m.prototype,"aiTerminalService",void 0),n.__decorate([(0,a.Autowired)(u.AITerminalDecorationService),n.__metadata("design:type",u.AITerminalDecorationService)],m.prototype,"aiTerminalDecorationService",void 0),n.__decorate([(0,a.Autowired)(G.PS1TerminalService),n.__metadata("design:type",G.PS1TerminalService)],m.prototype,"ps1TerminalService",void 0),n.__decorate([(0,a.Autowired)(o.AINativeConfigService),n.__metadata("design:type",o.AINativeConfigService)],m.prototype,"aiNativeConfigService",void 0),n.__decorate([(0,a.Autowired)(I.TerminalRegistryToken),n.__metadata("design:type",p.TerminalFeatureRegistry)],m.prototype,"terminalFeatureRegistry",void 0),m=n.__decorate([(0,o.Domain)(o.ClientAppContribution)],m),e.TerminalAIContribution=m},51903:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TerminalFeatureRegistry=void 0;const n=t(85608),a=t(76003),o=t(43718),I=t(93062),g=t(77633);let u=class extends o.Disposable{constructor(){super(...arguments),this.providerMap=new Set}hasProvider(){return this.providerMap.size>0}registerCommandSuggestionsProvider(p){this.providerMap.add(p)}async readableCommandSuggestions(p,m){var b,d,s,l;const r=Array.from(this.providerMap),c=[],h=[];try{for(var v=!0,f=n.__asyncValues(r),W;W=await f.next(),b=W.done,!b;){l=W.value,v=!1;try{const y=await l(p,m);if((0,I.isReadableStream)(y)){c.push(y);continue}h.push(...y)}finally{v=!0}}}catch(Z){d={error:Z}}finally{try{!v&&!b&&(s=f.return)&&await s.call(f)}finally{if(d)throw d.error}}const N=g.TerminalSuggestionReadableStream.create();return h.forEach(N.emitData.bind(N)),c.length===0?queueMicrotask(()=>{N.end()}):(0,I.listenGroupReadable)(c,{onData:N.emitData.bind(N),onEnd:N.end.bind(N)}),N}};u=n.__decorate([(0,a.Injectable)()],u),e.TerminalFeatureRegistry=u},85933:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isRedColor=e.ansiParser=e.ColorCode=e.StyleCode=void 0;const a=t(85608).__importDefault(t(91371)),o={color:0,isSpecialColor:!1,isRgbColor:!1,is256Color:!1,bgColor:0,isSpecialBg:!1,isRgbBg:!1,is256Bg:!1,bold:!1,underline:!1};var I;(function(m){m[m.RESET=0]="RESET",m[m.BOLD=1]="BOLD",m[m.UNDERLINE=4]="UNDERLINE",m[m.RESET_BOLD=22]="RESET_BOLD",m[m.RESET_UNDERLINE=24]="RESET_UNDERLINE"})(I=e.StyleCode||(e.StyleCode={}));var g;(function(m){m[m.MODE_RGB=2]="MODE_RGB",m[m.MODE_256=5]="MODE_256",m[m.BLACK=30]="BLACK",m[m.RED=31]="RED",m[m.GREEN=32]="GREEN",m[m.YELLOW=33]="YELLOW",m[m.BLUE=34]="BLUE",m[m.MAGENTA=35]="MAGENTA",m[m.CYAN=36]="CYAN",m[m.WHITE=37]="WHITE",m[m.SPECIAL_COLOR_MODE=38]="SPECIAL_COLOR_MODE",m[m.RESET_COLOR=39]="RESET_COLOR",m[m.BLACK_BG=40]="BLACK_BG",m[m.RED_BG=41]="RED_BG",m[m.GREEN_BG=42]="GREEN_BG",m[m.YELLOW_BG=43]="YELLOW_BG",m[m.BLUE_BG=44]="BLUE_BG",m[m.MAGENTA_BG=45]="MAGENTA_BG",m[m.CYAN_BG=46]="CYAN_BG",m[m.WHITE_BG=47]="WHITE_BG",m[m.SPECIAL_BG_MODE=48]="SPECIAL_BG_MODE",m[m.RESET_BG=49]="RESET_BG",m[m.BLACK_BRIGHT=90]="BLACK_BRIGHT",m[m.RED_BRIGHT=91]="RED_BRIGHT",m[m.GREEN_BRIGHT=92]="GREEN_BRIGHT",m[m.YELLOW_BRIGHT=93]="YELLOW_BRIGHT",m[m.BLUE_BRIGHT=94]="BLUE_BRIGHT",m[m.MAGENTA_BRIGHT=95]="MAGENTA_BRIGHT",m[m.CYAN_BRIGHT=96]="CYAN_BRIGHT",m[m.WHITE_BRIGHT=97]="WHITE_BRIGHT",m[m.BLACK_HIGH_INTENSITY=100]="BLACK_HIGH_INTENSITY",m[m.RED_HIGH_INTENSITY=101]="RED_HIGH_INTENSITY",m[m.GREEN_HIGH_INTENSITY=102]="GREEN_HIGH_INTENSITY",m[m.BLUE_HIGH_INTENSITY=104]="BLUE_HIGH_INTENSITY",m[m.MAGENTA_HIGH_INTENSITY=105]="MAGENTA_HIGH_INTENSITY",m[m.CYAN_HIGH_INTENSITY=106]="CYAN_HIGH_INTENSITY",m[m.WHITE_HIGH_INTENSITY=107]="WHITE_HIGH_INTENSITY"})(g=e.ColorCode||(e.ColorCode={}));function u(m,b,d){b.isSpecialColor||b.isSpecialBg?d===g.SPECIAL_COLOR_MODE?b.color=m:b.bgColor=m:m>=30&&m<=37||m>=90&&m<=97?b.color=m:(m>=40&&m<=47||m>=100&&m<=107)&&(b.bgColor=m)}function G(m,b){const d=(0,a.default)(),s=[];let l,r=0;const c=Object.assign({},b||o);for(;l=d.exec(m);){const v=m.slice(r,l.index);v&&s.push(Object.assign({content:v},c));const f=l[0].slice(2,-1).split(";").map(Number);if(f.length)for(let W=0;W<f.length;W++){const N=f[W],Z=f[W-1];switch(N){case I.RESET:Object.assign(c,o);break;case I.BOLD:c.bold=!0;break;case I.UNDERLINE:c.underline=!0;break;case I.RESET_BOLD:c.bold=!1;break;case I.RESET_UNDERLINE:c.underline=!1;break;case g.RESET_COLOR:c.color=0;break;case g.RESET_BG:c.bgColor=0;break;case g.SPECIAL_COLOR_MODE:c.isSpecialColor=!0;break;case g.SPECIAL_BG_MODE:c.isSpecialBg=!0;break;case g.MODE_RGB:Z===g.SPECIAL_COLOR_MODE?c.isRgbColor=!0:c.isRgbBg=!0;break;case g.MODE_256:Z===g.SPECIAL_COLOR_MODE?c.is256Color=!0:c.is256Bg=!0;break;default:u(N,c,f[W-2])}}r=l.index+l[0].length}const h=m.slice(r);return h&&s.push(Object.assign({content:h},c)),{parts:s,currentStyle:c}}e.ansiParser=G;function p(m){const{color:b,isSpecialColor:d,is256Color:s}=m;return d?s?b===1||b===9||b>=160&&b<=196:b===255:b===g.RED||b===g.RED_BRIGHT}e.isRedColor=p},74055:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ChatAgentService=void 0;const n=t(85608),a=n.__importDefault(t(66652)),o=t(76003),I=t(43718),g=t(29770);let u=class extends I.Disposable{constructor(){super(),this.agents=new Map,this._onDidChangeAgents=new I.Emitter,this.onDidChangeAgents=this._onDidChangeAgents.event,this._onDidSendMessage=new I.Emitter,this.onDidSendMessage=this._onDidSendMessage.event,this.addDispose(this._onDidChangeAgents)}registerAgent(p){if(this.agents.has(p.id))throw new Error(`Already registered an agent with id ${p.id}`);return this.agents.set(p.id,{agent:p,commands:[]}),this._onDidChangeAgents.fire(),(0,I.toDisposable)(()=>{this.agents.delete(p.id)&&this._onDidChangeAgents.fire()})}async updateAgent(p,m){const b=this.agents.get(p);if(!b)throw new Error(`No agent with id ${p} registered`);b.agent.metadata=Object.assign(Object.assign({},b.agent.metadata),m),b.agent.provideSlashCommands(I.CancellationToken.None).then(s=>{b.commands=s}),m.isDefault&&(this.defaultAgentId=p);const d=await b.agent.provideChatWelcomeMessage(I.CancellationToken.None);if(d){const{content:s,sampleQuestions:l}=d;this.chatFeatureRegistry.registerWelcome(s,l)}this._onDidChangeAgents.fire()}getAgents(){return Array.from(this.agents.values(),p=>p.agent)}hasAgent(p){return this.agents.has(p)}getDefaultAgentId(){return this.defaultAgentId}getAgent(p){const m=this.agents.get(p);return m?.agent}async invokeAgent(p,m,b,d,s){const l=this.agents.get(p);if(!l)throw new Error(`No agent with id ${p}`);return await l.agent.invoke(m,b,d,s)}populateChatInput(p,m){this.aiChatService.sendMessage(Object.assign(Object.assign({},m),{agentId:p,immediate:!1}))}getCommands(){return(0,a.default)(Array.from(this.agents.values(),({agent:p,commands:m})=>m.map(b=>Object.assign(Object.assign({},b),{agentId:p.id}))))}async getFollowups(p,m,b){const d=this.agents.get(p);if(!d)throw new Error(`No agent with id ${p}`);return d.agent.provideFollowups?d.agent.provideFollowups(m,b):[]}async getSampleQuestions(p,m){const b=this.agents.get(p);if(!b)throw new Error(`No agent with id ${p}`);return b.agent.provideSampleQuestions?b.agent.provideSampleQuestions(m):[]}async getAllSampleQuestions(){const p=await Promise.all(Array.from(this.agents.values()).map(async({agent:m})=>{try{return await this.getSampleQuestions(m.id,I.CancellationToken.None)}catch(b){return this.logger.error(b),[]}}));return(0,a.default)(p)}sendMessage(p){this._onDidSendMessage.fire(p)}parseMessage(p,m){var b;const d={agentId:"",command:"",message:p};let s=m;const l=this.getAgents(),r=new RegExp(`^@(${l.map(h=>h.id).join("|")})(?:\\s+|$)`,"i"),c=d.message.match(r);if(c){const h=l.find(v=>v.id.toLowerCase()===c[1].toLowerCase());if(!h)return d;s=h.id,d.agentId=s,d.message=d.message.replace(c[0],"")}if(s){const h=(b=this.agents.get(s))===null||b===void 0?void 0:b.commands;if(h?.length){const v=new RegExp(`^/\\s?(${h.map(W=>W.name).join("|")})(?:\\s+|$)`,"i"),f=d.message.match(v);if(f){const W=h.find(N=>N.name.toLowerCase()===f[1].toLowerCase());if(!W)return d;d.command=W.name,d.message=d.message.replace(f[0],"")}}}return d}};n.__decorate([(0,o.Autowired)(I.ILogger),n.__metadata("design:type",Object)],u.prototype,"logger",void 0),n.__decorate([(0,o.Autowired)(I.ChatServiceToken),n.__metadata("design:type",g.ChatService)],u.prototype,"aiChatService",void 0),n.__decorate([(0,o.Autowired)(I.ChatFeatureRegistryToken),n.__metadata("design:type",Object)],u.prototype,"chatFeatureRegistry",void 0),u=n.__decorate([(0,o.Injectable)(),n.__metadata("design:paramtypes",[])],u),e.ChatAgentService=u},84543:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ChatAgentViewService=void 0;const n=t(85608),a=t(76003),o=t(43718),I=t(19413),g=t(51081);let u=class{constructor(){this.componentsMap=new Map,this.componentsDeferredMap=new Map}registerChatComponent(p){return this.componentsMap.set(p.id,p),this.componentsDeferredMap.has(p.id)&&(this.componentsDeferredMap.get(p.id).resolve(p),this.componentsDeferredMap.delete(p.id)),{dispose:()=>{this.componentsMap.get(p.id)===p&&(this.componentsMap.delete(p.id),this.componentsDeferredMap.delete(p.id))}}}getChatComponent(p){return this.componentsMap.has(p)?this.componentsMap.get(p):(this.componentsDeferredMap.has(p)||this.componentsDeferredMap.set(p,new o.Deferred),null)}getChatComponentDeferred(p){return this.componentsDeferredMap.get(p)||null}getRenderAgents(){return this.chatAgentService.getAgents().filter(p=>p.id!==g.ChatProxyService.AGENT_ID)}};n.__decorate([(0,a.Autowired)(I.IChatAgentService),n.__metadata("design:type",Object)],u.prototype,"chatAgentService",void 0),u=n.__decorate([(0,a.Injectable)()],u),e.ChatAgentViewService=u},61282:(L,e,t)=>{"use strict";var n,a;Object.defineProperty(e,"__esModule",{value:!0}),e.ChatManagerService=void 0;const o=t(85608),I=t(76003),g=t(43718),u=t(19413),G=t(42033);let p=class extends g.Disposable{constructor(){super(),n.set(this,this.registerDispose(new g.DisposableMap)),a.set(this,this.registerDispose(new g.DisposableMap))}startSession(){const b=this.injector.get(G.ChatModel);return o.__classPrivateFieldGet(this,n,"f").set(b.sessionId,b),b}getSession(b){return o.__classPrivateFieldGet(this,n,"f").get(b)}clearSession(b){var d;if(!o.__classPrivateFieldGet(this,n,"f").get(b))throw new Error(`Unknown session: ${b}`);o.__classPrivateFieldGet(this,n,"f").disposeKey(b),(d=o.__classPrivateFieldGet(this,a,"f").get(b))===null||d===void 0||d.cancel(),o.__classPrivateFieldGet(this,a,"f").disposeKey(b)}createRequest(b,d,s,l){const r=this.getSession(b);if(!r)throw new Error(`Unknown session: ${b}`);if(!o.__classPrivateFieldGet(this,a,"f").has(b))return r.addRequest({prompt:d,agentId:s,command:l})}async sendRequest(b,d,s){const l=this.getSession(b);if(!l)throw new Error(`Unknown session: ${b}`);const r=new g.CancellationTokenSource,c=r.token;o.__classPrivateFieldGet(this,a,"f").set(l.sessionId,r);const h=c.onCancellationRequested(()=>{d.response.cancel()}),v=[];for(const f of l.requests)f.response.isComplete&&(v.push({role:1,content:f.message.prompt}),v.push({role:2,content:f.response.responseText}));try{const f=Z=>{c.isCancellationRequested||l.acceptResponseProgress(d,Z)},W={sessionId:b,requestId:d.requestId,message:d.message.prompt,command:d.message.command,regenerate:s},N=await this.chatAgentService.invokeAgent(d.message.agentId,W,f,v,c);c.isCancellationRequested||(N.errorDetails&&d.response.setErrorDetails(N.errorDetails),this.chatAgentService.getFollowups(d.message.agentId,b,g.CancellationToken.None).then(y=>{d.response.setFollowups(y),d.response.complete()}))}finally{h.dispose(),o.__classPrivateFieldGet(this,a,"f").disposeKey(l.sessionId)}}cancelRequest(b){var d;(d=o.__classPrivateFieldGet(this,a,"f").get(b))===null||d===void 0||d.cancel(),o.__classPrivateFieldGet(this,a,"f").disposeKey(b)}};n=new WeakMap,a=new WeakMap,o.__decorate([(0,I.Autowired)(I.INJECTOR_TOKEN),o.__metadata("design:type",I.Injector)],p.prototype,"injector",void 0),o.__decorate([(0,I.Autowired)(u.IChatAgentService),o.__metadata("design:type",Object)],p.prototype,"chatAgentService",void 0),p=o.__decorate([(0,I.Injectable)(),o.__metadata("design:paramtypes",[])],p),e.ChatManagerService=p},42033:(L,e,t)=>{"use strict";var n,a,o,I,g,u,G,p,m,b,d,s,l,r,c,h;Object.defineProperty(e,"__esModule",{value:!0}),e.ChatSlashCommandItemModel=e.ChatWelcomeMessageModel=e.ChatModel=e.ChatRequestModel=e.ChatResponseModel=void 0;const v=t(85608),f=t(76003),W=t(43718),N=t(90684),Z=t(19413);let y=class extends W.Disposable{get responseParts(){return v.__classPrivateFieldGet(this,a,"f")}get responseContents(){return v.__classPrivateFieldGet(this,o,"f")}get isComplete(){return v.__classPrivateFieldGet(this,I,"f")}get isCanceled(){return v.__classPrivateFieldGet(this,g,"f")}get requestId(){return v.__classPrivateFieldGet(this,u,"f")}get responseText(){return v.__classPrivateFieldGet(this,G,"f")}get errorDetails(){return v.__classPrivateFieldGet(this,p,"f")}get followups(){return v.__classPrivateFieldGet(this,m,"f")}get onDidChange(){return v.__classPrivateFieldGet(this,b,"f").event}constructor(V,Y,_){super(),this.session=Y,this.agentId=_,n.add(this),a.set(this,[]),o.set(this,[]),I.set(this,!1),g.set(this,!1),u.set(this,void 0),G.set(this,""),p.set(this,void 0),m.set(this,void 0),b.set(this,this.registerDispose(new W.Emitter)),v.__classPrivateFieldSet(this,u,V,"f")}updateContent(V,Y){var _;if(V.kind==="content"||V.kind==="markdownContent"){const H=v.__classPrivateFieldGet(this,a,"f").length-1,S=v.__classPrivateFieldGet(this,a,"f")[H];!S||S.kind!=="markdownContent"?V.kind==="content"?v.__classPrivateFieldGet(this,a,"f").push({content:new N.MarkdownString(V.content),kind:"markdownContent"}):v.__classPrivateFieldGet(this,a,"f").push(V):V.kind==="markdownContent"?v.__classPrivateFieldGet(this,a,"f")[H]={content:new N.MarkdownString(S.content.value+V.content.value),kind:"markdownContent"}:v.__classPrivateFieldGet(this,a,"f")[H]={content:new N.MarkdownString(S.content.value+V.content,S.content),kind:"markdownContent"},v.__classPrivateFieldGet(this,n,"m",d).call(this)}else if(V.kind==="asyncContent"){const H=v.__classPrivateFieldGet(this,a,"f").push(V)-1;v.__classPrivateFieldGet(this,n,"m",d).call(this),(_=V.resolvedContent)===null||_===void 0||_.then(S=>{typeof S=="string"?v.__classPrivateFieldGet(this,a,"f")[H]={content:new N.MarkdownString(S),kind:"markdownContent"}:(0,N.isMarkdownString)(S)?v.__classPrivateFieldGet(this,a,"f")[H]={content:S,kind:"markdownContent"}:v.__classPrivateFieldGet(this,a,"f")[H]=S,v.__classPrivateFieldGet(this,n,"m",d).call(this,Y)})}else V.kind==="treeData"?(v.__classPrivateFieldGet(this,a,"f").push(V),v.__classPrivateFieldGet(this,n,"m",d).call(this,Y)):V.kind==="component"&&(v.__classPrivateFieldGet(this,a,"f").push(V),v.__classPrivateFieldGet(this,n,"m",d).call(this,Y))}complete(){v.__classPrivateFieldSet(this,I,!0,"f"),v.__classPrivateFieldGet(this,b,"f").fire()}cancel(){v.__classPrivateFieldSet(this,I,!0,"f"),v.__classPrivateFieldSet(this,g,!0,"f"),v.__classPrivateFieldGet(this,b,"f").fire()}reset(){v.__classPrivateFieldSet(this,o,[],"f"),v.__classPrivateFieldSet(this,a,[],"f"),v.__classPrivateFieldSet(this,G,"","f"),v.__classPrivateFieldSet(this,g,!1,"f"),v.__classPrivateFieldSet(this,I,!1,"f"),v.__classPrivateFieldSet(this,p,void 0,"f"),v.__classPrivateFieldSet(this,m,void 0,"f"),v.__classPrivateFieldGet(this,b,"f").fire()}setErrorDetails(V){v.__classPrivateFieldSet(this,p,V,"f"),v.__classPrivateFieldGet(this,b,"f").fire()}setFollowups(V){v.__classPrivateFieldSet(this,m,V,"f"),v.__classPrivateFieldGet(this,b,"f").fire()}};a=new WeakMap,o=new WeakMap,I=new WeakMap,g=new WeakMap,u=new WeakMap,G=new WeakMap,p=new WeakMap,m=new WeakMap,b=new WeakMap,n=new WeakSet,d=function(V){v.__classPrivateFieldSet(this,G,v.__classPrivateFieldGet(this,a,"f").map(_=>_.kind==="asyncContent"?_.content:_.kind==="treeData"||_.kind==="component"?"":_.content.value).join(`
|
|
27281
27281
|
|
|
27282
|
-
`),"f");const Y=[];for(const _ of v.__classPrivateFieldGet(this,a,"f")){const H=Y[Y.length-1];_.kind==="markdownContent"&&H?.kind==="markdownContent"?Y[Y.length-1]={content:new N.MarkdownString(H.content.value+_.content.value,{isTrusted:H.content.isTrusted}),kind:"markdownContent"}:Y.push(_)}v.__classPrivateFieldSet(this,o,Y,"f"),V||v.__classPrivateFieldGet(this,b,"f").fire()},y=v.__decorate([(0,f.Injectable)({multiple:!0}),v.__metadata("design:paramtypes",[String,Object,String])],y),e.ChatResponseModel=y;let E=class{get requestId(){return v.__classPrivateFieldGet(this,s,"f")}constructor(V,Y,_,H){this.session=Y,this.message=_,this.response=H,s.set(this,void 0),v.__classPrivateFieldSet(this,s,V,"f")}};s=new WeakMap,E=v.__decorate([(0,f.Injectable)({multiple:!0}),v.__metadata("design:paramtypes",[String,Object,Object,y])],E),e.ChatRequestModel=E;let R=c=class extends W.Disposable{constructor(){super(...arguments),l.set(this,(0,W.uuid)()),r.set(this,new Map)}get sessionId(){return v.__classPrivateFieldGet(this,l,"f")}get requests(){return Array.from(v.__classPrivateFieldGet(this,r,"f").values())}addRequest(V){const Y=`${this.sessionId}_request_${c.requestIdPool++}`,_=new y(Y,this,V.agentId),H=new E(Y,this,V,_);return v.__classPrivateFieldGet(this,r,"f").set(Y,H),H}acceptResponseProgress(V,Y,_){if(V.response.isComplete)throw new Error("acceptResponseProgress: Adding progress to a completed response");const{kind:H}=Y;["content","markdownContent","asyncContent","treeData","component"].includes(H)?V.response.updateContent(Y,_):this.logger.error(`Couldn't handle progress: ${JSON.stringify(Y)}`)}getRequest(V){return v.__classPrivateFieldGet(this,r,"f").get(V)}dispose(){super.dispose(),v.__classPrivateFieldGet(this,r,"f").forEach(V=>V.response.dispose())}};l=new WeakMap,r=new WeakMap,R.requestIdPool=0,v.__decorate([(0,f.Autowired)(W.ILogger),v.__metadata("design:type",Object)],R.prototype,"logger",void 0),R=c=v.__decorate([(0,f.Injectable)({multiple:!0})],R),e.ChatModel=R;let A=h=class extends W.Disposable{get id(){return this._id}constructor(V,Y){super(),this.content=V,this.sampleQuestions=Y,this._id="welcome_"+h.nextId++}};A.nextId=0,A=h=v.__decorate([(0,f.Injectable)({multiple:!0}),v.__metadata("design:paramtypes",[Object,Array])],A),e.ChatWelcomeMessageModel=A;let w=class extends W.Disposable{constructor(V,Y,_){super(),this.chatCommand=V,this.command=Y,this.agentId=_}get name(){return this.chatCommand.name}get isShortcut(){return!!this.chatCommand.isShortcut}get icon(){return this.chatCommand.icon}get description(){return this.chatCommand.description}get tooltip(){return this.chatCommand.tooltip}get nameWithSlash(){return this.name.startsWith(Z.SLASH_SYMBOL)?this.name:`${Z.SLASH_SYMBOL} ${this.name}`}};w=v.__decorate([(0,f.Injectable)({multiple:!0}),v.__metadata("design:paramtypes",[Object,String,String])],w),e.ChatSlashCommandItemModel=w},51081:(L,e,t)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.ChatProxyService=void 0;const a=t(85608),o=t(76003),I=t(43718),g=t(9447),u=t(93062),G=t(19413),p=t(29770),m=t(11735);let b=n=class extends I.Disposable{constructor(){super(...arguments),this.chatDeferred=new I.Deferred}registerDefaultAgent(){this.addDispose(this.chatAgentService.registerAgent({id:n.AGENT_ID,metadata:{},invoke:async(s,l,r,c)=>{this.chatDeferred=new I.Deferred;const{message:h,command:v}=s;let f=h;if(v){const N=this.chatFeatureRegistry.getSlashCommandHandler(v);if(N&&N.providerPrompt){const Z=this.monacoCommandRegistry.getActiveCodeEditor();f=await N.providerPrompt(h,Z)}}const W=await this.aiBackService.requestStream(f,{requestId:s.requestId,history:this.aiChatService.getHistoryMessages()},c);return(0,u.listenReadable)(W,{onData:N=>{l(N)},onEnd:()=>{this.chatDeferred.resolve()},onError:N=>{this.aiReporter.end(s.sessionId+"_"+s.requestId,{message:N.message,success:!1})}}),await this.chatDeferred.promise,{}},provideSlashCommands:async s=>this.chatFeatureRegistry.getAllSlashCommand().map(l=>Object.assign(Object.assign({},l),{name:l.name,description:l.description||""})),provideChatWelcomeMessage:async s=>{}})),queueMicrotask(()=>{this.chatAgentService.updateAgent(n.AGENT_ID,{})})}};b.AGENT_ID="Default_Chat_Agent_"+(0,I.uuid)(6),a.__decorate([(0,o.Autowired)(G.IChatAgentService),a.__metadata("design:type",Object)],b.prototype,"chatAgentService",void 0),a.__decorate([(0,o.Autowired)(I.AIBackSerivcePath),a.__metadata("design:type",Object)],b.prototype,"aiBackService",void 0),a.__decorate([(0,o.Autowired)(I.ChatFeatureRegistryToken),a.__metadata("design:type",m.ChatFeatureRegistry)],b.prototype,"chatFeatureRegistry",void 0),a.__decorate([(0,o.Autowired)(g.MonacoCommandRegistry),a.__metadata("design:type",g.MonacoCommandRegistry)],b.prototype,"monacoCommandRegistry",void 0),a.__decorate([(0,o.Autowired)(I.ChatServiceToken),a.__metadata("design:type",p.ChatService)],b.prototype,"aiChatService",void 0),a.__decorate([(0,o.Autowired)(I.IAIReporter),a.__metadata("design:type",Object)],b.prototype,"aiReporter",void 0),b=n=a.__decorate([(0,o.Injectable)()],b),e.ChatProxyService=b},29770:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ChatService=void 0;const n=t(85608),a=t(76003),o=t(43718),I=t(63067),g=t(19413),u=t(44260);let G=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,this.addDispose(this.msgHistoryManager)}showChatView(){this.mainLayoutService.toggleSlot(g.AI_CHAT_VIEW_ID,!0)}sendMessage(m){this.showChatView(),this._onChatMessageLaunch.fire(m)}clearHistoryMessages(){this.msgHistoryManager.clearMessages()}sendReplyMessage(m){this._onChatReplyMessageLaunch.fire(m)}sendMessageList(m){this._onChatMessageListLaunch.fire(m)}getHistoryMessages(){return this.msgHistoryManager.getMessages()}scrollToBottom(){this._onScrollToBottom.fire()}};n.__decorate([(0,a.Autowired)(u.MsgHistoryManager),n.__metadata("design:type",u.MsgHistoryManager)],G.prototype,"msgHistoryManager",void 0),n.__decorate([(0,a.Autowired)(I.IMainLayoutService),n.__metadata("design:type",Object)],G.prototype,"mainLayoutService",void 0),G=n.__decorate([(0,a.Injectable)(),n.__metadata("design:paramtypes",[])],G),e.ChatService=G},11735:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ChatFeatureRegistry=void 0;const n=t(85608),a=t(76003),o=t(43718),I=t(19413),g=t(42033),u=t(51081);let G=class extends o.Disposable{constructor(){super(...arguments),this.logger=(0,o.getDebugLogger)(),this.slashCommandsMap=new Map,this.slashCommandsHandlerMap=new Map}dispose(){super.dispose(),this.slashCommandsMap.clear(),this.slashCommandsHandlerMap.clear()}registerWelcome(m,b){this.chatWelcomeMessageModel=new g.ChatWelcomeMessageModel(m,b)}registerSlashCommand(m,b){const{name:d}=m;if(this.slashCommandsMap.has(d)){this.logger.warn(`ChatFeatureRegistry: commands name ${d} already exists`);return}this.slashCommandsMap.set(d,new g.ChatSlashCommandItemModel(m,d,u.ChatProxyService.AGENT_ID)),this.slashCommandsHandlerMap.set(d,b)}getSlashCommandHandler(m){return this.slashCommandsHandlerMap.get(m)}getSlashCommand(m){return this.slashCommandsMap.get(m)}getSlashCommandHandlerBySlashName(m){const b=this.getAllSlashCommand().find(d=>d.nameWithSlash===m);if(b)return this.getSlashCommandHandler(b.name)}getSlashCommandBySlashName(m){const b=this.getAllSlashCommand().find(d=>d.nameWithSlash===m);if(b)return this.getSlashCommand(b.name)}getAllSlashCommand(){return Array.from(this.slashCommandsMap.values())}getAllShortcutSlashCommand(){return this.getAllSlashCommand().filter(m=>m.isShortcut===!0)}parseSlashCommand(m){if(m.startsWith(I.SLASH_SYMBOL)){const b=this.getAllSlashCommand();for(const d of b){const{nameWithSlash:s}=d;if(m.startsWith(s))return{value:m.slice(s.length),nameWithSlash:s}}}return{value:m,nameWithSlash:""}}};G=n.__decorate([(0,a.Injectable)()],G),e.ChatFeatureRegistry=G},59347:(L,e,t)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.ChatInternalService=void 0;const a=t(85608),o=t(76003),I=t(41869),g=t(43718),u=t(19413),G=t(61282);let p=class extends g.Disposable{get latestRequestId(){return this._latestRequestId}get sessionModel(){return a.__classPrivateFieldGet(this,n,"f")}constructor(){super(),this._onChangeRequestId=new g.Emitter,this.onChangeRequestId=this._onChangeRequestId.event,n.set(this,void 0),a.__classPrivateFieldSet(this,n,this.chatManagerService.startSession(),"f")}setLatestRequestId(b){this._latestRequestId=b,this._onChangeRequestId.fire(b)}createRequest(b,d,s){return this.chatManagerService.createRequest(a.__classPrivateFieldGet(this,n,"f").sessionId,b,d,s)}sendRequest(b,d=!1){return this.chatManagerService.sendRequest(a.__classPrivateFieldGet(this,n,"f").sessionId,b,d)}cancelRequest(){this.chatManagerService.cancelRequest(a.__classPrivateFieldGet(this,n,"f").sessionId)}clearSessionModel(){this.chatManagerService.clearSession(a.__classPrivateFieldGet(this,n,"f").sessionId),a.__classPrivateFieldSet(this,n,this.chatManagerService.startSession(),"f")}dispose(){var b;(b=a.__classPrivateFieldGet(this,n,"f"))===null||b===void 0||b.dispose(),super.dispose()}};n=new WeakMap,a.__decorate([(0,o.Autowired)(g.AIBackSerivcePath),a.__metadata("design:type",Object)],p.prototype,"aiBackService",void 0),a.__decorate([(0,o.Autowired)(I.PreferenceService),a.__metadata("design:type",Object)],p.prototype,"preferenceService",void 0),a.__decorate([(0,o.Autowired)(u.IChatManagerService),a.__metadata("design:type",G.ChatManagerService)],p.prototype,"chatManagerService",void 0),p=a.__decorate([(0,o.Injectable)(),a.__metadata("design:paramtypes",[])],p),e.ChatInternalService=p},70394:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ChatRenderRegistry=void 0;const n=t(85608),a=t(76003),o=t(43718);let I=class extends o.Disposable{registerWelcomeRender(u){this.chatWelcomeRender=u}registerAIRoleRender(u){this.chatAIRoleRender=u}registerUserRoleRender(u){this.chatUserRoleRender=u}registerThinkingRender(u){this.chatThinkingRender=u}registerInputRender(u){this.chatInputRender=u}registerThinkingResultRender(u){this.chatThinkingResultRender=u}};I=n.__decorate([(0,a.Injectable)()],I),e.ChatRenderRegistry=I},76154:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AIChatView=void 0;const n=t(85608),a=t(25150),o=n.__importStar(t(14041)),I=t(68392),g=t(41869),u=t(81878),G=t(89195),p=t(43718),m=t(63067);t(41937);const b=t(19413),d=t(25834),s=t(57987),l=t(56474),r=t(92635),c=t(29039),h=t(78048),v=t(86556),f=t(44260),W=t(51081),N=n.__importDefault(t(77256)),Z="chat_scroll";e.AIChatView=(0,a.observer)(()=>{const y=(0,g.useInjectable)(b.IChatInternalService),E=(0,g.useInjectable)(p.ChatServiceToken),R=(0,g.useInjectable)(p.IAIReporter),A=(0,g.useInjectable)(b.IChatAgentService),w=(0,g.useInjectable)(p.ChatFeatureRegistryToken),F=(0,g.useInjectable)(p.ChatRenderRegistryToken),V=(0,g.useInjectable)(m.IMainLayoutService),Y=(0,g.useInjectable)(f.MsgHistoryManager),_=o.useRef(null),H=o.useRef(null),[S,X]=o.useReducer((ue,q)=>{switch(q.type){case"add":return[...ue,...q.payload||[]];case"clear":return[];case"init":return Array.isArray(q.payload)?q.payload:[];default:return ue}},[]),[Q,O]=o.useState(!1),[M,T]=o.useState(""),[x,B]=o.useState(""),[D,J]=o.useState(""),[k,z]=o.useState(null),P=o.useMemo(()=>(0,p.localize)("aiNative.chat.ai.assistant.name"),[]),U=o.useMemo(()=>w.getAllShortcutSlashCommand(),[w]),re=o.useMemo(()=>F.chatInputRender?F.chatInputRender:s.ChatInput,[F.chatInputRender]),se=o.useMemo(()=>(0,h.createMessageByAI)({id:(0,p.uuid)(6),relationId:"",text:o.createElement(v.WelcomeMessage,null)}),[]),ae=o.useCallback(()=>{_&&_.current&&(_.current.scrollTop=Number.MAX_SAFE_INTEGER,_.current.scrollHeight>_.current.clientHeight&&_.current.classList.add(Z))},[_]),me=o.useCallback(ue=>{X(ue),requestAnimationFrame(()=>{ae()})},[X,ae]);o.useEffect(()=>{me({type:"init",payload:[se]})},[]),o.useEffect(()=>{ae()},[Q]),o.useEffect(()=>{const ue=new p.Disposable;return ue.addDispose(E.onScrollToBottom(()=>{requestAnimationFrame(()=>{ae()})})),ue.addDispose(E.onChatMessageLaunch(async q=>{var j;if(q.immediate!==!1){if(Q)return;await ge(q)}else q.agentId&&T(q.agentId),q.command&&J(q.command),(j=H?.current)===null||j===void 0||j.setInputValue(q.message)})),ue.addDispose(E.onChatReplyMessageLaunch(q=>{const j=R.start(p.AISerivceType.CustomReplay,{msgType:p.AISerivceType.CustomReplay,message:q});let ie=o.createElement(l.ChatMarkdown,{markdown:q,fillInIncompleteTokens:!0});if(F.chatAIRoleRender){const de=F.chatAIRoleRender;ie=o.createElement(de,{content:q})}Y.addAssistantMessage({content:q});const ne=(0,h.createMessageByAI)({id:(0,p.uuid)(6),relationId:j,text:ie,className:N.default.chat_with_more_actions});me({type:"add",payload:[ne]})})),ue.addDispose(E.onChatMessageListLaunch(q=>{const j=[];q.forEach(ie=>{const{role:ne}=ie,de=R.start(p.AISerivceType.Agent,{msgType:p.AISerivceType.Agent,message:""});if(ne==="assistant"){const Ie=ie;j.push((0,h.createMessageByAI)({id:(0,p.uuid)(6),relationId:de,text:o.createElement(r.ChatNotify,{requestId:de,chunk:Ie})},N.default.chat_notify))}if(ne==="user"){const{message:Ie,command:Ge}=ie,te=ie.agentId?ie.agentId:W.ChatProxyService.AGENT_ID,he=F.chatUserRoleRender,ve=te===W.ChatProxyService.AGENT_ID?"":te;j.push((0,h.createMessageByUser)({id:(0,p.uuid)(6),relationId:de,text:he?o.createElement(he,{content:Ie,agentId:ve,command:Ge}):o.createElement(d.CodeBlockWrapperInput,{relationId:de,text:Ie,agentId:ve,command:Ge})},N.default.chat_message_code))}}),console.log(`messageList: ${j}`),me({type:"add",payload:j}),setTimeout(ae,0)})),()=>ue.dispose()},[E,F.chatAIRoleRender,Y,ae]),o.useEffect(()=>{const ue=new p.Disposable;return ue.addDispose(A.onDidSendMessage(q=>{const j=q,ie=R.start(p.AISerivceType.Agent,{msgType:p.AISerivceType.Agent,message:""}),ne=(0,h.createMessageByAI)({id:(0,p.uuid)(6),relationId:ie,text:o.createElement(r.ChatNotify,{requestId:y.latestRequestId,chunk:j})},N.default.chat_notify);me({type:"add",payload:[ne]})})),ue.addDispose(A.onDidChangeAgents(async()=>{const q=A.getDefaultAgentId();B(q??"")})),()=>ue.dispose()},[A,Y,y]);const ee=o.useCallback(async ue=>{const{userMessage:q,relationId:j,requestId:ie,render:ne,startTime:de}=ue;Y.addAssistantMessage({type:"component",content:""});const Ie=(0,h.createMessageByAI)({id:(0,p.uuid)(6),relationId:j,className:N.default.chat_with_more_actions,text:o.createElement(c.SlashCustomRender,{userMessage:q,startTime:de,relationId:j,requestId:ie,renderContent:ne})});me({type:"add",payload:[Ie]})},[_,Y]),pe=o.useCallback(async ue=>{const{message:q,agentId:j,command:ie}=ue,ne=y.createRequest(q,j,ie);if(!ne)return;O(!0),y.setLatestRequestId(ne.requestId);const de=F.chatUserRoleRender,Ie=Date.now(),Ge=R.start(p.AISerivceType.Agent,{msgType:p.AISerivceType.Agent,message:ue.message});Y.addUserMessage({content:q,agentId:j,agentCommand:ie});const te=j===W.ChatProxyService.AGENT_ID?"":j,he=(0,h.createMessageByUser)({id:(0,p.uuid)(6),relationId:Ge,text:de?o.createElement(de,{content:q,agentId:te,command:ie}):o.createElement(d.CodeBlockWrapperInput,{relationId:Ge,text:q,agentId:te,command:ie})},N.default.chat_message_code);if(me({type:"add",payload:[he]}),j===W.ChatProxyService.AGENT_ID&&ie){const We=w.getSlashCommandHandler(ie);if(We&&We.providerRender)return O(!1),ee({userMessage:q,render:We.providerRender,relationId:Ge,requestId:ne.requestId,startTime:Ie})}const ve=(0,h.createMessageByAI)({id:(0,p.uuid)(6),relationId:Ge,className:N.default.chat_with_more_actions,text:o.createElement(r.ChatReply,{relationId:Ge,request:ne,startTime:Ie,onDidChange:()=>{ae()},onDone:()=>{O(!1)},onRegenerate:()=>{y.sendRequest(ne,!0)}})});y.sendRequest(ne),me({type:"add",payload:[ve]})},[F,F.chatUserRoleRender,Y,ae]),ge=o.useCallback(async ue=>{const{message:q,command:j}=ue,ie=ue.agentId?ue.agentId:W.ChatProxyService.AGENT_ID;return pe({message:q,agentId:ie,command:j})},[]),$=o.useCallback(()=>{var ue;y.clearSessionModel(),E.clearHistoryMessages(),(ue=_?.current)===null||ue===void 0||ue.classList.remove(Z),me({type:"init",payload:[se]})},[S]),le=ue=>{Q||(z(ue.nameWithSlash),T(ue.agentId),J(ue.command))},oe=o.useCallback(()=>{V.toggleSlot(b.AI_CHAT_VIEW_ID)},[V]);return o.createElement("div",{id:N.default.ai_chat_view},o.createElement("div",{className:N.default.header_container},o.createElement("div",{className:N.default.left},o.createElement("span",{className:N.default.title},P)),o.createElement("div",{className:N.default.right},o.createElement(u.Popover,{overlayClassName:N.default.popover_icon,id:"ai-chat-header-clear",title:(0,p.localize)("aiNative.operate.clear.title")},o.createElement(G.EnhanceIcon,{wrapperClassName:N.default.action_btn,className:(0,g.getIcon)("clear"),onClick:$})),o.createElement(u.Popover,{overlayClassName:N.default.popover_icon,id:"ai-chat-header-close",position:u.PopoverPosition.left,title:(0,p.localize)("aiNative.operate.close.title")},o.createElement(G.EnhanceIcon,{wrapperClassName:N.default.action_btn,className:(0,g.getIcon)("window-close"),onClick:oe})))),o.createElement("div",{className:N.default.body_container},o.createElement("div",{className:N.default.left_bar,id:"ai_chat_left_container"},o.createElement("div",{className:N.default.chat_container,ref:_},o.createElement(I.MessageList,{className:N.default.message_list,lockable:!0,toBottomHeight:"100%",dataSource:S})),o.createElement("div",{className:N.default.chat_input_wrap},o.createElement("div",{className:N.default.header_operate},o.createElement("div",{className:N.default.header_operate_left},U.map(ue=>o.createElement(u.Popover,{id:`ai-chat-shortcut-${ue.name}`,key:`ai-chat-shortcut-${ue.name}`,title:ue.tooltip||ue.name},o.createElement("div",{className:N.default.tag,onClick:()=>le(ue)},ue.name)))),o.createElement("div",{className:N.default.header_operate_right})),o.createElement(re,{onSend:(ue,q,j)=>ge({message:ue,agentId:q,command:j}),disabled:Q,enableOptions:!0,theme:k,setTheme:z,agentId:M,setAgentId:T,defaultAgentId:x,command:D,setCommand:J,ref:H})))))})},25834:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CodeBlockWrapperInput=e.CodeBlockWrapper=e.CodeEditorWithHighlight=void 0;const n=t(85608),a=n.__importDefault(t(56005)),o=n.__importStar(t(14041)),I=n.__importDefault(t(10580)),g=t(41869),u=t(81878),G=t(89195),p=t(43718),m=t(71624),b=t(9447),d=t(52416),s=n.__importDefault(t(6960)),l=t(83933);t(38191);const r=({input:f,language:W,relationId:N})=>{const Z=o.default.useRef(null),y=(0,g.useInjectable)(b.MonacoCommandRegistry),E=(0,g.useInjectable)(g.IClipboardService),R=(0,g.useInjectable)(d.IThemeService),A=(0,g.useInjectable)(p.IAIReporter),[w,F]=(0,o.useState)(!1),V=(0,o.useMemo)(()=>(0,g.uuid)(12),[Z,Z.current]);(0,o.useEffect)(()=>{const H=Q=>{Q.type==="dark"||Q.type==="hcDark"?t.e(622).then(t.bind(t,51622)):(Q.type==="light"||Q.type==="hcLight")&&t.e(412).then(t.bind(t,50412))},S=R.onThemeChange(Q=>{H(Q)}),X=R.getCurrentThemeSync();return H(X),()=>S.dispose()},[]);const Y=(0,o.useCallback)(async()=>{F(!0),await E.writeText(f),A.end(N,{copy:!0}),(0,p.runWhenIdle)(()=>{F(!1)},1e3)},[E,f,N]),_=(0,o.useCallback)(()=>{const H=y.getActiveCodeEditor();if(H){const S=H.getSelection();S&&((0,m.insertSnippetWithMonacoEditor)(H,f,[S],{undoStopBefore:!1,undoStopAfter:!1}),A.end(N,{insert:!0}))}},[y]);return o.default.createElement("div",{className:s.default.monaco_wrapper},o.default.createElement("div",{className:s.default.action_toolbar},o.default.createElement(u.Popover,{id:`ai-chat-inser-${V}`,title:(0,p.localize)("aiNative.chat.code.insert")},o.default.createElement(G.EnhanceIcon,{className:(0,g.getIcon)("insert"),onClick:()=>_()})),o.default.createElement(u.Popover,{id:`ai-chat-copy-${V}`,title:(0,p.localize)(w?"aiNative.chat.code.copy.success":"aiNative.chat.code.copy")},o.default.createElement(G.EnhanceIcon,{className:(0,g.getIcon)("copy"),onClick:()=>Y()}))),o.default.createElement(I.default,{language:W,ref:Z,className:s.default.editor},f))};e.CodeEditorWithHighlight=r;const c=({content:f="",relationId:W,renderText:N})=>{const Z=/`([^`]+)`/g,y=/```([^]+?)```/g,E=/```([^]+)?/g,R=w=>{const F=w.split(`
|
|
27282
|
+
`),"f");const Y=[];for(const _ of v.__classPrivateFieldGet(this,a,"f")){const H=Y[Y.length-1];_.kind==="markdownContent"&&H?.kind==="markdownContent"?Y[Y.length-1]={content:new N.MarkdownString(H.content.value+_.content.value,{isTrusted:H.content.isTrusted}),kind:"markdownContent"}:Y.push(_)}v.__classPrivateFieldSet(this,o,Y,"f"),V||v.__classPrivateFieldGet(this,b,"f").fire()},y=v.__decorate([(0,f.Injectable)({multiple:!0}),v.__metadata("design:paramtypes",[String,Object,String])],y),e.ChatResponseModel=y;let E=class{get requestId(){return v.__classPrivateFieldGet(this,s,"f")}constructor(V,Y,_,H){this.session=Y,this.message=_,this.response=H,s.set(this,void 0),v.__classPrivateFieldSet(this,s,V,"f")}};s=new WeakMap,E=v.__decorate([(0,f.Injectable)({multiple:!0}),v.__metadata("design:paramtypes",[String,Object,Object,y])],E),e.ChatRequestModel=E;let R=c=class extends W.Disposable{constructor(){super(...arguments),l.set(this,(0,W.uuid)()),r.set(this,new Map)}get sessionId(){return v.__classPrivateFieldGet(this,l,"f")}get requests(){return Array.from(v.__classPrivateFieldGet(this,r,"f").values())}addRequest(V){const Y=`${this.sessionId}_request_${c.requestIdPool++}`,_=new y(Y,this,V.agentId),H=new E(Y,this,V,_);return v.__classPrivateFieldGet(this,r,"f").set(Y,H),H}acceptResponseProgress(V,Y,_){if(V.response.isComplete)throw new Error("acceptResponseProgress: Adding progress to a completed response");const{kind:H}=Y;["content","markdownContent","asyncContent","treeData","component"].includes(H)?V.response.updateContent(Y,_):this.logger.error(`Couldn't handle progress: ${JSON.stringify(Y)}`)}getRequest(V){return v.__classPrivateFieldGet(this,r,"f").get(V)}dispose(){super.dispose(),v.__classPrivateFieldGet(this,r,"f").forEach(V=>V.response.dispose())}};l=new WeakMap,r=new WeakMap,R.requestIdPool=0,v.__decorate([(0,f.Autowired)(W.ILogger),v.__metadata("design:type",Object)],R.prototype,"logger",void 0),R=c=v.__decorate([(0,f.Injectable)({multiple:!0})],R),e.ChatModel=R;let A=h=class extends W.Disposable{get id(){return this._id}constructor(V,Y){super(),this.content=V,this.sampleQuestions=Y,this._id="welcome_"+h.nextId++}};A.nextId=0,A=h=v.__decorate([(0,f.Injectable)({multiple:!0}),v.__metadata("design:paramtypes",[Object,Array])],A),e.ChatWelcomeMessageModel=A;let w=class extends W.Disposable{constructor(V,Y,_){super(),this.chatCommand=V,this.command=Y,this.agentId=_}get name(){return this.chatCommand.name}get isShortcut(){return!!this.chatCommand.isShortcut}get icon(){return this.chatCommand.icon}get description(){return this.chatCommand.description}get tooltip(){return this.chatCommand.tooltip}get nameWithSlash(){return this.name.startsWith(Z.SLASH_SYMBOL)?this.name:`${Z.SLASH_SYMBOL} ${this.name}`}};w=v.__decorate([(0,f.Injectable)({multiple:!0}),v.__metadata("design:paramtypes",[Object,String,String])],w),e.ChatSlashCommandItemModel=w},51081:(L,e,t)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.ChatProxyService=void 0;const a=t(85608),o=t(76003),I=t(43718),g=t(9447),u=t(93062),G=t(19413),p=t(29770),m=t(11735);let b=n=class extends I.Disposable{constructor(){super(...arguments),this.chatDeferred=new I.Deferred}registerDefaultAgent(){this.addDispose(this.chatAgentService.registerAgent({id:n.AGENT_ID,metadata:{},invoke:async(s,l,r,c)=>{this.chatDeferred=new I.Deferred;const{message:h,command:v}=s;let f=h;if(v){const N=this.chatFeatureRegistry.getSlashCommandHandler(v);if(N&&N.providerPrompt){const Z=this.monacoCommandRegistry.getActiveCodeEditor();f=await N.providerPrompt(h,Z)}}const W=await this.aiBackService.requestStream(f,{requestId:s.requestId,history:this.aiChatService.getHistoryMessages()},c);return(0,u.listenReadable)(W,{onData:N=>{l(N)},onEnd:()=>{this.chatDeferred.resolve()},onError:N=>{this.aiReporter.end(s.sessionId+"_"+s.requestId,{message:N.message,success:!1})}}),await this.chatDeferred.promise,{}},provideSlashCommands:async s=>this.chatFeatureRegistry.getAllSlashCommand().map(l=>Object.assign(Object.assign({},l),{name:l.name,description:l.description||""})),provideChatWelcomeMessage:async s=>{}})),queueMicrotask(()=>{this.chatAgentService.updateAgent(n.AGENT_ID,{})})}};b.AGENT_ID="Default_Chat_Agent_"+(0,I.uuid)(6),a.__decorate([(0,o.Autowired)(G.IChatAgentService),a.__metadata("design:type",Object)],b.prototype,"chatAgentService",void 0),a.__decorate([(0,o.Autowired)(I.AIBackSerivcePath),a.__metadata("design:type",Object)],b.prototype,"aiBackService",void 0),a.__decorate([(0,o.Autowired)(I.ChatFeatureRegistryToken),a.__metadata("design:type",m.ChatFeatureRegistry)],b.prototype,"chatFeatureRegistry",void 0),a.__decorate([(0,o.Autowired)(g.MonacoCommandRegistry),a.__metadata("design:type",g.MonacoCommandRegistry)],b.prototype,"monacoCommandRegistry",void 0),a.__decorate([(0,o.Autowired)(I.ChatServiceToken),a.__metadata("design:type",p.ChatService)],b.prototype,"aiChatService",void 0),a.__decorate([(0,o.Autowired)(I.IAIReporter),a.__metadata("design:type",Object)],b.prototype,"aiReporter",void 0),b=n=a.__decorate([(0,o.Injectable)()],b),e.ChatProxyService=b},29770:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ChatService=void 0;const n=t(85608),a=t(76003),o=t(43718),I=t(63067),g=t(19413),u=t(44260);let G=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,this.addDispose(this.msgHistoryManager)}showChatView(){this.mainLayoutService.toggleSlot(g.AI_CHAT_VIEW_ID,!0)}sendMessage(m){this.showChatView(),this._onChatMessageLaunch.fire(m)}clearHistoryMessages(){this.msgHistoryManager.clearMessages()}sendReplyMessage(m){this._onChatReplyMessageLaunch.fire(m)}sendMessageList(m){this._onChatMessageListLaunch.fire(m)}getHistoryMessages(){return this.msgHistoryManager.getMessages()}scrollToBottom(){this._onScrollToBottom.fire()}};n.__decorate([(0,a.Autowired)(u.MsgHistoryManager),n.__metadata("design:type",u.MsgHistoryManager)],G.prototype,"msgHistoryManager",void 0),n.__decorate([(0,a.Autowired)(I.IMainLayoutService),n.__metadata("design:type",Object)],G.prototype,"mainLayoutService",void 0),G=n.__decorate([(0,a.Injectable)(),n.__metadata("design:paramtypes",[])],G),e.ChatService=G},11735:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ChatFeatureRegistry=void 0;const n=t(85608),a=t(76003),o=t(43718),I=t(19413),g=t(42033),u=t(51081);let G=class extends o.Disposable{constructor(){super(...arguments),this.logger=(0,o.getDebugLogger)(),this.slashCommandsMap=new Map,this.slashCommandsHandlerMap=new Map}dispose(){super.dispose(),this.slashCommandsMap.clear(),this.slashCommandsHandlerMap.clear()}registerWelcome(m,b){this.chatWelcomeMessageModel=new g.ChatWelcomeMessageModel(m,b)}registerSlashCommand(m,b){const{name:d}=m;if(this.slashCommandsMap.has(d)){this.logger.warn(`ChatFeatureRegistry: commands name ${d} already exists`);return}this.slashCommandsMap.set(d,new g.ChatSlashCommandItemModel(m,d,u.ChatProxyService.AGENT_ID)),this.slashCommandsHandlerMap.set(d,b)}getSlashCommandHandler(m){return this.slashCommandsHandlerMap.get(m)}getSlashCommand(m){return this.slashCommandsMap.get(m)}getSlashCommandHandlerBySlashName(m){const b=this.getAllSlashCommand().find(d=>d.nameWithSlash===m);if(b)return this.getSlashCommandHandler(b.name)}getSlashCommandBySlashName(m){const b=this.getAllSlashCommand().find(d=>d.nameWithSlash===m);if(b)return this.getSlashCommand(b.name)}getAllSlashCommand(){return Array.from(this.slashCommandsMap.values())}getAllShortcutSlashCommand(){return this.getAllSlashCommand().filter(m=>m.isShortcut===!0)}parseSlashCommand(m){if(m.startsWith(I.SLASH_SYMBOL)){const b=this.getAllSlashCommand();for(const d of b){const{nameWithSlash:s}=d;if(m.startsWith(s))return{value:m.slice(s.length),nameWithSlash:s}}}return{value:m,nameWithSlash:""}}};G=n.__decorate([(0,a.Injectable)()],G),e.ChatFeatureRegistry=G},59347:(L,e,t)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.ChatInternalService=void 0;const a=t(85608),o=t(76003),I=t(41869),g=t(43718),u=t(19413),G=t(61282);let p=class extends g.Disposable{get latestRequestId(){return this._latestRequestId}get sessionModel(){return a.__classPrivateFieldGet(this,n,"f")}constructor(){super(),this._onChangeRequestId=new g.Emitter,this.onChangeRequestId=this._onChangeRequestId.event,n.set(this,void 0),a.__classPrivateFieldSet(this,n,this.chatManagerService.startSession(),"f")}setLatestRequestId(b){this._latestRequestId=b,this._onChangeRequestId.fire(b)}createRequest(b,d,s){return this.chatManagerService.createRequest(a.__classPrivateFieldGet(this,n,"f").sessionId,b,d,s)}sendRequest(b,d=!1){return this.chatManagerService.sendRequest(a.__classPrivateFieldGet(this,n,"f").sessionId,b,d)}cancelRequest(){this.chatManagerService.cancelRequest(a.__classPrivateFieldGet(this,n,"f").sessionId)}clearSessionModel(){this.chatManagerService.clearSession(a.__classPrivateFieldGet(this,n,"f").sessionId),a.__classPrivateFieldSet(this,n,this.chatManagerService.startSession(),"f")}dispose(){var b;(b=a.__classPrivateFieldGet(this,n,"f"))===null||b===void 0||b.dispose(),super.dispose()}};n=new WeakMap,a.__decorate([(0,o.Autowired)(g.AIBackSerivcePath),a.__metadata("design:type",Object)],p.prototype,"aiBackService",void 0),a.__decorate([(0,o.Autowired)(I.PreferenceService),a.__metadata("design:type",Object)],p.prototype,"preferenceService",void 0),a.__decorate([(0,o.Autowired)(u.IChatManagerService),a.__metadata("design:type",G.ChatManagerService)],p.prototype,"chatManagerService",void 0),p=a.__decorate([(0,o.Injectable)(),a.__metadata("design:paramtypes",[])],p),e.ChatInternalService=p},70394:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ChatRenderRegistry=void 0;const n=t(85608),a=t(76003),o=t(43718);let I=class extends o.Disposable{registerWelcomeRender(u){this.chatWelcomeRender=u}registerAIRoleRender(u){this.chatAIRoleRender=u}registerUserRoleRender(u){this.chatUserRoleRender=u}registerThinkingRender(u){this.chatThinkingRender=u}registerInputRender(u){this.chatInputRender=u}registerThinkingResultRender(u){this.chatThinkingResultRender=u}};I=n.__decorate([(0,a.Injectable)()],I),e.ChatRenderRegistry=I},76154:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AIChatView=void 0;const n=t(85608),a=t(25150),o=n.__importStar(t(14041)),I=t(68392),g=t(41869),u=t(81878),G=t(89195),p=t(43718),m=t(63067);t(41937);const b=t(19413),d=t(25834),s=t(57987),l=t(56474),r=t(92635),c=t(29039),h=t(78048),v=t(86556),f=t(44260),W=t(51081),N=n.__importDefault(t(77256)),Z="chat_scroll";e.AIChatView=(0,a.observer)(()=>{const y=(0,g.useInjectable)(b.IChatInternalService),E=(0,g.useInjectable)(p.ChatServiceToken),R=(0,g.useInjectable)(p.IAIReporter),A=(0,g.useInjectable)(b.IChatAgentService),w=(0,g.useInjectable)(p.ChatFeatureRegistryToken),F=(0,g.useInjectable)(p.ChatRenderRegistryToken),V=(0,g.useInjectable)(m.IMainLayoutService),Y=(0,g.useInjectable)(f.MsgHistoryManager),_=o.useRef(null),H=o.useRef(null),[S,X]=o.useReducer((ue,q)=>{switch(q.type){case"add":return[...ue,...q.payload||[]];case"clear":return[];case"init":return Array.isArray(q.payload)?q.payload:[];default:return ue}},[]),[Q,O]=o.useState(!1),[M,T]=o.useState(""),[x,B]=o.useState(""),[D,J]=o.useState(""),[k,z]=o.useState(null),P=o.useMemo(()=>(0,p.localize)("aiNative.chat.ai.assistant.name"),[]),U=o.useMemo(()=>w.getAllShortcutSlashCommand(),[w]),re=o.useMemo(()=>F.chatInputRender?F.chatInputRender:s.ChatInput,[F.chatInputRender]),se=o.useMemo(()=>(0,h.createMessageByAI)({id:(0,p.uuid)(6),relationId:"",text:o.createElement(v.WelcomeMessage,null)}),[]),ae=o.useCallback(()=>{_&&_.current&&(_.current.scrollTop=Number.MAX_SAFE_INTEGER,_.current.scrollHeight>_.current.clientHeight&&_.current.classList.add(Z))},[_]),me=o.useCallback(ue=>{X(ue),requestAnimationFrame(()=>{ae()})},[X,ae]);o.useEffect(()=>{me({type:"init",payload:[se]})},[]),o.useEffect(()=>{ae()},[Q]),o.useEffect(()=>{const ue=new p.Disposable;return ue.addDispose(E.onScrollToBottom(()=>{requestAnimationFrame(()=>{ae()})})),ue.addDispose(E.onChatMessageLaunch(async q=>{var j;if(q.immediate!==!1){if(Q)return;await ge(q)}else q.agentId&&T(q.agentId),q.command&&J(q.command),(j=H?.current)===null||j===void 0||j.setInputValue(q.message)})),ue.addDispose(E.onChatReplyMessageLaunch(q=>{const j=R.start(p.AISerivceType.CustomReplay,{msgType:p.AISerivceType.CustomReplay,message:q});let ie=o.createElement(l.ChatMarkdown,{markdown:q,fillInIncompleteTokens:!0});if(F.chatAIRoleRender){const de=F.chatAIRoleRender;ie=o.createElement(de,{content:q})}Y.addAssistantMessage({content:q});const ne=(0,h.createMessageByAI)({id:(0,p.uuid)(6),relationId:j,text:ie,className:N.default.chat_with_more_actions});me({type:"add",payload:[ne]})})),ue.addDispose(E.onChatMessageListLaunch(q=>{const j=[];q.forEach(ie=>{const{role:ne}=ie,de=R.start(p.AISerivceType.Agent,{msgType:p.AISerivceType.Agent,message:""});if(ne==="assistant"){const Ie=ie;j.push((0,h.createMessageByAI)({id:(0,p.uuid)(6),relationId:de,text:o.createElement(r.ChatNotify,{requestId:de,chunk:Ie})},N.default.chat_notify))}if(ne==="user"){const{message:Ie}=ie,Ge=W.ChatProxyService.AGENT_ID,te=F.chatUserRoleRender,he=Ge===W.ChatProxyService.AGENT_ID?"":Ge;j.push((0,h.createMessageByUser)({id:(0,p.uuid)(6),relationId:de,text:te?o.createElement(te,{content:Ie,agentId:he}):o.createElement(d.CodeBlockWrapperInput,{relationId:de,text:Ie,agentId:he,command:D})},N.default.chat_message_code))}}),me({type:"add",payload:j}),setTimeout(ae,0)})),()=>ue.dispose()},[E,F.chatAIRoleRender,Y]),o.useEffect(()=>{const ue=new p.Disposable;return ue.addDispose(A.onDidSendMessage(q=>{const j=q,ie=R.start(p.AISerivceType.Agent,{msgType:p.AISerivceType.Agent,message:""}),ne=(0,h.createMessageByAI)({id:(0,p.uuid)(6),relationId:ie,text:o.createElement(r.ChatNotify,{requestId:y.latestRequestId,chunk:j})},N.default.chat_notify);me({type:"add",payload:[ne]})})),ue.addDispose(A.onDidChangeAgents(async()=>{const q=A.getDefaultAgentId();B(q??"")})),()=>ue.dispose()},[A,Y,y]);const ee=o.useCallback(async ue=>{const{userMessage:q,relationId:j,requestId:ie,render:ne,startTime:de}=ue;Y.addAssistantMessage({type:"component",content:""});const Ie=(0,h.createMessageByAI)({id:(0,p.uuid)(6),relationId:j,className:N.default.chat_with_more_actions,text:o.createElement(c.SlashCustomRender,{userMessage:q,startTime:de,relationId:j,requestId:ie,renderContent:ne})});me({type:"add",payload:[Ie]})},[_,Y]),pe=o.useCallback(async ue=>{const{message:q,agentId:j,command:ie}=ue,ne=y.createRequest(q,j,ie);if(!ne)return;O(!0),y.setLatestRequestId(ne.requestId);const de=F.chatUserRoleRender,Ie=Date.now(),Ge=R.start(p.AISerivceType.Agent,{msgType:p.AISerivceType.Agent,message:ue.message});Y.addUserMessage({content:q,agentId:j,agentCommand:ie});const te=j===W.ChatProxyService.AGENT_ID?"":j,he=(0,h.createMessageByUser)({id:(0,p.uuid)(6),relationId:Ge,text:de?o.createElement(de,{content:q,agentId:te,command:ie}):o.createElement(d.CodeBlockWrapperInput,{relationId:Ge,text:q,agentId:te,command:ie})},N.default.chat_message_code);if(me({type:"add",payload:[he]}),j===W.ChatProxyService.AGENT_ID&&ie){const We=w.getSlashCommandHandler(ie);if(We&&We.providerRender)return O(!1),ee({userMessage:q,render:We.providerRender,relationId:Ge,requestId:ne.requestId,startTime:Ie})}const ve=(0,h.createMessageByAI)({id:(0,p.uuid)(6),relationId:Ge,className:N.default.chat_with_more_actions,text:o.createElement(r.ChatReply,{relationId:Ge,request:ne,startTime:Ie,onDidChange:()=>{ae()},onDone:()=>{O(!1)},onRegenerate:()=>{y.sendRequest(ne,!0)}})});y.sendRequest(ne),me({type:"add",payload:[ve]})},[F,F.chatUserRoleRender,Y,ae]),ge=o.useCallback(async ue=>{const{message:q,command:j}=ue,ie=ue.agentId?ue.agentId:W.ChatProxyService.AGENT_ID;return pe({message:q,agentId:ie,command:j})},[]),$=o.useCallback(()=>{var ue;y.clearSessionModel(),E.clearHistoryMessages(),(ue=_?.current)===null||ue===void 0||ue.classList.remove(Z),me({type:"init",payload:[se]})},[S]),le=ue=>{Q||(z(ue.nameWithSlash),T(ue.agentId),J(ue.command))},oe=o.useCallback(()=>{V.toggleSlot(b.AI_CHAT_VIEW_ID)},[V]);return o.createElement("div",{id:N.default.ai_chat_view},o.createElement("div",{className:N.default.header_container},o.createElement("div",{className:N.default.left},o.createElement("span",{className:N.default.title},P)),o.createElement("div",{className:N.default.right},o.createElement(u.Popover,{overlayClassName:N.default.popover_icon,id:"ai-chat-header-clear",title:(0,p.localize)("aiNative.operate.clear.title")},o.createElement(G.EnhanceIcon,{wrapperClassName:N.default.action_btn,className:(0,g.getIcon)("clear"),onClick:$})),o.createElement(u.Popover,{overlayClassName:N.default.popover_icon,id:"ai-chat-header-close",position:u.PopoverPosition.left,title:(0,p.localize)("aiNative.operate.close.title")},o.createElement(G.EnhanceIcon,{wrapperClassName:N.default.action_btn,className:(0,g.getIcon)("window-close"),onClick:oe})))),o.createElement("div",{className:N.default.body_container},o.createElement("div",{className:N.default.left_bar,id:"ai_chat_left_container"},o.createElement("div",{className:N.default.chat_container,ref:_},o.createElement(I.MessageList,{className:N.default.message_list,lockable:!0,toBottomHeight:"100%",dataSource:S})),o.createElement("div",{className:N.default.chat_input_wrap},o.createElement("div",{className:N.default.header_operate},o.createElement("div",{className:N.default.header_operate_left},U.map(ue=>o.createElement(u.Popover,{id:`ai-chat-shortcut-${ue.name}`,key:`ai-chat-shortcut-${ue.name}`,title:ue.tooltip||ue.name},o.createElement("div",{className:N.default.tag,onClick:()=>le(ue)},ue.name)))),o.createElement("div",{className:N.default.header_operate_right})),o.createElement(re,{onSend:(ue,q,j)=>ge({message:ue,agentId:q,command:j}),disabled:Q,enableOptions:!0,theme:k,setTheme:z,agentId:M,setAgentId:T,defaultAgentId:x,command:D,setCommand:J,ref:H})))))})},25834:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CodeBlockWrapperInput=e.CodeBlockWrapper=e.CodeEditorWithHighlight=void 0;const n=t(85608),a=n.__importDefault(t(56005)),o=n.__importStar(t(14041)),I=n.__importDefault(t(10580)),g=t(41869),u=t(81878),G=t(89195),p=t(43718),m=t(71624),b=t(9447),d=t(52416),s=n.__importDefault(t(6960)),l=t(83933);t(38191);const r=({input:f,language:W,relationId:N})=>{const Z=o.default.useRef(null),y=(0,g.useInjectable)(b.MonacoCommandRegistry),E=(0,g.useInjectable)(g.IClipboardService),R=(0,g.useInjectable)(d.IThemeService),A=(0,g.useInjectable)(p.IAIReporter),[w,F]=(0,o.useState)(!1),V=(0,o.useMemo)(()=>(0,g.uuid)(12),[Z,Z.current]);(0,o.useEffect)(()=>{const H=Q=>{Q.type==="dark"||Q.type==="hcDark"?t.e(622).then(t.bind(t,51622)):(Q.type==="light"||Q.type==="hcLight")&&t.e(412).then(t.bind(t,50412))},S=R.onThemeChange(Q=>{H(Q)}),X=R.getCurrentThemeSync();return H(X),()=>S.dispose()},[]);const Y=(0,o.useCallback)(async()=>{F(!0),await E.writeText(f),A.end(N,{copy:!0}),(0,p.runWhenIdle)(()=>{F(!1)},1e3)},[E,f,N]),_=(0,o.useCallback)(()=>{const H=y.getActiveCodeEditor();if(H){const S=H.getSelection();S&&((0,m.insertSnippetWithMonacoEditor)(H,f,[S],{undoStopBefore:!1,undoStopAfter:!1}),A.end(N,{insert:!0}))}},[y]);return o.default.createElement("div",{className:s.default.monaco_wrapper},o.default.createElement("div",{className:s.default.action_toolbar},o.default.createElement(u.Popover,{id:`ai-chat-inser-${V}`,title:(0,p.localize)("aiNative.chat.code.insert")},o.default.createElement(G.EnhanceIcon,{className:(0,g.getIcon)("insert"),onClick:()=>_()})),o.default.createElement(u.Popover,{id:`ai-chat-copy-${V}`,title:(0,p.localize)(w?"aiNative.chat.code.copy.success":"aiNative.chat.code.copy")},o.default.createElement(G.EnhanceIcon,{className:(0,g.getIcon)("copy"),onClick:()=>Y()}))),o.default.createElement(I.default,{language:W,ref:Z,className:s.default.editor},f))};e.CodeEditorWithHighlight=r;const c=({content:f="",relationId:W,renderText:N})=>{const Z=/`([^`]+)`/g,y=/```([^]+?)```/g,E=/```([^]+)?/g,R=w=>{const F=w.split(`
|
|
27283
27283
|
`)[0].trim().toLowerCase(),V=l.highLightLanguageSupport.find(Y=>Y===F)||"plaintext";return w=w.replace(/.*?\n/,""),w=w.trim(),o.default.createElement("div",{className:s.default.code_block},o.default.createElement("div",{className:s.default.code_language},(0,a.default)(V)),o.default.createElement(e.CodeEditorWithHighlight,{input:w,language:F,relationId:W}))},A=(0,o.useMemo)(()=>{const w=f.split(y),F=[];return w.map((V,Y)=>{Y%2===0?V.split(Z).map((_,H)=>{if(H%2===0){if(_.includes("```")){const S=_.split(E).filter(Boolean);if(S.length===2){F.push(S[0]),F.push(R(S[1]));return}}N?F.push(N(_)):F.push(_)}else F.push(o.default.createElement("span",{className:s.default.code_inline,key:H},_))}):F.push(R(V))}),F},[f,N]);return o.default.createElement(o.default.Fragment,null,A)},h=({text:f,renderText:W,relationId:N})=>o.default.createElement("div",{className:s.default.ai_chat_code_wrapper},o.default.createElement("div",{className:s.default.render_text},o.default.createElement(c,{content:f,renderText:W,relationId:N})));e.CodeBlockWrapper=h;const v=({text:f,relationId:W,agentId:N,command:Z})=>{const y=(0,g.useInjectable)(p.ChatFeatureRegistryToken),[E,R]=(0,o.useState)(""),[A,w]=(0,o.useState)(f);return o.default.useEffect(()=>{const{value:F,nameWithSlash:V}=y.parseSlashCommand(f);if(V){R(V),w(F);return}},[f,y]),o.default.createElement("div",{className:s.default.ai_chat_code_wrapper},o.default.createElement("div",{className:s.default.render_text},E&&o.default.createElement("div",{className:s.default.tag_wrapper},o.default.createElement("span",{className:s.default.tag},E)),N&&o.default.createElement("div",{className:s.default.tag,style:{marginRight:4}},"@",N),Z&&o.default.createElement("div",{className:s.default.tag},"/ ",Z),o.default.createElement(c,{content:A,relationId:W})))};e.CodeBlockWrapperInput=v},57987:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ChatInput=void 0;const n=t(85608),a=n.__importDefault(t(53373)),o=n.__importStar(t(14041)),I=t(41869),g=t(81878),u=t(89195),G=t(43718),p=t(9447),m=t(19413),b=t(42033),d=t(51081),s=n.__importDefault(t(6960)),l=160,r=8,c=({icon:W,name:N,description:Z,agentId:y,command:E,selectedAgentId:R})=>{const A=(0,o.useMemo)(()=>!R&&y&&y!==d.ChatProxyService.AGENT_ID&&E?o.default.createElement("span",{className:s.default.agent_label},"@",y):null,[]);return o.default.createElement("div",{className:s.default.block},W&&o.default.createElement(u.EnhanceIcon,{className:W}),N&&o.default.createElement("span",{className:s.default.name},N),Z&&o.default.createElement("span",{className:s.default.text},Z),A)},h=({onClick:W,bottom:N,trigger:Z,agentId:y})=>{const E=(0,I.useInjectable)(m.IChatAgentService),R=(0,I.useInjectable)(G.ChatAgentViewServiceToken),A=(0,o.useMemo)(()=>Z===m.AT_SIGN_SYMBOL?R.getRenderAgents().map(F=>new b.ChatSlashCommandItemModel({icon:"",name:`${m.AT_SIGN_SYMBOL}${F.id} `,description:F.metadata.description},"",F.id)):E.getCommands().map(F=>new b.ChatSlashCommandItemModel({icon:"",name:`${m.SLASH_SYMBOL} ${F.name} `,description:F.description},F.name,F.agentId)).filter(F=>!y||F.agentId===y),[Z,E]),w=(0,o.useCallback)((F,V,Y)=>{W&&W(F||"",V,Y)},[W]);return A.length===0?null:o.default.createElement("div",{className:s.default.instruction_options_container,style:{bottom:N+"px"}},o.default.createElement("div",{className:s.default.options},o.default.createElement("ul",null,A.map(({icon:F,name:V,nameWithSlash:Y,description:_,agentId:H,command:S})=>o.default.createElement("li",{key:`${H||""}-${V}`,onMouseDown:()=>w(Y,H,S)},o.default.createElement(c,{icon:F,name:V,description:_,agentId:H,command:S,selectedAgentId:y}))))))},v=({themeBlock:W})=>o.default.createElement("div",{className:s.default.theme_container},o.default.createElement("div",{className:s.default.theme_block},W)),f=({agentId:W,command:N})=>o.default.createElement("div",{className:s.default.theme_container},W!==d.ChatProxyService.AGENT_ID&&o.default.createElement("div",{className:s.default.theme_block,style:{marginRight:4}},"@",W),N&&o.default.createElement("div",{className:s.default.theme_block},m.SLASH_SYMBOL," ",N));e.ChatInput=o.default.forwardRef((W,N)=>{const{onSend:Z,onValueChange:y,enableOptions:E=!1,disabled:R=!1,defaultHeight:A=32,autoFocus:w,setTheme:F,theme:V,setAgentId:Y,agentId:_,defaultAgentId:H,setCommand:S,command:X}=W,Q=_||H,[O,M]=(0,o.useState)(W.value||""),[T,x]=(0,o.useState)(!1),[B,D]=(0,o.useState)(A),J=(0,o.useRef)(null),[k,z]=(0,o.useState)(!1),[P,U]=(0,o.useState)(!1),[re,se]=(0,o.useState)(!1),ae=(0,o.useRef)(null),[me,ee]=(0,o.useState)((0,G.localize)("aiNative.chat.input.placeholder.default")),pe=(0,I.useInjectable)(p.MonacoCommandRegistry),ge=(0,I.useInjectable)(m.IChatAgentService),$=(0,I.useInjectable)(G.ChatFeatureRegistryToken),le=(0,I.useLatest)(Q);(0,o.useImperativeHandle)(N,()=>({setInputValue:te=>{M(te),(0,G.runWhenIdle)(()=>{var he;(he=J.current)===null||he===void 0||he.focus()},120)}})),(0,o.useEffect)(()=>{W.value!==O&&M(W.value||"")},[W.value]),(0,o.useEffect)(()=>{var te;(te=J.current)===null||te===void 0||te.focus();const he=(0,G.localize)("aiNative.chat.input.placeholder.default"),ve=$.getSlashCommandHandler(X);if(ve&&ve.providerInputPlaceholder){const We=pe.getActiveCodeEditor(),Ze=ve.providerInputPlaceholder(O,We);ee(Ze||he)}else ee(he)},[$,X]),(0,o.useEffect)(()=>{q(V||"",Q,X)},[V,Q,X]),(0,o.useEffect)(()=>{var te;J&&w&&((te=J.current)===null||te===void 0||te.focus())},[J,w,W.value]),(0,o.useEffect)(()=>{if(E&&((O===m.SLASH_SYMBOL||O===m.AT_SIGN_SYMBOL&&ge.getAgents().length>0)&&!re?x(!0):x(!1)),O.startsWith(m.SLASH_SYMBOL)){const{value:te,nameWithSlash:he}=$.parseSlashCommand(O);if(he){const ve=$.getSlashCommandBySlashName(he);M(te),F(he),ve&&(Y(ve.agentId),S(ve.command));return}}if(ge.getAgents().length){const te=ge.parseMessage(O,le.current);(te.agentId||te.command)&&(F(""),M(te.message),te.agentId&&Y(te.agentId),te.command&&S(te.command))}(0,G.runWhenIdle)(()=>{if(J&&J.current&&O&&!re){J.current.style.height="0px";const te=J.current.scrollHeight;J.current.style.height=Math.min(te,l)+"px";const he=Math.min(te+12,l);D(he),he>68?U(!0):U(!1)}})},[J,O,E,$]),(0,o.useEffect)(()=>{O||(D(A),U(!1),se(!1))},[O,B]);const oe=(0,o.useCallback)(te=>{M(te),y&&y(te)},[]),ue=(0,o.useCallback)(async()=>{if(R)return;const te=(he=O)=>{Z(he,Q,X),M(""),F(""),Y(""),S("")};if(X){const he=$.getSlashCommandHandler(X);if(he&&he.execute){const ve=pe.getActiveCodeEditor();await he.execute(O,We=>te(We),ve);return}}te()},[Z,O,Q,X,$]),q=(0,o.useCallback)((te,he,ve)=>{if(he){if(x(!1),F(""),Y(he),S(ve||""),J?.current){const We=J.current.value;(We===m.AT_SIGN_SYMBOL||ve&&We===m.SLASH_SYMBOL)&&M(""),(0,G.runWhenIdle)(()=>J.current.focus())}}else if(te){x(!1),Y(""),S("");const We=$.getSlashCommandBySlashName(te);if(F(We?We.nameWithSlash:""),J&&J.current){const Ze=J.current.value;Ze.length===1&&Ze.startsWith(m.SLASH_SYMBOL)&&M(""),(0,G.runWhenIdle)(()=>J.current.focus())}}},[J,$]),j=(0,o.useMemo)(()=>{const te=r+B;return re&&x(!1),te},[B]),ie=te=>{var he,ve;if(te.key==="Enter"&&!te.nativeEvent.isComposing)te.shiftKey||(te.preventDefault(),ue());else if(te.key==="Backspace"&&((he=J.current)===null||he===void 0?void 0:he.selectionEnd)===0&&((ve=J.current)===null||ve===void 0?void 0:ve.selectionStart)===0){if(F(""),Q===d.ChatProxyService.AGENT_ID){S(""),Y("");return}Q&&(X?S(""):Y(""))}},ne=()=>{z(!0)},de=(0,o.useCallback)(()=>{z(!1),x(!1)},[J]),Ie=(0,o.useCallback)(()=>{const te=re;if(se(!te),te)D(A),U(!1);else{const ve=document.querySelector("#ai_chat_left_container").clientHeight-68-(V?32:0)-16;D(ve)}},[re]),Ge=(0,o.useMemo)(()=>o.default.createElement("div",{className:s.default.input_icon_container},o.default.createElement("div",{className:(0,a.default)(s.default.send_chat_btn,k&&s.default.active,R&&s.default.disabled,W.sendBtnClassName)},R?o.default.createElement("div",{className:s.default.ai_loading},o.default.createElement("div",{className:s.default.loader}),o.default.createElement("div",{className:s.default.loader}),o.default.createElement("div",{className:s.default.loader})):o.default.createElement(g.Popover,{id:`ai_chat_input_send_${(0,G.uuid)(4)}`,content:(0,G.localize)("aiNative.chat.enter.send"),position:g.PopoverPosition.left,disable:R},o.default.createElement(u.EnhanceIcon,{wrapperClassName:s.default.send_icon,className:(0,g.getIcon)("send-solid"),onClick:()=>ue()})))),[k,R,W.sendBtnClassName,ue]);return o.default.createElement("div",{className:(0,a.default)(s.default.chat_input_container,k?s.default.active:null)},T&&o.default.createElement("div",{ref:ae},o.default.createElement(h,{onClick:q,bottom:j,trigger:O,agentId:Q})),V&&o.default.createElement(v,{themeBlock:V}),Q&&o.default.createElement(f,{agentId:Q,command:X}),P&&o.default.createElement("div",{className:s.default.expand_icon,onClick:()=>Ie()},o.default.createElement(g.Popover,{id:"ai_chat_input_expand",title:(0,G.localize)(re?"aiNative.chat.expand.unfullscreen":"aiNative.chat.expand.fullescreen")},o.default.createElement(g.Icon,{className:(0,a.default)(re?(0,g.getIcon)("unfullscreen"):(0,g.getIcon)("fullescreen"))}))),o.default.createElement(g.TextArea,{ref:J,placeholder:me,wrapperStyle:{height:B+"px"},style:{height:B-12+2+"px"},value:O,onKeyDown:ie,onFocus:ne,onBlur:de,onValueChange:oe,disabled:R,className:s.default.input_wrapper,addonAfter:Ge}))})},56474:(L,e,t)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.fillInIncompleteTokens=e.postProcessCodeBlockLanguageId=e.ChatMarkdown=void 0;const n=t(85608),a=n.__importDefault(t(53373)),o=n.__importStar(t(14041)),I=n.__importDefault(t(25873)),g=t(84605),u=t(41869),G=t(6397),p=t(77714),m=t(90684),b=t(25834),d=n.__importDefault(t(6960)),s=F=>{const V=(0,o.useRef)(null),Y=(0,u.useInjectable)(u.AppConfig);return(0,o.useEffect)(()=>{var _,H;const S=V.current;if(!S)return;const X=new Map,Q=typeof F.markdown=="string"?new m.MarkdownString(F.markdown):F.markdown,O=new g.marked.Renderer;O.link=(D,J,k)=>`<a rel="noopener" target="_blank" href="${D}" target="${D}" title="${J||D}">${k}</a>`,O.code=(D,J)=>{const k=G.defaultGenerator.nextId(),z=document.createElement("div"),P=l(J),U=I.default.createRoot(z);return U.render(o.default.createElement(u.ConfigProvider,{value:Y},o.default.createElement("div",{className:d.default.code_block},o.default.createElement("div",{className:d.default.code_language},P),o.default.createElement(b.CodeEditorWithHighlight,{input:D,language:P,relationId:F.relationId})))),X.set(k,{container:z,root:U}),`<div class="code" data-code="${k}">${(0,p.escape)(D)}</div>`},O.codespan=D=>`<code class=${d.default.code_inline}>${D}</code>`;const M=(_=F.markedOptions)!==null&&_!==void 0?_:{};M.renderer=O;let T=(H=Q.value)!==null&&H!==void 0?H:"";T.length>1e5&&(T=`${T.slice(0,1e5)}\u2026`);let x;if(F.fillInIncompleteTokens){const D=Object.assign(Object.assign({},g.marked.defaults),M),J=g.marked.lexer(T,D),k=r(J);x=g.marked.parser(k,D)}else x=g.marked.parse(T,M);return S.innerHTML=x,S.querySelectorAll("div[data-code]").forEach(D=>{var J;const k=X.get((J=D.dataset.code)!==null&&J!==void 0?J:"");k&&k.container&&(D.innerText="",D.append(k.container))}),()=>{X.size>0&&X.forEach(({root:D})=>{requestAnimationFrame(()=>{D.unmount()})})}},[F.markdown]),o.default.createElement("div",{className:(0,a.default)(d.default.markdown_container,F.className),ref:V})};e.ChatMarkdown=s;function l(F){if(!F)return"";const V=F.split(/[\s+|:|,|\{|\?]/,1);return V.length?V[0]:F}e.postProcessCodeBlockLanguageId=l;function r(F){let V,Y;for(V=0;V<F.length;V++){const _=F[V];if(_.type==="paragraph"&&_.raw.match(/(\n|^)```/)){Y=c(F.slice(V));break}if(_.type==="paragraph"&&_.raw.match(/(\n|^)\|/)){Y=R(F.slice(V));break}if(_.type==="paragraph"&&V===F.length-1){const H=w(_);if(H){Y=[H];break}}}if(Y){const _=[...F.slice(0,V),...Y];return _.links=F.links,_}return F}e.fillInIncompleteTokens=r;function c(F){const V=A(F);return g.marked.lexer(V+"\n```")}function h(F){return E(F,"`")}function v(F){return E(F,"*")}function f(F){return E(F,"_")}function W(F){return E(F,")")}function N(F){return E(F,"](about:blank)")}function Z(F){return E(F,"**")}function y(F){return E(F,"__")}function E(F,V){const Y=A(Array.isArray(F)?F:[F]);return g.marked.lexer(Y+V)[0]}function R(F){const V=A(F),Y=V.split(`
|
|
27284
27284
|
`);let _=0,H=!1;for(let S=0;S<Y.length;S++){const X=Y[S].trim();if(typeof _>"u"&&X.match(/^\s*\|/)){const Q=X.match(/(\|[^\|]+)(?=\||$)/g);Q&&(_=Q.length)}else if(typeof _=="number")if(X.match(/^\s*\|/)&&S===Y.length-1)H=!0;else return}if(_>0){const S=H?Y.slice(0,-1).join(`
|
|
27285
27285
|
`):V,X=!!S.match(/\|\s*$/),Q=S+(X?"":"|")+`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/cli-engine",
|
|
3
|
-
"version": "3.0.4
|
|
3
|
+
"version": "3.0.4",
|
|
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.0.4
|
|
30
|
-
"@opensumi/ide-core-common": "3.0.4
|
|
31
|
-
"@opensumi/ide-core-node": "3.0.4
|
|
32
|
-
"@opensumi/ide-express-file-server": "3.0.4
|
|
33
|
-
"@opensumi/ide-extension": "3.0.4
|
|
34
|
-
"@opensumi/ide-i18n": "3.0.4
|
|
35
|
-
"@opensumi/ide-main-layout": "3.0.4
|
|
36
|
-
"@opensumi/ide-startup": "3.0.4
|
|
29
|
+
"@opensumi/ide-core-browser": "3.0.4",
|
|
30
|
+
"@opensumi/ide-core-common": "3.0.4",
|
|
31
|
+
"@opensumi/ide-core-node": "3.0.4",
|
|
32
|
+
"@opensumi/ide-express-file-server": "3.0.4",
|
|
33
|
+
"@opensumi/ide-extension": "3.0.4",
|
|
34
|
+
"@opensumi/ide-i18n": "3.0.4",
|
|
35
|
+
"@opensumi/ide-main-layout": "3.0.4",
|
|
36
|
+
"@opensumi/ide-startup": "3.0.4",
|
|
37
37
|
"chalk": "^4.0.0",
|
|
38
38
|
"ejs": "^3.1.7",
|
|
39
39
|
"ip": "^1.1.8",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"webpack": "^5.90.0",
|
|
74
74
|
"webpack-cli": "^5.1.4"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "d6b4db921f09c2f164ba9335549550b3519f4b83"
|
|
77
77
|
}
|