@ian2018cs/agenthub 0.1.98 → 0.1.100

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.
@@ -72,7 +72,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
72
72
  `)})}catch{}if((r.toolName==="Grep"||r.toolName==="Glob")&&r.toolResult?.toolUseResult){const w=r.toolResult.toolUseResult;if(w.filenames&&Array.isArray(w.filenames)&&w.filenames.length>0)return e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium mb-2",children:["找到 ",w.numFiles||w.filenames.length," 个文件"]}),e.jsx("div",{className:"space-y-0.5 max-h-96 overflow-y-auto",children:w.filenames.map((N,A)=>{const E=N.split("/").pop(),T=N.substring(0,N.lastIndexOf("/"));return e.jsxs("div",{onClick:()=>c&&c(N),className:"flex items-center gap-2 px-2 py-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800/50 cursor-pointer transition-colors",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-400 dark:text-gray-500 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"font-mono font-medium truncate block",children:E}),e.jsx("span",{className:"font-mono text-[10px] text-gray-400 dark:text-gray-500 truncate block",children:Ue(T)})]})]},A)})})]})}if(f.includes("Do you want to proceed?")&&r.toolName==="Bash"){const w=f.split(`
73
73
  `),N=w.findIndex(R=>R.includes("Do you want to proceed?")),A=w.slice(0,N).join(`
74
74
  `),E=w.slice(N),T=E.find(R=>R.includes("Do you want to proceed?"))||"",$=[];E.forEach(R=>{const S=R.match(/^\s*(\d+)\.\s+(.+)$/);S&&$.push({number:S[1],text:S[2].trim()})});const M=f.match(/>\s*(\d+)/),D=M?M[1]:null;return e.jsxs("div",{className:"space-y-2",children:[A&&e.jsx("div",{className:"bg-gray-900 dark:bg-gray-950 text-gray-100 rounded-lg p-3 font-mono text-xs overflow-x-auto",children:e.jsx("pre",{className:"whitespace-pre-wrap break-words",children:A})}),e.jsx("div",{className:"text-gray-500 dark:text-gray-400 text-xs",children:T}),e.jsx("div",{className:"space-y-1",children:$.map(R=>e.jsxs("div",{className:`flex items-center gap-2 px-2 py-1 rounded text-xs ${D===R.number?"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"text-gray-500 dark:text-gray-400"}`,children:[e.jsxs("span",{className:"font-mono",children:[R.number,"."]}),e.jsx("span",{children:R.text}),D===R.number&&e.jsx("svg",{className:"w-3.5 h-3.5 ml-auto text-green-500 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M5 13l4 4L19 7"})})]},R.number))}),D&&e.jsxs("div",{className:"text-[10px] text-gray-400 dark:text-gray-500",children:["Claude 选择了选项 ",D]})]})}return f.includes("cat -n")&&f.includes("→")?e.jsxs("details",{open:!1,children:[e.jsxs("summary",{className:"[list-style:none] [&::-webkit-details-marker]:hidden cursor-pointer text-gray-400 dark:text-gray-500 hover:text-gray-500 flex items-center gap-1 mb-1 text-xs",children:[e.jsx("svg",{className:"w-3.5 h-3.5 transition-transform [details[open]>summary_&]:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看文件内容"]}),e.jsx("div",{className:"mt-2 bg-gray-50 dark:bg-gray-800/50 border border-gray-200/60 dark:border-gray-700/60 rounded-lg overflow-hidden",children:e.jsx("div",{className:"text-xs font-mono p-3 whitespace-pre-wrap break-words overflow-hidden",children:f})})]}):f.length>300?e.jsxs("details",{open:!1,children:[e.jsxs("summary",{className:"[list-style:none] [&::-webkit-details-marker]:hidden cursor-pointer text-gray-400 dark:text-gray-500 hover:text-gray-500 flex items-center gap-1 mb-1 text-xs",children:[e.jsx("svg",{className:"w-3.5 h-3.5 transition-transform [details[open]>summary_&]:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看完整输出 (",f.length," 字符)"]}),e.jsx(kr,{className:"mt-2 prose prose-sm max-w-none dark:prose-invert",children:f})]}):e.jsx(kr,{className:"prose prose-sm max-w-none dark:prose-invert",children:f})})(),i&&e.jsxs("div",{className:"mt-3 pt-2 border-t border-gray-200/60 dark:border-gray-700/40",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{if(!d)return;d(i)?.success?v("granted"):v("error")},disabled:i.isAllowed||g==="granted",className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${i.isAllowed||g==="granted"?"bg-green-100 dark:bg-green-900/30 border-green-300/70 dark:border-green-800/60 text-green-800 dark:text-green-200 cursor-default":"bg-white/80 dark:bg-gray-900/40 border-red-300/70 dark:border-red-800/60 text-red-700 dark:text-red-200 hover:bg-white dark:hover:bg-gray-900/70"}`,children:i.isAllowed||g==="granted"?"权限已添加":`授予权限 ${i.toolName}`}),m&&e.jsx("button",{type:"button",onClick:w=>{w.stopPropagation(),m()},className:"text-xs text-red-700 dark:text-red-200 underline hover:text-red-800 dark:hover:text-red-100",children:"打开设置"})]}),e.jsxs("div",{className:"mt-2 text-xs text-red-700/90 dark:text-red-200/80",children:["添加 ",e.jsx("span",{className:"font-mono",children:i.entry})," 到允许的工具列表。"]}),g==="error"&&e.jsx("div",{className:"mt-2 text-xs text-red-700 dark:text-red-200",children:"无法更新权限。请重试。"}),(i.isAllowed||g==="granted")&&e.jsx("div",{className:"mt-2 text-xs text-green-700 dark:text-green-200",children:"权限已保存。请重试请求以使用该工具。"})]})]})]})})()]})]})})():r.isInteractivePrompt?e.jsx("div",{className:"bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-amber-500 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-amber-900 dark:text-amber-100 text-base mb-3",children:"交互式提示"}),(()=>{const k=r.content.split(`
75
- `).filter(f=>f.trim()),b=k.find(f=>f.includes("?"))||k[0]||"",j=[];return k.forEach(f=>{const w=f.match(/[❯\s]*(\d+)\.\s+(.+)/);if(w){const N=f.includes("❯");j.push({number:w[1],text:w[2].trim(),isSelected:N})}}),e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-amber-800 dark:text-amber-200 mb-4",children:b}),e.jsx("div",{className:"space-y-2 mb-4",children:j.map(f=>e.jsx("button",{className:`w-full text-left px-4 py-3 rounded-lg border-2 transition-all ${f.isSelected?"bg-amber-600 dark:bg-amber-700 text-white border-amber-600 dark:border-amber-700 shadow-md":"bg-white dark:bg-gray-800 text-amber-900 dark:text-amber-100 border-amber-300 dark:border-amber-700"} cursor-not-allowed opacity-75`,disabled:!0,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center text-sm font-bold ${f.isSelected?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:f.number}),e.jsx("span",{className:"text-sm sm:text-base font-medium flex-1",children:f.text}),f.isSelected&&e.jsx("span",{className:"text-lg",children:"❯"})]})},f.number))}),e.jsxs("div",{className:"bg-amber-100 dark:bg-amber-800/30 rounded-lg p-3",children:[e.jsx("p",{className:"text-amber-900 dark:text-amber-100 text-sm font-medium mb-1",children:"⏳ 等待您在 CLI 中的响应"}),e.jsx("p",{className:"text-amber-800 dark:text-amber-200 text-xs",children:"请在运行 Claude 的终端中选择一个选项。"})]})]})})()]})]})}):r.isToolUse&&r.toolName==="Read"?(()=>{try{const k=JSON.parse(r.toolInput);if(k.file_path){const b=k.file_path.split("/").pop();return e.jsx("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})}),e.jsx("span",{className:"font-medium",children:"Read"}),e.jsx("button",{onClick:()=>c&&c(k.file_path),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-mono transition-colors",children:b})]})})}}catch{return e.jsx("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})}),e.jsx("span",{className:"font-medium",children:"读取文件"})]})})}})():r.isToolUse&&r.toolName==="TodoWrite"?(()=>{try{const k=JSON.parse(r.toolInput);if(k.todos&&Array.isArray(k.todos))return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400 mb-1.5",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),"更新待办列表"]}),e.jsx(Wo,{todos:k.todos})]})}catch{return e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"更新待办列表"})}})():r.isToolUse&&r.toolName==="TodoRead"?e.jsx("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),e.jsx("span",{className:"font-medium",children:"读取待办列表"})]})}):e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:(()=>{const k=Ue(Rn(String(r.content||""))),b=k.trim();if((b.startsWith("{")||b.startsWith("["))&&(b.endsWith("}")||b.endsWith("]")))try{const j=JSON.parse(b),f=JSON.stringify(j,null,2);return e.jsxs("div",{className:"my-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),e.jsx("span",{className:"font-medium",children:"JSON 响应"})]}),e.jsx("div",{className:"bg-gray-800 dark:bg-gray-900 border border-gray-600/30 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsx("pre",{className:"p-4 overflow-x-auto",children:e.jsx("code",{className:"text-gray-100 dark:text-gray-200 text-sm font-mono block whitespace-pre",children:f})})})]})}catch{}return r.type==="assistant"?e.jsx(kr,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:k}):e.jsx("div",{className:"whitespace-pre-wrap",children:k})})()}),e.jsxs("div",{className:`flex items-center gap-2 mt-1 ${h?"opacity-0 group-hover:opacity-100":""}`,children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(r.timestamp).toLocaleTimeString()}),t&&r.type==="assistant"&&!r.isToolUse&&e.jsx("button",{onClick:()=>t(x),className:"opacity-0 group-hover:opacity-100 transition-opacity p-0.5 rounded text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700",title:"从此处创建新会话分支",children:e.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",children:[e.jsx("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),e.jsx("circle",{cx:"18",cy:"6",r:"3"}),e.jsx("circle",{cx:"6",cy:"18",r:"3"}),e.jsx("path",{d:"M18 9a9 9 0 0 1-9 9"})]})})]})]})]})})}),Xl=({file:r,onRemove:o,uploadProgress:l,error:u})=>{const[c,m]=n.useState(null);return n.useEffect(()=>{const d=URL.createObjectURL(r);return m(d),()=>URL.revokeObjectURL(d)},[r]),e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:c,alt:r.name,className:"w-20 h-20 object-cover rounded"}),l!==void 0&&l<100&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsxs("div",{className:"text-white text-xs",children:[l,"%"]})}),u&&e.jsx("div",{className:"absolute inset-0 bg-red-500/50 flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),e.jsx("button",{onClick:o,className:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full p-1 opacity-0 group-hover:opacity-100",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})};function Ml({selectedProject:r,selectedSession:o,ws:l,sendMessage:u,messages:c,onFileOpen:m,onInputFocusChange:d,onSessionActive:s,onSessionInactive:p,onSessionProcessing:t,onSessionNotProcessing:x,processingSessions:h,onReplaceTemporarySession:a,onNavigateToSession:i,onShowSettings:g,autoScrollToBottom:v,sendByCtrlEnter:k,externalMessageUpdate:b,onTaskClick:j,limitStatus:f,onLimitExceeded:w,checkLimitStatus:N}){const{showConfirm:A,showAlert:E}=lt(),[T,$]=n.useState(()=>typeof window<"u"&&r&&pt.getItem(`draft_input_${r.name}`)||""),[M,D]=n.useState(()=>{if(typeof window<"u"&&r){const y=pt.getItem(`chat_messages_${r.name}`);return y?JSON.parse(y):[]}return[]}),[R,S]=n.useState(!1),[X,I]=n.useState(o?.id||null),[te,ne]=n.useState(!1),[Y,ie]=n.useState([]),de=n.useRef([]),[fe,Ee]=n.useState(!1),[ye,Me]=n.useState(!1),[Fe,le]=n.useState(0),[Se,He]=n.useState(!1),[,Be]=n.useState(0),he=20,Oe=n.useCallback(y=>{Z.current=y,le(y)},[]),[De,Ye]=n.useState(!1),[Xe,Je]=n.useState(wo),Ce=n.useRef(null),[_e,Re]=n.useState([]),ze=n.useRef(new Map),[$e,Ze]=n.useState(null),[Qe,K]=n.useState(!1);n.useEffect(()=>{const y=`${Ve} - ${fs}`;return _e.length>0?document.title=`[等待审批] ${y}`:document.title=y,()=>{document.title=y}},[_e.length]);const B=n.useRef(o?.id||null),C=n.useRef(null);n.useEffect(()=>{l&&!C.current&&R&&X&&u({type:"check-session-status",sessionId:X,provider:Tt}),C.current=l},[l]);const[V,z]=n.useState([]),[re,G]=n.useState(new Map),[ae,ce]=n.useState(new Map),[Pe,xe]=n.useState(!1),Le=n.useRef(null),oe=n.useRef(null),be=n.useRef(null),at=n.useRef(null),Ae=n.useRef(null),dt=n.useRef(!1),gt=n.useRef(!1),F=n.useRef(!1),Te=n.useRef(!1),O=n.useRef(null),se=n.useRef(null),ke=n.useRef(null),we=n.useRef(null),Z=n.useRef(0),We=n.useRef(""),tt=n.useRef(null),ft=n.useRef(null),ht=n.useRef([]),[hr,jt]=n.useState(""),[et,kt]=n.useState(!1),[Dr,xr]=n.useState([]),[Ct,Dt]=n.useState([]),[gr,tr]=n.useState(-1),[Pr,rr]=n.useState(0),[Ar,nr]=n.useState(-1),[nn,xt]=n.useState(!1),[$t,or]=n.useState(!1),Pt=n.useRef({height:0,top:0}),[sr,wt]=n.useState(!1),[ar,yr]=n.useState(!1),br=n.useRef(null),yt=n.useRef(null),[W,ee]=n.useState([]),[pe,Ie]=n.useState([]),[ut,Ke]=n.useState(""),[Is,Rt]=n.useState(!1),[so,ir]=n.useState(null),[on,At]=n.useState(-1),[ao,Lt]=n.useState(-1),[vr,_s]=n.useState(100),sn=typeof window<"u"&&window.innerWidth<640,[Wt,an]=n.useState(!1),[zs,$s]=n.useState(380),[ln,io]=n.useState(!1),[Rs,Nt]=n.useState(null),[St,lo]=n.useState(()=>localStorage.getItem("claude-model")||wn.DEFAULT),Tt="claude";n.useEffect(()=>{if(!ar)return;const y=P=>{br.current&&!br.current.contains(P.target)&&yt.current&&!yt.current.contains(P.target)&&yr(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[ar]),n.useEffect(()=>{if(o?.id){const y=localStorage.getItem(`permissionMode-${o.id}`);if(y)Je(y),Ce.current=null;else if(Ce.current){const P=Ce.current;Ce.current=null,localStorage.setItem(`permissionMode-${o.id}`,P),Je(P)}else Je(wo)}},[o?.id]),n.useEffect(()=>{const y=B.current,P=o?.id;B.current=P,Re(y&&y!==P?_=>(ze.current.set(y,_),ze.current.get(P)||[]):_=>_.filter(L=>!L.sessionId||L.sessionId===P))},[o?.id]),n.useEffect(()=>{(async()=>{if(r)try{const[P,_,L]=await Promise.all([J("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:r.path})}),J("/api/skills").catch(()=>null),J("/api/mcp/config/read").catch(()=>null)]);if(!P.ok)throw new Error("Failed to fetch commands");const H=await P.json();let q=[];_?.ok&&(q=((await _.json()).skills||[]).filter(je=>je.scope!=="local"||je.projectPath===r?.path).map(je=>({name:"/"+je.name,description:je.description||je.title||"",namespace:"skill",type:"skill"})));let ge=[];if(L?.ok){const ve=await L.json();ve.success&&ve.servers&&(ge=ve.servers.filter(je=>je.scope!=="local"||je.projectPath===r?.path).map(je=>({name:je.name,description:`${je.type}${je.scope?" · "+je.scope:""}`,namespace:"mcp",type:"mcp"})))}const Ne=[...(H.builtIn||[]).map(ve=>({...ve,type:"built-in"})),...(H.custom||[]).map(ve=>({...ve,type:"custom"})),...q,...ge];ee(Ne);const Q=`command_history_${r.name}`,ue=pt.getItem(Q);if(ue)try{const ve=JSON.parse(ue),je=Ne.sort((it,ca)=>{const da=ve[it.name]||0;return(ve[ca.name]||0)-da});ee(je)}catch(ve){console.error("Error parsing command history:",ve)}}catch(P){console.error("Error fetching slash commands:",P),ee([])}})()},[r]);const cn=n.useMemo(()=>W.length?new Sa(W,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[W]);n.useEffect(()=>{if(!ut){Ie(W);return}if(!cn){Ie([]);return}const y=cn.search(ut);Ie(y.map(P=>P.item))},[ut,W,cn]);const Ws=n.useMemo(()=>{if(!r||W.length===0)return[];const y=`command_history_${r.name}`,P=pt.getItem(y);if(!P)return[];try{const _=JSON.parse(P);return W.map(H=>({...H,usageCount:_[H.name]||0})).filter(H=>H.usageCount>0).sort((H,q)=>q.usageCount-H.usageCount).slice(0,5)}catch(_){return console.error("Error parsing command history:",_),[]}},[r,W]),Fs=n.useCallback((y,P,_)=>{if(!y||!r)return;if(_){At(P);return}const L=`command_history_${r.name}`,H=pt.getItem(L);let q={};try{q=H?JSON.parse(H):{}}catch(ge){console.error("Error parsing command history:",ge)}if(q[y.name]=(q[y.name]||0)+1,pt.setItem(L,JSON.stringify(q)),y.namespace==="skill"||y.namespace==="mcp"){$(y.name+" "),wt(!1),Lt(-1),Ke(""),At(-1),oe.current&&oe.current.focus();return}Lr(y)},[r]),Hs=n.useCallback(y=>{const{action:P,data:_}=y;switch(P){case"help":D(L=>[...L,{type:"assistant",content:_.content,timestamp:Date.now()}]);break;case"model":{const L=_.available.claude,H=_.message?.includes("Switching to model:")?_.message.replace("Switching to model: ","").trim():null;H&&L.includes(H)?(lo(H),localStorage.setItem("claude-model",H),D(q=>[...q,{type:"assistant",content:`已切换到模型: **${H}**`,timestamp:Date.now()}])):D(H?q=>[...q,{type:"assistant",content:`无效的模型: ${H}
75
+ `).filter(f=>f.trim()),b=k.find(f=>f.includes("?"))||k[0]||"",j=[];return k.forEach(f=>{const w=f.match(/[❯\s]*(\d+)\.\s+(.+)/);if(w){const N=f.includes("❯");j.push({number:w[1],text:w[2].trim(),isSelected:N})}}),e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-amber-800 dark:text-amber-200 mb-4",children:b}),e.jsx("div",{className:"space-y-2 mb-4",children:j.map(f=>e.jsx("button",{className:`w-full text-left px-4 py-3 rounded-lg border-2 transition-all ${f.isSelected?"bg-amber-600 dark:bg-amber-700 text-white border-amber-600 dark:border-amber-700 shadow-md":"bg-white dark:bg-gray-800 text-amber-900 dark:text-amber-100 border-amber-300 dark:border-amber-700"} cursor-not-allowed opacity-75`,disabled:!0,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center text-sm font-bold ${f.isSelected?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:f.number}),e.jsx("span",{className:"text-sm sm:text-base font-medium flex-1",children:f.text}),f.isSelected&&e.jsx("span",{className:"text-lg",children:"❯"})]})},f.number))}),e.jsxs("div",{className:"bg-amber-100 dark:bg-amber-800/30 rounded-lg p-3",children:[e.jsx("p",{className:"text-amber-900 dark:text-amber-100 text-sm font-medium mb-1",children:"⏳ 等待您在 CLI 中的响应"}),e.jsx("p",{className:"text-amber-800 dark:text-amber-200 text-xs",children:"请在运行 Claude 的终端中选择一个选项。"})]})]})})()]})]})}):r.isToolUse&&r.toolName==="Read"?(()=>{try{const k=JSON.parse(r.toolInput);if(k.file_path){const b=k.file_path.split("/").pop();return e.jsx("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})}),e.jsx("span",{className:"font-medium",children:"Read"}),e.jsx("button",{onClick:()=>c&&c(k.file_path),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-mono transition-colors",children:b})]})})}}catch{return e.jsx("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})}),e.jsx("span",{className:"font-medium",children:"读取文件"})]})})}})():r.isToolUse&&r.toolName==="TodoWrite"?(()=>{try{const k=JSON.parse(r.toolInput);if(k.todos&&Array.isArray(k.todos))return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400 mb-1.5",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),"更新待办列表"]}),e.jsx(Wo,{todos:k.todos})]})}catch{return e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"更新待办列表"})}})():r.isToolUse&&r.toolName==="TodoRead"?e.jsx("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),e.jsx("span",{className:"font-medium",children:"读取待办列表"})]})}):e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:(()=>{const k=Ue(Rn(String(r.content||""))),b=k.trim();if((b.startsWith("{")||b.startsWith("["))&&(b.endsWith("}")||b.endsWith("]")))try{const j=JSON.parse(b),f=JSON.stringify(j,null,2);return e.jsxs("div",{className:"my-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),e.jsx("span",{className:"font-medium",children:"JSON 响应"})]}),e.jsx("div",{className:"bg-gray-800 dark:bg-gray-900 border border-gray-600/30 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsx("pre",{className:"p-4 overflow-x-auto",children:e.jsx("code",{className:"text-gray-100 dark:text-gray-200 text-sm font-mono block whitespace-pre",children:f})})})]})}catch{}return r.type==="assistant"?e.jsx(kr,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:k}):e.jsx("div",{className:"whitespace-pre-wrap",children:k})})()}),e.jsxs("div",{className:`flex items-center gap-2 mt-1 ${h?"opacity-0 group-hover:opacity-100":""}`,children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(r.timestamp).toLocaleTimeString()}),t&&r.type==="assistant"&&!r.isToolUse&&e.jsx("button",{onClick:()=>t(x),className:"opacity-0 group-hover:opacity-100 transition-opacity p-0.5 rounded text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700",title:"从此处创建新会话分支",children:e.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",children:[e.jsx("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),e.jsx("circle",{cx:"18",cy:"6",r:"3"}),e.jsx("circle",{cx:"6",cy:"18",r:"3"}),e.jsx("path",{d:"M18 9a9 9 0 0 1-9 9"})]})})]})]})]})})}),Xl=({file:r,onRemove:o,uploadProgress:l,error:u})=>{const[c,m]=n.useState(null);return n.useEffect(()=>{const d=URL.createObjectURL(r);return m(d),()=>URL.revokeObjectURL(d)},[r]),e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:c,alt:r.name,className:"w-20 h-20 object-cover rounded"}),l!==void 0&&l<100&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsxs("div",{className:"text-white text-xs",children:[l,"%"]})}),u&&e.jsx("div",{className:"absolute inset-0 bg-red-500/50 flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),e.jsx("button",{onClick:o,className:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full p-1 opacity-0 group-hover:opacity-100",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})};function Ml({selectedProject:r,selectedSession:o,ws:l,sendMessage:u,messages:c,onFileOpen:m,onInputFocusChange:d,onSessionActive:s,onSessionInactive:p,onSessionProcessing:t,onSessionNotProcessing:x,processingSessions:h,onReplaceTemporarySession:a,onNavigateToSession:i,onShowSettings:g,autoScrollToBottom:v,sendByCtrlEnter:k,externalMessageUpdate:b,onTaskClick:j,limitStatus:f,onLimitExceeded:w,checkLimitStatus:N}){const{showConfirm:A,showAlert:E}=lt(),[T,$]=n.useState(()=>typeof window<"u"&&r&&pt.getItem(`draft_input_${r.name}`)||""),[M,D]=n.useState(()=>{if(typeof window<"u"&&r){const y=pt.getItem(`chat_messages_${r.name}`);return y?JSON.parse(y):[]}return[]}),[R,S]=n.useState(!1),[X,I]=n.useState(o?.id||null),[te,ne]=n.useState(!1),[Y,ie]=n.useState([]),de=n.useRef([]),[fe,Ee]=n.useState(!1),[ye,Me]=n.useState(!1),[Fe,le]=n.useState(0),[Se,He]=n.useState(!1),[,Be]=n.useState(0),he=100,Oe=n.useCallback(y=>{Z.current=y,le(y)},[]),[De,Ye]=n.useState(!1),[Xe,Je]=n.useState(wo),Ce=n.useRef(null),[_e,Re]=n.useState([]),ze=n.useRef(new Map),[$e,Ze]=n.useState(null),[Qe,K]=n.useState(!1);n.useEffect(()=>{const y=`${Ve} - ${fs}`;return _e.length>0?document.title=`[等待审批] ${y}`:document.title=y,()=>{document.title=y}},[_e.length]);const B=n.useRef(o?.id||null),C=n.useRef(null);n.useEffect(()=>{l&&!C.current&&R&&X&&u({type:"check-session-status",sessionId:X,provider:Tt}),C.current=l},[l]);const[V,z]=n.useState([]),[re,G]=n.useState(new Map),[ae,ce]=n.useState(new Map),[Pe,xe]=n.useState(!1),Le=n.useRef(null),oe=n.useRef(null),be=n.useRef(null),at=n.useRef(null),Ae=n.useRef(null),dt=n.useRef(!1),gt=n.useRef(!1),F=n.useRef(!1),Te=n.useRef(!1),O=n.useRef(null),se=n.useRef(null),ke=n.useRef(null),we=n.useRef(null),Z=n.useRef(0),We=n.useRef(""),tt=n.useRef(null),ft=n.useRef(null),ht=n.useRef([]),[hr,jt]=n.useState(""),[et,kt]=n.useState(!1),[Dr,xr]=n.useState([]),[Ct,Dt]=n.useState([]),[gr,tr]=n.useState(-1),[Pr,rr]=n.useState(0),[Ar,nr]=n.useState(-1),[nn,xt]=n.useState(!1),[$t,or]=n.useState(!1),Pt=n.useRef({height:0,top:0}),[sr,wt]=n.useState(!1),[ar,yr]=n.useState(!1),br=n.useRef(null),yt=n.useRef(null),[W,ee]=n.useState([]),[pe,Ie]=n.useState([]),[ut,Ke]=n.useState(""),[Is,Rt]=n.useState(!1),[so,ir]=n.useState(null),[on,At]=n.useState(-1),[ao,Lt]=n.useState(-1),[vr,_s]=n.useState(100),sn=typeof window<"u"&&window.innerWidth<640,[Wt,an]=n.useState(!1),[zs,$s]=n.useState(380),[ln,io]=n.useState(!1),[Rs,Nt]=n.useState(null),[St,lo]=n.useState(()=>localStorage.getItem("claude-model")||wn.DEFAULT),Tt="claude";n.useEffect(()=>{if(!ar)return;const y=P=>{br.current&&!br.current.contains(P.target)&&yt.current&&!yt.current.contains(P.target)&&yr(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[ar]),n.useEffect(()=>{if(o?.id){const y=localStorage.getItem(`permissionMode-${o.id}`);if(y)Je(y),Ce.current=null;else if(Ce.current){const P=Ce.current;Ce.current=null,localStorage.setItem(`permissionMode-${o.id}`,P),Je(P)}else Je(wo)}},[o?.id]),n.useEffect(()=>{const y=B.current,P=o?.id;B.current=P,Re(y&&y!==P?_=>(ze.current.set(y,_),ze.current.get(P)||[]):_=>_.filter(L=>!L.sessionId||L.sessionId===P))},[o?.id]),n.useEffect(()=>{(async()=>{if(r)try{const[P,_,L]=await Promise.all([J("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:r.path})}),J("/api/skills").catch(()=>null),J("/api/mcp/config/read").catch(()=>null)]);if(!P.ok)throw new Error("Failed to fetch commands");const H=await P.json();let q=[];_?.ok&&(q=((await _.json()).skills||[]).filter(je=>je.scope!=="local"||je.projectPath===r?.path).map(je=>({name:"/"+je.name,description:je.description||je.title||"",namespace:"skill",type:"skill"})));let ge=[];if(L?.ok){const ve=await L.json();ve.success&&ve.servers&&(ge=ve.servers.filter(je=>je.scope!=="local"||je.projectPath===r?.path).map(je=>({name:je.name,description:`${je.type}${je.scope?" · "+je.scope:""}`,namespace:"mcp",type:"mcp"})))}const Ne=[...(H.builtIn||[]).map(ve=>({...ve,type:"built-in"})),...(H.custom||[]).map(ve=>({...ve,type:"custom"})),...q,...ge];ee(Ne);const Q=`command_history_${r.name}`,ue=pt.getItem(Q);if(ue)try{const ve=JSON.parse(ue),je=Ne.sort((it,ca)=>{const da=ve[it.name]||0;return(ve[ca.name]||0)-da});ee(je)}catch(ve){console.error("Error parsing command history:",ve)}}catch(P){console.error("Error fetching slash commands:",P),ee([])}})()},[r]);const cn=n.useMemo(()=>W.length?new Sa(W,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[W]);n.useEffect(()=>{if(!ut){Ie(W);return}if(!cn){Ie([]);return}const y=cn.search(ut);Ie(y.map(P=>P.item))},[ut,W,cn]);const Ws=n.useMemo(()=>{if(!r||W.length===0)return[];const y=`command_history_${r.name}`,P=pt.getItem(y);if(!P)return[];try{const _=JSON.parse(P);return W.map(H=>({...H,usageCount:_[H.name]||0})).filter(H=>H.usageCount>0).sort((H,q)=>q.usageCount-H.usageCount).slice(0,5)}catch(_){return console.error("Error parsing command history:",_),[]}},[r,W]),Fs=n.useCallback((y,P,_)=>{if(!y||!r)return;if(_){At(P);return}const L=`command_history_${r.name}`,H=pt.getItem(L);let q={};try{q=H?JSON.parse(H):{}}catch(ge){console.error("Error parsing command history:",ge)}if(q[y.name]=(q[y.name]||0)+1,pt.setItem(L,JSON.stringify(q)),y.namespace==="skill"||y.namespace==="mcp"){$(y.name+" "),wt(!1),Lt(-1),Ke(""),At(-1),oe.current&&oe.current.focus();return}Lr(y)},[r]),Hs=n.useCallback(y=>{const{action:P,data:_}=y;switch(P){case"help":D(L=>[...L,{type:"assistant",content:_.content,timestamp:Date.now()}]);break;case"model":{const L=_.available.claude,H=_.message?.includes("Switching to model:")?_.message.replace("Switching to model: ","").trim():null;H&&L.includes(H)?(lo(H),localStorage.setItem("claude-model",H),D(q=>[...q,{type:"assistant",content:`已切换到模型: **${H}**`,timestamp:Date.now()}])):D(H?q=>[...q,{type:"assistant",content:`无效的模型: ${H}
76
76
 
77
77
  **可用模型**: ${L.join(", ")}`,timestamp:Date.now()}]:q=>[...q,{type:"assistant",content:`**当前模型**: ${St}
78
78
 
package/dist/index.html CHANGED
@@ -25,7 +25,7 @@
25
25
 
26
26
  <!-- Prevent zoom on iOS -->
27
27
  <meta name="format-detection" content="telephone=no" />
28
- <script type="module" crossorigin src="/assets/index-CW6M7hpM.js"></script>
28
+ <script type="module" crossorigin src="/assets/index-CFH3PKWA.js"></script>
29
29
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-C_uEg43g.js">
30
30
  <link rel="modulepreload" crossorigin href="/assets/vendor-codemirror-B2saKA4-.js">
31
31
  <link rel="modulepreload" crossorigin href="/assets/vendor-utils-00TdZexr.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ian2018cs/agenthub",
3
- "version": "0.1.98",
3
+ "version": "0.1.100",
4
4
  "description": "A web-based UI for AI Agents",
5
5
  "type": "module",
6
6
  "main": "server/index.js",
@@ -960,6 +960,16 @@ async function deleteProject(projectName, userUuid, options = {}) {
960
960
  // Remove from project config
961
961
  const config = await loadProjectConfig(userUuid);
962
962
  delete config[projectName];
963
+ // Also remove any config entry matching by originalPath.
964
+ // This handles encoding differences: Claude CLI replaces '_' with '-' in folder names,
965
+ // but addProjectManually only replaces '/' with '-', so keys may differ.
966
+ if (resolvedProjectDir) {
967
+ for (const [key, entry] of Object.entries(config)) {
968
+ if (entry.originalPath === resolvedProjectDir) {
969
+ delete config[key];
970
+ }
971
+ }
972
+ }
963
973
  await saveProjectConfig(config, userUuid);
964
974
 
965
975
  // Clean up project-scoped MCP servers from .claude.json