@opensumi/cli-engine 3.9.1-next-1749022016.0 → 3.9.1-next-1749022986.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 +1 -1
- package/package.json +10 -10
package/lib/browser/browser.js
CHANGED
|
@@ -32880,7 +32880,7 @@ User's intention: ${c.instructions}
|
|
|
32880
32880
|
`),k=M[M.length-1],F=[{condition:k.includes("`"),action:c},{condition:k.includes("**"),action:b},{condition:k.match(/\*\w/),action:E},{condition:k.match(/(^|\s)__\w/),action:A},{condition:k.match(/(^|\s)_\w/),action:f},{condition:k.match(/(^|\s)\[.*\]\(\w*/),action:d},{condition:k.match(/(^|\s)\[\w/),action:y}];for(const L of F)if(L.condition)return L.action(T)}}},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),l=e(41869),_=e(81878),v=e(43718),m=e(92323),p=e(87863),s=e(54414),g=e(47720),a=e(83890),h=e(29037),u=e(72665),c=e(52416),E=e(7443),f=e(51500),d=e(19413),y=e(27397),b=e(92819),A=n.__importDefault(e(6960)),S=e(96086),D=e(44692),I=T=>{const{onSend:R,disabled:P=!1,contextService:O}=T,[M,k]=(0,r.useState)(T.value||""),[F,L]=(0,r.useState)(T.images||[]),B=(0,l.useInjectable)(d.IChatInternalService),U=(0,l.useInjectable)(m.CommandService),W=(0,l.useInjectable)(g.FileSearchServicePath),j=(0,l.useInjectable)(l.RecentFilesManager),Q=(0,l.useInjectable)(f.IWorkspaceService),G=(0,l.useInjectable)(s.WorkbenchEditorService),Z=(0,l.useInjectable)(l.LabelService),$=(0,l.useInjectable)(E.IconService),V=(0,l.useInjectable)(u.IMessageService),H=(0,l.useInjectable)(v.ChatFeatureRegistryToken),K=(0,l.useInjectable)(h.OutlineTreeService),Y=(0,r.useRef)([]),X=(0,l.useInjectable)(l.PreferenceService),re=(0,l.useInjectable)(v.RulesServiceToken),oe=r.default.useCallback(()=>{U.executeCommand(y.MCPConfigCommands.OPEN_MCP_CONFIG.id)},[U]),he=r.default.useCallback(()=>{U.executeCommand(b.RulesCommands.OPEN_RULES_FILE.id)},[U]);(0,r.useEffect)(()=>{T.value!==M&&k(T.value||"")},[T.value]);const me=(0,r.useCallback)(async(Me,Be=[])=>{Me||(Me=(await K.resolveChildren())[0]);const De=await K.resolveChildren(Me);for(const _e of De)Be.push(_e),a.OutlineCompositeTreeNode.is(_e)&&await me(_e,Be);return Be},[K]),q=async(Me,Be)=>{const De=new Set,_e=new v.URI(Be);for(const Ne of Me){const Te=new v.URI(Ne),We=await Q.asRelativePath(Te);if(We?.path){const pe=We.path.split("/").filter(Boolean);for(let ie=0;ie<pe.length;ie++){const le=pe.slice(0,ie+1).join("/"),Se=_e.resolve(le).codeUri.fsPath;Se!==Be&&!Be.startsWith(Se)&&De.add(Se)}}else Ne!==Be&&!Be.startsWith(Ne)&&De.add(Ne)}return Promise.all(Array.from(De).map(async Ne=>{const Te=new v.URI(Ne),We=await Q.asRelativePath(Te);return{id:Te.codeUri.fsPath,type:D.MentionType.FOLDER,text:Te.displayName,value:Te.codeUri.fsPath,description:We?.root?We.path:"",contextId:Te.codeUri.fsPath,icon:(0,_.getIcon)("folder")}}))},Ae=[{id:D.MentionType.FILE,type:D.MentionType.FILE,text:"File",icon:(0,_.getIcon)("file"),getHighestLevelItems:()=>{const Me=G.currentEditor,Be=Me?.currentUri;return Be?[{id:Be.codeUri.fsPath,type:D.MentionType.FILE,text:Be.displayName,value:Be.codeUri.fsPath,description:`(${(0,v.localize)("aiNative.chat.defaultContextFile")})`,contextId:Be.codeUri.fsPath,icon:Z.getIcon(Be)}]:[]},getItems:async Me=>{if(Me){const Be=(await Q.roots).map(_e=>new v.URI(_e.uri).codeUri.fsPath.toString()),De=await W.find(Me,{rootUris:Be,useGitIgnore:!0,noIgnoreParent:!0,fuzzyMatch:!0,limit:10});return Promise.all(De.map(async _e=>{var Ne;const Te=new v.URI(_e),We=(Ne=await Q.asRelativePath(Te.parent))===null||Ne===void 0?void 0:Ne.path;return{id:Te.codeUri.fsPath,type:D.MentionType.FILE,text:Te.displayName,value:Te.codeUri.fsPath,description:We||"",contextId:Te.codeUri.fsPath,icon:Z.getIcon(Te)}}))}else{const Be=await j.getMostRecentlyOpenedFiles();return Promise.all(Be.map(async De=>{var _e;const Ne=new v.URI(De),Te=(_e=await Q.asRelativePath(Ne.parent))===null||_e===void 0?void 0:_e.path;return{id:Ne.codeUri.fsPath,type:D.MentionType.FILE,text:Ne.displayName,value:Ne.codeUri.fsPath,description:Te||"",contextId:Ne.codeUri.fsPath,icon:Z.getIcon(Ne)}}))}}},{id:D.MentionType.FOLDER,type:D.MentionType.FOLDER,text:"Folder",icon:(0,_.getIcon)("folder"),getHighestLevelItems:()=>{var Me,Be;const De=G.currentEditor,_e=(Me=De?.currentUri)===null||Me===void 0?void 0:Me.parent;return _e?_e.toString()===((Be=Q.workspace)===null||Be===void 0?void 0:Be.uri)?[]:[{id:_e.codeUri.fsPath,type:D.MentionType.FOLDER,text:_e.displayName,value:_e.codeUri.fsPath,description:`(${(0,v.localize)("aiNative.chat.defaultContextFolder")})`,contextId:_e.codeUri.fsPath,icon:(0,_.getIcon)("folder")}]:[]},getItems:async Me=>{var Be,De;let _e=[];if(Me){const Ne=(await Q.roots).map(pe=>new v.URI(pe.uri).codeUri.fsPath.toString()),Te=await W.find(Me,{rootUris:Ne,useGitIgnore:!0,noIgnoreParent:!0,fuzzyMatch:!0,excludePatterns:Object.keys(p.defaultFilesWatcherExcludes),limit:10}),We=Array.from(new Set(Te.map(pe=>new v.URI(pe).parent.toString()).filter(pe=>{var ie;return pe!==((ie=Q.workspace)===null||ie===void 0?void 0:ie.uri.toString())})));return await q(We,((De=Q.workspace)===null||De===void 0?void 0:De.uri.toString())||"")}else{const Ne=await j.getMostRecentlyOpenedFiles(),Te=Array.from(new Set(Ne.map(We=>new v.URI(We).parent.codeUri.fsPath).filter(We=>{var pe;return We!==((pe=Q.workspace)===null||pe===void 0?void 0:pe.uri.toString())&&We!=="/"})));_e=await q(Te,((Be=Q.workspace)===null||Be===void 0?void 0:Be.uri.toString())||"")}return _e.filter(Boolean).filter(Ne=>{var Te;return Ne.id!==new v.URI((Te=Q.workspace)===null||Te===void 0?void 0:Te.uri).codeUri.fsPath})}},{id:"code",type:"code",text:"Code",icon:(0,_.getIcon)("codebraces"),getHighestLevelItems:()=>[],getItems:async Me=>{if(!Me||Y.current.length===0){const Be=K.currentUri;if(!Be)return[];const De=await me();return Y.current=await Promise.all(De.map(async _e=>{var Ne;const Te=await Q.asRelativePath(Be);return{id:_e.raw.id,type:D.MentionType.CODE,text:_e.raw.name,symbol:_e.raw,value:_e.raw.id,description:`${Te?.root?Te.path:""}:L${_e.raw.range.startLineNumber}-${_e.raw.range.endLineNumber}`,kind:_e.raw.kind,contextId:`${(Ne=K.currentUri)===null||Ne===void 0?void 0:Ne.codeUri.fsPath}:L${_e.raw.range.startLineNumber}-${_e.raw.range.endLineNumber}`,icon:(0,l.getSymbolIcon)(_e.raw.kind)+" outline-icon"}})),Y.current}else return Me=Me.toLocaleLowerCase(),Y.current.sort((Be,De)=>Be.text.toLocaleLowerCase().includes(Me)&&De.text.toLocaleLowerCase().includes(Me)?0:Be.text.toLocaleLowerCase().includes(Me)?-1:De.text.toLocaleLowerCase().includes(Me)?1:0)}},{id:D.MentionType.RULE,type:D.MentionType.RULE,text:"Rule",icon:(0,_.getIcon)("rules"),getHighestLevelItems:()=>[],getItems:async Me=>{const De=(await re.projectRules).map(Ne=>{const Te=new v.URI(Ne.path);return{id:Te.codeUri.fsPath,type:D.MentionType.RULE,text:Te.displayName,value:Te.codeUri.fsPath,contextId:Te.codeUri.fsPath,description:Ne.description,icon:(0,_.getIcon)("rules")}});if(!Me)return De.slice(0,10);const _e=Me.toLocaleLowerCase();return De.filter(Ne=>Ne.text.toLocaleLowerCase().includes(_e)).sort((Ne,Te)=>{var We,pe;const ie=Ne.text.toLocaleLowerCase(),le=Te.text.toLocaleLowerCase(),Se=((We=Ne.description)===null||We===void 0?void 0:We.toLocaleLowerCase())||"",ye=((pe=Te.description)===null||pe===void 0?void 0:pe.toLocaleLowerCase())||"",Ue=ie.includes(_e),Ye=le.includes(_e),Ve=Se.includes(_e),pt=ye.includes(_e);return Ue&&Ye?ie.localeCompare(le):Ue&&!Ye?-1:!Ue&&Ye?1:Ve&&pt?ie.localeCompare(le):Ve&&!pt?-1:!Ve&&pt?1:ie.localeCompare(le)}).slice(0,10)}}],ge=(0,r.useMemo)(()=>({modelOptions:[{label:"Claude 4 Sonnet",value:"claude_sonnet4",iconClass:$.fromIcon("","https://img.alicdn.com/imgextra/i3/O1CN01p0mziz1Nsl40lp1HO_!!6000000001626-55-tps-92-65.svg",c.IconType.Background),tags:["\u591A\u6A21\u6001","\u957F\u4E0A\u4E0B\u6587\u7406\u89E3","\u601D\u8003\u6A21\u5F0F"],description:"\u9AD8\u6027\u80FD\u6A21\u578B\uFF0C\u652F\u6301\u591A\u6A21\u6001\u8F93\u5165"},{label:"DeepSeek R1",value:"DeepSeek-R1-0528",iconClass:$.fromIcon("","https://img.alicdn.com/imgextra/i3/O1CN01ClcK2w1JwdxcbAB3a_!!6000000001093-55-tps-30-30.svg",c.IconType.Background),tags:["\u601D\u8003\u6A21\u5F0F","\u957F\u4E0A\u4E0B\u6587\u7406\u89E3"],description:"\u4E13\u4E1A\u521B\u4F5C\uFF0C\u652F\u6301\u591A\u6A21\u6001\u8F93\u5165"}],defaultModel:T.sessionModelId||X.get(v.AINativeSettingSectionsId.ModelID)||"deepseek-r1",buttons:[{id:"mcp-server",icon:"mcp",title:"MCP Server",onClick:oe,position:D.FooterButtonPosition.LEFT},{id:"rules",icon:"rules",title:"Rules",onClick:he,position:D.FooterButtonPosition.LEFT},{id:"upload-image",icon:"image",title:(0,v.localize)("aiNative.chat.imageUpload"),onClick:()=>{const Me=document.createElement("input");Me.type="file",Me.accept="image/*",Me.onchange=Be=>{const De=Be.target.files;De?.length&&Oe(Array.from(De))},Me.click()},position:D.FooterButtonPosition.LEFT}],showModelSelector:!0,disableModelSelector:T.disableModelSelector}),[$,oe,he,T.disableModelSelector,T.sessionModelId]),te=(0,r.useCallback)(()=>{B.cancelRequest()},[]),fe=(0,r.useCallback)(async(Me,Be)=>{P||(R(Me,F.map(De=>De.toString()),void 0,void 0,Be),L(T.images||[]))},[R,F,P]),Oe=(0,r.useCallback)(async Me=>{const Be=["image/jpeg","image/jpg","image/png","image/webp","image/gif"];if(Me.filter(We=>!Be.includes(We.type)).length>0){V.error("Only JPG, PNG, WebP and GIF images are supported");return}const _e=H.getImageUploadProvider();if(!_e){V.error("No image upload provider found");return}const Ne=await Promise.all(Me.map(We=>_e.imageUpload(We))),Te=[...F,...Ne];L(Te)},[F]),xe=(0,r.useCallback)(Me=>{L(F.filter((Be,De)=>De!==Me))},[F]);return r.default.createElement("div",{className:A.default.chat_input_container},F.length>0&&r.default.createElement(w,{images:F,onDelete:xe}),r.default.createElement(S.MentionInput,{mentionItems:Ae,onSend:fe,onStop:te,loading:P,labelService:Z,workspaceService:Q,placeholder:(0,v.localize)("aiNative.chat.input.placeholder.default"),footerConfig:ge,onImageUpload:Oe,contextService:O}))};t.ChatMentionInput=I;const w=({images:T,onDelete:R})=>r.default.createElement("div",null,r.default.createElement("div",{className:A.default.thumbnail_container},T.map((P,O)=>r.default.createElement("div",{key:O,className:A.default.thumbnail},r.default.createElement(o.Image,{src:P.toString()}),r.default.createElement("button",{onClick:()=>R(O),className:A.default.delete_button},r.default.createElement(_.Icon,{iconClass:"codicon codicon-close"}))))))},15016:(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)),l=e(48412),_=e(91416),v=e(78569),m=e(72871),p=e(41869),s=e(81878),g=e(89195),a=e(43718),h=e(52416),u=e(90684),c=e(19413),E=e(56474),f=e(17319),d=n.__importDefault(e(6960)),y=I=>{const w=(0,p.useInjectable)(p.LabelService),T=(0,p.useInjectable)(p.CommandService),R=(L,B,U)=>{let W=w.getIcon(L,{isDirectory:B});return B&&U&&(W+=" expanded"),W},P=(0,o.useMemo)(()=>{const L=B=>{const U=typeof B.type=="number"?B.type===a.FileType.Directory:!!B.children,W=new a.URI(B.uri);return{label:B.label,iconClassName:R(W,U,U),expandable:!0,expanded:!0,children:U?(B.children||[]).map(L):null,uri:W}};return(I.treeData.children||[]).map(L)},[I.treeData]),[O,M]=(0,o.useState)(22),k=(0,o.useRef)(null),F=L=>{k.current=L;const B=()=>{let U=L.getModel().root.branchSize;U<1?U=1:U>20&&(U=20),M(U*22)};B(),L.onDidUpdate(B)};return P.length?o.default.createElement("div",{className:d.default.tree_container},o.default.createElement(_.BasicRecycleTree,{height:O,treeData:P,onContextMenu:L=>L.preventDefault(),onClick:(L,B)=>{!k.current||!B||(v.BasicCompositeTreeNode.is(B)?B.raw.iconClassName=R(B.raw.uri,!0,B.expanded):T.executeCommand(p.EDITOR_COMMANDS.OPEN_RESOURCE.id,B.raw.uri,{disableNavigate:!0,preview:!0}))},onReady:F,treeName:I.treeData.label,leaveBottomBlank:!1,baseIndent:0})):null},b=I=>{const{toolCall:w,messageId:T}=I,R=(0,p.useInjectable)(a.ChatAgentViewServiceToken),[P,O]=(0,o.useState)(null);return(0,o.useEffect)(()=>{const M=R.getChatComponent("toolCall");if(M){const{component:F,initialProps:L}=M;O(o.default.createElement(F,{...L,value:w,messageId:T}));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"))),R.getChatComponentDeferred("toolCall").promise.then(({component:F,initialProps:L})=>{O(o.default.createElement(F,{...L,value:w,messageId:T}))})},[w.state]),P},A=I=>{const w=(0,p.useInjectable)(a.ChatAgentViewServiceToken),[T,R]=(0,o.useState)(null);return(0,o.useEffect)(()=>{const P=w.getChatComponent(I.component);if(P){const{component:M,initialProps:k}=P;R(o.default.createElement(M,{...k,value:I.value,messageId:I.messageId}));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"))),w.getChatComponentDeferred(I.component).promise.then(({component:M,initialProps:k})=>{R(o.default.createElement(M,{...k,value:I.value}))})},[I.component,I.value]),T},S=I=>{var w,T;const{relationId:R,request:P,startTime:O=0,onRegenerate:M,onDidChange:k,onDone:F,agentId:L,command:B,history:U,msgId:W}=I,[,j]=(0,o.useReducer)(ge=>(ge+1)%1e6,0),Q=(0,p.useInjectable)(a.IAIReporter),G=(0,p.useInjectable)(h.IIconService),Z=(0,p.useInjectable)(p.IContextKeyService),$=(0,p.useInjectable)(c.IChatInternalService),V=(0,p.useInjectable)(a.ChatServiceToken),H=(0,p.useInjectable)(c.IChatAgentService),K=(0,p.useInjectable)(a.ChatRenderRegistryToken),[Y,X]=(0,o.useState)(P.response.isComplete?new Set(P.response.responseContents.map((ge,te)=>ge.kind==="reasoning"?te:-1).filter(ge=>ge!==-1)):new Set);(0,o.useEffect)(()=>{P.response.isComplete&&X(new Set(P.response.responseContents.map((ge,te)=>ge.kind==="reasoning"?te:-1).filter(ge=>ge!==-1)))},[P.response.isComplete]),(0,o.useEffect)(()=>{const ge=new p.DisposableCollection;return ge.push(P.response.onDidChange(()=>{U.updateAssistantMessage(W,{content:P.response.responseText}),P.response.isComplete&&(F&&F(),Q.end(R,{assistantMessage:P.response.responseText,replytime:Date.now()-O,success:!0,isStop:!1,command:B,agentId:L,messageId:W,sessionId:$.sessionModel.sessionId})),(0,o.startTransition)(()=>{k?.(),j()})})),()=>ge.dispose()},[R,k,F]);const re=(0,o.useCallback)(()=>{P.response.reset(),M?.()},[M]),oe=(0,o.useCallback)(ge=>{if(K.chatAIRoleRender){const te=K.chatAIRoleRender;return o.default.createElement(te,{content:ge.value})}return o.default.createElement(E.ChatMarkdown,{markdown:ge,fillInIncompleteTokens:!0})},[K,K.chatAIRoleRender]),he=ge=>o.default.createElement(y,{treeData:ge}),me=ge=>o.default.createElement("div",{className:d.default.placeholder},o.default.createElement(s.Icon,{iconClass:G.fromString("$(codicon/sync~spin)")}),o.default.createElement("div",{className:d.default.placeholder_content},oe(ge))),q=o.default.useMemo(()=>P.response.responseContents.map((ge,te)=>{let fe;if(ge.kind==="asyncContent")fe=me(new u.MarkdownString(ge.content));else if(ge.kind==="treeData")fe=he(ge.treeData);else if(ge.kind==="component")fe=o.default.createElement(A,{component:ge.component,value:ge.value,messageId:W});else if(ge.kind==="toolCall")fe=o.default.createElement(b,{toolCall:ge.content,messageId:W});else if(ge.kind==="reasoning"){const Oe=te===P.response.responseContents.length-1&&!P.response.isComplete;fe=o.default.createElement("div",{className:(0,r.default)(d.default.reasoning,{[d.default.thinking]:Oe})},o.default.createElement(l.Button,{size:"small",type:"secondary",className:d.default.thinking,onClick:()=>{Oe||(Y.has(te)?Y.delete(te):Y.add(te),X(new Set(Y)))}},o.default.createElement(s.Icon,{iconClass:"codicon codicon-sparkle"}),o.default.createElement("span",{style:{marginLeft:4},className:Oe?d.default.shiny_text:""},(0,a.localize)("aiNative.chat.thinking")),Oe?null:Y.has(te)?o.default.createElement(s.Icon,{iconClass:"codicon codicon-chevron-right"}):o.default.createElement(s.Icon,{iconClass:"codicon codicon-chevron-down"})),Y.has(te)?null:o.default.createElement("div",{className:d.default.reasoning_content},oe(new u.MarkdownString(ge.content))))}else fe=oe(ge.content);return o.default.createElement(o.Fragment,{key:`${ge.kind}-${te}`},fe)}),[P.response.responseContents,Y]),Ae=o.default.useMemo(()=>P.response.followups?P.response.followups.map((ge,te)=>{let fe=null;if(ge.kind==="reply"){const Oe=o.default.createElement("a",{onClick:()=>{V.sendMessage({...H.parseMessage(ge.message),reportExtra:{actionSource:a.ActionSourceEnum.Chat,actionType:a.ActionTypeEnum.Followup}})}},ge.title||ge.message);fe=ge.tooltip?o.default.createElement(m.Tooltip,{title:ge.tooltip},Oe):Oe}else ge.when&&!Z.match(ge.when)&&(fe=null),fe=o.default.createElement(l.Button,{type:"default"},ge.title);return fe&&o.default.createElement(o.Fragment,{key:te},fe)}):null,[P.response.followups]);return P.response.isComplete?o.default.createElement(f.ChatThinkingResult,{hasMessage:P.response.responseParts.length>0||P.response.responseContents.length>0||!!(!((w=P.response.errorDetails)===null||w===void 0)&&w.message),onRegenerate:re,requestId:P.requestId},o.default.createElement("div",{className:d.default.ai_chat_response_container},!((T=P.response.errorDetails)===null||T===void 0)&&T.message?o.default.createElement("div",{className:d.default.error},o.default.createElement(s.Icon,{className:(0,s.getIcon)("close-circle")}),o.default.createElement("span",null,P.response.errorDetails.message)):o.default.createElement(o.default.Fragment,null,q,Ae?.length!==0&&o.default.createElement("div",{className:d.default.followups},Ae)))):o.default.createElement(f.ChatThinking,{message:P.response.responseText},q)};t.ChatReply=S;const D=I=>{const{chunk:w}=I,T=(0,p.useInjectable)(a.ChatRenderRegistryToken),R=o.default.useMemo(()=>{let P;if(w.kind==="component")P=o.default.createElement(A,{component:w.component,value:w.value});else{let O=o.default.createElement(E.ChatMarkdown,{markdown:w.content,fillInIncompleteTokens:!0});if(T.chatAIRoleRender){const M=T.chatAIRoleRender;O=o.default.createElement(M,{content:w.content})}P=O}return P},[w]);return o.default.createElement(f.ChatThinkingResult,{hasMessage:!0,requestId:I.requestId,showRegenerate:!1},o.default.createElement("div",{className:d.default.ai_chat_response_container},R))};t.ChatNotify=D},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),l=e(89195),_=e(68974),v=e(43718),m=e(19413),p=n.__importDefault(e(6960)),s=a=>{const{children:h,message:u,thinkingText:c}=a,E=(0,o.useInjectable)(v.ChatRenderRegistryToken),f=(0,r.useMemo)(()=>E.chatThinkingRender,[E,E.chatThinkingRender]),d=(0,r.useMemo)(()=>Array.isArray(h)?h.length===0:!h,[h]),y=(0,r.useCallback)(()=>d?f?r.default.createElement(f,{thinkingText:c}):r.default.createElement("span",{className:p.default.thinking_text},c||"Thinking..."):h,[u,h,c,f]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{className:p.default.content},y()),r.default.createElement("div",{className:p.default.thinking_container},r.default.createElement("div",{className:p.default.stop},!f&&r.default.createElement("span",{className:p.default.progress_bar},d&&r.default.createElement(_.Progress,{loading:!0,wrapperClassName:p.default.ai_native_progress_wrapper})))))};t.ChatThinking=s;const g=({children:a,message:h,onRegenerate:u,requestId:c,hasMessage:E=!0,showRegenerate:f})=>{const d=(0,o.useInjectable)(m.IChatInternalService),[y,b]=(0,r.useState)(d.latestRequestId),A=(0,o.useInjectable)(v.ChatRenderRegistryToken);(0,r.useEffect)(()=>{const T=d.onChangeRequestId(R=>{b(R)});return()=>T.dispose()},[d]);const S=(0,r.useMemo)(()=>A.chatThinkingResultRender,[A,A.chatThinkingResultRender]),D=(0,r.useCallback)(()=>{u&&u()},[u]),I=(0,r.useCallback)(()=>{if(typeof E=="boolean"?!E:!h?.trim()){const T=(0,v.localize)("aiNative.chat.stop.immediately");return S?r.default.createElement(S,{thinkingResult:T}):r.default.createElement("span",null,T)}return a},[h,E,a]),w=(0,r.useMemo)(()=>(0,v.isUndefined)(f)?y===c&&!!c:!!f,[y,c,f]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{className:p.default.content},I()),r.default.createElement("div",{className:p.default.thinking_container},r.default.createElement("div",{className:p.default.bottom_container},r.default.createElement("div",{className:p.default.reset},w?r.default.createElement(l.EnhanceIcon,{icon:"refresh",wrapperClassName:p.default.text_btn,className:p.default.transform,onClick:D,tabIndex:0,role:"button"},r.default.createElement("span",null,(0,v.localize)("aiNative.operate.afresh.title"))):null),r.default.createElement("div",{className:p.default.thumbs},r.default.createElement(l.Thumbs,{relationId:c,wrapperClassName:p.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)),l=e(41869),_=e(81878),v=e(89195),m=e(43718),p=e(33783),s=e(98864),g=e(77633),a=e(25834),h=n.__importDefault(e(16796)),u=e(78112),c=E=>{var f,d,y;const{value:b,messageId:A}=E,[S,D]=(0,o.useState)(!1),I=(0,l.useInjectable)(g.TokenMCPServerRegistry);if(!b||!b.function||!b.id)return null;const w=((f=I.getMCPTool(b.function.name))===null||f===void 0?void 0:f.label)||b.function.name,T=w.split(s.TOOL_NAME_SEPARATOR),R=T.length>=3?T[2]:w,P=I.getToolComponent(b.function.name),O=L=>{switch(L){case"streaming-start":case"streaming":return{label:"Generating",icon:o.default.createElement(v.Loading,null)};case"complete":return{label:"Complete",icon:o.default.createElement(_.Icon,{iconClass:"codicon codicon-check"})};case"result":return{label:"Result Ready",icon:o.default.createElement(_.Icon,{iconClass:"codicon codicon-check-all"})};default:return{label:L||"Unknown",icon:o.default.createElement(_.Icon,{iconClass:"codicon codicon-question"})}}},M=()=>{var L;try{return b.state!=="complete"&&b.state!=="result"?{}:JSON.parse(((L=b.function)===null||L===void 0?void 0:L.arguments)||"{}")}catch{return{}}},k=()=>{D(!S)},F=O(b.state);return P&&(b.state==="complete"||b.state==="result")?o.default.createElement(P,{state:b.state,args:M(),result:b.result,index:b.index,messageId:A,toolCallId:b.id}):o.default.createElement("div",{className:h.default.chat_tool_render},o.default.createElement("div",{className:h.default.tool_header,onClick:k},o.default.createElement("div",{className:h.default.tool_name},o.default.createElement(_.Icon,{iconClass:`codicon codicon-chevron-${S?"down":"right"}`}),o.default.createElement(_.Icon,{size:"small",iconClass:(0,r.default)("codicon codicon-tools",h.default.tool_icon)}),o.default.createElement("span",{className:h.default.tool_label},o.default.createElement("span",{className:h.default.tool_prefix},"Called MCP Tool"),o.default.createElement("span",{className:h.default.tool_name,title:R},R))),b.state&&o.default.createElement("div",{className:h.default.tool_state},o.default.createElement("span",{className:h.default.state_icon},F.icon))),o.default.createElement("div",{className:(0,r.default)(h.default.tool_content,{[h.default.expanded]:S})},((d=b?.function)===null||d===void 0?void 0:d.arguments)&&o.default.createElement("div",{className:h.default.tool_arguments},o.default.createElement("div",{className:h.default.section_label},(0,p.localize)("ai.native.mcp.tool.arguments"),":"),o.default.createElement(a.CodeEditorWithHighlight,{input:(y=b?.function)===null||y===void 0?void 0:y.arguments,language:"json",relationId:(0,m.uuid)(4)})),b?.result&&o.default.createElement("div",{className:h.default.tool_result},o.default.createElement("div",{className:h.default.section_label},(0,p.localize)("ai.native.mcp.tool.results"),":"),o.default.createElement(u.ChatToolResult,{result:b.result,relationId:(0,m.uuid)(4)}))))};t.ChatToolRender=c},78112:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatToolResult=void 0;const n=e(85608),r=n.__importDefault(e(14041)),o=e(33783),l=e(25834),_=n.__importDefault(e(48091)),v=({result:m,relationId:p})=>{const s=r.default.useCallback(h=>{try{return JSON.parse(h).content||[]}catch{return[{type:"text",text:h}]}},[]),g=r.default.useCallback((h,u)=>{switch(h.type){case"text":return h.text?r.default.createElement("div",{key:`text-${u}`,className:_.default.text_content},r.default.createElement(l.CodeEditorWithHighlight,{input:h.text,language:"text",relationId:p||""})):null;case"image":return h.data?r.default.createElement("div",{key:`image-${u}`,className:_.default.image_content},r.default.createElement("img",{src:`data:${h.mimeType||"image/png"};base64,${h.data}`,alt:(0,o.localize)("aiNative.chat.result.image")})):null;default:return null}},[p]),a=r.default.useMemo(()=>s(m),[m,s]);return a.length?r.default.createElement("div",{className:_.default.result_container},a.map((h,u)=>g(h,u))):null};t.ChatToolResult=v},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),l=e(43718),_=e(19413),v=m=>{const{userMessage:p,relationId:s,requestId:g,renderContent:a,startTime:h,agentId:u,command:c}=m,E=(0,o.useInjectable)(_.IChatInternalService),f=(0,o.useInjectable)(l.IAIReporter);return r.useEffect(()=>{E.setLatestRequestId(g),f.end(s,{message:p,replytime:Date.now()-h,success:!0,isStop:!1,agentId:u,command:c})},[a,g,s]),r.createElement("div",null,a({userMessage:p}))};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),l=e(81878),_=e(4246),v=e(43718),m=e(90684);e(41937);const p=e(19413),s=e(56474),g=e(17319),a=e(78048),h=n.__importDefault(e(6960)),u=()=>{var c,E;const f=(0,o.useInjectable)(v.ChatServiceToken),d=(0,o.useInjectable)(p.IChatAgentService),y=(0,o.useInjectable)(v.ChatFeatureRegistryToken),b=(0,o.useInjectable)(v.ChatRenderRegistryToken),[A,S]=r.useState([]);(0,o.useUpdateOnEvent)(y.onDidWelcomeMessageChange);const D=r.useMemo(()=>{if(!y.chatWelcomeMessageModel)return[];const{sampleQuestions:R=[]}=y.chatWelcomeMessageModel;return R.map(a.extractIcon)},[(c=y.chatWelcomeMessageModel)===null||c===void 0?void 0:c.sampleQuestions]),I=r.useMemo(()=>{if(!y.chatWelcomeMessageModel)return"";const{content:R}=y.chatWelcomeMessageModel;return R},[(E=y.chatWelcomeMessageModel)===null||E===void 0?void 0:E.content]);if(r.useEffect(()=>{const R=d.onDidChangeAgents(async()=>{const O=(await d.getAllSampleQuestions()).map(a.extractIcon);S(O)});return()=>R.dispose()},[]),!I)return r.createElement(g.ChatThinking,{thinkingText:(0,v.localize)("aiNative.chat.welcome.loading.text")});const w=r.useMemo(()=>D.concat(A),[D,A]);return r.useMemo(()=>{if(b.chatWelcomeRender){const R=b.chatWelcomeRender;return r.createElement(R,{message:I,sampleQuestions:w})}return r.createElement("div",{className:h.default.chat_welcome_head},r.createElement("div",{className:h.default.chat_container_des},(0,m.isMarkdownString)(I)?r.createElement(s.ChatMarkdown,{key:"welcome",markdown:I}):I),r.createElement("div",{className:h.default.chat_container_content},w.map((R,P)=>{const O=r.createElement("a",{className:h.default.link_item,onClick:(0,_.withPrevented)(()=>{f.sendMessage({...d.parseMessage(R.message),reportExtra:{actionType:v.ActionTypeEnum.Welcome,actionSource:v.ActionSourceEnum.Chat}})})},R.icon?r.createElement(l.Icon,{className:R.icon,style:{color:"inherit",marginRight:"4px"}}):"",r.createElement("span",null,R.title));return R.tooltip?r.createElement(l.Tooltip,{title:R.tooltip,key:P},O):r.createElement(r.Fragment,{key:P},O)})))},[b.chatWelcomeRender,I,w])};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)),l=e(41869),_=e(81878),v=e(89195),m=e(70392),p=n.__importDefault(e(97599)),s=e(80732),g=e(37412),a=e(44692);t.WHITE_SPACE_TEXT=" ";const h=({mentionItems:u=[],onSend:c,onStop:E,loading:f=!1,mentionKeyword:d=a.MENTION_KEYWORD,onSelectionChange:y,onImageUpload:b,labelService:A,workspaceService:S,placeholder:D="Ask anything, @ to mention",footerConfig:I={buttons:[],showModelSelector:!1},contextService:w})=>{const T=o.useRef(null),[R,P]=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}),[O,M]=o.useState(I.defaultModel||""),[k,F]=o.useState({}),[L,B]=o.useState([]),[U,W]=o.useState(-1),[j,Q]=o.useState(""),[G,Z]=o.useState(!1),[$,V]=o.useState({files:[],folders:[],rules:[]}),H=o.useRef([]),K=()=>R.level===0?u:R.parentType?R.loading?k[R.parentType]||[]:k[R.parentType]||[]:[],X=((ie,le)=>{const[Se,ye]=o.useState(ie);return o.useEffect(()=>{const Ue=setTimeout(()=>{ye(ie)},le);return()=>{clearTimeout(Ue)}},[ie,le]),Se})(R.secondLevelFilter,300);o.useEffect(()=>{M(I.defaultModel||"")},[I.defaultModel]),o.useEffect(()=>{if(R.level===1&&R.parentType&&X!==void 0){const ie=u.find(Se=>Se.id===R.parentType);if(!ie)return;P(Se=>({...Se,loading:!0})),(async()=>{try{const Se=[];if(ie.getHighestLevelItems){const ye=ie.getHighestLevelItems();for(const Ue of ye)Se.some(Ye=>Ye.id===Ue.id)||Se.push(Ue);F(Ue=>({...Ue,[R.parentType]:ye}))}if(ie.getItems)try{const ye=await ie.getItems(X),Ue=[...Se];for(const Ye of ye)Ue.some(Ve=>Ve.id===Ye.id)||Ue.push(Ye);F(Ye=>({...Ye,[R.parentType]:Ue}))}catch{P(Ue=>({...Ue,loading:!1}))}P(ye=>({...ye,loading:!1}))}catch{P(ye=>({...ye,loading:!1}))}})()}},[X,R.level,R.parentType]),o.useEffect(()=>{const ie=w?.onDidContextFilesChangeEvent(({attached:le,attachedFolders:Se,attachedRules:ye})=>{V({files:le,folders:Se,rules:ye})});return()=>{ie?.dispose()}},[]);const re=ie=>{const le=window.getSelection();if(!le||!le.rangeCount)return 0;const Se=le.getRangeAt(0),ye=Se.cloneRange();return ye.selectNodeContents(ie),ye.setEnd(Se.endContainer,Se.endOffset),ye.toString().length},oe=()=>{if(G&&(Z(!1),W(-1)),T.current){const ye=Array.from(T.current.querySelectorAll(`.${p.default.mention_tag}`)).map(Ye=>({id:Ye.getAttribute("data-id")||"",type:Ye.getAttribute("data-type")||"",contextId:Ye.getAttribute("data-context-id")||""}));H.current.filter(Ye=>!ye.some(Ve=>Ve.id===Ye.id&&Ve.type===Ye.type&&Ve.contextId===Ye.contextId)).forEach(Ye=>{if(Ye.contextId){const Ve=new m.URI(Ye.contextId);Ye.type===a.MentionType.FILE?Te(a.MentionType.FILE,Ve):Ye.type===a.MentionType.FOLDER?Te(a.MentionType.FOLDER,Ve):Ye.type===a.MentionType.RULE&&Te(a.MentionType.RULE,Ve)}}),H.current=ye}const ie=window.getSelection();if(!ie||!ie.rangeCount||!T.current)return;const le=T.current.textContent||"",Se=re(T.current);if(le[Se-1]===d&&!R.active&&!R.inlineSearchActive&&P({active:!0,startPos:Se,filter:d,position:{top:0,left:0},activeIndex:0,level:0,parentType:null,secondLevelFilter:"",inlineSearchActive:!1,inlineSearchStartPos:null,loading:!1}),R.active&&R.level===0&&R.startPos!==null)if(Se<R.startPos)P(ye=>({...ye,active:!1}));else{const ye=le.substring(R.startPos-1,Se);P(Ue=>({...Ue,filter:ye,activeIndex:0}))}if(R.inlineSearchActive&&R.inlineSearchStartPos!==null&&R.parentType){const ye=u.find(Ve=>Ve.id===R.parentType);if(!ye)return;const Ue=`@${ye.type}:`,Ye=R.inlineSearchStartPos-Ue.length;if(Ye>=0&&Se>Ye+Ue.length){const Ve=le.substring(Ye+Ue.length,Se);Ve!==R.secondLevelFilter&&P(pt=>({...pt,secondLevelFilter:Ve,active:!0,activeIndex:0}))}else Se<=Ye&&P(Ve=>({...Ve,inlineSearchActive:!1,active:!1}))}if(T.current&&(T.current.scrollHeight>=120?T.current.style.overflowY="auto":T.current.style.overflowY="hidden"),T.current){const ye=T.current.innerHTML;(ye===""||ye==="<br>"||ye==="<br/>")&&(T.current.innerHTML="")}},he=ie=>{if(ie.key==="Escape"&&(R.active||R.inlineSearchActive)){R.level>0?P(Se=>({...Se,level:0,activeIndex:0,secondLevelFilter:"",inlineSearchActive:!1})):P(Se=>({...Se,active:!1,inlineSearchActive:!1})),ie.preventDefault();return}if((ie.key==="Backspace"||ie.key==="Delete")&&T.current&&(!T.current.textContent||T.current.textContent.trim()==="")&&w?.cleanFileContext(),ie.key===a.MENTION_KEYWORD&&!R.active&&!R.inlineSearchActive&&T.current){const Se=re(T.current);P({active:!0,startPos:Se+1,filter:d,position:{top:0,left:0},activeIndex:0,level:0,parentType:null,secondLevelFilter:"",inlineSearchActive:!1,inlineSearchStartPos:null,loading:!1})}if((ie.key==="ArrowUp"||ie.key==="ArrowDown")&&!ie.shiftKey&&!ie.ctrlKey&&!ie.metaKey&&!ie.altKey){if(!R.active&&!R.inlineSearchActive&&T.current&&L.length>0){const Se=T.current.innerHTML;if(!Se||Se==="<br>"||G&&U>=0&&L[L.length-1-U]===Se){ie.preventDefault(),G||(Q(Se),Z(!0));let Ue=U;ie.key==="ArrowUp"?Ue=Math.min(L.length-1,U+1):Ue=Math.max(-1,U-1),W(Ue),Ue===-1?T.current.innerHTML=j:T.current.innerHTML=L[L.length-1-Ue];const Ye=document.createRange();Ye.selectNodeContents(T.current),Ye.collapse(!1);const Ve=window.getSelection();Ve&&(Ve.removeAllRanges(),Ve.addRange(Ye));return}}}else G&&ie.key!=="ArrowUp"&&ie.key!=="ArrowDown"&&(Z(!1),W(-1));if(ie.key==="Enter"){if(ie.nativeEvent.isComposing)return;if(!ie.shiftKey&&(ie.preventDefault(),!R.active)){fe();return}}if(!R.active)return;let le=K();if(R.level===0&&R.filter&&R.filter.length>1){const Se=R.filter.substring(1).toLowerCase();le=le.filter(ye=>ye.text.toLowerCase().includes(Se))}le.length!==0&&(ie.key==="ArrowDown"?(P(Se=>({...Se,activeIndex:(Se.activeIndex+1)%le.length})),ie.preventDefault()):ie.key==="ArrowUp"?(P(Se=>({...Se,activeIndex:(Se.activeIndex-1+le.length)%le.length})),ie.preventDefault()):(ie.key==="Enter"||ie.key==="Tab")&&le.length>0&&(ge(le[R.activeIndex]),ie.preventDefault()))},me=()=>{},q=async ie=>{const le=ie.clipboardData.items,Se=[];for(let lt=0;lt<le.length;lt++)if(le[lt].kind===a.MentionType.FILE&&le[lt].type.startsWith("image/")){const wt=le[lt].getAsFile();wt&&Se.push(wt)}if(ie.preventDefault(),Se.length>0&&b){await b(Se);return}const Ue=ie.clipboardData.getData("text/plain").replace(/\t/g," ").replace(/\n\s*\n/g,`
|
|
32881
32881
|
|
|
32882
32882
|
`).replace(/[ \t]+$/gm,""),Ye=window.getSelection();if(!Ye||!Ye.rangeCount)return;const Ve=Ye.getRangeAt(0);Ve.deleteContents();const pt=Ue.split(`
|
|
32883
|
-
`),vt=document.createDocumentFragment();pt.forEach((lt,wt)=>{const at=lt.replace(/^[ ]+/g,st=>{const At=document.createElement("span");return At.innerHTML="\xA0".repeat(st.length),At.innerHTML}),tt=document.createElement("span");for(tt.innerHTML=at;tt.firstChild;)vt.appendChild(tt.firstChild);wt<pt.length-1&&vt.appendChild(document.createElement("br"))});const xt=vt.lastChild;if(Ve.insertNode(vt),xt&&xt.parentNode){const lt=document.createRange();lt.setStartAfter(xt),Ye.removeAllRanges(),Ye.addRange(lt)}oe()};o.useEffect(()=>{if(T.current){D&&!T.current.textContent&&T.current.setAttribute("data-placeholder",D);const ie=Array.from(T.current.querySelectorAll(`.${p.default.mention_tag}`)).map(le=>({id:le.getAttribute("data-id")||"",type:le.getAttribute("data-type")||"",contextId:le.getAttribute("data-context-id")||""}));H.current=ie}},[D]);const Ae=ie=>{var le;R.active&&!(!((le=document.querySelector(`.${p.default.mention_panel}`))===null||le===void 0)&&le.contains(ie.target))&&P(Se=>({...Se,active:!1,inlineSearchActive:!1}))};o.useEffect(()=>(document.addEventListener("click",Ae,!0),()=>{document.removeEventListener("click",Ae,!0)}),[R.active]);const ge=(ie,le=!1)=>{var Se;if(!T.current)return;if(ie.getItems){const tt=window.getSelection();if(!tt||!tt.rangeCount)return;if(R.level===0&&R.startPos!==null){let st,At,Ut;const _n=document.createTreeWalker(T.current,NodeFilter.SHOW_TEXT);let Ln=0,ui;for(;ui=_n.nextNode();){const Rn=((Se=ui.textContent)===null||Se===void 0?void 0:Se.length)||0;if(R.startPos-1>=Ln&&R.startPos-1<Ln+Rn){st=ui,At=R.startPos-1-Ln;const ln=le?R.startPos+R.filter.length-1:re(T.current);Ut=Math.min(ln-Ln,Rn);break}Ln+=Rn}if(st){const Rn=document.createRange();Rn.setStart(st,At),Rn.setEnd(st,Ut),Rn.deleteContents();const ln=document.createTextNode(`${d}${ie.type}:`);Rn.insertNode(ln);const Un=document.createRange();Un.setStartAfter(ln),Un.setEndAfter(ln),tt.removeAllRanges(),tt.addRange(Un),P(rn=>({...rn,active:!0,level:1,parentType:ie.id,inlineSearchActive:!0,inlineSearchStartPos:re(T.current),secondLevelFilter:"",activeIndex:0})),T.current.focus();return}}return}const ye=window.getSelection();if(!ye||!ye.rangeCount)return;if(R.inlineSearchActive&&R.parentType&&R.inlineSearchStartPos!==null){const tt=u.find(Ut=>Ut.id===R.parentType);if(!tt)return;const st=`${d}${tt.type}:`,At=R.inlineSearchStartPos-st.length;if(At>=0){let ct=function($e){if($e.nodeType===3)rn.push({node:$e,start:ln,end:ln+$e.textContent.length}),ln+=$e.textContent.length;else if($e.nodeType===1){const Re=$e.childNodes||[];for(const Le of Array.from(Re))ct(Le)}};const Ut=document.createElement("span");if(Ut.className=p.default.mention_tag,Ut.dataset.id=ie.id,Ut.dataset.type=ie.type,Ut.dataset.contextId=ie.contextId||"",Ut.contentEditable="false",ie.type===a.MentionType.FILE||ie.type===a.MentionType.FOLDER){const $e=document.createElement("span");$e.className=(0,r.default)(p.default.mention_icon,ie.type===a.MentionType.FILE?A?.getIcon(new m.URI(ie.text)):(0,_.getIcon)("folder")),Ut.appendChild($e),ie.type===a.MentionType.FOLDER?w?.addFolderToContext(new m.URI(ie.contextId),!0):w?.addFileToContext(new m.URI(ie.contextId),void 0,!0)}else if(ie.type===a.MentionType.CODE){const $e=document.createElement("span");$e.className=(0,r.default)(p.default.mention_icon,ie.kind&&(0,l.getSymbolIcon)(ie.kind)+" outline-icon"),Ut.appendChild($e),ie.symbol&&w?.addFileToContext(new m.URI(ie.contextId),[ie.symbol.range.startLineNumber,ie.symbol.range.endLineNumber],!0)}else if(ie.type===a.MentionType.RULE){const $e=document.createElement("span");$e.className=(0,r.default)(p.default.mention_icon,(0,_.getIcon)("rules")),Ut.appendChild($e),w?.addRuleToContext(new m.URI(ie.contextId),!0)}const _n=S?.workspace;let Ln=ie.text;_n&&ie.contextId&&(Ln=ie.contextId.replace(new m.URI(_n.uri).codeUri.fsPath,"").slice(1));const ui=document.createTextNode(Ln);Ut.appendChild(ui);const Rn=document.createRange();let ln=0,Un=!1;const rn=[];ct(T.current);for(const $e of rn){if(At>=$e.start&&At<=$e.end){const Re=At-$e.start;Rn.setStart($e.node,Re),Un=!0}if(Un){const Re=le?At+st.length+R.secondLevelFilter.length:re(T.current);if(Re>=$e.start&&Re<=$e.end){const Le=Re-$e.start;Rn.setEnd($e.node,Le);break}}}if(Un){Rn.deleteContents(),Rn.insertNode(Ut);const $e=document.createRange();$e.setStartAfter(Ut),$e.setEndAfter(Ut),ye.removeAllRanges(),ye.addRange($e);const Re=document.createTextNode("\xA0");$e.insertNode(Re),$e.setStartAfter(Re),$e.setEndAfter(Re),ye.removeAllRanges(),ye.addRange($e)}P($e=>({...$e,active:!1,inlineSearchActive:!1})),T.current.focus();return}}const Ue=document.createElement("span");if(Ue.className=p.default.mention_tag,Ue.dataset.id=ie.id,Ue.dataset.type=ie.type,Ue.dataset.contextId=ie.contextId||"",Ue.contentEditable="false",ie.type===a.MentionType.FILE||ie.type==="folder"){const tt=document.createElement("span");tt.className=(0,r.default)(p.default.mention_icon,ie.type===a.MentionType.FILE?A?.getIcon(new m.URI(ie.text)):(0,_.getIcon)("folder")),Ue.appendChild(tt)}const Ye=S?.workspace;let Ve=ie.text;Ye&&ie.contextId&&(Ve=ie.contextId.replace(new m.URI(Ye.uri).codeUri.fsPath,"").slice(1));const pt=document.createTextNode(Ve);Ue.appendChild(pt);let vt=0,xt=!1;const lt=[];function wt(tt){if(tt.nodeType===3)lt.push({node:tt,start:vt,end:vt+tt.textContent.length}),vt+=tt.textContent.length;else if(tt.nodeType===1){const st=tt.childNodes;for(const At of Array.from(st))wt(At)}}wt(T.current);const at=document.createRange();if(R.startPos!==null)for(const tt of lt){if(R.startPos-1>=tt.start&&R.startPos-1<=tt.end){const st=R.startPos-1-tt.start;at.setStart(tt.node,st),xt=!0}if(xt){const st=le?R.startPos+R.filter.length-1:re(T.current);if(st>=tt.start&&st<=tt.end){const At=st-tt.start;at.setEnd(tt.node,At);break}}}if(xt){at.deleteContents(),at.insertNode(Ue);const tt=document.createRange();tt.setStartAfter(Ue),tt.setEndAfter(Ue),ye.removeAllRanges(),ye.addRange(tt);const st=document.createTextNode("\xA0");tt.insertNode(st),tt.setStartAfter(st),tt.setEndAfter(st),ye.removeAllRanges(),ye.addRange(tt)}P(tt=>({...tt,active:!1})),T.current.focus()},te=o.useCallback(ie=>{M(ie),y?.(ie)},[O,y]),fe=()=>{if(!T.current)return;const ie=T.current.innerHTML;if(!ie)return;const le=document.createElement("div");le.innerHTML=ie,le.querySelectorAll(`.${p.default.mention_tag}`).forEach(Ue=>{var Ye;const Ve=Ue.getAttribute("data-context-id");if(Ve){const pt=document.createTextNode(`{{${d}${Ue.getAttribute("data-type")}:${Ve}}}`);(Ye=Ue.parentNode)===null||Ye===void 0||Ye.replaceChild(pt,Ue)}});let ye=le.innerHTML;ye=ye.trim().replaceAll(t.WHITE_SPACE_TEXT," "),ie&&(B(Ue=>[...Ue,ie]),W(-1),Z(!1)),c&&c(ye,{model:O,...I}),T.current.innerHTML="",T.current&&(T.current.style.overflowY="hidden",T.current.style.height="auto")},Oe=o.useCallback(()=>{w?.cleanFileContext()},[w]),xe=o.useCallback(()=>{if(!T.current)return;T.current.focus();const ie=window.getSelection();if(!ie)return;const le=document.createRange();if(!T.current.textContent||T.current.textContent.trim()==="")T.current.innerHTML="@",le.setStart(T.current.firstChild||T.current,1),le.setEnd(T.current.firstChild||T.current,1);else{const ye=document.createTextNode(" @");le.selectNodeContents(T.current),le.collapse(!1),le.insertNode(ye),le.setStartAfter(ye),le.setEndAfter(ye)}ie.removeAllRanges(),ie.addRange(le);const Se=re(T.current);P({active:!0,startPos:Se,filter:"@",position:{top:0,left:0},activeIndex:0,level:0,parentType:null,secondLevelFilter:"",inlineSearchActive:!1,inlineSearchStartPos:null,loading:!1})},[]),Me=o.useCallback(()=>{E&&E()},[E]),Be=o.useCallback(ie=>(I.buttons||[]).filter(le=>le.position===ie).map(le=>o.createElement(_.Popover,{key:le.id,overlayClassName:p.default.popover_icon,id:`ai-chat-${le.id}`,position:_.PopoverPosition.top,title:le.title},o.createElement(v.EnhanceIcon,{className:(0,r.default)(le.icon?(0,_.getIcon)(le.icon):le.iconClass,p.default[`${le.id}_logo`]),tabIndex:0,role:"button",ariaLabel:le.title,onClick:le.onClick}))),[I.buttons]),De=o.useMemo(()=>$.files.length>0||$.folders.length>0||$.rules.length>0,[$]),_e=o.useCallback(ie=>I.disableModelSelector?o.createElement(_.Popover,{id:"ai-chat-model-selector",title:(0,l.localize)("aiNative.chat.modelSelector.disableTip"),position:_.PopoverPosition.top},ie):ie,[I.disableModelSelector]),Ne=o.useMemo(()=>I.extendedModelOptions?I.extendedModelOptions.map(ie=>({...ie,selected:ie.value===O})):(I.modelOptions||[]).map(ie=>{const le={...ie};return le.selected=ie.value===O,le}),[I.modelOptions,I.extendedModelOptions,O]),Te=o.useCallback((ie,le)=>{ie===a.MentionType.FILE?w?.removeFileFromContext(le,!0):ie===a.MentionType.FOLDER?w?.removeFolderFromContext(le):ie===a.MentionType.RULE&&w?.removeRuleFromContext(le)},[w]),We=ie=>decodeURIComponent(ie.split("/").pop()||"Unknown Rule"),pe=o.useCallback(()=>o.createElement("div",{className:p.default.context_preview_container},o.createElement("span",{className:(0,r.default)(p.default.context_preview_title,De&&p.default.has_context),onClick:xe},De?"":(0,l.localize)("aiNative.chat.context.title")),$.files.map((ie,le)=>o.createElement("div",{key:`file-${le}`,className:p.default.context_preview_item,"data-type":a.MentionType.FILE,onClick:()=>w?.removeFileFromContext(ie.uri,!0)},o.createElement(_.Icon,{iconClass:(0,r.default)(A?.getIcon(ie.uri)||a.MentionType.FILE,p.default.context_preview_item_icon,p.default.icon)}),o.createElement(_.Icon,{iconClass:(0,r.default)(p.default.close_icon,(0,_.getIcon)("close")),onClick:()=>Te(a.MentionType.FILE,ie.uri)}),o.createElement("span",{className:p.default.context_preview_item_text},new m.URI(ie.uri.toString()).displayName))),$.folders.map((ie,le)=>o.createElement("div",{key:`folder-${le}`,className:p.default.context_preview_item,"data-type":"folder",onClick:()=>w?.removeFileFromContext(ie.uri,!0)},o.createElement(_.Icon,{iconClass:(0,r.default)((0,_.getIcon)("folder"),p.default.context_preview_item_icon,p.default.icon)}),o.createElement(_.Icon,{iconClass:(0,r.default)(p.default.close_icon,(0,_.getIcon)("close")),onClick:()=>Te(a.MentionType.FOLDER,ie.uri)}),o.createElement("span",{className:p.default.context_preview_item_text},new m.URI(ie.uri.toString()).displayName))),$.rules.map((ie,le)=>o.createElement("div",{key:`rule-${le}`,className:p.default.context_preview_item,"data-type":"rule",onClick:()=>{w?.cleanFileContext(),$.files.forEach(Se=>w?.addFileToContext(Se.uri,Se.selection,!0)),$.folders.forEach(Se=>w?.addFolderToContext(Se.uri,!0)),$.rules.forEach((Se,ye)=>{ye!==le&&w?.addRuleToContext(new m.URI(Se.path),!0)})}},o.createElement(_.Icon,{iconClass:(0,r.default)((0,_.getIcon)("rules"),p.default.context_preview_item_icon,p.default.icon)}),o.createElement(_.Icon,{iconClass:(0,r.default)(p.default.close_icon,(0,_.getIcon)("close")),onClick:()=>Te(a.MentionType.RULE,new m.URI(ie.path))}),o.createElement("span",{className:p.default.context_preview_item_text},We(ie.path))))),[Oe,De,$,A,w,xe,Te]);return o.createElement("div",{className:p.default.input_container},pe(),R.active&&o.createElement("div",{className:p.default.mention_panel_container},o.createElement(s.MentionPanel,{items:K(),activeIndex:R.activeIndex,onSelectItem:ie=>ge(ie,!0),position:{top:0,left:0},filter:R.level===0?R.filter:R.secondLevelFilter,visible:!0,level:R.level,loading:R.loading})),o.createElement("div",{className:p.default.editor_area},o.createElement("div",{ref:T,className:p.default.editor,contentEditable:!0,onInput:oe,onKeyDown:he,onPaste:q,onCompositionEnd:me})),o.createElement("div",{className:p.default.footer},o.createElement("div",{className:p.default.left_control},I.showModelSelector&&_e(o.createElement(g.MentionSelect,{options:Ne,value:O,onChange:te,className:p.default.model_selector,size:"small",disabled:I.disableModelSelector,showThinking:I.showThinking,thinkingEnabled:I.thinkingEnabled,onThinkingChange:I.onThinkingChange})),Be(a.FooterButtonPosition.LEFT)),o.createElement("div",{className:p.default.right_control},Be(a.FooterButtonPosition.RIGHT),o.createElement(_.Popover,{overlayClassName:p.default.popover_icon,id:"ai-chat-send",position:_.PopoverPosition.top,content:f?"Stop":"Send"},f?o.createElement(v.EnhanceIcon,{wrapperClassName:p.default.stop_logo,className:(0,r.default)((0,_.getIcon)("stop"),p.default.stop_logo_icon),tabIndex:0,role:"button",ariaLabel:"Stop",onClick:Me}):o.createElement(v.EnhanceIcon,{wrapperClassName:p.default.send_logo,className:(0,r.default)((0,_.getIcon)("send-outlined"),p.default.send_logo_icon),tabIndex:0,role:"button",onClick:fe,ariaLabel:"Send"})))))};t.MentionInput=h},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)),l=e(81878),_=n.__importDefault(e(97599)),v=({item:m,isActive:p,onClick:s})=>o.createElement("div",{className:`${_.default.mention_item} ${p?_.default.active:""}`,onClick:()=>s(m)},o.createElement("div",{className:_.default.mention_item_left},o.createElement(l.Icon,{className:(0,r.default)(_.default.mention_item_icon,m.icon)}),o.createElement("span",{className:_.default.mention_item_text},m.text),o.createElement("span",{className:_.default.mention_item_description},m.description)),m.getItems&&o.createElement(l.Icon,{className:(0,r.default)(_.default.mention_item_right,(0,l.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)),l=e(40167),_=({items:v,activeIndex:m,onSelectItem:p,position:s,filter:g,visible:a,level:h,loading:u=!1})=>{const c=r.useRef(null);if(r.useEffect(()=>{if(a&&c.current){const d=c.current.querySelector(`.${o.default.mention_item}.${o.default.active}`);d&&d.scrollIntoView({block:"nearest"})}},[m,a]),!a)return null;const f=(()=>{let d=v;if(h===0){if(g&&g.length>1){const y=g.substring(1).toLowerCase();d=v.filter(b=>b.text.toLowerCase().includes(y))}}else g&&g.length>0&&(d=v.filter(y=>y.text.toLowerCase().includes(g.toLowerCase())));return d})();return h===0&&f.length===0?null:r.createElement("div",{ref:c,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((d,y)=>r.createElement(l.MentionItem,{key:d.id,item:d,isActive:y===m,onClick:()=>p(d,!0)}))):r.createElement("div",{className:o.default.no_results},u?"\u6B63\u5728\u641C\u7D22...":"\u65E0\u5339\u914D\u7ED3\u679C"))};t.MentionPanel=_},37412:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MentionSelect=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=e(58998),_=e(81878),v=n.__importDefault(e(13163)),m=({enabled:s,onChange:g})=>o.default.createElement("div",{className:v.default.thinking_toggle,onClick:()=>g(!s)},o.default.createElement(_.Icon,{iconClass:(0,_.getIcon)(s?"check":"circle-outline"),className:(0,r.default)(v.default.thinking_icon,{[v.default.enabled]:s})}),o.default.createElement("span",{className:v.default.thinking_label},"Thinking")),p=({options:s,value:g,onChange:a,placeholder:h,disabled:u=!1,className:c,size:E="small",showThinking:f=!1,thinkingEnabled:d=!1,onThinkingChange:y})=>{const[b,A]=(0,o.useState)(!1),[S,D]=(0,o.useState)(-1),[I,w]=(0,o.useState)("up"),T=(0,o.useRef)(null),R=(0,o.useRef)(null),P=s.find(L=>L.selected)||s.find(L=>L.value===g),O=()=>{u||(A(!b),D(-1))},M=L=>{L.disabled||(a?.(L.value),A(!1),D(-1))},k=L=>{if(!u)switch(L.key){case"Enter":case" ":L.preventDefault(),b?S>=0&&M(s[S]):A(!0);break;case"Escape":L.preventDefault(),A(!1),D(-1);break;case"ArrowDown":L.preventDefault(),b?D(B=>B<s.length-1?B+1:0):A(!0);break;case"ArrowUp":L.preventDefault(),b&&D(B=>B>0?B-1:s.length-1);break}},F=()=>{A(!1),D(-1)};return(0,o.useEffect)(()=>{if(b&&T.current){const L=T.current.getBoundingClientRect(),B=window.innerHeight,U=Math.min(400,s.length*60),W=L.top,j=B-L.bottom;W<U&&j>W?w("down"):w("up")}},[b,s.length]),(0,o.useEffect)(()=>{if(b&&S>=0&&R.current){const L=R.current.children[S];L&&L.scrollIntoView({behavior:"smooth",block:"nearest"})}},[b,S]),o.default.createElement(l.ClickOutside,{onOutsideClick:F},o.default.createElement("div",{ref:T,className:(0,r.default)(v.default.mention_select,v.default[`size_${E}`],{[v.default.disabled]:u,[v.default.open]:b,[v.default.dropdown_up]:I==="up",[v.default.dropdown_down]:I==="down"},c),onClick:O,onKeyDown:k,tabIndex:u?-1:0,role:"combobox","aria-expanded":b,"aria-haspopup":"listbox"},o.default.createElement("div",{className:v.default.select_trigger},o.default.createElement("div",{className:v.default.select_content},P?o.default.createElement("div",{className:v.default.selected_option},o.default.createElement("span",{className:v.default.option_label},P.label),P.badge&&o.default.createElement("span",{className:v.default.option_badge,style:{backgroundColor:P.badgeColor}},P.badge)):o.default.createElement("span",{className:v.default.placeholder},h)),o.default.createElement(_.Icon,{iconClass:(0,_.getIcon)("down-arrow"),className:(0,r.default)(v.default.dropdown_arrow,{[v.default.open]:b})})),b&&o.default.createElement("div",{ref:R,className:v.default.dropdown,role:"listbox"},f&&y&&o.default.createElement("div",{className:v.default.thinking_section},o.default.createElement(m,{enabled:d,onChange:y}),o.default.createElement("div",{className:v.default.divider})),s.map((L,B)=>o.default.createElement("div",{key:L.value,className:(0,r.default)(v.default.option,{[v.default.active]:B===S,[v.default.selected]:L.selected||L.value===g,[v.default.disabled]:L.disabled}),onClick:()=>M(L),role:"option","aria-selected":L.selected||L.value===g},o.default.createElement("div",{className:v.default.option_main},o.default.createElement("div",{className:v.default.option_header},o.default.createElement("div",{className:v.default.option_title},L.icon&&o.default.createElement(_.Icon,{icon:L.icon,className:v.default.option_icon}),L.iconClass&&o.default.createElement(_.Icon,{iconClass:L.iconClass,className:v.default.option_icon}),o.default.createElement("span",{className:v.default.option_label},L.label),L.badge&&o.default.createElement("span",{className:v.default.option_badge,style:{backgroundColor:L.badgeColor}},L.badge))),L.description&&o.default.createElement("div",{className:v.default.option_description},L.description),L.tags&&L.tags.length>0&&o.default.createElement("div",{className:v.default.option_tags},L.tags.map((U,W)=>o.default.createElement("span",{key:W,className:v.default.tag},U)))))))))};t.MentionSelect=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",r.RULE="rule"})(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:""}`}),l=(m,p)=>o({...m,position:"right",title:r,className:p,role:1});t.createMessageByUser=l;const _=(m,p)=>o({...m,position:"left",title:"",className:p,role:2});t.createMessageByAI=_;const v=m=>{let{title:p}=m;const{message:s,tooltip:g}=m;let a=m.icon||"";if(!p)return{icon:a,title:s,message:s,tooltip:g};const h=p.match(/^\$\(([a-z.]+\/)?([a-z0-9-]+)(~[a-z]+)?\)/i);if(h){const[u,c,E,f]=h,d=c?c.slice(0,-1):n.CODICON_OWNER;a=(0,n.getExternalIcon)(E,d),f&&(a+=` ${f.slice(1)}`),p=p.slice(u.length)}return{icon:a,title:p,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),l=e(46044);let _=class{initialize(){this.llmContextService.startAutoCollection()}};t.LlmContextContribution=_,n.__decorate([(0,r.Autowired)(l.LLMContextServiceToken),n.__metadata("design:type",Object)],_.prototype,"llmContextService",void 0),t.LlmContextContribution=_=n.__decorate([(0,o.Domain)(o.ClientAppContribution)],_)},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(41869),l=e(11050),_=e(43718),v=e(25234),m=e(19083),p=e(86560),s=e(96689),g=e(82196),a=e(14951),h=e(6287),u=e(20868),c=e(6487),E=e(70392),f=e(23750);let d=class extends v.WithEventBus{constructor(){super(...arguments),this.isAutoCollecting=!1,this.contextVersion=0,this.maxAttachFilesLimit=10,this.maxAttachFoldersLimit=10,this.maxViewFilesLimit=20,this.attachedFiles=[],this.attachedFolders=[],this.attachedRules=[],this.recentlyViewFiles=[],this.onDidContextFilesChangeEmitter=new p.Emitter,this.hasUserManualReference=!1,this.onDidContextFilesChangeEvent=this.onDidContextFilesChangeEmitter.event}addFileToList(b,A,S){const D=A.findIndex(I=>{var w,T,R,P;return I.uri.toString()===b.uri.toString()&&((w=I.selection)===null||w===void 0?void 0:w[0])===((T=b.selection)===null||T===void 0?void 0:T[0])&&((R=I.selection)===null||R===void 0?void 0:R[1])===((P=b.selection)===null||P===void 0?void 0:P[1])});D>-1&&A.splice(D,1),A.push(b),A.length>S&&A.shift()}addFolderToList(b,A,S){const D=A.findIndex(I=>I.uri.toString()===b.uri.toString());D>-1&&A.splice(D,1),A.push(b),A.length>S&&A.shift()}addRuleToContext(b){if(!b||this.attachedRules.some(S=>S.path===b.toString()))return;const A=this.rulesService.projectRules.find(S=>S.path===b.toString());A&&(this.attachedRules.push(A),this.notifyContextChange())}addFileToContext(b,A,S=!1){if(!b)return;const D={uri:b,selection:A},I=S?this.attachedFiles:this.recentlyViewFiles,w=S?this.maxAttachFilesLimit:this.maxViewFilesLimit;S&&(this.docModelManager.createModelReference(b),this.hasUserManualReference=!0),this.addFileToList(D,I,w),this.notifyContextChange()}addFolderToContext(b){if(!b)return;const A={uri:b};this.addFolderToList(A,this.attachedFolders,this.maxAttachFoldersLimit),this.notifyContextChange()}notifyContextChange(){this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles())}cleanFileContext(){this.attachedFiles=[],this.attachedFolders=[],this.hasUserManualReference=!1,this.attachedRules=[],this.notifyContextChange()}getAllContextFiles(){return{viewed:this.recentlyViewFiles,attached:this.attachedFiles,attachedFolders:this.attachedFolders,attachedRules:this.attachedRules,version:this.contextVersion++}}removeFileFromContext(b,A=!1){const S=A?this.attachedFiles:this.recentlyViewFiles,D=S.findIndex(I=>I.uri.toString()===b.toString());D>-1&&S.splice(D,1),A&&this.attachedFiles.length===0&&(this.hasUserManualReference=!1),this.notifyContextChange()}removeFolderFromContext(b){const A=this.attachedFolders,S=A.findIndex(D=>D.uri.toString()===b.toString());S>-1&&A.splice(S,1),this.notifyContextChange()}removeRuleFromContext(b){const A=this.attachedRules,S=A.findIndex(D=>D.path===b.toString());S>-1&&A.splice(S,1),this.notifyContextChange()}startAutoCollection(){this.isAutoCollecting||(this.isAutoCollecting=!0,this.startAutoCollectionInternal())}startAutoCollectionInternal(){this.disposables.push(this.eventBus.on(s.EditorDocumentModelCreationEvent,b=>{b.payload.uri.scheme==="file"&&this.addFileToContext(b.payload.uri,void 0,!1)})),this.disposables.push(this.eventBus.on(s.EditorDocumentModelRemovalEvent,b=>{b.payload.scheme==="file"&&this.removeFileFromContext(b.payload,!1)})),this.disposables.push(this.eventBus.on(s.EditorDocumentModelSavedEvent,b=>{b.payload.scheme})),this.disposables.push(this.eventBus.on(g.EditorSelectionChangeEvent,b=>{if(b.payload.selections.length>0){const A=[b.payload.selections[0].selectionStartLineNumber,b.payload.selections[0].positionLineNumber].sort();this.hasUserManualReference||(A[0]===A[1]?this.addFileToContext(b.payload.editorUri,void 0,!1):this.addFileToContext(b.payload.editorUri,A.sort((S,D)=>S-D),!1))}}))}stopAutoCollection(){this.dispose()}async serialize(){const b=this.getAllContextFiles(),A=p.URI.file(this.appConfig.workspaceDir);return{recentlyViewFiles:this.serializeRecentlyViewFiles(b.viewed,A),attachedFiles:this.serializeAttachedFiles(b.attached,A),attachedFolders:await this.serializeAttachedFolders(b.attachedFolders),attachedRules:this.serializeAttachedRules(b.attachedRules),globalRules:this.serializeGlobalRules()}}async serializeAttachedFolders(b){const A=Array.from(new Set(b.map(I=>I.uri.toString()))),S="Here are some folder(s) I manually attached to my message:",D=await Promise.all(A.map(async I=>{const T=new p.URI(I).codeUri.fsPath,R=await this.getFormattedFolderStructure(T);return`Folder: ${T}
|
|
32883
|
+
`),vt=document.createDocumentFragment();pt.forEach((lt,wt)=>{const at=lt.replace(/^[ ]+/g,st=>{const At=document.createElement("span");return At.innerHTML="\xA0".repeat(st.length),At.innerHTML}),tt=document.createElement("span");for(tt.innerHTML=at;tt.firstChild;)vt.appendChild(tt.firstChild);wt<pt.length-1&&vt.appendChild(document.createElement("br"))});const xt=vt.lastChild;if(Ve.insertNode(vt),xt&&xt.parentNode){const lt=document.createRange();lt.setStartAfter(xt),Ye.removeAllRanges(),Ye.addRange(lt)}oe()};o.useEffect(()=>{if(T.current){D&&!T.current.textContent&&T.current.setAttribute("data-placeholder",D);const ie=Array.from(T.current.querySelectorAll(`.${p.default.mention_tag}`)).map(le=>({id:le.getAttribute("data-id")||"",type:le.getAttribute("data-type")||"",contextId:le.getAttribute("data-context-id")||""}));H.current=ie}},[D]);const Ae=ie=>{var le;R.active&&!(!((le=document.querySelector(`.${p.default.mention_panel}`))===null||le===void 0)&&le.contains(ie.target))&&P(Se=>({...Se,active:!1,inlineSearchActive:!1}))};o.useEffect(()=>(document.addEventListener("click",Ae,!0),()=>{document.removeEventListener("click",Ae,!0)}),[R.active]);const ge=(ie,le=!1)=>{var Se;if(!T.current)return;if(ie.getItems){const tt=window.getSelection();if(!tt||!tt.rangeCount)return;if(R.level===0&&R.startPos!==null){let st,At,Ut;const _n=document.createTreeWalker(T.current,NodeFilter.SHOW_TEXT);let Ln=0,ui;for(;ui=_n.nextNode();){const Rn=((Se=ui.textContent)===null||Se===void 0?void 0:Se.length)||0;if(R.startPos-1>=Ln&&R.startPos-1<Ln+Rn){st=ui,At=R.startPos-1-Ln;const ln=le?R.startPos+R.filter.length-1:re(T.current);Ut=Math.min(ln-Ln,Rn);break}Ln+=Rn}if(st){const Rn=document.createRange();Rn.setStart(st,At),Rn.setEnd(st,Ut),Rn.deleteContents();const ln=document.createTextNode(`${d}${ie.type}:`);Rn.insertNode(ln);const Un=document.createRange();Un.setStartAfter(ln),Un.setEndAfter(ln),tt.removeAllRanges(),tt.addRange(Un),P(rn=>({...rn,active:!0,level:1,parentType:ie.id,inlineSearchActive:!0,inlineSearchStartPos:re(T.current),secondLevelFilter:"",activeIndex:0})),T.current.focus();return}}return}const ye=window.getSelection();if(!ye||!ye.rangeCount)return;if(R.inlineSearchActive&&R.parentType&&R.inlineSearchStartPos!==null){const tt=u.find(Ut=>Ut.id===R.parentType);if(!tt)return;const st=`${d}${tt.type}:`,At=R.inlineSearchStartPos-st.length;if(At>=0){let ct=function($e){if($e.nodeType===3)rn.push({node:$e,start:ln,end:ln+$e.textContent.length}),ln+=$e.textContent.length;else if($e.nodeType===1){const Re=$e.childNodes||[];for(const Le of Array.from(Re))ct(Le)}};const Ut=document.createElement("span");if(Ut.className=p.default.mention_tag,Ut.dataset.id=ie.id,Ut.dataset.type=ie.type,Ut.dataset.contextId=ie.contextId||"",Ut.contentEditable="false",ie.type===a.MentionType.FILE||ie.type===a.MentionType.FOLDER){const $e=document.createElement("span");$e.className=(0,r.default)(p.default.mention_icon,ie.type===a.MentionType.FILE?A?.getIcon(new m.URI(ie.text)):(0,_.getIcon)("folder")),Ut.appendChild($e),ie.type===a.MentionType.FOLDER?w?.addFolderToContext(new m.URI(ie.contextId),!0):w?.addFileToContext(new m.URI(ie.contextId),void 0,!0)}else if(ie.type===a.MentionType.CODE){const $e=document.createElement("span");$e.className=(0,r.default)(p.default.mention_icon,ie.kind&&(0,l.getSymbolIcon)(ie.kind)+" outline-icon"),Ut.appendChild($e),ie.symbol&&w?.addFileToContext(new m.URI(ie.contextId),[ie.symbol.range.startLineNumber,ie.symbol.range.endLineNumber],!0)}else if(ie.type===a.MentionType.RULE){const $e=document.createElement("span");$e.className=(0,r.default)(p.default.mention_icon,(0,_.getIcon)("rules")),Ut.appendChild($e),w?.addRuleToContext(new m.URI(ie.contextId),!0)}const _n=S?.workspace;let Ln=ie.text;_n&&ie.contextId&&(Ln=ie.contextId.replace(new m.URI(_n.uri).codeUri.fsPath,"").slice(1));const ui=document.createTextNode(Ln);Ut.appendChild(ui);const Rn=document.createRange();let ln=0,Un=!1;const rn=[];ct(T.current);for(const $e of rn){if(At>=$e.start&&At<=$e.end){const Re=At-$e.start;Rn.setStart($e.node,Re),Un=!0}if(Un){const Re=le?At+st.length+R.secondLevelFilter.length:re(T.current);if(Re>=$e.start&&Re<=$e.end){const Le=Re-$e.start;Rn.setEnd($e.node,Le);break}}}if(Un){Rn.deleteContents(),Rn.insertNode(Ut);const $e=document.createRange();$e.setStartAfter(Ut),$e.setEndAfter(Ut),ye.removeAllRanges(),ye.addRange($e);const Re=document.createTextNode("\xA0");$e.insertNode(Re),$e.setStartAfter(Re),$e.setEndAfter(Re),ye.removeAllRanges(),ye.addRange($e)}P($e=>({...$e,active:!1,inlineSearchActive:!1})),T.current.focus();return}}const Ue=document.createElement("span");if(Ue.className=p.default.mention_tag,Ue.dataset.id=ie.id,Ue.dataset.type=ie.type,Ue.dataset.contextId=ie.contextId||"",Ue.contentEditable="false",ie.type===a.MentionType.FILE||ie.type==="folder"){const tt=document.createElement("span");tt.className=(0,r.default)(p.default.mention_icon,ie.type===a.MentionType.FILE?A?.getIcon(new m.URI(ie.text)):(0,_.getIcon)("folder")),Ue.appendChild(tt)}const Ye=S?.workspace;let Ve=ie.text;Ye&&ie.contextId&&(Ve=ie.contextId.replace(new m.URI(Ye.uri).codeUri.fsPath,"").slice(1));const pt=document.createTextNode(Ve);Ue.appendChild(pt);let vt=0,xt=!1;const lt=[];function wt(tt){if(tt.nodeType===3)lt.push({node:tt,start:vt,end:vt+tt.textContent.length}),vt+=tt.textContent.length;else if(tt.nodeType===1){const st=tt.childNodes;for(const At of Array.from(st))wt(At)}}wt(T.current);const at=document.createRange();if(R.startPos!==null)for(const tt of lt){if(R.startPos-1>=tt.start&&R.startPos-1<=tt.end){const st=R.startPos-1-tt.start;at.setStart(tt.node,st),xt=!0}if(xt){const st=le?R.startPos+R.filter.length-1:re(T.current);if(st>=tt.start&&st<=tt.end){const At=st-tt.start;at.setEnd(tt.node,At);break}}}if(xt){at.deleteContents(),at.insertNode(Ue);const tt=document.createRange();tt.setStartAfter(Ue),tt.setEndAfter(Ue),ye.removeAllRanges(),ye.addRange(tt);const st=document.createTextNode("\xA0");tt.insertNode(st),tt.setStartAfter(st),tt.setEndAfter(st),ye.removeAllRanges(),ye.addRange(tt)}P(tt=>({...tt,active:!1})),T.current.focus()},te=o.useCallback(ie=>{M(ie),y?.(ie)},[O,y]),fe=()=>{if(!T.current)return;const ie=T.current.innerHTML;if(!ie)return;const le=document.createElement("div");le.innerHTML=ie,le.querySelectorAll(`.${p.default.mention_tag}`).forEach(Ue=>{var Ye;const Ve=Ue.getAttribute("data-context-id");if(Ve){const pt=document.createTextNode(`{{${d}${Ue.getAttribute("data-type")}:${Ve}}}`);(Ye=Ue.parentNode)===null||Ye===void 0||Ye.replaceChild(pt,Ue)}});let ye=le.innerHTML;ye=ye.trim().replaceAll(t.WHITE_SPACE_TEXT," "),ie&&(B(Ue=>[...Ue,ie]),W(-1),Z(!1)),c&&c(ye,{model:O,...I}),T.current.innerHTML="",T.current&&(T.current.style.overflowY="hidden",T.current.style.height="auto")},Oe=o.useCallback(()=>{w?.cleanFileContext()},[w]),xe=o.useCallback(()=>{if(!T.current)return;T.current.focus();const ie=window.getSelection();if(!ie)return;const le=document.createRange();if(!T.current.textContent||T.current.textContent.trim()==="")T.current.innerHTML="@",le.setStart(T.current.firstChild||T.current,1),le.setEnd(T.current.firstChild||T.current,1);else{const ye=document.createTextNode(" @");le.selectNodeContents(T.current),le.collapse(!1),le.insertNode(ye),le.setStartAfter(ye),le.setEndAfter(ye)}ie.removeAllRanges(),ie.addRange(le);const Se=re(T.current);P({active:!0,startPos:Se,filter:"@",position:{top:0,left:0},activeIndex:0,level:0,parentType:null,secondLevelFilter:"",inlineSearchActive:!1,inlineSearchStartPos:null,loading:!1})},[]),Me=o.useCallback(()=>{E&&E()},[E]),Be=o.useCallback(ie=>(I.buttons||[]).filter(le=>le.position===ie).map(le=>o.createElement(_.Popover,{key:le.id,overlayClassName:p.default.popover_icon,id:`ai-chat-${le.id}`,position:_.PopoverPosition.top,title:le.title},o.createElement(v.EnhanceIcon,{className:(0,r.default)(le.icon?(0,_.getIcon)(le.icon):le.iconClass,p.default[`${le.id}_logo`]),tabIndex:0,role:"button",ariaLabel:le.title,onClick:le.onClick}))),[I.buttons]),De=o.useMemo(()=>$.files.length>0||$.folders.length>0||$.rules.length>0,[$]),_e=o.useCallback(ie=>I.disableModelSelector?o.createElement(_.Popover,{id:"ai-chat-model-selector",title:(0,l.localize)("aiNative.chat.modelSelector.disableTip"),position:_.PopoverPosition.top},ie):ie,[I.disableModelSelector]),Ne=o.useMemo(()=>I.extendedModelOptions?I.extendedModelOptions.map(ie=>({...ie,selected:ie.value===O})):(I.modelOptions||[]).map(ie=>{const le={...ie};return le.selected=ie.value===O,le}),[I.modelOptions,I.extendedModelOptions,O]),Te=o.useCallback((ie,le)=>{ie===a.MentionType.FILE?w?.removeFileFromContext(le,!0):ie===a.MentionType.FOLDER?w?.removeFolderFromContext(le):ie===a.MentionType.RULE&&w?.removeRuleFromContext(le)},[w]),We=ie=>decodeURIComponent(ie.split("/").pop()||"Unknown Rule"),pe=o.useCallback(()=>o.createElement("div",{className:p.default.context_preview_container},o.createElement("span",{className:(0,r.default)(p.default.context_preview_title,De&&p.default.has_context),onClick:xe},De?"":(0,l.localize)("aiNative.chat.context.title")),$.files.map((ie,le)=>o.createElement("div",{key:`file-${le}`,className:p.default.context_preview_item,"data-type":a.MentionType.FILE},o.createElement(_.Icon,{iconClass:(0,r.default)(A?.getIcon(ie.uri)||a.MentionType.FILE,p.default.context_preview_item_icon,p.default.icon)}),o.createElement(_.Icon,{iconClass:(0,r.default)(p.default.close_icon,(0,_.getIcon)("close")),onClick:()=>Te(a.MentionType.FILE,ie.uri)}),o.createElement("span",{className:p.default.context_preview_item_text},new m.URI(ie.uri.toString()).displayName))),$.folders.map((ie,le)=>o.createElement("div",{key:`folder-${le}`,className:p.default.context_preview_item,"data-type":"folder"},o.createElement(_.Icon,{iconClass:(0,r.default)((0,_.getIcon)("folder"),p.default.context_preview_item_icon,p.default.icon)}),o.createElement(_.Icon,{iconClass:(0,r.default)(p.default.close_icon,(0,_.getIcon)("close")),onClick:()=>Te(a.MentionType.FOLDER,ie.uri)}),o.createElement("span",{className:p.default.context_preview_item_text},new m.URI(ie.uri.toString()).displayName))),$.rules.map((ie,le)=>o.createElement("div",{key:`rule-${le}`,className:p.default.context_preview_item,"data-type":"rule"},o.createElement(_.Icon,{iconClass:(0,r.default)((0,_.getIcon)("rules"),p.default.context_preview_item_icon,p.default.icon)}),o.createElement(_.Icon,{iconClass:(0,r.default)(p.default.close_icon,(0,_.getIcon)("close")),onClick:()=>Te(a.MentionType.RULE,new m.URI(ie.path))}),o.createElement("span",{className:p.default.context_preview_item_text},We(ie.path).replace(".mdc",""))))),[Oe,De,$,A,w,xe,Te]);return o.createElement("div",{className:p.default.input_container},pe(),R.active&&o.createElement("div",{className:p.default.mention_panel_container},o.createElement(s.MentionPanel,{items:K(),activeIndex:R.activeIndex,onSelectItem:ie=>ge(ie,!0),position:{top:0,left:0},filter:R.level===0?R.filter:R.secondLevelFilter,visible:!0,level:R.level,loading:R.loading})),o.createElement("div",{className:p.default.editor_area},o.createElement("div",{ref:T,className:p.default.editor,contentEditable:!0,onInput:oe,onKeyDown:he,onPaste:q,onCompositionEnd:me})),o.createElement("div",{className:p.default.footer},o.createElement("div",{className:p.default.left_control},I.showModelSelector&&_e(o.createElement(g.MentionSelect,{options:Ne,value:O,onChange:te,className:p.default.model_selector,size:"small",disabled:I.disableModelSelector,showThinking:I.showThinking,thinkingEnabled:I.thinkingEnabled,onThinkingChange:I.onThinkingChange})),Be(a.FooterButtonPosition.LEFT)),o.createElement("div",{className:p.default.right_control},Be(a.FooterButtonPosition.RIGHT),o.createElement(_.Popover,{overlayClassName:p.default.popover_icon,id:"ai-chat-send",position:_.PopoverPosition.top,content:f?"Stop":"Send"},f?o.createElement(v.EnhanceIcon,{wrapperClassName:p.default.stop_logo,className:(0,r.default)((0,_.getIcon)("stop"),p.default.stop_logo_icon),tabIndex:0,role:"button",ariaLabel:"Stop",onClick:Me}):o.createElement(v.EnhanceIcon,{wrapperClassName:p.default.send_logo,className:(0,r.default)((0,_.getIcon)("send-outlined"),p.default.send_logo_icon),tabIndex:0,role:"button",onClick:fe,ariaLabel:"Send"})))))};t.MentionInput=h},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)),l=e(81878),_=n.__importDefault(e(97599)),v=({item:m,isActive:p,onClick:s})=>o.createElement("div",{className:`${_.default.mention_item} ${p?_.default.active:""}`,onClick:()=>s(m)},o.createElement("div",{className:_.default.mention_item_left},o.createElement(l.Icon,{className:(0,r.default)(_.default.mention_item_icon,m.icon)}),o.createElement("span",{className:_.default.mention_item_text},m.text),o.createElement("span",{className:_.default.mention_item_description},m.description)),m.getItems&&o.createElement(l.Icon,{className:(0,r.default)(_.default.mention_item_right,(0,l.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)),l=e(40167),_=({items:v,activeIndex:m,onSelectItem:p,position:s,filter:g,visible:a,level:h,loading:u=!1})=>{const c=r.useRef(null);if(r.useEffect(()=>{if(a&&c.current){const d=c.current.querySelector(`.${o.default.mention_item}.${o.default.active}`);d&&d.scrollIntoView({block:"nearest"})}},[m,a]),!a)return null;const f=(()=>{let d=v;if(h===0){if(g&&g.length>1){const y=g.substring(1).toLowerCase();d=v.filter(b=>b.text.toLowerCase().includes(y))}}else g&&g.length>0&&(d=v.filter(y=>y.text.toLowerCase().includes(g.toLowerCase())));return d})();return h===0&&f.length===0?null:r.createElement("div",{ref:c,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((d,y)=>r.createElement(l.MentionItem,{key:d.id,item:d,isActive:y===m,onClick:()=>p(d,!0)}))):r.createElement("div",{className:o.default.no_results},u?"\u6B63\u5728\u641C\u7D22...":"\u65E0\u5339\u914D\u7ED3\u679C"))};t.MentionPanel=_},37412:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MentionSelect=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=e(58998),_=e(81878),v=n.__importDefault(e(13163)),m=({enabled:s,onChange:g})=>o.default.createElement("div",{className:v.default.thinking_toggle,onClick:()=>g(!s)},o.default.createElement(_.Icon,{iconClass:(0,_.getIcon)(s?"check":"circle-outline"),className:(0,r.default)(v.default.thinking_icon,{[v.default.enabled]:s})}),o.default.createElement("span",{className:v.default.thinking_label},"Thinking")),p=({options:s,value:g,onChange:a,placeholder:h,disabled:u=!1,className:c,size:E="small",showThinking:f=!1,thinkingEnabled:d=!1,onThinkingChange:y})=>{const[b,A]=(0,o.useState)(!1),[S,D]=(0,o.useState)(-1),[I,w]=(0,o.useState)("up"),T=(0,o.useRef)(null),R=(0,o.useRef)(null),P=s.find(L=>L.selected)||s.find(L=>L.value===g),O=()=>{u||(A(!b),D(-1))},M=L=>{L.disabled||(a?.(L.value),A(!1),D(-1))},k=L=>{if(!u)switch(L.key){case"Enter":case" ":L.preventDefault(),b?S>=0&&M(s[S]):A(!0);break;case"Escape":L.preventDefault(),A(!1),D(-1);break;case"ArrowDown":L.preventDefault(),b?D(B=>B<s.length-1?B+1:0):A(!0);break;case"ArrowUp":L.preventDefault(),b&&D(B=>B>0?B-1:s.length-1);break}},F=()=>{A(!1),D(-1)};return(0,o.useEffect)(()=>{if(b&&T.current){const L=T.current.getBoundingClientRect(),B=window.innerHeight,U=Math.min(400,s.length*60),W=L.top,j=B-L.bottom;W<U&&j>W?w("down"):w("up")}},[b,s.length]),(0,o.useEffect)(()=>{if(b&&S>=0&&R.current){const L=R.current.children[S];L&&L.scrollIntoView({behavior:"smooth",block:"nearest"})}},[b,S]),o.default.createElement(l.ClickOutside,{onOutsideClick:F},o.default.createElement("div",{ref:T,className:(0,r.default)(v.default.mention_select,v.default[`size_${E}`],{[v.default.disabled]:u,[v.default.open]:b,[v.default.dropdown_up]:I==="up",[v.default.dropdown_down]:I==="down"},c),onClick:O,onKeyDown:k,tabIndex:u?-1:0,role:"combobox","aria-expanded":b,"aria-haspopup":"listbox"},o.default.createElement("div",{className:v.default.select_trigger},o.default.createElement("div",{className:v.default.select_content},P?o.default.createElement("div",{className:v.default.selected_option},o.default.createElement("span",{className:v.default.option_label},P.label),P.badge&&o.default.createElement("span",{className:v.default.option_badge,style:{backgroundColor:P.badgeColor}},P.badge)):o.default.createElement("span",{className:v.default.placeholder},h)),o.default.createElement(_.Icon,{iconClass:(0,_.getIcon)("down-arrow"),className:(0,r.default)(v.default.dropdown_arrow,{[v.default.open]:b})})),b&&o.default.createElement("div",{ref:R,className:v.default.dropdown,role:"listbox"},f&&y&&o.default.createElement("div",{className:v.default.thinking_section},o.default.createElement(m,{enabled:d,onChange:y}),o.default.createElement("div",{className:v.default.divider})),s.map((L,B)=>o.default.createElement("div",{key:L.value,className:(0,r.default)(v.default.option,{[v.default.active]:B===S,[v.default.selected]:L.selected||L.value===g,[v.default.disabled]:L.disabled}),onClick:()=>M(L),role:"option","aria-selected":L.selected||L.value===g},o.default.createElement("div",{className:v.default.option_main},o.default.createElement("div",{className:v.default.option_header},o.default.createElement("div",{className:v.default.option_title},L.icon&&o.default.createElement(_.Icon,{icon:L.icon,className:v.default.option_icon}),L.iconClass&&o.default.createElement(_.Icon,{iconClass:L.iconClass,className:v.default.option_icon}),o.default.createElement("span",{className:v.default.option_label},L.label),L.badge&&o.default.createElement("span",{className:v.default.option_badge,style:{backgroundColor:L.badgeColor}},L.badge))),L.description&&o.default.createElement("div",{className:v.default.option_description},L.description),L.tags&&L.tags.length>0&&o.default.createElement("div",{className:v.default.option_tags},L.tags.map((U,W)=>o.default.createElement("span",{key:W,className:v.default.tag},U)))))))))};t.MentionSelect=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",r.RULE="rule"})(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:""}`}),l=(m,p)=>o({...m,position:"right",title:r,className:p,role:1});t.createMessageByUser=l;const _=(m,p)=>o({...m,position:"left",title:"",className:p,role:2});t.createMessageByAI=_;const v=m=>{let{title:p}=m;const{message:s,tooltip:g}=m;let a=m.icon||"";if(!p)return{icon:a,title:s,message:s,tooltip:g};const h=p.match(/^\$\(([a-z.]+\/)?([a-z0-9-]+)(~[a-z]+)?\)/i);if(h){const[u,c,E,f]=h,d=c?c.slice(0,-1):n.CODICON_OWNER;a=(0,n.getExternalIcon)(E,d),f&&(a+=` ${f.slice(1)}`),p=p.slice(u.length)}return{icon:a,title:p,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),l=e(46044);let _=class{initialize(){this.llmContextService.startAutoCollection()}};t.LlmContextContribution=_,n.__decorate([(0,r.Autowired)(l.LLMContextServiceToken),n.__metadata("design:type",Object)],_.prototype,"llmContextService",void 0),t.LlmContextContribution=_=n.__decorate([(0,o.Domain)(o.ClientAppContribution)],_)},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(41869),l=e(11050),_=e(43718),v=e(25234),m=e(19083),p=e(86560),s=e(96689),g=e(82196),a=e(14951),h=e(6287),u=e(20868),c=e(6487),E=e(70392),f=e(23750);let d=class extends v.WithEventBus{constructor(){super(...arguments),this.isAutoCollecting=!1,this.contextVersion=0,this.maxAttachFilesLimit=10,this.maxAttachFoldersLimit=10,this.maxViewFilesLimit=20,this.attachedFiles=[],this.attachedFolders=[],this.attachedRules=[],this.recentlyViewFiles=[],this.onDidContextFilesChangeEmitter=new p.Emitter,this.hasUserManualReference=!1,this.onDidContextFilesChangeEvent=this.onDidContextFilesChangeEmitter.event}addFileToList(b,A,S){const D=A.findIndex(I=>{var w,T,R,P;return I.uri.toString()===b.uri.toString()&&((w=I.selection)===null||w===void 0?void 0:w[0])===((T=b.selection)===null||T===void 0?void 0:T[0])&&((R=I.selection)===null||R===void 0?void 0:R[1])===((P=b.selection)===null||P===void 0?void 0:P[1])});D>-1&&A.splice(D,1),A.push(b),A.length>S&&A.shift()}addFolderToList(b,A,S){const D=A.findIndex(I=>I.uri.toString()===b.uri.toString());D>-1&&A.splice(D,1),A.push(b),A.length>S&&A.shift()}addRuleToContext(b){if(!b||this.attachedRules.some(S=>S.path===b.toString()))return;const A=this.rulesService.projectRules.find(S=>S.path===b.toString());A&&(this.attachedRules.push(A),this.notifyContextChange())}addFileToContext(b,A,S=!1){if(!b)return;const D={uri:b,selection:A},I=S?this.attachedFiles:this.recentlyViewFiles,w=S?this.maxAttachFilesLimit:this.maxViewFilesLimit;S&&(this.docModelManager.createModelReference(b),this.hasUserManualReference=!0),this.addFileToList(D,I,w),this.notifyContextChange()}addFolderToContext(b){if(!b)return;const A={uri:b};this.addFolderToList(A,this.attachedFolders,this.maxAttachFoldersLimit),this.notifyContextChange()}notifyContextChange(){this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles())}cleanFileContext(){this.attachedFiles=[],this.attachedFolders=[],this.hasUserManualReference=!1,this.attachedRules=[],this.notifyContextChange()}getAllContextFiles(){return{viewed:this.recentlyViewFiles,attached:this.attachedFiles,attachedFolders:this.attachedFolders,attachedRules:this.attachedRules,version:this.contextVersion++}}removeFileFromContext(b,A=!1){const S=A?this.attachedFiles:this.recentlyViewFiles,D=S.findIndex(I=>I.uri.toString()===b.toString());D>-1&&S.splice(D,1),A&&this.attachedFiles.length===0&&(this.hasUserManualReference=!1),this.notifyContextChange()}removeFolderFromContext(b){const A=this.attachedFolders,S=A.findIndex(D=>D.uri.toString()===b.toString());S>-1&&A.splice(S,1),this.notifyContextChange()}removeRuleFromContext(b){const A=this.attachedRules,S=A.findIndex(D=>D.path===b.toString());S>-1&&A.splice(S,1),this.notifyContextChange()}startAutoCollection(){this.isAutoCollecting||(this.isAutoCollecting=!0,this.startAutoCollectionInternal())}startAutoCollectionInternal(){this.disposables.push(this.eventBus.on(s.EditorDocumentModelCreationEvent,b=>{b.payload.uri.scheme==="file"&&this.addFileToContext(b.payload.uri,void 0,!1)})),this.disposables.push(this.eventBus.on(s.EditorDocumentModelRemovalEvent,b=>{b.payload.scheme==="file"&&this.removeFileFromContext(b.payload,!1)})),this.disposables.push(this.eventBus.on(s.EditorDocumentModelSavedEvent,b=>{b.payload.scheme})),this.disposables.push(this.eventBus.on(g.EditorSelectionChangeEvent,b=>{if(b.payload.selections.length>0){const A=[b.payload.selections[0].selectionStartLineNumber,b.payload.selections[0].positionLineNumber].sort();this.hasUserManualReference||(A[0]===A[1]?this.addFileToContext(b.payload.editorUri,void 0,!1):this.addFileToContext(b.payload.editorUri,A.sort((S,D)=>S-D),!1))}}))}stopAutoCollection(){this.dispose()}async serialize(){const b=this.getAllContextFiles(),A=p.URI.file(this.appConfig.workspaceDir);return{recentlyViewFiles:this.serializeRecentlyViewFiles(b.viewed,A),attachedFiles:this.serializeAttachedFiles(b.attached,A),attachedFolders:await this.serializeAttachedFolders(b.attachedFolders),attachedRules:this.serializeAttachedRules(b.attachedRules),globalRules:this.serializeGlobalRules()}}async serializeAttachedFolders(b){const A=Array.from(new Set(b.map(I=>I.uri.toString()))),S="Here are some folder(s) I manually attached to my message:",D=await Promise.all(A.map(async I=>{const T=new p.URI(I).codeUri.fsPath,R=await this.getFormattedFolderStructure(T);return`Folder: ${T}
|
|
32884
32884
|
Contents of directory:
|
|
32885
32885
|
|
|
32886
32886
|
${R}`}));return D.length>0?[S,...D,""]:[]}async getFormattedFolderStructure(b){var A;const S=[];try{const D=await this.fileService.getFileStat(b);for(const I of D?.children||[]){const w=new p.URI(b).relative(new p.URI(I.uri)).toString();if(I.isSymbolicLink){const T=await this.fileService.getFileStat(I.realUri||I.uri);T?S.push(`[link] ${w} -> ${T}`):S.push(`[link] ${w} (broken)`);continue}if(I.type===a.FileType.Directory){const T=await this.fileService.getFileStat(I.uri),R=((A=T?.children)===null||A===void 0?void 0:A.length)||0;S.push(`[dir] ${w}/ (${R} items)`)}else I.type===a.FileType.File&&S.push(`[file] ${w}`)}}catch{return""}return S.join(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/cli-engine",
|
|
3
|
-
"version": "3.9.1-next-
|
|
3
|
+
"version": "3.9.1-next-1749022986.0",
|
|
4
4
|
"description": "Integration engine runtime for opensumi-cli and opensumi extension",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@koa/cors": "^5.0.0",
|
|
28
28
|
"@opensumi/di": "^1.8.0",
|
|
29
|
-
"@opensumi/ide-core-browser": "3.9.1-next-
|
|
30
|
-
"@opensumi/ide-core-common": "3.9.1-next-
|
|
31
|
-
"@opensumi/ide-core-node": "3.9.1-next-
|
|
32
|
-
"@opensumi/ide-express-file-server": "3.9.1-next-
|
|
33
|
-
"@opensumi/ide-extension": "3.9.1-next-
|
|
34
|
-
"@opensumi/ide-i18n": "3.9.1-next-
|
|
35
|
-
"@opensumi/ide-main-layout": "3.9.1-next-
|
|
36
|
-
"@opensumi/ide-startup": "3.9.1-next-
|
|
29
|
+
"@opensumi/ide-core-browser": "3.9.1-next-1749022986.0",
|
|
30
|
+
"@opensumi/ide-core-common": "3.9.1-next-1749022986.0",
|
|
31
|
+
"@opensumi/ide-core-node": "3.9.1-next-1749022986.0",
|
|
32
|
+
"@opensumi/ide-express-file-server": "3.9.1-next-1749022986.0",
|
|
33
|
+
"@opensumi/ide-extension": "3.9.1-next-1749022986.0",
|
|
34
|
+
"@opensumi/ide-i18n": "3.9.1-next-1749022986.0",
|
|
35
|
+
"@opensumi/ide-main-layout": "3.9.1-next-1749022986.0",
|
|
36
|
+
"@opensumi/ide-startup": "3.9.1-next-1749022986.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": "b033e87201db62dc36ba9e012a4e3ef206f5272b"
|
|
76
76
|
}
|