@bigduu/lotus 2026.5.7 → 2026.5.9
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/dist/assets/{App-DaOPoP5b.js → App-BTGbaEEX.js} +7 -7
- package/dist/assets/{SubAgentsPanel-CpKXYYmB.js → SubAgentsPanel-Ce4m3347.js} +1 -1
- package/dist/assets/{index-Dkb_XCk_.js → index-BS58SFDp.js} +1 -1
- package/dist/assets/{index-DPYLJuvQ.js → index-BastF0O4.js} +1 -1
- package/dist/assets/{index-BJC7afG8.js → index-BgLl21bt.js} +1 -1
- package/dist/assets/{index-Cj9EZ-Bm.js → index-Boq-mY30.js} +1 -1
- package/dist/assets/{index-BylZylqP.js → index-BznNIVdg.js} +1 -1
- package/dist/assets/{index-DLBYvmHv.js → index-CczbX5-W.js} +1 -1
- package/dist/assets/{index-CSqXTBwc.js → index-CqLfWip6.js} +1 -1
- package/dist/assets/{index-B1KXzc0W.js → index-De_fWx5w.js} +1 -1
- package/dist/assets/{index-D1aobBlB.js → index-DxXScfYt.js} +1 -1
- package/dist/assets/{index-RkUQwJrg.js → index-OvJdu3L8.js} +1 -1
- package/dist/assets/{index-D_SsVUqJ.js → index-wTpHqXAd.js} +2 -2
- package/dist/assets/{main-CuvqMgTQ.js → main-mHH04gTP.js} +2 -2
- package/dist/index.html +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var ne=Object.defineProperty;var se=(n,t,s)=>t in n?ne(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s;var N=(n,t,s)=>se(n,typeof t!="symbol"?t+"":t,s);import{j as i}from"./vendor-markdown-DzaXAW9Q.js";import{a as u,u as re}from"./vendor-i18n-BNURlJ23.js";import{n as E,v as W,w as oe,u as f,x as ae,o as le}from"./App-DaOPoP5b.js";import{l as I,C as ie,a7 as k,j as ue,E as _,ak as ce,v as de,ad as ge,t as me}from"./vendor-antd-DODjfilb.js";import"./vendor-mermaid-De-Yacw-.js";import"./main-CuvqMgTQ.js";const v=class v{static getInstance(){return v.instance||(v.instance=new v),v.instance}parseUserCommand(t){E("[ToolService]",`[ToolService] parseUserCommand: Parsing content: "${t}"`);const s=t.trim();if(!s.startsWith("/"))return E("[ToolService]",'[ToolService] parseUserCommand: Content does not start with "/", not a tool command.'),null;const o=s.indexOf(" ");let c,p;if(o===-1?(c=s.substring(1),p=""):(c=s.substring(1,o),p=s.substring(o+1).trim()),c){const d={tool_name:c,user_description:p};return E("[ToolService]","[ToolService] parseUserCommand: Successfully parsed command:",d),d}return E("[ToolService]","[ToolService] parseUserCommand: Failed to parse tool name from content."),null}parseAIResponseToToolCall(t){return this.parseUserCommand(t)}async executeTool(t){E("[ToolService]","[ToolService] executeTool: Attempting to execute tool via HTTP with request:",t);try{const s=await W.post("tools/execute",t),o=JSON.parse(s.result);return E("[ToolService]","[ToolService] executeTool: Parsed structured result:",o),o}catch(s){throw console.error("[ToolService] executeTool: HTTP tool execution failed:",s),s instanceof oe?new Error(`Workflow execution failed: ${s.message}`):s}}};N(v,"instance");let F=v;const H=new F;class pe{async listProfiles(){return W.get("subagent_profiles")}}const fe=new pe,he=[];function ye(n={}){const{enabled:t=!0,refreshKey:s}=n,[o,c]=u.useState(null),[p,d]=u.useState(!1),[A,S]=u.useState(null),b=u.useCallback(async()=>{d(!0);try{const m=await fe.listProfiles();c(m),S(null)}catch(m){S(m instanceof Error?m:new Error(String(m)))}finally{d(!1)}},[]);u.useEffect(()=>{t&&b()},[t,b,s]);const x=u.useMemo(()=>{const m=new Map;if(o!=null&&o.profiles)for(const j of o.profiles)m.set(j.id,j);return m},[o]);return{profiles:(o==null?void 0:o.profiles)??he,fallbackId:(o==null?void 0:o.fallback_id)??null,loading:p,error:A,refresh:b,byId:x}}const Se=(n,t)=>{var A,S,b,x,m;const s=n==null?void 0:n.trim();if(!s)return null;const o=t.get(s),c=((A=o==null?void 0:o.display_name)==null?void 0:A.trim())||s,p=(b=(S=o==null?void 0:o.ui)==null?void 0:S.icon)==null?void 0:b.trim(),d=((m=(x=o==null?void 0:o.ui)==null?void 0:x.color)==null?void 0:m.trim())||void 0;return i.jsx(I,{color:d,style:{marginInlineEnd:0,flex:"0 0 auto"},"data-testid":`sub-agent-role-tag-${s}`,children:p?`${p} ${c}`:c})},{Text:C}=ue,{useToken:G}=me,be="chat-session-sub-agents-collapsed:",we=3,Ce=600,P=n=>{const t=(n||"").trim().toLowerCase();return t?t==="started"||t==="already_running"?"running":t==="success"||t==="done"?"completed":t==="canceled"?"cancelled":t==="queued"||t==="created"?"pending":t:"pending"},xe=(n,t)=>{if(t&&t.trim())return t;if(n.isRunning)return"running";if(n.lastRunStatus&&n.lastRunStatus.trim())return n.lastRunStatus;const s=n.messageCount??0;return s>2?"completed":(s>0,"pending")},K=n=>`${be}${n}`,D=n=>{if(typeof window>"u")return!1;try{const t=window.localStorage.getItem(K(n));return t==="1"?!0:t==="0"?!1:null}catch{return null}},ve=(n,t)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(K(n),t?"1":"0")}catch{}},Oe=({parentSessionId:n})=>{const{t}=re(),{token:s}=G(),[o,c]=u.useState(()=>D(n)??!1),[p,d]=u.useState(null),[A,S]=u.useState(null),[b,x]=u.useState(null),m=f(e=>ae(n)(e)),j=f(e=>e.chats),O=f(e=>e.loadChatHistory),T=f(e=>e.refreshChats),M=f(e=>e.markOptimisticStart),z=f(e=>e.markRetryStart),R=f(e=>e.markSettleTimeout),Y=f(e=>e.pinSession),J=f(e=>e.unpinSession),h=f(e=>e.applyChildProgress),L=f(e=>e.clearChildProgress),{byId:q}=ye(),U=u.useMemo(()=>Object.entries(m).map(([e,l])=>({childSessionId:e,...l})),[m]),B=u.useMemo(()=>j.filter(e=>e.kind==="child"&&e.parentSessionId===n).sort((e,l)=>{const r=Date.parse(e.updatedAt||"")||0;return(Date.parse(l.updatedAt||"")||0)-r}),[j,n]),w=u.useMemo(()=>{const e=new Map(U.map(r=>[r.childSessionId,r])),l=[];for(const r of B){const a=e.get(r.id);l.push({childSessionId:r.id,title:r.title||(a==null?void 0:a.title),status:P(xe(r,a==null?void 0:a.status)),error:(a==null?void 0:a.error)||r.lastRunError,lastHeartbeatAt:a==null?void 0:a.lastHeartbeatAt,lastEventAt:a==null?void 0:a.lastEventAt,outputPreview:a==null?void 0:a.outputPreview,roundCount:a==null?void 0:a.roundCount,pinned:r.pinned,updatedAt:r.updatedAt,isRunning:r.isRunning,messageCount:r.messageCount,lastRunStatus:r.lastRunStatus,lastRunError:r.lastRunError,subagentType:r.subagentType??null}),e.delete(r.id)}for(const r of e.values())l.push({childSessionId:r.childSessionId,title:r.title,status:P(r.status),error:r.error,lastHeartbeatAt:r.lastHeartbeatAt,lastEventAt:r.lastEventAt,outputPreview:r.outputPreview,roundCount:r.roundCount});return l},[B,U]);u.useEffect(()=>{c(D(n)??!1)},[n]),u.useEffect(()=>{D(n)===null&&c(w.length>we)},[n,w.length]);const Q=u.useCallback(()=>{c(e=>{const l=!e;return ve(n,l),l})},[n]),X=u.useCallback(e=>e instanceof Error&&e.message.trim()?e.message:"Failed to run child session",[]),V=u.useCallback(async(e,l="regenerate")=>{d(e),h(n,e,{status:"running",error:void 0,lastEventAt:new Date().toISOString()}),z(e);try{const r=await H.executeTool({tool_name:"SubAgent",session_id:n,parameters:[{name:"action",value:"run"},{name:"child_session_id",value:e},{name:"reset_to_last_user",value:l==="error_retry"?"false":"true"}]});if(!r.success)throw new Error(r.result||"Failed to run sub-agent");h(n,e,{status:"running",error:void 0,lastEventAt:new Date().toISOString()}),await O(e,{mode:"replace"}),await T()}catch(r){R(e),h(n,e,{status:"error",error:X(r),lastEventAt:new Date().toISOString()})}finally{d(r=>r===e?null:r)}},[O,n,T,z,R,X,h]),Z=u.useCallback(async e=>{const l=typeof window<"u"?window.prompt.bind(window):null;if(!l)return;const r=l("Send a follow-up message to this sub-agent:","Continue from where you left off.");if(r===null)return;const a=r.trim();if(!a){h(n,e,{status:"error",error:"Follow-up message cannot be empty.",lastEventAt:new Date().toISOString()});return}S(e),h(n,e,{status:"running",error:void 0,lastEventAt:new Date().toISOString()}),M(e);try{const g=await H.executeTool({tool_name:"SubAgent",session_id:n,parameters:[{name:"action",value:"send_message"},{name:"child_session_id",value:e},{name:"message",value:a},{name:"auto_run",value:"true"}]});if(!g.success)throw new Error(g.result||"Follow-up failed");let y="running";try{JSON.parse(g.result).status==="pending"&&(y="pending")}catch{y="running"}h(n,e,{status:y,error:void 0,lastEventAt:new Date().toISOString()}),await T()}catch(g){R(e),h(n,e,{status:"error",error:g instanceof Error&&g.message.trim()?g.message:"Failed to continue child session",lastEventAt:new Date().toISOString()})}finally{S(g=>g===e?null:g)}},[n,T,M,R,h]),ee=u.useCallback(async e=>{x(e);try{const l=await H.executeTool({tool_name:"SubAgent",session_id:n,parameters:[{name:"action",value:"delete"},{name:"child_session_id",value:e}]});if(!l.success)throw new Error(l.result||"Failed to delete sub-agent");L(n,e),await T()}finally{x(l=>l===e?null:l)}},[L,n,T]);return w.length===0?null:i.jsxs(ie,{size:"small",className:"lotus-settings-card",style:{marginBottom:s.marginMD},"data-testid":"sub-agents-panel",title:i.jsxs(C,{strong:!0,children:[t("chat.subAgents.title")," ",i.jsxs(C,{type:"secondary",children:["(",w.length,")"]})]}),extra:i.jsx(_,{type:"text",size:"small",icon:o?i.jsx(de,{}):i.jsx(ge,{}),onClick:Q,"data-testid":"sub-agents-toggle",children:t(o?"chat.subAgents.expand":"chat.subAgents.collapse")}),children:[o?i.jsx(C,{type:"secondary","data-testid":"sub-agents-collapsed-hint",children:t("chat.subAgents.hiddenHint",{count:w.length})}):i.jsx(k,{vertical:!0,gap:s.marginSM,"data-testid":"sub-agents-list",style:{maxHeight:`${Ce}px`,overflowY:"auto",paddingRight:s.paddingXS},children:w.map(e=>{const l=P(e.status),r=l==="running",a=p===e.childSessionId,g=A===e.childSessionId,y=b===e.childSessionId,$=a||g||y;return i.jsxs(k,{align:"flex-start",justify:"space-between",gap:s.marginSM,className:"lotus-settings-list-item",style:{padding:s.paddingSM,borderRadius:s.borderRadiusSM},children:[i.jsxs(k,{vertical:!0,style:{flex:1,minWidth:0},children:[i.jsxs(k,{align:"center",gap:s.marginXS,style:{minWidth:0},children:[i.jsx(C,{strong:!0,ellipsis:!0,style:{minWidth:0},children:e.title||"Sub-agent"}),i.jsx(I,{color:l==="running"?"processing":l==="completed"?"success":l==="error"||l==="failed"?"error":l==="cancelled"?"warning":"default",style:{marginInlineEnd:0,flex:"0 0 auto"},children:l}),e.pinned?i.jsx(I,{color:"warning",style:{marginInlineEnd:0,flex:"0 0 auto"},children:"Pinned"}):null,Se(e.subagentType,q)]}),i.jsxs(C,{type:"secondary",style:{fontSize:12,marginTop:2},children:[e.childSessionId.slice(0,8),e.updatedAt?` • ${e.updatedAt}`:"",e.lastHeartbeatAt?` • heartbeat: ${e.lastHeartbeatAt}`:"",typeof e.roundCount=="number"?` • round ${e.roundCount+1}`:""]}),e.outputPreview?i.jsx(C,{type:"secondary",style:{marginTop:s.marginXS,fontSize:13},ellipsis:!0,children:e.outputPreview}):null,e.error?i.jsx(C,{type:"danger",style:{marginTop:s.marginXS},children:e.error}):null]}),i.jsxs(k,{gap:8,children:[i.jsx(_,{size:"small",disabled:$,onClick:()=>{le(e.childSessionId),O(e.childSessionId)},children:t("chat.subAgents.open")}),i.jsx(_,{size:"small",loading:g,disabled:y||a||r,"data-testid":`sub-agent-continue-${e.childSessionId}`,onClick:()=>{Z(e.childSessionId)},children:t("chat.subAgents.continue")}),i.jsx(ce,{trigger:["click"],menu:{items:[{key:"regenerate",label:t("chat.actions.regenerate")},{key:"error_retry",label:t("chat.actions.retryFailed")}],onClick:({key:te})=>{V(e.childSessionId,te)}},disabled:y||r||g,children:i.jsx(_,{size:"small",loading:a,disabled:y||r||g,"data-testid":`sub-agent-retry-${e.childSessionId}`,children:t("chat.subAgents.retry")})}),typeof e.pinned=="boolean"?i.jsx(_,{size:"small",disabled:$,onClick:()=>{e.pinned?J(e.childSessionId):Y(e.childSessionId)},children:e.pinned?t("chat.actions.unpin"):t("chat.actions.pin")}):null,i.jsx(_,{danger:!0,size:"small",loading:y,disabled:a,"data-testid":`sub-agent-delete-${e.childSessionId}`,onClick:()=>{ee(e.childSessionId)},children:t("common.delete")})]})]},e.childSessionId)})}),!o&&w.length>1&&i.jsx(Ae,{items:w})]})},Ae=({items:n})=>{const{token:t}=G(),s=n.reduce((c,p)=>{const d=P(p.status);return d==="completed"?c.completed++:d==="running"?c.running++:d==="error"||d==="failed"?c.error++:c.pending++,c},{completed:0,running:0,error:0,pending:0}),o=[];return s.completed>0&&o.push(`${s.completed} completed`),s.running>0&&o.push(`${s.running} running`),s.pending>0&&o.push(`${s.pending} pending`),s.error>0&&o.push(`${s.error} failed`),o.length===0?null:i.jsx(C,{type:"secondary",style:{fontSize:11,marginTop:t.marginXS,display:"block"},children:o.join(" · ")})};export{Oe as SubAgentsPanel};
|
|
1
|
+
var ne=Object.defineProperty;var se=(n,t,s)=>t in n?ne(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s;var N=(n,t,s)=>se(n,typeof t!="symbol"?t+"":t,s);import{j as i}from"./vendor-markdown-DzaXAW9Q.js";import{a as u,u as re}from"./vendor-i18n-BNURlJ23.js";import{n as E,v as W,w as oe,u as f,x as ae,o as le}from"./App-BTGbaEEX.js";import{l as I,C as ie,a7 as k,j as ue,E as _,ak as ce,v as de,ad as ge,t as me}from"./vendor-antd-DODjfilb.js";import"./vendor-mermaid-De-Yacw-.js";import"./main-mHH04gTP.js";const v=class v{static getInstance(){return v.instance||(v.instance=new v),v.instance}parseUserCommand(t){E("[ToolService]",`[ToolService] parseUserCommand: Parsing content: "${t}"`);const s=t.trim();if(!s.startsWith("/"))return E("[ToolService]",'[ToolService] parseUserCommand: Content does not start with "/", not a tool command.'),null;const o=s.indexOf(" ");let c,p;if(o===-1?(c=s.substring(1),p=""):(c=s.substring(1,o),p=s.substring(o+1).trim()),c){const d={tool_name:c,user_description:p};return E("[ToolService]","[ToolService] parseUserCommand: Successfully parsed command:",d),d}return E("[ToolService]","[ToolService] parseUserCommand: Failed to parse tool name from content."),null}parseAIResponseToToolCall(t){return this.parseUserCommand(t)}async executeTool(t){E("[ToolService]","[ToolService] executeTool: Attempting to execute tool via HTTP with request:",t);try{const s=await W.post("tools/execute",t),o=JSON.parse(s.result);return E("[ToolService]","[ToolService] executeTool: Parsed structured result:",o),o}catch(s){throw console.error("[ToolService] executeTool: HTTP tool execution failed:",s),s instanceof oe?new Error(`Workflow execution failed: ${s.message}`):s}}};N(v,"instance");let F=v;const H=new F;class pe{async listProfiles(){return W.get("subagent_profiles")}}const fe=new pe,he=[];function ye(n={}){const{enabled:t=!0,refreshKey:s}=n,[o,c]=u.useState(null),[p,d]=u.useState(!1),[A,S]=u.useState(null),b=u.useCallback(async()=>{d(!0);try{const m=await fe.listProfiles();c(m),S(null)}catch(m){S(m instanceof Error?m:new Error(String(m)))}finally{d(!1)}},[]);u.useEffect(()=>{t&&b()},[t,b,s]);const x=u.useMemo(()=>{const m=new Map;if(o!=null&&o.profiles)for(const j of o.profiles)m.set(j.id,j);return m},[o]);return{profiles:(o==null?void 0:o.profiles)??he,fallbackId:(o==null?void 0:o.fallback_id)??null,loading:p,error:A,refresh:b,byId:x}}const Se=(n,t)=>{var A,S,b,x,m;const s=n==null?void 0:n.trim();if(!s)return null;const o=t.get(s),c=((A=o==null?void 0:o.display_name)==null?void 0:A.trim())||s,p=(b=(S=o==null?void 0:o.ui)==null?void 0:S.icon)==null?void 0:b.trim(),d=((m=(x=o==null?void 0:o.ui)==null?void 0:x.color)==null?void 0:m.trim())||void 0;return i.jsx(I,{color:d,style:{marginInlineEnd:0,flex:"0 0 auto"},"data-testid":`sub-agent-role-tag-${s}`,children:p?`${p} ${c}`:c})},{Text:C}=ue,{useToken:G}=me,be="chat-session-sub-agents-collapsed:",we=3,Ce=600,P=n=>{const t=(n||"").trim().toLowerCase();return t?t==="started"||t==="already_running"?"running":t==="success"||t==="done"?"completed":t==="canceled"?"cancelled":t==="queued"||t==="created"?"pending":t:"pending"},xe=(n,t)=>{if(t&&t.trim())return t;if(n.isRunning)return"running";if(n.lastRunStatus&&n.lastRunStatus.trim())return n.lastRunStatus;const s=n.messageCount??0;return s>2?"completed":(s>0,"pending")},K=n=>`${be}${n}`,D=n=>{if(typeof window>"u")return!1;try{const t=window.localStorage.getItem(K(n));return t==="1"?!0:t==="0"?!1:null}catch{return null}},ve=(n,t)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(K(n),t?"1":"0")}catch{}},Oe=({parentSessionId:n})=>{const{t}=re(),{token:s}=G(),[o,c]=u.useState(()=>D(n)??!1),[p,d]=u.useState(null),[A,S]=u.useState(null),[b,x]=u.useState(null),m=f(e=>ae(n)(e)),j=f(e=>e.chats),O=f(e=>e.loadChatHistory),T=f(e=>e.refreshChats),M=f(e=>e.markOptimisticStart),z=f(e=>e.markRetryStart),R=f(e=>e.markSettleTimeout),Y=f(e=>e.pinSession),J=f(e=>e.unpinSession),h=f(e=>e.applyChildProgress),L=f(e=>e.clearChildProgress),{byId:q}=ye(),U=u.useMemo(()=>Object.entries(m).map(([e,l])=>({childSessionId:e,...l})),[m]),B=u.useMemo(()=>j.filter(e=>e.kind==="child"&&e.parentSessionId===n).sort((e,l)=>{const r=Date.parse(e.updatedAt||"")||0;return(Date.parse(l.updatedAt||"")||0)-r}),[j,n]),w=u.useMemo(()=>{const e=new Map(U.map(r=>[r.childSessionId,r])),l=[];for(const r of B){const a=e.get(r.id);l.push({childSessionId:r.id,title:r.title||(a==null?void 0:a.title),status:P(xe(r,a==null?void 0:a.status)),error:(a==null?void 0:a.error)||r.lastRunError,lastHeartbeatAt:a==null?void 0:a.lastHeartbeatAt,lastEventAt:a==null?void 0:a.lastEventAt,outputPreview:a==null?void 0:a.outputPreview,roundCount:a==null?void 0:a.roundCount,pinned:r.pinned,updatedAt:r.updatedAt,isRunning:r.isRunning,messageCount:r.messageCount,lastRunStatus:r.lastRunStatus,lastRunError:r.lastRunError,subagentType:r.subagentType??null}),e.delete(r.id)}for(const r of e.values())l.push({childSessionId:r.childSessionId,title:r.title,status:P(r.status),error:r.error,lastHeartbeatAt:r.lastHeartbeatAt,lastEventAt:r.lastEventAt,outputPreview:r.outputPreview,roundCount:r.roundCount});return l},[B,U]);u.useEffect(()=>{c(D(n)??!1)},[n]),u.useEffect(()=>{D(n)===null&&c(w.length>we)},[n,w.length]);const Q=u.useCallback(()=>{c(e=>{const l=!e;return ve(n,l),l})},[n]),X=u.useCallback(e=>e instanceof Error&&e.message.trim()?e.message:"Failed to run child session",[]),V=u.useCallback(async(e,l="regenerate")=>{d(e),h(n,e,{status:"running",error:void 0,lastEventAt:new Date().toISOString()}),z(e);try{const r=await H.executeTool({tool_name:"SubAgent",session_id:n,parameters:[{name:"action",value:"run"},{name:"child_session_id",value:e},{name:"reset_to_last_user",value:l==="error_retry"?"false":"true"}]});if(!r.success)throw new Error(r.result||"Failed to run sub-agent");h(n,e,{status:"running",error:void 0,lastEventAt:new Date().toISOString()}),await O(e,{mode:"replace"}),await T()}catch(r){R(e),h(n,e,{status:"error",error:X(r),lastEventAt:new Date().toISOString()})}finally{d(r=>r===e?null:r)}},[O,n,T,z,R,X,h]),Z=u.useCallback(async e=>{const l=typeof window<"u"?window.prompt.bind(window):null;if(!l)return;const r=l("Send a follow-up message to this sub-agent:","Continue from where you left off.");if(r===null)return;const a=r.trim();if(!a){h(n,e,{status:"error",error:"Follow-up message cannot be empty.",lastEventAt:new Date().toISOString()});return}S(e),h(n,e,{status:"running",error:void 0,lastEventAt:new Date().toISOString()}),M(e);try{const g=await H.executeTool({tool_name:"SubAgent",session_id:n,parameters:[{name:"action",value:"send_message"},{name:"child_session_id",value:e},{name:"message",value:a},{name:"auto_run",value:"true"}]});if(!g.success)throw new Error(g.result||"Follow-up failed");let y="running";try{JSON.parse(g.result).status==="pending"&&(y="pending")}catch{y="running"}h(n,e,{status:y,error:void 0,lastEventAt:new Date().toISOString()}),await T()}catch(g){R(e),h(n,e,{status:"error",error:g instanceof Error&&g.message.trim()?g.message:"Failed to continue child session",lastEventAt:new Date().toISOString()})}finally{S(g=>g===e?null:g)}},[n,T,M,R,h]),ee=u.useCallback(async e=>{x(e);try{const l=await H.executeTool({tool_name:"SubAgent",session_id:n,parameters:[{name:"action",value:"delete"},{name:"child_session_id",value:e}]});if(!l.success)throw new Error(l.result||"Failed to delete sub-agent");L(n,e),await T()}finally{x(l=>l===e?null:l)}},[L,n,T]);return w.length===0?null:i.jsxs(ie,{size:"small",className:"lotus-settings-card",style:{marginBottom:s.marginMD},"data-testid":"sub-agents-panel",title:i.jsxs(C,{strong:!0,children:[t("chat.subAgents.title")," ",i.jsxs(C,{type:"secondary",children:["(",w.length,")"]})]}),extra:i.jsx(_,{type:"text",size:"small",icon:o?i.jsx(de,{}):i.jsx(ge,{}),onClick:Q,"data-testid":"sub-agents-toggle",children:t(o?"chat.subAgents.expand":"chat.subAgents.collapse")}),children:[o?i.jsx(C,{type:"secondary","data-testid":"sub-agents-collapsed-hint",children:t("chat.subAgents.hiddenHint",{count:w.length})}):i.jsx(k,{vertical:!0,gap:s.marginSM,"data-testid":"sub-agents-list",style:{maxHeight:`${Ce}px`,overflowY:"auto",paddingRight:s.paddingXS},children:w.map(e=>{const l=P(e.status),r=l==="running",a=p===e.childSessionId,g=A===e.childSessionId,y=b===e.childSessionId,$=a||g||y;return i.jsxs(k,{align:"flex-start",justify:"space-between",gap:s.marginSM,className:"lotus-settings-list-item",style:{padding:s.paddingSM,borderRadius:s.borderRadiusSM},children:[i.jsxs(k,{vertical:!0,style:{flex:1,minWidth:0},children:[i.jsxs(k,{align:"center",gap:s.marginXS,style:{minWidth:0},children:[i.jsx(C,{strong:!0,ellipsis:!0,style:{minWidth:0},children:e.title||"Sub-agent"}),i.jsx(I,{color:l==="running"?"processing":l==="completed"?"success":l==="error"||l==="failed"?"error":l==="cancelled"?"warning":"default",style:{marginInlineEnd:0,flex:"0 0 auto"},children:l}),e.pinned?i.jsx(I,{color:"warning",style:{marginInlineEnd:0,flex:"0 0 auto"},children:"Pinned"}):null,Se(e.subagentType,q)]}),i.jsxs(C,{type:"secondary",style:{fontSize:12,marginTop:2},children:[e.childSessionId.slice(0,8),e.updatedAt?` • ${e.updatedAt}`:"",e.lastHeartbeatAt?` • heartbeat: ${e.lastHeartbeatAt}`:"",typeof e.roundCount=="number"?` • round ${e.roundCount+1}`:""]}),e.outputPreview?i.jsx(C,{type:"secondary",style:{marginTop:s.marginXS,fontSize:13},ellipsis:!0,children:e.outputPreview}):null,e.error?i.jsx(C,{type:"danger",style:{marginTop:s.marginXS},children:e.error}):null]}),i.jsxs(k,{gap:8,children:[i.jsx(_,{size:"small",disabled:$,onClick:()=>{le(e.childSessionId),O(e.childSessionId)},children:t("chat.subAgents.open")}),i.jsx(_,{size:"small",loading:g,disabled:y||a||r,"data-testid":`sub-agent-continue-${e.childSessionId}`,onClick:()=>{Z(e.childSessionId)},children:t("chat.subAgents.continue")}),i.jsx(ce,{trigger:["click"],menu:{items:[{key:"regenerate",label:t("chat.actions.regenerate")},{key:"error_retry",label:t("chat.actions.retryFailed")}],onClick:({key:te})=>{V(e.childSessionId,te)}},disabled:y||r||g,children:i.jsx(_,{size:"small",loading:a,disabled:y||r||g,"data-testid":`sub-agent-retry-${e.childSessionId}`,children:t("chat.subAgents.retry")})}),typeof e.pinned=="boolean"?i.jsx(_,{size:"small",disabled:$,onClick:()=>{e.pinned?J(e.childSessionId):Y(e.childSessionId)},children:e.pinned?t("chat.actions.unpin"):t("chat.actions.pin")}):null,i.jsx(_,{danger:!0,size:"small",loading:y,disabled:a,"data-testid":`sub-agent-delete-${e.childSessionId}`,onClick:()=>{ee(e.childSessionId)},children:t("common.delete")})]})]},e.childSessionId)})}),!o&&w.length>1&&i.jsx(Ae,{items:w})]})},Ae=({items:n})=>{const{token:t}=G(),s=n.reduce((c,p)=>{const d=P(p.status);return d==="completed"?c.completed++:d==="running"?c.running++:d==="error"||d==="failed"?c.error++:c.pending++,c},{completed:0,running:0,error:0,pending:0}),o=[];return s.completed>0&&o.push(`${s.completed} completed`),s.running>0&&o.push(`${s.running} running`),s.pending>0&&o.push(`${s.pending} pending`),s.error>0&&o.push(`${s.error} failed`),o.length===0?null:i.jsx(C,{type:"secondary",style:{fontSize:11,marginTop:t.marginXS,display:"block"},children:o.join(" · ")})};export{Oe as SubAgentsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as o}from"./vendor-markdown-DzaXAW9Q.js";import{u as A,R as D,a as T}from"./vendor-i18n-BNURlJ23.js";import{u as g}from"./App-
|
|
1
|
+
import{j as o}from"./vendor-markdown-DzaXAW9Q.js";import{u as A,R as D,a as T}from"./vendor-i18n-BNURlJ23.js";import{u as g}from"./App-BTGbaEEX.js";import{t as F,C as M,A as W,i as q,P as O,j as Q,L as k,S as m,k as f,l as y,m as G,n as H,o as $,p as J,q as N,u as U,v as V,w as X,x as v,B as Y,y as Z,z as oo}from"./vendor-antd-DODjfilb.js";import"./vendor-mermaid-De-Yacw-.js";import"./main-mHH04gTP.js";const{Text:p}=Q,so=c=>({pending:{icon:o.jsx(oo,{}),color:c.colorTextTertiary,textKey:"components.todoList.status.pending",tagColor:"default"},in_progress:{icon:o.jsx(v,{spin:!0}),color:c.colorPrimary,textKey:"components.todoList.status.inProgress",tagColor:"processing"},completed:{icon:o.jsx($,{}),color:c.colorSuccess,textKey:"components.todoList.status.completed",tagColor:"success"},blocked:{icon:o.jsx(Z,{}),color:c.colorError,textKey:"components.todoList.status.blocked",tagColor:"error"}}),io=({sessionId:c,initialCollapsed:P=!0})=>{const{t:e}=A(),{token:t}=F.useToken(),z=D.useMemo(()=>so(t),[t]),x=g(s=>s.chats.find(d=>d.id===c)),h=(x==null?void 0:x.kind)==="child"&&(x.parentSessionId||x.rootSessionId)||c,n=g(s=>s.taskLists[h]),_=g(s=>s.activeItems[h]),a=g(s=>s.evaluationStates[h]),[l,S]=T.useState(P),[i,B]=T.useState(!1),I=(a==null?void 0:a.isEvaluating)||!1,L=(a==null?void 0:a.reasoning)||null,C=n?{session_id:n.session_id,title:n.title,items:n.items,progress:{completed:n.items.filter(s=>s.status==="completed").length,total:n.items.length,percentage:n.items.length>0?Math.round(n.items.filter(s=>s.status==="completed").length/n.items.length*100):0}}:null;if(!C)return null;const R=()=>{i||S(!l)},w=s=>{s.stopPropagation(),B(!i),i||S(!1)},{title:E,items:K,progress:r}=C,j=r.percentage===100;return o.jsx(M,{size:"small",style:{marginBottom:16,borderRadius:8,boxShadow:I?`0 0 0 2px ${t.colorPrimaryBorder}`:"0 2px 8px rgba(0, 0, 0, 0.06)",opacity:l&&!i?.9:1},styles:{body:{padding:l?"12px 16px":16}},title:o.jsxs(m,{onClick:R,style:{cursor:"pointer",width:"100%"},children:[o.jsx(X,{style:{color:t.colorPrimary}}),o.jsx(p,{strong:!0,style:{fontSize:15},children:E||e("components.todoList.title")}),I&&o.jsx(y,{icon:o.jsx(v,{spin:!0}),color:"processing",children:e("components.todoList.evaluating")}),!l&&r.total>0&&o.jsx(Y,{count:`${r.completed}/${r.total}`,style:{backgroundColor:j?t.colorSuccess:t.colorPrimary}})]}),extra:o.jsxs(m,{children:[r.total>0&&l&&o.jsxs(p,{type:"secondary",style:{fontSize:13},children:[r.completed,"/",r.total,j&&o.jsx($,{style:{color:t.colorSuccess,marginLeft:4}})]}),o.jsx(f,{title:e(i?"components.todoList.unpin":"components.todoList.pin"),children:o.jsx("span",{onClick:w,style:{cursor:"pointer",color:i?t.colorPrimary:t.colorTextSecondary,fontSize:16},children:i?o.jsx(J,{}):o.jsx(N,{})})}),!i&&o.jsx("span",{onClick:R,style:{cursor:"pointer",color:t.colorTextSecondary,fontSize:12,transform:l?"rotate(-90deg)":void 0,transition:"transform 0.2s"},children:l?o.jsx(U,{}):o.jsx(V,{})})]}),children:!l&&o.jsxs(o.Fragment,{children:[L&&o.jsx(W,{icon:o.jsx(q,{}),message:e("components.todoList.llmEvaluation"),description:L,type:"info",showIcon:!0,style:{marginBottom:16}}),r.total>0&&o.jsx("div",{style:{marginBottom:16},children:o.jsx(O,{percent:r.percentage,size:"small",status:j?"success":"active",format:s=>o.jsxs(p,{type:"secondary",children:[s,"%"]})})}),o.jsx(k,{size:"small",dataSource:K,renderItem:s=>{const d=z[s.status],u=_===s.id,b=e(d.textKey);return o.jsx(k.Item,{style:{padding:"12px 0",borderLeft:u?`3px solid ${t.colorPrimary}`:"3px solid transparent",paddingLeft:u?12:15,backgroundColor:u?t.colorPrimaryBg:"transparent",borderRadius:4,marginBottom:4},children:o.jsx("div",{style:{width:"100%"},children:o.jsxs(m,{align:"start",style:{width:"100%"},children:[o.jsx(f,{title:b,children:o.jsx("span",{style:{color:d.color,fontSize:16},children:d.icon})}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx(p,{style:{textDecoration:s.status==="completed"?"line-through":"none",color:s.status==="completed"?t.colorTextSecondary:t.colorText,fontWeight:u?500:400},children:s.description}),o.jsx("div",{style:{marginTop:4},children:o.jsxs(m,{size:8,wrap:!0,children:[o.jsx(y,{color:d.tagColor,children:b}),s.tool_calls_count!==void 0&&s.tool_calls_count>0&&o.jsxs(y,{icon:o.jsx(G,{}),color:"processing",children:[s.tool_calls_count," ",e("components.todoList.tools")]}),s.depends_on.length>0&&o.jsx(f,{title:e("components.todoList.dependsOn",{deps:s.depends_on.join(", ")}),children:o.jsxs(y,{icon:o.jsx(H,{}),children:[s.depends_on.length," ",e("components.todoList.dependencies")]})})]})}),s.status==="completed"&&s.summary&&o.jsx(p,{type:"secondary",style:{display:"block",marginTop:6,fontSize:12,padding:"4px 8px",backgroundColor:t.colorSuccessBg,borderRadius:4,color:t.colorSuccess},children:s.summary}),s.notes&&o.jsx(p,{type:"secondary",style:{display:"block",marginTop:6,fontSize:12,padding:"4px 8px",backgroundColor:t.colorFillQuaternary,borderRadius:4},children:s.notes})]})]})})})}})]})})};export{io as TodoList,io as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./vendor-markdown-DzaXAW9Q.js";import{u as y,a as c}from"./vendor-i18n-BNURlJ23.js";import{u as x,s as j,E as N}from"./App-
|
|
1
|
+
import{j as s}from"./vendor-markdown-DzaXAW9Q.js";import{u as y,a as c}from"./vendor-i18n-BNURlJ23.js";import{u as x,s as j,E as N}from"./App-BTGbaEEX.js";import{t as T,a5 as v,a6 as R,q as S,z as w,H as k,a2 as I,l as b,u as A}from"./vendor-antd-DODjfilb.js";import"./vendor-mermaid-De-Yacw-.js";import"./main-mHH04gTP.js";const M=5,$=5,C=5,D=o=>{if(!o)return"";try{const l=Date.now()-new Date(o).getTime();if(l<0)return"";const t=Math.floor(l/1e3);if(t<60)return"just now";const n=Math.floor(t/60);if(n<60)return`${n}m ago`;const i=Math.floor(n/60);if(i<24)return`${i}h ago`;const r=Math.floor(i/24);return r<30?`${r}d ago`:new Date(o).toLocaleDateString()}catch{return""}},E=(o,l)=>l?"is-running":o.lastRunStatus==="error"?"is-error":o.pinned?"is-pinned":"is-idle",h=({chat:o,onOpen:l,textSecondary:t})=>{const n=x(j(o.id)),i=o.config.workspacePath?o.config.workspacePath.split("/").pop()||o.config.workspacePath:null;return s.jsxs("button",{type:"button",className:"lotus-home-session-item",onClick:()=>l(o.id),children:[s.jsx("span",{className:`lotus-home-session-status ${E(o,n)}`}),s.jsxs("span",{className:"lotus-home-session-content",children:[s.jsx("span",{className:"lotus-home-session-title",children:o.title}),s.jsxs("span",{className:"lotus-home-session-meta",style:{color:t},children:[s.jsx("span",{children:D(o.updatedAt)}),i?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"lotus-home-session-meta-sep"}),s.jsxs("span",{children:[s.jsx(k,{style:{marginRight:3}}),i]})]}):null,o.messageCount!=null?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"lotus-home-session-meta-sep"}),s.jsxs("span",{children:[s.jsx(I,{style:{marginRight:3}}),o.messageCount]})]}):null]})]}),n?s.jsx(b,{color:"green",bordered:!1,style:{margin:0,fontSize:11},children:"Running"}):null,s.jsx(A,{className:"lotus-home-session-arrow"})]})},F=({onOpenSession:o})=>{const{t:l}=y(),{token:t}=T.useToken(),n=x(e=>e.chats),i=c.useCallback(e=>j(e)(x.getState()),[]),r=c.useMemo(()=>n.filter(e=>i(e.id)).slice(0,$),[n,i]),d=c.useMemo(()=>n.filter(e=>e.pinned&&!i(e.id)).slice(0,C),[n,i]),p=c.useMemo(()=>{const e=new Set(r.map(a=>a.id)),f=new Set(d.map(a=>a.id));return n.filter(a=>a.kind!=="child"&&!e.has(a.id)&&!f.has(a.id)).sort((a,u)=>{const g=a.updatedAt?new Date(a.updatedAt).getTime():a.createdAt;return(u.updatedAt?new Date(u.updatedAt).getTime():u.createdAt)-g}).slice(0,M)},[n,r,d]),m=c.useCallback(e=>{o(e)},[o]);return s.jsx("div",{className:"lotus-home-dashboard",children:s.jsxs("div",{className:"lotus-home-dashboard-inner",children:[s.jsxs("div",{className:"lotus-home-header",children:[s.jsx("span",{className:"lotus-home-header-icon",style:{background:`${t.colorPrimary}15`,color:t.colorPrimary},children:s.jsx(v,{})}),s.jsxs("div",{className:"lotus-home-header-text",children:[s.jsx("h2",{style:{color:t.colorText},children:l("home.title","Welcome to Bodhi")}),s.jsx("p",{style:{color:t.colorTextSecondary},children:l("home.subtitle","Here's an overview of your workspace.")})]})]}),s.jsx("div",{className:"lotus-home-launcher-shell","data-tour-id":"task-templates",children:s.jsx(N,{embedded:!0,layoutMode:"staggered"})}),s.jsxs("div",{className:"lotus-home-secondary-sections",children:[r.length>0?s.jsxs("div",{className:"lotus-home-section",children:[s.jsxs("div",{className:"lotus-home-section-title",style:{color:t.colorTextSecondary},children:[s.jsx(R,{className:"lotus-home-section-icon",style:{color:"#52c41a"}}),s.jsx("span",{children:l("home.sections.running","Running Now")})]}),s.jsx("div",{className:"lotus-home-session-list",children:r.map(e=>s.jsx(h,{chat:e,onOpen:m,textSecondary:t.colorTextTertiary},e.id))})]}):null,d.length>0?s.jsxs("div",{className:"lotus-home-section",children:[s.jsxs("div",{className:"lotus-home-section-title",style:{color:t.colorTextSecondary},children:[s.jsx(S,{className:"lotus-home-section-icon",style:{color:"#faad14"}}),s.jsx("span",{children:l("home.sections.pinned","Pinned")})]}),s.jsx("div",{className:"lotus-home-session-list",children:d.map(e=>s.jsx(h,{chat:e,onOpen:m,textSecondary:t.colorTextTertiary},e.id))})]}):null,p.length>0?s.jsxs("div",{className:"lotus-home-section",children:[s.jsxs("div",{className:"lotus-home-section-title",style:{color:t.colorTextSecondary},children:[s.jsx(w,{className:"lotus-home-section-icon"}),s.jsx("span",{children:l("home.sections.recent","Recent Sessions")})]}),s.jsx("div",{className:"lotus-home-session-list",children:p.map(e=>s.jsx(h,{chat:e,onOpen:m,textSecondary:t.colorTextTertiary},e.id))})]}):null,n.length===0?s.jsx("div",{className:"lotus-home-empty-hint",style:{color:t.colorTextTertiary},children:l("home.empty","No sessions yet. Create one to get started!")}):null]})]})})};export{F as HomeDashboard,F as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as n}from"./vendor-markdown-DzaXAW9Q.js";import{u as U,a}from"./vendor-i18n-BNURlJ23.js";import{u as k,a as H,b as B,c as P,d as V,A as W,g as z,s as G,o as Y}from"./App-DaOPoP5b.js";import{t as X,K as Z,X as J,N as ee,Y as te,Z as se,$ as ne,a0 as oe,a1 as ae,a2 as ie,V as le,a3 as ce,W as re,j as de,z as me,a4 as ue,l as pe}from"./vendor-antd-DODjfilb.js";import"./vendor-mermaid-De-Yacw-.js";import"./main-CuvqMgTQ.js";const ge=[{id:"settings-provider",tabKey:"provider",titleKey:"commandPalette.actions.openProviderSettings",fallbackTitle:"Open Provider Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"AI",keywords:["api","key","openai","anthropic","gemini","model"]},{id:"settings-model-limits",tabKey:"model-limits",titleKey:"commandPalette.actions.openModelLimits",fallbackTitle:"Open Model Limits",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"AI",keywords:["token","context","window","budget","limit"]},{id:"settings-prompts",tabKey:"prompts",titleKey:"commandPalette.actions.openPrompts",fallbackTitle:"Open System Prompts",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"AI",keywords:["system","prompt","persona","instruction"]},{id:"settings-skills",tabKey:"skills",titleKey:"commandPalette.actions.openSkills",fallbackTitle:"Open Skills",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["skill","capability","plugin"]},{id:"settings-mcp",tabKey:"mcp",titleKey:"commandPalette.actions.openMcpSettings",fallbackTitle:"Open MCP Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["mcp","server","tool","external"]},{id:"settings-workflows",tabKey:"workflows",titleKey:"commandPalette.actions.openWorkflowSettings",fallbackTitle:"Open Workflow Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["workflow","automation","template"]},{id:"settings-hooks",tabKey:"hooks",titleKey:"commandPalette.actions.openHooks",fallbackTitle:"Open Hooks",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["hook","event","trigger","callback"]},{id:"settings-schedules",tabKey:"schedules",titleKey:"commandPalette.actions.openSchedulesSettings",fallbackTitle:"Open Schedules",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Ops",keywords:["schedule","cron","recurring","timer","automated"]},{id:"settings-sessions",tabKey:"sessions",titleKey:"commandPalette.actions.openSessionsSettings",fallbackTitle:"Open Session Monitor",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Monitor",keywords:["session","monitor","cleanup","history"]},{id:"settings-metrics",tabKey:"metrics",titleKey:"commandPalette.actions.openMetrics",fallbackTitle:"Open Metrics Dashboard",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Monitor",keywords:["metrics","dashboard","analytics","usage","stats"]},{id:"settings-masking",tabKey:"masking",titleKey:"commandPalette.actions.openMasking",fallbackTitle:"Open Keyword Masking",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"Security & privacy",badge:"Security",keywords:["mask","redact","privacy","keyword","sensitive"]},{id:"settings-env",tabKey:"env-vars",titleKey:"commandPalette.actions.openEnvVars",fallbackTitle:"Open Environment Variables",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"System",keywords:["env","environment","variable","config"]},{id:"settings-config",tabKey:"config",titleKey:"commandPalette.actions.openConfig",fallbackTitle:"Open Configuration",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"System",keywords:["config","json","bamboo","data","path"]},{id:"settings-app",tabKey:"app",titleKey:"commandPalette.actions.openAppSettings",fallbackTitle:"Open App Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"System",keywords:["app","application","reset","theme","language"]}],be=(t,c)=>{const i=[t.title,t.id,t.kind||"root"];return t.pinned&&i.push("pinned","pin"),c&&i.push("running","processing"),t.config.workspacePath&&i.push(t.config.workspacePath),t.updatedAt&&i.push(t.updatedAt),i.filter(Boolean)},fe=(t,c,i)=>{const l=[];if(t.kind==="child"?l.push(c):l.push(i),t.config.workspacePath&&l.push(t.config.workspacePath),t.updatedAt)try{l.push(new Date(t.updatedAt).toLocaleString())}catch{l.push(t.updatedAt)}return l.join(" • ")},ye=(t,c)=>{const i=c.trim().toLowerCase();return i?t.filter(l=>[l.title,l.subtitle||"",...l.keywords].join(" ").toLowerCase().includes(i)):t},ke=t=>{if(!(t instanceof HTMLElement))return!1;const c=t.tagName.toLowerCase();return t.isContentEditable?!0:c==="input"||c==="textarea"||c==="select"},K="__LOTUS_COMMAND_PALETTE_FORCE_OPEN__",Te=()=>{const{t}=U(),{token:c}=X.useToken(),i=typeof document<"u"&&document.body.getAttribute("data-vdi-safe")==="true",{message:l}=Z.useApp(),x=k(e=>e.chats),j=k(e=>e.addChat),v=k(e=>e.lastSelectedPromptId),m=k(e=>e.systemPrompts),I=k(e=>e.executionBySession),[u,p]=a.useState(()=>typeof window>"u"?!1:window[K]?(delete window[K],!0):!1),[T,S]=a.useState(""),[b,f]=a.useState(0),A=a.useRef(null),M=a.useRef(null),C=H(e=>e.open),O=B(e=>e.toggleTheme),E=B(e=>e.themeMode),w=P(e=>e.sidebar.collapsed),N=P(e=>e.setSidebarCollapsed),h=V(e=>e.mode),L=V(e=>e.toggleMode),R=a.useCallback(async()=>{var F,q;const e=m.find(y=>y.id===v),s=(e==null?void 0:e.id)||(m.length>0?((F=m.find(y=>y.id==="general_assistant"))==null?void 0:F.id)||m[0].id:""),d=await j({title:t("chat.sidebar.newSession"),createdAt:Date.now(),messages:[],config:{systemPromptId:s,baseSystemPrompt:(e==null?void 0:e.content)||(m.length>0?((q=m.find(y=>y.id==="general_assistant"))==null?void 0:q.content)||m[0].content:""),lastUsedEnhancedPrompt:null}}),{activeLeafId:o,setLeafSessionId:g,setActiveLeafId:Q}=P.getState();g(o,d),Q(o)},[j,v,m,t]),_=a.useMemo(()=>{const e=ge.filter(s=>!(h==="simple"&&W.has(s.tabKey))).map(s=>({id:s.id,kind:"action",title:t(s.titleKey,s.fallbackTitle),subtitle:t(s.subtitleKey||"commandPalette.groups.settings",s.fallbackSubtitle||"System settings"),keywords:[s.tabKey,s.badge||"","settings","config",...s.keywords||[]],icon:n.jsx(J,{}),badge:s.badge,onSelect:()=>{C("chat",s.tabKey)}}));return[{id:"new-session",kind:"action",title:t("commandPalette.actions.newSession","Create New Session"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["new","create","session","chat","conversation"],icon:n.jsx(ee,{}),badge:t("commandPalette.badges.quickAction","Action"),onSelect:async()=>{await R()}},{id:"toggle-theme",kind:"action",title:E==="dark"?t("commandPalette.actions.switchToLight","Switch to Light Mode"):t("commandPalette.actions.switchToDark","Switch to Dark Mode"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["theme","dark","light","mode","appearance","toggle","color"],icon:n.jsx(te,{}),badge:E==="dark"?"☀️":"🌙",onSelect:()=>{O()}},{id:"toggle-sidebar",kind:"action",title:w?t("commandPalette.actions.showSidebar","Show Sidebar"):t("commandPalette.actions.hideSidebar","Hide Sidebar"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["sidebar","toggle","hide","show","panel","menu"],icon:w?n.jsx(se,{}):n.jsx(ne,{}),badge:"Layout",onSelect:()=>{N(!w)}},{id:"split-pane",kind:"action",title:t("commandPalette.actions.splitPane","Split Pane"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["split","pane","multi","dual","side","layout"],icon:n.jsx(oe,{}),badge:"Layout",onSelect:()=>{const{tree:s,activeLeafId:d,splitLeaf:o}=P.getState();z(s).length<4&&o(d,"vertical")}},...e,{id:"toggle-experience-mode",kind:"action",title:h==="simple"?t("commandPalette.actions.switchToAdvanced","Switch to Advanced Mode"):t("commandPalette.actions.switchToSimple","Switch to Simple Mode"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["mode","simple","advanced","beginner","expert","experience","complexity"],icon:n.jsx(ae,{}),badge:h==="simple"?"Simple":"Advanced",onSelect:()=>{L()}}]},[R,C,O,E,w,N,h,L,t]),D=a.useMemo(()=>x.map(e=>{const s=G(e.id)({executionBySession:I});return{id:`session-${e.id}`,kind:"session",title:e.title,subtitle:fe(e,t("commandPalette.badges.childSession","Child session"),t("commandPalette.badges.rootSession","Session")),keywords:be(e,s),icon:n.jsx(ie,{}),badge:e.pinned?t("commandPalette.badges.pinned","Pinned"):s?t("commandPalette.badges.running","Running"):e.kind==="child"?t("commandPalette.badges.child","Child"):void 0,onSelect:()=>{Y(e.id)}}}),[x,I,t]),$=a.useMemo(()=>[..._,...D],[_,D]),r=a.useMemo(()=>ye($,T).slice(0,40),[$,T]);return a.useEffect(()=>{f(e=>r.length===0?0:Math.min(e,r.length-1))},[r.length]),a.useEffect(()=>{if(!u)return;const e=window.setTimeout(()=>{var s,d;(s=A.current)==null||s.focus(),(d=A.current)==null||d.select()},0);return()=>window.clearTimeout(e)},[u]),a.useEffect(()=>{if(typeof window>"u")return;const e=s=>{if((s.metaKey||s.ctrlKey)&&s.key.toLowerCase()==="k"){s.preventDefault(),p(o=>!o);return}if(u){if(s.key==="Escape"){s.preventDefault(),p(!1);return}if(!(ke(s.target)&&s.key!=="ArrowUp"&&s.key!=="ArrowDown"&&s.key!=="Enter")){if(s.key==="ArrowDown"){s.preventDefault(),f(o=>r.length===0?0:(o+1)%r.length);return}if(s.key==="ArrowUp"){s.preventDefault(),f(o=>r.length===0?0:o===0?r.length-1:o-1);return}if(s.key==="Enter"){const o=r[b];if(!o)return;s.preventDefault(),(async()=>{try{await o.onSelect(),p(!1),S("")}catch(g){console.error("[CommandPalette] action failed",g),l.error(g instanceof Error?g.message:t("commandPalette.errors.actionFailed","Command failed"))}})()}}}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,l,u,b,t]),a.useEffect(()=>{u||(S(""),f(0))},[u]),a.useEffect(()=>{typeof window>"u"||!window[K]||(delete window[K],p(!0))},[]),a.useEffect(()=>{const e=M.current;if(!e)return;const s=e.querySelector(`[data-command-index="${b}"]`);s==null||s.scrollIntoView({block:"nearest"})},[b]),n.jsx(le,{open:u,onCancel:()=>p(!1),footer:null,centered:!0,width:680,destroyOnClose:!0,className:"lotus-command-palette-modal",title:null,closable:!1,styles:{content:{padding:12,borderRadius:c.borderRadiusLG,overflow:"hidden",background:c.colorBgElevated,backdropFilter:i?"none":"blur(18px)",WebkitBackdropFilter:i?"none":"blur(18px)"},body:{padding:0},mask:{backdropFilter:i?"none":"blur(6px)",WebkitBackdropFilter:i?"none":"blur(6px)"}},children:n.jsxs("div",{className:"lotus-command-palette-shell",children:[n.jsxs("div",{className:"lotus-command-palette-search",children:[n.jsx(ce,{style:{color:c.colorTextTertiary,fontSize:16}}),n.jsx(re,{ref:A,value:T,onChange:e=>S(e.target.value),variant:"borderless",placeholder:t("commandPalette.searchPlaceholder","Search sessions, settings, and actions"),"aria-label":t("commandPalette.searchPlaceholder","Search sessions, settings, and actions"),suffix:n.jsx(de.Text,{type:"secondary",style:{fontSize:12},children:"⌘K"})})]}),n.jsxs("div",{className:"lotus-command-palette-hint",children:[n.jsx(me,{}),n.jsx("span",{children:t("commandPalette.navigationHint","Use ↑↓ to navigate, Enter to open, and Esc to close.")})]}),n.jsx("div",{ref:M,className:"lotus-command-palette-list",role:"listbox",children:r.length===0?n.jsxs("div",{className:"lotus-command-palette-empty",children:[n.jsx(ue,{}),n.jsx("span",{children:t("commandPalette.empty","No matching commands")})]}):r.map((e,s)=>{const d=s===b;return n.jsxs("button",{type:"button",className:`lotus-command-palette-item ${d?"is-selected":""}`,"data-command-index":s,onMouseEnter:()=>f(s),onClick:()=>{(async()=>{try{await e.onSelect(),p(!1),S("")}catch(o){console.error("[CommandPalette] action failed",o),l.error(o instanceof Error?o.message:t("commandPalette.errors.actionFailed","Command failed"))}})()},children:[n.jsx("span",{className:"lotus-command-palette-item-icon",children:e.icon}),n.jsxs("span",{className:"lotus-command-palette-item-content",children:[n.jsxs("span",{className:"lotus-command-palette-item-title-row",children:[n.jsx("span",{className:"lotus-command-palette-item-title",children:e.title}),e.badge?n.jsx(pe,{bordered:!1,children:e.badge}):null]}),e.subtitle?n.jsx("span",{className:"lotus-command-palette-item-subtitle",children:e.subtitle}):null]})]},e.id)})})]})})};export{Te as CommandPalette,Te as default};
|
|
1
|
+
import{j as n}from"./vendor-markdown-DzaXAW9Q.js";import{u as U,a}from"./vendor-i18n-BNURlJ23.js";import{u as k,a as H,b as B,c as P,d as V,A as W,g as z,s as G,o as Y}from"./App-BTGbaEEX.js";import{t as X,K as Z,X as J,N as ee,Y as te,Z as se,$ as ne,a0 as oe,a1 as ae,a2 as ie,V as le,a3 as ce,W as re,j as de,z as me,a4 as ue,l as pe}from"./vendor-antd-DODjfilb.js";import"./vendor-mermaid-De-Yacw-.js";import"./main-mHH04gTP.js";const ge=[{id:"settings-provider",tabKey:"provider",titleKey:"commandPalette.actions.openProviderSettings",fallbackTitle:"Open Provider Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"AI",keywords:["api","key","openai","anthropic","gemini","model"]},{id:"settings-model-limits",tabKey:"model-limits",titleKey:"commandPalette.actions.openModelLimits",fallbackTitle:"Open Model Limits",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"AI",keywords:["token","context","window","budget","limit"]},{id:"settings-prompts",tabKey:"prompts",titleKey:"commandPalette.actions.openPrompts",fallbackTitle:"Open System Prompts",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"AI",keywords:["system","prompt","persona","instruction"]},{id:"settings-skills",tabKey:"skills",titleKey:"commandPalette.actions.openSkills",fallbackTitle:"Open Skills",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["skill","capability","plugin"]},{id:"settings-mcp",tabKey:"mcp",titleKey:"commandPalette.actions.openMcpSettings",fallbackTitle:"Open MCP Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["mcp","server","tool","external"]},{id:"settings-workflows",tabKey:"workflows",titleKey:"commandPalette.actions.openWorkflowSettings",fallbackTitle:"Open Workflow Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["workflow","automation","template"]},{id:"settings-hooks",tabKey:"hooks",titleKey:"commandPalette.actions.openHooks",fallbackTitle:"Open Hooks",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["hook","event","trigger","callback"]},{id:"settings-schedules",tabKey:"schedules",titleKey:"commandPalette.actions.openSchedulesSettings",fallbackTitle:"Open Schedules",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Ops",keywords:["schedule","cron","recurring","timer","automated"]},{id:"settings-sessions",tabKey:"sessions",titleKey:"commandPalette.actions.openSessionsSettings",fallbackTitle:"Open Session Monitor",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Monitor",keywords:["session","monitor","cleanup","history"]},{id:"settings-metrics",tabKey:"metrics",titleKey:"commandPalette.actions.openMetrics",fallbackTitle:"Open Metrics Dashboard",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Monitor",keywords:["metrics","dashboard","analytics","usage","stats"]},{id:"settings-masking",tabKey:"masking",titleKey:"commandPalette.actions.openMasking",fallbackTitle:"Open Keyword Masking",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"Security & privacy",badge:"Security",keywords:["mask","redact","privacy","keyword","sensitive"]},{id:"settings-env",tabKey:"env-vars",titleKey:"commandPalette.actions.openEnvVars",fallbackTitle:"Open Environment Variables",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"System",keywords:["env","environment","variable","config"]},{id:"settings-config",tabKey:"config",titleKey:"commandPalette.actions.openConfig",fallbackTitle:"Open Configuration",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"System",keywords:["config","json","bamboo","data","path"]},{id:"settings-app",tabKey:"app",titleKey:"commandPalette.actions.openAppSettings",fallbackTitle:"Open App Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"System",keywords:["app","application","reset","theme","language"]}],be=(t,c)=>{const i=[t.title,t.id,t.kind||"root"];return t.pinned&&i.push("pinned","pin"),c&&i.push("running","processing"),t.config.workspacePath&&i.push(t.config.workspacePath),t.updatedAt&&i.push(t.updatedAt),i.filter(Boolean)},fe=(t,c,i)=>{const l=[];if(t.kind==="child"?l.push(c):l.push(i),t.config.workspacePath&&l.push(t.config.workspacePath),t.updatedAt)try{l.push(new Date(t.updatedAt).toLocaleString())}catch{l.push(t.updatedAt)}return l.join(" • ")},ye=(t,c)=>{const i=c.trim().toLowerCase();return i?t.filter(l=>[l.title,l.subtitle||"",...l.keywords].join(" ").toLowerCase().includes(i)):t},ke=t=>{if(!(t instanceof HTMLElement))return!1;const c=t.tagName.toLowerCase();return t.isContentEditable?!0:c==="input"||c==="textarea"||c==="select"},K="__LOTUS_COMMAND_PALETTE_FORCE_OPEN__",Te=()=>{const{t}=U(),{token:c}=X.useToken(),i=typeof document<"u"&&document.body.getAttribute("data-vdi-safe")==="true",{message:l}=Z.useApp(),x=k(e=>e.chats),j=k(e=>e.addChat),v=k(e=>e.lastSelectedPromptId),m=k(e=>e.systemPrompts),I=k(e=>e.executionBySession),[u,p]=a.useState(()=>typeof window>"u"?!1:window[K]?(delete window[K],!0):!1),[T,S]=a.useState(""),[b,f]=a.useState(0),A=a.useRef(null),M=a.useRef(null),C=H(e=>e.open),O=B(e=>e.toggleTheme),E=B(e=>e.themeMode),w=P(e=>e.sidebar.collapsed),N=P(e=>e.setSidebarCollapsed),h=V(e=>e.mode),L=V(e=>e.toggleMode),R=a.useCallback(async()=>{var F,q;const e=m.find(y=>y.id===v),s=(e==null?void 0:e.id)||(m.length>0?((F=m.find(y=>y.id==="general_assistant"))==null?void 0:F.id)||m[0].id:""),d=await j({title:t("chat.sidebar.newSession"),createdAt:Date.now(),messages:[],config:{systemPromptId:s,baseSystemPrompt:(e==null?void 0:e.content)||(m.length>0?((q=m.find(y=>y.id==="general_assistant"))==null?void 0:q.content)||m[0].content:""),lastUsedEnhancedPrompt:null}}),{activeLeafId:o,setLeafSessionId:g,setActiveLeafId:Q}=P.getState();g(o,d),Q(o)},[j,v,m,t]),_=a.useMemo(()=>{const e=ge.filter(s=>!(h==="simple"&&W.has(s.tabKey))).map(s=>({id:s.id,kind:"action",title:t(s.titleKey,s.fallbackTitle),subtitle:t(s.subtitleKey||"commandPalette.groups.settings",s.fallbackSubtitle||"System settings"),keywords:[s.tabKey,s.badge||"","settings","config",...s.keywords||[]],icon:n.jsx(J,{}),badge:s.badge,onSelect:()=>{C("chat",s.tabKey)}}));return[{id:"new-session",kind:"action",title:t("commandPalette.actions.newSession","Create New Session"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["new","create","session","chat","conversation"],icon:n.jsx(ee,{}),badge:t("commandPalette.badges.quickAction","Action"),onSelect:async()=>{await R()}},{id:"toggle-theme",kind:"action",title:E==="dark"?t("commandPalette.actions.switchToLight","Switch to Light Mode"):t("commandPalette.actions.switchToDark","Switch to Dark Mode"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["theme","dark","light","mode","appearance","toggle","color"],icon:n.jsx(te,{}),badge:E==="dark"?"☀️":"🌙",onSelect:()=>{O()}},{id:"toggle-sidebar",kind:"action",title:w?t("commandPalette.actions.showSidebar","Show Sidebar"):t("commandPalette.actions.hideSidebar","Hide Sidebar"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["sidebar","toggle","hide","show","panel","menu"],icon:w?n.jsx(se,{}):n.jsx(ne,{}),badge:"Layout",onSelect:()=>{N(!w)}},{id:"split-pane",kind:"action",title:t("commandPalette.actions.splitPane","Split Pane"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["split","pane","multi","dual","side","layout"],icon:n.jsx(oe,{}),badge:"Layout",onSelect:()=>{const{tree:s,activeLeafId:d,splitLeaf:o}=P.getState();z(s).length<4&&o(d,"vertical")}},...e,{id:"toggle-experience-mode",kind:"action",title:h==="simple"?t("commandPalette.actions.switchToAdvanced","Switch to Advanced Mode"):t("commandPalette.actions.switchToSimple","Switch to Simple Mode"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["mode","simple","advanced","beginner","expert","experience","complexity"],icon:n.jsx(ae,{}),badge:h==="simple"?"Simple":"Advanced",onSelect:()=>{L()}}]},[R,C,O,E,w,N,h,L,t]),D=a.useMemo(()=>x.map(e=>{const s=G(e.id)({executionBySession:I});return{id:`session-${e.id}`,kind:"session",title:e.title,subtitle:fe(e,t("commandPalette.badges.childSession","Child session"),t("commandPalette.badges.rootSession","Session")),keywords:be(e,s),icon:n.jsx(ie,{}),badge:e.pinned?t("commandPalette.badges.pinned","Pinned"):s?t("commandPalette.badges.running","Running"):e.kind==="child"?t("commandPalette.badges.child","Child"):void 0,onSelect:()=>{Y(e.id)}}}),[x,I,t]),$=a.useMemo(()=>[..._,...D],[_,D]),r=a.useMemo(()=>ye($,T).slice(0,40),[$,T]);return a.useEffect(()=>{f(e=>r.length===0?0:Math.min(e,r.length-1))},[r.length]),a.useEffect(()=>{if(!u)return;const e=window.setTimeout(()=>{var s,d;(s=A.current)==null||s.focus(),(d=A.current)==null||d.select()},0);return()=>window.clearTimeout(e)},[u]),a.useEffect(()=>{if(typeof window>"u")return;const e=s=>{if((s.metaKey||s.ctrlKey)&&s.key.toLowerCase()==="k"){s.preventDefault(),p(o=>!o);return}if(u){if(s.key==="Escape"){s.preventDefault(),p(!1);return}if(!(ke(s.target)&&s.key!=="ArrowUp"&&s.key!=="ArrowDown"&&s.key!=="Enter")){if(s.key==="ArrowDown"){s.preventDefault(),f(o=>r.length===0?0:(o+1)%r.length);return}if(s.key==="ArrowUp"){s.preventDefault(),f(o=>r.length===0?0:o===0?r.length-1:o-1);return}if(s.key==="Enter"){const o=r[b];if(!o)return;s.preventDefault(),(async()=>{try{await o.onSelect(),p(!1),S("")}catch(g){console.error("[CommandPalette] action failed",g),l.error(g instanceof Error?g.message:t("commandPalette.errors.actionFailed","Command failed"))}})()}}}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,l,u,b,t]),a.useEffect(()=>{u||(S(""),f(0))},[u]),a.useEffect(()=>{typeof window>"u"||!window[K]||(delete window[K],p(!0))},[]),a.useEffect(()=>{const e=M.current;if(!e)return;const s=e.querySelector(`[data-command-index="${b}"]`);s==null||s.scrollIntoView({block:"nearest"})},[b]),n.jsx(le,{open:u,onCancel:()=>p(!1),footer:null,centered:!0,width:680,destroyOnClose:!0,className:"lotus-command-palette-modal",title:null,closable:!1,styles:{content:{padding:12,borderRadius:c.borderRadiusLG,overflow:"hidden",background:c.colorBgElevated,backdropFilter:i?"none":"blur(18px)",WebkitBackdropFilter:i?"none":"blur(18px)"},body:{padding:0},mask:{backdropFilter:i?"none":"blur(6px)",WebkitBackdropFilter:i?"none":"blur(6px)"}},children:n.jsxs("div",{className:"lotus-command-palette-shell",children:[n.jsxs("div",{className:"lotus-command-palette-search",children:[n.jsx(ce,{style:{color:c.colorTextTertiary,fontSize:16}}),n.jsx(re,{ref:A,value:T,onChange:e=>S(e.target.value),variant:"borderless",placeholder:t("commandPalette.searchPlaceholder","Search sessions, settings, and actions"),"aria-label":t("commandPalette.searchPlaceholder","Search sessions, settings, and actions"),suffix:n.jsx(de.Text,{type:"secondary",style:{fontSize:12},children:"⌘K"})})]}),n.jsxs("div",{className:"lotus-command-palette-hint",children:[n.jsx(me,{}),n.jsx("span",{children:t("commandPalette.navigationHint","Use ↑↓ to navigate, Enter to open, and Esc to close.")})]}),n.jsx("div",{ref:M,className:"lotus-command-palette-list",role:"listbox",children:r.length===0?n.jsxs("div",{className:"lotus-command-palette-empty",children:[n.jsx(ue,{}),n.jsx("span",{children:t("commandPalette.empty","No matching commands")})]}):r.map((e,s)=>{const d=s===b;return n.jsxs("button",{type:"button",className:`lotus-command-palette-item ${d?"is-selected":""}`,"data-command-index":s,onMouseEnter:()=>f(s),onClick:()=>{(async()=>{try{await e.onSelect(),p(!1),S("")}catch(o){console.error("[CommandPalette] action failed",o),l.error(o instanceof Error?o.message:t("commandPalette.errors.actionFailed","Command failed"))}})()},children:[n.jsx("span",{className:"lotus-command-palette-item-icon",children:e.icon}),n.jsxs("span",{className:"lotus-command-palette-item-content",children:[n.jsxs("span",{className:"lotus-command-palette-item-title-row",children:[n.jsx("span",{className:"lotus-command-palette-item-title",children:e.title}),e.badge?n.jsx(pe,{bordered:!1,children:e.badge}):null]}),e.subtitle?n.jsx("span",{className:"lotus-command-palette-item-subtitle",children:e.subtitle}):null]})]},e.id)})})]})})};export{Te as CommandPalette,Te as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./vendor-markdown-DzaXAW9Q.js";import{u as g,a as u}from"./vendor-i18n-BNURlJ23.js";import{u as d,e as j}from"./App-
|
|
1
|
+
import{j as s}from"./vendor-markdown-DzaXAW9Q.js";import{u as g,a as u}from"./vendor-i18n-BNURlJ23.js";import{u as d,e as j}from"./App-BTGbaEEX.js";import{a7 as h,k as i,l as m,H as y,a8 as b,a9 as B,t as _}from"./vendor-antd-DODjfilb.js";import"./vendor-mermaid-De-Yacw-.js";import"./main-mHH04gTP.js";const{useToken:P}=_,k=n=>{const o=n.replace(/\/$/,"").split("/").filter(Boolean);return o.length<=2?n:`~/${o.slice(-2).join("/")}`},E=({sessionId:n})=>{const{t:o}=g(),{token:f}=P(),e=d(j(n)),p=d(t=>t.systemPrompts),r=e==null?void 0:e.config.workspacePath,a=e==null?void 0:e.config.systemPromptId,l=u.useMemo(()=>{if(!a)return null;const t=p.find(x=>x.id===a);return(t==null?void 0:t.name)||a},[a,p]),c=u.useMemo(()=>e!=null&&e.messages?e.messages.filter(t=>t.role==="user"&&"type"in t&&t.type==="file_reference").length:0,[e==null?void 0:e.messages]);return!e||!(r||l||c>0)?null:s.jsx("div",{className:"lotus-context-bar",style:{borderBottomColor:f.colorBorderSecondary,backgroundColor:f.colorBgContainer},children:s.jsxs(h,{align:"center",gap:6,wrap:"wrap",className:"lotus-context-bar__content",children:[r&&s.jsx(i,{title:r,children:s.jsx(m,{className:"lotus-context-bar__tag",icon:s.jsx(y,{}),bordered:!1,children:k(r)})}),c>0&&s.jsx(i,{title:o("chat.contextBar.fileRefsTooltip",{count:c,defaultValue:"{{count}} file reference(s) in this session"}),children:s.jsxs(m,{className:"lotus-context-bar__tag",icon:s.jsx(b,{}),bordered:!1,children:[c," ",o("chat.contextBar.files","files")]})}),l&&s.jsx(i,{title:o("chat.contextBar.promptTooltip",{name:l,defaultValue:"System prompt: {{name}}"}),children:s.jsx(m,{className:"lotus-context-bar__tag",icon:s.jsx(B,{}),bordered:!1,children:l})})]})})};export{E as ContextBar,E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t}from"./vendor-markdown-DzaXAW9Q.js";import{u as b,a as x}from"./vendor-i18n-BNURlJ23.js";import{u as i}from"./App-
|
|
1
|
+
import{j as t}from"./vendor-markdown-DzaXAW9Q.js";import{u as b,a as x}from"./vendor-i18n-BNURlJ23.js";import{u as i}from"./App-BTGbaEEX.js";import{K as w,M as n,E as l,N as T,L as c,l as E,O as L,Q as R,U as k,V as v,W as d}from"./vendor-antd-DODjfilb.js";import"./vendor-mermaid-De-Yacw-.js";import"./main-mHH04gTP.js";const B=()=>{const{t:s}=b(),{message:r}=w.useApp(),f=i(e=>e.systemPrompts),P=i(e=>e.addSystemPrompt),M=i(e=>e.updateSystemPrompt),j=i(e=>e.deleteSystemPrompt),[h,u]=x.useState(!1),[a,p]=x.useState(null),[o]=n.useForm(),g=(e=null)=>{if(e!=null&&e.isDefault){r.warning(s("settings.systemPromptManager.defaultPromptLocked"));return}p(e),o.setFieldsValue(e||{name:"",description:"",content:""}),u(!0)},y=()=>{u(!1),p(null),o.resetFields()},S=async()=>{if(a!=null&&a.isDefault){r.warning(s("settings.systemPromptManager.defaultPromptLocked"));return}try{const e=await o.validateFields();a?(await M({...a,...e}),r.success(s("settings.systemPromptManager.updateSuccess"))):(await P(e),r.success(s("settings.systemPromptManager.addSuccess"))),y()}catch(e){console.error("Failed to save prompt:",e),r.error(e instanceof Error?e.message:s("settings.systemPromptManager.saveError"))}},I=async e=>{try{await j(e),r.success(s("settings.systemPromptManager.deleteSuccess"))}catch(m){console.error("Failed to delete prompt:",m),r.error(m instanceof Error?m.message:s("settings.systemPromptManager.deleteError"))}};return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[t.jsx("h2",{children:s("settings.systemPromptManager.title")}),t.jsx(l,{type:"primary",icon:t.jsx(T,{}),onClick:()=>g(),children:s("settings.systemPromptManager.addButton")})]}),t.jsx(c,{itemLayout:"horizontal",dataSource:f,renderItem:e=>t.jsxs(c.Item,{actions:[e.isDefault?null:t.jsx(l,{type:"text",icon:t.jsx(L,{}),onClick:()=>g(e)}),e.isDefault?null:t.jsx(R,{title:s("settings.systemPromptManager.deleteConfirm"),onConfirm:()=>I(e.id),okText:s("common.yes"),cancelText:s("common.no"),children:t.jsx(l,{type:"text",danger:!0,icon:t.jsx(k,{}),"aria-label":s("common.delete")})})],children:[t.jsx(c.Item.Meta,{title:e.name,description:e.description||e.content.substring(0,200)+(e.content.length>200?"...":"")}),e.isDefault&&t.jsx(E,{children:s("settings.systemPromptManager.defaultTag")})]})}),t.jsx(v,{title:s(a?"settings.systemPromptManager.editTitle":"settings.systemPromptManager.addTitle"),open:h,onOk:S,onCancel:y,width:"60%",forceRender:!0,children:t.jsxs(n,{form:o,layout:"vertical",name:"system_prompt_form",children:[t.jsx(n.Item,{name:"name",label:s("settings.systemPromptManager.nameLabel"),rules:[{required:!0,message:s("settings.systemPromptManager.nameRequired")}],children:t.jsx(d,{})}),t.jsx(n.Item,{name:"description",label:s("settings.systemPromptManager.descriptionLabel"),rules:[{required:!1,message:s("settings.systemPromptManager.descriptionRequired")}],children:t.jsx(d.TextArea,{rows:3})}),t.jsx(n.Item,{name:"content",label:s("settings.systemPromptManager.contentLabel"),rules:[{required:!0,message:s("settings.systemPromptManager.contentRequired")}],children:t.jsx(d.TextArea,{rows:10})})]})})]})};export{B as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var ee=Object.defineProperty;var te=(i,t,s)=>t in i?ee(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var z=(i,t,s)=>te(i,typeof t!="symbol"?t+"":t,s);import{j as e}from"./vendor-markdown-DzaXAW9Q.js";import{u as V,a as o,i as J}from"./vendor-i18n-BNURlJ23.js";import{y as D,v as se}from"./App-DaOPoP5b.js";import{K as Z,t as Y,j as B,V as G,S as j,E as P,an as N,ao as ae,ap as re,aq as K,C as ie,J as O,G as M,L as W,H as C,a7 as _,ar as Q,as as ne,o as ce,y as oe,A as L,W as le,at as de}from"./vendor-antd-DODjfilb.js";import"./main-CuvqMgTQ.js";import"./vendor-mermaid-De-Yacw-.js";const he=({visible:i,onClose:t,onSelect:s})=>{const{t:n}=V(),{message:r}=Z.useApp(),{token:a}=Y.useToken(),{Text:c}=B,[p,w]=o.useState(!1),[l,x]=o.useState(""),[u,I]=o.useState(),[S,k]=o.useState([]),[v,y]=o.useState([]);o.useEffect(()=>{i&&m()},[i]);const m=async d=>{w(!0);try{const g=await D.browseFolder(d);x(g.current_path),I(g.parent_path),k(g.folders)}catch(g){console.error("Failed to load directory:",g),r.error("Unable to read folder")}finally{w(!1)}},f=d=>{y([...v,l]),m(d.path)},E=()=>{u&&(y(v.slice(0,-1)),m(u))},T=()=>{y([]),m()},b=()=>{s(l),t()},R=()=>{if(!l)return[];const d=l.split(/[/\\]/).filter(Boolean);return l.startsWith("/")&&d.unshift("/"),d},A=d=>{const F=R().slice(0,d+1).join("/"),$=(l.startsWith("/"),F);m($)};return e.jsx(G,{title:n("chat.folderBrowser.title"),open:i,onCancel:t,width:700,footer:null,children:e.jsxs(j,{direction:"vertical",size:"middle",style:{width:"100%"},children:[e.jsxs(j,{children:[e.jsx(P,{icon:e.jsx(N,{}),onClick:T,size:"small",children:n("common.home")}),e.jsx(P,{icon:e.jsx(ae,{}),onClick:E,disabled:!u,size:"small",children:n("common.parentDirectory")}),e.jsx(P,{type:"primary",icon:e.jsx(re,{}),onClick:b,size:"small",children:n("chat.folderBrowser.selectCurrent")})]}),e.jsx(K,{children:R().map((d,g)=>e.jsx(K.Item,{children:e.jsx(P,{type:"link",size:"small",onClick:()=>A(g),style:{padding:0},children:d==="/"?e.jsx(N,{}):d})},g))}),e.jsxs(ie,{size:"small",styles:{body:{padding:a.paddingXS}},children:[e.jsx(c,{type:"secondary",style:{fontSize:12},children:n("common.currentPath")})," ",e.jsx(c,{code:!0,children:l})]}),e.jsx(O,{spinning:p,children:S.length===0&&!p?e.jsx(M,{image:M.PRESENTED_IMAGE_SIMPLE,description:e.jsx(c,{type:"secondary",children:n("chat.folderBrowser.emptyFolder")})}):e.jsx(W,{dataSource:S,style:{maxHeight:400,overflowY:"auto"},renderItem:d=>e.jsx(W.Item,{style:{padding:0},children:e.jsx(P,{type:"text",icon:e.jsx(C,{}),onClick:()=>f(d),style:{width:"100%",textAlign:"left",padding:`${a.paddingXS}px ${a.paddingSM}px`},children:d.name})})})}),e.jsx(c,{type:"secondary",style:{fontSize:12},children:n("chat.folderBrowser.tip")})]})})};class pe{constructor(t={}){z(this,"cache",new Map);z(this,"pendingValidations",new Map);z(this,"options");this.options={debounceMs:t.debounceMs??300,cacheTimeoutMs:t.cacheTimeoutMs??5*60*1e3,maxRetries:t.maxRetries??3}}async validateWorkspace(t){if(!t||t.trim().length===0)return{path:"",is_valid:!1,error_message:J.t("chat.workspace.errorEnterPath")};const s=t.trim(),n=this.getCachedResult(s);if(n)return n;const r=this.pendingValidations.get(s);if(r)return r;const a=this.performValidation(s);this.pendingValidations.set(s,a);try{const c=await a;return this.setCachedResult(s,c),c}finally{this.pendingValidations.delete(s)}}validateWorkspaceDebounced(t,s){let n;return n=setTimeout(async()=>{try{const a=await this.validateWorkspace(t);s(a)}catch(a){const c={path:t,is_valid:!1,error_message:a instanceof Error?a.message:J.t("chat.workspace.checkDescription")};s(c)}},this.options.debounceMs),()=>{clearTimeout(n)}}clearCache(){this.cache.clear()}getCachedResult(t){const s=this.cache.get(t);return s?Date.now()-s.timestamp>this.options.cacheTimeoutMs?(this.cache.delete(t),null):s.result:null}setCachedResult(t,s){this.cache.set(t,{result:s,timestamp:Date.now()})}async performValidation(t,s=0){try{return await se.post("workspace/validate",{path:t})}catch(n){if(s<this.options.maxRetries&&this.isRetryableError(n))return await this.delay(Math.pow(2,s)*1e3),this.performValidation(t,s+1);throw n}}isRetryableError(t){return t instanceof Error?t.message.includes("Failed to fetch")||t.message.includes("HTTP error! status: 5"):!1}delay(t){return new Promise(s=>setTimeout(s,t))}async validateMultiplePaths(t){const n=[];for(let r=0;r<t.length;r+=5){const a=t.slice(r,r+5),c=await Promise.all(a.map(p=>this.validateWorkspace(p)));n.push(...c),r+5<t.length&&await this.delay(100)}return n}}const ue=new pe,ge=({value:i="",onChange:t,showRecentWorkspaces:s,showSuggestions:n,onValidationChange:r})=>{const{message:a}=Z.useApp(),[c,p]=o.useState(i),[w,l]=o.useState({isValidating:!1,result:null}),[x,u]=o.useState([]),[I,S]=o.useState(!1),[k,v]=o.useState([]),[y,m]=o.useState(!1),[f,E]=o.useState(!1),T=o.useRef(null),b=o.useRef(null);o.useEffect(()=>{p(i)},[i]),o.useEffect(()=>(s&&R(),n&&A(),()=>{T.current&&T.current.abort(),b.current&&b.current()}),[s,n]);const R=o.useCallback(async()=>{m(!0);try{const h=await D.getRecentWorkspaces();u(h.slice(0,5))}catch(h){console.error("Failed to load recent workspaces:",h),u([])}finally{m(!1)}},[]),A=o.useCallback(async()=>{E(!0);try{const h=await D.getPathSuggestions();v(h.suggestions.slice(0,8))}catch(h){console.error("Failed to load suggestions:",h),v([])}finally{E(!1)}},[]),d=o.useCallback(h=>{p(h),t&&t(h),T.current&&T.current.abort(),b.current&&b.current(),h.trim()?(l({isValidating:!0,result:null}),b.current=ue.validateWorkspaceDebounced(h.trim(),q=>{l({isValidating:!1,result:q}),r&&r(q)})):(l({isValidating:!1,result:null}),r&&r(null))},[t,r]),g=o.useCallback(()=>{S(!0)},[]),F=o.useCallback(h=>{d(h),a.success("Folder selected successfully")},[d]),$=o.useCallback(h=>{d(h)},[d]);return{path:c,validationStatus:w,recentWorkspaces:x,suggestions:k,isLoadingRecent:y,isLoadingSuggestions:f,folderBrowserVisible:I,setFolderBrowserVisible:S,handlePathChange:d,handleBrowseClick:g,handleFolderSelect:F,handleWorkspaceSelect:$}},{Text:H}=B,me=({show:i,isLoading:t,recentWorkspaces:s,onSelect:n,token:r})=>{const{t:a}=V();return i?e.jsxs(_,{vertical:!0,gap:r.marginXS,style:{marginTop:r.marginMD},children:[e.jsxs(j,{style:{paddingInline:r.paddingSM},children:[e.jsx(Q,{}),e.jsx(H,{strong:!0,children:a("chat.workspace.recentTitle")})]}),t?e.jsx(_,{justify:"center",style:{padding:r.paddingSM},children:e.jsx(O,{size:"small"})}):s.length===0?e.jsx(M,{description:a("chat.workspace.noRecentWorkspaces"),image:M.PRESENTED_IMAGE_SIMPLE,style:{padding:r.paddingSM}}):e.jsx(W,{size:"small",dataSource:s,style:{paddingInline:r.paddingSM},renderItem:c=>e.jsx(W.Item,{style:{padding:0},children:e.jsx(P,{type:"text",onClick:()=>n(c.path),style:{width:"100%",textAlign:"left",padding:`${r.paddingXS}px 0`,height:"auto"},children:e.jsxs(_,{justify:"space-between",align:"center",style:{width:"100%"},children:[e.jsxs(j,{children:[e.jsx(C,{style:{color:r.colorWarning}}),e.jsx(H,{strong:!0,children:c.workspace_name||c.path.split("/").pop()||a("chat.workspace.defaultWorkspaceName")})]}),e.jsx(H,{type:"secondary",ellipsis:{tooltip:c.path},style:{fontSize:12,maxWidth:"55%",textAlign:"right"},children:c.path})]})})})})]}):null},{Text:X}=B,xe=(i,t)=>{switch(i.suggestion_type){case"home":return e.jsx(N,{style:{color:t.colorPrimary}});case"documents":case"desktop":case"downloads":return e.jsx(C,{style:{color:t.colorSuccess}});case"recent":return e.jsx(Q,{style:{color:t.colorWarning}});default:return e.jsx(C,{})}},fe=({show:i,isLoading:t,suggestions:s,onSelect:n,token:r})=>{const{t:a}=V();return i?e.jsxs(_,{vertical:!0,gap:r.marginXS,style:{marginTop:r.marginMD},children:[e.jsxs(j,{style:{paddingInline:r.paddingSM},children:[e.jsx(C,{}),e.jsx(X,{strong:!0,children:a("chat.workspace.suggestedTitle")})]}),t?e.jsx(_,{justify:"center",style:{padding:r.paddingSM},children:e.jsx(O,{size:"small"})}):s.length===0?e.jsx(M,{description:a("chat.workspace.noSuggestions"),image:M.PRESENTED_IMAGE_SIMPLE,style:{padding:r.paddingSM}}):e.jsx(W,{size:"small",dataSource:s,style:{paddingInline:r.paddingSM},renderItem:c=>e.jsx(W.Item,{style:{padding:0},children:e.jsx(P,{type:"text",onClick:()=>n(c.path),style:{width:"100%",textAlign:"left",padding:`${r.paddingXS}px 0`,height:"auto"},children:e.jsxs(_,{justify:"space-between",align:"center",style:{width:"100%"},children:[e.jsxs(j,{children:[xe(c,r),e.jsx(X,{strong:!0,children:c.name})]}),e.jsx(X,{type:"secondary",ellipsis:{tooltip:c.path},style:{fontSize:12,maxWidth:"55%",textAlign:"right"},children:c.path})]})})})})]}):null},ye=({isValidating:i,result:t,token:s})=>i?e.jsx(ne,{style:{color:s.colorPrimary}}):t?t.is_valid?e.jsx(ce,{style:{color:s.colorSuccess}}):e.jsx(oe,{style:{color:s.colorError}}):null,{Text:U}=B,je=({result:i,token:t})=>{const{t:s}=V();return i?e.jsx("div",{style:{marginTop:t.marginXS},children:i.is_valid?e.jsx(L,{type:"success",message:e.jsxs(j,{children:[e.jsx("span",{children:s("chat.workspace.validWorkspace")}),i.workspace_name&&e.jsxs(U,{type:"secondary",children:["(",i.workspace_name,")"]}),i.file_count!==void 0&&e.jsx(U,{type:"secondary",children:s("chat.workspace.fileCount",{count:i.file_count})})]}),showIcon:!0}):e.jsx(L,{type:"error",message:i.error_message||s("validation.invalidPath"),showIcon:!0})}):null},{Text:we}=B,Se=({value:i="",onChange:t,placeholder:s,disabled:n=!1,allowBrowse:r=!0,showRecentWorkspaces:a=!0,showSuggestions:c=!0,onValidationChange:p,className:w,style:l})=>{const{t:x}=V(),{token:u}=Y.useToken(),I=s??x("chat.workspace.placeholder"),{path:S,validationStatus:k,recentWorkspaces:v,suggestions:y,isLoadingRecent:m,isLoadingSuggestions:f,folderBrowserVisible:E,setFolderBrowserVisible:T,handlePathChange:b,handleBrowseClick:R,handleFolderSelect:A,handleWorkspaceSelect:d}=ge({value:i,onChange:t,showRecentWorkspaces:a,showSuggestions:c,onValidationChange:p});return e.jsxs("div",{className:w,style:l,children:[e.jsx(le,{value:S,onChange:g=>b(g.target.value),placeholder:I,disabled:n,size:"middle",style:{width:"100%"},suffix:e.jsx(ye,{isValidating:k.isValidating,result:k.result,token:u}),addonBefore:e.jsxs(j,{children:[e.jsx(C,{}),e.jsx(we,{children:x("chat.workspace.label")})]}),addonAfter:r?e.jsx(P,{"aria-label":x("chat.workspace.browseFolder"),title:x("chat.workspace.browseFolder"),icon:e.jsx(C,{}),onClick:R,disabled:n,type:"text",size:"middle",style:{display:"inline-flex",alignItems:"center"}}):void 0}),e.jsx(je,{result:k.result,token:u}),(a||c)&&e.jsxs(e.Fragment,{children:[e.jsx(de,{style:{margin:"16px 0 12px 0"}}),e.jsx(me,{show:a,isLoading:m,recentWorkspaces:v,onSelect:d,token:u}),e.jsx(fe,{show:c,isLoading:f,suggestions:y,onSelect:d,token:u})]}),e.jsx(he,{visible:E,onClose:()=>T(!1),onSelect:A})]})},{Title:ke}=B,Re=({open:i,initialPath:t="",loading:s=!1,onSubmit:n,onCancel:r})=>{const{t:a}=V(),{message:c}=Z.useApp(),[p,w]=o.useState(t),[l,x]=o.useState(null),[u,I]=o.useState(!1);o.useEffect(()=>{i&&(w(t),x(null))},[i,t]);const S=f=>{w(f)},k=f=>{x(f)},v=async()=>{if(!p.trim()){c.error(a("chat.workspace.errorEnterPath"));return}l&&!l.is_valid?G.confirm({title:a("chat.workspace.invalidTitle"),content:e.jsxs("div",{children:[e.jsx("p",{children:a("chat.workspace.issuesDetected")}),e.jsx("p",{children:l.error_message||a("chat.workspace.invalidTitle")}),e.jsx("p",{children:a("chat.workspace.confirmSaveInvalid")})]}),okText:a("common.saveAnyway"),cancelText:a("common.cancel"),onOk:()=>y()}):y()},y=async()=>{I(!0);try{l!=null&&l.is_valid&&await D.addRecentWorkspace(p.trim(),{workspace_name:l.workspace_name}),n(p.trim())}catch(f){console.error("Failed to save workspace path:",f),c.error(a("chat.workspace.errorSaveFailed"))}finally{I(!1)}},m=!p.trim()||s||u;return e.jsx(G,{open:i,title:e.jsx(j,{children:e.jsx(ke,{level:4,style:{margin:0},children:a("chat.workspace.modalTitle")})}),okText:a("common.save"),cancelText:a("common.cancel"),onOk:v,onCancel:r,okButtonProps:{disabled:m,loading:u||s},width:600,destroyOnClose:!0,children:e.jsxs(j,{direction:"vertical",size:"middle",style:{width:"100%"},children:[e.jsx(L,{message:a("chat.workspace.descriptionTitle"),description:e.jsxs("div",{children:[e.jsx("p",{children:a("chat.workspace.descriptionP1")}),e.jsx("p",{children:a("chat.workspace.descriptionP2")})]}),type:"info",showIcon:!0}),e.jsx(Se,{value:p,onChange:S,onValidationChange:k,placeholder:a("chat.workspace.placeholder"),disabled:u,allowBrowse:!0,showRecentWorkspaces:!0,showSuggestions:!0}),l&&!l.is_valid&&e.jsx(L,{message:a("chat.workspace.checkTitle"),description:l.error_message||a("chat.workspace.checkDescription"),type:"warning",showIcon:!0})]})})};export{Re as default};
|
|
1
|
+
var ee=Object.defineProperty;var te=(i,t,s)=>t in i?ee(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var z=(i,t,s)=>te(i,typeof t!="symbol"?t+"":t,s);import{j as e}from"./vendor-markdown-DzaXAW9Q.js";import{u as V,a as o,i as J}from"./vendor-i18n-BNURlJ23.js";import{y as D,v as se}from"./App-BTGbaEEX.js";import{K as Z,t as Y,j as B,V as G,S as j,E as P,an as N,ao as ae,ap as re,aq as K,C as ie,J as O,G as M,L as W,H as C,a7 as _,ar as Q,as as ne,o as ce,y as oe,A as L,W as le,at as de}from"./vendor-antd-DODjfilb.js";import"./main-mHH04gTP.js";import"./vendor-mermaid-De-Yacw-.js";const he=({visible:i,onClose:t,onSelect:s})=>{const{t:n}=V(),{message:r}=Z.useApp(),{token:a}=Y.useToken(),{Text:c}=B,[p,w]=o.useState(!1),[l,x]=o.useState(""),[u,I]=o.useState(),[S,k]=o.useState([]),[v,y]=o.useState([]);o.useEffect(()=>{i&&m()},[i]);const m=async d=>{w(!0);try{const g=await D.browseFolder(d);x(g.current_path),I(g.parent_path),k(g.folders)}catch(g){console.error("Failed to load directory:",g),r.error("Unable to read folder")}finally{w(!1)}},f=d=>{y([...v,l]),m(d.path)},E=()=>{u&&(y(v.slice(0,-1)),m(u))},T=()=>{y([]),m()},b=()=>{s(l),t()},R=()=>{if(!l)return[];const d=l.split(/[/\\]/).filter(Boolean);return l.startsWith("/")&&d.unshift("/"),d},A=d=>{const F=R().slice(0,d+1).join("/"),$=(l.startsWith("/"),F);m($)};return e.jsx(G,{title:n("chat.folderBrowser.title"),open:i,onCancel:t,width:700,footer:null,children:e.jsxs(j,{direction:"vertical",size:"middle",style:{width:"100%"},children:[e.jsxs(j,{children:[e.jsx(P,{icon:e.jsx(N,{}),onClick:T,size:"small",children:n("common.home")}),e.jsx(P,{icon:e.jsx(ae,{}),onClick:E,disabled:!u,size:"small",children:n("common.parentDirectory")}),e.jsx(P,{type:"primary",icon:e.jsx(re,{}),onClick:b,size:"small",children:n("chat.folderBrowser.selectCurrent")})]}),e.jsx(K,{children:R().map((d,g)=>e.jsx(K.Item,{children:e.jsx(P,{type:"link",size:"small",onClick:()=>A(g),style:{padding:0},children:d==="/"?e.jsx(N,{}):d})},g))}),e.jsxs(ie,{size:"small",styles:{body:{padding:a.paddingXS}},children:[e.jsx(c,{type:"secondary",style:{fontSize:12},children:n("common.currentPath")})," ",e.jsx(c,{code:!0,children:l})]}),e.jsx(O,{spinning:p,children:S.length===0&&!p?e.jsx(M,{image:M.PRESENTED_IMAGE_SIMPLE,description:e.jsx(c,{type:"secondary",children:n("chat.folderBrowser.emptyFolder")})}):e.jsx(W,{dataSource:S,style:{maxHeight:400,overflowY:"auto"},renderItem:d=>e.jsx(W.Item,{style:{padding:0},children:e.jsx(P,{type:"text",icon:e.jsx(C,{}),onClick:()=>f(d),style:{width:"100%",textAlign:"left",padding:`${a.paddingXS}px ${a.paddingSM}px`},children:d.name})})})}),e.jsx(c,{type:"secondary",style:{fontSize:12},children:n("chat.folderBrowser.tip")})]})})};class pe{constructor(t={}){z(this,"cache",new Map);z(this,"pendingValidations",new Map);z(this,"options");this.options={debounceMs:t.debounceMs??300,cacheTimeoutMs:t.cacheTimeoutMs??5*60*1e3,maxRetries:t.maxRetries??3}}async validateWorkspace(t){if(!t||t.trim().length===0)return{path:"",is_valid:!1,error_message:J.t("chat.workspace.errorEnterPath")};const s=t.trim(),n=this.getCachedResult(s);if(n)return n;const r=this.pendingValidations.get(s);if(r)return r;const a=this.performValidation(s);this.pendingValidations.set(s,a);try{const c=await a;return this.setCachedResult(s,c),c}finally{this.pendingValidations.delete(s)}}validateWorkspaceDebounced(t,s){let n;return n=setTimeout(async()=>{try{const a=await this.validateWorkspace(t);s(a)}catch(a){const c={path:t,is_valid:!1,error_message:a instanceof Error?a.message:J.t("chat.workspace.checkDescription")};s(c)}},this.options.debounceMs),()=>{clearTimeout(n)}}clearCache(){this.cache.clear()}getCachedResult(t){const s=this.cache.get(t);return s?Date.now()-s.timestamp>this.options.cacheTimeoutMs?(this.cache.delete(t),null):s.result:null}setCachedResult(t,s){this.cache.set(t,{result:s,timestamp:Date.now()})}async performValidation(t,s=0){try{return await se.post("workspace/validate",{path:t})}catch(n){if(s<this.options.maxRetries&&this.isRetryableError(n))return await this.delay(Math.pow(2,s)*1e3),this.performValidation(t,s+1);throw n}}isRetryableError(t){return t instanceof Error?t.message.includes("Failed to fetch")||t.message.includes("HTTP error! status: 5"):!1}delay(t){return new Promise(s=>setTimeout(s,t))}async validateMultiplePaths(t){const n=[];for(let r=0;r<t.length;r+=5){const a=t.slice(r,r+5),c=await Promise.all(a.map(p=>this.validateWorkspace(p)));n.push(...c),r+5<t.length&&await this.delay(100)}return n}}const ue=new pe,ge=({value:i="",onChange:t,showRecentWorkspaces:s,showSuggestions:n,onValidationChange:r})=>{const{message:a}=Z.useApp(),[c,p]=o.useState(i),[w,l]=o.useState({isValidating:!1,result:null}),[x,u]=o.useState([]),[I,S]=o.useState(!1),[k,v]=o.useState([]),[y,m]=o.useState(!1),[f,E]=o.useState(!1),T=o.useRef(null),b=o.useRef(null);o.useEffect(()=>{p(i)},[i]),o.useEffect(()=>(s&&R(),n&&A(),()=>{T.current&&T.current.abort(),b.current&&b.current()}),[s,n]);const R=o.useCallback(async()=>{m(!0);try{const h=await D.getRecentWorkspaces();u(h.slice(0,5))}catch(h){console.error("Failed to load recent workspaces:",h),u([])}finally{m(!1)}},[]),A=o.useCallback(async()=>{E(!0);try{const h=await D.getPathSuggestions();v(h.suggestions.slice(0,8))}catch(h){console.error("Failed to load suggestions:",h),v([])}finally{E(!1)}},[]),d=o.useCallback(h=>{p(h),t&&t(h),T.current&&T.current.abort(),b.current&&b.current(),h.trim()?(l({isValidating:!0,result:null}),b.current=ue.validateWorkspaceDebounced(h.trim(),q=>{l({isValidating:!1,result:q}),r&&r(q)})):(l({isValidating:!1,result:null}),r&&r(null))},[t,r]),g=o.useCallback(()=>{S(!0)},[]),F=o.useCallback(h=>{d(h),a.success("Folder selected successfully")},[d]),$=o.useCallback(h=>{d(h)},[d]);return{path:c,validationStatus:w,recentWorkspaces:x,suggestions:k,isLoadingRecent:y,isLoadingSuggestions:f,folderBrowserVisible:I,setFolderBrowserVisible:S,handlePathChange:d,handleBrowseClick:g,handleFolderSelect:F,handleWorkspaceSelect:$}},{Text:H}=B,me=({show:i,isLoading:t,recentWorkspaces:s,onSelect:n,token:r})=>{const{t:a}=V();return i?e.jsxs(_,{vertical:!0,gap:r.marginXS,style:{marginTop:r.marginMD},children:[e.jsxs(j,{style:{paddingInline:r.paddingSM},children:[e.jsx(Q,{}),e.jsx(H,{strong:!0,children:a("chat.workspace.recentTitle")})]}),t?e.jsx(_,{justify:"center",style:{padding:r.paddingSM},children:e.jsx(O,{size:"small"})}):s.length===0?e.jsx(M,{description:a("chat.workspace.noRecentWorkspaces"),image:M.PRESENTED_IMAGE_SIMPLE,style:{padding:r.paddingSM}}):e.jsx(W,{size:"small",dataSource:s,style:{paddingInline:r.paddingSM},renderItem:c=>e.jsx(W.Item,{style:{padding:0},children:e.jsx(P,{type:"text",onClick:()=>n(c.path),style:{width:"100%",textAlign:"left",padding:`${r.paddingXS}px 0`,height:"auto"},children:e.jsxs(_,{justify:"space-between",align:"center",style:{width:"100%"},children:[e.jsxs(j,{children:[e.jsx(C,{style:{color:r.colorWarning}}),e.jsx(H,{strong:!0,children:c.workspace_name||c.path.split("/").pop()||a("chat.workspace.defaultWorkspaceName")})]}),e.jsx(H,{type:"secondary",ellipsis:{tooltip:c.path},style:{fontSize:12,maxWidth:"55%",textAlign:"right"},children:c.path})]})})})})]}):null},{Text:X}=B,xe=(i,t)=>{switch(i.suggestion_type){case"home":return e.jsx(N,{style:{color:t.colorPrimary}});case"documents":case"desktop":case"downloads":return e.jsx(C,{style:{color:t.colorSuccess}});case"recent":return e.jsx(Q,{style:{color:t.colorWarning}});default:return e.jsx(C,{})}},fe=({show:i,isLoading:t,suggestions:s,onSelect:n,token:r})=>{const{t:a}=V();return i?e.jsxs(_,{vertical:!0,gap:r.marginXS,style:{marginTop:r.marginMD},children:[e.jsxs(j,{style:{paddingInline:r.paddingSM},children:[e.jsx(C,{}),e.jsx(X,{strong:!0,children:a("chat.workspace.suggestedTitle")})]}),t?e.jsx(_,{justify:"center",style:{padding:r.paddingSM},children:e.jsx(O,{size:"small"})}):s.length===0?e.jsx(M,{description:a("chat.workspace.noSuggestions"),image:M.PRESENTED_IMAGE_SIMPLE,style:{padding:r.paddingSM}}):e.jsx(W,{size:"small",dataSource:s,style:{paddingInline:r.paddingSM},renderItem:c=>e.jsx(W.Item,{style:{padding:0},children:e.jsx(P,{type:"text",onClick:()=>n(c.path),style:{width:"100%",textAlign:"left",padding:`${r.paddingXS}px 0`,height:"auto"},children:e.jsxs(_,{justify:"space-between",align:"center",style:{width:"100%"},children:[e.jsxs(j,{children:[xe(c,r),e.jsx(X,{strong:!0,children:c.name})]}),e.jsx(X,{type:"secondary",ellipsis:{tooltip:c.path},style:{fontSize:12,maxWidth:"55%",textAlign:"right"},children:c.path})]})})})})]}):null},ye=({isValidating:i,result:t,token:s})=>i?e.jsx(ne,{style:{color:s.colorPrimary}}):t?t.is_valid?e.jsx(ce,{style:{color:s.colorSuccess}}):e.jsx(oe,{style:{color:s.colorError}}):null,{Text:U}=B,je=({result:i,token:t})=>{const{t:s}=V();return i?e.jsx("div",{style:{marginTop:t.marginXS},children:i.is_valid?e.jsx(L,{type:"success",message:e.jsxs(j,{children:[e.jsx("span",{children:s("chat.workspace.validWorkspace")}),i.workspace_name&&e.jsxs(U,{type:"secondary",children:["(",i.workspace_name,")"]}),i.file_count!==void 0&&e.jsx(U,{type:"secondary",children:s("chat.workspace.fileCount",{count:i.file_count})})]}),showIcon:!0}):e.jsx(L,{type:"error",message:i.error_message||s("validation.invalidPath"),showIcon:!0})}):null},{Text:we}=B,Se=({value:i="",onChange:t,placeholder:s,disabled:n=!1,allowBrowse:r=!0,showRecentWorkspaces:a=!0,showSuggestions:c=!0,onValidationChange:p,className:w,style:l})=>{const{t:x}=V(),{token:u}=Y.useToken(),I=s??x("chat.workspace.placeholder"),{path:S,validationStatus:k,recentWorkspaces:v,suggestions:y,isLoadingRecent:m,isLoadingSuggestions:f,folderBrowserVisible:E,setFolderBrowserVisible:T,handlePathChange:b,handleBrowseClick:R,handleFolderSelect:A,handleWorkspaceSelect:d}=ge({value:i,onChange:t,showRecentWorkspaces:a,showSuggestions:c,onValidationChange:p});return e.jsxs("div",{className:w,style:l,children:[e.jsx(le,{value:S,onChange:g=>b(g.target.value),placeholder:I,disabled:n,size:"middle",style:{width:"100%"},suffix:e.jsx(ye,{isValidating:k.isValidating,result:k.result,token:u}),addonBefore:e.jsxs(j,{children:[e.jsx(C,{}),e.jsx(we,{children:x("chat.workspace.label")})]}),addonAfter:r?e.jsx(P,{"aria-label":x("chat.workspace.browseFolder"),title:x("chat.workspace.browseFolder"),icon:e.jsx(C,{}),onClick:R,disabled:n,type:"text",size:"middle",style:{display:"inline-flex",alignItems:"center"}}):void 0}),e.jsx(je,{result:k.result,token:u}),(a||c)&&e.jsxs(e.Fragment,{children:[e.jsx(de,{style:{margin:"16px 0 12px 0"}}),e.jsx(me,{show:a,isLoading:m,recentWorkspaces:v,onSelect:d,token:u}),e.jsx(fe,{show:c,isLoading:f,suggestions:y,onSelect:d,token:u})]}),e.jsx(he,{visible:E,onClose:()=>T(!1),onSelect:A})]})},{Title:ke}=B,Re=({open:i,initialPath:t="",loading:s=!1,onSubmit:n,onCancel:r})=>{const{t:a}=V(),{message:c}=Z.useApp(),[p,w]=o.useState(t),[l,x]=o.useState(null),[u,I]=o.useState(!1);o.useEffect(()=>{i&&(w(t),x(null))},[i,t]);const S=f=>{w(f)},k=f=>{x(f)},v=async()=>{if(!p.trim()){c.error(a("chat.workspace.errorEnterPath"));return}l&&!l.is_valid?G.confirm({title:a("chat.workspace.invalidTitle"),content:e.jsxs("div",{children:[e.jsx("p",{children:a("chat.workspace.issuesDetected")}),e.jsx("p",{children:l.error_message||a("chat.workspace.invalidTitle")}),e.jsx("p",{children:a("chat.workspace.confirmSaveInvalid")})]}),okText:a("common.saveAnyway"),cancelText:a("common.cancel"),onOk:()=>y()}):y()},y=async()=>{I(!0);try{l!=null&&l.is_valid&&await D.addRecentWorkspace(p.trim(),{workspace_name:l.workspace_name}),n(p.trim())}catch(f){console.error("Failed to save workspace path:",f),c.error(a("chat.workspace.errorSaveFailed"))}finally{I(!1)}},m=!p.trim()||s||u;return e.jsx(G,{open:i,title:e.jsx(j,{children:e.jsx(ke,{level:4,style:{margin:0},children:a("chat.workspace.modalTitle")})}),okText:a("common.save"),cancelText:a("common.cancel"),onOk:v,onCancel:r,okButtonProps:{disabled:m,loading:u||s},width:600,destroyOnClose:!0,children:e.jsxs(j,{direction:"vertical",size:"middle",style:{width:"100%"},children:[e.jsx(L,{message:a("chat.workspace.descriptionTitle"),description:e.jsxs("div",{children:[e.jsx("p",{children:a("chat.workspace.descriptionP1")}),e.jsx("p",{children:a("chat.workspace.descriptionP2")})]}),type:"info",showIcon:!0}),e.jsx(Se,{value:p,onChange:S,onValidationChange:k,placeholder:a("chat.workspace.placeholder"),disabled:u,allowBrowse:!0,showRecentWorkspaces:!0,showSuggestions:!0}),l&&!l.is_valid&&e.jsx(L,{message:a("chat.workspace.checkTitle"),description:l.error_message||a("chat.workspace.checkDescription"),type:"warning",showIcon:!0})]})})};export{Re as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as a}from"./vendor-markdown-DzaXAW9Q.js";import{m as $,n as v,p as B}from"./App-
|
|
1
|
+
import{j as a}from"./vendor-markdown-DzaXAW9Q.js";import{m as $,n as v,p as B}from"./App-BTGbaEEX.js";import{a as l,u as E}from"./vendor-i18n-BNURlJ23.js";import{J as T,t as M,l as L,af as D,a6 as K,H as F}from"./vendor-antd-DODjfilb.js";import"./vendor-mermaid-De-Yacw-.js";import"./main-mHH04gTP.js";const z=({visible:p,searchText:k,onSelect:j,onCancel:f,onAutoComplete:g})=>{const[o,i]=l.useState([]),[c,R]=l.useState([]),[d,u]=l.useState(0),[N,I]=l.useState(!1),S=l.useRef(null),h=l.useRef(null);l.useEffect(()=>{if(!p)return;const s=$.getInstance();(async()=>{I(!0);try{const r=await s.listCommands();v("[CommandSelector]","[CommandSelector] Fetched commands:",r),i(r),u(0)}catch(r){console.error("[CommandSelector] Failed to fetch commands:",r),i([])}finally{I(!1)}})()},[p]),l.useEffect(()=>{const s=o.filter(e=>{var x,y,b,C,w;const r=k.toLowerCase(),n=(e.displayName??"").toLowerCase();return e.name.toLowerCase().includes(r)||n.includes(r)||e.description.toLowerCase().includes(r)||e.type==="mcp"&&[(x=e.metadata)==null?void 0:x.serverId,(y=e.metadata)==null?void 0:y.serverName,(b=e.metadata)==null?void 0:b.originalName].filter(m=>typeof m=="string").some(m=>m.toLowerCase().includes(r))||(((C=e.category)==null?void 0:C.toLowerCase().includes(r))??!1)||(((w=e.tags)==null?void 0:w.some(m=>m.toLowerCase().includes(r)))??!1)});R(s),u(0)},[o,k]),l.useEffect(()=>{if(!h.current||!S.current)return;const s=S.current,e=h.current,r=s.getBoundingClientRect(),n=e.getBoundingClientRect();n.top<r.top?e.scrollIntoView({block:"start",behavior:"smooth"}):n.bottom>r.bottom&&e.scrollIntoView({block:"end",behavior:"smooth"})},[d,c]);const t=l.useCallback(async s=>{try{j({name:s.name,type:s.type,id:s.id})}catch(e){console.error(`[CommandSelector] Failed to select command '${s.name}':`,e)}},[j]);return l.useEffect(()=>{const s=e=>{if(p)switch(e.key){case"ArrowDown":case"n":if(e.key==="n"&&!e.ctrlKey)break;e.preventDefault(),e.stopPropagation(),u(r=>r<c.length-1?r+1:0);break;case"ArrowUp":case"p":if(e.key==="p"&&!e.ctrlKey)break;e.preventDefault(),e.stopPropagation(),u(r=>r>0?r-1:c.length-1);break;case"Enter":e.preventDefault(),e.stopPropagation(),c[d]&&t(c[d]);break;case" ":case"Tab":e.preventDefault(),e.stopPropagation(),c[d]&&g&&g(c[d].name);break;case"Escape":e.preventDefault(),e.stopPropagation(),f();break}};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[p,c,d,f,g,t]),{containerRef:S,selectedItemRef:h,filteredCommands:c,selectedIndex:d,setSelectedIndex:u,isLoading:N,handleCommandSelect:t}},{useToken:X}=M,P={workflow:{color:"blue",icon:a.jsx(F,{}),labelKey:"chat.commandSelector.types.workflow"},skill:{color:"green",icon:a.jsx(K,{}),labelKey:"chat.commandSelector.types.skill"},mcp:{color:"purple",icon:a.jsx(D,{}),labelKey:"chat.commandSelector.types.mcp"}},Q=({visible:p,onSelect:k,onCancel:j,searchText:f,onAutoComplete:g})=>{const{token:o}=X(),{t:i}=E(),{containerRef:c,selectedItemRef:R,filteredCommands:d,selectedIndex:u,setSelectedIndex:N,isLoading:I,handleCommandSelect:S}=z({visible:p,searchText:f,onSelect:k,onCancel:j,onAutoComplete:g});if(!p)return null;if(I)return a.jsxs("div",{style:{position:"absolute",bottom:"100%",left:0,right:0,background:o.colorBgContainer,border:`1px solid ${o.colorBorderSecondary}`,borderRadius:o.borderRadiusSM,boxShadow:o.boxShadowSecondary,padding:`${o.paddingSM}px ${o.paddingMD}px`,zIndex:1e3,marginBottom:o.marginXS,textAlign:"center"},children:[a.jsx(T,{size:"small"})," ",i("chat.commandSelector.loading")]});if(d.length===0)return a.jsx("div",{style:{position:"absolute",bottom:"100%",left:0,right:0,background:o.colorBgContainer,border:`1px solid ${o.colorBorderSecondary}`,borderRadius:o.borderRadiusSM,boxShadow:o.boxShadowSecondary,padding:`${o.paddingSM}px ${o.paddingMD}px`,zIndex:1e3,marginBottom:o.marginXS,textAlign:"center",color:o.colorTextSecondary},children:f?i("chat.commandSelector.emptyWithSearch",{search:f}):i("chat.commandSelector.empty")});const h=(t,s)=>{var b,C,w;const e=P[t.type],r=s===u,n=t.type==="mcp"?B(t.name):null,x=t.type==="mcp"?((b=t.metadata)==null?void 0:b.originalName)||(n==null?void 0:n.toolName)||t.displayName||t.name:null,y=t.type==="mcp"&&(((C=t.metadata)==null?void 0:C.serverName)||((w=t.metadata)==null?void 0:w.serverId)||(n==null?void 0:n.serverId))||null;return a.jsxs("div",{ref:r?R:null,className:`command-selector-item ${r?"selected":""}`,onClick:()=>S(t),onMouseEnter:()=>N(s),children:[a.jsxs("div",{className:"command-selector-item-header",children:[a.jsxs("div",{className:"command-selector-item-name",style:{color:o.colorPrimary},children:["/",t.type==="mcp"&&x?x:t.name]}),a.jsxs("div",{style:{display:"flex",gap:o.marginXS},children:[t.type==="mcp"&&y&&a.jsx(L,{color:"processing",children:y}),a.jsxs(L,{color:e.color,children:[e.icon," ",i(e.labelKey)]})]})]}),a.jsx("div",{className:"command-selector-item-description",style:{color:o.colorTextSecondary},children:t.description}),t.type==="mcp"&&y&&a.jsxs("div",{className:"command-selector-item-category",style:{color:o.colorTextTertiary},children:[i("common.server")," ",y]}),t.category&&a.jsxs("div",{className:"command-selector-item-category",style:{color:o.colorTextTertiary},children:[i("common.category")," ",t.category]}),t.tags&&t.tags.length>0&&a.jsx("div",{className:"command-selector-item-tags",children:t.tags.slice(0,3).map(m=>a.jsx(L,{children:m},m))})]},t.id)};return a.jsxs("div",{ref:c,className:"command-selector-container",style:{background:o.colorBgContainer,border:`1px solid ${o.colorBorderSecondary}`,borderRadius:o.borderRadiusSM,boxShadow:o.boxShadowSecondary},children:[a.jsx("div",{style:{padding:`${o.paddingXXS}px ${o.paddingSM}px`,borderBottom:`1px solid ${o.colorBorderSecondary}`,background:o.colorFillQuaternary,fontSize:o.fontSizeSM,color:o.colorTextTertiary},children:i("chat.commandSelector.navigationHint")}),d.map((t,s)=>h(t,s))]})};export{Q as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as r}from"./vendor-markdown-DzaXAW9Q.js";import{R as pe,u as he,a as s}from"./vendor-i18n-BNURlJ23.js";import{u as Y,f as ye,h as qe,i as B,r as ge,j as ve,s as xe,k as Z,l as L,C as H}from"./App-
|
|
1
|
+
import{j as r}from"./vendor-markdown-DzaXAW9Q.js";import{R as pe,u as he,a as s}from"./vendor-i18n-BNURlJ23.js";import{u as Y,f as ye,h as qe,i as B,r as ge,j as ve,s as xe,k as Z,l as L,C as H}from"./App-BTGbaEEX.js";import{K as Ee,j as we,E as Q,v as Ce,ad as Se,ae as F,S as ee,O as je,t as Pe}from"./vendor-antd-DODjfilb.js";import"./vendor-mermaid-De-Yacw-.js";import"./main-mHH04gTP.js";const Re="_questionCard_15meh_1",Te="_questionHeader_15meh_8",ke="_headerLeft_15meh_27",De="_questionIcon_15meh_35",be="_questionText_15meh_40",Ne="_collapseBtn_15meh_52",Be="_questionBody_15meh_57",Le="_optionsGroup_15meh_61",He="_optionItem_15meh_65",Fe="_customHint_15meh_81",Ie="_questionFooter_15meh_93",a={questionCard:Re,questionHeader:Te,headerLeft:ke,questionIcon:De,questionText:be,collapseBtn:Ne,questionBody:Be,optionsGroup:Le,optionItem:He,customHint:Fe,questionFooter:Ie},{Text:j}=we,{useToken:Oe}=Pe,ze=n=>{const f=(n||"").replace(/\\r\\n/g,`
|
|
2
2
|
`).replace(/\\n/g,`
|
|
3
3
|
`).replace(/\r\n?/g,`
|
|
4
4
|
`).trim();return f?f.includes(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,M as D,r as E,h as F}from"./vendor-markdown-DzaXAW9Q.js";import{u as I,a as p}from"./vendor-i18n-BNURlJ23.js";import{S as y,E as v,C as H,j as T,L as X,ae as A,l as j,ag as O,ah as Y,ai as q,aj as K,V,G as J,m as N,t as Q}from"./vendor-antd-DODjfilb.js";import{q as U,u as z,t as W}from"./App-
|
|
1
|
+
import{j as t,M as D,r as E,h as F}from"./vendor-markdown-DzaXAW9Q.js";import{u as I,a as p}from"./vendor-i18n-BNURlJ23.js";import{S as y,E as v,C as H,j as T,L as X,ae as A,l as j,ag as O,ah as Y,ai as q,aj as K,V,G as J,m as N,t as Q}from"./vendor-antd-DODjfilb.js";import{q as U,u as z,t as W}from"./App-BTGbaEEX.js";import"./vendor-mermaid-De-Yacw-.js";import"./main-mHH04gTP.js";const Z=({buttons:r,className:e,style:m,size:l="middle",align:i="right"})=>{const h={className:e,style:{width:"100%",justifyContent:i==="left"?"flex-start":i==="center"?"center":"flex-end",...m}};return t.jsx(y,{...h,children:r.map(a=>t.jsx(v,{type:a.type||"default",disabled:a.disabled,loading:a.loading,danger:a.danger,onClick:a.onClick,size:l,icon:a.icon,children:a.text},a.key))})},_=(r,e)=>({key:"cancel",text:e||"Cancel",type:"default",onClick:r}),k=(r,e)=>({key:"ok",text:(e==null?void 0:e.text)||"OK",type:"primary",disabled:e==null?void 0:e.disabled,loading:e==null?void 0:e.loading,onClick:r}),{Text:b,Paragraph:ee}=T,te=({content:r,token:e,showGradient:m,onClick:l})=>t.jsx(H,{size:"small",style:{marginLeft:e.marginLG,marginTop:e.marginXS,backgroundColor:e.colorBgLayout,borderColor:e.colorBorderSecondary},styles:{body:{padding:e.paddingMD}},onClick:l,children:t.jsxs("div",{style:{maxHeight:"60vh",overflowY:"auto",position:"relative",paddingRight:e.paddingXS},children:[t.jsx(D,{remarkPlugins:[E],components:{p:({children:i})=>t.jsx(ee,{style:{marginBottom:e.marginSM},children:i}),ol:({children:i})=>t.jsx("ol",{style:{marginBottom:e.marginSM,paddingLeft:e.paddingLG},children:i}),ul:({children:i})=>t.jsx("ul",{style:{marginBottom:e.marginSM,paddingLeft:e.paddingLG},children:i}),li:({children:i})=>t.jsx("li",{style:{marginBottom:e.marginXS},children:i}),h1:({children:i})=>t.jsx(b,{strong:!0,style:{fontSize:e.fontSizeHeading3,marginBottom:e.marginSM,display:"block"},children:i}),h2:({children:i})=>t.jsx(b,{strong:!0,style:{fontSize:e.fontSizeHeading4,marginBottom:e.marginSM,display:"block"},children:i}),code:({inline:i,className:h,children:a,...n})=>{const o=/language-(\w+)/.exec(h||"");return i?t.jsx("code",{className:h,style:{backgroundColor:e.colorFillTertiary,padding:"0 4px",borderRadius:e.borderRadiusSM,fontSize:e.fontSizeSM},...n,children:a}):t.jsx(F,{style:U,language:(o==null?void 0:o[1])||"text",PreTag:"div",wrapLongLines:!0,children:String(a).replace(/\n$/,"")})}},children:r||"No content available."}),m?t.jsx("div",{style:{position:"sticky",bottom:0,height:48,background:`linear-gradient(180deg, transparent, ${e.colorBgLayout})`,pointerEvents:"none",marginTop:-48}}):null]})}),{Text:M,Paragraph:re}=T,se=({prompt:r,token:e,isSelected:m,isExpanded:l,onSelect:i,onToggleExpand:h,onCopy:a})=>{const{t:n}=I(),o=r.content||"",{nonEmptyLineCount:f,wordCount:u,characterCount:P,showGradient:x}=p.useMemo(()=>{const S=(o?o.split(/\r?\n/):[]).filter(w=>w.trim().length>0).length,C=o.trim()?o.trim().split(/\s+/).filter(Boolean).length:0,g=o.length;return{nonEmptyLineCount:S,wordCount:C,characterCount:g,showGradient:!l&&g>600}},[o,l]);return t.jsx(X.Item,{style:{cursor:"pointer",padding:e.paddingMD,borderRadius:e.borderRadius,border:m?`2px solid ${e.colorPrimary}`:`1px solid ${e.colorBorderSecondary}`,marginBottom:e.marginXS,backgroundColor:m?e.colorPrimaryBg:e.colorBgContainer,transition:"all 0.2s ease"},onClick:()=>i(r.id),children:t.jsxs(y,{direction:"vertical",style:{width:"100%"},size:e.marginSM,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",width:"100%",gap:e.marginSM},children:[t.jsxs(y,{align:"start",children:[t.jsx(A,{checked:m,onChange:()=>i(r.id),onClick:c=>c.stopPropagation()}),t.jsxs("div",{children:[t.jsx(M,{strong:!0,children:r.name||r.id}),t.jsx("div",{children:t.jsx(M,{code:!0,style:{fontSize:e.fontSizeSM,color:e.colorTextSecondary},children:r.id})})]}),r.isDefault?t.jsx(j,{color:"warning",children:n("chat.systemPromptSelector.defaultTag")}):null]}),t.jsxs(y,{size:"small",children:[t.jsx(v,{type:"text",size:"small",icon:l?t.jsx(O,{}):t.jsx(Y,{}),onClick:c=>{c.stopPropagation(),h(r.id)},children:n(l?"chat.systemPromptSelector.hide":"chat.systemPromptSelector.preview")}),t.jsx(v,{type:"text",size:"small",icon:t.jsx(q,{}),onClick:c=>a(c,r),children:n("chat.systemPromptSelector.copy")})]})]}),r.description?t.jsx(M,{type:"secondary",style:{marginLeft:e.marginLG,fontSize:e.fontSizeSM},children:r.description}):null,t.jsxs(y,{size:"small",wrap:!0,style:{marginLeft:e.marginLG},children:[t.jsx(j,{color:"processing",children:n("chat.systemPromptSelector.lines",{count:f})}),t.jsx(j,{color:"purple",children:n("chat.systemPromptSelector.words",{count:u})}),t.jsx(j,{color:"success",children:n("chat.systemPromptSelector.chars",{count:P})})]}),l?t.jsx(te,{content:o,token:e,showGradient:x,onClick:c=>c.stopPropagation()}):t.jsx(re,{type:"secondary",ellipsis:{rows:3},style:{marginLeft:e.marginLG,marginBottom:0,color:e.colorTextSecondary},children:o||n("chat.systemPromptSelector.noContent")})]})},r.id)},{Text:ie}=T,{useToken:ae}=Q,me=({open:r,onClose:e,onSelect:m,prompts:l,title:i,showCancelButton:h=!0})=>{const{t:a}=I(),{token:n}=ae(),[o,f]=K.useMessage(),u=z(s=>s.lastSelectedPromptId),P=z(s=>s.setLastSelectedPromptId),[x,c]=p.useState(null),[S,C]=p.useState(null),g=p.useMemo(()=>l.filter(s=>s.id&&s.id.trim()!==""),[l]),w=async(s,d)=>{s.stopPropagation();const L=d.content??"";try{await W(L),o.success(a("success.promptCopied",{name:d.name}))}catch($){console.error("[SystemPromptSelector] Failed to copy prompt:",$),o.error(a("error.copyPromptFailed"))}},G=i??a("chat.prompt.selectorTitle");p.useEffect(()=>{if(r){const s=g.find(L=>L.isDefault),d=u||(s==null?void 0:s.id)||(g.length>0?g[0].id:null);c(d)}},[r,u,g.length]);const R=s=>{c(s.id),P(s.id),m(s),e()},B=()=>{e()};return t.jsxs(t.Fragment,{children:[f,t.jsxs(V,{title:t.jsxs(y,{children:[t.jsx(N,{}),G]}),open:r,onCancel:B,width:700,footer:t.jsx(Z,{buttons:[...h?[_(B)]:[],k(()=>{const s=g.find(d=>d.id===x);s&&R(s)},{text:a("chat.prompt.createButton"),disabled:!x})]}),styles:{body:{maxHeight:"70vh",overflowY:"auto",padding:n.paddingMD}},children:[t.jsx("div",{style:{marginBottom:n.marginMD},children:t.jsx(ie,{type:"secondary",style:{fontSize:n.fontSizeSM},children:a("chat.prompt.helperText")})}),g.length===0?t.jsx(J,{description:a("chat.prompt.emptyDescription"),style:{margin:n.marginLG}}):t.jsx("div",{children:g.map(s=>t.jsx(se,{prompt:s,token:n,isSelected:x===s.id,isExpanded:S===s.id,onSelect:d=>c(d),onToggleExpand:d=>C(S===d?null:d),onCopy:w},s.id))})]})]})};export{me as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./vendor-markdown-DzaXAW9Q.js";import{u as S,a as j}from"./vendor-i18n-BNURlJ23.js";import{u as T,e as v}from"./App-
|
|
1
|
+
import{j as s}from"./vendor-markdown-DzaXAW9Q.js";import{u as S,a as j}from"./vendor-i18n-BNURlJ23.js";import{u as T,e as v}from"./App-BTGbaEEX.js";import{t as E,aa as R,a2 as g,ab as N,D as C,v as $,ac as I,z as b,a9 as k,k as M,l as A}from"./vendor-antd-DODjfilb.js";import"./vendor-mermaid-De-Yacw-.js";import"./main-mHH04gTP.js";const _=new Set(["Write","Edit","apply_patch","NotebookEdit"]),B=i=>{const o=i.match(/(?:file_path|Wrote file|Edited file)[:\s]*["']?([^\s"',]+)/i);if(o){const e=o[1];return e.split("/").pop()||e}return null},D=(i,o)=>{const e=o-i;if(e<0)return"";const l=Math.floor(e/1e3);if(l<60)return`${l}s`;const r=Math.floor(l/60);return r<60?`${r}m ${l%60}s`:`${Math.floor(r/60)}h ${r%60}m`},W=i=>{var x,h;let o=0,e=0,l=0,r=0,m=!1,u=0,t="";const y=new Set;let c=0,n=0;for(const a of i){const p=a.createdAt?new Date(a.createdAt).getTime():0;if(p>0&&(c===0||p<c)&&(c=p),p>n&&(n=p),a.isCompressed){m=!0,u++;continue}if(a.role==="user"&&!("type"in a&&a.type==="file_reference")&&o++,a.role==="assistant"){if("type"in a&&a.type==="tool_call"&&(l+=((x=a.toolCalls)==null?void 0:x.length)??0),"type"in a&&a.type==="tool_result"){const d=a;if(d.isError&&r++,_.has(d.toolName)){const f=B(((h=d.result)==null?void 0:h.result)??"");f&&y.add(f)}}if("type"in a&&a.type==="text"){e++;const d=a.content||"";d.length>0&&d.length>30&&(t=d.slice(0,300))}}}return{messageCount:i.length,userMessageCount:o,assistantMessageCount:e,toolCallCount:l,toolErrorCount:r,fileChanges:Array.from(y).slice(0,10),lastAssistantExcerpt:t,hasCompression:m,compressionCount:u,duration:c>0&&n>c?D(c,n):""}},P=({sessionId:i})=>{const{t:o}=S(),{token:e}=E.useToken(),[l,r]=j.useState(!1),m=T(v(i)),u=m==null?void 0:m.messages,t=j.useMemo(()=>!u||u.length===0?null:W(u),[u]);if(!t||t.messageCount<3)return null;const y=t.fileChanges.length>0,c=t.lastAssistantExcerpt.length>0;return s.jsxs("div",{className:"lotus-session-summary",style:{borderColor:e.colorBorderSecondary,background:`${e.colorBgElevated}`},children:[s.jsxs("div",{className:"lotus-session-summary-header",onClick:()=>r(n=>!n),role:"button",tabIndex:0,onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),r(x=>!x))},"aria-expanded":l,children:[s.jsx("span",{className:"lotus-session-summary-header-icon",style:{color:e.colorPrimary},children:s.jsx(R,{})}),s.jsx("span",{className:"lotus-session-summary-header-title",style:{color:e.colorText},children:o("sessionSummary.title","Session Summary")}),!l&&s.jsxs("span",{className:"lotus-session-summary-stats",children:[s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(g,{className:"lotus-session-summary-stat-icon"}),s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.messageCount})]}),t.toolCallCount>0&&s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(N,{className:"lotus-session-summary-stat-icon"}),s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.toolCallCount})]}),y&&s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(C,{className:"lotus-session-summary-stat-icon"}),s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.fileChanges.length})]})]}),s.jsx("span",{className:`lotus-session-summary-toggle ${l?"is-expanded":""}`,style:{color:e.colorTextTertiary},children:s.jsx($,{})})]}),l&&s.jsxs("div",{className:"lotus-session-summary-body",children:[s.jsxs("div",{className:"lotus-session-summary-stats",children:[s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(g,{className:"lotus-session-summary-stat-icon"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.messageCount})," ",o("sessionSummary.messages","messages")]})]}),s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx("span",{className:"lotus-session-summary-stat-icon",children:"👤"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.userMessageCount})," ",o("sessionSummary.userTurns","user")]})]}),s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx("span",{className:"lotus-session-summary-stat-icon",children:"🤖"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.assistantMessageCount})," ",o("sessionSummary.assistantTurns","assistant")]})]}),t.toolCallCount>0&&s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(N,{className:"lotus-session-summary-stat-icon"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.toolCallCount})," ",o("sessionSummary.toolCalls","tool calls")]})]}),t.toolErrorCount>0&&s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:"#ff4d4f"},children:[s.jsx(I,{className:"lotus-session-summary-stat-icon"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.toolErrorCount})," ",o("sessionSummary.errors","errors")]})]}),t.duration&&s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(b,{className:"lotus-session-summary-stat-icon"}),s.jsx("span",{children:t.duration})]}),t.hasCompression&&s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(k,{className:"lotus-session-summary-stat-icon"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.compressionCount})," ",o("sessionSummary.compressions","compressions")]})]})]}),y&&s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:11,fontWeight:600,color:e.colorTextSecondary,marginBottom:4,textTransform:"uppercase",letterSpacing:.3},children:o("sessionSummary.filesChanged","Files Changed")}),s.jsx("div",{className:"lotus-session-summary-files",children:t.fileChanges.map(n=>s.jsx(M,{title:n,children:s.jsxs(A,{bordered:!1,className:"lotus-session-summary-file-tag",children:[s.jsx(C,{style:{marginRight:4}}),n]})},n))})]}),c&&s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:11,fontWeight:600,color:e.colorTextSecondary,marginBottom:4,textTransform:"uppercase",letterSpacing:.3},children:o("sessionSummary.lastResponse","Latest Response")}),s.jsx("div",{className:"lotus-session-summary-conclusion",style:{color:e.colorTextSecondary},children:t.lastAssistantExcerpt})]})]})]})};export{P as SessionSummaryCard,P as default};
|