@opensumi/cli-engine 3.8.3-next-1744788732.0 → 3.8.3-next-1744791676.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 +12 -2
- package/package.json +10 -10
package/lib/browser/browser.js
CHANGED
|
@@ -4259,9 +4259,14 @@ WARNING: This link could potentially be dangerous`)){const a=window.open();if(a)
|
|
|
4259
4259
|
}
|
|
4260
4260
|
.kt-select-container .kt-select-value.kt-select-disabled {
|
|
4261
4261
|
pointer-events: none;
|
|
4262
|
+
cursor: not-allowed;
|
|
4262
4263
|
background-color: var(--kt-select-disableBackground);
|
|
4263
4264
|
color: var(--kt-select-disableForeground);
|
|
4264
4265
|
}
|
|
4266
|
+
.kt-select-container .kt-select-value.kt-select-disabled .kt-select-option,
|
|
4267
|
+
.kt-select-container .kt-select-value.kt-select-disabled .kt-icon {
|
|
4268
|
+
color: inherit;
|
|
4269
|
+
}
|
|
4265
4270
|
.kt-select-container .kt-select-value.kt-select-warning {
|
|
4266
4271
|
border-color: var(--kt-select-warningForeground);
|
|
4267
4272
|
}
|
|
@@ -5652,9 +5657,14 @@ WARNING: This link could potentially be dangerous`)){const a=window.open();if(a)
|
|
|
5652
5657
|
}
|
|
5653
5658
|
.kt-select-container .kt-select-value.kt-select-disabled {
|
|
5654
5659
|
pointer-events: none;
|
|
5660
|
+
cursor: not-allowed;
|
|
5655
5661
|
background-color: var(--kt-select-disableBackground);
|
|
5656
5662
|
color: var(--kt-select-disableForeground);
|
|
5657
5663
|
}
|
|
5664
|
+
.kt-select-container .kt-select-value.kt-select-disabled .kt-select-option,
|
|
5665
|
+
.kt-select-container .kt-select-value.kt-select-disabled .kt-icon {
|
|
5666
|
+
color: inherit;
|
|
5667
|
+
}
|
|
5658
5668
|
.kt-select-container .kt-select-value.kt-select-warning {
|
|
5659
5669
|
border-color: var(--kt-select-warningForeground);
|
|
5660
5670
|
}
|
|
@@ -31267,10 +31277,10 @@ The user's OS is ${(0,p.getOperatingSystemName)()}. The absolute path of the use
|
|
|
31267
31277
|
`);let R=0,P=!1;for(let k=0;k<M.length;k++){const F=M[k].trim();if(typeof R>"u"&&F.match(/^\s*\|/)){const L=F.match(/(\|[^\|]+)(?=\||$)/g);L&&(R=L.length)}else if(typeof R=="number")if(F.match(/^\s*\|/)&&k===M.length-1)P=!0;else return}if(R>0){const k=P?M.slice(0,-1).join(`
|
|
31268
31278
|
`):O,F=!!k.match(/\|\s*$/),L=k+(F?"":"|")+`
|
|
31269
31279
|
|${" --- |".repeat(R)}`;return p.marked.lexer(L)}}function T(I){return I.reduce((O,M)=>O+M.raw,"")}function D(I){for(const{type:O,raw:M}of I.tokens){if(O!=="text")continue;const R=M.split(`
|
|
31270
|
-
`),P=R[R.length-1],k=[{condition:P.includes("`"),action:d},{condition:P.includes("**"),action:y},{condition:P.match(/\*\w/),action:E},{condition:P.match(/(^|\s)__\w/),action:A},{condition:P.match(/(^|\s)_\w/),action:f},{condition:P.match(/(^|\s)\[.*\]\(\w*/),action:a},{condition:P.match(/(^|\s)\[\w/),action:b}];for(const F of k)if(F.condition)return F.action(I)}}},49601:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatMentionInput=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(46541),c=e(41869),p=e(81878),v=e(43718),m=e(92323),_=e(54414),s=e(47720),g=e(72665),l=e(51500),h=e(19413),u=e(27397),d=n.__importDefault(e(6960)),E=e(96086),f=e(44692),a=y=>{const{onSend:A,disabled:S=!1}=y,[w,T]=(0,r.useState)(y.value||""),[D,I]=(0,r.useState)(y.images||[]),O=(0,c.useInjectable)(h.IChatInternalService),M=(0,c.useInjectable)(m.CommandService),R=(0,c.useInjectable)(s.FileSearchServicePath),P=(0,c.useInjectable)(c.RecentFilesManager),k=(0,c.useInjectable)(l.IWorkspaceService),F=(0,c.useInjectable)(_.WorkbenchEditorService),L=(0,c.useInjectable)(c.LabelService),B=(0,c.useInjectable)(g.IMessageService),j=(0,c.useInjectable)(v.ChatFeatureRegistryToken),W=r.default.useCallback(()=>{M.executeCommand(u.OPEN_MCP_CONFIG_COMMAND.id)},[M]);(0,r.useEffect)(()=>{y.value!==w&&T(y.value||"")},[y.value]);const U=[{id:f.MentionType.FILE,type:f.MentionType.FILE,text:"File",icon:(0,p.getIcon)("file"),getHighestLevelItems:()=>{const H=F.currentEditor,K=H?.currentUri;return K?[{id:K.codeUri.fsPath,type:f.MentionType.FILE,text:K.displayName,value:K.codeUri.fsPath,description:`(${(0,v.localize)("aiNative.chat.defaultContextFile")})`,contextId:K.codeUri.fsPath,icon:L.getIcon(K)}]:[]},getItems:async H=>{if(H){const K=(await k.roots).map(X=>new v.URI(X.uri).codeUri.fsPath.toString()),Z=await R.find(H,{rootUris:K,useGitIgnore:!0,noIgnoreParent:!0,fuzzyMatch:!0,limit:10});return Promise.all(Z.map(async X=>{var ie;const oe=new v.URI(X),le=(ie=await k.asRelativePath(oe.parent))===null||ie===void 0?void 0:ie.path;return{id:oe.codeUri.fsPath,type:f.MentionType.FILE,text:oe.displayName,value:oe.codeUri.fsPath,description:le||"",contextId:oe.codeUri.fsPath,icon:L.getIcon(oe)}}))}else{const K=await P.getMostRecentlyOpenedFiles();return Promise.all(K.map(async Z=>{var X;const ie=new v.URI(Z),oe=(X=await k.asRelativePath(ie.parent))===null||X===void 0?void 0:X.path;return{id:ie.codeUri.fsPath,type:f.MentionType.FILE,text:ie.displayName,value:ie.codeUri.fsPath,description:oe||"",contextId:ie.codeUri.fsPath,icon:L.getIcon(ie)}}))}}},{id:f.MentionType.FOLDER,type:f.MentionType.FOLDER,text:"Folder",icon:(0,p.getIcon)("folder"),getHighestLevelItems:()=>{var H,K;const Z=F.currentEditor,X=(H=Z?.currentUri)===null||H===void 0?void 0:H.parent;return X?X.toString()===((K=k.workspace)===null||K===void 0?void 0:K.uri)?[]:[{id:X.codeUri.fsPath,type:f.MentionType.FOLDER,text:X.displayName,value:X.codeUri.fsPath,description:`(${(0,v.localize)("aiNative.chat.defaultContextFolder")})`,contextId:X.codeUri.fsPath,icon:(0,p.getIcon)("folder")}]:[]},getItems:async H=>{let K=[];if(H){const Z=(await k.roots).map(oe=>new v.URI(oe.uri).codeUri.fsPath.toString()),X=await R.find(H,{rootUris:Z,useGitIgnore:!0,noIgnoreParent:!0,fuzzyMatch:!0,excludePatterns:["**/node_modules/**/*","**/.git/**/*"],limit:10}),ie=Array.from(new Set(X.map(oe=>new v.URI(oe).parent.toString()).filter(oe=>{var le;return oe!==((le=k.workspace)===null||le===void 0?void 0:le.uri.toString())})));return Promise.all(ie.map(async oe=>{var le;const pe=new v.URI(oe);return{id:pe.codeUri.fsPath,type:f.MentionType.FOLDER,text:pe.displayName,value:pe.codeUri.fsPath,description:((le=await k.asRelativePath(pe.parent))===null||le===void 0?void 0:le.path)||"",contextId:pe.codeUri.fsPath,icon:(0,p.getIcon)("folder")}}))}else{const Z=await P.getMostRecentlyOpenedFiles(),X=Array.from(new Set(Z.map(ie=>new v.URI(ie).parent.codeUri.fsPath)));K=await Promise.all(X.map(async ie=>{const oe=new v.URI(ie),le=await k.asRelativePath(oe);return{id:oe.codeUri.fsPath,type:f.MentionType.FOLDER,text:oe.displayName,value:oe.codeUri.fsPath,description:le?.root?le.path:"",contextId:oe.codeUri.fsPath,icon:(0,p.getIcon)("folder")}}))}return K.filter(Z=>{var X;return Z.id!==new v.URI((X=k.workspace)===null||X===void 0?void 0:X.uri).codeUri.fsPath})}}],Q=(0,r.useMemo)(()=>({modelOptions:[{label:"QWQ 32B",value:"qwq-32b"},{label:"DeepSeek R1",value:"deepseek-r1"}],defaultModel:"deepseek-r1",buttons:[{id:"mcp-server",icon:"mcp",title:"MCP Server",onClick:W,position:f.FooterButtonPosition.LEFT},{id:"upload-image",icon:"image",title:(0,v.localize)("aiNative.chat.imageUpload"),onClick:()=>{const H=document.createElement("input");H.type="file",H.accept="image/*",H.onchange=K=>{const Z=K.target.files;Z?.length&&Y(Array.from(Z))},H.click()},position:f.FooterButtonPosition.LEFT}],showModelSelector:!y.disableModelSelector}),[W,y.disableModelSelector]),V=(0,r.useCallback)(()=>{O.cancelRequest()},[]),$=(0,r.useCallback)(async(H,K)=>{S||(A(H,D.map(Z=>Z.toString()),void 0,void 0,K),I(y.images||[]))},[A,D,S]),Y=(0,r.useCallback)(async H=>{const K=["image/jpeg","image/jpg","image/png","image/webp","image/gif"];if(H.filter(le=>!K.includes(le.type)).length>0){B.error("Only JPG, PNG, WebP and GIF images are supported");return}const X=j.getImageUploadProvider();if(!X){B.error("No image upload provider found");return}const ie=await Promise.all(H.map(le=>X.imageUpload(le))),oe=[...D,...ie];I(oe)},[D]),z=(0,r.useCallback)(H=>{I(D.filter((K,Z)=>Z!==H))},[D]);return r.default.createElement("div",{className:d.default.chat_input_container},D.length>0&&r.default.createElement(b,{images:D,onDelete:z}),r.default.createElement(E.MentionInput,{mentionItems:U,onSend:$,onStop:V,loading:S,labelService:L,workspaceService:k,placeholder:(0,v.localize)("aiNative.chat.input.placeholder.default"),footerConfig:Q,onImageUpload:Y}))};t.ChatMentionInput=a;const b=({images:y,onDelete:A})=>r.default.createElement("div",null,r.default.createElement("div",{className:d.default.thumbnail_container},y.map((S,w)=>r.default.createElement("div",{key:w,className:d.default.thumbnail},r.default.createElement(o.Image,{src:S.toString()}),r.default.createElement("button",{onClick:()=>A(w),className:d.default.delete_button},r.default.createElement(p.Icon,{iconClass:"codicon codicon-close"}))))))},92635:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatNotify=t.ChatReply=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),c=e(48412),p=e(91416),v=e(78569),m=e(72871),_=e(41869),s=e(81878),g=e(89195),l=e(43718),h=e(52416),u=e(90684),d=e(19413),E=e(56474),f=e(17319),a=n.__importDefault(e(6960)),b=T=>{const D=(0,_.useInjectable)(_.LabelService),I=(0,_.useInjectable)(_.CommandService),O=(L,B,j)=>{let W=D.getIcon(L,{isDirectory:B});return B&&j&&(W+=" expanded"),W},M=(0,o.useMemo)(()=>{const L=B=>{const j=typeof B.type=="number"?B.type===l.FileType.Directory:!!B.children,W=new l.URI(B.uri);return{label:B.label,iconClassName:O(W,j,j),expandable:!0,expanded:!0,children:j?(B.children||[]).map(L):null,uri:W}};return(T.treeData.children||[]).map(L)},[T.treeData]),[R,P]=(0,o.useState)(22),k=(0,o.useRef)(null),F=L=>{k.current=L;const B=()=>{let j=L.getModel().root.branchSize;j<1?j=1:j>20&&(j=20),P(j*22)};B(),L.onDidUpdate(B)};return M.length?o.default.createElement("div",{className:a.default.tree_container},o.default.createElement(p.BasicRecycleTree,{height:R,treeData:M,onContextMenu:L=>L.preventDefault(),onClick:(L,B)=>{!k.current||!B||(v.BasicCompositeTreeNode.is(B)?B.raw.iconClassName=O(B.raw.uri,!0,B.expanded):I.executeCommand(_.EDITOR_COMMANDS.OPEN_RESOURCE.id,B.raw.uri,{disableNavigate:!0,preview:!0}))},onReady:F,treeName:T.treeData.label,leaveBottomBlank:!1,baseIndent:0})):null},y=T=>{const{toolCall:D,messageId:I}=T,O=(0,_.useInjectable)(l.ChatAgentViewServiceToken),[M,R]=(0,o.useState)(null);return(0,o.useEffect)(()=>{const P=O.getChatComponent("toolCall");if(P){const{component:F,initialProps:L}=P;R(o.default.createElement(F,{...L,value:D,messageId:I}));return}R(o.default.createElement("div",null,o.default.createElement(g.Loading,null),o.default.createElement("span",{style:{marginLeft:4}},"\u6B63\u5728\u52A0\u8F7D\u7EC4\u4EF6"))),O.getChatComponentDeferred("toolCall").promise.then(({component:F,initialProps:L})=>{R(o.default.createElement(F,{...L,value:D,messageId:I}))})},[D.state]),M},A=T=>{const D=(0,_.useInjectable)(l.ChatAgentViewServiceToken),[I,O]=(0,o.useState)(null);return(0,o.useEffect)(()=>{const M=D.getChatComponent(T.component);if(M){const{component:P,initialProps:k}=M;O(o.default.createElement(P,{...k,value:T.value,messageId:T.messageId}));return}O(o.default.createElement("div",null,o.default.createElement(g.Loading,null),o.default.createElement("span",{style:{marginLeft:4}},"\u6B63\u5728\u52A0\u8F7D\u7EC4\u4EF6"))),D.getChatComponentDeferred(T.component).promise.then(({component:P,initialProps:k})=>{O(o.default.createElement(P,{...k,value:T.value}))})},[T.component,T.value]),I},S=T=>{var D,I;const{relationId:O,request:M,startTime:R=0,onRegenerate:P,onDidChange:k,onDone:F,agentId:L,command:B,history:j,msgId:W}=T,[,U]=(0,o.useReducer)(_e=>(_e+1)%1e6,0),Q=(0,_.useInjectable)(l.IAIReporter),V=(0,_.useInjectable)(h.IIconService),$=(0,_.useInjectable)(_.IContextKeyService),Y=(0,_.useInjectable)(d.IChatInternalService),z=(0,_.useInjectable)(l.ChatServiceToken),H=(0,_.useInjectable)(d.IChatAgentService),K=(0,_.useInjectable)(l.ChatRenderRegistryToken),[Z,X]=(0,o.useState)(M.response.isComplete?new Set(M.response.responseContents.map((_e,ne)=>_e.kind==="reasoning"?ne:-1).filter(_e=>_e!==-1)):new Set);(0,o.useEffect)(()=>{M.response.isComplete&&X(new Set(M.response.responseContents.map((_e,ne)=>_e.kind==="reasoning"?ne:-1).filter(_e=>_e!==-1)))},[M.response.isComplete]),(0,o.useEffect)(()=>{const _e=new _.DisposableCollection;return _e.push(M.response.onDidChange(()=>{j.updateAssistantMessage(W,{content:M.response.responseText}),M.response.isComplete&&(F&&F(),Q.end(O,{assistantMessage:M.response.responseText,replytime:Date.now()-R,success:!0,isStop:!1,command:B,agentId:L,messageId:W,sessionId:Y.sessionModel.sessionId})),(0,o.startTransition)(()=>{k?.(),U()})})),()=>_e.dispose()},[O,k,F]);const ie=(0,o.useCallback)(()=>{M.response.reset(),P?.()},[P]),oe=(0,o.useCallback)(_e=>{if(K.chatAIRoleRender){const ne=K.chatAIRoleRender;return o.default.createElement(ne,{content:_e.value})}return o.default.createElement(E.ChatMarkdown,{markdown:_e,fillInIncompleteTokens:!0})},[K,K.chatAIRoleRender]),le=_e=>o.default.createElement(b,{treeData:_e}),pe=_e=>o.default.createElement("div",{className:a.default.placeholder},o.default.createElement(s.Icon,{iconClass:V.fromString("$(codicon/sync~spin)")}),o.default.createElement("div",{className:a.default.placeholder_content},oe(_e))),q=o.default.useMemo(()=>M.response.responseContents.map((_e,ne)=>{let ge;if(_e.kind==="asyncContent")ge=pe(new u.MarkdownString(_e.content));else if(_e.kind==="treeData")ge=le(_e.treeData);else if(_e.kind==="component")ge=o.default.createElement(A,{component:_e.component,value:_e.value,messageId:W});else if(_e.kind==="toolCall")ge=o.default.createElement(y,{toolCall:_e.content,messageId:W});else if(_e.kind==="reasoning"){const we=ne===M.response.responseContents.length-1&&!M.response.isComplete;ge=o.default.createElement("div",{className:(0,r.default)(a.default.reasoning,{[a.default.thinking]:we})},o.default.createElement(c.Button,{size:"small",type:"secondary",className:a.default.thinking,onClick:()=>{we||(Z.has(ne)?Z.delete(ne):Z.add(ne),X(new Set(Z)))}},o.default.createElement(s.Icon,{iconClass:"codicon codicon-sparkle"}),(0,l.localize)("aiNative.chat.thinking"),we?o.default.createElement(g.Loading,null):Z.has(ne)?o.default.createElement(s.Icon,{iconClass:"codicon codicon-chevron-right"}):o.default.createElement(s.Icon,{iconClass:"codicon codicon-chevron-down"})),Z.has(ne)?null:o.default.createElement("div",{className:a.default.reasoning_content},oe(new u.MarkdownString(_e.content))))}else ge=oe(_e.content);return o.default.createElement(o.Fragment,{key:`${_e.kind}-${ne}`},ge)}),[M.response.responseContents,Z]),Ee=o.default.useMemo(()=>M.response.followups?M.response.followups.map((_e,ne)=>{let ge=null;if(_e.kind==="reply"){const we=o.default.createElement("a",{onClick:()=>{z.sendMessage({...H.parseMessage(_e.message),reportExtra:{actionSource:l.ActionSourceEnum.Chat,actionType:l.ActionTypeEnum.Followup}})}},_e.title||_e.message);ge=_e.tooltip?o.default.createElement(m.Tooltip,{title:_e.tooltip},we):we}else _e.when&&!$.match(_e.when)&&(ge=null),ge=o.default.createElement(c.Button,{type:"default"},_e.title);return ge&&o.default.createElement(o.Fragment,{key:ne},ge)}):null,[M.response.followups]);return M.response.isComplete?o.default.createElement(f.ChatThinkingResult,{hasMessage:M.response.responseParts.length>0||M.response.responseContents.length>0||!!(!((D=M.response.errorDetails)===null||D===void 0)&&D.message),onRegenerate:ie,requestId:M.requestId},o.default.createElement("div",{className:a.default.ai_chat_response_container},!((I=M.response.errorDetails)===null||I===void 0)&&I.message?o.default.createElement("div",{className:a.default.error},o.default.createElement(s.Icon,{className:(0,s.getIcon)("close-circle")}),o.default.createElement("span",null,M.response.errorDetails.message)):o.default.createElement(o.default.Fragment,null,q,Ee?.length!==0&&o.default.createElement("div",{className:a.default.followups},Ee)))):o.default.createElement(f.ChatThinking,{message:M.response.responseText},q)};t.ChatReply=S;const w=T=>{const{chunk:D}=T,I=(0,_.useInjectable)(l.ChatRenderRegistryToken),O=o.default.useMemo(()=>{let M;if(D.kind==="component")M=o.default.createElement(A,{component:D.component,value:D.value});else{let R=o.default.createElement(E.ChatMarkdown,{markdown:D.content,fillInIncompleteTokens:!0});if(I.chatAIRoleRender){const P=I.chatAIRoleRender;R=o.default.createElement(P,{content:D.content})}M=R}return M},[D]);return o.default.createElement(f.ChatThinkingResult,{hasMessage:!0,requestId:T.requestId,showRegenerate:!1},o.default.createElement("div",{className:a.default.ai_chat_response_container},O))};t.ChatNotify=w},17319:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatThinkingResult=t.ChatThinking=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(41869),c=e(89195),p=e(68974),v=e(43718),m=e(19413),_=n.__importDefault(e(6960)),s=l=>{const{children:h,message:u,thinkingText:d}=l,E=(0,o.useInjectable)(v.ChatRenderRegistryToken),f=(0,r.useMemo)(()=>E.chatThinkingRender,[E,E.chatThinkingRender]),a=(0,r.useMemo)(()=>Array.isArray(h)?h.length===0:!h,[h]),b=(0,r.useCallback)(()=>a?f?r.default.createElement(f,{thinkingText:d}):r.default.createElement("span",{className:_.default.thinking_text},d||"Thinking..."):h,[u,h,d,f]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{className:_.default.content},b()),r.default.createElement("div",{className:_.default.thinking_container},r.default.createElement("div",{className:_.default.stop},!f&&r.default.createElement("span",{className:_.default.progress_bar},a&&r.default.createElement(p.Progress,{loading:!0,wrapperClassName:_.default.ai_native_progress_wrapper})))))};t.ChatThinking=s;const g=({children:l,message:h,onRegenerate:u,requestId:d,hasMessage:E=!0,showRegenerate:f})=>{const a=(0,o.useInjectable)(m.IChatInternalService),[b,y]=(0,r.useState)(a.latestRequestId),A=(0,o.useInjectable)(v.ChatRenderRegistryToken);(0,r.useEffect)(()=>{const I=a.onChangeRequestId(O=>{y(O)});return()=>I.dispose()},[a]);const S=(0,r.useMemo)(()=>A.chatThinkingResultRender,[A,A.chatThinkingResultRender]),w=(0,r.useCallback)(()=>{u&&u()},[u]),T=(0,r.useCallback)(()=>{if(typeof E=="boolean"?!E:!h?.trim()){const I=(0,v.localize)("aiNative.chat.stop.immediately");return S?r.default.createElement(S,{thinkingResult:I}):r.default.createElement("span",null,I)}return l},[h,E,l]),D=(0,r.useMemo)(()=>(0,v.isUndefined)(f)?b===d&&!!d:!!f,[b,d,f]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{className:_.default.content},T()),r.default.createElement("div",{className:_.default.thinking_container},r.default.createElement("div",{className:_.default.bottom_container},r.default.createElement("div",{className:_.default.reset},D?r.default.createElement(c.EnhanceIcon,{icon:"refresh",wrapperClassName:_.default.text_btn,className:_.default.transform,onClick:w,tabIndex:0,role:"button"},r.default.createElement("span",null,(0,v.localize)("aiNative.operate.afresh.title"))):null),r.default.createElement("div",{className:_.default.thumbs},r.default.createElement(c.Thumbs,{relationId:d,wrapperClassName:_.default.icon_btn})))))};t.ChatThinkingResult=g},34817:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatToolRender=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),c=e(41869),p=e(81878),v=e(89195),m=e(43718),_=e(33783),s=e(77633),g=e(25834),l=n.__importDefault(e(16796)),h=u=>{var d,E,f;const{value:a,messageId:b}=u,[y,A]=(0,o.useState)(!1),S=(0,c.useInjectable)(s.TokenMCPServerRegistry);if(!a||!a.function||!a.id)return null;const w=((d=S.getMCPTool(a.function.name))===null||d===void 0?void 0:d.label)||a.function.name,T=S.getToolComponent(a.function.name),D=R=>{switch(R){case"streaming-start":case"streaming":return{label:"Generating",icon:o.default.createElement(v.Loading,null)};case"complete":return{label:"Complete",icon:o.default.createElement(p.Icon,{iconClass:"codicon codicon-check"})};case"result":return{label:"Result Ready",icon:o.default.createElement(p.Icon,{iconClass:"codicon codicon-check-all"})};default:return{label:R||"Unknown",icon:o.default.createElement(p.Icon,{iconClass:"codicon codicon-question"})}}},I=()=>{var R;try{return a.state!=="complete"&&a.state!=="result"?{}:JSON.parse(((R=a.function)===null||R===void 0?void 0:R.arguments)||"{}")}catch{return{}}},O=()=>{A(!y)},M=D(a.state);return T&&(a.state==="complete"||a.state==="result")?o.default.createElement(T,{state:a.state,args:I(),result:a.result,index:a.index,messageId:b,toolCallId:a.id}):o.default.createElement("div",{className:l.default.chat_tool_render},o.default.createElement("div",{className:l.default.tool_header,onClick:O},o.default.createElement("div",{className:l.default.tool_name},o.default.createElement(p.Icon,{iconClass:`codicon codicon-chevron-${y?"down":"right"}`}),o.default.createElement(p.Icon,{size:"small",iconClass:(0,r.default)("codicon codicon-tools",l.default.tool_icon)}),o.default.createElement("span",{className:l.default.tool_label},w)),a.state&&o.default.createElement("div",{className:l.default.tool_state},o.default.createElement("span",{className:l.default.state_icon},M.icon))),o.default.createElement("div",{className:(0,r.default)(l.default.tool_content,{[l.default.expanded]:y})},((E=a?.function)===null||E===void 0?void 0:E.arguments)&&o.default.createElement("div",{className:l.default.tool_arguments},o.default.createElement("div",{className:l.default.section_label},(0,_.localize)("ai.native.mcp.tool.arguments"),":"),o.default.createElement(g.CodeEditorWithHighlight,{input:(f=a?.function)===null||f===void 0?void 0:f.arguments,language:"json",relationId:(0,m.uuid)(4)})),a?.result&&o.default.createElement("div",{className:l.default.tool_result},o.default.createElement("div",{className:l.default.section_label},(0,_.localize)("ai.native.mcp.tool.results"),":"),o.default.createElement(g.CodeEditorWithHighlight,{input:a.result,language:"json",relationId:(0,m.uuid)(4)}))))};t.ChatToolRender=h},29039:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SlashCustomRender=void 0;const r=e(85608).__importStar(e(14041)),o=e(41869),c=e(43718),p=e(19413),v=m=>{const{userMessage:_,relationId:s,requestId:g,renderContent:l,startTime:h,agentId:u,command:d}=m,E=(0,o.useInjectable)(p.IChatInternalService),f=(0,o.useInjectable)(c.IAIReporter);return r.useEffect(()=>{E.setLatestRequestId(g),f.end(s,{message:_,replytime:Date.now()-h,success:!0,isStop:!1,agentId:u,command:d})},[l,g,s]),r.createElement("div",null,l({userMessage:_}))};t.SlashCustomRender=v},86556:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WelcomeMessage=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(41869),c=e(81878),p=e(4246),v=e(43718),m=e(90684);e(41937);const _=e(19413),s=e(56474),g=e(17319),l=e(78048),h=n.__importDefault(e(6960)),u=()=>{var d,E;const f=(0,o.useInjectable)(v.ChatServiceToken),a=(0,o.useInjectable)(_.IChatAgentService),b=(0,o.useInjectable)(v.ChatFeatureRegistryToken),y=(0,o.useInjectable)(v.ChatRenderRegistryToken),[A,S]=r.useState([]);(0,o.useUpdateOnEvent)(b.onDidWelcomeMessageChange);const w=r.useMemo(()=>{if(!b.chatWelcomeMessageModel)return[];const{sampleQuestions:O=[]}=b.chatWelcomeMessageModel;return O.map(l.extractIcon)},[(d=b.chatWelcomeMessageModel)===null||d===void 0?void 0:d.sampleQuestions]),T=r.useMemo(()=>{if(!b.chatWelcomeMessageModel)return"";const{content:O}=b.chatWelcomeMessageModel;return O},[(E=b.chatWelcomeMessageModel)===null||E===void 0?void 0:E.content]);if(r.useEffect(()=>{const O=a.onDidChangeAgents(async()=>{const R=(await a.getAllSampleQuestions()).map(l.extractIcon);S(R)});return()=>O.dispose()},[]),!T)return r.createElement(g.ChatThinking,{thinkingText:(0,v.localize)("aiNative.chat.welcome.loading.text")});const D=r.useMemo(()=>w.concat(A),[w,A]);return r.useMemo(()=>{if(y.chatWelcomeRender){const O=y.chatWelcomeRender;return r.createElement(O,{message:T,sampleQuestions:D})}return r.createElement("div",{className:h.default.chat_welcome_head},r.createElement("div",{className:h.default.chat_container_des},(0,m.isMarkdownString)(T)?r.createElement(s.ChatMarkdown,{key:"welcome",markdown:T}):T),r.createElement("div",{className:h.default.chat_container_content},D.map((O,M)=>{const R=r.createElement("a",{className:h.default.link_item,onClick:(0,p.withPrevented)(()=>{f.sendMessage({...a.parseMessage(O.message),reportExtra:{actionType:v.ActionTypeEnum.Welcome,actionSource:v.ActionSourceEnum.Chat}})})},O.icon?r.createElement(c.Icon,{className:O.icon,style:{color:"inherit",marginRight:"4px"}}):"",r.createElement("span",null,O.title));return O.tooltip?r.createElement(c.Tooltip,{title:O.tooltip,key:M},R):r.createElement(r.Fragment,{key:M},R)})))},[y.chatWelcomeRender,T,D])};t.WelcomeMessage=u},83933:(x,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.highLightLanguageSupport=void 0,t.highLightLanguageSupport=["1c","abnf","accesslog","actionscript","ada","angelscript","apache","applescript","arcade","arduino","armasm","xml","asciidoc","aspectj","autohotkey","autoit","avrasm","awk","axapta","bash","basic","bnf","brainfuck","c-like","c","cal","capnproto","ceylon","clean","clojure","clojure-repl","cmake","coffeescript","coq","cos","cpp","crmsh","crystal","csharp","csp","css","d","markdown","dart","delphi","diff","django","dns","dockerfile","dos","dsconfig","dts","dust","ebnf","elixir","elm","ruby","erb","erlang-repl","erlang","excel","fix","flix","fortran","fsharp","gams","gauss","gcode","gherkin","glsl","gml","go","golo","gradle","groovy","haml","handlebars","haskell","haxe","hsp","htmlbars","http","hy","inform7","ini","irpf90","isbl","java","javascript","jboss-cli","json","julia","julia-repl","kotlin","lasso","latex","ldif","leaf","less","lisp","livecodeserver","livescript","llvm","lsl","lua","makefile","mathematica","matlab","maxima","mel","mercury","mipsasm","mizar","perl","mojolicious","monkey","moonscript","n1ql","nginx","nim","nix","node-repl","nsis","objectivec","ocaml","openscad","oxygene","parser3","pf","pgsql","php","php-template","plaintext","pony","powershell","processing","profile","prolog","properties","protobuf","puppet","purebasic","python","python-repl","q","qml","r","reasonml","rib","roboconf","routeros","rsl","ruleslanguage","rust","sas","scala","scheme","scilab","scss","shell","smali","smalltalk","sml","sqf","sql_more","sql","stan","stata","step21","stylus","subunit","swift","taggerscript","yaml","tap","tcl","thrift","tp","twig","typescript","vala","vbnet","vbscript","vbscript-html","verilog","vhdl","vim","x86asm","xl","xquery","zephir"]},96086:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MentionInput=t.WHITE_SPACE_TEXT=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),c=e(81878),p=e(89195),v=e(70392),m=n.__importDefault(e(97599)),_=e(80732),s=e(44692);t.WHITE_SPACE_TEXT=" ";const g=({mentionItems:l=[],onSend:h,onStop:u,loading:d=!1,mentionKeyword:E=s.MENTION_KEYWORD,onSelectionChange:f,onImageUpload:a,labelService:b,workspaceService:y,placeholder:A="Ask anything, @ to mention",footerConfig:S={buttons:[],showModelSelector:!1}})=>{const w=o.useRef(null),[T,D]=o.useState({active:!1,startPos:null,filter:"",position:{top:0,left:0},activeIndex:0,level:0,parentType:null,secondLevelFilter:"",inlineSearchActive:!1,inlineSearchStartPos:null,loading:!1}),[I,O]=o.useState(S.defaultModel||""),[M,R]=o.useState({}),[P,k]=o.useState([]),[F,L]=o.useState(-1),[B,j]=o.useState(""),[W,U]=o.useState(!1),Q=()=>T.level===0?l:T.parentType?T.loading?M[T.parentType]||[]:M[T.parentType]||[]:[],$=((Ee,_e)=>{const[ne,ge]=o.useState(Ee);return o.useEffect(()=>{const we=setTimeout(()=>{ge(Ee)},_e);return()=>{clearTimeout(we)}},[Ee,_e]),ne})(T.secondLevelFilter,300);o.useEffect(()=>{if(T.level===1&&T.parentType&&$!==void 0){const Ee=l.find(ne=>ne.id===T.parentType);if(!Ee)return;D(ne=>({...ne,loading:!0})),(async()=>{try{const ne=[];if(Ee.getHighestLevelItems){const ge=Ee.getHighestLevelItems();for(const we of ge)ne.some(Pe=>Pe.id===we.id)||ne.push(we);R(we=>({...we,[T.parentType]:ge}))}if(Ee.getItems)try{const ge=await Ee.getItems($),we=[...ne];for(const Pe of ge)we.some(Ae=>Ae.id===Pe.id)||we.push(Pe);R(Pe=>({...Pe,[T.parentType]:we}))}catch{D(we=>({...we,loading:!1}))}D(ge=>({...ge,loading:!1}))}catch{D(ge=>({...ge,loading:!1}))}})()}},[$,T.level,T.parentType]);const Y=Ee=>{const _e=window.getSelection();if(!_e||!_e.rangeCount)return 0;const ne=_e.getRangeAt(0),ge=ne.cloneRange();return ge.selectNodeContents(Ee),ge.setEnd(ne.endContainer,ne.endOffset),ge.toString().length},z=()=>{W&&(U(!1),L(-1));const Ee=window.getSelection();if(!Ee||!Ee.rangeCount||!w.current)return;const _e=w.current.textContent||"",ne=Y(w.current);if(_e[ne-1]===E&&!T.active&&!T.inlineSearchActive&&D({active:!0,startPos:ne,filter:E,position:{top:0,left:0},activeIndex:0,level:0,parentType:null,secondLevelFilter:"",inlineSearchActive:!1,inlineSearchStartPos:null,loading:!1}),T.active&&T.level===0&&T.startPos!==null)if(ne<T.startPos)D(ge=>({...ge,active:!1}));else{const ge=_e.substring(T.startPos-1,ne);D(we=>({...we,filter:ge,activeIndex:0}))}if(T.inlineSearchActive&&T.inlineSearchStartPos!==null&&T.parentType){const ge=l.find(Ae=>Ae.id===T.parentType);if(!ge)return;const we=`@${ge.type}:`,Pe=T.inlineSearchStartPos-we.length;if(Pe>=0&&ne>Pe+we.length){const Ae=_e.substring(Pe+we.length,ne);Ae!==T.secondLevelFilter&&D(Te=>({...Te,secondLevelFilter:Ae,active:!0,activeIndex:0}))}else ne<=Pe&&D(Ae=>({...Ae,inlineSearchActive:!1,active:!1}))}if(w.current&&(w.current.scrollHeight>120?w.current.style.overflowY="auto":w.current.style.overflowY="hidden"),w.current){const ge=w.current.innerHTML;(ge===""||ge==="<br>"||ge==="<br/>")&&(w.current.innerHTML="")}},H=Ee=>{if(Ee.key==="Escape"&&(T.active||T.inlineSearchActive)){T.level>0?D(ne=>({...ne,level:0,activeIndex:0,secondLevelFilter:"",inlineSearchActive:!1})):D(ne=>({...ne,active:!1,inlineSearchActive:!1})),Ee.preventDefault();return}if(Ee.key===s.MENTION_KEYWORD&&!T.active&&!T.inlineSearchActive&&w.current){const ne=Y(w.current);D({active:!0,startPos:ne+1,filter:E,position:{top:0,left:0},activeIndex:0,level:0,parentType:null,secondLevelFilter:"",inlineSearchActive:!1,inlineSearchStartPos:null,loading:!1})}if((Ee.key==="ArrowUp"||Ee.key==="ArrowDown")&&!Ee.shiftKey&&!Ee.ctrlKey&&!Ee.metaKey&&!Ee.altKey){if(!T.active&&!T.inlineSearchActive&&w.current&&P.length>0){const ne=w.current.innerHTML;if(!ne||ne==="<br>"||W&&F>=0&&P[P.length-1-F]===ne){Ee.preventDefault(),W||(j(ne),U(!0));let we=F;Ee.key==="ArrowUp"?we=Math.min(P.length-1,F+1):we=Math.max(-1,F-1),L(we),we===-1?w.current.innerHTML=B:w.current.innerHTML=P[P.length-1-we];const Pe=document.createRange();Pe.selectNodeContents(w.current),Pe.collapse(!1);const Ae=window.getSelection();Ae&&(Ae.removeAllRanges(),Ae.addRange(Pe));return}}}else W&&Ee.key!=="ArrowUp"&&Ee.key!=="ArrowDown"&&(U(!1),L(-1));if(Ee.key==="Enter"){if(Ee.nativeEvent.isComposing)return;if(!Ee.shiftKey&&(Ee.preventDefault(),!T.active)){le();return}}if(!T.active)return;let _e=Q();if(T.level===0&&T.filter&&T.filter.length>1){const ne=T.filter.substring(1).toLowerCase();_e=_e.filter(ge=>ge.text.toLowerCase().includes(ne))}_e.length!==0&&(Ee.key==="ArrowDown"?(D(ne=>({...ne,activeIndex:(ne.activeIndex+1)%_e.length})),Ee.preventDefault()):Ee.key==="ArrowUp"?(D(ne=>({...ne,activeIndex:(ne.activeIndex-1+_e.length)%_e.length})),Ee.preventDefault()):(Ee.key==="Enter"||Ee.key==="Tab")&&_e.length>0&&(ie(_e[T.activeIndex]),Ee.preventDefault()))},K=()=>{},Z=async Ee=>{const _e=Ee.clipboardData.items,ne=[];for(let me=0;me<_e.length;me++)if(_e[me].kind==="file"&&_e[me].type.startsWith("image/")){const xe=_e[me].getAsFile();xe&&ne.push(xe)}if(Ee.preventDefault(),ne.length>0&&a){await a(ne);return}const we=Ee.clipboardData.getData("text/plain").replace(/\t/g," ").replace(/\n\s*\n/g,`
|
|
31280
|
+
`),P=R[R.length-1],k=[{condition:P.includes("`"),action:d},{condition:P.includes("**"),action:y},{condition:P.match(/\*\w/),action:E},{condition:P.match(/(^|\s)__\w/),action:A},{condition:P.match(/(^|\s)_\w/),action:f},{condition:P.match(/(^|\s)\[.*\]\(\w*/),action:a},{condition:P.match(/(^|\s)\[\w/),action:b}];for(const F of k)if(F.condition)return F.action(I)}}},49601:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatMentionInput=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(46541),c=e(41869),p=e(81878),v=e(43718),m=e(92323),_=e(54414),s=e(47720),g=e(72665),l=e(51500),h=e(19413),u=e(27397),d=n.__importDefault(e(6960)),E=e(96086),f=e(44692),a=y=>{const{onSend:A,disabled:S=!1}=y,[w,T]=(0,r.useState)(y.value||""),[D,I]=(0,r.useState)(y.images||[]),O=(0,c.useInjectable)(h.IChatInternalService),M=(0,c.useInjectable)(m.CommandService),R=(0,c.useInjectable)(s.FileSearchServicePath),P=(0,c.useInjectable)(c.RecentFilesManager),k=(0,c.useInjectable)(l.IWorkspaceService),F=(0,c.useInjectable)(_.WorkbenchEditorService),L=(0,c.useInjectable)(c.LabelService),B=(0,c.useInjectable)(g.IMessageService),j=(0,c.useInjectable)(v.ChatFeatureRegistryToken),W=r.default.useCallback(()=>{M.executeCommand(u.OPEN_MCP_CONFIG_COMMAND.id)},[M]);(0,r.useEffect)(()=>{y.value!==w&&T(y.value||"")},[y.value]);const U=[{id:f.MentionType.FILE,type:f.MentionType.FILE,text:"File",icon:(0,p.getIcon)("file"),getHighestLevelItems:()=>{const H=F.currentEditor,K=H?.currentUri;return K?[{id:K.codeUri.fsPath,type:f.MentionType.FILE,text:K.displayName,value:K.codeUri.fsPath,description:`(${(0,v.localize)("aiNative.chat.defaultContextFile")})`,contextId:K.codeUri.fsPath,icon:L.getIcon(K)}]:[]},getItems:async H=>{if(H){const K=(await k.roots).map(X=>new v.URI(X.uri).codeUri.fsPath.toString()),Z=await R.find(H,{rootUris:K,useGitIgnore:!0,noIgnoreParent:!0,fuzzyMatch:!0,limit:10});return Promise.all(Z.map(async X=>{var ie;const oe=new v.URI(X),le=(ie=await k.asRelativePath(oe.parent))===null||ie===void 0?void 0:ie.path;return{id:oe.codeUri.fsPath,type:f.MentionType.FILE,text:oe.displayName,value:oe.codeUri.fsPath,description:le||"",contextId:oe.codeUri.fsPath,icon:L.getIcon(oe)}}))}else{const K=await P.getMostRecentlyOpenedFiles();return Promise.all(K.map(async Z=>{var X;const ie=new v.URI(Z),oe=(X=await k.asRelativePath(ie.parent))===null||X===void 0?void 0:X.path;return{id:ie.codeUri.fsPath,type:f.MentionType.FILE,text:ie.displayName,value:ie.codeUri.fsPath,description:oe||"",contextId:ie.codeUri.fsPath,icon:L.getIcon(ie)}}))}}},{id:f.MentionType.FOLDER,type:f.MentionType.FOLDER,text:"Folder",icon:(0,p.getIcon)("folder"),getHighestLevelItems:()=>{var H,K;const Z=F.currentEditor,X=(H=Z?.currentUri)===null||H===void 0?void 0:H.parent;return X?X.toString()===((K=k.workspace)===null||K===void 0?void 0:K.uri)?[]:[{id:X.codeUri.fsPath,type:f.MentionType.FOLDER,text:X.displayName,value:X.codeUri.fsPath,description:`(${(0,v.localize)("aiNative.chat.defaultContextFolder")})`,contextId:X.codeUri.fsPath,icon:(0,p.getIcon)("folder")}]:[]},getItems:async H=>{let K=[];if(H){const Z=(await k.roots).map(oe=>new v.URI(oe.uri).codeUri.fsPath.toString()),X=await R.find(H,{rootUris:Z,useGitIgnore:!0,noIgnoreParent:!0,fuzzyMatch:!0,excludePatterns:["**/node_modules/**/*","**/.git/**/*"],limit:10}),ie=Array.from(new Set(X.map(oe=>new v.URI(oe).parent.toString()).filter(oe=>{var le;return oe!==((le=k.workspace)===null||le===void 0?void 0:le.uri.toString())})));return Promise.all(ie.map(async oe=>{var le;const pe=new v.URI(oe);return{id:pe.codeUri.fsPath,type:f.MentionType.FOLDER,text:pe.displayName,value:pe.codeUri.fsPath,description:((le=await k.asRelativePath(pe.parent))===null||le===void 0?void 0:le.path)||"",contextId:pe.codeUri.fsPath,icon:(0,p.getIcon)("folder")}}))}else{const Z=await P.getMostRecentlyOpenedFiles(),X=Array.from(new Set(Z.map(ie=>new v.URI(ie).parent.codeUri.fsPath)));K=await Promise.all(X.map(async ie=>{const oe=new v.URI(ie),le=await k.asRelativePath(oe);return{id:oe.codeUri.fsPath,type:f.MentionType.FOLDER,text:oe.displayName,value:oe.codeUri.fsPath,description:le?.root?le.path:"",contextId:oe.codeUri.fsPath,icon:(0,p.getIcon)("folder")}}))}return K.filter(Z=>{var X;return Z.id!==new v.URI((X=k.workspace)===null||X===void 0?void 0:X.uri).codeUri.fsPath})}}],Q=(0,r.useMemo)(()=>({modelOptions:[{label:"QWQ 32B",value:"qwq-32b"},{label:"DeepSeek R1",value:"deepseek-r1"}],defaultModel:"deepseek-r1",buttons:[{id:"mcp-server",icon:"mcp",title:"MCP Server",onClick:W,position:f.FooterButtonPosition.LEFT},{id:"upload-image",icon:"image",title:(0,v.localize)("aiNative.chat.imageUpload"),onClick:()=>{const H=document.createElement("input");H.type="file",H.accept="image/*",H.onchange=K=>{const Z=K.target.files;Z?.length&&Y(Array.from(Z))},H.click()},position:f.FooterButtonPosition.LEFT}],showModelSelector:!0,disableModelSelector:y.disableModelSelector}),[W,y.disableModelSelector]),V=(0,r.useCallback)(()=>{O.cancelRequest()},[]),$=(0,r.useCallback)(async(H,K)=>{S||(A(H,D.map(Z=>Z.toString()),void 0,void 0,K),I(y.images||[]))},[A,D,S]),Y=(0,r.useCallback)(async H=>{const K=["image/jpeg","image/jpg","image/png","image/webp","image/gif"];if(H.filter(le=>!K.includes(le.type)).length>0){B.error("Only JPG, PNG, WebP and GIF images are supported");return}const X=j.getImageUploadProvider();if(!X){B.error("No image upload provider found");return}const ie=await Promise.all(H.map(le=>X.imageUpload(le))),oe=[...D,...ie];I(oe)},[D]),z=(0,r.useCallback)(H=>{I(D.filter((K,Z)=>Z!==H))},[D]);return r.default.createElement("div",{className:d.default.chat_input_container},D.length>0&&r.default.createElement(b,{images:D,onDelete:z}),r.default.createElement(E.MentionInput,{mentionItems:U,onSend:$,onStop:V,loading:S,labelService:L,workspaceService:k,placeholder:(0,v.localize)("aiNative.chat.input.placeholder.default"),footerConfig:Q,onImageUpload:Y}))};t.ChatMentionInput=a;const b=({images:y,onDelete:A})=>r.default.createElement("div",null,r.default.createElement("div",{className:d.default.thumbnail_container},y.map((S,w)=>r.default.createElement("div",{key:w,className:d.default.thumbnail},r.default.createElement(o.Image,{src:S.toString()}),r.default.createElement("button",{onClick:()=>A(w),className:d.default.delete_button},r.default.createElement(p.Icon,{iconClass:"codicon codicon-close"}))))))},92635:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatNotify=t.ChatReply=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),c=e(48412),p=e(91416),v=e(78569),m=e(72871),_=e(41869),s=e(81878),g=e(89195),l=e(43718),h=e(52416),u=e(90684),d=e(19413),E=e(56474),f=e(17319),a=n.__importDefault(e(6960)),b=T=>{const D=(0,_.useInjectable)(_.LabelService),I=(0,_.useInjectable)(_.CommandService),O=(L,B,j)=>{let W=D.getIcon(L,{isDirectory:B});return B&&j&&(W+=" expanded"),W},M=(0,o.useMemo)(()=>{const L=B=>{const j=typeof B.type=="number"?B.type===l.FileType.Directory:!!B.children,W=new l.URI(B.uri);return{label:B.label,iconClassName:O(W,j,j),expandable:!0,expanded:!0,children:j?(B.children||[]).map(L):null,uri:W}};return(T.treeData.children||[]).map(L)},[T.treeData]),[R,P]=(0,o.useState)(22),k=(0,o.useRef)(null),F=L=>{k.current=L;const B=()=>{let j=L.getModel().root.branchSize;j<1?j=1:j>20&&(j=20),P(j*22)};B(),L.onDidUpdate(B)};return M.length?o.default.createElement("div",{className:a.default.tree_container},o.default.createElement(p.BasicRecycleTree,{height:R,treeData:M,onContextMenu:L=>L.preventDefault(),onClick:(L,B)=>{!k.current||!B||(v.BasicCompositeTreeNode.is(B)?B.raw.iconClassName=O(B.raw.uri,!0,B.expanded):I.executeCommand(_.EDITOR_COMMANDS.OPEN_RESOURCE.id,B.raw.uri,{disableNavigate:!0,preview:!0}))},onReady:F,treeName:T.treeData.label,leaveBottomBlank:!1,baseIndent:0})):null},y=T=>{const{toolCall:D,messageId:I}=T,O=(0,_.useInjectable)(l.ChatAgentViewServiceToken),[M,R]=(0,o.useState)(null);return(0,o.useEffect)(()=>{const P=O.getChatComponent("toolCall");if(P){const{component:F,initialProps:L}=P;R(o.default.createElement(F,{...L,value:D,messageId:I}));return}R(o.default.createElement("div",null,o.default.createElement(g.Loading,null),o.default.createElement("span",{style:{marginLeft:4}},"\u6B63\u5728\u52A0\u8F7D\u7EC4\u4EF6"))),O.getChatComponentDeferred("toolCall").promise.then(({component:F,initialProps:L})=>{R(o.default.createElement(F,{...L,value:D,messageId:I}))})},[D.state]),M},A=T=>{const D=(0,_.useInjectable)(l.ChatAgentViewServiceToken),[I,O]=(0,o.useState)(null);return(0,o.useEffect)(()=>{const M=D.getChatComponent(T.component);if(M){const{component:P,initialProps:k}=M;O(o.default.createElement(P,{...k,value:T.value,messageId:T.messageId}));return}O(o.default.createElement("div",null,o.default.createElement(g.Loading,null),o.default.createElement("span",{style:{marginLeft:4}},"\u6B63\u5728\u52A0\u8F7D\u7EC4\u4EF6"))),D.getChatComponentDeferred(T.component).promise.then(({component:P,initialProps:k})=>{O(o.default.createElement(P,{...k,value:T.value}))})},[T.component,T.value]),I},S=T=>{var D,I;const{relationId:O,request:M,startTime:R=0,onRegenerate:P,onDidChange:k,onDone:F,agentId:L,command:B,history:j,msgId:W}=T,[,U]=(0,o.useReducer)(_e=>(_e+1)%1e6,0),Q=(0,_.useInjectable)(l.IAIReporter),V=(0,_.useInjectable)(h.IIconService),$=(0,_.useInjectable)(_.IContextKeyService),Y=(0,_.useInjectable)(d.IChatInternalService),z=(0,_.useInjectable)(l.ChatServiceToken),H=(0,_.useInjectable)(d.IChatAgentService),K=(0,_.useInjectable)(l.ChatRenderRegistryToken),[Z,X]=(0,o.useState)(M.response.isComplete?new Set(M.response.responseContents.map((_e,ne)=>_e.kind==="reasoning"?ne:-1).filter(_e=>_e!==-1)):new Set);(0,o.useEffect)(()=>{M.response.isComplete&&X(new Set(M.response.responseContents.map((_e,ne)=>_e.kind==="reasoning"?ne:-1).filter(_e=>_e!==-1)))},[M.response.isComplete]),(0,o.useEffect)(()=>{const _e=new _.DisposableCollection;return _e.push(M.response.onDidChange(()=>{j.updateAssistantMessage(W,{content:M.response.responseText}),M.response.isComplete&&(F&&F(),Q.end(O,{assistantMessage:M.response.responseText,replytime:Date.now()-R,success:!0,isStop:!1,command:B,agentId:L,messageId:W,sessionId:Y.sessionModel.sessionId})),(0,o.startTransition)(()=>{k?.(),U()})})),()=>_e.dispose()},[O,k,F]);const ie=(0,o.useCallback)(()=>{M.response.reset(),P?.()},[P]),oe=(0,o.useCallback)(_e=>{if(K.chatAIRoleRender){const ne=K.chatAIRoleRender;return o.default.createElement(ne,{content:_e.value})}return o.default.createElement(E.ChatMarkdown,{markdown:_e,fillInIncompleteTokens:!0})},[K,K.chatAIRoleRender]),le=_e=>o.default.createElement(b,{treeData:_e}),pe=_e=>o.default.createElement("div",{className:a.default.placeholder},o.default.createElement(s.Icon,{iconClass:V.fromString("$(codicon/sync~spin)")}),o.default.createElement("div",{className:a.default.placeholder_content},oe(_e))),q=o.default.useMemo(()=>M.response.responseContents.map((_e,ne)=>{let ge;if(_e.kind==="asyncContent")ge=pe(new u.MarkdownString(_e.content));else if(_e.kind==="treeData")ge=le(_e.treeData);else if(_e.kind==="component")ge=o.default.createElement(A,{component:_e.component,value:_e.value,messageId:W});else if(_e.kind==="toolCall")ge=o.default.createElement(y,{toolCall:_e.content,messageId:W});else if(_e.kind==="reasoning"){const we=ne===M.response.responseContents.length-1&&!M.response.isComplete;ge=o.default.createElement("div",{className:(0,r.default)(a.default.reasoning,{[a.default.thinking]:we})},o.default.createElement(c.Button,{size:"small",type:"secondary",className:a.default.thinking,onClick:()=>{we||(Z.has(ne)?Z.delete(ne):Z.add(ne),X(new Set(Z)))}},o.default.createElement(s.Icon,{iconClass:"codicon codicon-sparkle"}),(0,l.localize)("aiNative.chat.thinking"),we?o.default.createElement(g.Loading,null):Z.has(ne)?o.default.createElement(s.Icon,{iconClass:"codicon codicon-chevron-right"}):o.default.createElement(s.Icon,{iconClass:"codicon codicon-chevron-down"})),Z.has(ne)?null:o.default.createElement("div",{className:a.default.reasoning_content},oe(new u.MarkdownString(_e.content))))}else ge=oe(_e.content);return o.default.createElement(o.Fragment,{key:`${_e.kind}-${ne}`},ge)}),[M.response.responseContents,Z]),Ee=o.default.useMemo(()=>M.response.followups?M.response.followups.map((_e,ne)=>{let ge=null;if(_e.kind==="reply"){const we=o.default.createElement("a",{onClick:()=>{z.sendMessage({...H.parseMessage(_e.message),reportExtra:{actionSource:l.ActionSourceEnum.Chat,actionType:l.ActionTypeEnum.Followup}})}},_e.title||_e.message);ge=_e.tooltip?o.default.createElement(m.Tooltip,{title:_e.tooltip},we):we}else _e.when&&!$.match(_e.when)&&(ge=null),ge=o.default.createElement(c.Button,{type:"default"},_e.title);return ge&&o.default.createElement(o.Fragment,{key:ne},ge)}):null,[M.response.followups]);return M.response.isComplete?o.default.createElement(f.ChatThinkingResult,{hasMessage:M.response.responseParts.length>0||M.response.responseContents.length>0||!!(!((D=M.response.errorDetails)===null||D===void 0)&&D.message),onRegenerate:ie,requestId:M.requestId},o.default.createElement("div",{className:a.default.ai_chat_response_container},!((I=M.response.errorDetails)===null||I===void 0)&&I.message?o.default.createElement("div",{className:a.default.error},o.default.createElement(s.Icon,{className:(0,s.getIcon)("close-circle")}),o.default.createElement("span",null,M.response.errorDetails.message)):o.default.createElement(o.default.Fragment,null,q,Ee?.length!==0&&o.default.createElement("div",{className:a.default.followups},Ee)))):o.default.createElement(f.ChatThinking,{message:M.response.responseText},q)};t.ChatReply=S;const w=T=>{const{chunk:D}=T,I=(0,_.useInjectable)(l.ChatRenderRegistryToken),O=o.default.useMemo(()=>{let M;if(D.kind==="component")M=o.default.createElement(A,{component:D.component,value:D.value});else{let R=o.default.createElement(E.ChatMarkdown,{markdown:D.content,fillInIncompleteTokens:!0});if(I.chatAIRoleRender){const P=I.chatAIRoleRender;R=o.default.createElement(P,{content:D.content})}M=R}return M},[D]);return o.default.createElement(f.ChatThinkingResult,{hasMessage:!0,requestId:T.requestId,showRegenerate:!1},o.default.createElement("div",{className:a.default.ai_chat_response_container},O))};t.ChatNotify=w},17319:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatThinkingResult=t.ChatThinking=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(41869),c=e(89195),p=e(68974),v=e(43718),m=e(19413),_=n.__importDefault(e(6960)),s=l=>{const{children:h,message:u,thinkingText:d}=l,E=(0,o.useInjectable)(v.ChatRenderRegistryToken),f=(0,r.useMemo)(()=>E.chatThinkingRender,[E,E.chatThinkingRender]),a=(0,r.useMemo)(()=>Array.isArray(h)?h.length===0:!h,[h]),b=(0,r.useCallback)(()=>a?f?r.default.createElement(f,{thinkingText:d}):r.default.createElement("span",{className:_.default.thinking_text},d||"Thinking..."):h,[u,h,d,f]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{className:_.default.content},b()),r.default.createElement("div",{className:_.default.thinking_container},r.default.createElement("div",{className:_.default.stop},!f&&r.default.createElement("span",{className:_.default.progress_bar},a&&r.default.createElement(p.Progress,{loading:!0,wrapperClassName:_.default.ai_native_progress_wrapper})))))};t.ChatThinking=s;const g=({children:l,message:h,onRegenerate:u,requestId:d,hasMessage:E=!0,showRegenerate:f})=>{const a=(0,o.useInjectable)(m.IChatInternalService),[b,y]=(0,r.useState)(a.latestRequestId),A=(0,o.useInjectable)(v.ChatRenderRegistryToken);(0,r.useEffect)(()=>{const I=a.onChangeRequestId(O=>{y(O)});return()=>I.dispose()},[a]);const S=(0,r.useMemo)(()=>A.chatThinkingResultRender,[A,A.chatThinkingResultRender]),w=(0,r.useCallback)(()=>{u&&u()},[u]),T=(0,r.useCallback)(()=>{if(typeof E=="boolean"?!E:!h?.trim()){const I=(0,v.localize)("aiNative.chat.stop.immediately");return S?r.default.createElement(S,{thinkingResult:I}):r.default.createElement("span",null,I)}return l},[h,E,l]),D=(0,r.useMemo)(()=>(0,v.isUndefined)(f)?b===d&&!!d:!!f,[b,d,f]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{className:_.default.content},T()),r.default.createElement("div",{className:_.default.thinking_container},r.default.createElement("div",{className:_.default.bottom_container},r.default.createElement("div",{className:_.default.reset},D?r.default.createElement(c.EnhanceIcon,{icon:"refresh",wrapperClassName:_.default.text_btn,className:_.default.transform,onClick:w,tabIndex:0,role:"button"},r.default.createElement("span",null,(0,v.localize)("aiNative.operate.afresh.title"))):null),r.default.createElement("div",{className:_.default.thumbs},r.default.createElement(c.Thumbs,{relationId:d,wrapperClassName:_.default.icon_btn})))))};t.ChatThinkingResult=g},34817:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatToolRender=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),c=e(41869),p=e(81878),v=e(89195),m=e(43718),_=e(33783),s=e(77633),g=e(25834),l=n.__importDefault(e(16796)),h=u=>{var d,E,f;const{value:a,messageId:b}=u,[y,A]=(0,o.useState)(!1),S=(0,c.useInjectable)(s.TokenMCPServerRegistry);if(!a||!a.function||!a.id)return null;const w=((d=S.getMCPTool(a.function.name))===null||d===void 0?void 0:d.label)||a.function.name,T=S.getToolComponent(a.function.name),D=R=>{switch(R){case"streaming-start":case"streaming":return{label:"Generating",icon:o.default.createElement(v.Loading,null)};case"complete":return{label:"Complete",icon:o.default.createElement(p.Icon,{iconClass:"codicon codicon-check"})};case"result":return{label:"Result Ready",icon:o.default.createElement(p.Icon,{iconClass:"codicon codicon-check-all"})};default:return{label:R||"Unknown",icon:o.default.createElement(p.Icon,{iconClass:"codicon codicon-question"})}}},I=()=>{var R;try{return a.state!=="complete"&&a.state!=="result"?{}:JSON.parse(((R=a.function)===null||R===void 0?void 0:R.arguments)||"{}")}catch{return{}}},O=()=>{A(!y)},M=D(a.state);return T&&(a.state==="complete"||a.state==="result")?o.default.createElement(T,{state:a.state,args:I(),result:a.result,index:a.index,messageId:b,toolCallId:a.id}):o.default.createElement("div",{className:l.default.chat_tool_render},o.default.createElement("div",{className:l.default.tool_header,onClick:O},o.default.createElement("div",{className:l.default.tool_name},o.default.createElement(p.Icon,{iconClass:`codicon codicon-chevron-${y?"down":"right"}`}),o.default.createElement(p.Icon,{size:"small",iconClass:(0,r.default)("codicon codicon-tools",l.default.tool_icon)}),o.default.createElement("span",{className:l.default.tool_label},w)),a.state&&o.default.createElement("div",{className:l.default.tool_state},o.default.createElement("span",{className:l.default.state_icon},M.icon))),o.default.createElement("div",{className:(0,r.default)(l.default.tool_content,{[l.default.expanded]:y})},((E=a?.function)===null||E===void 0?void 0:E.arguments)&&o.default.createElement("div",{className:l.default.tool_arguments},o.default.createElement("div",{className:l.default.section_label},(0,_.localize)("ai.native.mcp.tool.arguments"),":"),o.default.createElement(g.CodeEditorWithHighlight,{input:(f=a?.function)===null||f===void 0?void 0:f.arguments,language:"json",relationId:(0,m.uuid)(4)})),a?.result&&o.default.createElement("div",{className:l.default.tool_result},o.default.createElement("div",{className:l.default.section_label},(0,_.localize)("ai.native.mcp.tool.results"),":"),o.default.createElement(g.CodeEditorWithHighlight,{input:a.result,language:"json",relationId:(0,m.uuid)(4)}))))};t.ChatToolRender=h},29039:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SlashCustomRender=void 0;const r=e(85608).__importStar(e(14041)),o=e(41869),c=e(43718),p=e(19413),v=m=>{const{userMessage:_,relationId:s,requestId:g,renderContent:l,startTime:h,agentId:u,command:d}=m,E=(0,o.useInjectable)(p.IChatInternalService),f=(0,o.useInjectable)(c.IAIReporter);return r.useEffect(()=>{E.setLatestRequestId(g),f.end(s,{message:_,replytime:Date.now()-h,success:!0,isStop:!1,agentId:u,command:d})},[l,g,s]),r.createElement("div",null,l({userMessage:_}))};t.SlashCustomRender=v},86556:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WelcomeMessage=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(41869),c=e(81878),p=e(4246),v=e(43718),m=e(90684);e(41937);const _=e(19413),s=e(56474),g=e(17319),l=e(78048),h=n.__importDefault(e(6960)),u=()=>{var d,E;const f=(0,o.useInjectable)(v.ChatServiceToken),a=(0,o.useInjectable)(_.IChatAgentService),b=(0,o.useInjectable)(v.ChatFeatureRegistryToken),y=(0,o.useInjectable)(v.ChatRenderRegistryToken),[A,S]=r.useState([]);(0,o.useUpdateOnEvent)(b.onDidWelcomeMessageChange);const w=r.useMemo(()=>{if(!b.chatWelcomeMessageModel)return[];const{sampleQuestions:O=[]}=b.chatWelcomeMessageModel;return O.map(l.extractIcon)},[(d=b.chatWelcomeMessageModel)===null||d===void 0?void 0:d.sampleQuestions]),T=r.useMemo(()=>{if(!b.chatWelcomeMessageModel)return"";const{content:O}=b.chatWelcomeMessageModel;return O},[(E=b.chatWelcomeMessageModel)===null||E===void 0?void 0:E.content]);if(r.useEffect(()=>{const O=a.onDidChangeAgents(async()=>{const R=(await a.getAllSampleQuestions()).map(l.extractIcon);S(R)});return()=>O.dispose()},[]),!T)return r.createElement(g.ChatThinking,{thinkingText:(0,v.localize)("aiNative.chat.welcome.loading.text")});const D=r.useMemo(()=>w.concat(A),[w,A]);return r.useMemo(()=>{if(y.chatWelcomeRender){const O=y.chatWelcomeRender;return r.createElement(O,{message:T,sampleQuestions:D})}return r.createElement("div",{className:h.default.chat_welcome_head},r.createElement("div",{className:h.default.chat_container_des},(0,m.isMarkdownString)(T)?r.createElement(s.ChatMarkdown,{key:"welcome",markdown:T}):T),r.createElement("div",{className:h.default.chat_container_content},D.map((O,M)=>{const R=r.createElement("a",{className:h.default.link_item,onClick:(0,p.withPrevented)(()=>{f.sendMessage({...a.parseMessage(O.message),reportExtra:{actionType:v.ActionTypeEnum.Welcome,actionSource:v.ActionSourceEnum.Chat}})})},O.icon?r.createElement(c.Icon,{className:O.icon,style:{color:"inherit",marginRight:"4px"}}):"",r.createElement("span",null,O.title));return O.tooltip?r.createElement(c.Tooltip,{title:O.tooltip,key:M},R):r.createElement(r.Fragment,{key:M},R)})))},[y.chatWelcomeRender,T,D])};t.WelcomeMessage=u},83933:(x,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.highLightLanguageSupport=void 0,t.highLightLanguageSupport=["1c","abnf","accesslog","actionscript","ada","angelscript","apache","applescript","arcade","arduino","armasm","xml","asciidoc","aspectj","autohotkey","autoit","avrasm","awk","axapta","bash","basic","bnf","brainfuck","c-like","c","cal","capnproto","ceylon","clean","clojure","clojure-repl","cmake","coffeescript","coq","cos","cpp","crmsh","crystal","csharp","csp","css","d","markdown","dart","delphi","diff","django","dns","dockerfile","dos","dsconfig","dts","dust","ebnf","elixir","elm","ruby","erb","erlang-repl","erlang","excel","fix","flix","fortran","fsharp","gams","gauss","gcode","gherkin","glsl","gml","go","golo","gradle","groovy","haml","handlebars","haskell","haxe","hsp","htmlbars","http","hy","inform7","ini","irpf90","isbl","java","javascript","jboss-cli","json","julia","julia-repl","kotlin","lasso","latex","ldif","leaf","less","lisp","livecodeserver","livescript","llvm","lsl","lua","makefile","mathematica","matlab","maxima","mel","mercury","mipsasm","mizar","perl","mojolicious","monkey","moonscript","n1ql","nginx","nim","nix","node-repl","nsis","objectivec","ocaml","openscad","oxygene","parser3","pf","pgsql","php","php-template","plaintext","pony","powershell","processing","profile","prolog","properties","protobuf","puppet","purebasic","python","python-repl","q","qml","r","reasonml","rib","roboconf","routeros","rsl","ruleslanguage","rust","sas","scala","scheme","scilab","scss","shell","smali","smalltalk","sml","sqf","sql_more","sql","stan","stata","step21","stylus","subunit","swift","taggerscript","yaml","tap","tcl","thrift","tp","twig","typescript","vala","vbnet","vbscript","vbscript-html","verilog","vhdl","vim","x86asm","xl","xquery","zephir"]},96086:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MentionInput=t.WHITE_SPACE_TEXT=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),c=e(81878),p=e(89195),v=e(70392),m=n.__importDefault(e(97599)),_=e(80732),s=e(44692);t.WHITE_SPACE_TEXT=" ";const g=({mentionItems:l=[],onSend:h,onStop:u,loading:d=!1,mentionKeyword:E=s.MENTION_KEYWORD,onSelectionChange:f,onImageUpload:a,labelService:b,workspaceService:y,placeholder:A="Ask anything, @ to mention",footerConfig:S={buttons:[],showModelSelector:!1}})=>{const w=o.useRef(null),[T,D]=o.useState({active:!1,startPos:null,filter:"",position:{top:0,left:0},activeIndex:0,level:0,parentType:null,secondLevelFilter:"",inlineSearchActive:!1,inlineSearchStartPos:null,loading:!1}),[I,O]=o.useState(S.defaultModel||""),[M,R]=o.useState({}),[P,k]=o.useState([]),[F,L]=o.useState(-1),[B,j]=o.useState(""),[W,U]=o.useState(!1),Q=()=>T.level===0?l:T.parentType?T.loading?M[T.parentType]||[]:M[T.parentType]||[]:[],$=((Ee,_e)=>{const[ne,ge]=o.useState(Ee);return o.useEffect(()=>{const we=setTimeout(()=>{ge(Ee)},_e);return()=>{clearTimeout(we)}},[Ee,_e]),ne})(T.secondLevelFilter,300);o.useEffect(()=>{if(T.level===1&&T.parentType&&$!==void 0){const Ee=l.find(ne=>ne.id===T.parentType);if(!Ee)return;D(ne=>({...ne,loading:!0})),(async()=>{try{const ne=[];if(Ee.getHighestLevelItems){const ge=Ee.getHighestLevelItems();for(const we of ge)ne.some(Pe=>Pe.id===we.id)||ne.push(we);R(we=>({...we,[T.parentType]:ge}))}if(Ee.getItems)try{const ge=await Ee.getItems($),we=[...ne];for(const Pe of ge)we.some(Ae=>Ae.id===Pe.id)||we.push(Pe);R(Pe=>({...Pe,[T.parentType]:we}))}catch{D(we=>({...we,loading:!1}))}D(ge=>({...ge,loading:!1}))}catch{D(ge=>({...ge,loading:!1}))}})()}},[$,T.level,T.parentType]);const Y=Ee=>{const _e=window.getSelection();if(!_e||!_e.rangeCount)return 0;const ne=_e.getRangeAt(0),ge=ne.cloneRange();return ge.selectNodeContents(Ee),ge.setEnd(ne.endContainer,ne.endOffset),ge.toString().length},z=()=>{W&&(U(!1),L(-1));const Ee=window.getSelection();if(!Ee||!Ee.rangeCount||!w.current)return;const _e=w.current.textContent||"",ne=Y(w.current);if(_e[ne-1]===E&&!T.active&&!T.inlineSearchActive&&D({active:!0,startPos:ne,filter:E,position:{top:0,left:0},activeIndex:0,level:0,parentType:null,secondLevelFilter:"",inlineSearchActive:!1,inlineSearchStartPos:null,loading:!1}),T.active&&T.level===0&&T.startPos!==null)if(ne<T.startPos)D(ge=>({...ge,active:!1}));else{const ge=_e.substring(T.startPos-1,ne);D(we=>({...we,filter:ge,activeIndex:0}))}if(T.inlineSearchActive&&T.inlineSearchStartPos!==null&&T.parentType){const ge=l.find(Ae=>Ae.id===T.parentType);if(!ge)return;const we=`@${ge.type}:`,Pe=T.inlineSearchStartPos-we.length;if(Pe>=0&&ne>Pe+we.length){const Ae=_e.substring(Pe+we.length,ne);Ae!==T.secondLevelFilter&&D(Te=>({...Te,secondLevelFilter:Ae,active:!0,activeIndex:0}))}else ne<=Pe&&D(Ae=>({...Ae,inlineSearchActive:!1,active:!1}))}if(w.current&&(w.current.scrollHeight>120?w.current.style.overflowY="auto":w.current.style.overflowY="hidden"),w.current){const ge=w.current.innerHTML;(ge===""||ge==="<br>"||ge==="<br/>")&&(w.current.innerHTML="")}},H=Ee=>{if(Ee.key==="Escape"&&(T.active||T.inlineSearchActive)){T.level>0?D(ne=>({...ne,level:0,activeIndex:0,secondLevelFilter:"",inlineSearchActive:!1})):D(ne=>({...ne,active:!1,inlineSearchActive:!1})),Ee.preventDefault();return}if(Ee.key===s.MENTION_KEYWORD&&!T.active&&!T.inlineSearchActive&&w.current){const ne=Y(w.current);D({active:!0,startPos:ne+1,filter:E,position:{top:0,left:0},activeIndex:0,level:0,parentType:null,secondLevelFilter:"",inlineSearchActive:!1,inlineSearchStartPos:null,loading:!1})}if((Ee.key==="ArrowUp"||Ee.key==="ArrowDown")&&!Ee.shiftKey&&!Ee.ctrlKey&&!Ee.metaKey&&!Ee.altKey){if(!T.active&&!T.inlineSearchActive&&w.current&&P.length>0){const ne=w.current.innerHTML;if(!ne||ne==="<br>"||W&&F>=0&&P[P.length-1-F]===ne){Ee.preventDefault(),W||(j(ne),U(!0));let we=F;Ee.key==="ArrowUp"?we=Math.min(P.length-1,F+1):we=Math.max(-1,F-1),L(we),we===-1?w.current.innerHTML=B:w.current.innerHTML=P[P.length-1-we];const Pe=document.createRange();Pe.selectNodeContents(w.current),Pe.collapse(!1);const Ae=window.getSelection();Ae&&(Ae.removeAllRanges(),Ae.addRange(Pe));return}}}else W&&Ee.key!=="ArrowUp"&&Ee.key!=="ArrowDown"&&(U(!1),L(-1));if(Ee.key==="Enter"){if(Ee.nativeEvent.isComposing)return;if(!Ee.shiftKey&&(Ee.preventDefault(),!T.active)){le();return}}if(!T.active)return;let _e=Q();if(T.level===0&&T.filter&&T.filter.length>1){const ne=T.filter.substring(1).toLowerCase();_e=_e.filter(ge=>ge.text.toLowerCase().includes(ne))}_e.length!==0&&(Ee.key==="ArrowDown"?(D(ne=>({...ne,activeIndex:(ne.activeIndex+1)%_e.length})),Ee.preventDefault()):Ee.key==="ArrowUp"?(D(ne=>({...ne,activeIndex:(ne.activeIndex-1+_e.length)%_e.length})),Ee.preventDefault()):(Ee.key==="Enter"||Ee.key==="Tab")&&_e.length>0&&(ie(_e[T.activeIndex]),Ee.preventDefault()))},K=()=>{},Z=async Ee=>{const _e=Ee.clipboardData.items,ne=[];for(let me=0;me<_e.length;me++)if(_e[me].kind==="file"&&_e[me].type.startsWith("image/")){const xe=_e[me].getAsFile();xe&&ne.push(xe)}if(Ee.preventDefault(),ne.length>0&&a){await a(ne);return}const we=Ee.clipboardData.getData("text/plain").replace(/\t/g," ").replace(/\n\s*\n/g,`
|
|
31271
31281
|
|
|
31272
31282
|
`).replace(/[ \t]+$/gm,""),Pe=window.getSelection();if(!Pe||!Pe.rangeCount)return;const Ae=Pe.getRangeAt(0);Ae.deleteContents();const Te=we.split(`
|
|
31273
|
-
`),be=document.createDocumentFragment();Te.forEach((me,xe)=>{const Re=me.replace(/^[ ]+/g,fe=>{const re=document.createElement("span");return re.innerHTML="\xA0".repeat(fe.length),re.innerHTML}),Ne=document.createElement("span");for(Ne.innerHTML=Re;Ne.firstChild;)be.appendChild(Ne.firstChild);xe<Te.length-1&&be.appendChild(document.createElement("br"))}),Ae.insertNode(be),Ae.setStartAfter(be),Ae.setEndAfter(be),Pe.removeAllRanges(),Pe.addRange(Ae),z()};o.useEffect(()=>{w.current&&A&&!w.current.textContent&&w.current.setAttribute("data-placeholder",A)},[A]);const X=Ee=>{var _e;T.active&&!(!((_e=document.querySelector(`.${m.default.mention_panel}`))===null||_e===void 0)&&_e.contains(Ee.target))&&D(ne=>({...ne,active:!1,inlineSearchActive:!1}))};o.useEffect(()=>(document.addEventListener("click",X,!0),()=>{document.removeEventListener("click",X,!0)}),[T.active]);const ie=(Ee,_e=!1)=>{var ne;if(!w.current)return;if(Ee.getItems){const fe=window.getSelection();if(!fe||!fe.rangeCount)return;if(T.level===0&&T.startPos!==null){let re,he,Oe;const De=document.createTreeWalker(w.current,NodeFilter.SHOW_TEXT);let Fe=0,Ge;for(;Ge=De.nextNode();){const Ve=((ne=Ge.textContent)===null||ne===void 0?void 0:ne.length)||0;if(T.startPos-1>=Fe&&T.startPos-1<Fe+Ve){re=Ge,he=T.startPos-1-Fe;const gt=_e?T.startPos+T.filter.length-1:Y(w.current);Oe=Math.min(gt-Fe,Ve);break}Fe+=Ve}if(re){const Ve=document.createRange();Ve.setStart(re,he),Ve.setEnd(re,Oe),Ve.deleteContents();const gt=document.createTextNode(`${E}${Ee.type}:`);Ve.insertNode(gt);const rt=document.createRange();rt.setStartAfter(gt),rt.setEndAfter(gt),fe.removeAllRanges(),fe.addRange(rt),D(Mt=>({...Mt,active:!0,level:1,parentType:Ee.id,inlineSearchActive:!0,inlineSearchStartPos:Y(w.current),secondLevelFilter:"",activeIndex:0})),w.current.focus();return}}return}const ge=window.getSelection();if(!ge||!ge.rangeCount)return;if(T.inlineSearchActive&&T.parentType&&T.inlineSearchStartPos!==null){const fe=l.find(Oe=>Oe.id===T.parentType);if(!fe)return;const re=`${E}${fe.type}:`,he=T.inlineSearchStartPos-re.length;if(he>=0){let lt=function(yt){if(yt.nodeType===3)Mt.push({node:yt,start:gt,end:gt+yt.textContent.length}),gt+=yt.textContent.length;else if(yt.nodeType===1){const ot=yt.childNodes||[];for(const st of Array.from(ot))lt(st)}};const Oe=document.createElement("span");if(Oe.className=m.default.mention_tag,Oe.dataset.id=Ee.id,Oe.dataset.type=Ee.type,Oe.dataset.contextId=Ee.contextId||"",Oe.contentEditable="false",Ee.type==="file"||Ee.type==="folder"){const yt=document.createElement("span");yt.className=(0,r.default)(m.default.mention_icon,Ee.type==="file"?b?.getIcon(new v.URI(Ee.text)):(0,c.getIcon)("folder")),Oe.appendChild(yt)}const De=y?.workspace;let Fe=Ee.text;De&&Ee.contextId&&(Fe=Ee.contextId.replace(new v.URI(De.uri).codeUri.fsPath,"").slice(1));const Ge=document.createTextNode(Fe);Oe.appendChild(Ge);const Ve=document.createRange();let gt=0,rt=!1;const Mt=[];lt(w.current);for(const yt of Mt){if(he>=yt.start&&he<=yt.end){const ot=he-yt.start;Ve.setStart(yt.node,ot),rt=!0}if(rt){const ot=_e?he+re.length+T.secondLevelFilter.length:Y(w.current);if(ot>=yt.start&&ot<=yt.end){const st=ot-yt.start;Ve.setEnd(yt.node,st);break}}}if(rt){Ve.deleteContents(),Ve.insertNode(Oe);const yt=document.createRange();yt.setStartAfter(Oe),yt.setEndAfter(Oe),ge.removeAllRanges(),ge.addRange(yt);const ot=document.createTextNode("\xA0");yt.insertNode(ot),yt.setStartAfter(ot),yt.setEndAfter(ot),ge.removeAllRanges(),ge.addRange(yt)}D(yt=>({...yt,active:!1,inlineSearchActive:!1})),w.current.focus();return}}const we=document.createElement("span");if(we.className=m.default.mention_tag,we.dataset.id=Ee.id,we.dataset.type=Ee.type,we.dataset.contextId=Ee.contextId||"",we.contentEditable="false",Ee.type==="file"||Ee.type==="folder"){const fe=document.createElement("span");fe.className=(0,r.default)(m.default.mention_icon,Ee.type==="file"?b?.getIcon(new v.URI(Ee.text)):(0,c.getIcon)("folder")),we.appendChild(fe)}const Pe=y?.workspace;let Ae=Ee.text;Pe&&Ee.contextId&&(Ae=Ee.contextId.replace(new v.URI(Pe.uri).codeUri.fsPath,"").slice(1));const Te=document.createTextNode(Ae);we.appendChild(Te);let be=0,me=!1;const xe=[];function Re(fe){if(fe.nodeType===3)xe.push({node:fe,start:be,end:be+fe.textContent.length}),be+=fe.textContent.length;else if(fe.nodeType===1){const re=fe.childNodes;for(const he of Array.from(re))Re(he)}}Re(w.current);const Ne=document.createRange();if(T.startPos!==null)for(const fe of xe){if(T.startPos-1>=fe.start&&T.startPos-1<=fe.end){const re=T.startPos-1-fe.start;Ne.setStart(fe.node,re),me=!0}if(me){const re=_e?T.startPos+T.filter.length-1:Y(w.current);if(re>=fe.start&&re<=fe.end){const he=re-fe.start;Ne.setEnd(fe.node,he);break}}}if(me){Ne.deleteContents(),Ne.insertNode(we);const fe=document.createRange();fe.setStartAfter(we),fe.setEndAfter(we),ge.removeAllRanges(),ge.addRange(fe);const re=document.createTextNode("\xA0");fe.insertNode(re),fe.setStartAfter(re),fe.setEndAfter(re),ge.removeAllRanges(),ge.addRange(fe)}D(fe=>({...fe,active:!1})),w.current.focus()},oe=o.useCallback(Ee=>{O(Ee),f?.(Ee)},[I,f]),le=()=>{if(!w.current)return;const Ee=w.current.innerHTML;if(!Ee)return;const _e=document.createElement("div");_e.innerHTML=Ee,_e.querySelectorAll(`.${m.default.mention_tag}`).forEach(we=>{var Pe;const Ae=we.getAttribute("data-context-id");if(Ae){const Te=document.createTextNode(`{{${E}${we.getAttribute("data-type")}:${Ae}}}`);(Pe=we.parentNode)===null||Pe===void 0||Pe.replaceChild(Te,we)}});let ge=_e.innerHTML;ge=ge.trim().replaceAll(t.WHITE_SPACE_TEXT," "),Ee&&(k(we=>[...we,Ee]),L(-1),U(!1)),h&&h(ge,{model:I,...S}),w.current.innerHTML="",w.current&&(w.current.style.overflowY="hidden",w.current.style.height="auto")},pe=o.useCallback(()=>{u&&u()},[u]),q=o.useCallback(Ee=>(S.buttons||[]).filter(_e=>_e.position===Ee).map(_e=>o.createElement(c.Popover,{key:_e.id,overlayClassName:m.default.popover_icon,id:`ai-chat-${_e.id}`,position:c.PopoverPosition.top,title:_e.title},o.createElement(p.EnhanceIcon,{className:(0,r.default)(_e.icon?(0,c.getIcon)(_e.icon):_e.iconClass,m.default[`${_e.id}_logo`]),tabIndex:0,role:"button",ariaLabel:_e.title,onClick:_e.onClick}))),[S.buttons]);return o.createElement("div",{className:m.default.input_container},T.active&&o.createElement("div",{className:m.default.mention_panel_container},o.createElement(_.MentionPanel,{items:Q(),activeIndex:T.activeIndex,onSelectItem:Ee=>ie(Ee,!0),position:{top:0,left:0},filter:T.level===0?T.filter:T.secondLevelFilter,visible:!0,level:T.level,loading:T.loading})),o.createElement("div",{className:m.default.editor_area},o.createElement("div",{ref:w,className:m.default.editor,contentEditable:!0,onInput:z,onKeyDown:H,onPaste:Z,onCompositionEnd:K})),o.createElement("div",{className:m.default.footer},o.createElement("div",{className:m.default.left_control},S.showModelSelector&&o.createElement(c.Select,{options:S.modelOptions||[],value:I,onChange:oe,className:m.default.model_selector,size:"small"}),q(s.FooterButtonPosition.LEFT)),o.createElement("div",{className:m.default.right_control},q(s.FooterButtonPosition.RIGHT),o.createElement(c.Popover,{overlayClassName:m.default.popover_icon,id:"ai-chat-send",position:c.PopoverPosition.top,content:d?"Stop":"Send"},d?o.createElement(p.EnhanceIcon,{wrapperClassName:m.default.stop_logo,className:(0,r.default)((0,c.getIcon)("stop"),m.default.stop_logo_icon),tabIndex:0,role:"button",ariaLabel:"Stop",onClick:pe}):o.createElement(p.EnhanceIcon,{wrapperClassName:m.default.send_logo,className:(0,r.default)((0,c.getIcon)("send-outlined"),m.default.send_logo_icon),tabIndex:0,role:"button",onClick:le,ariaLabel:"Send"})))))};t.MentionInput=g},40167:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MentionItem=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),c=e(81878),p=n.__importDefault(e(97599)),v=({item:m,isActive:_,onClick:s})=>o.createElement("div",{className:`${p.default.mention_item} ${_?p.default.active:""}`,onClick:()=>s(m)},o.createElement("div",{className:p.default.mention_item_left},o.createElement(c.Icon,{className:(0,r.default)(p.default.mention_item_icon,m.icon)}),o.createElement("span",{className:p.default.mention_item_text},m.text),o.createElement("span",{className:p.default.mention_item_description},m.description)),m.getItems&&o.createElement(c.Icon,{className:(0,r.default)(p.default.mention_item_right,(0,c.getIcon)("arrowright"))}));t.MentionItem=v},80732:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MentionPanel=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=n.__importDefault(e(97599)),c=e(40167),p=({items:v,activeIndex:m,onSelectItem:_,position:s,filter:g,visible:l,level:h,loading:u=!1})=>{const d=r.useRef(null);if(r.useEffect(()=>{if(l&&d.current){const a=d.current.querySelector(`.${o.default.mention_item}.${o.default.active}`);a&&a.scrollIntoView({block:"nearest"})}},[m,l]),!l)return null;const f=(()=>{let a=v;if(h===0){if(g&&g.length>1){const b=g.substring(1).toLowerCase();a=v.filter(y=>y.text.toLowerCase().includes(b))}}else g&&g.length>0&&(a=v.filter(b=>b.text.toLowerCase().includes(g.toLowerCase())));return a})();return h===0&&f.length===0?null:r.createElement("div",{ref:d,className:o.default.mention_panel,style:{top:s.top,left:s.left}},u&&r.createElement("div",{className:o.default.loading_bar}),v.length>0?r.createElement("ul",{className:o.default.mention_list},v.map((a,b)=>r.createElement(c.MentionItem,{key:a.id,item:a,isActive:b===m,onClick:()=>_(a,!0)}))):r.createElement("div",{className:o.default.no_results},u?"\u6B63\u5728\u641C\u7D22...":"\u65E0\u5339\u914D\u7ED3\u679C"))};t.MentionPanel=p},44692:(x,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MENTION_KEYWORD=t.MentionType=t.FooterButtonPosition=void 0;var e;(function(r){r.LEFT="left",r.RIGHT="right"})(e||(t.FooterButtonPosition=e={}));var n;(function(r){r.FILE="file",r.FOLDER="folder",r.CODE="code"})(n||(t.MentionType=n={})),t.MENTION_KEYWORD="@"},78048:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractIcon=t.createMessageByAI=t.createMessageByUser=void 0;const n=e(41869),r="",o=m=>({...m,type:"text",className:`${m.position==="left"?"rce-ai-msg":"rce-user-msg"} ${m.className?m.className:""}`}),c=(m,_)=>o({...m,position:"right",title:r,className:_,role:1});t.createMessageByUser=c;const p=(m,_)=>o({...m,position:"left",title:"",className:_,role:2});t.createMessageByAI=p;const v=m=>{let{title:_}=m;const{message:s,tooltip:g}=m;let l=m.icon||"";if(!_)return{icon:l,title:s,message:s,tooltip:g};const h=_.match(/^\$\(([a-z.]+\/)?([a-z0-9-]+)(~[a-z]+)?\)/i);if(h){const[u,d,E,f]=h,a=d?d.slice(0,-1):n.CODICON_OWNER;l=(0,n.getExternalIcon)(E,a),f&&(l+=` ${f.slice(1)}`),_=_.slice(u.length)}return{icon:l,title:_,message:s,tooltip:g}};t.extractIcon=v},19957:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LlmContextContribution=void 0;const n=e(85608),r=e(76003),o=e(41869),c=e(46044);let p=class{initialize(){this.llmContextService.startAutoCollection()}};t.LlmContextContribution=p,n.__decorate([(0,r.Autowired)(c.LLMContextServiceToken),n.__metadata("design:type",Object)],p.prototype,"llmContextService",void 0),t.LlmContextContribution=p=n.__decorate([(0,o.Domain)(o.ClientAppContribution)],p)},63536:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LLMContextServiceImpl=void 0;const n=e(85608),r=e(76003),o=e(11050),c=e(25234),p=e(19083),v=e(86560),m=e(96689),_=e(82196),s=e(14951),g=e(6287),l=e(20868);let h=class extends c.WithEventBus{constructor(){super(...arguments),this.isAutoCollecting=!1,this.contextVersion=0,this.maxAttachFilesLimit=10,this.maxAttachFoldersLimit=10,this.maxViewFilesLimit=20,this.attachedFiles=[],this.attachedFolders=[],this.recentlyViewFiles=[],this.onDidContextFilesChangeEmitter=new v.Emitter,this.onDidContextFilesChangeEvent=this.onDidContextFilesChangeEmitter.event}addFileToList(d,E,f){const a=E.findIndex(b=>b.uri.toString()===d.uri.toString());a>-1&&E.splice(a,1),E.push(d),E.length>f&&E.shift()}addFolderToList(d,E,f){const a=E.findIndex(b=>b.uri.toString()===d.uri.toString());a>-1&&E.splice(a,1),E.push(d),E.length>f&&E.shift()}addFileToContext(d,E,f=!1){if(!d)return;const a={uri:d,selection:E},b=f?this.attachedFiles:this.recentlyViewFiles,y=f?this.maxAttachFilesLimit:this.maxViewFilesLimit;f&&this.docModelManager.createModelReference(d),this.addFileToList(a,b,y),this.notifyContextChange()}addFolderToContext(d){if(!d)return;const E={uri:d};this.addFolderToList(E,this.attachedFolders,this.maxAttachFoldersLimit),this.notifyContextChange()}notifyContextChange(){this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles())}cleanFileContext(){this.attachedFiles=[],this.attachedFolders=[],this.notifyContextChange()}getAllContextFiles(){return{viewed:this.recentlyViewFiles,attached:this.attachedFiles,attachedFolders:this.attachedFolders,version:this.contextVersion++}}removeFileFromContext(d,E=!1){const f=E?this.attachedFiles:this.recentlyViewFiles,a=f.findIndex(b=>b.uri.toString()===d.toString());a>-1&&f.splice(a,1),this.notifyContextChange()}startAutoCollection(){this.isAutoCollecting||(this.isAutoCollecting=!0,this.startAutoCollectionInternal())}startAutoCollectionInternal(){this.disposables.push(this.eventBus.on(m.EditorDocumentModelCreationEvent,d=>{d.payload.uri.scheme==="file"&&this.addFileToContext(d.payload.uri,void 0,!1)})),this.disposables.push(this.eventBus.on(m.EditorDocumentModelRemovalEvent,d=>{d.payload.scheme==="file"&&this.removeFileFromContext(d.payload,!1)})),this.disposables.push(this.eventBus.on(m.EditorDocumentModelSavedEvent,d=>{d.payload.scheme})),this.disposables.push(this.eventBus.on(_.EditorSelectionChangeEvent,d=>{if(d.payload.selections.length>0){const E=[d.payload.selections[0].selectionStartLineNumber,d.payload.selections[0].positionLineNumber].sort();E[0]===E[1]?this.addFileToContext(d.payload.editorUri,void 0,!1):this.addFileToContext(d.payload.editorUri,E.sort((f,a)=>f-a),!1)}}))}stopAutoCollection(){this.dispose()}async serialize(){const d=this.getAllContextFiles(),E=v.URI.file(this.appConfig.workspaceDir);return{recentlyViewFiles:this.serializeRecentlyViewFiles(d.viewed,E),attachedFiles:this.serializeAttachedFiles(d.attached,E),attachedFolders:await this.serializeAttachedFolders(d.attachedFolders,E)}}async serializeAttachedFolders(d,E){const f=Array.from(new Set(d.map(a=>a.uri.toString())));return Promise.all(f.map(async a=>{var b;const y=new v.URI(a);return`\`\`\`
|
|
31283
|
+
`),be=document.createDocumentFragment();Te.forEach((me,xe)=>{const Re=me.replace(/^[ ]+/g,fe=>{const re=document.createElement("span");return re.innerHTML="\xA0".repeat(fe.length),re.innerHTML}),Ne=document.createElement("span");for(Ne.innerHTML=Re;Ne.firstChild;)be.appendChild(Ne.firstChild);xe<Te.length-1&&be.appendChild(document.createElement("br"))}),Ae.insertNode(be),Ae.setStartAfter(be),Ae.setEndAfter(be),Pe.removeAllRanges(),Pe.addRange(Ae),z()};o.useEffect(()=>{w.current&&A&&!w.current.textContent&&w.current.setAttribute("data-placeholder",A)},[A]);const X=Ee=>{var _e;T.active&&!(!((_e=document.querySelector(`.${m.default.mention_panel}`))===null||_e===void 0)&&_e.contains(Ee.target))&&D(ne=>({...ne,active:!1,inlineSearchActive:!1}))};o.useEffect(()=>(document.addEventListener("click",X,!0),()=>{document.removeEventListener("click",X,!0)}),[T.active]);const ie=(Ee,_e=!1)=>{var ne;if(!w.current)return;if(Ee.getItems){const fe=window.getSelection();if(!fe||!fe.rangeCount)return;if(T.level===0&&T.startPos!==null){let re,he,Oe;const De=document.createTreeWalker(w.current,NodeFilter.SHOW_TEXT);let Fe=0,Ge;for(;Ge=De.nextNode();){const Ve=((ne=Ge.textContent)===null||ne===void 0?void 0:ne.length)||0;if(T.startPos-1>=Fe&&T.startPos-1<Fe+Ve){re=Ge,he=T.startPos-1-Fe;const gt=_e?T.startPos+T.filter.length-1:Y(w.current);Oe=Math.min(gt-Fe,Ve);break}Fe+=Ve}if(re){const Ve=document.createRange();Ve.setStart(re,he),Ve.setEnd(re,Oe),Ve.deleteContents();const gt=document.createTextNode(`${E}${Ee.type}:`);Ve.insertNode(gt);const rt=document.createRange();rt.setStartAfter(gt),rt.setEndAfter(gt),fe.removeAllRanges(),fe.addRange(rt),D(Mt=>({...Mt,active:!0,level:1,parentType:Ee.id,inlineSearchActive:!0,inlineSearchStartPos:Y(w.current),secondLevelFilter:"",activeIndex:0})),w.current.focus();return}}return}const ge=window.getSelection();if(!ge||!ge.rangeCount)return;if(T.inlineSearchActive&&T.parentType&&T.inlineSearchStartPos!==null){const fe=l.find(Oe=>Oe.id===T.parentType);if(!fe)return;const re=`${E}${fe.type}:`,he=T.inlineSearchStartPos-re.length;if(he>=0){let lt=function(yt){if(yt.nodeType===3)Mt.push({node:yt,start:gt,end:gt+yt.textContent.length}),gt+=yt.textContent.length;else if(yt.nodeType===1){const ot=yt.childNodes||[];for(const st of Array.from(ot))lt(st)}};const Oe=document.createElement("span");if(Oe.className=m.default.mention_tag,Oe.dataset.id=Ee.id,Oe.dataset.type=Ee.type,Oe.dataset.contextId=Ee.contextId||"",Oe.contentEditable="false",Ee.type==="file"||Ee.type==="folder"){const yt=document.createElement("span");yt.className=(0,r.default)(m.default.mention_icon,Ee.type==="file"?b?.getIcon(new v.URI(Ee.text)):(0,c.getIcon)("folder")),Oe.appendChild(yt)}const De=y?.workspace;let Fe=Ee.text;De&&Ee.contextId&&(Fe=Ee.contextId.replace(new v.URI(De.uri).codeUri.fsPath,"").slice(1));const Ge=document.createTextNode(Fe);Oe.appendChild(Ge);const Ve=document.createRange();let gt=0,rt=!1;const Mt=[];lt(w.current);for(const yt of Mt){if(he>=yt.start&&he<=yt.end){const ot=he-yt.start;Ve.setStart(yt.node,ot),rt=!0}if(rt){const ot=_e?he+re.length+T.secondLevelFilter.length:Y(w.current);if(ot>=yt.start&&ot<=yt.end){const st=ot-yt.start;Ve.setEnd(yt.node,st);break}}}if(rt){Ve.deleteContents(),Ve.insertNode(Oe);const yt=document.createRange();yt.setStartAfter(Oe),yt.setEndAfter(Oe),ge.removeAllRanges(),ge.addRange(yt);const ot=document.createTextNode("\xA0");yt.insertNode(ot),yt.setStartAfter(ot),yt.setEndAfter(ot),ge.removeAllRanges(),ge.addRange(yt)}D(yt=>({...yt,active:!1,inlineSearchActive:!1})),w.current.focus();return}}const we=document.createElement("span");if(we.className=m.default.mention_tag,we.dataset.id=Ee.id,we.dataset.type=Ee.type,we.dataset.contextId=Ee.contextId||"",we.contentEditable="false",Ee.type==="file"||Ee.type==="folder"){const fe=document.createElement("span");fe.className=(0,r.default)(m.default.mention_icon,Ee.type==="file"?b?.getIcon(new v.URI(Ee.text)):(0,c.getIcon)("folder")),we.appendChild(fe)}const Pe=y?.workspace;let Ae=Ee.text;Pe&&Ee.contextId&&(Ae=Ee.contextId.replace(new v.URI(Pe.uri).codeUri.fsPath,"").slice(1));const Te=document.createTextNode(Ae);we.appendChild(Te);let be=0,me=!1;const xe=[];function Re(fe){if(fe.nodeType===3)xe.push({node:fe,start:be,end:be+fe.textContent.length}),be+=fe.textContent.length;else if(fe.nodeType===1){const re=fe.childNodes;for(const he of Array.from(re))Re(he)}}Re(w.current);const Ne=document.createRange();if(T.startPos!==null)for(const fe of xe){if(T.startPos-1>=fe.start&&T.startPos-1<=fe.end){const re=T.startPos-1-fe.start;Ne.setStart(fe.node,re),me=!0}if(me){const re=_e?T.startPos+T.filter.length-1:Y(w.current);if(re>=fe.start&&re<=fe.end){const he=re-fe.start;Ne.setEnd(fe.node,he);break}}}if(me){Ne.deleteContents(),Ne.insertNode(we);const fe=document.createRange();fe.setStartAfter(we),fe.setEndAfter(we),ge.removeAllRanges(),ge.addRange(fe);const re=document.createTextNode("\xA0");fe.insertNode(re),fe.setStartAfter(re),fe.setEndAfter(re),ge.removeAllRanges(),ge.addRange(fe)}D(fe=>({...fe,active:!1})),w.current.focus()},oe=o.useCallback(Ee=>{O(Ee),f?.(Ee)},[I,f]),le=()=>{if(!w.current)return;const Ee=w.current.innerHTML;if(!Ee)return;const _e=document.createElement("div");_e.innerHTML=Ee,_e.querySelectorAll(`.${m.default.mention_tag}`).forEach(we=>{var Pe;const Ae=we.getAttribute("data-context-id");if(Ae){const Te=document.createTextNode(`{{${E}${we.getAttribute("data-type")}:${Ae}}}`);(Pe=we.parentNode)===null||Pe===void 0||Pe.replaceChild(Te,we)}});let ge=_e.innerHTML;ge=ge.trim().replaceAll(t.WHITE_SPACE_TEXT," "),Ee&&(k(we=>[...we,Ee]),L(-1),U(!1)),h&&h(ge,{model:I,...S}),w.current.innerHTML="",w.current&&(w.current.style.overflowY="hidden",w.current.style.height="auto")},pe=o.useCallback(()=>{u&&u()},[u]),q=o.useCallback(Ee=>(S.buttons||[]).filter(_e=>_e.position===Ee).map(_e=>o.createElement(c.Popover,{key:_e.id,overlayClassName:m.default.popover_icon,id:`ai-chat-${_e.id}`,position:c.PopoverPosition.top,title:_e.title},o.createElement(p.EnhanceIcon,{className:(0,r.default)(_e.icon?(0,c.getIcon)(_e.icon):_e.iconClass,m.default[`${_e.id}_logo`]),tabIndex:0,role:"button",ariaLabel:_e.title,onClick:_e.onClick}))),[S.buttons]);return o.createElement("div",{className:m.default.input_container},T.active&&o.createElement("div",{className:m.default.mention_panel_container},o.createElement(_.MentionPanel,{items:Q(),activeIndex:T.activeIndex,onSelectItem:Ee=>ie(Ee,!0),position:{top:0,left:0},filter:T.level===0?T.filter:T.secondLevelFilter,visible:!0,level:T.level,loading:T.loading})),o.createElement("div",{className:m.default.editor_area},o.createElement("div",{ref:w,className:m.default.editor,contentEditable:!0,onInput:z,onKeyDown:H,onPaste:Z,onCompositionEnd:K})),o.createElement("div",{className:m.default.footer},o.createElement("div",{className:m.default.left_control},S.showModelSelector&&o.createElement(c.Select,{options:S.modelOptions||[],value:I,onChange:oe,className:m.default.model_selector,size:"small",disabled:S.disableModelSelector}),q(s.FooterButtonPosition.LEFT)),o.createElement("div",{className:m.default.right_control},q(s.FooterButtonPosition.RIGHT),o.createElement(c.Popover,{overlayClassName:m.default.popover_icon,id:"ai-chat-send",position:c.PopoverPosition.top,content:d?"Stop":"Send"},d?o.createElement(p.EnhanceIcon,{wrapperClassName:m.default.stop_logo,className:(0,r.default)((0,c.getIcon)("stop"),m.default.stop_logo_icon),tabIndex:0,role:"button",ariaLabel:"Stop",onClick:pe}):o.createElement(p.EnhanceIcon,{wrapperClassName:m.default.send_logo,className:(0,r.default)((0,c.getIcon)("send-outlined"),m.default.send_logo_icon),tabIndex:0,role:"button",onClick:le,ariaLabel:"Send"})))))};t.MentionInput=g},40167:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MentionItem=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),c=e(81878),p=n.__importDefault(e(97599)),v=({item:m,isActive:_,onClick:s})=>o.createElement("div",{className:`${p.default.mention_item} ${_?p.default.active:""}`,onClick:()=>s(m)},o.createElement("div",{className:p.default.mention_item_left},o.createElement(c.Icon,{className:(0,r.default)(p.default.mention_item_icon,m.icon)}),o.createElement("span",{className:p.default.mention_item_text},m.text),o.createElement("span",{className:p.default.mention_item_description},m.description)),m.getItems&&o.createElement(c.Icon,{className:(0,r.default)(p.default.mention_item_right,(0,c.getIcon)("arrowright"))}));t.MentionItem=v},80732:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MentionPanel=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=n.__importDefault(e(97599)),c=e(40167),p=({items:v,activeIndex:m,onSelectItem:_,position:s,filter:g,visible:l,level:h,loading:u=!1})=>{const d=r.useRef(null);if(r.useEffect(()=>{if(l&&d.current){const a=d.current.querySelector(`.${o.default.mention_item}.${o.default.active}`);a&&a.scrollIntoView({block:"nearest"})}},[m,l]),!l)return null;const f=(()=>{let a=v;if(h===0){if(g&&g.length>1){const b=g.substring(1).toLowerCase();a=v.filter(y=>y.text.toLowerCase().includes(b))}}else g&&g.length>0&&(a=v.filter(b=>b.text.toLowerCase().includes(g.toLowerCase())));return a})();return h===0&&f.length===0?null:r.createElement("div",{ref:d,className:o.default.mention_panel,style:{top:s.top,left:s.left}},u&&r.createElement("div",{className:o.default.loading_bar}),v.length>0?r.createElement("ul",{className:o.default.mention_list},v.map((a,b)=>r.createElement(c.MentionItem,{key:a.id,item:a,isActive:b===m,onClick:()=>_(a,!0)}))):r.createElement("div",{className:o.default.no_results},u?"\u6B63\u5728\u641C\u7D22...":"\u65E0\u5339\u914D\u7ED3\u679C"))};t.MentionPanel=p},44692:(x,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MENTION_KEYWORD=t.MentionType=t.FooterButtonPosition=void 0;var e;(function(r){r.LEFT="left",r.RIGHT="right"})(e||(t.FooterButtonPosition=e={}));var n;(function(r){r.FILE="file",r.FOLDER="folder",r.CODE="code"})(n||(t.MentionType=n={})),t.MENTION_KEYWORD="@"},78048:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractIcon=t.createMessageByAI=t.createMessageByUser=void 0;const n=e(41869),r="",o=m=>({...m,type:"text",className:`${m.position==="left"?"rce-ai-msg":"rce-user-msg"} ${m.className?m.className:""}`}),c=(m,_)=>o({...m,position:"right",title:r,className:_,role:1});t.createMessageByUser=c;const p=(m,_)=>o({...m,position:"left",title:"",className:_,role:2});t.createMessageByAI=p;const v=m=>{let{title:_}=m;const{message:s,tooltip:g}=m;let l=m.icon||"";if(!_)return{icon:l,title:s,message:s,tooltip:g};const h=_.match(/^\$\(([a-z.]+\/)?([a-z0-9-]+)(~[a-z]+)?\)/i);if(h){const[u,d,E,f]=h,a=d?d.slice(0,-1):n.CODICON_OWNER;l=(0,n.getExternalIcon)(E,a),f&&(l+=` ${f.slice(1)}`),_=_.slice(u.length)}return{icon:l,title:_,message:s,tooltip:g}};t.extractIcon=v},19957:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LlmContextContribution=void 0;const n=e(85608),r=e(76003),o=e(41869),c=e(46044);let p=class{initialize(){this.llmContextService.startAutoCollection()}};t.LlmContextContribution=p,n.__decorate([(0,r.Autowired)(c.LLMContextServiceToken),n.__metadata("design:type",Object)],p.prototype,"llmContextService",void 0),t.LlmContextContribution=p=n.__decorate([(0,o.Domain)(o.ClientAppContribution)],p)},63536:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LLMContextServiceImpl=void 0;const n=e(85608),r=e(76003),o=e(11050),c=e(25234),p=e(19083),v=e(86560),m=e(96689),_=e(82196),s=e(14951),g=e(6287),l=e(20868);let h=class extends c.WithEventBus{constructor(){super(...arguments),this.isAutoCollecting=!1,this.contextVersion=0,this.maxAttachFilesLimit=10,this.maxAttachFoldersLimit=10,this.maxViewFilesLimit=20,this.attachedFiles=[],this.attachedFolders=[],this.recentlyViewFiles=[],this.onDidContextFilesChangeEmitter=new v.Emitter,this.onDidContextFilesChangeEvent=this.onDidContextFilesChangeEmitter.event}addFileToList(d,E,f){const a=E.findIndex(b=>b.uri.toString()===d.uri.toString());a>-1&&E.splice(a,1),E.push(d),E.length>f&&E.shift()}addFolderToList(d,E,f){const a=E.findIndex(b=>b.uri.toString()===d.uri.toString());a>-1&&E.splice(a,1),E.push(d),E.length>f&&E.shift()}addFileToContext(d,E,f=!1){if(!d)return;const a={uri:d,selection:E},b=f?this.attachedFiles:this.recentlyViewFiles,y=f?this.maxAttachFilesLimit:this.maxViewFilesLimit;f&&this.docModelManager.createModelReference(d),this.addFileToList(a,b,y),this.notifyContextChange()}addFolderToContext(d){if(!d)return;const E={uri:d};this.addFolderToList(E,this.attachedFolders,this.maxAttachFoldersLimit),this.notifyContextChange()}notifyContextChange(){this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles())}cleanFileContext(){this.attachedFiles=[],this.attachedFolders=[],this.notifyContextChange()}getAllContextFiles(){return{viewed:this.recentlyViewFiles,attached:this.attachedFiles,attachedFolders:this.attachedFolders,version:this.contextVersion++}}removeFileFromContext(d,E=!1){const f=E?this.attachedFiles:this.recentlyViewFiles,a=f.findIndex(b=>b.uri.toString()===d.toString());a>-1&&f.splice(a,1),this.notifyContextChange()}startAutoCollection(){this.isAutoCollecting||(this.isAutoCollecting=!0,this.startAutoCollectionInternal())}startAutoCollectionInternal(){this.disposables.push(this.eventBus.on(m.EditorDocumentModelCreationEvent,d=>{d.payload.uri.scheme==="file"&&this.addFileToContext(d.payload.uri,void 0,!1)})),this.disposables.push(this.eventBus.on(m.EditorDocumentModelRemovalEvent,d=>{d.payload.scheme==="file"&&this.removeFileFromContext(d.payload,!1)})),this.disposables.push(this.eventBus.on(m.EditorDocumentModelSavedEvent,d=>{d.payload.scheme})),this.disposables.push(this.eventBus.on(_.EditorSelectionChangeEvent,d=>{if(d.payload.selections.length>0){const E=[d.payload.selections[0].selectionStartLineNumber,d.payload.selections[0].positionLineNumber].sort();E[0]===E[1]?this.addFileToContext(d.payload.editorUri,void 0,!1):this.addFileToContext(d.payload.editorUri,E.sort((f,a)=>f-a),!1)}}))}stopAutoCollection(){this.dispose()}async serialize(){const d=this.getAllContextFiles(),E=v.URI.file(this.appConfig.workspaceDir);return{recentlyViewFiles:this.serializeRecentlyViewFiles(d.viewed,E),attachedFiles:this.serializeAttachedFiles(d.attached,E),attachedFolders:await this.serializeAttachedFolders(d.attachedFolders,E)}}async serializeAttachedFolders(d,E){const f=Array.from(new Set(d.map(a=>a.uri.toString())));return Promise.all(f.map(async a=>{var b;const y=new v.URI(a);return`\`\`\`
|
|
31274
31284
|
${((b=E.relative(y))===null||b===void 0?void 0:b.toString())||"/"}
|
|
31275
31285
|
${(await this.getPartiaFolderStructure(y.codeUri.fsPath)).map(S=>`- ${S}`).join(`
|
|
31276
31286
|
`)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/cli-engine",
|
|
3
|
-
"version": "3.8.3-next-
|
|
3
|
+
"version": "3.8.3-next-1744791676.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.3-next-
|
|
30
|
-
"@opensumi/ide-core-common": "3.8.3-next-
|
|
31
|
-
"@opensumi/ide-core-node": "3.8.3-next-
|
|
32
|
-
"@opensumi/ide-express-file-server": "3.8.3-next-
|
|
33
|
-
"@opensumi/ide-extension": "3.8.3-next-
|
|
34
|
-
"@opensumi/ide-i18n": "3.8.3-next-
|
|
35
|
-
"@opensumi/ide-main-layout": "3.8.3-next-
|
|
36
|
-
"@opensumi/ide-startup": "3.8.3-next-
|
|
29
|
+
"@opensumi/ide-core-browser": "3.8.3-next-1744791676.0",
|
|
30
|
+
"@opensumi/ide-core-common": "3.8.3-next-1744791676.0",
|
|
31
|
+
"@opensumi/ide-core-node": "3.8.3-next-1744791676.0",
|
|
32
|
+
"@opensumi/ide-express-file-server": "3.8.3-next-1744791676.0",
|
|
33
|
+
"@opensumi/ide-extension": "3.8.3-next-1744791676.0",
|
|
34
|
+
"@opensumi/ide-i18n": "3.8.3-next-1744791676.0",
|
|
35
|
+
"@opensumi/ide-main-layout": "3.8.3-next-1744791676.0",
|
|
36
|
+
"@opensumi/ide-startup": "3.8.3-next-1744791676.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": "f88022f50075ffc43b6a09a32699676782ec8251"
|
|
76
76
|
}
|