cli-link 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -58,14 +58,14 @@ AgentPilot READY
58
58
  Mobile-first remote console for your local agent
59
59
 
60
60
  OPEN ON MOBILE
61
- Mobile http://192.168.1.23:5101/?token=...
61
+ Mobile http://192.168.1.23:51258/?token=...
62
62
  Scan use the QR code below
63
63
 
64
64
  QR CODE
65
65
  [terminal QR code]
66
66
 
67
67
  LOCAL ACCESS
68
- Local http://localhost:5101/?token=...
68
+ Local http://localhost:51258/?token=...
69
69
  Token enabled, required for browser/API/WebSocket access
70
70
 
71
71
  RUNTIME
@@ -75,11 +75,20 @@ RUNTIME
75
75
  MACOS LONG TASKS
76
76
  已启用 caffeinate -i,当前服务运行期间会阻止 Mac 空闲休眠。
77
77
  合盖或低电量等系统策略仍可能中断任务;长时间运行建议接入电源。
78
+
79
+ 这个机制主要防止“空闲后自动睡眠”。合盖、低电量、系统强制睡眠或断电仍可能中断任务;如果要离开电脑、从手机继续遥控长任务,建议接入电源,并按需开启 macOS 的防休眠选项:
80
+
81
+ 1. 打开 `系统设置` -> `电池` -> `选项...`。
82
+ 2. 开启“使用电源适配器供电且显示器关闭时,防止自动进入睡眠”。
83
+ 3. 点击“完成”。
84
+
85
+ 这样电脑接入电源且显示器关闭后,AgentPilot 后端和底层 CLI 更不容易被系统睡眠中断。
78
86
  ```
79
87
 
80
88
  默认行为:
81
89
 
82
- - 监听 `0.0.0.0:5101`,电脑访问 `http://localhost:5101`,手机访问终端打印的 `Mobile` 地址。
90
+ - 监听 `0.0.0.0:51258`,电脑访问 `http://localhost:51258`,手机访问终端打印的 `Mobile` 地址。
91
+ - 生产默认使用较小众的高位端口,降低与常见本地开发服务冲突的概率;如需固定为其它端口,可通过 `--port` 或 `PORT` 覆盖。
83
92
  - 终端会为第一个 `Mobile` 地址打印二维码,手机扫码即可打开。
84
93
  - NPX 启动默认生成一次性访问 token;缺少 token 或校验 cookie 时,前端页面、后端 API 和 WebSocket 都会返回 401。
85
94
  - 使用执行 `npx` 时的当前目录作为工作目录。
@@ -90,7 +99,7 @@ MACOS LONG TASKS
90
99
  常用参数:
91
100
 
92
101
  ```bash
93
- npx cli-link --port 5101
102
+ npx cli-link --port 51258
94
103
  npx cli-link --host 0.0.0.0
95
104
  npx cli-link --token your-fixed-token
96
105
  npx cli-link --no-token
@@ -212,7 +221,7 @@ AgentPilot 的设计目标是个人开发机上的 Agent 遥控器,不是多
212
221
 
213
222
  使用时建议遵守这些边界:
214
223
 
215
- - 只在可信的本机、内网或受控 VPN 中使用;不要把 NPX 启动的 `5101` 单端口,或本地开发调试的 `5101` 前端端口和 `3101` 后端 HTTP/WebSocket 端口直接暴露到公网。
224
+ - 只在可信的本机、内网或受控 VPN 中使用;不要把 NPX 启动的 `51258` 单端口,或本地开发调试的 `5101` 前端端口和 `3101` 后端 HTTP/WebSocket 端口直接暴露到公网。
216
225
  - 如果只需要本机访问,优先把前端和后端改为监听 `127.0.0.1`,或者用系统防火墙限制可访问来源。
217
226
  - 如果必须跨网络访问,建议放在带身份认证和 HTTPS/WSS 的反向代理或安全隧道后面,不要直接转发裸 HTTP/WebSocket 端口。
218
227
  - 公司 VPN 只解决“网络可达”问题,不等于应用层鉴权;同一 VPN 或同一网段内的非预期客户端仍然可能访问。
package/bin/agentpilot.js CHANGED
@@ -8,6 +8,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
8
8
  const __dirname = dirname(fileURLToPath(import.meta.url));
9
9
  const packageRoot = resolve(__dirname, '..');
10
10
  const packageJsonPath = join(packageRoot, 'package.json');
11
+ const DEFAULT_PORT = '51258';
11
12
 
12
13
  function readPackageJson() {
13
14
  return JSON.parse(readFileSync(packageJsonPath, 'utf8'));
@@ -22,7 +23,7 @@ Usage:
22
23
 
23
24
  Options:
24
25
  --host <host> Host to bind. Default: 0.0.0.0
25
- --port <port> Port to listen on. Default: 5101
26
+ --port <port> Port to listen on. Default: ${DEFAULT_PORT}
26
27
  --token <token> Fixed access token. Default: random per startup
27
28
  --no-token Disable access token checks
28
29
  --workdir <path> Project directory. Default: current directory
@@ -204,7 +205,7 @@ async function main() {
204
205
  return;
205
206
  }
206
207
 
207
- const port = validatePort(options.port || process.env.PORT || '5101');
208
+ const port = validatePort(options.port || process.env.PORT || DEFAULT_PORT);
208
209
  const host = options.host || process.env.HOST || '0.0.0.0';
209
210
  const workDir = resolveWorkDir(options.workdir);
210
211
  const serverEntry = join(packageRoot, 'dist', 'server', 'index.js');
@@ -1,3 +1,3 @@
1
- import{u as oe,h as xe,r as m,j as e}from"./vendor-react-DSV5aFEg.js";import{u as ce,s as N,g as me,c as g}from"./index-C89UCwGk.js";import{g as ue,M as C,W as ge}from"./WorkspaceLinkedText-D6hNg0T9.js";import{P as pe}from"./PageTopBar-SnTIrSb5.js";import{C as ye,X as K,L as O,j as he,g as L,q as H,r as R,s as fe,B as be,m as _,n as D,c as F,o as je,p as ke}from"./vendor-icons-S_ObYVVf.js";import{A as Ne,m as q}from"./vendor-motion-n6Lx6G4a.js";function G(r){if(/^```/.test(r.trim()))return r;try{const s=JSON.parse(r);return"```json\n"+JSON.stringify(s,null,2)+"\n```"}catch{}return r.split(`
1
+ import{u as oe,h as xe,r as m,j as e}from"./vendor-react-DSV5aFEg.js";import{u as ce,s as N,g as me,c as g}from"./index-DOgH1Kf3.js";import{g as ue,M as C,W as ge}from"./WorkspaceLinkedText-DQyPLk-X.js";import{P as pe}from"./PageTopBar-C8j-5s_3.js";import{C as ye,X as K,L as O,j as he,g as L,q as H,r as R,s as fe,B as be,m as _,n as D,c as F,o as je,p as ke}from"./vendor-icons-CNN4EKVi.js";import{A as Ne,m as q}from"./vendor-motion-n6Lx6G4a.js";function G(r){if(/^```/.test(r.trim()))return r;try{const s=JSON.parse(r);return"```json\n"+JSON.stringify(s,null,2)+"\n```"}catch{}return r.split(`
2
2
  `).map(s=>{const n=s.trim();if(!n)return s;try{const i=JSON.parse(n);return"```json\n"+JSON.stringify(i,null,2)+"\n```"}catch{return s}}).join(`
3
3
  `)}function V(r){const l=Date.now()-r,s=Math.floor(l/6e4);if(s<1)return"刚刚";if(s<60)return`${s}分钟前`;const n=Math.floor(s/60);if(n<24)return`${n}小时前`;const i=Math.floor(n/24);return i===1?"昨天":i<7?`${i}天前`:new Date(r).toLocaleDateString("zh-CN",{month:"short",day:"numeric"})}function we(r){return r.split(/[\\/]/).filter(Boolean).pop()||r}const ze=()=>{var A;const r=oe(),{cliConfig:t}=ce(),[l,s]=xe(),n=l.get("filter")||"all",i=l.get("detail"),[c,p]=m.useState([]),[d,u]=m.useState(!0),[b,h]=m.useState(""),[j,$]=m.useState(null),[I,k]=m.useState(""),[re,B]=m.useState(null),[P,w]=m.useState(""),v=m.useRef(null),T=m.useCallback(async()=>{try{const a=await N.fetchHistory();p(x=>a.map(y=>{const f=x.find(de=>de.id===y.id);return f!=null&&f.messagesLoaded?{...y,messagesLoaded:!0,messages:f.messages}:y}))}catch(a){console.error("[History] Failed to fetch:",a)}finally{u(!1)}},[]);m.useEffect(()=>{T()},[T]),m.useEffect(()=>{h(""),k(""),$(null),w(""),v.current=null},[i]),m.useEffect(()=>{const x=me().onMessage(y=>{y.type==="history_changed"&&T()});return()=>{x()}},[T]);const U=c.filter(a=>n==="all"?!0:n==="running"?a.status==="running"||a.status==="confirm":a.status===n),o=c.find(a=>a.id===i),W=o!=null&&o.messagesLoaded?ue(o.messages):[],M=(t==null?void 0:t.workDir)||((A=c.find(a=>a.workDir))==null?void 0:A.workDir)||"",te=M?we(M):"未选择工作目录";m.useEffect(()=>{if(!i||!o||o.messagesLoaded||v.current===i)return;let a=!1;return v.current=i,B(i),w(""),N.fetchHistoryTask(i).then(x=>{if(!a){if(!x){w("会话记录不存在或已被删除");return}p(y=>y.map(f=>f.id===x.id?x:f))}}).catch(x=>{a||(console.error("[History] Failed to fetch detail:",x),w(x instanceof Error?x.message:"加载会话记录失败"))}).finally(()=>{a||(B(null),v.current=null)}),()=>{a=!0}},[i,o==null?void 0:o.id,o==null?void 0:o.messagesLoaded]);const ae=a=>{s(x=>(x.set("filter",a),x.delete("detail"),x))},se=a=>{s(x=>(x.set("detail",a),x))},S=()=>{s(a=>(a.delete("detail"),a))},ne=async(a,x)=>{x.stopPropagation();try{await N.deleteHistoryTask(a),p(y=>y.filter(f=>f.id!==a)),i===a&&S()}catch(y){console.error("[History] Failed to delete:",y)}},le=async()=>{try{await N.clearHistory(),p([])}catch(a){console.error("[History] Failed to clear:",a)}},z=async()=>{if(!o||j)return;const a=b.trim();if(a){if(!o.canResume){k("该会话记录缺少可恢复的 CLI 会话 ID,无法继续追问");return}$(o.id),k("");try{await N.resumeHistoryTask(o.id,a),h(""),r("/session")}catch(x){k(x instanceof Error?x.message:"恢复会话记录失败")}finally{$(null)}}},ie=[{id:"all",label:"全部",count:c.length},{id:"running",label:"进行中",count:c.filter(a=>a.status==="running"||a.status==="confirm").length},{id:"completed",label:"已完成",count:c.filter(a=>a.status==="completed").length},{id:"failed",label:"失败",count:c.filter(a=>a.status==="failed").length}];return e.jsxs("div",{className:"flex flex-col h-full bg-gray-50 dark:bg-gray-950 relative",children:[e.jsx(pe,{title:"会话记录",meta:e.jsx("span",{className:"text-[10px] text-gray-500 dark:text-gray-400 truncate max-w-[120px] flex-shrink-0",title:M,children:te}),actions:c.length>0?e.jsx("button",{onClick:le,className:"text-xs text-gray-400 hover:text-red-500 transition-colors flex-shrink-0",children:"清空"}):void 0,bottom:e.jsx("div",{className:"flex px-2 overflow-x-auto hide-scrollbar",children:ie.map(a=>e.jsxs("button",{onClick:()=>ae(a.id),className:g("flex items-center gap-1.5 px-4 py-2.5 border-b-2 text-sm font-medium whitespace-nowrap transition-colors",n===a.id?"border-primary-600 text-primary-600 dark:text-primary-400":"border-transparent text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),children:[a.label,e.jsx("span",{className:g("text-[10px] px-1.5 py-0.5 rounded-full",n===a.id?"bg-primary-100 text-primary-700 dark:bg-primary-900 dark:text-primary-300":"bg-gray-100 text-gray-500 dark:bg-gray-800 dark:text-gray-400"),children:a.count})]},a.id))})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-3",children:U.length>0?U.map(a=>e.jsx(Re,{task:a,onClick:()=>se(a.id),onDelete:x=>ne(a.id,x)},a.id)):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-400 dark:text-gray-600 gap-3",children:[e.jsx(ye,{className:"w-12 h-12 opacity-20"}),e.jsx("p",{className:"text-sm",children:"暂无相关会话"})]})}),e.jsx(Ne,{children:i&&o&&e.jsxs(e.Fragment,{children:[e.jsx(q.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:S,className:"absolute inset-0 bg-black/40 z-40"}),e.jsxs(q.div,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",damping:25,stiffness:200},className:"absolute bottom-0 left-0 right-0 h-[85%] bg-white dark:bg-gray-900 rounded-t-2xl z-50 flex flex-col shadow-xl",children:[e.jsx("div",{className:"flex justify-center pt-3 pb-2 flex-shrink-0",onClick:S,children:e.jsx("div",{className:"w-12 h-1.5 bg-gray-300 dark:bg-gray-600 rounded-full"})}),e.jsxs("div",{className:"px-5 pb-4 border-b border-gray-100 dark:border-gray-800 flex-shrink-0",children:[e.jsxs("div",{className:"flex justify-between items-start gap-4 mb-3",children:[e.jsx("h2",{className:"text-base font-medium text-gray-900 dark:text-gray-100 leading-snug",children:o.title}),e.jsx("button",{onClick:S,className:"p-1 text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-full flex-shrink-0",children:e.jsx(K,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsx(ee,{status:o.status}),o.duration&&e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["耗时 ",o.duration]}),e.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:V(o.startTime)})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-5 bg-gray-50 dark:bg-gray-950",children:[e.jsx("div",{className:"text-center text-xs text-gray-400 dark:text-gray-600 mb-4",children:"完整消息流"}),re===o.id?e.jsxs("div",{className:"flex flex-col items-center justify-center mt-10 gap-2 text-gray-400 dark:text-gray-600",children:[e.jsx(O,{className:"w-5 h-5 animate-spin"}),e.jsx("div",{className:"text-sm",children:"正在加载会话详情"})]}):P?e.jsx("div",{className:"text-center text-sm text-red-500 dark:text-red-400 mt-8",children:P}):W.length>0?e.jsx("div",{className:"space-y-4",children:W.map(a=>e.jsx(ve,{message:a},a.id))}):o.messagesLoaded?e.jsx("div",{className:"text-center text-sm text-gray-400 dark:text-gray-600 mt-8",children:"无消息记录"}):e.jsx("div",{className:"text-center text-sm text-gray-400 dark:text-gray-600 mt-8",children:"点击后加载消息记录"})]}),e.jsx("div",{className:"border-t border-gray-100 dark:border-gray-800 bg-white dark:bg-gray-900 p-3 pb-safe flex-shrink-0",children:o.canResume?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("textarea",{value:b,onChange:a=>{h(a.target.value),k(""),a.currentTarget.style.height="auto",a.currentTarget.style.height=`${Math.min(a.currentTarget.scrollHeight,96)}px`},onKeyDown:a=>{a.key==="Enter"&&(a.metaKey||a.ctrlKey)&&(a.preventDefault(),z())},placeholder:"基于这段会话继续追问…",rows:1,disabled:j===o.id,className:"flex-1 min-h-[42px] max-h-24 resize-none rounded-2xl border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 px-4 py-2.5 text-sm text-gray-800 dark:text-gray-200 placeholder:text-gray-400 dark:placeholder:text-gray-600 outline-none focus:border-primary-400 focus:bg-white dark:focus:bg-gray-800 focus:ring-[3px] focus:ring-primary-100 dark:focus:ring-primary-900 hide-scrollbar"}),e.jsx("button",{type:"button",onClick:z,disabled:!b.trim()||j===o.id,className:g("p-2.5 rounded-full flex-shrink-0 transition-all duration-200 shadow-sm active:scale-95",b.trim()&&j!==o.id?"bg-primary-600 text-white hover:bg-primary-700":"bg-gray-200 dark:bg-gray-700 text-gray-400 dark:text-gray-500 shadow-none"),title:"继续追问",children:j===o.id?e.jsx(O,{className:"w-4 h-4 animate-spin"}):e.jsx(he,{className:"w-4 h-4"})})]}),I&&e.jsx("div",{className:"mt-2 text-xs text-red-500 dark:text-red-400 px-1",children:I})]}):e.jsx("div",{className:"rounded-xl border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-950 px-3 py-2 text-xs text-gray-500 dark:text-gray-400",children:"该会话记录缺少底层 CLI 会话 ID,无法继续追问。"})})]})]})})]})},ve=({message:r})=>{switch(r.type){case"system_group":return e.jsx(Ee,{group:r});case"tool_group":return e.jsx(Me,{group:r});case"user":return e.jsx("div",{className:"flex justify-end",children:e.jsx("div",{className:"bg-primary-600 text-white rounded-2xl rounded-tr-sm px-4 py-2.5 max-w-[85%] shadow-sm",children:e.jsx("p",{className:"text-[15px] leading-relaxed whitespace-pre-wrap",children:e.jsx(ge,{linkClassName:"text-white decoration-white/70",children:r.content})})})});case"ai":return e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 text-gray-800 dark:text-gray-200 rounded-2xl rounded-tl-md px-3.5 py-3 max-w-[88%] shadow-sm markdown-body overflow-hidden min-w-0",children:e.jsx(C,{children:r.content})})});case"tool":return e.jsx($e,{message:r});case"confirm":return e.jsx("div",{className:"flex justify-start",children:e.jsxs("div",{className:g("border rounded-xl px-4 py-2.5 max-w-[85%] shadow-sm",r.status==="approved"?"bg-green-50 dark:bg-green-950 border-green-200 dark:border-green-800":"bg-red-50 dark:bg-red-950 border-red-200 dark:border-red-800"),children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[r.status==="approved"?e.jsx(R,{className:"w-3.5 h-3.5 text-green-600"}):e.jsx(H,{className:"w-3.5 h-3.5 text-red-600"}),e.jsx("span",{className:g("text-xs font-medium",r.status==="approved"?"text-green-700 dark:text-green-400":"text-red-700 dark:text-red-400"),children:r.status==="approved"?"已批准":"已拒绝"})]}),e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:r.content})]})});case"system":{const t=r.details;if(t&&Object.keys(t).length>0){const l=t.subtype==="result",s=[];if(t.model&&s.push({label:"模型",value:t.model}),t.costUsd!=null&&s.push({label:"费用",value:`$${Number(t.costUsd).toFixed(4)}`}),t.durationMs!=null){const n=Math.round(Number(t.durationMs)/1e3);s.push({label:"耗时",value:n>=60?`${Math.floor(n/60)}m${n%60}s`:`${n}s`})}return t.numTurns!=null&&s.push({label:"轮次",value:String(t.numTurns)}),e.jsx("div",{className:"flex justify-start",children:e.jsxs("div",{className:`px-3 py-2 rounded-xl border max-w-[85%] ${l?"bg-green-50/80 dark:bg-green-950/40 border-green-200/60 dark:border-green-800/40":"bg-gray-50 dark:bg-gray-800/80 border-gray-200 dark:border-gray-700"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:`text-xs font-medium ${l?"text-green-700 dark:text-green-300":"text-gray-500 dark:text-gray-400"}`,children:r.content}),e.jsx("span",{className:"text-[10px] text-gray-400 dark:text-gray-500",children:r.time})]}),s.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((n,i)=>e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-full font-medium bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300",children:[e.jsx("span",{className:"opacity-60",children:n.label}),e.jsx("span",{className:"font-semibold",children:n.value})]},i))})]})})}return e.jsx("div",{className:"flex justify-start",children:e.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-600 bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded-full",children:r.content})})}case"thinking":return e.jsx(Le,{message:r});case"error":return e.jsx("div",{className:"flex justify-start",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-950 border border-red-100 dark:border-red-800 text-red-800 dark:text-red-300 rounded-xl px-4 py-2.5 max-w-[85%] shadow-sm flex items-start gap-2",children:[e.jsx(H,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("p",{className:"text-sm leading-relaxed",children:r.content})]})});default:return null}};function Te(r){const t=(r.toolName||r.content||"").toLowerCase();return["readfile","writefile","read","write","edit","multiedit"].includes(t)}function E(r){return r.toolName&&r.toolName!=="result"?r.toolName:r.content||"tool"}function Se(r){return X(r).join("、")||"工具调用"}function X(r){return Array.from(new Set(r.map(E).filter(Boolean)))}function Ce(r){if(r.some(t=>t.status==="failed"))return"failed";if(r.some(t=>t.status==="running"))return"running";if(r.some(t=>t.status==="success"))return"success"}function He(r){const t=r.filter(i=>i.status==="running").length,l=r.filter(i=>i.status==="failed").length,s=r.filter(i=>i.status==="success").length,n=[`${r.length} 个`];return t&&n.push(`${t} 运行中`),l&&n.push(`${l} 失败`),s&&!t&&!l&&n.push("已完成"),n.join(" · ")}function Q(r,t="w-4 h-4 text-primary-600 dark:text-primary-400"){return Te(r)?e.jsx(je,{className:t}):e.jsx(F,{className:t})}function Y({status:r,className:t="w-3.5 h-3.5"}){return r==="running"?e.jsx(ke,{className:g(t,"text-primary-500 animate-pulse")}):r==="success"?e.jsx(R,{className:g(t,"text-green-600")}):r==="failed"?e.jsx(H,{className:g(t,"text-red-600")}):null}function De({status:r}){return e.jsx("span",{className:g("w-1.5 h-1.5 rounded-full flex-shrink-0",r==="running"?"bg-primary-500 animate-pulse":r==="failed"?"bg-red-500":r==="success"?"bg-green-500":"bg-gray-300 dark:bg-gray-600")})}const Z=({message:r,compact:t=!1})=>{const l="max-h-32";return e.jsxs(e.Fragment,{children:[r.toolDetails&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-medium text-primary-600 dark:text-primary-400 uppercase tracking-wider mb-0.5",children:"输入"}),e.jsx("div",{className:g("text-xs text-gray-600 dark:text-gray-400 bg-white/50 dark:bg-gray-900/50 p-2 rounded-lg border border-primary-50 dark:border-gray-700 overflow-y-auto",l),children:e.jsx(C,{children:G(r.toolDetails)})})]}),r.toolResult&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-medium text-primary-600 dark:text-primary-400 uppercase tracking-wider mb-0.5",children:"输出"}),e.jsx("div",{className:g("text-xs p-2 rounded-lg overflow-y-auto",l,r.status==="failed"?"text-red-700 dark:text-red-300 bg-red-50/50 dark:bg-red-950/50 border border-red-100 dark:border-red-900":"text-gray-600 dark:text-gray-400 bg-white/50 dark:bg-gray-900/50 border border-primary-50 dark:border-gray-700"),children:e.jsx(C,{children:G(r.toolResult)})})]})]})},$e=({message:r})=>e.jsx("div",{className:"flex justify-start",children:e.jsxs("div",{className:"bg-primary-50 dark:bg-primary-950 border border-primary-100 dark:border-primary-900 rounded-xl px-3 py-2 max-w-[85%] flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[Q(r),e.jsx("span",{className:"text-sm text-primary-800 dark:text-primary-300 break-words min-w-0",children:r.content}),e.jsx("span",{className:"ml-auto flex-shrink-0",children:e.jsx(Y,{status:r.status})})]}),e.jsx(Z,{message:r})]})}),Me=({group:r})=>{const[t,l]=m.useState(!1),[s,n]=m.useState({}),i=Ce(r.messages),c=Se(r.messages),p=m.useCallback(d=>{n(u=>({...u,[d]:!u[d]}))},[]);return e.jsx("div",{className:"flex justify-start",children:e.jsxs("div",{className:"max-w-[85%] rounded-xl border border-primary-100 dark:border-gray-700 bg-primary-50/90 dark:bg-gray-800 overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>l(!t),className:"w-full px-3 py-2 flex items-center gap-2 text-left min-w-0 hover:bg-primary-100/60 dark:hover:bg-gray-700 transition-colors",children:[t?e.jsx(D,{className:"w-3.5 h-3.5 text-primary-500 flex-shrink-0"}):e.jsx(L,{className:"w-3.5 h-3.5 text-primary-500 flex-shrink-0"}),e.jsx(F,{className:"w-3.5 h-3.5 text-primary-600 dark:text-primary-400 flex-shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-primary-800 dark:text-primary-300 flex-shrink-0",children:"工具调用"}),e.jsx("span",{className:g("text-[10px] px-1.5 py-0.5 rounded-full flex-shrink-0",i==="failed"?"bg-red-100 text-red-700 dark:bg-red-950 dark:text-red-300":i==="running"?"bg-primary-100 text-primary-700 dark:bg-primary-950 dark:text-primary-300":"bg-green-100 text-green-700 dark:bg-green-950 dark:text-green-300"),children:He(r.messages)}),e.jsx("span",{className:"text-[10px] text-gray-400 dark:text-gray-500 flex-shrink-0",children:r.time}),e.jsx("span",{className:"min-w-0 truncate text-xs text-gray-600 dark:text-gray-400",title:c,children:c})]}),!t&&e.jsx("div",{className:"px-3 pb-2 flex flex-wrap gap-1.5",children:X(r.messages).map(d=>{const u=r.messages.find(b=>E(b)===d);return e.jsxs("span",{className:"inline-flex max-w-full min-w-0 items-center gap-1.5 text-[10px] px-1.5 py-0.5 rounded-full bg-white/70 dark:bg-gray-900/50 text-gray-600 dark:text-gray-300 border border-primary-100/60 dark:border-gray-700",title:d,children:[e.jsx(De,{status:u==null?void 0:u.status}),e.jsx("span",{className:"truncate text-left",children:d})]},d)})}),t&&e.jsx("div",{className:"border-t border-primary-100/80 dark:border-gray-700 divide-y divide-primary-100/70 dark:divide-gray-700",children:r.messages.map(d=>{const u=E(d),b=d.content&&d.content!==u,h=!!(d.toolDetails||d.toolResult),j=!!s[d.id];return e.jsxs("div",{className:"px-3 py-2 flex flex-col gap-1.5 min-w-0",children:[e.jsxs("button",{type:"button",onClick:()=>h&&p(d.id),className:g("w-full flex flex-col gap-1 min-w-0 text-left",h&&"cursor-pointer hover:text-primary-900 dark:hover:text-primary-200"),children:[e.jsxs("div",{className:"w-full flex items-start gap-2 min-w-0",children:[Q(d,"w-3.5 h-3.5 text-primary-600 dark:text-primary-400 flex-shrink-0 mt-0.5"),e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-semibold text-primary-800 dark:text-primary-300",title:u,children:u}),e.jsxs("span",{className:"ml-auto flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("span",{className:"text-[10px] text-gray-400 dark:text-gray-500 flex-shrink-0",children:d.time}),h&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-white/70 dark:bg-gray-900/50 text-gray-500 dark:text-gray-400 border border-primary-100/60 dark:border-gray-700",children:d.toolDetails&&d.toolResult?"输入/输出":d.toolDetails?"输入":"输出"}),e.jsx(Y,{status:d.status,className:"w-3 h-3"}),h&&(j?e.jsx(_,{className:"w-3 h-3 text-primary-500"}):e.jsx(D,{className:"w-3 h-3 text-primary-500"}))]})]}),b&&e.jsx("span",{className:"w-full pl-5 pr-1 text-xs text-gray-500 dark:text-gray-400 truncate min-w-0",children:d.content})]}),h&&j&&e.jsx(Z,{message:d,compact:!0})]},d.id)})})]})})};function J(r){const t=r.details;if(!t)return[];const l=[];if(t.model&&l.push({label:"模型",value:t.model}),t.costUsd!=null&&l.push({label:"费用",value:`$${Number(t.costUsd).toFixed(4)}`}),t.durationMs!=null){const s=Math.round(Number(t.durationMs)/1e3);l.push({label:"耗时",value:s>=60?`${Math.floor(s/60)}m${s%60}s`:`${s}s`})}if(t.numTurns!=null&&l.push({label:"轮次",value:String(t.numTurns)}),t.inputTokens!=null||t.outputTokens!=null){const s=t.inputTokens?Number(t.inputTokens).toLocaleString():"0",n=t.outputTokens?Number(t.outputTokens).toLocaleString():"0";l.push({label:"Token",value:`${s} → ${n}`})}return l}const Ee=({group:r})=>{const[t,l]=m.useState(!1),s=r.messages.length>1,n=r.messages[r.messages.length-1],i=J(n);return e.jsx("div",{className:"flex justify-start",children:e.jsxs("div",{className:"max-w-[85%] rounded-xl border border-gray-200 dark:border-gray-800 bg-gray-50/90 dark:bg-gray-900/80 overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>s&&l(!t),className:g("w-full px-3 py-2 flex items-center gap-2 text-left min-w-0",s&&"hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"),children:[s?t?e.jsx(D,{className:"w-3.5 h-3.5 text-gray-400 flex-shrink-0"}):e.jsx(L,{className:"w-3.5 h-3.5 text-gray-400 flex-shrink-0"}):e.jsx(F,{className:"w-3.5 h-3.5 text-gray-400 flex-shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-gray-600 dark:text-gray-300 flex-shrink-0",children:"系统消息"}),s&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-gray-200/70 dark:bg-gray-800 text-gray-500 dark:text-gray-400 flex-shrink-0",children:[r.messages.length," 条"]}),e.jsx("span",{className:"text-[10px] text-gray-400 dark:text-gray-500 flex-shrink-0",children:r.time}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate min-w-0",children:r.content})]}),!t&&i.length>0&&e.jsx("div",{className:"px-3 pb-2 flex flex-wrap gap-1.5",children:i.map((c,p)=>e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-full font-medium bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300 max-w-full",children:[e.jsx("span",{className:"opacity-60 flex-shrink-0",children:c.label}),e.jsx("span",{className:"font-semibold truncate",children:c.value})]},`${c.label}-${p}`))}),t&&s&&e.jsx("div",{className:"border-t border-gray-200/80 dark:border-gray-800 divide-y divide-gray-200/70 dark:divide-gray-800",children:r.messages.map(c=>{const p=J(c);return e.jsxs("div",{className:"px-3 py-2 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300 truncate min-w-0",children:c.content}),e.jsx("span",{className:"text-[10px] text-gray-400 dark:text-gray-500 flex-shrink-0",children:c.time})]}),p.length>0&&e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:p.map((d,u)=>e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-full font-medium bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300 max-w-full",children:[e.jsx("span",{className:"opacity-60 flex-shrink-0",children:d.label}),e.jsx("span",{className:"font-semibold truncate",children:d.value})]},`${d.label}-${u}`))})]},c.id)})})]})})},Le=({message:r})=>{const[t,l]=m.useState(!1);return e.jsx("div",{className:"flex justify-start",children:e.jsxs("div",{className:"bg-indigo-50/80 dark:bg-indigo-950/40 border border-indigo-200/60 dark:border-indigo-800/40 rounded-xl px-3 py-2 max-w-[85%] cursor-pointer hover:bg-indigo-100/60 dark:hover:bg-indigo-950/60 transition-colors",onClick:()=>l(!t),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(be,{className:"w-3.5 h-3.5 text-indigo-500 dark:text-indigo-400"}),e.jsx("span",{className:"text-xs font-medium text-indigo-600 dark:text-indigo-400",children:t?"思考过程":"思考中..."}),e.jsxs("span",{className:"text-[10px] text-indigo-400 dark:text-indigo-500",children:["(",r.content.length," 字)"]}),t?e.jsx(_,{className:"w-3 h-3 text-indigo-400"}):e.jsx(D,{className:"w-3 h-3 text-indigo-400"})]}),t&&e.jsx("div",{className:"mt-2 text-sm text-indigo-800/80 dark:text-indigo-200/80 markdown-body-sm prose-sm",children:e.jsx(C,{children:r.content})})]})})},Re=({task:r,onClick:t,onDelete:l})=>e.jsxs("div",{onClick:t,className:"bg-white dark:bg-gray-900 p-4 rounded-xl border border-gray-100 dark:border-gray-800 shadow-sm active:scale-[0.98] transition-transform cursor-pointer group",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx(ee,{status:r.status}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:V(r.startTime)}),e.jsx("button",{onClick:l,className:"p-0.5 text-gray-300 dark:text-gray-600 hover:text-red-400 opacity-0 group-hover:opacity-100 transition-all",children:e.jsx(K,{className:"w-3.5 h-3.5"})})]})]}),e.jsx("p",{className:"text-sm text-gray-800 dark:text-gray-200 font-medium line-clamp-2 mb-3 leading-relaxed",children:r.title}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{children:[r.confirmCount," 次确认"]}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[r.toolCount," 个工具调用"]}),r.duration&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:r.duration})]})]}),e.jsx(L,{className:"w-4 h-4 text-gray-300 dark:text-gray-600"})]})]}),ee=({status:r})=>{switch(r){case"running":return e.jsxs("div",{className:"flex items-center gap-1.5 text-primary-600 dark:text-primary-400",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-primary-600 dark:bg-primary-400 animate-pulse"}),e.jsx("span",{className:"text-xs font-medium",children:"进行中"})]});case"confirm":return e.jsxs("div",{className:"flex items-center gap-1.5 text-orange-600 dark:text-orange-400",children:[e.jsx(fe,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-xs font-medium",children:"等待确认"})]});case"completed":return e.jsxs("div",{className:"flex items-center gap-1.5 text-green-600",children:[e.jsx(R,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-xs font-medium",children:"已完成"})]});case"failed":return e.jsxs("div",{className:"flex items-center gap-1.5 text-red-600",children:[e.jsx(H,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-xs font-medium",children:"失败"})]})}};export{ze as History};
@@ -1 +1 @@
1
- import{u as x,r as f,j as m}from"./vendor-react-DSV5aFEg.js";import{u as k}from"./index-C89UCwGk.js";import{c as H}from"./code-highlight-CEcsuMpw.js";import{p as d,s as M}from"./WorkspaceLinkedText-D6hNg0T9.js";import{r as j,M as w,a as K}from"./vendor-markdown-BDwu-Ux6.js";import"./vendor-icons-S_ObYVVf.js";const P=[K];function R(t){return function(){return function(n){h(n,t)}}}function W(t){return(t==null?void 0:t.type)==="element"&&["a","code","pre"].includes(t.tagName)}function h(t,o){if(!(t!=null&&t.children)||W(t))return;const r=[];let n=!1;for(const e of t.children){if((e==null?void 0:e.type)==="text"&&typeof e.value=="string"){const c=M(e.value,o);if(c.length===1&&c[0].type==="text"){r.push(e);continue}n=!0;for(const i of c)i.type==="text"?r.push({type:"text",value:i.text}):r.push({type:"element",tagName:"a",properties:{href:i.target.href,title:`打开 ${i.target.path}:${i.target.line}`},children:[{type:"text",value:i.text}]});continue}h(e,o),r.push(e)}n&&(t.children=r)}function $(t){return t.startsWith("/workspace?")}function S({children:t,enableWorkspaceLinks:o=!0}){const r=x(),{cliConfig:n}=k(),e=n==null?void 0:n.workDir,c=f.useMemo(()=>{const s=[[j,H]];return o&&s.push(R(e)),s},[o,e]),i=f.useMemo(()=>({a({href:s,children:g,node:N,...l}){const a=typeof s=="string"?d(s,e):null,p=(a==null?void 0:a.href)||(typeof s=="string"&&$(s)?s:""),y=p||s;return m.jsx("a",{...l,href:y,title:a?`打开 ${a.path}:${a.line}`:l.title,onClick:u=>{!p||u.button!==0||u.metaKey||u.ctrlKey||u.shiftKey||u.altKey||(u.preventDefault(),r(p))},children:g})}}),[r,e]);return m.jsx(w,{remarkPlugins:P,rehypePlugins:c,components:i,children:t})}export{S as default};
1
+ import{u as x,r as f,j as m}from"./vendor-react-DSV5aFEg.js";import{u as k}from"./index-DOgH1Kf3.js";import{c as H}from"./code-highlight-CEcsuMpw.js";import{p as d,s as M}from"./WorkspaceLinkedText-DQyPLk-X.js";import{r as j,M as w,a as K}from"./vendor-markdown-BDwu-Ux6.js";import"./vendor-icons-CNN4EKVi.js";const P=[K];function R(t){return function(){return function(n){h(n,t)}}}function W(t){return(t==null?void 0:t.type)==="element"&&["a","code","pre"].includes(t.tagName)}function h(t,o){if(!(t!=null&&t.children)||W(t))return;const r=[];let n=!1;for(const e of t.children){if((e==null?void 0:e.type)==="text"&&typeof e.value=="string"){const c=M(e.value,o);if(c.length===1&&c[0].type==="text"){r.push(e);continue}n=!0;for(const i of c)i.type==="text"?r.push({type:"text",value:i.text}):r.push({type:"element",tagName:"a",properties:{href:i.target.href,title:`打开 ${i.target.path}:${i.target.line}`},children:[{type:"text",value:i.text}]});continue}h(e,o),r.push(e)}n&&(t.children=r)}function $(t){return t.startsWith("/workspace?")}function S({children:t,enableWorkspaceLinks:o=!0}){const r=x(),{cliConfig:n}=k(),e=n==null?void 0:n.workDir,c=f.useMemo(()=>{const s=[[j,H]];return o&&s.push(R(e)),s},[o,e]),i=f.useMemo(()=>({a({href:s,children:g,node:N,...l}){const a=typeof s=="string"?d(s,e):null,p=(a==null?void 0:a.href)||(typeof s=="string"&&$(s)?s:""),y=p||s;return m.jsx("a",{...l,href:y,title:a?`打开 ${a.path}:${a.line}`:l.title,onClick:u=>{!p||u.button!==0||u.metaKey||u.ctrlKey||u.shiftKey||u.altKey||(u.preventDefault(),r(p))},children:g})}}),[r,e]);return m.jsx(w,{remarkPlugins:P,rehypePlugins:c,components:i,children:t})}export{S as default};
@@ -1 +1 @@
1
- import{j as e}from"./vendor-react-DSV5aFEg.js";import{c}from"./index-C89UCwGk.js";const x=({title:a,meta:s,leading:i,actions:r,bottom:t,className:l})=>e.jsxs("div",{className:c("bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800 flex-shrink-0 pt-safe z-10",l),children:[e.jsxs("div",{className:"min-h-14 px-4 py-2.5 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[i,e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 truncate",children:a}),s&&e.jsx("div",{className:"mt-0.5 flex items-center gap-2 min-w-0",children:s})]})]}),r&&e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:r})]}),t]});export{x as P};
1
+ import{j as e}from"./vendor-react-DSV5aFEg.js";import{c}from"./index-DOgH1Kf3.js";const x=({title:a,meta:s,leading:i,actions:r,bottom:t,className:l})=>e.jsxs("div",{className:c("bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800 flex-shrink-0 pt-safe z-10",l),children:[e.jsxs("div",{className:"min-h-14 px-4 py-2.5 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[i,e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 truncate",children:a}),s&&e.jsx("div",{className:"mt-0.5 flex items-center gap-2 min-w-0",children:s})]})]}),r&&e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:r})]}),t]});export{x as P};
@@ -1,4 +1,4 @@
1
- import{r as i,j as e,R as F}from"./vendor-react-DSV5aFEg.js";import{u as bt}from"./vendor-virtual-CcftJrIC.js";import{u as yt,a as Be,c as g}from"./index-C89UCwGk.js";import{g as kt,M as ne,i as He,W as jt}from"./WorkspaceLinkedText-D6hNg0T9.js";import{P as wt}from"./PageTopBar-SnTIrSb5.js";import{b as le,c as oe,d as Nt,T as Se,A as vt,H as Ct,e as Oe,f as St,F as Tt,g as Te,h as De,i as Dt,j as Et,X as ie,k as Ee,l as Re,m as de,n as V,B as Rt,P as Pt,o as Ft,p as Lt}from"./vendor-icons-S_ObYVVf.js";function Ve(r){if(/^```/.test(r.trim()))return r;try{const l=JSON.parse(r);return"```json\n"+JSON.stringify(l,null,2)+"\n```"}catch{}return r.split(`
1
+ import{r as i,j as e,R as F}from"./vendor-react-DSV5aFEg.js";import{u as bt}from"./vendor-virtual-CcftJrIC.js";import{u as yt,a as Be,c as g}from"./index-DOgH1Kf3.js";import{g as kt,M as ne,i as He,W as jt}from"./WorkspaceLinkedText-DQyPLk-X.js";import{P as wt}from"./PageTopBar-C8j-5s_3.js";import{b as le,c as oe,d as Nt,T as Se,A as vt,H as Ct,e as Oe,f as St,F as Tt,g as Te,h as De,i as Dt,j as Et,X as ie,k as Ee,l as Re,m as de,n as V,B as Rt,P as Pt,o as Ft,p as Lt}from"./vendor-icons-CNN4EKVi.js";function Ve(r){if(/^```/.test(r.trim()))return r;try{const l=JSON.parse(r);return"```json\n"+JSON.stringify(l,null,2)+"\n```"}catch{}return r.split(`
2
2
  `).map(l=>{const a=l.trim();if(!a)return l;try{const d=JSON.parse(a);return"```json\n"+JSON.stringify(d,null,2)+"\n```"}catch{return l}}).join(`
3
3
  `)}function Mt(r){var a;const t=(r==null?void 0:r.cliCommand)||"",o=((a=t.split(/[\\/]/).pop())==null?void 0:a.toLowerCase())||t.toLowerCase();return((r==null?void 0:r.cliType)||(o.includes("codex")?"codex":"claude"))==="codex"?"Codex CLI":"Claude Code"}const sr=()=>{const{status:r,messages:t,connectionStatus:o,sendMessage:l,confirmResponse:a,questionResponse:d,interrupt:c,newSession:b,editUserMessage:j,cliConfig:m,tokenUsage:f,hasMoreMessagesBefore:x,isLoadingOlderMessages:w,loadOlderMessages:S}=yt(),h=Mt(m),[u,p]=i.useState(""),[N,v]=i.useState(!1),[C,k]=i.useState(!1),[_,R]=i.useState(""),[Je,ce]=i.useState([]),[M,Pe]=i.useState(!1),[Fe,xe]=i.useState(!1),[G,P]=i.useState(!1),[Le,qe]=i.useState(""),[Me,Xe]=i.useState([]),[Ie,Ye]=i.useState([]),[Ze,et]=i.useState(""),[tt,rt]=i.useState(!1),[X,$e]=i.useState(!1),[Y,I]=i.useState(""),[ue,W]=i.useState(!1),[L,Z]=i.useState(null),[K,Q]=i.useState(""),[me,ee]=i.useState(!1),[st,$]=i.useState(null),[ge,Ae]=i.useState({}),te=i.useRef(null),he=i.useRef(null),fe=i.useRef(null),pe=i.useRef(!0),J=i.useRef(),be=i.useRef(new Set),ye=i.useRef(!1),T=i.useMemo(()=>kt(t),[t]),A=bt({count:T.length,getScrollElement:()=>fe.current,estimateSize:s=>{const n=T[s];return n?n.type==="system_group"?ge[n.id]?48+n.messages.length*42:44:n.type==="tool_group"?ge[n.id]?72+n.messages.length*40:58:n.type==="system"&&!n.details&&n.content==="系统消息"?0:n.type==="system"&&!n.details?32:n.type==="thinking"?44:n.type==="tool"?56:n.type==="confirm"?80:n.type==="question"?100:n.type==="error"?60:80:80},overscan:5});i.useEffect(()=>{const s=fe.current;if(!s)return;const n=()=>{pe.current=s.scrollHeight-s.scrollTop-s.clientHeight<150,s.scrollTop<80&&x&&!w&&S()};return s.addEventListener("scroll",n,{passive:!0}),()=>s.removeEventListener("scroll",n)},[x,w,S]),i.useEffect(()=>{t.length===0&&(ye.current=!1,be.current.clear(),Ae({}))},[t.length]),i.useEffect(()=>{T.length>0&&!ye.current&&(ye.current=!0,requestAnimationFrame(()=>{A.scrollToIndex(T.length-1,{align:"end"}),pe.current=!0}))},[T.length,A]);const z=T.length>0?T[T.length-1]:null,at=(z==null?void 0:z.id)||"",nt=(z==null?void 0:z.content)||"";i.useEffect(()=>(T.length>0&&pe.current&&(J.current&&cancelAnimationFrame(J.current),J.current=requestAnimationFrame(()=>{A.scrollToIndex(T.length-1,{align:"end"})})),()=>{J.current&&cancelAnimationFrame(J.current)}),[T.length,at,nt,A]);const lt=i.useCallback(s=>{Ae(n=>({...n,[s]:!n[s]}))},[]),re=i.useCallback(()=>{const s=he.current,n=te.current;if(!s||!n)return;he.current=null;const y=Math.min(s.start,n.value.length),E=Math.min(s.end,n.value.length);n.focus(),n.setSelectionRange(y,E)},[]),D=i.useCallback((s,n=s.length)=>{he.current={start:n,end:n},p(s),requestAnimationFrame(re)},[re]);i.useLayoutEffect(()=>{re()},[u,re]);const Ue=i.useCallback(async()=>{if(!M){Pe(!0);try{const s=await Be.getSkills();ce(s.skills||[]),xe(!0)}catch{ce([]),xe(!0)}finally{Pe(!1)}}},[M]);i.useEffect(()=>{ce([]),xe(!1)},[m==null?void 0:m.workDir,m==null?void 0:m.cliCommand]),i.useEffect(()=>{C&&!Fe&&!M&&Ue()},[C,Fe,M,Ue]);const We=()=>{!u.trim()||r==="running"||(l(u),p(""),k(!1),R(""),W(!1),te.current&&(te.current.style.height="auto"))},it=s=>{const n=s.target.value;p(n);const y=s.target;if(y.style.height="auto",y.style.height=`${Math.min(y.scrollHeight,120)}px`,n.startsWith("/")){const E=n.slice(1).trimStart();R(E),C||k(!0),G&&(P(!1),I(""))}else if(n.startsWith("@")){const E=n.slice(1).trimStart();if(I(E),!G){P(!0);const H=(m==null?void 0:m.workDir)||"~";ae(H)}C&&(k(!1),R(""))}else C&&(k(!1),R("")),G&&(P(!1),I(""))},ot=s=>{a(s)},se=i.useCallback(s=>{if(s==="/"){k(!0),R(""),D("/",1);return}if(s==="@"){P(!0),I(""),D("@",1);const O=(m==null?void 0:m.workDir)||"~";ae(O);return}const n=u,y=n.trimStart(),E=s+" ",H=E.length;if(y===""){D(E,H);return}if(y.startsWith("/ ")||y.startsWith("! ")||y.startsWith("@ ")||y.startsWith("# ")){const O=y.slice(2);D(E+O,H);return}if(y.startsWith("/")||y.startsWith("!")||y.startsWith("@")||y.startsWith("#")){const O=y.indexOf(" "),pt=O>=0?y.slice(O+1):"";D(E+pt,H);return}D(E+n,H)},[m==null?void 0:m.workDir,u,D]),dt=i.useCallback(s=>{D(s+" ",s.length+1),k(!1),R("")},[D]),ae=i.useCallback(async s=>{$e(!0);try{const n=await Be.listFiles(s);qe(n.dir),Xe(n.dirs),Ye(n.files||[]),et(n.parent),rt(n.isRoot)}catch{}$e(!1)},[]),ct=i.useCallback(s=>{const n=Le.split("/").slice(0,3).join("/"),y=s.replace(n,"~");D("@"+y+" ",y.length+2),P(!1),I("")},[Le,D]),ze=i.useCallback(()=>t.filter(s=>s.type==="user"&&s.content.trim()).map(s=>s.content.trim()).filter((s,n,y)=>y.indexOf(s)===n).slice(-20),[t]),xt=i.useCallback(s=>{D(s),W(!1)},[D]),ut=i.useCallback(s=>{r!=="idle"||o!=="connected"||(Z(s.id),Q(s.content),$(null),k(!1),P(!1),W(!1))},[o,r]),mt=i.useCallback(()=>{Z(null),Q(""),ee(!1),$(null)},[]),gt=i.useCallback(async()=>{if(!L||me)return;const s=t.find(n=>n.id===L);if(!K.trim()){$("消息不能为空");return}if(s&&K.trim()===s.content.trim()){$("内容没有变化");return}ee(!0),$(null);try{await j(L,K),Z(null),Q("")}catch(n){$(n instanceof Error?n.message:"编辑消息失败")}finally{ee(!1)}},[j,L,me,K,t]);i.useEffect(()=>{L&&!t.some(s=>s.id===L)&&(Z(null),Q(""),$(null),ee(!1))},[L,t]);const U=o==="disconnected",B=o==="reconnecting",ht=r==="idle"&&o==="connected",ft=A.getVirtualItems(),ke=_.toLowerCase(),je=Je.filter(s=>!ke||s.command.toLowerCase().includes(ke)||s.description.toLowerCase().includes(ke));return e.jsxs("div",{className:"flex flex-col h-full bg-gray-50 dark:bg-gray-950",children:[e.jsx(wt,{leading:e.jsx("div",{className:"relative flex items-center justify-center w-4 h-4 flex-shrink-0",children:U?e.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-500"}):o==="connecting"?e.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-yellow-500 animate-pulse"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-green-500 z-10"}),r==="running"&&e.jsx("div",{className:"absolute w-4 h-4 rounded-full bg-green-500 opacity-30 animate-ping"})]})}),title:h,meta:e.jsxs(e.Fragment,{children:[(m==null?void 0:m.workDir)&&e.jsx("span",{className:"text-[10px] text-gray-500 dark:text-gray-400 truncate max-w-[120px] flex-shrink-0",children:m.workDir.split("/").pop()}),e.jsx("span",{className:g("text-[10px] px-1.5 py-0.5 rounded-full font-medium",U?"bg-red-50 dark:bg-red-950 text-red-600 dark:text-red-400":B||o==="connecting"?"bg-yellow-50 dark:bg-yellow-950 text-yellow-600 dark:text-yellow-400":r==="idle"?"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400":r==="running"?"bg-primary-50 dark:bg-primary-950 text-primary-600 dark:text-primary-400":r==="confirm"?"bg-orange-50 dark:bg-orange-950 text-orange-600 dark:text-orange-400":r==="question"?"bg-blue-50 dark:bg-blue-950 text-blue-600 dark:text-blue-400":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400"),children:U?"已断开":B?"重连中...":o==="connecting"?"连接中...":r==="idle"?"空闲":r==="running"?"进行中":r==="confirm"?"等待确认":r==="question"?"等待回答":"空闲"})]}),actions:e.jsxs(e.Fragment,{children:[f.inputTokens>0&&e.jsxs("span",{className:"text-[10px] text-gray-400 dark:text-gray-500 font-mono mr-1",title:`会话累计 Token
4
4
  输入: ${f.inputTokens.toLocaleString()}
@@ -1 +1 @@
1
- import{r as s,j as e,u as J}from"./vendor-react-DSV5aFEg.js";import{b as _,d as V,p as Y,a as Z,u as ee,e as re,c as g}from"./index-C89UCwGk.js";import{A as ae,m as q}from"./vendor-motion-n6Lx6G4a.js";import{X as se,F as R,f as te,g as ne,l as le,_ as z,h as de,$ as ie,a0 as ce,a1 as oe,a2 as xe,r as me,a3 as ge,a4 as ye,R as F,a5 as O,T as he,a6 as be,a7 as pe,b as ue,k as fe}from"./vendor-icons-S_ObYVVf.js";import{P as je}from"./PageTopBar-SnTIrSb5.js";function ke(){const[c,n]=s.useState(()=>_());s.useEffect(()=>V(()=>{n(_())}),[]);const l=s.useCallback(async()=>Y(),[]);return{...c,promptInstall:l}}const Ne={home:e.jsx(ce,{className:"w-4 h-4"}),desktop:e.jsx(ie,{className:"w-4 h-4"}),documents:e.jsx(de,{className:"w-4 h-4"}),downloads:e.jsx(z,{className:"w-4 h-4"})},ve=({open:c,currentDir:n,onSelect:l,onClose:d})=>{const[w,E]=s.useState(n),[t,A]=s.useState([]),[b,P]=s.useState(""),[C,x]=s.useState(!1),[f,T]=s.useState([]),[j,o]=s.useState(!1),[m,S]=s.useState(""),k=s.useCallback(async a=>{o(!0),S("");try{const i=await Z.listDir(a);E(i.dir),A(i.dirs),P(i.parent),x(i.isRoot),T(i.quickAccess)}catch(i){S(i.message||"加载失败")}finally{o(!1)}},[]);s.useEffect(()=>{c&&k(n)},[c,n,k]);const y=a=>{k(a)},N=()=>{l(w),d()},p=a=>{const i=t.length>0?a.split("/").slice(0,3).join("/"):a;return a.replace(i,"~").replace("//","/")};return e.jsx(ae,{children:c&&e.jsxs(e.Fragment,{children:[e.jsx(q.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 z-40",onClick:d}),e.jsxs(q.div,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",damping:25,stiffness:300},className:"fixed bottom-0 left-0 right-0 bg-white dark:bg-gray-900 rounded-t-2xl z-50 flex flex-col",style:{maxHeight:"80vh"},children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-100 dark:border-gray-800",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:"选择工作目录"}),e.jsx("button",{onClick:d,className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(se,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"px-4 py-2 border-b border-gray-100 dark:border-gray-800",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm font-mono text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-950 rounded-lg px-3 py-2 overflow-x-auto whitespace-nowrap",children:[e.jsx(R,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{children:p(w)})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-contain",children:[f.length>0&&e.jsxs("div",{className:"px-4 py-2",children:[e.jsx("div",{className:"text-xs font-medium text-gray-400 dark:text-gray-500 uppercase tracking-wider mb-1",children:"快捷访问"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:f.map(a=>e.jsxs("button",{onClick:()=>y(a.path),className:"flex items-center gap-2 px-3 py-2.5 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors text-left",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:Ne[a.icon]||e.jsx(R,{className:"w-4 h-4"})}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 truncate",children:a.name})]},a.path))})]}),e.jsxs("div",{className:"px-4 py-2",children:[e.jsx("div",{className:"text-xs font-medium text-gray-400 dark:text-gray-500 uppercase tracking-wider mb-1",children:"目录列表"}),!C&&e.jsxs("button",{onClick:()=>y(b),className:"w-full flex items-center gap-3 px-3 py-3 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors text-left",children:[e.jsx(te,{className:"w-5 h-5 text-gray-400"}),e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"返回上级目录"})]}),j&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"w-6 h-6 border-2 border-primary-600 border-t-transparent rounded-full animate-spin"})}),m&&e.jsx("div",{className:"px-3 py-4 text-center text-sm text-red-500",children:m}),!j&&!m&&t.length===0&&e.jsx("div",{className:"px-3 py-4 text-center text-sm text-gray-400",children:"此目录下没有子目录"}),!j&&!m&&t.map(a=>e.jsxs("button",{onClick:()=>y(a.path),className:"w-full flex items-center gap-3 px-3 py-3 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors text-left active:bg-gray-100 dark:active:bg-gray-700",children:[e.jsx(R,{className:"w-5 h-5 text-amber-500 dark:text-amber-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 flex-1 truncate",children:a.name}),e.jsx(ne,{className:"w-4 h-4 text-gray-300 dark:text-gray-600 flex-shrink-0"})]},a.path))]})]}),e.jsx("div",{className:"px-4 py-3 border-t border-gray-100 dark:border-gray-800 bg-white dark:bg-gray-900 pb-safe",children:e.jsxs("button",{onClick:N,className:"w-full py-3 flex items-center justify-center gap-2 text-sm font-medium text-white bg-primary-600 rounded-xl hover:bg-primary-700 transition-colors active:scale-[0.98]",children:[e.jsx(le,{className:"w-4 h-4"}),"使用此目录"]})})]})]})})},we=["--dangerously-bypass-approvals-and-sandbox","-m","gpt-5.5","-c",'model_reasoning_effort="xhigh"'],v={claude:{label:"Claude Code",command:"claude",cliArgs:["--dangerously-skip-permissions"],dangerArg:"--dangerously-skip-permissions"},codex:{label:"Codex CLI",command:"codex",cliArgs:we,dangerArg:"--dangerously-bypass-approvals-and-sandbox",modelLabel:"GPT-5.5",intelligenceLabel:"超好",speedLabel:"标准"}};function G(c){var d;const n=c||"";return n.trim()?(((d=n.split(/[\\/]/).pop())==null?void 0:d.toLowerCase())||n.toLowerCase()).includes("codex")?"codex":"claude":"codex"}const Pe=()=>{const c=J(),{connectionStatus:n,cliConfig:l,startCLI:d,restartCLI:w,setConfirmMode:E,status:t,newSession:A}=ee(),{theme:b,toggleTheme:P}=re(),{canPromptInstall:C,isInstalled:x,isInstalling:f,isIos:T,promptInstall:j}=ke(),[o,m]=s.useState("codex"),[S,k]=s.useState("key"),[y,N]=s.useState("codex"),[p,a]=s.useState("~"),[i,M]=s.useState(!1),h=n==="connected",D=t==="running"||t==="confirm"||t==="question",B=window.location.port||(window.location.protocol==="https:"?"443":"80");s.useEffect(()=>{if(l){const r=l.cliType||G(l.cliCommand);m(r),k(l.confirmMode),N(l.cliCommand),a(l.workDir)}},[l]);const I=(r=p,u=o,$=y)=>({cliType:u,cliCommand:$,workDir:r,confirmMode:S,cliArgs:v[u].cliArgs}),H=()=>{d(I())},Q=()=>{d(I())},U=()=>{w(),c("/session")},W=r=>{const u=v[r].command;r===o&&u===y||(m(r),N(u),h&&!D&&d(I(p,r,u)))},X=r=>{a(r),h&&d(I(r))},K=r=>{N(r),m(G(r))},L=v[o];return e.jsxs("div",{className:"flex flex-col h-full bg-gray-50 dark:bg-gray-950 overflow-y-auto",children:[e.jsx(je,{title:"设置",className:"sticky top-0"}),e.jsxs("div",{className:"p-4 space-y-6 pb-8",children:[e.jsxs("section",{children:[e.jsx("h2",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2 px-1",children:"外观"}),e.jsx("div",{className:"bg-white dark:bg-gray-900 rounded-xl border border-gray-100 dark:border-gray-800 shadow-sm overflow-hidden",children:e.jsxs("div",{className:"p-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[b==="dark"?e.jsx("div",{className:"w-10 h-10 rounded-full bg-gray-800 text-gray-300 flex items-center justify-center",children:e.jsx(oe,{className:"w-5 h-5"})}):e.jsx("div",{className:"w-10 h-10 rounded-full bg-yellow-50 text-yellow-600 flex items-center justify-center",children:e.jsx(xe,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:b==="dark"?"深色模式":"浅色模式"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:"切换界面主题"})]})]}),e.jsx("button",{onClick:P,className:g("relative inline-flex h-7 w-12 items-center rounded-full transition-colors",b==="dark"?"bg-primary-600":"bg-gray-300"),children:e.jsx("span",{className:g("inline-block h-5 w-5 transform rounded-full bg-white transition-transform shadow-sm",b==="dark"?"translate-x-6":"translate-x-1")})})]})})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2 px-1",children:"安装应用"}),e.jsx("div",{className:"bg-white dark:bg-gray-900 rounded-xl border border-gray-100 dark:border-gray-800 shadow-sm overflow-hidden",children:e.jsxs("div",{className:"p-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:g("w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0",x?"bg-green-50 dark:bg-green-950 text-green-600 dark:text-green-400":"bg-primary-50 dark:bg-primary-950 text-primary-600 dark:text-primary-400"),children:x?e.jsx(me,{className:"w-5 h-5"}):e.jsx(ge,{className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:x?"已安装为独立 App":"添加到主屏幕"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5 leading-relaxed",children:x?"当前正在独立窗口中运行":C?"从桌面或主屏幕直接启动 AgentPilot":T?"打开分享菜单后选择“添加到主屏幕”":"使用浏览器菜单安装 AgentPilot"})]})]}),C?e.jsxs("button",{onClick:j,disabled:f,className:"flex items-center justify-center gap-1.5 rounded-lg bg-primary-600 px-3 py-2 text-sm font-medium text-white hover:bg-primary-700 disabled:cursor-not-allowed disabled:opacity-60 transition-colors flex-shrink-0",children:[e.jsx(z,{className:"w-4 h-4"}),f?"安装中":"安装"]}):e.jsx("span",{className:g("text-xs px-2 py-1 rounded-full font-medium flex-shrink-0",x?"bg-green-50 dark:bg-green-950 text-green-700 dark:text-green-400":"bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400"),children:x?"已完成":"浏览器菜单"})]})})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2 px-1",children:"连接信息"}),e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-xl border border-gray-100 dark:border-gray-800 shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-gray-50 dark:border-gray-800 flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:g("w-10 h-10 rounded-full flex items-center justify-center",h?"bg-green-50 dark:bg-green-950 text-green-600 dark:text-green-400":"bg-red-50 dark:bg-red-950 text-red-600 dark:text-red-400"),children:e.jsx(ye,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Agent Server"}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx("div",{className:g("w-2 h-2 rounded-full",h?"bg-green-500":"bg-red-500")}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:n==="connected"?"已连接":n==="connecting"?"连接中...":n==="reconnecting"?"重连中...":"已断开"})]})]})]}),!h&&e.jsx("button",{onClick:Q,className:"p-2 text-primary-600 dark:text-primary-400 hover:bg-primary-50 dark:hover:bg-primary-950 rounded-full transition-colors",children:e.jsx(F,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"服务器地址"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-mono text-gray-900 dark:text-gray-100",children:window.location.hostname}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(O,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"端口"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-mono text-gray-900 dark:text-gray-100",children:B}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(O,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"CLI 状态"}),e.jsx("span",{className:g("text-xs px-2 py-0.5 rounded-full font-medium",t==="idle"?"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400":t==="running"?"bg-primary-50 dark:bg-primary-950 text-primary-600 dark:text-primary-400":t==="confirm"?"bg-orange-50 dark:bg-orange-950 text-orange-600 dark:text-orange-400":t==="question"?"bg-blue-50 dark:bg-blue-950 text-blue-600 dark:text-blue-400":"bg-red-50 dark:bg-red-950 text-red-600 dark:text-red-400"),children:t==="idle"?"空闲":t==="running"?"进行中":t==="confirm"?"等待确认":t==="question"?"等待回答":"未连接"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"权限模式"}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-medium bg-amber-50 dark:bg-amber-950 text-amber-700 dark:text-amber-400",children:"跳过权限检查"})]})]})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2 px-1",children:"CLI 配置"}),e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-xl border border-gray-100 dark:border-gray-800 shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-gray-50 dark:border-gray-800 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-primary-50 dark:bg-primary-950 text-primary-600 dark:text-primary-400 flex items-center justify-center",children:e.jsx(he,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"运行环境"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:"配置底层 Agent CLI 参数"})]})]}),e.jsxs("div",{className:"divide-y divide-gray-50 dark:divide-gray-800",children:[e.jsxs("div",{className:"w-full p-4 space-y-2",children:[e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"CLI 类型"}),e.jsx("div",{className:"grid grid-cols-2 gap-2 rounded-lg bg-gray-50 dark:bg-gray-800 p-1 border border-gray-200 dark:border-gray-700",children:Object.keys(v).map(r=>e.jsx("button",{onClick:()=>W(r),disabled:D,className:g("py-2 px-3 rounded-md text-sm font-medium transition-colors",o===r?"bg-white dark:bg-gray-900 text-primary-700 dark:text-primary-300 shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",D&&"opacity-60 cursor-not-allowed"),children:v[r].label},r))})]}),e.jsxs("div",{className:"w-full p-4 space-y-2",children:[e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"CLI 命令"}),e.jsx("input",{type:"text",value:y,onChange:r=>K(r.target.value),className:"w-full text-sm text-gray-900 dark:text-gray-100 font-mono bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg px-3 py-2 focus:outline-none focus:border-primary-500",disabled:h&&t!=="disconnected"})]}),e.jsxs("div",{className:"w-full p-4 space-y-2",children:[e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"工作目录"}),e.jsxs("button",{onClick:()=>M(!0),className:"w-full flex items-center gap-2 text-sm text-gray-900 dark:text-gray-100 font-mono bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg px-3 py-2 text-left hover:border-primary-500 transition-colors",children:[e.jsx(be,{className:"w-4 h-4 text-amber-500 flex-shrink-0"}),e.jsx("span",{className:"truncate flex-1",children:p})]})]}),o==="codex"&&e.jsxs("div",{className:"w-full p-4 flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Codex 档位"}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-1.5",children:[e.jsx("span",{className:"text-xs px-2 py-1 rounded-full bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300",children:L.modelLabel}),e.jsxs("span",{className:"text-xs px-2 py-1 rounded-full bg-green-50 dark:bg-green-950 text-green-700 dark:text-green-400",children:["智能度 ",L.intelligenceLabel]}),e.jsxs("span",{className:"text-xs px-2 py-1 rounded-full bg-blue-50 dark:bg-blue-950 text-blue-700 dark:text-blue-400",children:["速度 ",L.speedLabel]})]})]})]}),e.jsx("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 border-t border-gray-100 dark:border-gray-700 space-y-2",children:h?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{A(),c("/session")},className:"w-full py-2.5 flex items-center justify-center gap-2 text-sm font-medium text-white bg-primary-600 rounded-lg hover:bg-primary-700 transition-colors",children:[e.jsx(ue,{className:"w-4 h-4"}),"新开会话"]}),e.jsxs("button",{onClick:U,className:"w-full py-2.5 flex items-center justify-center gap-2 text-sm font-medium text-red-600 dark:text-red-400 bg-white dark:bg-gray-900 border border-red-100 dark:border-red-800 rounded-lg hover:bg-red-50 dark:hover:bg-red-950 transition-colors",children:[e.jsx(F,{className:"w-4 h-4"}),"重启 CLI 进程"]})]}):e.jsxs("button",{onClick:H,className:"w-full py-2.5 flex items-center justify-center gap-2 text-sm font-medium text-white bg-primary-600 rounded-lg hover:bg-primary-700 transition-colors",children:[e.jsx(pe,{className:"w-4 h-4"}),"启动 CLI"]})})]})]}),e.jsx("section",{children:e.jsx("div",{className:"bg-amber-50 dark:bg-amber-950 rounded-xl border border-amber-200 dark:border-amber-800 p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(fe,{className:"w-5 h-5 text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-amber-800 dark:text-amber-300",children:"危险模式已启用"}),e.jsxs("div",{className:"text-xs text-amber-700 dark:text-amber-400 mt-1 leading-relaxed",children:["当前使用 ",L.dangerArg," 运行,CLI 拥有完整的文件读写和命令执行权限,无需手动确认。请确保在可信环境中使用。",o==="codex"&&" Codex CLI 预设为 GPT-5.5 / 智能度超好 / 速度标准。"]})]})]})})}),e.jsxs("div",{className:"text-center pt-4 pb-8",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-400 dark:text-gray-600",children:"AgentPilot"}),e.jsx("div",{className:"text-xs text-gray-300 dark:text-gray-600 mt-1",children:"AI Agent 遥控器"}),e.jsx("div",{className:"text-[10px] text-gray-300 dark:text-gray-700 mt-2",children:"v0.1.0"})]})]}),e.jsx(ve,{open:i,currentDir:p,onSelect:X,onClose:()=>M(!1)})]})};export{Pe as Settings};
1
+ import{r as s,j as e,u as J}from"./vendor-react-DSV5aFEg.js";import{b as _,d as V,p as Y,a as Z,u as ee,e as re,c as g}from"./index-DOgH1Kf3.js";import{A as ae,m as q}from"./vendor-motion-n6Lx6G4a.js";import{X as se,F as R,f as te,g as ne,l as le,D as z,h as de,$ as ie,a0 as ce,a1 as oe,a2 as xe,r as me,a3 as ge,a4 as ye,R as F,a5 as O,T as he,a6 as be,a7 as pe,b as ue,k as fe}from"./vendor-icons-CNN4EKVi.js";import{P as je}from"./PageTopBar-C8j-5s_3.js";function ke(){const[c,n]=s.useState(()=>_());s.useEffect(()=>V(()=>{n(_())}),[]);const l=s.useCallback(async()=>Y(),[]);return{...c,promptInstall:l}}const Ne={home:e.jsx(ce,{className:"w-4 h-4"}),desktop:e.jsx(ie,{className:"w-4 h-4"}),documents:e.jsx(de,{className:"w-4 h-4"}),downloads:e.jsx(z,{className:"w-4 h-4"})},ve=({open:c,currentDir:n,onSelect:l,onClose:d})=>{const[w,E]=s.useState(n),[t,A]=s.useState([]),[b,P]=s.useState(""),[C,x]=s.useState(!1),[f,T]=s.useState([]),[j,o]=s.useState(!1),[m,S]=s.useState(""),k=s.useCallback(async a=>{o(!0),S("");try{const i=await Z.listDir(a);E(i.dir),A(i.dirs),P(i.parent),x(i.isRoot),T(i.quickAccess)}catch(i){S(i.message||"加载失败")}finally{o(!1)}},[]);s.useEffect(()=>{c&&k(n)},[c,n,k]);const y=a=>{k(a)},N=()=>{l(w),d()},p=a=>{const i=t.length>0?a.split("/").slice(0,3).join("/"):a;return a.replace(i,"~").replace("//","/")};return e.jsx(ae,{children:c&&e.jsxs(e.Fragment,{children:[e.jsx(q.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 z-40",onClick:d}),e.jsxs(q.div,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",damping:25,stiffness:300},className:"fixed bottom-0 left-0 right-0 bg-white dark:bg-gray-900 rounded-t-2xl z-50 flex flex-col",style:{maxHeight:"80vh"},children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-100 dark:border-gray-800",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:"选择工作目录"}),e.jsx("button",{onClick:d,className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(se,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"px-4 py-2 border-b border-gray-100 dark:border-gray-800",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm font-mono text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-950 rounded-lg px-3 py-2 overflow-x-auto whitespace-nowrap",children:[e.jsx(R,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{children:p(w)})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-contain",children:[f.length>0&&e.jsxs("div",{className:"px-4 py-2",children:[e.jsx("div",{className:"text-xs font-medium text-gray-400 dark:text-gray-500 uppercase tracking-wider mb-1",children:"快捷访问"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:f.map(a=>e.jsxs("button",{onClick:()=>y(a.path),className:"flex items-center gap-2 px-3 py-2.5 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors text-left",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:Ne[a.icon]||e.jsx(R,{className:"w-4 h-4"})}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 truncate",children:a.name})]},a.path))})]}),e.jsxs("div",{className:"px-4 py-2",children:[e.jsx("div",{className:"text-xs font-medium text-gray-400 dark:text-gray-500 uppercase tracking-wider mb-1",children:"目录列表"}),!C&&e.jsxs("button",{onClick:()=>y(b),className:"w-full flex items-center gap-3 px-3 py-3 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors text-left",children:[e.jsx(te,{className:"w-5 h-5 text-gray-400"}),e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"返回上级目录"})]}),j&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"w-6 h-6 border-2 border-primary-600 border-t-transparent rounded-full animate-spin"})}),m&&e.jsx("div",{className:"px-3 py-4 text-center text-sm text-red-500",children:m}),!j&&!m&&t.length===0&&e.jsx("div",{className:"px-3 py-4 text-center text-sm text-gray-400",children:"此目录下没有子目录"}),!j&&!m&&t.map(a=>e.jsxs("button",{onClick:()=>y(a.path),className:"w-full flex items-center gap-3 px-3 py-3 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors text-left active:bg-gray-100 dark:active:bg-gray-700",children:[e.jsx(R,{className:"w-5 h-5 text-amber-500 dark:text-amber-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 flex-1 truncate",children:a.name}),e.jsx(ne,{className:"w-4 h-4 text-gray-300 dark:text-gray-600 flex-shrink-0"})]},a.path))]})]}),e.jsx("div",{className:"px-4 py-3 border-t border-gray-100 dark:border-gray-800 bg-white dark:bg-gray-900 pb-safe",children:e.jsxs("button",{onClick:N,className:"w-full py-3 flex items-center justify-center gap-2 text-sm font-medium text-white bg-primary-600 rounded-xl hover:bg-primary-700 transition-colors active:scale-[0.98]",children:[e.jsx(le,{className:"w-4 h-4"}),"使用此目录"]})})]})]})})},we=["--dangerously-bypass-approvals-and-sandbox","-m","gpt-5.5","-c",'model_reasoning_effort="xhigh"'],v={claude:{label:"Claude Code",command:"claude",cliArgs:["--dangerously-skip-permissions"],dangerArg:"--dangerously-skip-permissions"},codex:{label:"Codex CLI",command:"codex",cliArgs:we,dangerArg:"--dangerously-bypass-approvals-and-sandbox",modelLabel:"GPT-5.5",intelligenceLabel:"超好",speedLabel:"标准"}};function G(c){var d;const n=c||"";return n.trim()?(((d=n.split(/[\\/]/).pop())==null?void 0:d.toLowerCase())||n.toLowerCase()).includes("codex")?"codex":"claude":"codex"}const Pe=()=>{const c=J(),{connectionStatus:n,cliConfig:l,startCLI:d,restartCLI:w,setConfirmMode:E,status:t,newSession:A}=ee(),{theme:b,toggleTheme:P}=re(),{canPromptInstall:C,isInstalled:x,isInstalling:f,isIos:T,promptInstall:j}=ke(),[o,m]=s.useState("codex"),[S,k]=s.useState("key"),[y,N]=s.useState("codex"),[p,a]=s.useState("~"),[i,M]=s.useState(!1),h=n==="connected",D=t==="running"||t==="confirm"||t==="question",B=window.location.port||(window.location.protocol==="https:"?"443":"80");s.useEffect(()=>{if(l){const r=l.cliType||G(l.cliCommand);m(r),k(l.confirmMode),N(l.cliCommand),a(l.workDir)}},[l]);const I=(r=p,u=o,$=y)=>({cliType:u,cliCommand:$,workDir:r,confirmMode:S,cliArgs:v[u].cliArgs}),H=()=>{d(I())},Q=()=>{d(I())},U=()=>{w(),c("/session")},W=r=>{const u=v[r].command;r===o&&u===y||(m(r),N(u),h&&!D&&d(I(p,r,u)))},X=r=>{a(r),h&&d(I(r))},K=r=>{N(r),m(G(r))},L=v[o];return e.jsxs("div",{className:"flex flex-col h-full bg-gray-50 dark:bg-gray-950 overflow-y-auto",children:[e.jsx(je,{title:"设置",className:"sticky top-0"}),e.jsxs("div",{className:"p-4 space-y-6 pb-8",children:[e.jsxs("section",{children:[e.jsx("h2",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2 px-1",children:"外观"}),e.jsx("div",{className:"bg-white dark:bg-gray-900 rounded-xl border border-gray-100 dark:border-gray-800 shadow-sm overflow-hidden",children:e.jsxs("div",{className:"p-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[b==="dark"?e.jsx("div",{className:"w-10 h-10 rounded-full bg-gray-800 text-gray-300 flex items-center justify-center",children:e.jsx(oe,{className:"w-5 h-5"})}):e.jsx("div",{className:"w-10 h-10 rounded-full bg-yellow-50 text-yellow-600 flex items-center justify-center",children:e.jsx(xe,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:b==="dark"?"深色模式":"浅色模式"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:"切换界面主题"})]})]}),e.jsx("button",{onClick:P,className:g("relative inline-flex h-7 w-12 items-center rounded-full transition-colors",b==="dark"?"bg-primary-600":"bg-gray-300"),children:e.jsx("span",{className:g("inline-block h-5 w-5 transform rounded-full bg-white transition-transform shadow-sm",b==="dark"?"translate-x-6":"translate-x-1")})})]})})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2 px-1",children:"安装应用"}),e.jsx("div",{className:"bg-white dark:bg-gray-900 rounded-xl border border-gray-100 dark:border-gray-800 shadow-sm overflow-hidden",children:e.jsxs("div",{className:"p-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:g("w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0",x?"bg-green-50 dark:bg-green-950 text-green-600 dark:text-green-400":"bg-primary-50 dark:bg-primary-950 text-primary-600 dark:text-primary-400"),children:x?e.jsx(me,{className:"w-5 h-5"}):e.jsx(ge,{className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:x?"已安装为独立 App":"添加到主屏幕"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5 leading-relaxed",children:x?"当前正在独立窗口中运行":C?"从桌面或主屏幕直接启动 AgentPilot":T?"打开分享菜单后选择“添加到主屏幕”":"使用浏览器菜单安装 AgentPilot"})]})]}),C?e.jsxs("button",{onClick:j,disabled:f,className:"flex items-center justify-center gap-1.5 rounded-lg bg-primary-600 px-3 py-2 text-sm font-medium text-white hover:bg-primary-700 disabled:cursor-not-allowed disabled:opacity-60 transition-colors flex-shrink-0",children:[e.jsx(z,{className:"w-4 h-4"}),f?"安装中":"安装"]}):e.jsx("span",{className:g("text-xs px-2 py-1 rounded-full font-medium flex-shrink-0",x?"bg-green-50 dark:bg-green-950 text-green-700 dark:text-green-400":"bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400"),children:x?"已完成":"浏览器菜单"})]})})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2 px-1",children:"连接信息"}),e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-xl border border-gray-100 dark:border-gray-800 shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-gray-50 dark:border-gray-800 flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:g("w-10 h-10 rounded-full flex items-center justify-center",h?"bg-green-50 dark:bg-green-950 text-green-600 dark:text-green-400":"bg-red-50 dark:bg-red-950 text-red-600 dark:text-red-400"),children:e.jsx(ye,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Agent Server"}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx("div",{className:g("w-2 h-2 rounded-full",h?"bg-green-500":"bg-red-500")}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:n==="connected"?"已连接":n==="connecting"?"连接中...":n==="reconnecting"?"重连中...":"已断开"})]})]})]}),!h&&e.jsx("button",{onClick:Q,className:"p-2 text-primary-600 dark:text-primary-400 hover:bg-primary-50 dark:hover:bg-primary-950 rounded-full transition-colors",children:e.jsx(F,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"服务器地址"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-mono text-gray-900 dark:text-gray-100",children:window.location.hostname}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(O,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"端口"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-mono text-gray-900 dark:text-gray-100",children:B}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(O,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"CLI 状态"}),e.jsx("span",{className:g("text-xs px-2 py-0.5 rounded-full font-medium",t==="idle"?"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400":t==="running"?"bg-primary-50 dark:bg-primary-950 text-primary-600 dark:text-primary-400":t==="confirm"?"bg-orange-50 dark:bg-orange-950 text-orange-600 dark:text-orange-400":t==="question"?"bg-blue-50 dark:bg-blue-950 text-blue-600 dark:text-blue-400":"bg-red-50 dark:bg-red-950 text-red-600 dark:text-red-400"),children:t==="idle"?"空闲":t==="running"?"进行中":t==="confirm"?"等待确认":t==="question"?"等待回答":"未连接"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"权限模式"}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-medium bg-amber-50 dark:bg-amber-950 text-amber-700 dark:text-amber-400",children:"跳过权限检查"})]})]})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2 px-1",children:"CLI 配置"}),e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-xl border border-gray-100 dark:border-gray-800 shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-gray-50 dark:border-gray-800 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-primary-50 dark:bg-primary-950 text-primary-600 dark:text-primary-400 flex items-center justify-center",children:e.jsx(he,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"运行环境"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:"配置底层 Agent CLI 参数"})]})]}),e.jsxs("div",{className:"divide-y divide-gray-50 dark:divide-gray-800",children:[e.jsxs("div",{className:"w-full p-4 space-y-2",children:[e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"CLI 类型"}),e.jsx("div",{className:"grid grid-cols-2 gap-2 rounded-lg bg-gray-50 dark:bg-gray-800 p-1 border border-gray-200 dark:border-gray-700",children:Object.keys(v).map(r=>e.jsx("button",{onClick:()=>W(r),disabled:D,className:g("py-2 px-3 rounded-md text-sm font-medium transition-colors",o===r?"bg-white dark:bg-gray-900 text-primary-700 dark:text-primary-300 shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",D&&"opacity-60 cursor-not-allowed"),children:v[r].label},r))})]}),e.jsxs("div",{className:"w-full p-4 space-y-2",children:[e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"CLI 命令"}),e.jsx("input",{type:"text",value:y,onChange:r=>K(r.target.value),className:"w-full text-sm text-gray-900 dark:text-gray-100 font-mono bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg px-3 py-2 focus:outline-none focus:border-primary-500",disabled:h&&t!=="disconnected"})]}),e.jsxs("div",{className:"w-full p-4 space-y-2",children:[e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"工作目录"}),e.jsxs("button",{onClick:()=>M(!0),className:"w-full flex items-center gap-2 text-sm text-gray-900 dark:text-gray-100 font-mono bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg px-3 py-2 text-left hover:border-primary-500 transition-colors",children:[e.jsx(be,{className:"w-4 h-4 text-amber-500 flex-shrink-0"}),e.jsx("span",{className:"truncate flex-1",children:p})]})]}),o==="codex"&&e.jsxs("div",{className:"w-full p-4 flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Codex 档位"}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-1.5",children:[e.jsx("span",{className:"text-xs px-2 py-1 rounded-full bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300",children:L.modelLabel}),e.jsxs("span",{className:"text-xs px-2 py-1 rounded-full bg-green-50 dark:bg-green-950 text-green-700 dark:text-green-400",children:["智能度 ",L.intelligenceLabel]}),e.jsxs("span",{className:"text-xs px-2 py-1 rounded-full bg-blue-50 dark:bg-blue-950 text-blue-700 dark:text-blue-400",children:["速度 ",L.speedLabel]})]})]})]}),e.jsx("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 border-t border-gray-100 dark:border-gray-700 space-y-2",children:h?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{A(),c("/session")},className:"w-full py-2.5 flex items-center justify-center gap-2 text-sm font-medium text-white bg-primary-600 rounded-lg hover:bg-primary-700 transition-colors",children:[e.jsx(ue,{className:"w-4 h-4"}),"新开会话"]}),e.jsxs("button",{onClick:U,className:"w-full py-2.5 flex items-center justify-center gap-2 text-sm font-medium text-red-600 dark:text-red-400 bg-white dark:bg-gray-900 border border-red-100 dark:border-red-800 rounded-lg hover:bg-red-50 dark:hover:bg-red-950 transition-colors",children:[e.jsx(F,{className:"w-4 h-4"}),"重启 CLI 进程"]})]}):e.jsxs("button",{onClick:H,className:"w-full py-2.5 flex items-center justify-center gap-2 text-sm font-medium text-white bg-primary-600 rounded-lg hover:bg-primary-700 transition-colors",children:[e.jsx(pe,{className:"w-4 h-4"}),"启动 CLI"]})})]})]}),e.jsx("section",{children:e.jsx("div",{className:"bg-amber-50 dark:bg-amber-950 rounded-xl border border-amber-200 dark:border-amber-800 p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(fe,{className:"w-5 h-5 text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-amber-800 dark:text-amber-300",children:"危险模式已启用"}),e.jsxs("div",{className:"text-xs text-amber-700 dark:text-amber-400 mt-1 leading-relaxed",children:["当前使用 ",L.dangerArg," 运行,CLI 拥有完整的文件读写和命令执行权限,无需手动确认。请确保在可信环境中使用。",o==="codex"&&" Codex CLI 预设为 GPT-5.5 / 智能度超好 / 速度标准。"]})]})]})})}),e.jsxs("div",{className:"text-center pt-4 pb-8",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-400 dark:text-gray-600",children:"AgentPilot"}),e.jsx("div",{className:"text-xs text-gray-300 dark:text-gray-600 mt-1",children:"AI Agent 遥控器"}),e.jsx("div",{className:"text-[10px] text-gray-300 dark:text-gray-700 mt-2",children:"v0.1.0"})]})]}),e.jsx(ve,{open:i,currentDir:p,onSelect:X,onClose:()=>M(!1)})]})};export{Pe as Settings};
@@ -0,0 +1,8 @@
1
+ import{r as l,j as e,R as ce,h as Wt}from"./vendor-react-DSV5aFEg.js";import{c as p,u as Rt,a as j}from"./index-DOgH1Kf3.js";import{c as zt}from"./code-highlight-CEcsuMpw.js";import{M as Gt,r as Mt}from"./vendor-markdown-BDwu-Ux6.js";import{P as Bt}from"./PageTopBar-C8j-5s_3.js";import{a as Tt,G as _,t as ie,R as Ht,g as te,k as N,L as v,f as Ut,F as tt,u as ae,v as Ee,D as it,w as Vt,x as _t,X as qt,h as ct,y as Ot,z as Kt,E as at,I as Yt,J as Jt,K as Xt,N as Qt,O as st,Q as Zt,U as ea,V as ta,W as aa,Y as sa,Z as ra,_ as na}from"./vendor-icons-CNN4EKVi.js";import{A as se,m as rt}from"./vendor-motion-n6Lx6G4a.js";const la=[[Mt,zt]];function ia(t){var s;const r=((s=t.match(/~{3,}/g))==null?void 0:s.reduce((o,n)=>Math.max(o,n.length),2))??2;return"~".repeat(r+1)}function ca(t){return t.replace(/[^\w#+.-]/g,"")}function oa(t,r){const s=ia(t),o=ca(r),n=t.endsWith(`
2
+ `)?"":`
3
+ `;return`${s}${o?` ${o}`:""}
4
+ ${t}${n}${s}`}function da(t,r){return t==null||typeof t=="boolean"?[[]]:typeof t=="string"||typeof t=="number"?String(t).split(`
5
+ `).map(s=>s?[s]:[]):Array.isArray(t)?Fe(t,r):ce.isValidElement(t)?Fe(t.props.children,r).map((o,n)=>o.length>0?[ce.cloneElement(t,{key:`${r}-${n}`},o)]:[]):[[t]]}function Fe(t,r="code"){const s=[[]];return ce.Children.forEach(t,(o,n)=>{da(o,`${r}-${n}`).forEach((d,c)=>{c===0?s[s.length-1].push(...d):s.push([...d])})}),s}function xa(t,r){const s=[...t];for(;s.length>r&&s[s.length-1].length===0;)s.pop();for(;s.length<r;)s.push([]);return s}function ma({children:t,className:r,expectedLineCount:s,lineNumberWidth:o,targetLine:n,targetLineRef:x}){const d=l.useMemo(()=>xa(Fe(t),s),[t,s]);return e.jsx("div",{className:"min-w-max py-3 font-mono text-[12px] leading-5",children:d.map((c,m)=>{const u=m+1,y=n===u;return e.jsxs("div",{ref:y?x:void 0,className:p("grid min-w-max",y?"bg-primary-50 text-primary-950 dark:bg-primary-950/45 dark:text-primary-100":"text-gray-800 dark:text-gray-200"),style:{gridTemplateColumns:`${o}ch minmax(0, 1fr)`},children:[e.jsx("div",{className:p("select-none border-r px-2 text-right text-[11px]",y?"border-primary-200 text-primary-600 dark:border-primary-800 dark:text-primary-300":"border-gray-100 text-gray-400 dark:border-gray-800 dark:text-gray-600"),children:u}),e.jsx("code",{className:p("whitespace-pre px-3 font-mono tabular-nums",r),children:c.length>0?c:" "})]},u)})})}function ga({content:t,language:r,lineNumberWidth:s,targetLine:o,targetLineRef:n}){const x=l.useMemo(()=>t.split(`
6
+ `).length,[t]),d=l.useMemo(()=>oa(t,r),[t,r]),c=l.useMemo(()=>({pre({children:m}){return e.jsx(e.Fragment,{children:m})},code({children:m,className:u}){return e.jsx(ma,{className:u,expectedLineCount:x,lineNumberWidth:s,targetLine:o,targetLineRef:n,children:m})}}),[x,s,o,n]);return e.jsx(Gt,{rehypePlugins:la,components:c,children:d})}const ha={".bash":"bash",".c":"c",".cc":"cpp",".conf":"ini",".cpp":"cpp",".cs":"csharp",".css":"css",".dart":"dart",".diff":"diff",".dockerfile":"dockerfile",".go":"go",".graphql":"graphql",".groovy":"groovy",".h":"cpp",".hpp":"cpp",".html":"html",".ini":"ini",".java":"java",".js":"javascript",".json":"json",".jsx":"jsx",".kt":"kotlin",".less":"less",".lua":"lua",".md":"markdown",".mjs":"javascript",".php":"php",".plist":"xml",".properties":"ini",".py":"python",".rb":"ruby",".rs":"rust",".scss":"scss",".sh":"bash",".sql":"sql",".svelte":"xml",".swift":"swift",".toml":"ini",".ts":"typescript",".tsx":"tsx",".vue":"xml",".xml":"xml",".yaml":"yaml",".yml":"yaml",".zsh":"bash"},nt={dockerfile:"dockerfile",makefile:"makefile","package.json":"json","pnpm-lock.yaml":"yaml","tsconfig.json":"json",vite:"typescript"};function oe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function A(t){const r=t.split("/").filter(Boolean);return r[r.length-1]||t||"工作目录"}function ve(t){return t?t.replace(/^\/Users\/[^/]+/,"~"):"未选择工作目录"}function lt(t){return t||"."}function ot(t){const r=new Date(t);return Number.isNaN(r.getTime())?t:new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(r)}function dt(t){const r=[];for(const s of t.replace(/\\/g,"/").replace(/^\/+/,"").split("/"))if(!(!s||s===".")){if(s===".."){if(r.length===0)return"";r.pop();continue}r.push(s)}return r.join("/")}function ua(t){const r=dt(t),s=r.lastIndexOf("/");return s>0?r.slice(0,s):""}function pa(t){if(!t)return null;const r=Number(t);return Number.isSafeInteger(r)&&r>0?r:null}function xt(t){const r=A(t).toLowerCase(),s=r.lastIndexOf(".");return s>0?r.slice(s):""}function fa(t){const r=A(t).toLowerCase();return nt[r]?nt[r]:r.startsWith("dockerfile")?"dockerfile":r.endsWith("rc")||r.startsWith(".env")?"ini":ha[xt(t)]||""}function de(t){const r=A(t).toLowerCase(),s=xt(t);return r==="package.json"||r.endsWith("lock.json")||r==="pnpm-lock.yaml"?{Icon:Kt,className:"text-orange-500 dark:text-orange-400",label:"包配置"}:r.startsWith("dockerfile")?{Icon:at,className:"text-blue-600 dark:text-blue-400",label:"Dockerfile"}:r==="makefile"||[".sh",".bash",".zsh"].includes(s)?{Icon:at,className:"text-slate-700 dark:text-slate-300",label:"脚本"}:r.startsWith(".env")||[".ini",".conf",".toml",".properties",".plist"].includes(s)?{Icon:Yt,className:"text-gray-600 dark:text-gray-400",label:"配置"}:[".json"].includes(s)?{Icon:Jt,className:"text-yellow-600 dark:text-yellow-400",label:"JSON"}:[".ts",".tsx",".js",".jsx",".mjs",".vue",".svelte"].includes(s)?{Icon:Xt,className:"text-sky-600 dark:text-sky-400",label:"前端代码"}:[".go",".rs",".py",".rb",".php",".java",".kt",".swift",".c",".cc",".cpp",".h",".hpp",".cs",".lua",".dart"].includes(s)?{Icon:Qt,className:"text-primary-600 dark:text-primary-400",label:"代码"}:[".css",".scss",".less"].includes(s)?{Icon:st,className:"text-pink-600 dark:text-pink-400",label:"样式"}:[".png",".jpg",".jpeg",".gif",".webp",".ico",".bmp",".avif",".svg"].includes(s)?{Icon:Zt,className:"text-emerald-600 dark:text-emerald-400",label:s===".svg"?"SVG":"图片"}:[".html",".xml"].includes(s)?{Icon:ea,className:"text-orange-600 dark:text-orange-400",label:"标记"}:[".md",".mdx",".txt",".log",".rst"].includes(s)?{Icon:ie,className:"text-gray-600 dark:text-gray-400",label:"文档"}:[".sql",".db",".sqlite"].includes(s)?{Icon:ta,className:"text-indigo-600 dark:text-indigo-400",label:"数据"}:[".zip",".gz",".tar",".tgz",".rar",".7z"].includes(s)?{Icon:aa,className:"text-amber-600 dark:text-amber-400",label:"压缩包"}:[".mp3",".wav",".ogg",".m4a"].includes(s)?{Icon:sa,className:"text-purple-600 dark:text-purple-400",label:"音频"}:[".mp4",".mov",".avi",".webm"].includes(s)?{Icon:ra,className:"text-purple-600 dark:text-purple-400",label:"视频"}:[".csv",".tsv",".xls",".xlsx"].includes(s)?{Icon:na,className:"text-green-700 dark:text-green-400",label:"表格"}:[".yaml",".yml"].includes(s)?{Icon:st,className:"text-red-600 dark:text-red-400",label:"YAML"}:{Icon:ct,className:"text-gray-500 dark:text-gray-400",label:"文件"}}function mt(t){return t.includes("D")?"text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-950/50 border-red-100 dark:border-red-900":t.includes("A")||t==="??"?"text-green-700 dark:text-green-400 bg-green-50 dark:bg-green-950/50 border-green-100 dark:border-green-900":t.includes("R")||t.includes("C")?"text-blue-700 dark:text-blue-400 bg-blue-50 dark:bg-blue-950/50 border-blue-100 dark:border-blue-900":t.includes("U")?"text-orange-700 dark:text-orange-400 bg-orange-50 dark:bg-orange-950/50 border-orange-100 dark:border-orange-900":"text-amber-700 dark:text-amber-400 bg-amber-50 dark:bg-amber-950/50 border-amber-100 dark:border-amber-900"}function Ce(t){return t.status==="??"||t.worktreeStatus!==" "&&t.worktreeStatus!=="?"&&t.worktreeStatus!=="!"}function re(t){return t.indexStatus!==" "&&t.indexStatus!=="?"&&t.indexStatus!=="!"}function ne(t){return t.replace(/^"|"$/g,"").replace(/^[ab]\//,"").replace(/^\/dev\/null$/,"/dev/null")}function ba(t){const r=t.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?/);return r?{oldLine:Number(r[1]),newLine:Number(r[2])}:{oldLine:0,newLine:0}}function ya(t){const r=[];let s=null,o=null,n=0,x=0;const d=()=>(s||(s={oldPath:"",newPath:"",meta:[],hunks:[],additions:0,deletions:0},r.push(s)),s);for(const c of t.split(`
7
+ `)){if(c.startsWith("diff --git ")){const u=c.split(" ");s={oldPath:ne(u[2]||""),newPath:ne(u[3]||u[2]||""),meta:[],hunks:[],additions:0,deletions:0},r.push(s),o=null;continue}if(c.startsWith("--- ")&&!c.startsWith("--- 已")){d().oldPath=ne(c.slice(4).trim());continue}if(c.startsWith("+++ ")){d().newPath=ne(c.slice(4).trim());continue}if(c.startsWith("@@")){const u=d();o={header:c,lines:[]},u.hunks.push(o);const y=ba(c);n=y.oldLine,x=y.newLine;continue}if(!o){c.trim()&&d().meta.push(c);continue}const m=d();c.startsWith("+")?(o.lines.push({kind:"add",newLine:x,content:c.slice(1)}),m.additions+=1,x+=1):c.startsWith("-")?(o.lines.push({kind:"delete",oldLine:n,content:c.slice(1)}),m.deletions+=1,n+=1):c.startsWith(" ")?(o.lines.push({kind:"context",oldLine:n,newLine:x,content:c.slice(1)}),n+=1,x+=1):c.startsWith("\\")?o.lines.push({kind:"note",content:c}):c.trim()&&o.lines.push({kind:"meta",content:c})}return r.filter(c=>c.hunks.length>0||c.meta.length>0)}const Le=({path:t,className:r="w-4 h-4 flex-shrink-0"})=>{const s=de(t),o=s.Icon;return e.jsx(o,{className:p(r,s.className),"aria-label":s.label})},$a=()=>{var Ze,et;const{cliConfig:t,connectionStatus:r}=Rt(),[s,o]=Wt(),[n,x]=l.useState("files"),[d,c]=l.useState(""),[m,u]=l.useState(null),[y,q]=l.useState(!1),[Pe,Ie]=l.useState(""),[L,xe]=l.useState(null),[ht,me]=l.useState(null),[f,ge]=l.useState(null),[$e,De]=l.useState(!1),[Ae,We]=l.useState(""),[G,he]=l.useState(!1),[Re,M]=l.useState(""),[g,ut]=l.useState(null),[ue,ze]=l.useState(!1),[Ge,Me]=l.useState(""),[k,pt]=l.useState(null),[pe,Be]=l.useState(!1),[Te,He]=l.useState(""),[Ue,W]=l.useState(""),[P,fe]=l.useState(null),[I,be]=l.useState(null),[ft,ye]=l.useState(!1),[ke,O]=l.useState(""),[bt,Ve]=l.useState(!1),[yt,_e]=l.useState(!1),[kt,C]=l.useState(""),[jt,B]=l.useState(""),[b,K]=l.useState(null),[wt,qe]=l.useState(!1),[Oe,Ke]=l.useState(""),[$,Y]=l.useState(null),[R,J]=l.useState(null),[Nt,Ye]=l.useState(!1),[Je,X]=l.useState(""),[D,T]=l.useState(null),S=(t==null?void 0:t.workDir)||"",w=r==="connected",Q=dt(s.get("file")||""),Xe=pa(s.get("line")),vt=(f==null?void 0:f.name)||(L?A(L):""),Ct=b?A(b):"",St=(D==null?void 0:D.shortHash)||((Ze=k==null?void 0:k.commits.find(a=>a.hash===R))==null?void 0:Ze.shortHash)||(R==null?void 0:R.slice(0,8))||"",je=b?(g==null?void 0:g.files.find(a=>a.path===b))||($==null?void 0:$.files.find(a=>a.path===b)):void 0,Et=!!(g!=null&&g.files.some(Ce)),Ft=!!(g!=null&&g.files.some(re)),H=(g==null?void 0:g.files.filter(re).length)||0;l.useEffect(()=>{c(""),xe(null),me(null),K(null),J(null),ge(null),M(""),he(!1),Y(null),T(null),X(""),W(""),fe(null),be(null),ye(!1),O(""),C(""),B("")},[S]);const we=l.useCallback(async(a=d)=>{q(!0),Ie("");try{const i=await j.listWorkdir(a);u({workDir:i.workDir,path:i.path||"",parent:i.parent||"",isRoot:!!i.isRoot,dirs:i.dirs||[],files:i.files||[]}),c(i.path||"")}catch(i){Ie(i instanceof Error?i.message:"加载失败")}finally{q(!1)}},[d]),E=l.useCallback(async()=>{ze(!0),Me(""),W("");try{const a=await j.getWorkdirChanges();ut({workDir:a.workDir,isGitRepo:!!a.isGitRepo,branch:a.branch||"",files:a.files||[],diff:a.diff||"",diffPath:a.diffPath,truncated:!!a.truncated})}catch(a){Me(a instanceof Error?a.message:"加载失败")}finally{ze(!1)}},[]),U=l.useCallback(async()=>{Be(!0),He("");try{const a=await j.getWorkdirCommits();pt({workDir:a.workDir,isGitRepo:!!a.isGitRepo,branch:a.branch||"",commits:a.commits||[]})}catch(a){He(a instanceof Error?a.message:"加载失败")}finally{Be(!1)}},[]);l.useEffect(()=>{!w||n!=="files"||we(d)},[w,n,d,S,we]),l.useEffect(()=>{!w||n!=="changes"||E()},[w,n,S,E]),l.useEffect(()=>{!w||n!=="commits"||U()},[w,n,S,U]);const Ne=l.useCallback(async(a,i=null)=>{xe(a),me(i),ge(null),We(""),M(""),De(!0);try{const F=await j.readWorkdirFile(a);ge(F)}catch(F){We(F instanceof Error?F.message:"读取失败")}finally{De(!1)}},[]);l.useEffect(()=>{!w||!Q||(x("files"),K(null),Y(null),J(null),T(null),c(ua(Q)),Ne(Q,Xe))},[w,Xe,Q,Ne,S]);const Lt=l.useCallback(()=>{if(xe(null),me(null),M(""),!s.has("file")&&!s.has("line"))return;const a=new URLSearchParams(s);a.delete("file"),a.delete("line"),o(a,{replace:!0})},[s,o]),Z=l.useCallback(()=>{if(L){he(!0),M("");try{const a=document.createElement("a");a.href=j.getWorkdirFileDownloadUrl(L),a.download=A(L)||"download",document.body.appendChild(a),a.click(),a.remove()}catch(a){M(a instanceof Error?a.message:"下载失败")}finally{window.setTimeout(()=>he(!1),800)}}},[L]),V=l.useCallback(async a=>{K(a),Y(null),Ke(""),qe(!0);try{const i=await j.getWorkdirChanges(a);Y({workDir:i.workDir,isGitRepo:!!i.isGitRepo,branch:i.branch||"",files:i.files||[],diff:i.diff||"",diffPath:i.diffPath,truncated:!!i.truncated})}catch(i){Ke(i instanceof Error?i.message:"读取失败")}finally{qe(!1)}},[]),Pt=l.useCallback(async a=>{J(a),T(null),X(""),Ye(!0);try{const i=await j.getWorkdirCommit(a);T({workDir:i.workDir,isGitRepo:!!i.isGitRepo,hash:i.hash,shortHash:i.shortHash,authorName:i.authorName,authorEmail:i.authorEmail,date:i.date,subject:i.subject,body:i.body||"",files:i.files||[],diff:i.diff||"",truncated:!!i.truncated})}catch(i){X(i instanceof Error?i.message:"读取失败")}finally{Ye(!1)}},[]),ee=l.useCallback(async(a,i)=>{fe(`${i}:${a}`),W("");try{i==="stage"?await j.stageWorkdirChanges(a):await j.unstageWorkdirChanges(a),await E(),b===a&&await V(a)}catch(F){W(F instanceof Error?F.message:i==="stage"?"暂存失败":"取消暂存失败")}finally{fe(null)}},[E,V,b]),Qe=l.useCallback(async a=>{be(a),W("");try{a==="stage"?await j.stageWorkdirChanges():await j.unstageWorkdirChanges(),await E(),b&&await V(b)}catch(i){W(i instanceof Error?i.message:a==="stage"?"暂存失败":"取消暂存失败")}finally{be(null)}},[E,V,b]),It=l.useCallback(()=>{ye(!0),C(""),B("")},[]),$t=l.useCallback(async()=>{if(H===0){C("请先暂存要提交的文件");return}_e(!0),C(""),B("");try{const a=await j.generateWorkdirCommitMessage();O(a.message||"")}catch(a){C(a instanceof Error?a.message:"生成提交信息失败")}finally{_e(!1)}},[H]),Dt=l.useCallback(async()=>{const a=ke.trim();if(!a){C("提交信息不能为空");return}if(H===0){C("请先暂存要提交的文件");return}Ve(!0),C(""),B("");try{const i=await j.commitWorkdirChanges(a);B(`已提交 ${i.commitHash}`),O(""),await E(),await U()}catch(i){C(i instanceof Error?i.message:"提交失败")}finally{Ve(!1)}},[ke,E,U,H]),At=l.useMemo(()=>{const a=d.split("/").filter(Boolean);return a.map((i,F)=>({label:i,path:a.slice(0,F+1).join("/")}))},[d]);return e.jsxs("div",{className:"flex flex-col h-full bg-gray-50 dark:bg-gray-950 relative",children:[e.jsx(Bt,{title:A(S),meta:e.jsx("span",{className:"text-[10px] text-gray-500 dark:text-gray-400 font-mono truncate max-w-[220px]",title:ve(S),children:ve(S)}),actions:e.jsx("button",{onClick:()=>n==="files"?we(d):n==="changes"?E():U(),disabled:!w||y||ue||pe,className:"w-9 h-9 rounded-full border border-gray-200 dark:border-gray-800 flex items-center justify-center text-gray-500 dark:text-gray-400 disabled:opacity-40 active:scale-95 transition-all",title:"刷新",children:e.jsx(Ht,{className:p("w-4 h-4",(y||ue||pe)&&"animate-spin")})}),bottom:e.jsx("div",{className:"px-4 pb-3",children:e.jsxs("div",{className:"grid grid-cols-3 p-1 rounded-xl bg-gray-100 dark:bg-gray-800",children:[e.jsxs("button",{type:"button",onClick:()=>x("files"),className:p("h-9 rounded-lg flex items-center justify-center gap-2 text-sm font-medium transition-colors",n==="files"?"bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100 shadow-sm":"text-gray-500 dark:text-gray-400"),children:[e.jsx(Tt,{className:"w-4 h-4"}),"代码"]}),e.jsxs("button",{type:"button",onClick:()=>x("changes"),className:p("h-9 rounded-lg flex items-center justify-center gap-2 text-sm font-medium transition-colors",n==="changes"?"bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100 shadow-sm":"text-gray-500 dark:text-gray-400"),children:[e.jsx(_,{className:"w-4 h-4"}),"变更"]}),e.jsxs("button",{type:"button",onClick:()=>x("commits"),className:p("h-9 rounded-lg flex items-center justify-center gap-2 text-sm font-medium transition-colors",n==="commits"?"bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100 shadow-sm":"text-gray-500 dark:text-gray-400"),children:[e.jsx(ie,{className:"w-4 h-4"}),"提交"]})]})})}),n==="files"?e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"px-4 py-2 bg-white dark:bg-gray-900 border-b border-gray-100 dark:border-gray-800 overflow-x-auto hide-scrollbar flex items-center gap-1 text-xs",children:[e.jsx("button",{onClick:()=>c(""),className:p("px-2 py-1 rounded-md flex-shrink-0",d?"text-gray-500 dark:text-gray-400":"text-primary-600 bg-primary-50 dark:bg-primary-950"),children:"."}),At.map(a=>e.jsxs(ce.Fragment,{children:[e.jsx(te,{className:"w-3 h-3 text-gray-300 flex-shrink-0"}),e.jsx("button",{onClick:()=>c(a.path),className:"px-2 py-1 rounded-md text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 whitespace-nowrap",children:a.label})]},a.path))]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:w?y?e.jsx(h,{icon:e.jsx(v,{className:"w-5 h-5 animate-spin"}),title:"正在加载"}):Pe?e.jsx(h,{icon:e.jsx(N,{className:"w-5 h-5"}),title:Pe,danger:!0}):m&&(m.dirs.length>0||m.files.length>0||!m.isRoot)?e.jsxs("div",{className:"py-2",children:[!m.isRoot&&e.jsxs("button",{onClick:()=>c(m.parent),className:"w-full px-4 py-3 flex items-center gap-3 text-left hover:bg-white dark:hover:bg-gray-900 transition-colors",children:[e.jsx(Ut,{className:"w-4 h-4 text-gray-400"}),e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"返回上级"})]}),m.dirs.map(a=>e.jsxs("button",{onClick:()=>c(a.path),className:"w-full px-4 py-3 flex items-center gap-3 text-left hover:bg-white dark:hover:bg-gray-900 transition-colors",children:[e.jsx(tt,{className:"w-4 h-4 text-amber-500 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-gray-800 dark:text-gray-200 flex-1 truncate",children:a.name}),e.jsx(te,{className:"w-4 h-4 text-gray-300 dark:text-gray-600 flex-shrink-0"})]},a.path)),m.files.map(a=>e.jsxs("button",{onClick:()=>Ne(a.path),className:"w-full px-4 py-3 flex items-center gap-3 text-left hover:bg-white dark:hover:bg-gray-900 transition-colors",children:[e.jsx(Le,{path:a.path}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm text-gray-800 dark:text-gray-200 truncate",children:a.name}),e.jsxs("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 font-mono truncate",children:[oe(a.size),a.ext?` · ${a.ext}`:""]})]})]},a.path))]}):e.jsx(h,{icon:e.jsx(tt,{className:"w-5 h-5"}),title:"空目录"}):e.jsx(h,{icon:e.jsx(N,{className:"w-5 h-5"}),title:"连接已断开"})})]}):n==="changes"?e.jsx("div",{className:"flex-1 overflow-y-auto",children:w?ue?e.jsx(h,{icon:e.jsx(v,{className:"w-5 h-5 animate-spin"}),title:"正在加载"}):Ge?e.jsx(h,{icon:e.jsx(N,{className:"w-5 h-5"}),title:Ge,danger:!0}):g&&!g.isGitRepo?e.jsx(h,{icon:e.jsx(ae,{className:"w-5 h-5"}),title:"非 Git 仓库"}):g&&g.files.length>0?e.jsxs("div",{className:"py-2",children:[e.jsxs("div",{className:"px-4 py-2 flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx(ae,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:g.branch||"HEAD"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 flex-wrap",children:[e.jsxs("span",{children:[g.files.length," 个文件"]}),Et&&e.jsx(z,{variant:"stage",label:"全部暂存",loading:I==="stage",disabled:I!==null,onClick:()=>Qe("stage")}),Ft&&e.jsx(z,{variant:"unstage",label:"全部取消",loading:I==="unstage",disabled:I!==null,onClick:()=>Qe("unstage")}),e.jsxs("button",{type:"button",onClick:It,className:"h-7 px-2.5 rounded-md border border-primary-200 dark:border-primary-900 bg-primary-50 dark:bg-primary-950/40 text-primary-700 dark:text-primary-300 flex items-center gap-1.5 text-xs font-medium active:scale-95 transition-all",title:"提交代码","aria-label":"提交代码",children:[e.jsx(Ee,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"提交"})]})]})]}),Ue&&e.jsxs("div",{className:"mx-4 mb-2 px-3 py-2 rounded-md border border-red-100 dark:border-red-900 bg-red-50 dark:bg-red-950/40 flex items-center gap-2 text-xs text-red-600 dark:text-red-300",children:[e.jsx(N,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsx("span",{className:"min-w-0 truncate",children:Ue})]}),g.files.map(a=>e.jsxs("div",{className:"w-full px-4 py-3 flex items-center gap-3 text-left hover:bg-white dark:hover:bg-gray-900 transition-colors",children:[e.jsxs("button",{type:"button",onClick:()=>V(a.path),className:"min-w-0 flex-1 flex items-center gap-3 text-left",children:[e.jsx("span",{className:p("w-14 h-6 rounded-full border flex items-center justify-center text-[11px] font-medium flex-shrink-0",mt(a.status)),children:a.label}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Le,{path:a.path,className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsx("div",{className:"text-sm text-gray-800 dark:text-gray-200 truncate",children:a.name})]}),e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 font-mono truncate",children:a.path})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[Ce(a)&&e.jsx(z,{variant:"stage",label:"暂存",loading:P===`stage:${a.path}`,disabled:P!==null||I!==null,onClick:i=>{i.stopPropagation(),ee(a.path,"stage")}}),re(a)&&e.jsx(z,{variant:"unstage",label:"取消",loading:P===`unstage:${a.path}`,disabled:P!==null||I!==null,onClick:i=>{i.stopPropagation(),ee(a.path,"unstage")}})]}),e.jsx(te,{className:"w-4 h-4 text-gray-300 dark:text-gray-600 flex-shrink-0"})]},`${a.status}-${a.path}`))]}):e.jsx(h,{icon:e.jsx(_,{className:"w-5 h-5"}),title:"工作区干净"}):e.jsx(h,{icon:e.jsx(N,{className:"w-5 h-5"}),title:"连接已断开"})}):e.jsx("div",{className:"flex-1 overflow-y-auto",children:w?pe?e.jsx(h,{icon:e.jsx(v,{className:"w-5 h-5 animate-spin"}),title:"正在加载"}):Te?e.jsx(h,{icon:e.jsx(N,{className:"w-5 h-5"}),title:Te,danger:!0}):k&&!k.isGitRepo?e.jsx(h,{icon:e.jsx(ae,{className:"w-5 h-5"}),title:"非 Git 仓库"}):k&&k.commits.length>0?e.jsxs("div",{className:"py-2",children:[e.jsxs("div",{className:"px-4 py-2 flex items-center justify-between gap-3 text-xs text-gray-500 dark:text-gray-400",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx(ae,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:k.branch||"HEAD"})]}),e.jsxs("span",{className:"flex-shrink-0",children:[k.commits.length," 条提交"]})]}),k.commits.map(a=>e.jsxs("button",{type:"button",onClick:()=>Pt(a.hash),className:"w-full px-4 py-3 flex items-center gap-3 text-left hover:bg-white dark:hover:bg-gray-900 transition-colors",children:[e.jsx("span",{className:"w-20 h-6 rounded-full border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 text-gray-600 dark:text-gray-300 font-mono text-[11px] flex items-center justify-center flex-shrink-0",children:a.shortHash}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:a.subject||"(无提交信息)"}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-2 min-w-0 text-[11px] text-gray-500 dark:text-gray-400",children:[e.jsx("span",{className:"truncate",children:a.authorName||a.authorEmail||"unknown"}),e.jsx("span",{className:"flex-shrink-0",children:"·"}),e.jsx("span",{className:"flex-shrink-0",children:ot(a.date)})]})]}),e.jsx(te,{className:"w-4 h-4 text-gray-300 dark:text-gray-600 flex-shrink-0"})]},a.hash))]}):e.jsx(h,{icon:e.jsx(ie,{className:"w-5 h-5"}),title:"暂无 commit 记录"}):e.jsx(h,{icon:e.jsx(N,{className:"w-5 h-5"}),title:"连接已断开"})}),e.jsx(se,{children:L&&e.jsx(le,{title:vt,subtitle:lt(L),onClose:Lt,actions:e.jsx("button",{type:"button",onClick:()=>void Z(),disabled:!f||$e||G,className:"w-8 h-8 rounded-full flex items-center justify-center text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-900 disabled:opacity-40 disabled:hover:bg-transparent active:scale-95 transition-all",title:"下载","aria-label":"下载文件",children:G?e.jsx(v,{className:"w-4 h-4 animate-spin"}):e.jsx(it,{className:"w-4 h-4"})}),children:e.jsxs("div",{className:"h-full min-h-0 flex flex-col",children:[Re&&e.jsx("div",{className:"px-4 py-2 border-b border-red-100 dark:border-red-950 bg-red-50 dark:bg-red-950/30 text-xs text-red-600 dark:text-red-300 flex-shrink-0",children:Re}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:$e?e.jsx(h,{icon:e.jsx(v,{className:"w-5 h-5 animate-spin"}),title:"正在读取",compact:!0}):Ae?e.jsx(h,{icon:e.jsx(N,{className:"w-5 h-5"}),title:Ae,danger:!0,compact:!0}):f!=null&&f.tooLarge?e.jsx(Se,{file:f,title:`文件过大:${oe(f.size)}`,downloading:G,onDownload:Z}):f!=null&&f.isImage?f.dataUrl?e.jsx(ja,{file:f}):e.jsx(Se,{file:f,title:"图片预览不可用",downloading:G,onDownload:Z}):f!=null&&f.isBinary?e.jsx(Se,{file:f,title:"二进制文件",downloading:G,onDownload:Z}):e.jsx(Na,{file:f,targetLine:ht})})]})})}),e.jsx(se,{children:b&&e.jsx(le,{title:Ct,subtitle:lt(b),onClose:()=>K(null),actions:je?e.jsxs("div",{className:"flex items-center gap-1.5",children:[Ce(je)&&e.jsx(z,{variant:"stage",label:"暂存",loading:P===`stage:${b}`,disabled:P!==null||I!==null,onClick:()=>ee(b,"stage")}),re(je)&&e.jsx(z,{variant:"unstage",label:"取消",loading:P===`unstage:${b}`,disabled:P!==null||I!==null,onClick:()=>ee(b,"unstage")})]}):void 0,children:wt?e.jsx(h,{icon:e.jsx(v,{className:"w-5 h-5 animate-spin"}),title:"正在读取",compact:!0}):Oe?e.jsx(h,{icon:e.jsx(N,{className:"w-5 h-5"}),title:Oe,danger:!0,compact:!0}):$!=null&&$.diff?e.jsx(gt,{diff:$.diff,truncated:$.truncated}):e.jsx(h,{icon:e.jsx(_,{className:"w-5 h-5"}),title:"暂无 diff 内容",compact:!0})})}),e.jsx(se,{children:R&&e.jsx(le,{title:St,subtitle:(D==null?void 0:D.subject)||((et=k==null?void 0:k.commits.find(a=>a.hash===R))==null?void 0:et.subject)||"commit 详情",onClose:()=>{J(null),T(null),X("")},children:Nt?e.jsx(h,{icon:e.jsx(v,{className:"w-5 h-5 animate-spin"}),title:"正在读取",compact:!0}):Je?e.jsx(h,{icon:e.jsx(N,{className:"w-5 h-5"}),title:Je,danger:!0,compact:!0}):D?e.jsx(wa,{commit:D}):e.jsx(h,{icon:e.jsx(ie,{className:"w-5 h-5"}),title:"暂无 commit 详情",compact:!0})})}),e.jsx(se,{children:ft&&e.jsx(le,{title:"提交代码",subtitle:g!=null&&g.branch?`当前分支:${g.branch}`:ve(S),onClose:()=>ye(!1),children:e.jsx(ka,{message:ke,onMessageChange:O,onGenerate:$t,onCommit:Dt,aiLoading:yt,commitLoading:bt,error:kt,result:jt,changedCount:(g==null?void 0:g.files.length)||0,stagedCount:H})})})]})},h=({icon:t,title:r,danger:s=!1,compact:o=!1})=>e.jsxs("div",{className:p("flex flex-col items-center justify-center gap-2 text-center",o?"h-full min-h-[220px]":"h-full min-h-[360px]"),children:[e.jsx("div",{className:p(s?"text-red-500 dark:text-red-400":"text-gray-400 dark:text-gray-600"),children:t}),e.jsx("div",{className:p("text-sm",s?"text-red-500 dark:text-red-400":"text-gray-400 dark:text-gray-600"),children:r})]}),ka=({message:t,onMessageChange:r,onGenerate:s,onCommit:o,aiLoading:n,commitLoading:x,error:d,result:c,changedCount:m,stagedCount:u})=>{const y=n||x;return e.jsxs("div",{className:"h-full bg-white dark:bg-gray-950 flex flex-col",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-gray-100 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/70 flex items-center justify-between gap-3 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx(_,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsxs("span",{className:"truncate",children:[u," 个已暂存 / ",m," 个文件"]})]}),e.jsxs("button",{type:"button",onClick:s,disabled:y||u===0,className:"h-8 px-3 rounded-md border border-violet-200 dark:border-violet-900 bg-violet-50 dark:bg-violet-950/40 text-violet-700 dark:text-violet-300 flex items-center gap-1.5 text-xs font-medium disabled:opacity-60 active:scale-95 transition-all",title:"AI 生成提交信息","aria-label":"AI 生成提交信息",children:[n?e.jsx(v,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Ot,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"AI 生成"})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 p-4 flex flex-col gap-3",children:[e.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",htmlFor:"workspace-commit-message",children:"Commit 信息"}),e.jsx("textarea",{id:"workspace-commit-message",value:t,onChange:q=>r(q.target.value),placeholder:"feat(scope): describe the change",className:"flex-1 min-h-[220px] resize-none rounded-lg border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-950 px-3 py-2 text-sm leading-6 font-mono text-gray-900 dark:text-gray-100 placeholder:text-gray-400 dark:placeholder:text-gray-600 focus:outline-none focus:ring-2 focus:ring-primary-500/40"}),d&&e.jsxs("div",{className:"px-3 py-2 rounded-md border border-red-100 dark:border-red-900 bg-red-50 dark:bg-red-950/40 flex items-center gap-2 text-xs text-red-600 dark:text-red-300",children:[e.jsx(N,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsx("span",{className:"min-w-0",children:d})]}),c&&e.jsxs("div",{className:"px-3 py-2 rounded-md border border-green-100 dark:border-green-900 bg-green-50 dark:bg-green-950/40 flex items-center gap-2 text-xs text-green-700 dark:text-green-300",children:[e.jsx(Ee,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsx("span",{className:"min-w-0",children:c})]}),e.jsxs("button",{type:"button",onClick:o,disabled:y||!t.trim()||u===0,className:"h-10 rounded-lg bg-primary-600 text-white text-sm font-medium flex items-center justify-center gap-2 disabled:opacity-50 active:scale-[0.99] transition-all",children:[x?e.jsx(v,{className:"w-4 h-4 animate-spin"}):e.jsx(Ee,{className:"w-4 h-4"}),e.jsx("span",{children:"提交代码"})]})]})]})},z=({variant:t,label:r,loading:s,disabled:o=!1,onClick:n})=>{const x=t==="stage";return e.jsxs("button",{type:"button",onClick:n,disabled:o||s,className:p("h-7 px-2.5 rounded-md border flex items-center gap-1.5 text-xs font-medium flex-shrink-0 disabled:opacity-60 active:scale-95 transition-all",x?"border-green-200 dark:border-green-900 bg-green-50 dark:bg-green-950/40 text-green-700 dark:text-green-300":"border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900 text-gray-600 dark:text-gray-300"),title:r,"aria-label":r,children:[s?e.jsx(v,{className:"w-3.5 h-3.5 animate-spin"}):x?e.jsx(Vt,{className:"w-3.5 h-3.5"}):e.jsx(_t,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:r})]})},Se=({file:t,title:r,downloading:s,onDownload:o})=>{const n=de(t.path||t.name||""),x=n.Icon;return e.jsxs("div",{className:"h-full bg-white dark:bg-gray-950 flex flex-col items-center justify-center gap-4 px-6 text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900 flex items-center justify-center",children:e.jsx(x,{className:p("w-7 h-7",n.className)})}),e.jsxs("div",{className:"max-w-full space-y-1",children:[e.jsx("div",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:r}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono truncate max-w-[280px]",children:[t.mimeType||n.label," · ",oe(t.size)]})]}),e.jsxs("button",{type:"button",onClick:()=>void o(),disabled:s,className:"h-10 px-4 rounded-lg bg-primary-600 text-white text-sm font-medium flex items-center justify-center gap-2 disabled:opacity-60 active:scale-[0.99] transition-all",children:[s?e.jsx(v,{className:"w-4 h-4 animate-spin"}):e.jsx(it,{className:"w-4 h-4"}),e.jsx("span",{children:"下载文件"})]})]})},ja=({file:t})=>{const r=de(t.path||t.name||""),s=r.Icon;return e.jsxs("div",{className:"h-full overflow-hidden bg-white dark:bg-gray-950 flex flex-col",children:[e.jsxs("div",{className:"px-4 py-2 border-b border-gray-100 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/70 flex items-center justify-between gap-3 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(s,{className:p("w-4 h-4 flex-shrink-0",r.className)}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:r.label})]}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0 text-[11px] font-mono text-gray-400 dark:text-gray-500",children:[t.mimeType&&e.jsx("span",{className:"truncate",children:t.mimeType}),e.jsx("span",{className:"flex-shrink-0",children:oe(t.size)})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto workspace-image-canvas p-4",children:e.jsx("div",{className:"h-full min-h-[320px] flex items-center justify-center",children:e.jsx("img",{src:t.dataUrl,alt:t.name,className:"max-w-full max-h-[calc(86vh-132px)] object-contain rounded border border-gray-200/80 dark:border-gray-800/80 bg-white/80 dark:bg-gray-950/80 shadow-sm",draggable:!1})})})]})},wa=({commit:t})=>e.jsxs("div",{className:"h-full bg-white dark:bg-gray-950 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-gray-100 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/70 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 break-words",children:t.subject||"(无提交信息)"}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 min-w-0 text-[11px] text-gray-500 dark:text-gray-400",children:[e.jsx("span",{className:"font-mono flex-shrink-0",children:t.shortHash}),e.jsx("span",{className:"flex-shrink-0",children:"·"}),e.jsx("span",{className:"truncate",children:t.authorName||t.authorEmail||"unknown"}),e.jsx("span",{className:"flex-shrink-0",children:"·"}),e.jsx("span",{className:"flex-shrink-0",children:ot(t.date)})]})]}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:[t.files.length," 个文件"]})]}),t.body&&e.jsx("div",{className:"mt-3 rounded-lg border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-950 px-3 py-2 text-xs leading-5 text-gray-700 dark:text-gray-300 whitespace-pre-wrap break-words",children:t.body})]}),t.files.length>0&&e.jsx("div",{className:"max-h-40 overflow-y-auto border-b border-gray-100 dark:border-gray-800 bg-white dark:bg-gray-950 flex-shrink-0",children:t.files.map(r=>e.jsxs("div",{className:"px-4 py-2 flex items-center gap-3 border-b border-gray-50 dark:border-gray-900 last:border-b-0",children:[e.jsx("span",{className:p("w-14 h-6 rounded-full border flex items-center justify-center text-[11px] font-medium flex-shrink-0",mt(r.status)),children:r.label}),e.jsx(Le,{path:r.path,className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs text-gray-800 dark:text-gray-200 truncate",children:r.path}),r.oldPath&&r.oldPath!==r.path&&e.jsxs("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 font-mono truncate",children:[r.oldPath," ","->"," ",r.path]})]})]},`${r.status}-${r.oldPath||""}-${r.path}`))}),e.jsx("div",{className:"flex-1 min-h-0",children:t.diff?e.jsx(gt,{diff:t.diff,truncated:t.truncated}):e.jsx(h,{icon:e.jsx(_,{className:"w-5 h-5"}),title:"暂无 diff 内容",compact:!0})})]}),Na=({file:t,targetLine:r})=>{const s=fa((t==null?void 0:t.path)||(t==null?void 0:t.name)||""),o=de((t==null?void 0:t.path)||(t==null?void 0:t.name)||""),n=o.Icon,x=l.useMemo(()=>((t==null?void 0:t.content)??"").split(`
8
+ `),[t==null?void 0:t.content]),d=Math.max(2,String(x.length).length)+1,c=l.useRef(null);return l.useEffect(()=>{if(!t||!r)return;const m=requestAnimationFrame(()=>{var u;(u=c.current)==null||u.scrollIntoView({block:"center",inline:"nearest"})});return()=>cancelAnimationFrame(m)},[t,r]),t?e.jsxs("div",{className:"h-full overflow-hidden bg-white dark:bg-gray-950 flex flex-col",children:[e.jsxs("div",{className:"px-4 py-2 border-b border-gray-100 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/70 flex items-center justify-between gap-3 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(n,{className:p("w-4 h-4 flex-shrink-0",o.className)}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.label})]}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0 text-[11px] font-mono text-gray-400 dark:text-gray-500",children:[r&&e.jsxs("span",{className:"flex-shrink-0",children:["L",r]}),s&&e.jsx("span",{className:"flex-shrink-0",children:s})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto bg-white dark:bg-gray-950 workspace-code-preview",children:e.jsx(ga,{content:t.content,language:s,lineNumberWidth:d,targetLine:r,targetLineRef:c})})]}):e.jsx(h,{icon:e.jsx(ct,{className:"w-5 h-5"}),title:"暂无文件内容",compact:!0})},gt=({diff:t,truncated:r})=>{const s=l.useMemo(()=>ya(t),[t]),o=l.useMemo(()=>s.reduce((n,x)=>({additions:n.additions+x.additions,deletions:n.deletions+x.deletions}),{additions:0,deletions:0}),[s]);return s.length===0?e.jsx("pre",{className:"min-h-full overflow-auto p-4 text-[12px] leading-5 font-mono text-gray-800 dark:text-gray-200 whitespace-pre-wrap break-words bg-white dark:bg-gray-950",children:t}):e.jsxs("div",{className:"h-full overflow-y-auto bg-white dark:bg-gray-950",children:[e.jsxs("div",{className:"sticky top-0 z-10 border-b border-gray-100 dark:border-gray-800 bg-white/95 dark:bg-gray-950/95 backdrop-blur px-4 py-2 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[s.length," 个文件"]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[e.jsxs("span",{className:"text-green-700 dark:text-green-400",children:["+",o.additions]}),e.jsxs("span",{className:"text-red-700 dark:text-red-400",children:["-",o.deletions]})]})]}),r&&e.jsx("div",{className:"mx-4 mt-3 rounded-lg border border-amber-200 dark:border-amber-900 bg-amber-50 dark:bg-amber-950/40 px-3 py-2 text-xs text-amber-800 dark:text-amber-300",children:"diff 内容过长,已截断。"}),e.jsx("div",{className:"pb-4",children:s.map((n,x)=>e.jsxs("div",{className:"border-b border-gray-100 dark:border-gray-800 last:border-b-0",children:[e.jsxs("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/70 border-b border-gray-100 dark:border-gray-800",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:n.newPath||n.oldPath||"变更文件"}),n.oldPath&&n.newPath&&n.oldPath!==n.newPath&&e.jsxs("div",{className:"text-[11px] text-gray-500 dark:text-gray-400 font-mono truncate mt-1",children:[n.oldPath," ","->"," ",n.newPath]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium flex-shrink-0",children:[e.jsxs("span",{className:"text-green-700 dark:text-green-400",children:["+",n.additions]}),e.jsxs("span",{className:"text-red-700 dark:text-red-400",children:["-",n.deletions]})]})]}),n.meta.length>0&&e.jsx("div",{className:"mt-2 space-y-1",children:n.meta.map((d,c)=>e.jsx("div",{className:"text-[11px] leading-4 text-gray-500 dark:text-gray-400 font-mono truncate",children:d},`${d}-${c}`))})]}),n.hunks.map((d,c)=>e.jsxs("div",{children:[e.jsx("div",{className:"px-4 py-2 bg-primary-50 dark:bg-primary-950/30 text-[11px] font-mono text-primary-700 dark:text-primary-300 border-b border-primary-100 dark:border-primary-900 overflow-x-auto hide-scrollbar",children:d.header}),e.jsx("div",{className:"font-mono text-[12px] leading-5",children:d.lines.map((m,u)=>e.jsx(va,{line:m},`${m.kind}-${m.oldLine}-${m.newLine}-${u}`))})]},`${d.header}-${c}`))]},`${n.newPath||n.oldPath}-${x}`))})]})},va=({line:t})=>{const r=t.kind==="add",s=t.kind==="delete",o=t.kind==="note",n=r?"+":s?"-":o?"\\":" ";return e.jsxs("div",{className:p("grid grid-cols-[3.25rem_3.25rem_1.5rem_minmax(0,1fr)] min-w-0 border-b border-transparent",r&&"bg-green-50 dark:bg-green-950/35",s&&"bg-red-50 dark:bg-red-950/35",t.kind==="meta"&&"bg-gray-50 dark:bg-gray-900/70",o&&"bg-gray-50 dark:bg-gray-900/70 text-gray-500 dark:text-gray-400 italic"),children:[e.jsx("div",{className:"px-2 py-0.5 text-right text-[11px] text-gray-400 dark:text-gray-600 select-none border-r border-gray-100 dark:border-gray-800",children:t.oldLine??""}),e.jsx("div",{className:"px-2 py-0.5 text-right text-[11px] text-gray-400 dark:text-gray-600 select-none border-r border-gray-100 dark:border-gray-800",children:t.newLine??""}),e.jsx("div",{className:p("px-1.5 py-0.5 text-center select-none",r&&"text-green-700 dark:text-green-400",s&&"text-red-700 dark:text-red-400",!r&&!s&&"text-gray-400 dark:text-gray-600"),children:n}),e.jsx("div",{className:p("py-0.5 pr-4 overflow-x-auto whitespace-pre",r&&"text-green-900 dark:text-green-100",s&&"text-red-900 dark:text-red-100",!r&&!s&&"text-gray-800 dark:text-gray-200"),children:t.content||" "})]})},le=({title:t,subtitle:r,onClose:s,actions:o,children:n})=>e.jsxs(e.Fragment,{children:[e.jsx(rt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:s,className:"absolute inset-0 bg-black/40 z-40"}),e.jsxs(rt.div,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",damping:25,stiffness:220},className:"absolute bottom-0 left-0 right-0 h-[86%] bg-white dark:bg-gray-950 rounded-t-2xl z-50 flex flex-col shadow-xl overflow-hidden",children:[e.jsx("div",{className:"flex justify-center pt-3 pb-2 flex-shrink-0",onClick:s,children:e.jsx("div",{className:"w-12 h-1.5 bg-gray-300 dark:bg-gray-700 rounded-full"})}),e.jsxs("div",{className:"px-4 pb-3 border-b border-gray-100 dark:border-gray-800 flex items-start justify-between gap-3 flex-shrink-0",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100 truncate",children:t}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono truncate mt-0.5",children:r})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o,e.jsx("button",{onClick:s,className:"w-8 h-8 rounded-full flex items-center justify-center text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-900 flex-shrink-0",title:"关闭","aria-label":"关闭",children:e.jsx(qt,{className:"w-5 h-5"})})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n})]})]});export{$a as Workspace};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-D9IwexPM.js","assets/vendor-react-DSV5aFEg.js","assets/index-C89UCwGk.js","assets/vendor-icons-S_ObYVVf.js","assets/index-Bk4_acsd.css","assets/code-highlight-CEcsuMpw.js","assets/vendor-markdown-BDwu-Ux6.js"])))=>i.map(i=>d[i]);
2
- import{_,u as k,c as R}from"./index-C89UCwGk.js";import{j as c,r as p,R as h,u as M}from"./vendor-react-DSV5aFEg.js";function w(t){return t.type==="system_group"}function E(t){return t.type==="tool_group"}function D(t){return w(t)||E(t)}function F(t){return!!t.details&&Object.keys(t.details).length>0}function m(t){return F(t)||t.content!=="系统消息"}function W(t){const e=t.filter(m);if(e.length===0)return null;const r=e[0],n=e[e.length-1];return{id:`system-group-${r.id}`,type:"system_group",content:n.content,time:e.length>1?`${r.time} - ${n.time}`:n.time,messages:e}}function j(t){const e=t[0],r=t[t.length-1];return{id:`tool-group-${e.id}`,type:"tool_group",content:r.content,time:t.length>1?`${e.time} - ${r.time}`:r.time,messages:t}}function B(t){const e=[];let r=[],n=[];const o=()=>{if(r.length===0)return;const s=W(r);s&&e.push(s),r=[]},i=()=>{n.length!==0&&(n.length===1?e.push(n[0]):e.push(j(n)),n=[])};for(const s of t){if(s.type==="system"){if(i(),!m(s))continue;r.push(s);continue}if(s.type==="tool"){o(),n.push(s);continue}o(),i(),e.push(s)}return o(),i(),e}const T=h.lazy(()=>_(()=>import("./MarkdownRenderer-D9IwexPM.js"),__vite__mapDeps([0,1,2,3,4,5,6])));function G({children:t,enableWorkspaceLinks:e=!0}){return c.jsx(p.Suspense,{fallback:c.jsx(z,{content:t}),children:c.jsx(T,{enableWorkspaceLinks:e,children:t})})}function z({content:t}){return c.jsx("span",{className:"whitespace-pre-wrap break-words",children:t})}const b=/(^|[^\w@:/?#&=.-])((?:\/|\.{1,2}\/|~\/)?(?:(?:[\w.@+-]+\/)+)?[\w.@+-]+\.[A-Za-z][A-Za-z0-9_-]*)(?::(\d+)(?::\d+)?|#L(\d+))(?![\w/-])/g,S=/^(.+?)(?::(\d+)(?::\d+)?|#L(\d+))$/;function d(t){try{return decodeURIComponent(t)}catch{return t}}function g(t){return t.replace(/^["'<]+/,"").replace(/[>"')\],.;]+$/,"")}function y(t){return t?t.replace(/\\/g,"/").replace(/\/+$/,"")||"/":""}function A(t){const e=y(t),r=e.match(/^(\/Users\/[^/]+)(?:\/|$)/);if(r)return r[1];const n=e.match(/^(\/home\/[^/]+)(?:\/|$)/);return n?n[1]:""}function f(t){const e=[];for(const r of t.replace(/^\.\/+/,"").split("/"))if(!(!r||r===".")){if(r===".."){if(e.length===0)return null;e.pop();continue}e.push(r)}return e.join("/")}function I(t){if(!t)return null;const e=Number(t);return Number.isSafeInteger(e)&&e>0?e:null}function x(t,e,r){const n=I(e);if(!n)return null;let o=g(d(t).trim()).replace(/\\/g,"/");if(!o||(o.startsWith("file://")&&(o=o.slice(7)),/^[a-z][a-z0-9+.-]*:\/\//i.test(o)))return null;const i=A(r);o.startsWith("~/")&&i&&(o=`${i}${o.slice(1)}`);const s=y(r);let u;if(o.startsWith("/")){if(!s)return null;const l=o.replace(/\/+$/,"");if(l!==s&&!l.startsWith(`${s}/`))return null;u=f(l.slice(s.length).replace(/^\/+/,""))}else u=f(o);return u?{path:u,line:n,href:`/workspace?file=${encodeURIComponent(u)}&line=${n}`}:null}function K(t,e){const r=g(d(t).trim());if(!r||r.startsWith("/workspace?"))return null;const n=r.match(S);return n?x(n[1],n[2]||n[3],e):null}function L(t,e){const r=[];let n=0;for(const o of t.matchAll(b)){const i=o[0],s=o[1]||"",u=i.slice(s.length),l=(o.index||0)+s.length,$=(o.index||0)+i.length,a=x(o[2],o[3]||o[4],e);a&&(l>n&&r.push({type:"text",text:t.slice(n,l)}),r.push({type:"link",text:u,target:a}),n=$)}return n<t.length&&r.push({type:"text",text:t.slice(n)}),r.length>0?r:[{type:"text",text:t}]}function H({children:t,linkClassName:e}){const r=M(),{cliConfig:n}=k(),o=p.useMemo(()=>L(t,n==null?void 0:n.workDir),[t,n==null?void 0:n.workDir]);return c.jsx(c.Fragment,{children:o.map((i,s)=>i.type==="text"?c.jsx(h.Fragment,{children:i.text},s):c.jsx("a",{href:i.target.href,className:R("font-mono underline underline-offset-2 decoration-current/50 hover:decoration-current",e),title:`打开 ${i.target.path}:${i.target.line}`,onClick:u=>{u.button!==0||u.metaKey||u.ctrlKey||u.shiftKey||u.altKey||(u.preventDefault(),r(i.target.href))},children:i.text},`${i.target.href}-${s}`))})}export{G as M,H as W,B as g,D as i,K as p,L as s};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-BO-KS_L1.js","assets/vendor-react-DSV5aFEg.js","assets/index-DOgH1Kf3.js","assets/vendor-icons-CNN4EKVi.js","assets/index-BXT2BylN.css","assets/code-highlight-CEcsuMpw.js","assets/vendor-markdown-BDwu-Ux6.js"])))=>i.map(i=>d[i]);
2
+ import{_,u as k,c as R}from"./index-DOgH1Kf3.js";import{j as c,r as p,R as h,u as M}from"./vendor-react-DSV5aFEg.js";function w(t){return t.type==="system_group"}function E(t){return t.type==="tool_group"}function D(t){return w(t)||E(t)}function F(t){return!!t.details&&Object.keys(t.details).length>0}function m(t){return F(t)||t.content!=="系统消息"}function W(t){const e=t.filter(m);if(e.length===0)return null;const r=e[0],n=e[e.length-1];return{id:`system-group-${r.id}`,type:"system_group",content:n.content,time:e.length>1?`${r.time} - ${n.time}`:n.time,messages:e}}function j(t){const e=t[0],r=t[t.length-1];return{id:`tool-group-${e.id}`,type:"tool_group",content:r.content,time:t.length>1?`${e.time} - ${r.time}`:r.time,messages:t}}function B(t){const e=[];let r=[],n=[];const o=()=>{if(r.length===0)return;const s=W(r);s&&e.push(s),r=[]},i=()=>{n.length!==0&&(n.length===1?e.push(n[0]):e.push(j(n)),n=[])};for(const s of t){if(s.type==="system"){if(i(),!m(s))continue;r.push(s);continue}if(s.type==="tool"){o(),n.push(s);continue}o(),i(),e.push(s)}return o(),i(),e}const T=h.lazy(()=>_(()=>import("./MarkdownRenderer-BO-KS_L1.js"),__vite__mapDeps([0,1,2,3,4,5,6])));function G({children:t,enableWorkspaceLinks:e=!0}){return c.jsx(p.Suspense,{fallback:c.jsx(z,{content:t}),children:c.jsx(T,{enableWorkspaceLinks:e,children:t})})}function z({content:t}){return c.jsx("span",{className:"whitespace-pre-wrap break-words",children:t})}const b=/(^|[^\w@:/?#&=.-])((?:\/|\.{1,2}\/|~\/)?(?:(?:[\w.@+-]+\/)+)?[\w.@+-]+\.[A-Za-z][A-Za-z0-9_-]*)(?::(\d+)(?::\d+)?|#L(\d+))(?![\w/-])/g,S=/^(.+?)(?::(\d+)(?::\d+)?|#L(\d+))$/;function d(t){try{return decodeURIComponent(t)}catch{return t}}function g(t){return t.replace(/^["'<]+/,"").replace(/[>"')\],.;]+$/,"")}function y(t){return t?t.replace(/\\/g,"/").replace(/\/+$/,"")||"/":""}function A(t){const e=y(t),r=e.match(/^(\/Users\/[^/]+)(?:\/|$)/);if(r)return r[1];const n=e.match(/^(\/home\/[^/]+)(?:\/|$)/);return n?n[1]:""}function f(t){const e=[];for(const r of t.replace(/^\.\/+/,"").split("/"))if(!(!r||r===".")){if(r===".."){if(e.length===0)return null;e.pop();continue}e.push(r)}return e.join("/")}function I(t){if(!t)return null;const e=Number(t);return Number.isSafeInteger(e)&&e>0?e:null}function x(t,e,r){const n=I(e);if(!n)return null;let o=g(d(t).trim()).replace(/\\/g,"/");if(!o||(o.startsWith("file://")&&(o=o.slice(7)),/^[a-z][a-z0-9+.-]*:\/\//i.test(o)))return null;const i=A(r);o.startsWith("~/")&&i&&(o=`${i}${o.slice(1)}`);const s=y(r);let u;if(o.startsWith("/")){if(!s)return null;const l=o.replace(/\/+$/,"");if(l!==s&&!l.startsWith(`${s}/`))return null;u=f(l.slice(s.length).replace(/^\/+/,""))}else u=f(o);return u?{path:u,line:n,href:`/workspace?file=${encodeURIComponent(u)}&line=${n}`}:null}function K(t,e){const r=g(d(t).trim());if(!r||r.startsWith("/workspace?"))return null;const n=r.match(S);return n?x(n[1],n[2]||n[3],e):null}function L(t,e){const r=[];let n=0;for(const o of t.matchAll(b)){const i=o[0],s=o[1]||"",u=i.slice(s.length),l=(o.index||0)+s.length,$=(o.index||0)+i.length,a=x(o[2],o[3]||o[4],e);a&&(l>n&&r.push({type:"text",text:t.slice(n,l)}),r.push({type:"link",text:u,target:a}),n=$)}return n<t.length&&r.push({type:"text",text:t.slice(n)}),r.length>0?r:[{type:"text",text:t}]}function H({children:t,linkClassName:e}){const r=M(),{cliConfig:n}=k(),o=p.useMemo(()=>L(t,n==null?void 0:n.workDir),[t,n==null?void 0:n.workDir]);return c.jsx(c.Fragment,{children:o.map((i,s)=>i.type==="text"?c.jsx(h.Fragment,{children:i.text},s):c.jsx("a",{href:i.target.href,className:R("font-mono underline underline-offset-2 decoration-current/50 hover:decoration-current",e),title:`打开 ${i.target.path}:${i.target.line}`,onClick:u=>{u.button!==0||u.metaKey||u.ctrlKey||u.shiftKey||u.altKey||(u.preventDefault(),r(i.target.href))},children:i.text},`${i.target.href}-${s}`))})}export{G as M,H as W,B as g,D as i,K as p,L as s};