@bigduu/lotus 2026.5.16 → 2026.5.18

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.
@@ -1 +1 @@
1
- import{a as n}from"./App-Agd9FqjU.js";const r=s=>{const t=new URLSearchParams;Object.entries(s).forEach(([i,a])=>{a===void 0||a===""||t.set(i,String(a))});const e=t.toString();return e?`?${e}`:""};class d{async getSummary(t={}){const e=r({start_date:t.startDate,end_date:t.endDate});return n.get(`metrics/summary${e}`)}async getByModel(t={}){const e=r({start_date:t.startDate,end_date:t.endDate});return n.get(`metrics/by-model${e}`)}async getSessions(t={}){const e=r({start_date:t.startDate,end_date:t.endDate,model:t.model,limit:t.limit});return n.get(`metrics/sessions${e}`)}async getSessionDetail(t){try{return await n.get(`metrics/sessions/${encodeURIComponent(t)}`)}catch(e){if(e instanceof Error&&e.message.includes("not found"))return null;throw e}}async getUsageBreakdown(t={}){const e=r({start_date:t.startDate,end_date:t.endDate,model:t.model});return n.get(`metrics/usage-breakdown${e}`)}async getDaily(t={}){const e=r({days:t.days,end_date:t.endDate,granularity:t.granularity});return n.get(`metrics/daily${e}`)}async getForwardSummary(t={}){const e=r({start_date:t.startDate,end_date:t.endDate,endpoint:t.endpoint,model:t.model,limit:t.limit});return n.get(`metrics/forward/summary${e}`)}async getForwardByEndpoint(t={}){const e=r({start_date:t.startDate,end_date:t.endDate,endpoint:t.endpoint,model:t.model,limit:t.limit});return n.get(`metrics/forward/by-endpoint${e}`)}async getForwardRequests(t={}){const e=r({start_date:t.startDate,end_date:t.endDate,endpoint:t.endpoint,model:t.model,limit:t.limit});return n.get(`metrics/forward/requests${e}`)}async getMemorySummary(t={}){const e=r({scope:t.scope,project_key:t.projectKey});return n.get(`metrics/memory/summary${e}`)}async getMemoryTimeline(t={}){const e=r({scope:t.scope,project_key:t.projectKey,days:t.days,end_date:t.endDate,granularity:t.granularity});return n.get(`metrics/memory/timeline${e}`)}async getUnifiedSummary(t={}){const e=r({start_date:t.startDate,end_date:t.endDate});return n.get(`metrics/v2/summary${e}`)}async getUnifiedTimeline(t={}){const e=r({days:t.days,end_date:t.endDate,granularity:t.granularity});return n.get(`metrics/v2/timeline${e}`)}}const m=new d;export{m};
1
+ import{a as n}from"./App-BYqor0NW.js";const r=s=>{const t=new URLSearchParams;Object.entries(s).forEach(([i,a])=>{a===void 0||a===""||t.set(i,String(a))});const e=t.toString();return e?`?${e}`:""};class d{async getSummary(t={}){const e=r({start_date:t.startDate,end_date:t.endDate});return n.get(`metrics/summary${e}`)}async getByModel(t={}){const e=r({start_date:t.startDate,end_date:t.endDate});return n.get(`metrics/by-model${e}`)}async getSessions(t={}){const e=r({start_date:t.startDate,end_date:t.endDate,model:t.model,limit:t.limit});return n.get(`metrics/sessions${e}`)}async getSessionDetail(t){try{return await n.get(`metrics/sessions/${encodeURIComponent(t)}`)}catch(e){if(e instanceof Error&&e.message.includes("not found"))return null;throw e}}async getUsageBreakdown(t={}){const e=r({start_date:t.startDate,end_date:t.endDate,model:t.model});return n.get(`metrics/usage-breakdown${e}`)}async getDaily(t={}){const e=r({days:t.days,end_date:t.endDate,granularity:t.granularity});return n.get(`metrics/daily${e}`)}async getForwardSummary(t={}){const e=r({start_date:t.startDate,end_date:t.endDate,endpoint:t.endpoint,model:t.model,limit:t.limit});return n.get(`metrics/forward/summary${e}`)}async getForwardByEndpoint(t={}){const e=r({start_date:t.startDate,end_date:t.endDate,endpoint:t.endpoint,model:t.model,limit:t.limit});return n.get(`metrics/forward/by-endpoint${e}`)}async getForwardRequests(t={}){const e=r({start_date:t.startDate,end_date:t.endDate,endpoint:t.endpoint,model:t.model,limit:t.limit});return n.get(`metrics/forward/requests${e}`)}async getMemorySummary(t={}){const e=r({scope:t.scope,project_key:t.projectKey});return n.get(`metrics/memory/summary${e}`)}async getMemoryTimeline(t={}){const e=r({scope:t.scope,project_key:t.projectKey,days:t.days,end_date:t.endDate,granularity:t.granularity});return n.get(`metrics/memory/timeline${e}`)}async getUnifiedSummary(t={}){const e=r({start_date:t.startDate,end_date:t.endDate});return n.get(`metrics/v2/summary${e}`)}async getUnifiedTimeline(t={}){const e=r({days:t.days,end_date:t.endDate,granularity:t.granularity});return n.get(`metrics/v2/timeline${e}`)}}const m=new d;export{m};
@@ -1 +1 @@
1
- var Ce=Object.defineProperty;var Se=(e,t,s)=>t in e?Ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var re=(e,t,s)=>Se(e,typeof t!="symbol"?t+"":t,s);import{j as o}from"./vendor-markdown-DZuK0SxV.js";import{a as u,u as N}from"./vendor-i18n-BNURlJ23.js";import{t as _,y as le,z as we,I as z,u as x,B as xe,o as Ae}from"./App-Agd9FqjU.js";import{l as W,F as I,j as ie,E as $,ak as Te,t as ue,u as ve,a8 as Ee,C as ke}from"./vendor-antd-C8lKwvI6.js";import"./vendor-mermaid-C1Gk9PtT.js";import"./main-C-I4C72U.js";const j=class j{static getInstance(){return j.instance||(j.instance=new j),j.instance}parseUserCommand(t){_("[ToolService]",`[ToolService] parseUserCommand: Parsing content: "${t}"`);const s=t.trim();if(!s.startsWith("/"))return _("[ToolService]",'[ToolService] parseUserCommand: Content does not start with "/", not a tool command.'),null;const r=s.indexOf(" ");let i,d;if(r===-1?(i=s.substring(1),d=""):(i=s.substring(1,r),d=s.substring(r+1).trim()),i){const f={tool_name:i,user_description:d};return _("[ToolService]","[ToolService] parseUserCommand: Successfully parsed command:",f),f}return _("[ToolService]","[ToolService] parseUserCommand: Failed to parse tool name from content."),null}parseAIResponseToToolCall(t){return this.parseUserCommand(t)}async executeTool(t){_("[ToolService]","[ToolService] executeTool: Attempting to execute tool via HTTP with request:",t);try{const s=await le.post("tools/execute",t),r=JSON.parse(s.result);return _("[ToolService]","[ToolService] executeTool: Parsed structured result:",r),r}catch(s){throw console.error("[ToolService] executeTool: HTTP tool execution failed:",s),s instanceof we?new Error(`Workflow execution failed: ${s.message}`):s}}};re(j,"instance");let L=j;const F=new L;class Re{async listProfiles(){return le.get("subagent_profiles")}}const je=new Re,Pe=[];function _e(e={}){const{enabled:t=!0,refreshKey:s}=e,[r,i]=u.useState(null),[d,f]=u.useState(!1),[b,E]=u.useState(null),w=u.useCallback(async()=>{f(!0);try{const y=await je.listProfiles();i(y),E(null)}catch(y){E(y instanceof Error?y:new Error(String(y)))}finally{f(!1)}},[]);u.useEffect(()=>{t&&w()},[t,w,s]);const T=u.useMemo(()=>{const y=new Map;if(r!=null&&r.profiles)for(const p of r.profiles)y.set(p.id,p);return y},[r]);return{profiles:(r==null?void 0:r.profiles)??Pe,fallbackId:(r==null?void 0:r.fallback_id)??null,loading:d,error:b,refresh:w,byId:T}}const oe=(e,t,s)=>{var w,T,y,p,c;const r=e==null?void 0:e.trim();if(!r)return null;const i=t.get(r),d=((w=i==null?void 0:i.display_name)==null?void 0:w.trim())||r,f=(y=(T=i==null?void 0:i.ui)==null?void 0:T.icon)==null?void 0:y.trim(),b=((c=(p=i==null?void 0:i.ui)==null?void 0:p.color)==null?void 0:c.trim())||void 0;return(s==null?void 0:s.compact)??!1?o.jsx("span",{"data-testid":`sub-agent-role-tag-${r}`,style:{color:b||"inherit",lineHeight:"inherit",whiteSpace:"nowrap"},children:f?`${f} ${d}`:d}):o.jsx(W,{color:b,style:{marginInlineEnd:0,flex:"0 0 auto"},"data-testid":`sub-agent-role-tag-${r}`,children:f?`${f} ${d}`:d})},{Text:D}=ie,{useToken:$e}=ue,Ie=e=>{const t=(e||"").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"},He=u.memo(({item:e,index:t,compact:s,isRetrying:r,isContinuing:i,isDeleting:d,subagentProfilesById:f,onOpenChild:b,onContinueChild:E,onRetryChild:w,onTogglePin:T,onDeleteChild:y})=>{const{token:p}=$e(),{t:c}=N(),k=s?{marginInlineEnd:0,flex:"0 0 auto",fontSize:10,lineHeight:"16px",paddingInline:6}:{marginInlineEnd:0,flex:"0 0 auto"},C=s?{paddingInline:0,height:22}:void 0,S=Ie(e.status),P=S==="running",R=r||i||d,H=h=>h==="running"?c("chat.subAgents.statusRunning"):h==="completed"?c("chat.subAgents.statusCompleted"):h==="pending"?c("chat.subAgents.statusPending"):h==="cancelled"?c("chat.subAgents.statusCancelled"):h==="error"||h==="failed"?c("chat.subAgents.statusFailed"):h,O=h=>h==="running"?p.colorPrimary:h==="completed"?p.colorSuccess:h==="error"||h==="failed"?p.colorError:h==="cancelled"?p.colorWarning:p.colorTextSecondary;return o.jsxs(I,{vertical:!0,gap:s?6:p.marginSM,className:s?void 0:"lotus-settings-list-item",style:{width:"100%",minWidth:0,padding:s?"6px 0":p.paddingSM,borderRadius:s?0:p.borderRadiusSM,borderTop:s&&t>0?`1px solid ${p.colorBorderSecondary}`:void 0,background:s?"transparent":void 0},children:[o.jsxs(I,{vertical:!0,style:{width:"100%",minWidth:0},children:[o.jsxs(I,{align:"center",gap:p.marginXS,wrap:!0,style:{width:"100%",minWidth:0},children:[o.jsx(D,{strong:!0,ellipsis:!0,style:{minWidth:0,flex:"1 1 180px",fontSize:s?13:void 0},children:e.title||c("chat.subAgents.fallbackTitle")}),s?o.jsx(z,{nowrap:!0,items:[o.jsx("span",{style:{color:O(S)},children:H(S)}),e.pinned?c("chat.subAgents.pinned"):null,oe(e.subagentType,f,{compact:!0})]}):o.jsxs(o.Fragment,{children:[o.jsx(W,{color:S==="running"?"processing":S==="completed"?"success":S==="error"||S==="failed"?"error":S==="cancelled"?"warning":"default",style:k,children:H(S)}),e.pinned?o.jsx(W,{color:"warning",style:k,children:c("chat.subAgents.pinned")}):null,oe(e.subagentType,f)]})]}),s?o.jsx(z,{block:!0,items:[e.childSessionId.slice(0,8),e.updatedAt,e.lastHeartbeatAt?`${c("chat.subAgents.heartbeat")}: ${e.lastHeartbeatAt}`:null,typeof e.roundCount=="number"?`${c("chat.subAgents.round")} ${e.roundCount+1}`:null]}):o.jsxs(D,{type:"secondary",style:{display:"block",minWidth:0,fontSize:12,marginTop:2},children:[e.childSessionId.slice(0,8),e.updatedAt?` • ${e.updatedAt}`:"",e.lastHeartbeatAt?` • ${c("chat.subAgents.heartbeat")}: ${e.lastHeartbeatAt}`:"",typeof e.roundCount=="number"?` • ${c("chat.subAgents.round")} ${e.roundCount+1}`:""]}),e.outputPreview?o.jsx(D,{type:"secondary",style:{display:"block",minWidth:0,marginTop:s?4:p.marginXS,fontSize:s?11:13,lineHeight:s?1.35:void 0},ellipsis:!0,children:e.outputPreview}):null,e.error?o.jsx(D,{type:"danger",style:{display:"block",minWidth:0,marginTop:s?4:p.marginXS,fontSize:s?11:void 0,lineHeight:s?1.35:void 0},children:e.error}):null]}),o.jsxs(I,{gap:s?4:8,wrap:!0,style:{width:"100%",minWidth:0,paddingTop:s?2:0},children:[o.jsx($,{size:"small",type:s?"text":"default",style:C,disabled:R,onClick:()=>b(e.childSessionId),children:c("chat.subAgents.open")}),o.jsx($,{size:"small",type:s?"text":"default",style:C,loading:i,disabled:d||r||P,"data-testid":`sub-agent-continue-${e.childSessionId}`,onClick:()=>E(e.childSessionId),children:c("chat.subAgents.continue")}),o.jsx(Te,{trigger:["click"],menu:{items:[{key:"regenerate",label:c("chat.actions.regenerate")},{key:"error_retry",label:c("chat.actions.retryFailed")}],onClick:({key:h})=>{w(e.childSessionId,h)}},disabled:d||P||i,children:o.jsx($,{size:"small",type:s?"text":"default",style:C,loading:r,disabled:d||P||i,"data-testid":`sub-agent-retry-${e.childSessionId}`,children:c("chat.subAgents.retry")})}),typeof e.pinned=="boolean"?o.jsx($,{size:"small",type:s?"text":"default",style:C,disabled:R,onClick:()=>T(e.childSessionId,e.pinned),children:e.pinned?c("chat.actions.unpin"):c("chat.actions.pin")}):null,o.jsx($,{danger:!0,type:s?"text":"default",style:C,size:"small",loading:d,disabled:r,"data-testid":`sub-agent-delete-${e.childSessionId}`,onClick:()=>y(e.childSessionId),children:c("common.delete")})]})]})},(e,t)=>e.item===t.item&&e.index===t.index&&e.compact===t.compact&&e.isRetrying===t.isRetrying&&e.isContinuing===t.isContinuing&&e.isDeleting===t.isDeleting&&e.subagentProfilesById===t.subagentProfilesById&&e.onOpenChild===t.onOpenChild&&e.onContinueChild===t.onContinueChild&&e.onRetryChild===t.onRetryChild&&e.onTogglePin===t.onTogglePin&&e.onDeleteChild===t.onDeleteChild),{Text:B}=ie,{useToken:de}=ue,Oe="chat-session-sub-agents-collapsed:",Me=3,De=600,U=e=>{const t=(e||"").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"},Fe=(e,t)=>{if(t&&t.trim())return t;if(e.isRunning)return"running";if(e.lastRunStatus&&e.lastRunStatus.trim())return e.lastRunStatus;const s=e.messageCount??0;return s>2?"completed":(s>0,"pending")},ce=e=>`${Oe}${e}`,X=e=>{if(typeof window>"u")return!1;try{const t=window.localStorage.getItem(ce(e));return t==="1"?!0:t==="0"?!1:null}catch{return null}},Be=(e,t)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(ce(e),t?"1":"0")}catch{}},ae=(e,t)=>e.childSessionId===t.childSessionId&&e.title===t.title&&e.status===t.status&&e.error===t.error&&e.lastHeartbeatAt===t.lastHeartbeatAt&&e.lastEventAt===t.lastEventAt&&e.outputPreview===t.outputPreview&&e.pinned===t.pinned&&e.updatedAt===t.updatedAt&&e.isRunning===t.isRunning&&e.messageCount===t.messageCount&&e.lastRunStatus===t.lastRunStatus&&e.lastRunError===t.lastRunError&&e.subagentType===t.subagentType&&e.roundCount===t.roundCount,Ke=({parentSessionId:e,compact:t=!1})=>{const{t:s}=N(),{token:r}=de(),[i,d]=u.useState(()=>X(e)??!1),[f,b]=u.useState(null),[E,w]=u.useState(null),[T,y]=u.useState(null),p=x(n=>xe(e)(n)),c=x(n=>n.chats),k=x(n=>n.loadChatHistory),C=x(n=>n.refreshChats),S=x(n=>n.markOptimisticStart),P=x(n=>n.markRetryStart),R=x(n=>n.markSettleTimeout),H=x(n=>n.pinSession),O=x(n=>n.unpinSession),h=x(n=>n.applyChildProgress),G=x(n=>n.clearChildProgress),{byId:ge}=_e(),q=u.useRef(new Map),K=u.useMemo(()=>Object.entries(p).map(([n,g])=>({childSessionId:n,...g})),[p]),Y=u.useMemo(()=>c.filter(n=>n.kind==="child"&&n.parentSessionId===e).sort((n,g)=>{const m=Date.parse(n.updatedAt||"")||0;return(Date.parse(g.updatedAt||"")||0)-m}),[c,e]),v=u.useMemo(()=>{const n=new Map(K.map(l=>[l.childSessionId,l])),g=q.current,m=[];for(const l of Y){const a=n.get(l.id),A={childSessionId:l.id,title:l.title||(a==null?void 0:a.title),status:U(Fe(l,a==null?void 0:a.status)),error:(a==null?void 0:a.error)||l.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:l.pinned,updatedAt:l.updatedAt,isRunning:l.isRunning,messageCount:l.messageCount,lastRunStatus:l.lastRunStatus,lastRunError:l.lastRunError,subagentType:l.subagentType??null},M=g.get(l.id);m.push(M&&ae(M,A)?M:A),n.delete(l.id)}for(const l of n.values()){const a={childSessionId:l.childSessionId,title:l.title,status:U(l.status),error:l.error,lastHeartbeatAt:l.lastHeartbeatAt,lastEventAt:l.lastEventAt,outputPreview:l.outputPreview,roundCount:l.roundCount},A=g.get(l.childSessionId);m.push(A&&ae(A,a)?A:a)}return q.current=new Map(m.map(l=>[l.childSessionId,l])),m},[Y,K]);u.useEffect(()=>{d(X(e)??!1)},[e]),u.useEffect(()=>{X(e)===null&&d(v.length>Me)},[e,v.length]);const he=u.useCallback(()=>{d(n=>{const g=!n;return Be(e,g),g})},[e]),J=u.useCallback(n=>n instanceof Error&&n.message.trim()?n.message:s("chat.subAgents.runChildFailed"),[s]),Q=u.useCallback(async(n,g="regenerate")=>{b(n),h(e,n,{status:"running",error:void 0,lastEventAt:new Date().toISOString()}),P(n);try{const m=await F.executeTool({tool_name:"SubAgent",session_id:e,parameters:[{name:"action",value:"run"},{name:"child_session_id",value:n},{name:"reset_to_last_user",value:g==="error_retry"?"false":"true"}]});if(!m.success)throw new Error(m.result||"Failed to run sub-agent");h(e,n,{status:"running",error:void 0,lastEventAt:new Date().toISOString()}),await k(n,{mode:"replace"}),await C()}catch(m){R(n),h(e,n,{status:"error",error:J(m),lastEventAt:new Date().toISOString()})}finally{b(m=>m===n?null:m)}},[k,e,C,P,R,J,h]),V=u.useCallback(async n=>{const g=typeof window<"u"?window.prompt.bind(window):null;if(!g)return;const m=g("Send a follow-up message to this sub-agent:","Continue from where you left off.");if(m===null)return;const l=m.trim();if(!l){h(e,n,{status:"error",error:"Follow-up message cannot be empty.",lastEventAt:new Date().toISOString()});return}w(n),h(e,n,{status:"running",error:void 0,lastEventAt:new Date().toISOString()}),S(n);try{const a=await F.executeTool({tool_name:"SubAgent",session_id:e,parameters:[{name:"action",value:"send_message"},{name:"child_session_id",value:n},{name:"message",value:l},{name:"auto_run",value:"true"}]});if(!a.success)throw new Error(a.result||"Follow-up failed");let A="running";try{JSON.parse(a.result).status==="pending"&&(A="pending")}catch{A="running"}h(e,n,{status:A,error:void 0,lastEventAt:new Date().toISOString()}),await C()}catch(a){R(n),h(e,n,{status:"error",error:a instanceof Error&&a.message.trim()?a.message:s("chat.subAgents.continueChildFailed"),lastEventAt:new Date().toISOString()})}finally{w(a=>a===n?null:a)}},[e,C,S,R,h,s]),Z=u.useCallback(async n=>{y(n);try{const g=await F.executeTool({tool_name:"SubAgent",session_id:e,parameters:[{name:"action",value:"delete"},{name:"child_session_id",value:n}]});if(!g.success)throw new Error(g.result||"Failed to delete sub-agent");G(e,n),await C()}finally{y(g=>g===n?null:g)}},[G,e,C]),pe=u.useCallback(n=>{Ae(n),k(n)},[k]),fe=u.useCallback(n=>{V(n)},[V]),me=u.useCallback((n,g)=>{Q(n,g)},[Q]),ye=u.useCallback((n,g)=>{g?O(n):H(n)},[H,O]),be=u.useCallback(n=>{Z(n)},[Z]);if(v.length===0)return null;const ee=o.jsxs(B,{strong:!0,children:[s("chat.subAgents.title")," ",o.jsxs(B,{type:"secondary",children:["(",v.length,")"]})]}),te=o.jsx($,{type:"text",size:"small",icon:i?o.jsx(ve,{}):o.jsx(Ee,{}),onClick:he,"data-testid":"sub-agents-toggle",style:t?{paddingInline:4}:void 0,children:s(i?"chat.subAgents.expand":"chat.subAgents.collapse")}),ne=i?o.jsx(B,{type:"secondary","data-testid":"sub-agents-collapsed-hint",children:s("chat.subAgents.hiddenHint",{count:v.length})}):o.jsx(I,{vertical:!0,gap:t?r.marginXS:r.marginSM,"data-testid":"sub-agents-list",style:{width:"100%",minWidth:0,maxHeight:`${De}px`,overflowY:"auto",overflowX:"hidden",paddingRight:t?0:r.paddingXS},children:v.map((n,g)=>o.jsx(He,{item:n,index:g,compact:t,isRetrying:f===n.childSessionId,isContinuing:E===n.childSessionId,isDeleting:T===n.childSessionId,subagentProfilesById:ge,onOpenChild:pe,onContinueChild:fe,onRetryChild:me,onTogglePin:ye,onDeleteChild:be},n.childSessionId))}),se=!i&&v.length>1?o.jsx(Xe,{items:v}):null;return t?o.jsxs("section",{"data-testid":"sub-agents-panel",style:{width:"100%",minWidth:0,marginBottom:r.marginXS,overflow:"hidden"},children:[o.jsxs(I,{align:"center",justify:"space-between",gap:r.marginXS,style:{padding:`${r.paddingXXS??2}px 0 ${r.paddingXS}px`,borderBottom:`1px solid ${r.colorBorderSecondary}`},children:[o.jsx("div",{style:{flex:1,minWidth:0},children:ee}),o.jsx("div",{style:{flex:"0 0 auto"},children:te})]}),o.jsxs("div",{style:{padding:`${r.paddingXS}px 0 0`},children:[ne,se]})]}):o.jsxs(ke,{size:"small",className:"lotus-settings-card",style:{marginBottom:r.marginMD},"data-testid":"sub-agents-panel",title:ee,extra:te,children:[ne,se]})},Xe=({items:e})=>{const{token:t}=de(),{t:s}=N(),r=e.reduce((d,f)=>{const b=U(f.status);return b==="completed"?d.completed++:b==="running"?d.running++:b==="error"||b==="failed"?d.error++:d.pending++,d},{completed:0,running:0,error:0,pending:0}),i=[];return r.completed>0&&i.push(s("chat.subAgents.summaryCompleted",{count:r.completed})),r.running>0&&i.push(s("chat.subAgents.summaryRunning",{count:r.running})),r.pending>0&&i.push(s("chat.subAgents.summaryPending",{count:r.pending})),r.error>0&&i.push(s("chat.subAgents.summaryFailed",{count:r.error})),i.length===0?null:o.jsx(z,{block:!0,items:i,style:{marginTop:t.marginXS}})};export{Ke as SubAgentsPanel};
1
+ var Ce=Object.defineProperty;var Se=(e,t,s)=>t in e?Ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var re=(e,t,s)=>Se(e,typeof t!="symbol"?t+"":t,s);import{j as o}from"./vendor-markdown-DZuK0SxV.js";import{a as u,u as N}from"./vendor-i18n-BNURlJ23.js";import{v as _,z as le,B as we,I as z,u as x,D as xe,o as Ae}from"./App-BYqor0NW.js";import{l as W,F as I,j as ie,E as $,ak as Te,t as ue,u as ve,a8 as Ee,C as ke}from"./vendor-antd-C8lKwvI6.js";import"./vendor-mermaid-C1Gk9PtT.js";import"./main-CEmqYfJe.js";const j=class j{static getInstance(){return j.instance||(j.instance=new j),j.instance}parseUserCommand(t){_("[ToolService]",`[ToolService] parseUserCommand: Parsing content: "${t}"`);const s=t.trim();if(!s.startsWith("/"))return _("[ToolService]",'[ToolService] parseUserCommand: Content does not start with "/", not a tool command.'),null;const r=s.indexOf(" ");let i,d;if(r===-1?(i=s.substring(1),d=""):(i=s.substring(1,r),d=s.substring(r+1).trim()),i){const f={tool_name:i,user_description:d};return _("[ToolService]","[ToolService] parseUserCommand: Successfully parsed command:",f),f}return _("[ToolService]","[ToolService] parseUserCommand: Failed to parse tool name from content."),null}parseAIResponseToToolCall(t){return this.parseUserCommand(t)}async executeTool(t){_("[ToolService]","[ToolService] executeTool: Attempting to execute tool via HTTP with request:",t);try{const s=await le.post("tools/execute",t),r=JSON.parse(s.result);return _("[ToolService]","[ToolService] executeTool: Parsed structured result:",r),r}catch(s){throw console.error("[ToolService] executeTool: HTTP tool execution failed:",s),s instanceof we?new Error(`Workflow execution failed: ${s.message}`):s}}};re(j,"instance");let L=j;const F=new L;class Re{async listProfiles(){return le.get("subagent_profiles")}}const je=new Re,Pe=[];function _e(e={}){const{enabled:t=!0,refreshKey:s}=e,[r,i]=u.useState(null),[d,f]=u.useState(!1),[b,E]=u.useState(null),w=u.useCallback(async()=>{f(!0);try{const y=await je.listProfiles();i(y),E(null)}catch(y){E(y instanceof Error?y:new Error(String(y)))}finally{f(!1)}},[]);u.useEffect(()=>{t&&w()},[t,w,s]);const T=u.useMemo(()=>{const y=new Map;if(r!=null&&r.profiles)for(const p of r.profiles)y.set(p.id,p);return y},[r]);return{profiles:(r==null?void 0:r.profiles)??Pe,fallbackId:(r==null?void 0:r.fallback_id)??null,loading:d,error:b,refresh:w,byId:T}}const oe=(e,t,s)=>{var w,T,y,p,c;const r=e==null?void 0:e.trim();if(!r)return null;const i=t.get(r),d=((w=i==null?void 0:i.display_name)==null?void 0:w.trim())||r,f=(y=(T=i==null?void 0:i.ui)==null?void 0:T.icon)==null?void 0:y.trim(),b=((c=(p=i==null?void 0:i.ui)==null?void 0:p.color)==null?void 0:c.trim())||void 0;return(s==null?void 0:s.compact)??!1?o.jsx("span",{"data-testid":`sub-agent-role-tag-${r}`,style:{color:b||"inherit",lineHeight:"inherit",whiteSpace:"nowrap"},children:f?`${f} ${d}`:d}):o.jsx(W,{color:b,style:{marginInlineEnd:0,flex:"0 0 auto"},"data-testid":`sub-agent-role-tag-${r}`,children:f?`${f} ${d}`:d})},{Text:M}=ie,{useToken:$e}=ue,Ie=e=>{const t=(e||"").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"},He=u.memo(({item:e,index:t,compact:s,isRetrying:r,isContinuing:i,isDeleting:d,subagentProfilesById:f,onOpenChild:b,onContinueChild:E,onRetryChild:w,onTogglePin:T,onDeleteChild:y})=>{const{token:p}=$e(),{t:c}=N(),k=s?{marginInlineEnd:0,flex:"0 0 auto",fontSize:10,lineHeight:"16px",paddingInline:6}:{marginInlineEnd:0,flex:"0 0 auto"},C=s?{paddingInline:0,height:22}:void 0,S=Ie(e.status),P=S==="running",R=r||i||d,H=h=>h==="running"?c("chat.subAgents.statusRunning"):h==="completed"?c("chat.subAgents.statusCompleted"):h==="pending"?c("chat.subAgents.statusPending"):h==="cancelled"?c("chat.subAgents.statusCancelled"):h==="error"||h==="failed"?c("chat.subAgents.statusFailed"):h,O=h=>h==="running"?p.colorPrimary:h==="completed"?p.colorSuccess:h==="error"||h==="failed"?p.colorError:h==="cancelled"?p.colorWarning:p.colorTextSecondary;return o.jsxs(I,{vertical:!0,gap:s?6:p.marginSM,className:s?void 0:"lotus-settings-list-item",style:{width:"100%",minWidth:0,padding:s?"6px 0":p.paddingSM,borderRadius:s?0:p.borderRadiusSM,borderTop:s&&t>0?`1px solid ${p.colorBorderSecondary}`:void 0,background:s?"transparent":void 0},children:[o.jsxs(I,{vertical:!0,style:{width:"100%",minWidth:0},children:[o.jsxs(I,{align:"center",gap:p.marginXS,wrap:!0,style:{width:"100%",minWidth:0},children:[o.jsx(M,{strong:!0,ellipsis:!0,style:{minWidth:0,flex:"1 1 180px",fontSize:s?13:void 0},children:e.title||c("chat.subAgents.fallbackTitle")}),s?o.jsx(z,{nowrap:!0,items:[o.jsx("span",{style:{color:O(S)},children:H(S)}),e.pinned?c("chat.subAgents.pinned"):null,oe(e.subagentType,f,{compact:!0})]}):o.jsxs(o.Fragment,{children:[o.jsx(W,{color:S==="running"?"processing":S==="completed"?"success":S==="error"||S==="failed"?"error":S==="cancelled"?"warning":"default",style:k,children:H(S)}),e.pinned?o.jsx(W,{color:"warning",style:k,children:c("chat.subAgents.pinned")}):null,oe(e.subagentType,f)]})]}),s?o.jsx(z,{block:!0,items:[e.childSessionId.slice(0,8),e.updatedAt,e.lastHeartbeatAt?`${c("chat.subAgents.heartbeat")}: ${e.lastHeartbeatAt}`:null,typeof e.roundCount=="number"?`${c("chat.subAgents.round")} ${e.roundCount+1}`:null]}):o.jsxs(M,{type:"secondary",style:{display:"block",minWidth:0,fontSize:12,marginTop:2},children:[e.childSessionId.slice(0,8),e.updatedAt?` • ${e.updatedAt}`:"",e.lastHeartbeatAt?` • ${c("chat.subAgents.heartbeat")}: ${e.lastHeartbeatAt}`:"",typeof e.roundCount=="number"?` • ${c("chat.subAgents.round")} ${e.roundCount+1}`:""]}),e.outputPreview?o.jsx(M,{type:"secondary",style:{display:"block",minWidth:0,marginTop:s?4:p.marginXS,fontSize:s?11:13,lineHeight:s?1.35:void 0},ellipsis:!0,children:e.outputPreview}):null,e.error?o.jsx(M,{type:"danger",style:{display:"block",minWidth:0,marginTop:s?4:p.marginXS,fontSize:s?11:void 0,lineHeight:s?1.35:void 0},children:e.error}):null]}),o.jsxs(I,{gap:s?4:8,wrap:!0,style:{width:"100%",minWidth:0,paddingTop:s?2:0},children:[o.jsx($,{size:"small",type:s?"text":"default",style:C,disabled:R,onClick:()=>b(e.childSessionId),children:c("chat.subAgents.open")}),o.jsx($,{size:"small",type:s?"text":"default",style:C,loading:i,disabled:d||r||P,"data-testid":`sub-agent-continue-${e.childSessionId}`,onClick:()=>E(e.childSessionId),children:c("chat.subAgents.continue")}),o.jsx(Te,{trigger:["click"],menu:{items:[{key:"regenerate",label:c("chat.actions.regenerate")},{key:"error_retry",label:c("chat.actions.retryFailed")}],onClick:({key:h})=>{w(e.childSessionId,h)}},disabled:d||P||i,children:o.jsx($,{size:"small",type:s?"text":"default",style:C,loading:r,disabled:d||P||i,"data-testid":`sub-agent-retry-${e.childSessionId}`,children:c("chat.subAgents.retry")})}),typeof e.pinned=="boolean"?o.jsx($,{size:"small",type:s?"text":"default",style:C,disabled:R,onClick:()=>T(e.childSessionId,e.pinned),children:e.pinned?c("chat.actions.unpin"):c("chat.actions.pin")}):null,o.jsx($,{danger:!0,type:s?"text":"default",style:C,size:"small",loading:d,disabled:r,"data-testid":`sub-agent-delete-${e.childSessionId}`,onClick:()=>y(e.childSessionId),children:c("common.delete")})]})]})},(e,t)=>e.item===t.item&&e.index===t.index&&e.compact===t.compact&&e.isRetrying===t.isRetrying&&e.isContinuing===t.isContinuing&&e.isDeleting===t.isDeleting&&e.subagentProfilesById===t.subagentProfilesById&&e.onOpenChild===t.onOpenChild&&e.onContinueChild===t.onContinueChild&&e.onRetryChild===t.onRetryChild&&e.onTogglePin===t.onTogglePin&&e.onDeleteChild===t.onDeleteChild),{Text:B}=ie,{useToken:de}=ue,Oe="chat-session-sub-agents-collapsed:",De=3,Me=600,U=e=>{const t=(e||"").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"},Fe=(e,t)=>{if(t&&t.trim())return t;if(e.isRunning)return"running";if(e.lastRunStatus&&e.lastRunStatus.trim())return e.lastRunStatus;const s=e.messageCount??0;return s>2?"completed":(s>0,"pending")},ce=e=>`${Oe}${e}`,X=e=>{if(typeof window>"u")return!1;try{const t=window.localStorage.getItem(ce(e));return t==="1"?!0:t==="0"?!1:null}catch{return null}},Be=(e,t)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(ce(e),t?"1":"0")}catch{}},ae=(e,t)=>e.childSessionId===t.childSessionId&&e.title===t.title&&e.status===t.status&&e.error===t.error&&e.lastHeartbeatAt===t.lastHeartbeatAt&&e.lastEventAt===t.lastEventAt&&e.outputPreview===t.outputPreview&&e.pinned===t.pinned&&e.updatedAt===t.updatedAt&&e.isRunning===t.isRunning&&e.messageCount===t.messageCount&&e.lastRunStatus===t.lastRunStatus&&e.lastRunError===t.lastRunError&&e.subagentType===t.subagentType&&e.roundCount===t.roundCount,Ke=({parentSessionId:e,compact:t=!1})=>{const{t:s}=N(),{token:r}=de(),[i,d]=u.useState(()=>X(e)??!1),[f,b]=u.useState(null),[E,w]=u.useState(null),[T,y]=u.useState(null),p=x(n=>xe(e)(n)),c=x(n=>n.chats),k=x(n=>n.loadChatHistory),C=x(n=>n.refreshChats),S=x(n=>n.markOptimisticStart),P=x(n=>n.markRetryStart),R=x(n=>n.markSettleTimeout),H=x(n=>n.pinSession),O=x(n=>n.unpinSession),h=x(n=>n.applyChildProgress),G=x(n=>n.clearChildProgress),{byId:ge}=_e(),q=u.useRef(new Map),K=u.useMemo(()=>Object.entries(p).map(([n,g])=>({childSessionId:n,...g})),[p]),Y=u.useMemo(()=>c.filter(n=>n.kind==="child"&&n.parentSessionId===e).sort((n,g)=>{const m=Date.parse(n.updatedAt||"")||0;return(Date.parse(g.updatedAt||"")||0)-m}),[c,e]),v=u.useMemo(()=>{const n=new Map(K.map(l=>[l.childSessionId,l])),g=q.current,m=[];for(const l of Y){const a=n.get(l.id),A={childSessionId:l.id,title:l.title||(a==null?void 0:a.title),status:U(Fe(l,a==null?void 0:a.status)),error:(a==null?void 0:a.error)||l.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:l.pinned,updatedAt:l.updatedAt,isRunning:l.isRunning,messageCount:l.messageCount,lastRunStatus:l.lastRunStatus,lastRunError:l.lastRunError,subagentType:l.subagentType??null},D=g.get(l.id);m.push(D&&ae(D,A)?D:A),n.delete(l.id)}for(const l of n.values()){const a={childSessionId:l.childSessionId,title:l.title,status:U(l.status),error:l.error,lastHeartbeatAt:l.lastHeartbeatAt,lastEventAt:l.lastEventAt,outputPreview:l.outputPreview,roundCount:l.roundCount},A=g.get(l.childSessionId);m.push(A&&ae(A,a)?A:a)}return q.current=new Map(m.map(l=>[l.childSessionId,l])),m},[Y,K]);u.useEffect(()=>{d(X(e)??!1)},[e]),u.useEffect(()=>{X(e)===null&&d(v.length>De)},[e,v.length]);const he=u.useCallback(()=>{d(n=>{const g=!n;return Be(e,g),g})},[e]),J=u.useCallback(n=>n instanceof Error&&n.message.trim()?n.message:s("chat.subAgents.runChildFailed"),[s]),Q=u.useCallback(async(n,g="regenerate")=>{b(n),h(e,n,{status:"running",error:void 0,lastEventAt:new Date().toISOString()}),P(n);try{const m=await F.executeTool({tool_name:"SubAgent",session_id:e,parameters:[{name:"action",value:"run"},{name:"child_session_id",value:n},{name:"reset_to_last_user",value:g==="error_retry"?"false":"true"}]});if(!m.success)throw new Error(m.result||"Failed to run sub-agent");h(e,n,{status:"running",error:void 0,lastEventAt:new Date().toISOString()}),await k(n,{mode:"replace"}),await C()}catch(m){R(n),h(e,n,{status:"error",error:J(m),lastEventAt:new Date().toISOString()})}finally{b(m=>m===n?null:m)}},[k,e,C,P,R,J,h]),V=u.useCallback(async n=>{const g=typeof window<"u"?window.prompt.bind(window):null;if(!g)return;const m=g("Send a follow-up message to this sub-agent:","Continue from where you left off.");if(m===null)return;const l=m.trim();if(!l){h(e,n,{status:"error",error:"Follow-up message cannot be empty.",lastEventAt:new Date().toISOString()});return}w(n),h(e,n,{status:"running",error:void 0,lastEventAt:new Date().toISOString()}),S(n);try{const a=await F.executeTool({tool_name:"SubAgent",session_id:e,parameters:[{name:"action",value:"send_message"},{name:"child_session_id",value:n},{name:"message",value:l},{name:"auto_run",value:"true"}]});if(!a.success)throw new Error(a.result||"Follow-up failed");let A="running";try{JSON.parse(a.result).status==="pending"&&(A="pending")}catch{A="running"}h(e,n,{status:A,error:void 0,lastEventAt:new Date().toISOString()}),await C()}catch(a){R(n),h(e,n,{status:"error",error:a instanceof Error&&a.message.trim()?a.message:s("chat.subAgents.continueChildFailed"),lastEventAt:new Date().toISOString()})}finally{w(a=>a===n?null:a)}},[e,C,S,R,h,s]),Z=u.useCallback(async n=>{y(n);try{const g=await F.executeTool({tool_name:"SubAgent",session_id:e,parameters:[{name:"action",value:"delete"},{name:"child_session_id",value:n}]});if(!g.success)throw new Error(g.result||"Failed to delete sub-agent");G(e,n),await C()}finally{y(g=>g===n?null:g)}},[G,e,C]),pe=u.useCallback(n=>{Ae(n),k(n)},[k]),fe=u.useCallback(n=>{V(n)},[V]),me=u.useCallback((n,g)=>{Q(n,g)},[Q]),ye=u.useCallback((n,g)=>{g?O(n):H(n)},[H,O]),be=u.useCallback(n=>{Z(n)},[Z]);if(v.length===0)return null;const ee=o.jsxs(B,{strong:!0,children:[s("chat.subAgents.title")," ",o.jsxs(B,{type:"secondary",children:["(",v.length,")"]})]}),te=o.jsx($,{type:"text",size:"small",icon:i?o.jsx(ve,{}):o.jsx(Ee,{}),onClick:he,"data-testid":"sub-agents-toggle",style:t?{paddingInline:4}:void 0,children:s(i?"chat.subAgents.expand":"chat.subAgents.collapse")}),ne=i?o.jsx(B,{type:"secondary","data-testid":"sub-agents-collapsed-hint",children:s("chat.subAgents.hiddenHint",{count:v.length})}):o.jsx(I,{vertical:!0,gap:t?r.marginXS:r.marginSM,"data-testid":"sub-agents-list",style:{width:"100%",minWidth:0,maxHeight:`${Me}px`,overflowY:"auto",overflowX:"hidden",paddingRight:t?0:r.paddingXS},children:v.map((n,g)=>o.jsx(He,{item:n,index:g,compact:t,isRetrying:f===n.childSessionId,isContinuing:E===n.childSessionId,isDeleting:T===n.childSessionId,subagentProfilesById:ge,onOpenChild:pe,onContinueChild:fe,onRetryChild:me,onTogglePin:ye,onDeleteChild:be},n.childSessionId))}),se=!i&&v.length>1?o.jsx(Xe,{items:v}):null;return t?o.jsxs("section",{"data-testid":"sub-agents-panel",style:{width:"100%",minWidth:0,marginBottom:r.marginXS,overflow:"hidden"},children:[o.jsxs(I,{align:"center",justify:"space-between",gap:r.marginXS,style:{padding:`${r.paddingXXS??2}px 0 ${r.paddingXS}px`,borderBottom:`1px solid ${r.colorBorderSecondary}`},children:[o.jsx("div",{style:{flex:1,minWidth:0},children:ee}),o.jsx("div",{style:{flex:"0 0 auto"},children:te})]}),o.jsxs("div",{style:{padding:`${r.paddingXS}px 0 0`},children:[ne,se]})]}):o.jsxs(ke,{size:"small",className:"lotus-settings-card",style:{marginBottom:r.marginMD},"data-testid":"sub-agents-panel",title:ee,extra:te,children:[ne,se]})},Xe=({items:e})=>{const{token:t}=de(),{t:s}=N(),r=e.reduce((d,f)=>{const b=U(f.status);return b==="completed"?d.completed++:b==="running"?d.running++:b==="error"||b==="failed"?d.error++:d.pending++,d},{completed:0,running:0,error:0,pending:0}),i=[];return r.completed>0&&i.push(s("chat.subAgents.summaryCompleted",{count:r.completed})),r.running>0&&i.push(s("chat.subAgents.summaryRunning",{count:r.running})),r.pending>0&&i.push(s("chat.subAgents.summaryPending",{count:r.pending})),r.error>0&&i.push(s("chat.subAgents.summaryFailed",{count:r.error})),i.length===0?null:o.jsx(z,{block:!0,items:i,style:{marginTop:t.marginXS}})};export{Ke as SubAgentsPanel};
@@ -0,0 +1,8 @@
1
+ import{j as s}from"./vendor-markdown-DZuK0SxV.js";import{R as ge,u as ye,a as r}from"./vendor-i18n-BNURlJ23.js";import{u as b,b as he,h as ve,j as xe,k as I,r as _e,l as Ce,s as Ee,a as X,m as L,C as A}from"./App-BYqor0NW.js";import{M as Se,j as qe,E as Y,u as Re,a8 as we,a9 as H,S as Z,Q as ke,t as be}from"./vendor-antd-C8lKwvI6.js";import"./vendor-mermaid-C1Gk9PtT.js";import"./main-CEmqYfJe.js";const Te="_questionCard_15meh_1",je="_questionHeader_15meh_8",De="_headerLeft_15meh_27",Be="_questionIcon_15meh_35",Ne="_questionText_15meh_40",Pe="_collapseBtn_15meh_52",Qe="_questionBody_15meh_57",Ie="_optionsGroup_15meh_61",Le="_optionItem_15meh_65",Ae="_customHint_15meh_81",He="_questionFooter_15meh_93",a={questionCard:Te,questionHeader:je,headerLeft:De,questionIcon:Be,questionText:Ne,collapseBtn:Pe,questionBody:Qe,optionsGroup:Ie,optionItem:Le,customHint:Ae,questionFooter:He},{Text:T}=qe,{useToken:Fe}=be,Ge=n=>{const f=(n||"").replace(/\\r\\n/g,`
2
+ `).replace(/\\n/g,`
3
+ `).replace(/\r\n?/g,`
4
+ `).trim();return f?f.includes(`
5
+ `)?f:f.replace(/\s+(?=\d+[).]\s)/g,`
6
+ `).replace(/\s+(?=[一二三四五六七八九十]+[、.]\s)/g,`
7
+ `).replace(/\s+(?=[-*•]\s)/g,`
8
+ `):""};const ee=({sessionId:n,onResponseSubmitted:f,onQuestionAppeared:F})=>{const{t:v}=ye(),{token:x}=Fe(),{message:j}=Se.useApp(),[g,C]=r.useState(null),[D,G]=r.useState(!1),[te,B]=r.useState(!0),[R,w]=r.useState(!1),u=r.useRef(0),m=r.useRef(0),p=r.useRef(null),c=r.useRef(null),_=r.useRef(0),k=r.useRef(F);k.current=F;const E=r.useCallback(()=>{_.current+=1,_.current},[n]),[N,ne]=r.useState(()=>typeof document>"u"?!0:!document.hidden),{markRespondStart:oe,markSettleTimeout:M,applyExecutionStarted:re,setPendingQuestion:z,clearPendingQuestion:S,sessionModelRef:y,sessionReasoningEffort:le,inputReasoningEffort:se,isCurrentSession:P}=b(he(e=>{var l,i,d,J;const t=n?e.chats.find(pe=>pe.id===n)??null:null;return{markRespondStart:e.markRespondStart,markSettleTimeout:e.markSettleTimeout,applyExecutionStarted:e.applyExecutionStarted,setPendingQuestion:e.setPendingQuestion,clearPendingQuestion:e.clearPendingQuestion,sessionModelRef:((l=t==null?void 0:t.config)==null?void 0:l.model_ref)??null,sessionReasoningEffort:((i=t==null?void 0:t.config)==null?void 0:i.reasoningEffort)??null,inputReasoningEffort:n?((J=(d=e.inputStates)==null?void 0:d[n])==null?void 0:J.reasoningEffort)??null:null,isCurrentSession:e.currentSessionId===n}})),o=b(ve(n)),q=xe(y),O=I(e=>e.currentProvider),V=I(e=>e.providerConfig),ie=r.useMemo(()=>_e(V,q,(y==null?void 0:y.provider)??O),[q,y==null?void 0:y.provider,V,O]),ue=r.useMemo(()=>n?Ce(n):void 0,[n]),ae=le??se??ue??ie??"medium",h=r.useCallback(()=>{var t,l;const e=(t=b.getState().executionBySession)==null?void 0:t[n];return e?{phase:e.phase,generation:e.generation,backendRunId:e.backendRunId??null,backendIsRunning:e.backend.isRunning,hasPendingQuestion:e.interaction.pendingQuestion!=null,pendingQuestionToolCallId:((l=e.interaction.pendingQuestion)==null?void 0:l.toolCallId)??null,tokenCount:e.stream.tokenCount,hasTokens:e.stream.hasTokens,activeReasons:e.activeReasons}:null},[n]),$=b(Ee(n)),K=r.useCallback(async()=>{const e=_.current;try{const t=await X.get(`respond/${n}/pending`);if(e!==_.current)return;if(t.has_pending_question){const l={question:t.question??"",options:t.options??[],allowCustom:t.allow_custom??!0,toolCallId:t.tool_call_id??null},i=L({sessionId:n,...l});if(c.current===i){u.current=0,m.current=0;return}c.current=null,z(n,l),u.current=0,m.current=0}else c.current=null,S(n),p.current=null,u.current+=1,u.current>=6?m.current=2:u.current>=2&&(m.current=1)}catch(t){if(e!==_.current)return;if(t instanceof Error&&t.message.includes("404")){c.current=null,S(n),p.current=null,u.current+=1;return}c.current=null,S(n),p.current=null,u.current+=1,u.current>=6?m.current=2:u.current>=2&&(m.current=1),console.error("Failed to fetch pending question:",t)}finally{if(e!==_.current)return;B(!1)}},[n,z,S]);r.useEffect(()=>{E(),u.current=0,m.current=0,p.current=null,c.current=null,B(!0),C(null),w(!1)},[n,E]),r.useEffect(()=>{if(typeof document>"u")return;const e=()=>{ne(!document.hidden)};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[]),r.useEffect(()=>{var e;if(o){const t=L({sessionId:n,question:o.question,options:o.options,allowCustom:o.allowCustom,toolCallId:o.toolCallId});p.current===t||(C(null),w(!1),(e=k.current)==null||e.call(k)),p.current=t,c.current!==null&&c.current!==t&&(c.current=null)}else p.current=null},[n,o,o==null?void 0:o.allowCustom,o==null?void 0:o.options,o==null?void 0:o.question,o==null?void 0:o.toolCallId]);const U=r.useCallback(()=>{if(o)return null;if($)return P?N?5e3:15e3:null;if(!P||!N)return null;const e=m.current;return e===0?3e4:e===1?6e4:12e4},[o,$,P,N]);r.useEffect(()=>{if(o){B(!1);return}let e=!1,t=null;const l=async()=>{if(e||D||(await K(),e))return;const i=U();i!==null&&(t=setTimeout(l,i))};return l(),()=>{e=!0,t&&clearTimeout(t)}},[o,K,U,D]),r.useEffect(()=>{if(typeof window>"u")return;const e=t=>{var d;const i=((d=t.detail)==null?void 0:d.sessionId)??null;!i||i!==n||(h(),E(),C(null),p.current=null,u.current=0)};return window.addEventListener(A,e),()=>{window.removeEventListener(A,e)}},[n,E,h]);const ce=r.useCallback(e=>{C(e)},[]),de=async()=>{if(!g||g==="custom"){j.warning(v("components.questionDialog.selectOptionWarning"));return}G(!0),o==null||o.toolCallId,h(),E();const e=oe(n,(o==null?void 0:o.toolCallId)??null);h(),await new Promise(t=>setTimeout(t,0));try{const t={};I.getState().isProviderModelRefEnabled()&&q&&(t.model_ref=q,t.provider=q.provider);const l=await X.post(`respond/${n}`,{response:g,reasoning_effort:ae,...t});h(),j.success(v("components.questionDialog.responseSubmitted")),c.current=o?L({sessionId:n,question:o.question,options:o.options,allowCustom:o.allowCustom,toolCallId:o.toolCallId}):null,C(null),u.current=0,S(n),typeof window<"u"&&window.dispatchEvent(new CustomEvent(A,{detail:{sessionId:n}}));const i=l==null?void 0:l.auto_resume_status,d=l==null?void 0:l.run_id;h(),i==="started"||i==="already_running"?(re(n,d??"",e),h(),void 0):(i==="error"||!i)&&(console.error("[QuestionDialog] Failed to auto-resume agent execution"),M(n)),f==null||f()}catch(t){console.error("Failed to submit response:",t),j.error(t instanceof Error?t.message:v("components.questionDialog.submitFailed")),M(n)}finally{G(!1)}};if(te||!o)return null;const{question:fe,options:Q,allowCustom:me}=o,W=Ge(fe);return s.jsxs("div",{className:a.questionCard,style:{background:x.colorBgContainer,borderColor:x.colorBorderSecondary,border:`1px solid ${x.colorBorderSecondary}`},children:[s.jsxs("div",{className:a.questionHeader,"data-collapsed":R?"true":"false",onClick:()=>w(e=>!e),role:"button",tabIndex:0,onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&w(t=>!t)},children:[s.jsxs("span",{className:a.headerLeft,children:[s.jsx("span",{className:a.questionIcon,children:"🤔"}),s.jsx(T,{strong:!0,className:a.questionText,style:{color:x.colorPrimary,whiteSpace:"pre-wrap"},title:R?W:void 0,children:W})]}),s.jsx(Y,{type:"text",size:"small",icon:R?s.jsx(Re,{}):s.jsx(we,{}),className:a.collapseBtn,tabIndex:-1})]}),!R&&s.jsxs("div",{className:a.questionBody,children:[s.jsx(H.Group,{className:a.optionsGroup,value:g,onChange:e=>ce(e.target.value),children:s.jsxs(Z,{direction:"vertical",size:4,style:{width:"100%"},children:[Q==null?void 0:Q.map((e,t)=>s.jsx(H,{value:e,className:a.optionItem,children:s.jsx(T,{style:{color:x.colorText},children:e})},t)),me&&s.jsx(H,{value:"custom",className:a.optionItem,children:s.jsxs(Z,{size:4,children:[s.jsx(ke,{}),s.jsx(T,{style:{color:x.colorText},children:v("components.questionDialog.otherTypeBelow")})]})})]})}),g==="custom"&&s.jsx("div",{className:a.customHint,children:s.jsx(T,{type:"secondary",style:{fontSize:12},children:v("components.questionDialog.customAnswerTip")})}),g&&g!=="custom"&&s.jsx("div",{className:a.questionFooter,children:s.jsx(Y,{type:"primary",size:"small",onClick:de,loading:D,children:v("components.questionDialog.confirm")})})]})]})};ee.displayName="QuestionDialog";const Me=ge.memo(ee);Me.displayName="QuestionDialog";export{Me as QuestionDialog,Me as default};
@@ -0,0 +1 @@
1
+ import{j as a}from"./vendor-markdown-DZuK0SxV.js";import{t as $,v,w as B}from"./App-BYqor0NW.js";import{a as l,u as E}from"./vendor-i18n-BNURlJ23.js";import{K as T,t as M,l as L,af as D,a7 as K,I as F}from"./vendor-antd-C8lKwvI6.js";import"./vendor-mermaid-C1Gk9PtT.js";import"./main-CEmqYfJe.js";const z=({visible:p,searchText:k,onSelect:I,onCancel:f,onAutoComplete:g})=>{const[o,i]=l.useState([]),[c,R]=l.useState([]),[d,u]=l.useState(0),[N,j]=l.useState(!1),S=l.useRef(null),h=l.useRef(null);l.useEffect(()=>{if(!p)return;const s=$.getInstance();(async()=>{j(!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{j(!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{I({name:s.name,type:s.type,id:s.id})}catch(e){console.error(`[CommandSelector] Failed to select command '${s.name}':`,e)}},[I]);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"}},U=({visible:p,onSelect:k,onCancel:I,searchText:f,onAutoComplete:g})=>{const{token:o}=X(),{t:i}=E(),{containerRef:c,selectedItemRef:R,filteredCommands:d,selectedIndex:u,setSelectedIndex:N,isLoading:j,handleCommandSelect:S}=z({visible:p,searchText:f,onSelect:k,onCancel:I,onAutoComplete:g});if(!p)return null;if(j)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{U as default};
@@ -1 +1 @@
1
- import{j as n}from"./vendor-markdown-DZuK0SxV.js";import{u as V,a as d}from"./vendor-i18n-BNURlJ23.js";import{u as h,b as H,c as W,d as B,e as A,f as Q,A as z,g as G,o as Y,i as X}from"./App-Agd9FqjU.js";import{t as Z,M as J,Y as ee,O as te,Z as se,$ as ne,a0 as oe,a1 as ae,a2 as ie,a3 as le,W as re,a4 as de,X as ce,j as me,z as ue,a5 as pe,l as ge}from"./vendor-antd-C8lKwvI6.js";import"./vendor-mermaid-C1Gk9PtT.js";import"./main-C-I4C72U.js";const be=(()=>{let e=null,o=[],a=new Map;return i=>{if(i===e)return o;const p=i.map(c=>{const l=a.get(c.id),g={id:c.id,title:c.title,kind:c.kind,pinned:c.pinned,updatedAt:c.updatedAt,workspacePath:c.config.workspacePath};return l&&l.title===g.title&&l.kind===g.kind&&l.pinned===g.pinned&&l.updatedAt===g.updatedAt&&l.workspacePath===g.workspacePath?l:g}),P=p.length===o.length&&p.every((c,l)=>c===o[l]);return e=i,a=new Map(p.map(c=>[c.id,c])),P?o:(o=p,p)}})(),fe=[{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"]}],ye=(e,o)=>{const a=[e.title,e.id,e.kind||"root"];return e.pinned&&a.push("pinned","pin"),o&&a.push("running","processing"),e.workspacePath&&a.push(e.workspacePath),e.updatedAt&&a.push(e.updatedAt),a.filter(Boolean)},ke=(e,o,a)=>{const i=[];if(e.kind==="child"?i.push(o):i.push(a),e.workspacePath&&i.push(e.workspacePath),e.updatedAt)try{i.push(new Date(e.updatedAt).toLocaleString())}catch{i.push(e.updatedAt)}return i.join(" • ")},Se=(e,o)=>{const a=o.trim().toLowerCase();return a?e.filter(i=>[i.title,i.subtitle||"",...i.keywords].join(" ").toLowerCase().includes(a)):e},we=e=>{if(!(e instanceof HTMLElement))return!1;const o=e.tagName.toLowerCase();return e.isContentEditable?!0:o==="input"||o==="textarea"||o==="select"},v="__LOTUS_COMMAND_PALETTE_FORCE_OPEN__",ve=()=>{const{t:e}=V(),{token:o}=Z.useToken(),a=typeof document<"u"&&document.body.getAttribute("data-vdi-safe")==="true",{message:i}=J.useApp(),p=h(t=>be(t.chats)),P=h(t=>t.addChat),c=h(t=>t.lastSelectedPromptId),l=h(t=>t.systemPrompts),g=h(H(t=>Object.entries(t.executionBySession).filter(([,s])=>X(s.phase)).map(([s])=>s).sort())),[b,f]=d.useState(()=>typeof window>"u"?!1:window[v]?(delete window[v],!0):!1),[j,x]=d.useState(""),[k,S]=d.useState(0),E=d.useRef(null),I=d.useRef(null),O=W(t=>t.open),C=B(t=>t.toggleTheme),M=B(t=>t.themeMode),K=A(t=>t.sidebar.collapsed),L=A(t=>t.setSidebarCollapsed),T=Q(t=>t.mode),N=Q(t=>t.toggleMode),R=d.useCallback(async()=>{var F,q;const t=l.find(w=>w.id===c),s=(t==null?void 0:t.id)||(l.length>0?((F=l.find(w=>w.id==="general_assistant"))==null?void 0:F.id)||l[0].id:""),m=await P({title:e("chat.sidebar.newSession"),createdAt:Date.now(),messages:[],config:{systemPromptId:s,baseSystemPrompt:(t==null?void 0:t.content)||(l.length>0?((q=l.find(w=>w.id==="general_assistant"))==null?void 0:q.content)||l[0].content:""),lastUsedEnhancedPrompt:null}}),{activeLeafId:r,setLeafSessionId:y,setActiveLeafId:U}=A.getState();y(r,m),U(r)},[P,c,l,e]),_=d.useMemo(()=>{const t=fe.filter(s=>!(T==="simple"&&z.has(s.tabKey))).map(s=>({id:s.id,kind:"action",title:e(s.titleKey,s.fallbackTitle),subtitle:e(s.subtitleKey||"commandPalette.groups.settings",s.fallbackSubtitle||"System settings"),keywords:[s.tabKey,s.badge||"","settings","config",...s.keywords||[]],icon:n.jsx(ee,{}),badge:s.badge,onSelect:()=>{O("chat",s.tabKey)}}));return[{id:"new-session",kind:"action",title:e("commandPalette.actions.newSession","Create New Session"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["new","create","session","chat","conversation"],icon:n.jsx(te,{}),badge:e("commandPalette.badges.quickAction","Action"),onSelect:async()=>{await R()}},{id:"toggle-theme",kind:"action",title:M==="dark"?e("commandPalette.actions.switchToLight","Switch to Light Mode"):e("commandPalette.actions.switchToDark","Switch to Dark Mode"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["theme","dark","light","mode","appearance","toggle","color"],icon:n.jsx(se,{}),badge:M==="dark"?"☀️":"🌙",onSelect:()=>{C()}},{id:"toggle-sidebar",kind:"action",title:K?e("commandPalette.actions.showSidebar","Show Sidebar"):e("commandPalette.actions.hideSidebar","Hide Sidebar"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["sidebar","toggle","hide","show","panel","menu"],icon:K?n.jsx(ne,{}):n.jsx(oe,{}),badge:"Layout",onSelect:()=>{L(!K)}},{id:"split-pane",kind:"action",title:e("commandPalette.actions.splitPane","Split Pane"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["split","pane","multi","dual","side","layout"],icon:n.jsx(ae,{}),badge:"Layout",onSelect:()=>{const{tree:s,activeLeafId:m,splitLeaf:r}=A.getState();G(s).length<4&&r(m,"vertical")}},...t,{id:"toggle-experience-mode",kind:"action",title:T==="simple"?e("commandPalette.actions.switchToAdvanced","Switch to Advanced Mode"):e("commandPalette.actions.switchToSimple","Switch to Simple Mode"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["mode","simple","advanced","beginner","expert","experience","complexity"],icon:n.jsx(ie,{}),badge:T==="simple"?"Simple":"Advanced",onSelect:()=>{N()}}]},[R,O,C,M,K,L,T,N,e]),D=d.useMemo(()=>{if(!b)return[];const t=new Set(g);return p.map(s=>{const m=t.has(s.id);return{id:`session-${s.id}`,kind:"session",title:s.title,subtitle:ke(s,e("commandPalette.badges.childSession","Child session"),e("commandPalette.badges.rootSession","Session")),keywords:ye(s,m),icon:n.jsx(le,{}),badge:s.pinned?e("commandPalette.badges.pinned","Pinned"):m?e("commandPalette.badges.running","Running"):s.kind==="child"?e("commandPalette.badges.child","Child"):void 0,onSelect:()=>{Y(s.id)}}})},[b,g,p,e]),$=d.useMemo(()=>[..._,...D],[_,D]),u=d.useMemo(()=>Se($,j).slice(0,40),[$,j]);return d.useEffect(()=>{S(t=>u.length===0?0:Math.min(t,u.length-1))},[u.length]),d.useEffect(()=>{if(!b)return;const t=window.setTimeout(()=>{var s,m;(s=E.current)==null||s.focus(),(m=E.current)==null||m.select()},0);return()=>window.clearTimeout(t)},[b]),d.useEffect(()=>{if(typeof window>"u")return;const t=s=>{if((s.metaKey||s.ctrlKey)&&s.key.toLowerCase()==="k"){s.preventDefault(),f(r=>!r);return}if(b){if(s.key==="Escape"){s.preventDefault(),f(!1);return}if(!(we(s.target)&&s.key!=="ArrowUp"&&s.key!=="ArrowDown"&&s.key!=="Enter")){if(s.key==="ArrowDown"){s.preventDefault(),S(r=>u.length===0?0:(r+1)%u.length);return}if(s.key==="ArrowUp"){s.preventDefault(),S(r=>u.length===0?0:r===0?u.length-1:r-1);return}if(s.key==="Enter"){const r=u[k];if(!r)return;s.preventDefault(),(async()=>{try{await r.onSelect(),f(!1),x("")}catch(y){console.error("[CommandPalette] action failed",y),i.error(y instanceof Error?y.message:e("commandPalette.errors.actionFailed","Command failed"))}})()}}}};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[u,i,b,k,e]),d.useEffect(()=>{b||(x(""),S(0))},[b]),d.useEffect(()=>{typeof window>"u"||!window[v]||(delete window[v],f(!0))},[]),d.useEffect(()=>{const t=I.current;if(!t)return;const s=t.querySelector(`[data-command-index="${k}"]`);s==null||s.scrollIntoView({block:"nearest"})},[k]),n.jsx(re,{open:b,onCancel:()=>f(!1),footer:null,centered:!0,width:680,destroyOnClose:!0,className:"lotus-command-palette-modal",title:null,closable:!1,styles:{content:{padding:12,borderRadius:o.borderRadiusLG,overflow:"hidden",background:o.colorBgElevated,backdropFilter:a?"none":"blur(18px)",WebkitBackdropFilter:a?"none":"blur(18px)"},body:{padding:0},mask:{backdropFilter:a?"none":"blur(6px)",WebkitBackdropFilter:a?"none":"blur(6px)"}},children:n.jsxs("div",{className:"lotus-command-palette-shell",children:[n.jsxs("div",{className:"lotus-command-palette-search",children:[n.jsx(de,{style:{color:o.colorTextTertiary,fontSize:16}}),n.jsx(ce,{ref:E,value:j,onChange:t=>x(t.target.value),variant:"borderless",placeholder:e("commandPalette.searchPlaceholder","Search sessions, settings, and actions"),"aria-label":e("commandPalette.searchPlaceholder","Search sessions, settings, and actions"),suffix:n.jsx(me.Text,{type:"secondary",style:{fontSize:12},children:"⌘K"})})]}),n.jsxs("div",{className:"lotus-command-palette-hint",children:[n.jsx(ue,{}),n.jsx("span",{children:e("commandPalette.navigationHint","Use ↑↓ to navigate, Enter to open, and Esc to close.")})]}),n.jsx("div",{ref:I,className:"lotus-command-palette-list",role:"listbox",children:u.length===0?n.jsxs("div",{className:"lotus-command-palette-empty",children:[n.jsx(pe,{}),n.jsx("span",{children:e("commandPalette.empty","No matching commands")})]}):u.map((t,s)=>{const m=s===k;return n.jsxs("button",{type:"button",className:`lotus-command-palette-item ${m?"is-selected":""}`,"data-command-index":s,onMouseEnter:()=>S(s),onClick:()=>{(async()=>{try{await t.onSelect(),f(!1),x("")}catch(r){console.error("[CommandPalette] action failed",r),i.error(r instanceof Error?r.message:e("commandPalette.errors.actionFailed","Command failed"))}})()},children:[n.jsx("span",{className:"lotus-command-palette-item-icon",children:t.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:t.title}),t.badge?n.jsx(ge,{bordered:!1,children:t.badge}):null]}),t.subtitle?n.jsx("span",{className:"lotus-command-palette-item-subtitle",children:t.subtitle}):null]})]},t.id)})})]})})};export{ve as CommandPalette,ve as default};
1
+ import{j as n}from"./vendor-markdown-DZuK0SxV.js";import{u as V,a as d}from"./vendor-i18n-BNURlJ23.js";import{u as h,b as H,c as W,d as B,e as A,f as Q,A as z,g as G,o as Y,i as X}from"./App-BYqor0NW.js";import{t as Z,M as J,Y as ee,O as te,Z as se,$ as ne,a0 as oe,a1 as ae,a2 as ie,a3 as le,W as re,a4 as de,X as ce,j as me,z as ue,a5 as pe,l as ge}from"./vendor-antd-C8lKwvI6.js";import"./vendor-mermaid-C1Gk9PtT.js";import"./main-CEmqYfJe.js";const be=(()=>{let e=null,o=[],a=new Map;return i=>{if(i===e)return o;const p=i.map(c=>{const l=a.get(c.id),g={id:c.id,title:c.title,kind:c.kind,pinned:c.pinned,updatedAt:c.updatedAt,workspacePath:c.config.workspacePath};return l&&l.title===g.title&&l.kind===g.kind&&l.pinned===g.pinned&&l.updatedAt===g.updatedAt&&l.workspacePath===g.workspacePath?l:g}),P=p.length===o.length&&p.every((c,l)=>c===o[l]);return e=i,a=new Map(p.map(c=>[c.id,c])),P?o:(o=p,p)}})(),fe=[{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"]}],ye=(e,o)=>{const a=[e.title,e.id,e.kind||"root"];return e.pinned&&a.push("pinned","pin"),o&&a.push("running","processing"),e.workspacePath&&a.push(e.workspacePath),e.updatedAt&&a.push(e.updatedAt),a.filter(Boolean)},ke=(e,o,a)=>{const i=[];if(e.kind==="child"?i.push(o):i.push(a),e.workspacePath&&i.push(e.workspacePath),e.updatedAt)try{i.push(new Date(e.updatedAt).toLocaleString())}catch{i.push(e.updatedAt)}return i.join(" • ")},Se=(e,o)=>{const a=o.trim().toLowerCase();return a?e.filter(i=>[i.title,i.subtitle||"",...i.keywords].join(" ").toLowerCase().includes(a)):e},we=e=>{if(!(e instanceof HTMLElement))return!1;const o=e.tagName.toLowerCase();return e.isContentEditable?!0:o==="input"||o==="textarea"||o==="select"},v="__LOTUS_COMMAND_PALETTE_FORCE_OPEN__",ve=()=>{const{t:e}=V(),{token:o}=Z.useToken(),a=typeof document<"u"&&document.body.getAttribute("data-vdi-safe")==="true",{message:i}=J.useApp(),p=h(t=>be(t.chats)),P=h(t=>t.addChat),c=h(t=>t.lastSelectedPromptId),l=h(t=>t.systemPrompts),g=h(H(t=>Object.entries(t.executionBySession).filter(([,s])=>X(s.phase)).map(([s])=>s).sort())),[b,f]=d.useState(()=>typeof window>"u"?!1:window[v]?(delete window[v],!0):!1),[j,x]=d.useState(""),[k,S]=d.useState(0),E=d.useRef(null),I=d.useRef(null),O=W(t=>t.open),C=B(t=>t.toggleTheme),M=B(t=>t.themeMode),K=A(t=>t.sidebar.collapsed),L=A(t=>t.setSidebarCollapsed),T=Q(t=>t.mode),N=Q(t=>t.toggleMode),R=d.useCallback(async()=>{var F,q;const t=l.find(w=>w.id===c),s=(t==null?void 0:t.id)||(l.length>0?((F=l.find(w=>w.id==="general_assistant"))==null?void 0:F.id)||l[0].id:""),m=await P({title:e("chat.sidebar.newSession"),createdAt:Date.now(),messages:[],config:{systemPromptId:s,baseSystemPrompt:(t==null?void 0:t.content)||(l.length>0?((q=l.find(w=>w.id==="general_assistant"))==null?void 0:q.content)||l[0].content:""),lastUsedEnhancedPrompt:null}}),{activeLeafId:r,setLeafSessionId:y,setActiveLeafId:U}=A.getState();y(r,m),U(r)},[P,c,l,e]),_=d.useMemo(()=>{const t=fe.filter(s=>!(T==="simple"&&z.has(s.tabKey))).map(s=>({id:s.id,kind:"action",title:e(s.titleKey,s.fallbackTitle),subtitle:e(s.subtitleKey||"commandPalette.groups.settings",s.fallbackSubtitle||"System settings"),keywords:[s.tabKey,s.badge||"","settings","config",...s.keywords||[]],icon:n.jsx(ee,{}),badge:s.badge,onSelect:()=>{O("chat",s.tabKey)}}));return[{id:"new-session",kind:"action",title:e("commandPalette.actions.newSession","Create New Session"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["new","create","session","chat","conversation"],icon:n.jsx(te,{}),badge:e("commandPalette.badges.quickAction","Action"),onSelect:async()=>{await R()}},{id:"toggle-theme",kind:"action",title:M==="dark"?e("commandPalette.actions.switchToLight","Switch to Light Mode"):e("commandPalette.actions.switchToDark","Switch to Dark Mode"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["theme","dark","light","mode","appearance","toggle","color"],icon:n.jsx(se,{}),badge:M==="dark"?"☀️":"🌙",onSelect:()=>{C()}},{id:"toggle-sidebar",kind:"action",title:K?e("commandPalette.actions.showSidebar","Show Sidebar"):e("commandPalette.actions.hideSidebar","Hide Sidebar"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["sidebar","toggle","hide","show","panel","menu"],icon:K?n.jsx(ne,{}):n.jsx(oe,{}),badge:"Layout",onSelect:()=>{L(!K)}},{id:"split-pane",kind:"action",title:e("commandPalette.actions.splitPane","Split Pane"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["split","pane","multi","dual","side","layout"],icon:n.jsx(ae,{}),badge:"Layout",onSelect:()=>{const{tree:s,activeLeafId:m,splitLeaf:r}=A.getState();G(s).length<4&&r(m,"vertical")}},...t,{id:"toggle-experience-mode",kind:"action",title:T==="simple"?e("commandPalette.actions.switchToAdvanced","Switch to Advanced Mode"):e("commandPalette.actions.switchToSimple","Switch to Simple Mode"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["mode","simple","advanced","beginner","expert","experience","complexity"],icon:n.jsx(ie,{}),badge:T==="simple"?"Simple":"Advanced",onSelect:()=>{N()}}]},[R,O,C,M,K,L,T,N,e]),D=d.useMemo(()=>{if(!b)return[];const t=new Set(g);return p.map(s=>{const m=t.has(s.id);return{id:`session-${s.id}`,kind:"session",title:s.title,subtitle:ke(s,e("commandPalette.badges.childSession","Child session"),e("commandPalette.badges.rootSession","Session")),keywords:ye(s,m),icon:n.jsx(le,{}),badge:s.pinned?e("commandPalette.badges.pinned","Pinned"):m?e("commandPalette.badges.running","Running"):s.kind==="child"?e("commandPalette.badges.child","Child"):void 0,onSelect:()=>{Y(s.id)}}})},[b,g,p,e]),$=d.useMemo(()=>[..._,...D],[_,D]),u=d.useMemo(()=>Se($,j).slice(0,40),[$,j]);return d.useEffect(()=>{S(t=>u.length===0?0:Math.min(t,u.length-1))},[u.length]),d.useEffect(()=>{if(!b)return;const t=window.setTimeout(()=>{var s,m;(s=E.current)==null||s.focus(),(m=E.current)==null||m.select()},0);return()=>window.clearTimeout(t)},[b]),d.useEffect(()=>{if(typeof window>"u")return;const t=s=>{if((s.metaKey||s.ctrlKey)&&s.key.toLowerCase()==="k"){s.preventDefault(),f(r=>!r);return}if(b){if(s.key==="Escape"){s.preventDefault(),f(!1);return}if(!(we(s.target)&&s.key!=="ArrowUp"&&s.key!=="ArrowDown"&&s.key!=="Enter")){if(s.key==="ArrowDown"){s.preventDefault(),S(r=>u.length===0?0:(r+1)%u.length);return}if(s.key==="ArrowUp"){s.preventDefault(),S(r=>u.length===0?0:r===0?u.length-1:r-1);return}if(s.key==="Enter"){const r=u[k];if(!r)return;s.preventDefault(),(async()=>{try{await r.onSelect(),f(!1),x("")}catch(y){console.error("[CommandPalette] action failed",y),i.error(y instanceof Error?y.message:e("commandPalette.errors.actionFailed","Command failed"))}})()}}}};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[u,i,b,k,e]),d.useEffect(()=>{b||(x(""),S(0))},[b]),d.useEffect(()=>{typeof window>"u"||!window[v]||(delete window[v],f(!0))},[]),d.useEffect(()=>{const t=I.current;if(!t)return;const s=t.querySelector(`[data-command-index="${k}"]`);s==null||s.scrollIntoView({block:"nearest"})},[k]),n.jsx(re,{open:b,onCancel:()=>f(!1),footer:null,centered:!0,width:680,destroyOnClose:!0,className:"lotus-command-palette-modal",title:null,closable:!1,styles:{content:{padding:12,borderRadius:o.borderRadiusLG,overflow:"hidden",background:o.colorBgElevated,backdropFilter:a?"none":"blur(18px)",WebkitBackdropFilter:a?"none":"blur(18px)"},body:{padding:0},mask:{backdropFilter:a?"none":"blur(6px)",WebkitBackdropFilter:a?"none":"blur(6px)"}},children:n.jsxs("div",{className:"lotus-command-palette-shell",children:[n.jsxs("div",{className:"lotus-command-palette-search",children:[n.jsx(de,{style:{color:o.colorTextTertiary,fontSize:16}}),n.jsx(ce,{ref:E,value:j,onChange:t=>x(t.target.value),variant:"borderless",placeholder:e("commandPalette.searchPlaceholder","Search sessions, settings, and actions"),"aria-label":e("commandPalette.searchPlaceholder","Search sessions, settings, and actions"),suffix:n.jsx(me.Text,{type:"secondary",style:{fontSize:12},children:"⌘K"})})]}),n.jsxs("div",{className:"lotus-command-palette-hint",children:[n.jsx(ue,{}),n.jsx("span",{children:e("commandPalette.navigationHint","Use ↑↓ to navigate, Enter to open, and Esc to close.")})]}),n.jsx("div",{ref:I,className:"lotus-command-palette-list",role:"listbox",children:u.length===0?n.jsxs("div",{className:"lotus-command-palette-empty",children:[n.jsx(pe,{}),n.jsx("span",{children:e("commandPalette.empty","No matching commands")})]}):u.map((t,s)=>{const m=s===k;return n.jsxs("button",{type:"button",className:`lotus-command-palette-item ${m?"is-selected":""}`,"data-command-index":s,onMouseEnter:()=>S(s),onClick:()=>{(async()=>{try{await t.onSelect(),f(!1),x("")}catch(r){console.error("[CommandPalette] action failed",r),i.error(r instanceof Error?r.message:e("commandPalette.errors.actionFailed","Command failed"))}})()},children:[n.jsx("span",{className:"lotus-command-palette-item-icon",children:t.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:t.title}),t.badge?n.jsx(ge,{bordered:!1,children:t.badge}):null]}),t.subtitle?n.jsx("span",{className:"lotus-command-palette-item-subtitle",children:t.subtitle}):null]})]},t.id)})})]})})};export{ve as CommandPalette,ve as default};
@@ -1 +1 @@
1
- import{j as s}from"./vendor-markdown-DZuK0SxV.js";import{u as y,a as c,i as d}from"./vendor-i18n-BNURlJ23.js";import{u as p,s as f,E as T}from"./App-Agd9FqjU.js";import{t as v,a6 as R,a7 as S,p as w,z as k,I as A,a3 as I,l as b,q as M}from"./vendor-antd-C8lKwvI6.js";import"./vendor-mermaid-C1Gk9PtT.js";import"./main-C-I4C72U.js";const C=5,D=5,$=5,E=o=>{if(!o)return"";try{const n=Date.now()-new Date(o).getTime();if(n<0)return"";const t=Math.floor(n/1e3);if(t<60)return d.t("chat.home.justNow");const l=Math.floor(t/60);if(l<60)return d.t("chat.home.minutesAgo",{count:l});const a=Math.floor(l/60);if(a<24)return d.t("chat.home.hoursAgo",{count:a});const r=Math.floor(a/24);return r<30?d.t("chat.home.daysAgo",{count:r}):new Date(o).toLocaleDateString()}catch{return""}},P=(o,n)=>n?"is-running":o.lastRunStatus==="error"?"is-error":o.pinned?"is-pinned":"is-idle",x=({chat:o,onOpen:n,textSecondary:t})=>{const{t:l}=y(),a=p(f(o.id)),r=o.config.workspacePath?o.config.workspacePath.split("/").pop()||o.config.workspacePath:null;return s.jsxs("button",{type:"button",className:"lotus-home-session-item",onClick:()=>n(o.id),children:[s.jsx("span",{className:`lotus-home-session-status ${P(o,a)}`}),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:E(o.updatedAt)}),r?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"lotus-home-session-meta-sep"}),s.jsxs("span",{children:[s.jsx(A,{style:{marginRight:3}}),r]})]}):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]})]}),a?s.jsx(b,{color:"green",bordered:!1,style:{margin:0,fontSize:11},children:l("chat.home.running")}):null,s.jsx(M,{className:"lotus-home-session-arrow"})]})},L=({onOpenSession:o})=>{const{t:n}=y(),{token:t}=v.useToken(),l=p(e=>e.chats),a=c.useCallback(e=>f(e)(p.getState()),[]),r=c.useMemo(()=>l.filter(e=>a(e.id)).slice(0,D),[l,a]),m=c.useMemo(()=>l.filter(e=>e.pinned&&!a(e.id)).slice(0,$),[l,a]),j=c.useMemo(()=>{const e=new Set(r.map(i=>i.id)),g=new Set(m.map(i=>i.id));return l.filter(i=>i.kind!=="child"&&!e.has(i.id)&&!g.has(i.id)).sort((i,h)=>{const N=i.updatedAt?new Date(i.updatedAt).getTime():i.createdAt;return(h.updatedAt?new Date(h.updatedAt).getTime():h.createdAt)-N}).slice(0,C)},[l,r,m]),u=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(R,{})}),s.jsxs("div",{className:"lotus-home-header-text",children:[s.jsx("h2",{style:{color:t.colorText},children:n("home.title","Welcome to Bodhi")}),s.jsx("p",{style:{color:t.colorTextSecondary},children:n("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(T,{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(S,{className:"lotus-home-section-icon",style:{color:"#52c41a"}}),s.jsx("span",{children:n("home.sections.running","Running Now")})]}),s.jsx("div",{className:"lotus-home-session-list",children:r.map(e=>s.jsx(x,{chat:e,onOpen:u,textSecondary:t.colorTextTertiary},e.id))})]}):null,m.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",style:{color:"#faad14"}}),s.jsx("span",{children:n("home.sections.pinned","Pinned")})]}),s.jsx("div",{className:"lotus-home-session-list",children:m.map(e=>s.jsx(x,{chat:e,onOpen:u,textSecondary:t.colorTextTertiary},e.id))})]}):null,j.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(k,{className:"lotus-home-section-icon"}),s.jsx("span",{children:n("home.sections.recent","Recent Sessions")})]}),s.jsx("div",{className:"lotus-home-session-list",children:j.map(e=>s.jsx(x,{chat:e,onOpen:u,textSecondary:t.colorTextTertiary},e.id))})]}):null,l.length===0?s.jsx("div",{className:"lotus-home-empty-hint",style:{color:t.colorTextTertiary},children:n("home.empty","No sessions yet. Create one to get started!")}):null]})]})})};export{L as HomeDashboard,L as default};
1
+ import{j as s}from"./vendor-markdown-DZuK0SxV.js";import{u as y,a as c,i as d}from"./vendor-i18n-BNURlJ23.js";import{u as p,s as f,E as T}from"./App-BYqor0NW.js";import{t as v,a6 as R,a7 as S,p as w,z as k,I as A,a3 as I,l as b,q as M}from"./vendor-antd-C8lKwvI6.js";import"./vendor-mermaid-C1Gk9PtT.js";import"./main-CEmqYfJe.js";const C=5,D=5,$=5,E=o=>{if(!o)return"";try{const n=Date.now()-new Date(o).getTime();if(n<0)return"";const t=Math.floor(n/1e3);if(t<60)return d.t("chat.home.justNow");const l=Math.floor(t/60);if(l<60)return d.t("chat.home.minutesAgo",{count:l});const a=Math.floor(l/60);if(a<24)return d.t("chat.home.hoursAgo",{count:a});const r=Math.floor(a/24);return r<30?d.t("chat.home.daysAgo",{count:r}):new Date(o).toLocaleDateString()}catch{return""}},P=(o,n)=>n?"is-running":o.lastRunStatus==="error"?"is-error":o.pinned?"is-pinned":"is-idle",x=({chat:o,onOpen:n,textSecondary:t})=>{const{t:l}=y(),a=p(f(o.id)),r=o.config.workspacePath?o.config.workspacePath.split("/").pop()||o.config.workspacePath:null;return s.jsxs("button",{type:"button",className:"lotus-home-session-item",onClick:()=>n(o.id),children:[s.jsx("span",{className:`lotus-home-session-status ${P(o,a)}`}),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:E(o.updatedAt)}),r?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"lotus-home-session-meta-sep"}),s.jsxs("span",{children:[s.jsx(A,{style:{marginRight:3}}),r]})]}):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]})]}),a?s.jsx(b,{color:"green",bordered:!1,style:{margin:0,fontSize:11},children:l("chat.home.running")}):null,s.jsx(M,{className:"lotus-home-session-arrow"})]})},L=({onOpenSession:o})=>{const{t:n}=y(),{token:t}=v.useToken(),l=p(e=>e.chats),a=c.useCallback(e=>f(e)(p.getState()),[]),r=c.useMemo(()=>l.filter(e=>a(e.id)).slice(0,D),[l,a]),m=c.useMemo(()=>l.filter(e=>e.pinned&&!a(e.id)).slice(0,$),[l,a]),j=c.useMemo(()=>{const e=new Set(r.map(i=>i.id)),g=new Set(m.map(i=>i.id));return l.filter(i=>i.kind!=="child"&&!e.has(i.id)&&!g.has(i.id)).sort((i,h)=>{const N=i.updatedAt?new Date(i.updatedAt).getTime():i.createdAt;return(h.updatedAt?new Date(h.updatedAt).getTime():h.createdAt)-N}).slice(0,C)},[l,r,m]),u=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(R,{})}),s.jsxs("div",{className:"lotus-home-header-text",children:[s.jsx("h2",{style:{color:t.colorText},children:n("home.title","Welcome to Bodhi")}),s.jsx("p",{style:{color:t.colorTextSecondary},children:n("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(T,{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(S,{className:"lotus-home-section-icon",style:{color:"#52c41a"}}),s.jsx("span",{children:n("home.sections.running","Running Now")})]}),s.jsx("div",{className:"lotus-home-session-list",children:r.map(e=>s.jsx(x,{chat:e,onOpen:u,textSecondary:t.colorTextTertiary},e.id))})]}):null,m.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",style:{color:"#faad14"}}),s.jsx("span",{children:n("home.sections.pinned","Pinned")})]}),s.jsx("div",{className:"lotus-home-session-list",children:m.map(e=>s.jsx(x,{chat:e,onOpen:u,textSecondary:t.colorTextTertiary},e.id))})]}):null,j.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(k,{className:"lotus-home-section-icon"}),s.jsx("span",{children:n("home.sections.recent","Recent Sessions")})]}),s.jsx("div",{className:"lotus-home-session-list",children:j.map(e=>s.jsx(x,{chat:e,onOpen:u,textSecondary:t.colorTextTertiary},e.id))})]}):null,l.length===0?s.jsx("div",{className:"lotus-home-empty-hint",style:{color:t.colorTextTertiary},children:n("home.empty","No sessions yet. Create one to get started!")}):null]})]})})};export{L as HomeDashboard,L as default};
@@ -1 +1 @@
1
- import{j as s}from"./vendor-markdown-DZuK0SxV.js";import{u as g,a as u}from"./vendor-i18n-BNURlJ23.js";import{u as d,m as j}from"./App-Agd9FqjU.js";import{F as h,n as i,l as m,I as y,ae as b,ac as B,t as _}from"./vendor-antd-C8lKwvI6.js";import"./vendor-mermaid-C1Gk9PtT.js";import"./main-C-I4C72U.js";const{useToken:P}=_,I=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:I(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
+ import{j as s}from"./vendor-markdown-DZuK0SxV.js";import{u as g,a as u}from"./vendor-i18n-BNURlJ23.js";import{u as d,n as j}from"./App-BYqor0NW.js";import{F as h,n as i,l as m,I as y,ae as b,ac as B,t as _}from"./vendor-antd-C8lKwvI6.js";import"./vendor-mermaid-C1Gk9PtT.js";import"./main-CEmqYfJe.js";const{useToken:P}=_,I=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:I(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,M as E,r as H,h as F}from"./vendor-markdown-DZuK0SxV.js";import{i as I,u as R,a as p}from"./vendor-i18n-BNURlJ23.js";import{S as y,E as v,C as X,j as T,L as A,a9 as Y,l as j,ag as O,ah as W,ai as q,aj as J,W as K,H as N,w as Q,t as U}from"./vendor-antd-C8lKwvI6.js";import{w as V,u as z,x as Z}from"./App-Agd9FqjU.js";import"./vendor-mermaid-C1Gk9PtT.js";import"./main-C-I4C72U.js";const _=({buttons:r,className:e,style:g,size:l="middle",align:n="right"})=>{const h={className:e,style:{width:"100%",justifyContent:n==="left"?"flex-start":n==="center"?"center":"flex-end",...g}};return t.jsx(y,{...h,children:r.map(i=>t.jsx(v,{type:i.type||"default",disabled:i.disabled,loading:i.loading,danger:i.danger,onClick:i.onClick,size:l,icon:i.icon,children:i.text},i.key))})},k=(r,e)=>({key:"cancel",text:e||I.t("common.cancel"),type:"default",onClick:r}),ee=(r,e)=>({key:"ok",text:(e==null?void 0:e.text)||I.t("common.ok"),type:"primary",disabled:e==null?void 0:e.disabled,loading:e==null?void 0:e.loading,onClick:r}),{Text:b,Paragraph:te}=T,re=({content:r,token:e,showGradient:g,onClick:l})=>t.jsx(X,{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(E,{remarkPlugins:[H],components:{p:({children:n})=>t.jsx(te,{style:{marginBottom:e.marginSM},children:n}),ol:({children:n})=>t.jsx("ol",{style:{marginBottom:e.marginSM,paddingLeft:e.paddingLG},children:n}),ul:({children:n})=>t.jsx("ul",{style:{marginBottom:e.marginSM,paddingLeft:e.paddingLG},children:n}),li:({children:n})=>t.jsx("li",{style:{marginBottom:e.marginXS},children:n}),h1:({children:n})=>t.jsx(b,{strong:!0,style:{fontSize:e.fontSizeHeading3,marginBottom:e.marginSM,display:"block"},children:n}),h2:({children:n})=>t.jsx(b,{strong:!0,style:{fontSize:e.fontSizeHeading4,marginBottom:e.marginSM,display:"block"},children:n}),code:({inline:n,className:h,children:i,...a})=>{const o=/language-(\w+)/.exec(h||"");return n?t.jsx("code",{className:h,style:{backgroundColor:e.colorFillTertiary,padding:"0 4px",borderRadius:e.borderRadiusSM,fontSize:e.fontSizeSM},...a,children:i}):t.jsx(F,{style:V,language:(o==null?void 0:o[1])||"text",PreTag:"div",wrapLongLines:!0,children:String(i).replace(/\n$/,"")})}},children:r||"No content available."}),g?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:se}=T,ne=({prompt:r,token:e,isSelected:g,isExpanded:l,onSelect:n,onToggleExpand:h,onCopy:i})=>{const{t:a}=R(),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,m=o.length;return{nonEmptyLineCount:S,wordCount:C,characterCount:m,showGradient:!l&&m>600}},[o,l]);return t.jsx(A.Item,{style:{cursor:"pointer",padding:e.paddingMD,borderRadius:e.borderRadius,border:g?`2px solid ${e.colorPrimary}`:`1px solid ${e.colorBorderSecondary}`,marginBottom:e.marginXS,backgroundColor:g?e.colorPrimaryBg:e.colorBgContainer,transition:"all 0.2s ease"},onClick:()=>n(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(Y,{checked:g,onChange:()=>n(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:a("chat.systemPromptSelector.defaultTag")}):null]}),t.jsxs(y,{size:"small",children:[t.jsx(v,{type:"text",size:"small",icon:l?t.jsx(O,{}):t.jsx(W,{}),onClick:c=>{c.stopPropagation(),h(r.id)},children:a(l?"chat.systemPromptSelector.hide":"chat.systemPromptSelector.preview")}),t.jsx(v,{type:"text",size:"small",icon:t.jsx(q,{}),onClick:c=>i(c,r),children:a("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:a("chat.systemPromptSelector.lines",{count:f})}),t.jsx(j,{color:"purple",children:a("chat.systemPromptSelector.words",{count:u})}),t.jsx(j,{color:"success",children:a("chat.systemPromptSelector.chars",{count:P})})]}),l?t.jsx(re,{content:o,token:e,showGradient:x,onClick:c=>c.stopPropagation()}):t.jsx(se,{type:"secondary",ellipsis:{rows:3},style:{marginLeft:e.marginLG,marginBottom:0,color:e.colorTextSecondary},children:o||a("chat.systemPromptSelector.noContent")})]})},r.id)},{Text:ie}=T,{useToken:ae}=U,he=({open:r,onClose:e,onSelect:g,prompts:l,title:n,showCancelButton:h=!0})=>{const{t:i}=R(),{token:a}=ae(),[o,f]=J.useMessage(),u=z(s=>s.lastSelectedPromptId),P=z(s=>s.setLastSelectedPromptId),[x,c]=p.useState(null),[S,C]=p.useState(null),m=p.useMemo(()=>l.filter(s=>s.id&&s.id.trim()!==""),[l]),w=async(s,d)=>{s.stopPropagation();const L=d.content??"";try{await Z(L),o.success(i("success.promptCopied",{name:d.name}))}catch(D){console.error("[SystemPromptSelector] Failed to copy prompt:",D),o.error(i("error.copyPromptFailed"))}},G=n??i("chat.prompt.selectorTitle");p.useEffect(()=>{if(r){const s=m.find(L=>L.isDefault),d=u||(s==null?void 0:s.id)||(m.length>0?m[0].id:null);c(d)}},[r,u,m.length]);const $=s=>{c(s.id),P(s.id),g(s),e()},B=()=>{e()};return t.jsxs(t.Fragment,{children:[f,t.jsxs(K,{title:t.jsxs(y,{children:[t.jsx(Q,{}),G]}),open:r,onCancel:B,width:700,footer:t.jsx(_,{buttons:[...h?[k(B)]:[],ee(()=>{const s=m.find(d=>d.id===x);s&&$(s)},{text:i("chat.prompt.createButton"),disabled:!x})]}),styles:{body:{maxHeight:"70vh",overflowY:"auto",padding:a.paddingMD}},children:[t.jsx("div",{style:{marginBottom:a.marginMD},children:t.jsx(ie,{type:"secondary",style:{fontSize:a.fontSizeSM},children:i("chat.prompt.helperText")})}),m.length===0?t.jsx(N,{description:i("chat.prompt.emptyDescription"),style:{margin:a.marginLG}}):t.jsx("div",{children:m.map(s=>t.jsx(ne,{prompt:s,token:a,isSelected:x===s.id,isExpanded:S===s.id,onSelect:d=>c(d),onToggleExpand:d=>C(S===d?null:d),onCopy:w},s.id))})]})]})};export{he as default};
1
+ import{j as t,M as E,r as H,h as F}from"./vendor-markdown-DZuK0SxV.js";import{i as I,u as R,a as p}from"./vendor-i18n-BNURlJ23.js";import{S as y,E as v,C as X,j as T,L as A,a9 as Y,l as j,ag as O,ah as W,ai as q,aj as J,W as K,H as N,w as Q,t as U}from"./vendor-antd-C8lKwvI6.js";import{x as V,u as z,y as Z}from"./App-BYqor0NW.js";import"./vendor-mermaid-C1Gk9PtT.js";import"./main-CEmqYfJe.js";const _=({buttons:r,className:e,style:g,size:l="middle",align:n="right"})=>{const h={className:e,style:{width:"100%",justifyContent:n==="left"?"flex-start":n==="center"?"center":"flex-end",...g}};return t.jsx(y,{...h,children:r.map(i=>t.jsx(v,{type:i.type||"default",disabled:i.disabled,loading:i.loading,danger:i.danger,onClick:i.onClick,size:l,icon:i.icon,children:i.text},i.key))})},k=(r,e)=>({key:"cancel",text:e||I.t("common.cancel"),type:"default",onClick:r}),ee=(r,e)=>({key:"ok",text:(e==null?void 0:e.text)||I.t("common.ok"),type:"primary",disabled:e==null?void 0:e.disabled,loading:e==null?void 0:e.loading,onClick:r}),{Text:b,Paragraph:te}=T,re=({content:r,token:e,showGradient:g,onClick:l})=>t.jsx(X,{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(E,{remarkPlugins:[H],components:{p:({children:n})=>t.jsx(te,{style:{marginBottom:e.marginSM},children:n}),ol:({children:n})=>t.jsx("ol",{style:{marginBottom:e.marginSM,paddingLeft:e.paddingLG},children:n}),ul:({children:n})=>t.jsx("ul",{style:{marginBottom:e.marginSM,paddingLeft:e.paddingLG},children:n}),li:({children:n})=>t.jsx("li",{style:{marginBottom:e.marginXS},children:n}),h1:({children:n})=>t.jsx(b,{strong:!0,style:{fontSize:e.fontSizeHeading3,marginBottom:e.marginSM,display:"block"},children:n}),h2:({children:n})=>t.jsx(b,{strong:!0,style:{fontSize:e.fontSizeHeading4,marginBottom:e.marginSM,display:"block"},children:n}),code:({inline:n,className:h,children:i,...a})=>{const o=/language-(\w+)/.exec(h||"");return n?t.jsx("code",{className:h,style:{backgroundColor:e.colorFillTertiary,padding:"0 4px",borderRadius:e.borderRadiusSM,fontSize:e.fontSizeSM},...a,children:i}):t.jsx(F,{style:V,language:(o==null?void 0:o[1])||"text",PreTag:"div",wrapLongLines:!0,children:String(i).replace(/\n$/,"")})}},children:r||"No content available."}),g?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:se}=T,ne=({prompt:r,token:e,isSelected:g,isExpanded:l,onSelect:n,onToggleExpand:h,onCopy:i})=>{const{t:a}=R(),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,m=o.length;return{nonEmptyLineCount:S,wordCount:C,characterCount:m,showGradient:!l&&m>600}},[o,l]);return t.jsx(A.Item,{style:{cursor:"pointer",padding:e.paddingMD,borderRadius:e.borderRadius,border:g?`2px solid ${e.colorPrimary}`:`1px solid ${e.colorBorderSecondary}`,marginBottom:e.marginXS,backgroundColor:g?e.colorPrimaryBg:e.colorBgContainer,transition:"all 0.2s ease"},onClick:()=>n(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(Y,{checked:g,onChange:()=>n(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:a("chat.systemPromptSelector.defaultTag")}):null]}),t.jsxs(y,{size:"small",children:[t.jsx(v,{type:"text",size:"small",icon:l?t.jsx(O,{}):t.jsx(W,{}),onClick:c=>{c.stopPropagation(),h(r.id)},children:a(l?"chat.systemPromptSelector.hide":"chat.systemPromptSelector.preview")}),t.jsx(v,{type:"text",size:"small",icon:t.jsx(q,{}),onClick:c=>i(c,r),children:a("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:a("chat.systemPromptSelector.lines",{count:f})}),t.jsx(j,{color:"purple",children:a("chat.systemPromptSelector.words",{count:u})}),t.jsx(j,{color:"success",children:a("chat.systemPromptSelector.chars",{count:P})})]}),l?t.jsx(re,{content:o,token:e,showGradient:x,onClick:c=>c.stopPropagation()}):t.jsx(se,{type:"secondary",ellipsis:{rows:3},style:{marginLeft:e.marginLG,marginBottom:0,color:e.colorTextSecondary},children:o||a("chat.systemPromptSelector.noContent")})]})},r.id)},{Text:ie}=T,{useToken:ae}=U,he=({open:r,onClose:e,onSelect:g,prompts:l,title:n,showCancelButton:h=!0})=>{const{t:i}=R(),{token:a}=ae(),[o,f]=J.useMessage(),u=z(s=>s.lastSelectedPromptId),P=z(s=>s.setLastSelectedPromptId),[x,c]=p.useState(null),[S,C]=p.useState(null),m=p.useMemo(()=>l.filter(s=>s.id&&s.id.trim()!==""),[l]),w=async(s,d)=>{s.stopPropagation();const L=d.content??"";try{await Z(L),o.success(i("success.promptCopied",{name:d.name}))}catch(D){console.error("[SystemPromptSelector] Failed to copy prompt:",D),o.error(i("error.copyPromptFailed"))}},G=n??i("chat.prompt.selectorTitle");p.useEffect(()=>{if(r){const s=m.find(L=>L.isDefault),d=u||(s==null?void 0:s.id)||(m.length>0?m[0].id:null);c(d)}},[r,u,m.length]);const $=s=>{c(s.id),P(s.id),g(s),e()},B=()=>{e()};return t.jsxs(t.Fragment,{children:[f,t.jsxs(K,{title:t.jsxs(y,{children:[t.jsx(Q,{}),G]}),open:r,onCancel:B,width:700,footer:t.jsx(_,{buttons:[...h?[k(B)]:[],ee(()=>{const s=m.find(d=>d.id===x);s&&$(s)},{text:i("chat.prompt.createButton"),disabled:!x})]}),styles:{body:{maxHeight:"70vh",overflowY:"auto",padding:a.paddingMD}},children:[t.jsx("div",{style:{marginBottom:a.marginMD},children:t.jsx(ie,{type:"secondary",style:{fontSize:a.fontSizeSM},children:i("chat.prompt.helperText")})}),m.length===0?t.jsx(N,{description:i("chat.prompt.emptyDescription"),style:{margin:a.marginLG}}):t.jsx("div",{children:m.map(s=>t.jsx(ne,{prompt:s,token:a,isSelected:x===s.id,isExpanded:S===s.id,onSelect:d=>c(d),onToggleExpand:d=>C(S===d?null:d),onCopy:w},s.id))})]})]})};export{he as default};