pikiclaw 0.3.12 → 0.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{r,j as e}from"./react-vendor-DTcmqLiz.js";import{u as I,b as xe,a as H,g as R,B as y,E as pe,S as q,k as Y,c as ge}from"./index-BPyYJAu2.js";import{B as he}from"./BrandIcon-DI28YjL9.js";import{L as P}from"./Input-BzRdrrQl.js";import{S as K}from"./Select-CzehncNR.js";import{M as ve,a as be}from"./Modal-BWEFrRB_.js";import{S as Z}from"./shared-Diw6OFf-.js";import"./router-emLofBBH.js";const je=["claude","codex","gemini"];function Ne(t){return t==="zh-CN"?{defaultsTitle:"新会话默认值",defaultsHint:"新会话会默认采用这里的智能体、模型和推理强度。",defaultsEditTitle:"编辑新会话默认值",defaultsEditHint:"在弹窗中选择默认智能体、模型和推理强度,保存后对新会话生效。",defaultsSaved:"新会话默认值已保存",editDefaults:"修改默认值",agentsTitle:"可用智能体",defaultAgent:"默认智能体",defaultModel:"默认模型",defaultEffort:"推理强度",status:"状态",model:"模型",models:"模型",version:"版本",defaultBadge:"默认",installed:"已安装",notInstalled:"未安装",noModel:"暂无可选模型",currentModelPrefix:"当前模型",availableModelsSuffix:"个可选",availableModels:"可用模型",recommendedFor:"建议场景",currentConfig:"当前配置",effort:"推理强度",readyHint:"已安装,可直接作为新会话执行智能体。",installHint:"尚未安装,需要先完成本地 CLI 安装。",noVersion:"版本未知",moreModels:s=>`+${s}`,install:"安装",installing:"安装中...",noEffort:"不支持调整",loadFailed:"无法加载智能体状态",latestVersion:"最新版本",updateAvailable:"有新版本可用",updateSkipped:"自动更新已跳过",updateFailed:"自动更新失败",update:"手动升级",updating:"升级中...",checkUpdate:"检查更新",checking:"检查中...",upToDate:"已是最新"}:{defaultsTitle:"New Session Defaults",defaultsHint:"New sessions use this agent, model, and effort by default.",defaultsEditTitle:"Edit New Session Defaults",defaultsEditHint:"Choose the default agent, model, and effort in the modal, then save them for new sessions.",defaultsSaved:"New session defaults saved",editDefaults:"Edit Defaults",agentsTitle:"Available Agents",defaultAgent:"Default Agent",defaultModel:"Default Model",defaultEffort:"Effort",status:"Status",model:"Model",models:"Models",version:"Version",defaultBadge:"Default",installed:"Installed",notInstalled:"Not installed",noModel:"No selectable models",currentModelPrefix:"Current model",availableModelsSuffix:"available",availableModels:"Available models",recommendedFor:"Recommended for",currentConfig:"Current config",effort:"Effort",readyHint:"Installed and ready for new sessions.",installHint:"Not installed locally yet.",noVersion:"Version unavailable",moreModels:s=>`+${s}`,install:"Install",installing:"Installing...",noEffort:"Not supported",loadFailed:"Failed to load agent status",latestVersion:"Latest",updateAvailable:"Update available",updateSkipped:"Auto-update skipped",updateFailed:"Auto-update failed",update:"Update",updating:"Updating...",checkUpdate:"Check update",checking:"Checking...",upToDate:"Up to date"}}function Me(t,s){const n=t.filter(u=>u.installed);return(n.length?n:t).map(u=>({value:u.agent,label:`${R(u.agent).label} · ${u.installed?u.version||s.installed:s.notInstalled}`}))}function ke(t){if(!t)return[];const s=t.models.map(n=>({value:n.id,label:n.alias?`${n.alias} · ${n.id}`:n.id}));return t.selectedModel&&!s.some(n=>n.value===t.selectedModel)&&s.unshift({value:t.selectedModel,label:t.selectedModel}),s}function Ae(t){return t?pe[t.agent].map(s=>({value:s,label:s})):[]}function Ee(t,s){if(!t.models.length)return s.noModel;const n=t.selectedModel?t.models.find(u=>u.id===t.selectedModel):t.models[0],m=n?.alias||n?.id||s.noModel;return`${s.currentModelPrefix}: ${m} · ${t.models.length} ${s.availableModelsSuffix}`}function se(t){return t?t.alias||t.id:"—"}function le(t,s){if(!t.models.length)return s.noModel;const n=t.selectedModel?t.models.find(m=>m.id===t.selectedModel):t.models[0];return se(n)}function Se(t,s=4){const n=new Set;return t.models.map(u=>({key:u.id,label:se(u)})).filter(u=>n.has(u.key)?!1:(n.add(u.key),!0)).slice(0,s)}function ee(t,s){t({defaultAgent:s.defaultAgent,agents:s.agents})}function te(t,s){return{agent:t?.agent||s,model:t?.selectedModel||"",effort:t?.selectedEffort||""}}function G({label:t,value:s,hint:n,loading:m=!1}){return e.jsxs("div",{className:"rounded-lg border border-edge bg-panel-alt px-3.5 py-2.5",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-fg-5",children:t}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[13px] font-semibold text-fg-2",children:[m&&e.jsx(q,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:s})]}),n&&e.jsx("div",{className:"mt-0.5 text-[10px] leading-relaxed text-fg-5",children:n})]})}function we({agent:t,copy:s,t:n,installing:m,onInstall:u,updatingAgent:o,checkingAgent:d,onUpdate:A,onCheckUpdate:U,loading:c=!1}){const E=R(t.agent),V=Ee(t,s),O=le(t,s),j=E.advantageKey?n(E.advantageKey):"—",D=Se(t),F=Math.max(0,t.models.length-D.length),_=t.selectedEffort||s.noEffort,S=t.version||s.noVersion,N=c?n("status.loading"):t.installed?s.installed:s.notInstalled,i=c?"muted":t.installed?"ok":"warn",w=c?n("status.loading"):t.installed?s.readyHint:s.installHint,C=c?n("status.loading"):O,p=c?n("status.loading"):_,g=c?n("status.loading"):j,h=c?n("status.loading"):V;return e.jsx("div",{className:"glass rounded-md border border-edge px-4 py-3 shadow-[0_1px_0_rgba(255,255,255,0.02),0_4px_12px_rgba(15,23,42,0.05)]",children:e.jsxs("div",{className:"grid gap-x-5 gap-y-3 xl:grid-cols-[220px_130px_220px_minmax(0,1fr)_auto] xl:items-start",children:[e.jsx("div",{className:"min-w-0",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-edge bg-panel-alt",children:e.jsx(he,{brand:t.agent,size:22})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-[15px] font-semibold text-fg",children:E.label}),t.isDefault&&e.jsx(Y,{variant:"accent",children:s.defaultBadge})]}),e.jsxs("div",{className:"mt-1 text-[12px] leading-relaxed text-fg-5",children:[s.version,": ",S,t.latestVersion&&t.updateAvailable&&e.jsxs("span",{className:"ml-1.5 text-amber-400",children:["→ ",t.latestVersion]}),t.latestVersion&&!t.updateAvailable&&t.installed&&e.jsx("span",{className:"ml-1.5 text-emerald-400",children:"✓"})]})]})]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:s.status}),e.jsx("div",{className:"mt-1.5",children:e.jsxs(Y,{variant:i,children:[c&&e.jsx(q,{className:"h-3 w-3"}),N]})}),e.jsx("div",{className:"mt-1.5 text-[12px] leading-relaxed text-fg-5",children:w})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:s.currentConfig}),e.jsxs("div",{className:"mt-1.5 space-y-1.5 text-[13px] leading-relaxed text-fg-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-16 shrink-0 text-fg-5",children:s.model}),e.jsx("span",{className:"min-w-0 break-words text-fg-2",children:C})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-16 shrink-0 text-fg-5",children:s.effort}),e.jsx("span",{className:"text-fg-2",children:p})]})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:s.recommendedFor}),e.jsx("div",{className:"mt-1.5 text-[13px] leading-relaxed text-fg-3",children:g}),e.jsx("div",{className:"mt-2.5 text-[10px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:s.availableModels}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[!c&&D.length>0?D.map(v=>e.jsx("span",{className:"inline-flex h-6 max-w-full items-center rounded-md border border-edge bg-panel-alt px-2 text-[11px] text-fg-3",title:v.key,children:e.jsx("span",{className:"truncate",children:v.label})},v.key)):e.jsx("span",{className:"text-[12px] text-fg-5",children:c?n("status.loading"):s.noModel}),!c&&F>0&&e.jsx("span",{className:"inline-flex h-6 items-center rounded-md border border-edge bg-panel-alt px-2 text-[11px] text-fg-5",children:s.moreModels(F)})]}),e.jsx("div",{className:"mt-1.5 text-[12px] leading-relaxed text-fg-5",children:h})]}),e.jsxs("div",{className:ge("flex flex-col items-start gap-1.5 xl:items-end",t.installed&&"xl:self-start"),children:[c&&e.jsxs("div",{className:"inline-flex h-7 items-center gap-2 rounded-md border border-edge bg-transparent px-2.5 text-[11px] text-fg-5",children:[e.jsx(q,{className:"h-3 w-3"}),n("status.loading")]}),!c&&!t.installed&&e.jsx(y,{variant:"outline",size:"sm",disabled:m,onClick:()=>u(t),children:m?s.installing:s.install}),!c&&t.installed&&t.updateAvailable&&e.jsx(y,{variant:"primary",size:"sm",disabled:o,onClick:()=>A(t),children:o?s.updating:s.update}),!c&&t.installed&&!t.updateAvailable&&e.jsx(y,{variant:"ghost",size:"sm",disabled:d,onClick:()=>U(t),children:d?s.checking:s.checkUpdate}),!c&&t.installed&&t.updateAvailable&&t.updateStatus==="skipped"&&t.updateDetail&&e.jsxs("div",{className:"text-[11px] leading-relaxed text-amber-400",children:[s.updateSkipped,": ",t.updateDetail]}),!c&&t.installed&&t.updateStatus==="failed"&&t.updateDetail&&e.jsxs("div",{className:"text-[11px] leading-relaxed text-red-400",children:[s.updateFailed,": ",t.updateDetail]})]})]})})}function Oe(){const t=I(l=>l.locale),s=I(l=>l.toast),n=I(l=>l.agentStatus),m=I(l=>l.setAgentStatus),u=I(l=>l.refreshAgentStatus),o=r.useMemo(()=>xe(t),[t]),d=Ne(t),[A,U]=r.useState(n?{defaultAgent:n.defaultAgent,agents:n.agents}:null),[c,E]=r.useState(!n),[V,O]=r.useState(null),[j,D]=r.useState(!1),[F,_]=r.useState(null),[S,N]=r.useState(!1),[i,w]=r.useState({agent:"codex",model:"",effort:""}),C=r.useRef(!!n);r.useEffect(()=>{n&&(ee(U,n),C.current||(C.current=!0,E(!1)))},[n]);const p=r.useCallback(l=>{ee(U,l),m(l)},[m]),g=r.useCallback(async()=>{C.current||E(!0);try{const l=await H.getAgentStatus();return p(l),O(null),C.current=!0,l}catch(l){const a=l instanceof Error?l.message:d.loadFailed;return O(a),C.current||s(a,!1),null}finally{E(!1)}},[p,d.loadFailed,s]);r.useEffect(()=>{n?u():g()},[]);const h=r.useMemo(()=>{const l=A?.agents||[],a=new Map(l.map(f=>[f.agent,f]));return je.map(f=>{const T=a.get(f);if(T)return T;const b=R(f);return{agent:f,label:b.label,installed:!1,version:void 0,installCommand:void 0,selectedModel:null,selectedEffort:null,isDefault:A?.defaultAgent===f,models:[],usage:null}})},[A]),v=A?.defaultAgent||"codex",M=h.find(l=>l.agent===v)||null,J=h.filter(l=>l.installed).length>0,ae=Me(h,d),x=h.find(l=>l.agent===i.agent)||null,L=ke(x),$=Ae(x),Q=r.useCallback(async l=>{D(!0);try{const a=await H.updateRuntimeAgent(l);if(!a.ok)throw new Error(a.error||o("config.applyFailed"));return p(a),a}catch(a){const f=a instanceof Error?a.message:o("config.applyFailed");return s(f,!1),g(),null}finally{D(!1)}},[p,g,o,s]);r.useEffect(()=>{S&&w(te(M,v))},[v,M,S]),r.useEffect(()=>{if(!S||!x)return;const l=x.selectedModel||"",a=!i.model||L.some(b=>b.value===i.model),f=x.selectedEffort||"",T=!i.effort||$.some(b=>b.value===i.effort);a&&T||w(b=>({...b,model:a?b.model:l,effort:T?b.effort:f}))},[S,i.effort,i.model,x,$,L]);const ne=r.useCallback(l=>{const a=h.find(f=>f.agent===l);a?.installed&&w(te(a,a.agent))},[h]),de=r.useCallback(async()=>{if(!x?.installed)return;const l={};if(i.agent!==v&&(l.defaultAgent=i.agent),i.model&&i.model!==(x.selectedModel||"")&&(l.agent=i.agent,l.model=i.model),i.effort&&i.effort!==(x.selectedEffort||"")&&(l.agent=i.agent,l.effort=i.effort),Object.keys(l).length===0){N(!1);return}await Q(l)&&(s(d.defaultsSaved),N(!1))},[d.defaultsSaved,v,i.agent,i.effort,i.model,x,s,Q]),ie=r.useCallback(async l=>{if(!F){_(l.agent);try{const a=await H.installAgent(l.agent);if(!a.ok)throw new Error(a.error||o("config.agentInstallFailed"));p(a),s(o("config.agentInstalled"))}catch(a){const f=a instanceof Error?a.message:o("config.agentInstallFailed");s(f,!1),g()}finally{_(a=>a===l.agent?null:a)}}},[p,F,g,o,s]),[B,W]=r.useState(null),[z,X]=r.useState(null),re=r.useCallback(async l=>{if(!B){W(l.agent);try{const a=await H.updateAgent(l.agent);if(!a.ok)throw new Error(a.error||o("config.agentInstallFailed"));p(a),s(d.upToDate)}catch(a){const f=a instanceof Error?a.message:d.updateFailed;s(f,!1),g()}finally{W(a=>a===l.agent?null:a)}}},[p,d.updateFailed,d.upToDate,g,o,s,B]),oe=r.useCallback(async l=>{if(!z){X(l.agent);try{const a=await H.checkAgentUpdate(l.agent);if(!a.ok)throw new Error(a.error||d.loadFailed);p(a)}catch(a){const f=a instanceof Error?a.message:d.loadFailed;s(f,!1),g()}finally{X(a=>a===l.agent?null:a)}}},[p,z,d.loadFailed,g,s]),k=c&&!A,ce=k?o("status.loading"):M?R(M.agent).label:d.notInstalled,fe=k?o("status.loading"):M?.installed?d.installed:d.notInstalled,ue=k?o("status.loading"):M?le(M,d):d.noModel,me=k?o("status.loading"):M?.selectedEffort||d.noEffort;return e.jsxs("div",{className:"animate-in space-y-4",children:[e.jsx("section",{className:"space-y-3",children:e.jsxs(Z,{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-semibold tracking-tight text-fg",children:d.defaultsTitle}),e.jsx("div",{className:"mt-0.5 text-[13px] leading-relaxed text-fg-4",children:d.defaultsHint})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(y,{variant:"secondary",onClick:()=>N(!0),disabled:j||!J,children:d.editDefaults})})]}),e.jsxs("div",{className:"grid gap-2.5 lg:grid-cols-3",children:[e.jsx(G,{label:d.defaultAgent,value:ce,hint:fe,loading:k}),e.jsx(G,{label:d.defaultModel,value:ue,loading:k}),e.jsx(G,{label:d.defaultEffort,value:me,loading:k})]})]})}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] text-fg-5",children:d.agentsTitle}),e.jsx("div",{className:"space-y-3",children:h.map(l=>e.jsx(we,{agent:l,copy:d,t:o,installing:F===l.agent,loading:k,onInstall:ie,updatingAgent:B===l.agent,checkingAgent:z===l.agent,onUpdate:re,onCheckUpdate:oe},l.agent))})]}),V&&e.jsx(Z,{className:"border-amber-500/20 bg-amber-500/5",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[13px] text-fg-2",children:V}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>{g()},children:o("sessions.retry")})]})}),e.jsxs(ve,{open:S,onClose:()=>N(!1),children:[e.jsx(be,{title:d.defaultsEditTitle,description:d.defaultsEditHint,onClose:()=>N(!1)}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(P,{children:d.defaultAgent}),e.jsx(K,{value:i.agent,options:ae,onChange:ne,disabled:j||!J,placeholder:d.notInstalled})]}),e.jsxs("div",{children:[e.jsx(P,{children:d.defaultModel}),e.jsx(K,{value:i.model,options:L,onChange:l=>w(a=>({...a,model:l})),disabled:j||!x?.installed||L.length===0,placeholder:d.noModel})]}),e.jsxs("div",{children:[e.jsx(P,{children:d.defaultEffort}),e.jsx(K,{value:i.effort,options:$,onChange:l=>w(a=>({...a,effort:l})),disabled:j||!x?.installed||$.length===0,placeholder:d.noEffort})]})]}),e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:()=>N(!1),children:o("modal.cancel")}),e.jsx(y,{variant:"primary",disabled:j||!x?.installed,onClick:()=>{de()},children:o(j?"config.validating":"modal.save")})]})]})]})}export{Oe as AgentTab,Oe as default};
1
+ import{r,j as e}from"./react-vendor-DTcmqLiz.js";import{u as I,b as xe,a as H,g as R,B as y,E as pe,S as q,k as Y,c as ge}from"./index-D5sKCspB.js";import{B as he}from"./BrandIcon-BoMxvhBf.js";import{L as P}from"./Input-DJydTgbG.js";import{S as K}from"./Select-D6Uav_-v.js";import{M as ve,a as be}from"./Modal-CtsiLdVr.js";import{S as Z}from"./shared-6sWbm5Tj.js";import"./router-emLofBBH.js";const je=["claude","codex","gemini"];function Ne(t){return t==="zh-CN"?{defaultsTitle:"新会话默认值",defaultsHint:"新会话会默认采用这里的智能体、模型和推理强度。",defaultsEditTitle:"编辑新会话默认值",defaultsEditHint:"在弹窗中选择默认智能体、模型和推理强度,保存后对新会话生效。",defaultsSaved:"新会话默认值已保存",editDefaults:"修改默认值",agentsTitle:"可用智能体",defaultAgent:"默认智能体",defaultModel:"默认模型",defaultEffort:"推理强度",status:"状态",model:"模型",models:"模型",version:"版本",defaultBadge:"默认",installed:"已安装",notInstalled:"未安装",noModel:"暂无可选模型",currentModelPrefix:"当前模型",availableModelsSuffix:"个可选",availableModels:"可用模型",recommendedFor:"建议场景",currentConfig:"当前配置",effort:"推理强度",readyHint:"已安装,可直接作为新会话执行智能体。",installHint:"尚未安装,需要先完成本地 CLI 安装。",noVersion:"版本未知",moreModels:s=>`+${s}`,install:"安装",installing:"安装中...",noEffort:"不支持调整",loadFailed:"无法加载智能体状态",latestVersion:"最新版本",updateAvailable:"有新版本可用",updateSkipped:"自动更新已跳过",updateFailed:"自动更新失败",update:"手动升级",updating:"升级中...",checkUpdate:"检查更新",checking:"检查中...",upToDate:"已是最新"}:{defaultsTitle:"New Session Defaults",defaultsHint:"New sessions use this agent, model, and effort by default.",defaultsEditTitle:"Edit New Session Defaults",defaultsEditHint:"Choose the default agent, model, and effort in the modal, then save them for new sessions.",defaultsSaved:"New session defaults saved",editDefaults:"Edit Defaults",agentsTitle:"Available Agents",defaultAgent:"Default Agent",defaultModel:"Default Model",defaultEffort:"Effort",status:"Status",model:"Model",models:"Models",version:"Version",defaultBadge:"Default",installed:"Installed",notInstalled:"Not installed",noModel:"No selectable models",currentModelPrefix:"Current model",availableModelsSuffix:"available",availableModels:"Available models",recommendedFor:"Recommended for",currentConfig:"Current config",effort:"Effort",readyHint:"Installed and ready for new sessions.",installHint:"Not installed locally yet.",noVersion:"Version unavailable",moreModels:s=>`+${s}`,install:"Install",installing:"Installing...",noEffort:"Not supported",loadFailed:"Failed to load agent status",latestVersion:"Latest",updateAvailable:"Update available",updateSkipped:"Auto-update skipped",updateFailed:"Auto-update failed",update:"Update",updating:"Updating...",checkUpdate:"Check update",checking:"Checking...",upToDate:"Up to date"}}function Me(t,s){const n=t.filter(u=>u.installed);return(n.length?n:t).map(u=>({value:u.agent,label:`${R(u.agent).label} · ${u.installed?u.version||s.installed:s.notInstalled}`}))}function ke(t){if(!t)return[];const s=t.models.map(n=>({value:n.id,label:n.alias?`${n.alias} · ${n.id}`:n.id}));return t.selectedModel&&!s.some(n=>n.value===t.selectedModel)&&s.unshift({value:t.selectedModel,label:t.selectedModel}),s}function Ae(t){return t?pe[t.agent].map(s=>({value:s,label:s})):[]}function Ee(t,s){if(!t.models.length)return s.noModel;const n=t.selectedModel?t.models.find(u=>u.id===t.selectedModel):t.models[0],m=n?.alias||n?.id||s.noModel;return`${s.currentModelPrefix}: ${m} · ${t.models.length} ${s.availableModelsSuffix}`}function se(t){return t?t.alias||t.id:"—"}function le(t,s){if(!t.models.length)return s.noModel;const n=t.selectedModel?t.models.find(m=>m.id===t.selectedModel):t.models[0];return se(n)}function Se(t,s=4){const n=new Set;return t.models.map(u=>({key:u.id,label:se(u)})).filter(u=>n.has(u.key)?!1:(n.add(u.key),!0)).slice(0,s)}function ee(t,s){t({defaultAgent:s.defaultAgent,agents:s.agents})}function te(t,s){return{agent:t?.agent||s,model:t?.selectedModel||"",effort:t?.selectedEffort||""}}function G({label:t,value:s,hint:n,loading:m=!1}){return e.jsxs("div",{className:"rounded-lg border border-edge bg-panel-alt px-3.5 py-2.5",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-fg-5",children:t}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[13px] font-semibold text-fg-2",children:[m&&e.jsx(q,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:s})]}),n&&e.jsx("div",{className:"mt-0.5 text-[10px] leading-relaxed text-fg-5",children:n})]})}function we({agent:t,copy:s,t:n,installing:m,onInstall:u,updatingAgent:o,checkingAgent:d,onUpdate:A,onCheckUpdate:U,loading:c=!1}){const E=R(t.agent),V=Ee(t,s),O=le(t,s),j=E.advantageKey?n(E.advantageKey):"—",D=Se(t),F=Math.max(0,t.models.length-D.length),_=t.selectedEffort||s.noEffort,S=t.version||s.noVersion,N=c?n("status.loading"):t.installed?s.installed:s.notInstalled,i=c?"muted":t.installed?"ok":"warn",w=c?n("status.loading"):t.installed?s.readyHint:s.installHint,C=c?n("status.loading"):O,p=c?n("status.loading"):_,g=c?n("status.loading"):j,h=c?n("status.loading"):V;return e.jsx("div",{className:"glass rounded-md border border-edge px-4 py-3 shadow-[0_1px_0_rgba(255,255,255,0.02),0_4px_12px_rgba(15,23,42,0.05)]",children:e.jsxs("div",{className:"grid gap-x-5 gap-y-3 xl:grid-cols-[220px_130px_220px_minmax(0,1fr)_auto] xl:items-start",children:[e.jsx("div",{className:"min-w-0",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-edge bg-panel-alt",children:e.jsx(he,{brand:t.agent,size:22})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-[15px] font-semibold text-fg",children:E.label}),t.isDefault&&e.jsx(Y,{variant:"accent",children:s.defaultBadge})]}),e.jsxs("div",{className:"mt-1 text-[12px] leading-relaxed text-fg-5",children:[s.version,": ",S,t.latestVersion&&t.updateAvailable&&e.jsxs("span",{className:"ml-1.5 text-amber-400",children:["→ ",t.latestVersion]}),t.latestVersion&&!t.updateAvailable&&t.installed&&e.jsx("span",{className:"ml-1.5 text-emerald-400",children:"✓"})]})]})]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:s.status}),e.jsx("div",{className:"mt-1.5",children:e.jsxs(Y,{variant:i,children:[c&&e.jsx(q,{className:"h-3 w-3"}),N]})}),e.jsx("div",{className:"mt-1.5 text-[12px] leading-relaxed text-fg-5",children:w})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:s.currentConfig}),e.jsxs("div",{className:"mt-1.5 space-y-1.5 text-[13px] leading-relaxed text-fg-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-16 shrink-0 text-fg-5",children:s.model}),e.jsx("span",{className:"min-w-0 break-words text-fg-2",children:C})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-16 shrink-0 text-fg-5",children:s.effort}),e.jsx("span",{className:"text-fg-2",children:p})]})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:s.recommendedFor}),e.jsx("div",{className:"mt-1.5 text-[13px] leading-relaxed text-fg-3",children:g}),e.jsx("div",{className:"mt-2.5 text-[10px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:s.availableModels}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[!c&&D.length>0?D.map(v=>e.jsx("span",{className:"inline-flex h-6 max-w-full items-center rounded-md border border-edge bg-panel-alt px-2 text-[11px] text-fg-3",title:v.key,children:e.jsx("span",{className:"truncate",children:v.label})},v.key)):e.jsx("span",{className:"text-[12px] text-fg-5",children:c?n("status.loading"):s.noModel}),!c&&F>0&&e.jsx("span",{className:"inline-flex h-6 items-center rounded-md border border-edge bg-panel-alt px-2 text-[11px] text-fg-5",children:s.moreModels(F)})]}),e.jsx("div",{className:"mt-1.5 text-[12px] leading-relaxed text-fg-5",children:h})]}),e.jsxs("div",{className:ge("flex flex-col items-start gap-1.5 xl:items-end",t.installed&&"xl:self-start"),children:[c&&e.jsxs("div",{className:"inline-flex h-7 items-center gap-2 rounded-md border border-edge bg-transparent px-2.5 text-[11px] text-fg-5",children:[e.jsx(q,{className:"h-3 w-3"}),n("status.loading")]}),!c&&!t.installed&&e.jsx(y,{variant:"outline",size:"sm",disabled:m,onClick:()=>u(t),children:m?s.installing:s.install}),!c&&t.installed&&t.updateAvailable&&e.jsx(y,{variant:"primary",size:"sm",disabled:o,onClick:()=>A(t),children:o?s.updating:s.update}),!c&&t.installed&&!t.updateAvailable&&e.jsx(y,{variant:"ghost",size:"sm",disabled:d,onClick:()=>U(t),children:d?s.checking:s.checkUpdate}),!c&&t.installed&&t.updateAvailable&&t.updateStatus==="skipped"&&t.updateDetail&&e.jsxs("div",{className:"text-[11px] leading-relaxed text-amber-400",children:[s.updateSkipped,": ",t.updateDetail]}),!c&&t.installed&&t.updateStatus==="failed"&&t.updateDetail&&e.jsxs("div",{className:"text-[11px] leading-relaxed text-red-400",children:[s.updateFailed,": ",t.updateDetail]})]})]})})}function Oe(){const t=I(l=>l.locale),s=I(l=>l.toast),n=I(l=>l.agentStatus),m=I(l=>l.setAgentStatus),u=I(l=>l.refreshAgentStatus),o=r.useMemo(()=>xe(t),[t]),d=Ne(t),[A,U]=r.useState(n?{defaultAgent:n.defaultAgent,agents:n.agents}:null),[c,E]=r.useState(!n),[V,O]=r.useState(null),[j,D]=r.useState(!1),[F,_]=r.useState(null),[S,N]=r.useState(!1),[i,w]=r.useState({agent:"codex",model:"",effort:""}),C=r.useRef(!!n);r.useEffect(()=>{n&&(ee(U,n),C.current||(C.current=!0,E(!1)))},[n]);const p=r.useCallback(l=>{ee(U,l),m(l)},[m]),g=r.useCallback(async()=>{C.current||E(!0);try{const l=await H.getAgentStatus();return p(l),O(null),C.current=!0,l}catch(l){const a=l instanceof Error?l.message:d.loadFailed;return O(a),C.current||s(a,!1),null}finally{E(!1)}},[p,d.loadFailed,s]);r.useEffect(()=>{n?u():g()},[]);const h=r.useMemo(()=>{const l=A?.agents||[],a=new Map(l.map(f=>[f.agent,f]));return je.map(f=>{const T=a.get(f);if(T)return T;const b=R(f);return{agent:f,label:b.label,installed:!1,version:void 0,installCommand:void 0,selectedModel:null,selectedEffort:null,isDefault:A?.defaultAgent===f,models:[],usage:null}})},[A]),v=A?.defaultAgent||"codex",M=h.find(l=>l.agent===v)||null,J=h.filter(l=>l.installed).length>0,ae=Me(h,d),x=h.find(l=>l.agent===i.agent)||null,L=ke(x),$=Ae(x),Q=r.useCallback(async l=>{D(!0);try{const a=await H.updateRuntimeAgent(l);if(!a.ok)throw new Error(a.error||o("config.applyFailed"));return p(a),a}catch(a){const f=a instanceof Error?a.message:o("config.applyFailed");return s(f,!1),g(),null}finally{D(!1)}},[p,g,o,s]);r.useEffect(()=>{S&&w(te(M,v))},[v,M,S]),r.useEffect(()=>{if(!S||!x)return;const l=x.selectedModel||"",a=!i.model||L.some(b=>b.value===i.model),f=x.selectedEffort||"",T=!i.effort||$.some(b=>b.value===i.effort);a&&T||w(b=>({...b,model:a?b.model:l,effort:T?b.effort:f}))},[S,i.effort,i.model,x,$,L]);const ne=r.useCallback(l=>{const a=h.find(f=>f.agent===l);a?.installed&&w(te(a,a.agent))},[h]),de=r.useCallback(async()=>{if(!x?.installed)return;const l={};if(i.agent!==v&&(l.defaultAgent=i.agent),i.model&&i.model!==(x.selectedModel||"")&&(l.agent=i.agent,l.model=i.model),i.effort&&i.effort!==(x.selectedEffort||"")&&(l.agent=i.agent,l.effort=i.effort),Object.keys(l).length===0){N(!1);return}await Q(l)&&(s(d.defaultsSaved),N(!1))},[d.defaultsSaved,v,i.agent,i.effort,i.model,x,s,Q]),ie=r.useCallback(async l=>{if(!F){_(l.agent);try{const a=await H.installAgent(l.agent);if(!a.ok)throw new Error(a.error||o("config.agentInstallFailed"));p(a),s(o("config.agentInstalled"))}catch(a){const f=a instanceof Error?a.message:o("config.agentInstallFailed");s(f,!1),g()}finally{_(a=>a===l.agent?null:a)}}},[p,F,g,o,s]),[B,W]=r.useState(null),[z,X]=r.useState(null),re=r.useCallback(async l=>{if(!B){W(l.agent);try{const a=await H.updateAgent(l.agent);if(!a.ok)throw new Error(a.error||o("config.agentInstallFailed"));p(a),s(d.upToDate)}catch(a){const f=a instanceof Error?a.message:d.updateFailed;s(f,!1),g()}finally{W(a=>a===l.agent?null:a)}}},[p,d.updateFailed,d.upToDate,g,o,s,B]),oe=r.useCallback(async l=>{if(!z){X(l.agent);try{const a=await H.checkAgentUpdate(l.agent);if(!a.ok)throw new Error(a.error||d.loadFailed);p(a)}catch(a){const f=a instanceof Error?a.message:d.loadFailed;s(f,!1),g()}finally{X(a=>a===l.agent?null:a)}}},[p,z,d.loadFailed,g,s]),k=c&&!A,ce=k?o("status.loading"):M?R(M.agent).label:d.notInstalled,fe=k?o("status.loading"):M?.installed?d.installed:d.notInstalled,ue=k?o("status.loading"):M?le(M,d):d.noModel,me=k?o("status.loading"):M?.selectedEffort||d.noEffort;return e.jsxs("div",{className:"animate-in space-y-4",children:[e.jsx("section",{className:"space-y-3",children:e.jsxs(Z,{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-semibold tracking-tight text-fg",children:d.defaultsTitle}),e.jsx("div",{className:"mt-0.5 text-[13px] leading-relaxed text-fg-4",children:d.defaultsHint})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(y,{variant:"secondary",onClick:()=>N(!0),disabled:j||!J,children:d.editDefaults})})]}),e.jsxs("div",{className:"grid gap-2.5 lg:grid-cols-3",children:[e.jsx(G,{label:d.defaultAgent,value:ce,hint:fe,loading:k}),e.jsx(G,{label:d.defaultModel,value:ue,loading:k}),e.jsx(G,{label:d.defaultEffort,value:me,loading:k})]})]})}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] text-fg-5",children:d.agentsTitle}),e.jsx("div",{className:"space-y-3",children:h.map(l=>e.jsx(we,{agent:l,copy:d,t:o,installing:F===l.agent,loading:k,onInstall:ie,updatingAgent:B===l.agent,checkingAgent:z===l.agent,onUpdate:re,onCheckUpdate:oe},l.agent))})]}),V&&e.jsx(Z,{className:"border-amber-500/20 bg-amber-500/5",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[13px] text-fg-2",children:V}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>{g()},children:o("sessions.retry")})]})}),e.jsxs(ve,{open:S,onClose:()=>N(!1),children:[e.jsx(be,{title:d.defaultsEditTitle,description:d.defaultsEditHint,onClose:()=>N(!1)}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(P,{children:d.defaultAgent}),e.jsx(K,{value:i.agent,options:ae,onChange:ne,disabled:j||!J,placeholder:d.notInstalled})]}),e.jsxs("div",{children:[e.jsx(P,{children:d.defaultModel}),e.jsx(K,{value:i.model,options:L,onChange:l=>w(a=>({...a,model:l})),disabled:j||!x?.installed||L.length===0,placeholder:d.noModel})]}),e.jsxs("div",{children:[e.jsx(P,{children:d.defaultEffort}),e.jsx(K,{value:i.effort,options:$,onChange:l=>w(a=>({...a,effort:l})),disabled:j||!x?.installed||$.length===0,placeholder:d.noEffort})]})]}),e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:()=>N(!1),children:o("modal.cancel")}),e.jsx(y,{variant:"primary",disabled:j||!x?.installed,onClick:()=>{de()},children:o(j?"config.validating":"modal.save")})]})]})]})}export{Oe as AgentTab,Oe as default};
@@ -1 +1 @@
1
- import{j as t}from"./react-vendor-DTcmqLiz.js";import{c as s}from"./index-BPyYJAu2.js";const o="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAF+0lEQVRYha2XbXBUZxXHf+e5u4SkCZjg0NIWnQLJLgRF5UWnL75MP9gMjqPT2eyC0qlMiYxOUAR206LOyhiSTVscp52O0xamWgu7WTp0qLUz6kht6Qed1L7M5GUTsAoDTRSIJJos2b33+GFfWMJuNqmcT/c595z/+d3nOc+9zxXKWE9Li7tm0fjyqmT6H0t/Fp8sFz9XM+UCauouH8Rx+ifmWWdP7Q0sLRbT98g3lySC/mcSQd+GGwrQt2vzx1G2ZEa6KJ3S1mJxlpOKIDyEmEM3FGCk5vw5YCw3FmFbb9hXfV2gcm/26vINBfhS+LU0qgcKXB9xT1hbr6kdDhtgcYaDxHSNwVBg92Ao0DMY8n97zgAAZnK8U2AoX1D0++rzWfkC44k6wAVghP7C3EQo8Iiijyq61oEDiV2bPjojwKk234pEsPnh/lDgzpyv/olXrwi6qyDsjsQy2ZQXmJdefPWWvp0v3uZ/CLQ9NxZINpxJj84IYDvmOUT2G/T1DD0CUB/pflnhd1eT5Mcnwl90Adi23JzPl9TbAEN7fF9AeapQW5AOicftGQFEOJ+9tEDbB9v8x99r21wLYBlnJ5AGUKhfklz8QEbY3J71nVnZceziUPAbtzvGxAB3wdPH6yPRx6cXvw4gbbm/B5zIO5SvVKjdMxAMrKvviPcpHMyLqvyoN+ybh7AUwIi+M9TaVOGI/SJwc4Fsf6rS2SqgxQBkukPDYTM40RdCZB/Z5gKmEGmzjStq2alBoDqbvF2hEWgF9oEuAvlugdx/Deaz9ZEjvcWKFwXIWaLNv14cDqmwugDvFRVOi8qOrOMdhT6BzQhvoNxzjbjItxo6o8+VqjEjAMBQa1OFXbXwh4KGuLqmDleXToHzwG1FpLs9kah/uvf98IPz08nkSuZbp+vDL4zNCJAHaQt82lH9JfCJ2cQrTFjq8hiZGrfVtQGcDQhrFNYAywELuFw15SwRgN6dvrrahcnkreGXJ0pCtDZVOFULwsCerEBJExhVGAY8FH/Z2cBvPJHY1ySx13cbaXMaqACSwCVRLqlhVNBRVTOm4lxCOSdqPkB0FdA2m5kosGGEHpC3UP2z6uRJb9fx8SwsJEL+nwBNwEKgWqBSoXaORQqtH+VNhDdErJMNnYf/ViqwbBNO3lRbVZFSS9yyIG1jucRuVuGnM6TZZL4d/wS9KEgawIH/gF5EzAWBvzecto9KPG7PqgkBTu0NLHVs7VBlcxnwS8ALgtyp6Kco3S9/OF850lQWYCD41RpMZUiUH5BZmgkRDqmyVaCqeJYeS1dqwJq4UoG56S5w7hb4PMp6YH426LJR1+qSAOrzWYPLZCvIPuAWAIHXxGGXY3geWAV6DOTrJRR+r5q8P9dskNtJ1etBVl4R19FPdh4eLQowEPR5RKxfgebOeGMqGvLMX/V0YrK/W+B+4ATCYZRnEJ5E+Q5gFM4AFwQ+I8hbLks2Ltt/ZKTUg163Rwfamrcj5q/54spvLZes9nZ2/yIx0b8jW/wCLmeLOLoCAEdeAjmYnaWPGXga9Jiia1O28+bAbt8dswJQEFF5IrO2chGVBzxdsY0r2qNnBx5uvkuELkAFedDTHj+nIl4AIzJsjL2XTAOisB+XtqryKLBcLHNyKLSpsSyAgKrKJoRtbksaPV3R5yFz7BaHOOBGOdAQib6SRV4L4KQZqe+I/wvYmZWqE1ue8nbFggjbgDoH/VOxY3vZXdDT0uKuqR37I+jdIH9JV9r3NIbjU717fLe4jPkASDVEYhW5730i2PwqIvdlZkK3eCPdv06E/GuAbmCBJxJbUnIGill13b8fyxRnRG070BiOTwG4MeuyszBSeNiw3KZFYDTzdPLzU7u3LPZEYu+qTq5Tlev+K2YESAQD94rKjqzgl72Pxd/P3VNLsgAyXJizoj161kG3Z4d1aZP6HIC36/i4tyt6dE4AasQNDIhxNnoisXevvZndJcLw9DxvpLsb5XGE9yzD2ZlqzPpVPN0SIf854FaUZz1dsW0fVqdsD5Q05Qhgg7z+oTX+Xyv2pzNX+x+eTlGviPgh3AAAAABJRU5ErkJggg==",g="/assets/codex-DYadqqp0.png",r="/assets/feishu-C4OMrjCW.ico",a="/assets/gemini-BYkEpiWr.svg",n="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='16px'%20height='16px'%20viewBox='0%200%2016%2016'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cdefs%3e%3clinearGradient%20x1='50%25'%20y1='0%25'%20x2='50%25'%20y2='100%25'%20id='linearGradient-1'%3e%3cstop%20stop-color='%2338AEEB'%20offset='0%25'%3e%3c/stop%3e%3cstop%20stop-color='%23279AD1'%20offset='100%25'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3cg%20id='Artboard'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3ccircle%20id='Oval'%20fill='url(%23linearGradient-1)'%20cx='8'%20cy='8'%20r='8'%3e%3c/circle%3e%3cpath%20d='M3.17026167,7.83635602%20C5.78750201,6.74265999%207.53273882,6.02162863%208.40597211,5.67326193%20C10.8992306,4.67860423%2011.2454541,4.53439191%2011.5831299,4.52864956%20C11.6573986,4.52743168%2011.8385417,4.55776042%2011.9798438,4.67645833%20C12.1211458,4.79515625%2012.1635786,4.87206678%2012.1755371,4.93908691%20C12.1874957,5.00610705%2012.1862759,5.21456762%2012.1744385,5.3338623%20C12.0393279,6.69547283%2011.5259342,9.83829771%2011.2285121,11.3633248%20C11.1026617,12.008621%2010.8548582,12.2249854%2010.6149558,12.2461596%20C10.0935924,12.2921758%209.69769267,11.9156852%209.19272668,11.5981993%20C8.40255458,11.1013965%208.13911734,10.9180161%207.3721185,10.4332283%20C6.48571864,9.87297217%206.85080034,9.6784879%207.35595703,9.17524981%20C7.48815894,9.04355001%209.67825076,7.04590073%209.71077046,6.86250183%20C9.7391276,6.70257812%209.7494847,6.68189389%209.67664063,6.60973958%20C9.60379655,6.53758527%209.51674192,6.54658941%209.46083149,6.55876051%20C9.38158015,6.57601267%208.17521836,7.33962686%205.84174612,8.84960308%20C5.48344358,9.08558775%205.15890428,9.20056741%204.86812819,9.19454205%20C4.54757089,9.18789957%203.93094724,9.02070014%203.47255094,8.87778221%20C2.91030922,8.70248755%202.46345069,8.609808%202.50236203,8.31210343%20C2.52262946,8.15704047%202.74526267,7.998458%203.17026167,7.83635602%20Z'%20id='Path-3'%20fill='%23FFFFFF'%3e%3c/path%3e%3c/g%3e%3c/svg%3e",d="data:image/svg+xml,%3csvg%20width='128'%20height='128'%20viewBox='0%200%20128%20128'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='128'%20height='128'%20rx='28'%20fill='%2307C160'/%3e%3cpath%20d='M42%2033c-16.569%200-30%2011.64-30%2026%200%208.084%204.283%2015.306%2011.008%2020.073L18%2095l20.832-8.102A37.33%2037.33%200%200%200%2042%2087c16.569%200%2030-11.64%2030-26S58.569%2033%2042%2033Z'%20fill='%23fff'/%3e%3cpath%20d='M85%2048c-13.807%200-25%209.402-25%2021%200%2011.598%2011.193%2021%2025%2021%202.545%200%205-.319%207.29-.91L109%2095l-4.772-12.27C109.078%2079.05%20112%2074.232%20112%2069c0-11.598-12.193-21-27-21Z'%20fill='%23fff'%20opacity='.95'/%3e%3ccircle%20cx='33'%20cy='56'%20r='4.5'%20fill='%2307C160'/%3e%3ccircle%20cx='50'%20cy='56'%20r='4.5'%20fill='%2307C160'/%3e%3ccircle%20cx='77'%20cy='66'%20r='4'%20fill='%2307C160'/%3e%3ccircle%20cx='92'%20cy='66'%20r='4'%20fill='%2307C160'/%3e%3c/svg%3e",w="/assets/playwright-BldPFZgC.ico",h="/assets/appium-Ra-JU1qL.png",x="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M23.15%202.587L18.21.21a1.494%201.494%200%200%200-1.705.29l-9.46%208.63-4.12-3.128a.999.999%200%200%200-1.276.057L.327%207.261A1%201%200%200%200%20.326%208.74L3.899%2012%20.326%2015.26a1%201%200%200%200%20.001%201.479L1.65%2017.94a.999.999%200%200%200%201.276.057l4.12-3.128%209.46%208.63a1.492%201.492%200%200%200%201.704.29l4.942-2.377A1.5%201.5%200%200%200%2024%2020.06V3.939a1.5%201.5%200%200%200-.85-1.352zm-5.146%2014.861L10.826%2012l7.178-5.448v10.896z'%20fill='%23007ACC'/%3e%3c/svg%3e",f="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3crect%20width='24'%20height='24'%20rx='5.5'%20fill='%2319191C'/%3e%3cpath%20d='M7%205l10%207-4.5%201.5L15.5%2019l-2.2.8-3-5.5L7%2017z'%20fill='%23fff'/%3e%3c/svg%3e",A="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3crect%20width='24'%20height='24'%20rx='5.5'%20fill='%230BA48A'/%3e%3cpath%20d='M8%2018l2-12h2.5l-1.2%205h4.2L10%2018H8zm3.5-3.5l3-7.5'%20fill='%23fff'%20fill-rule='evenodd'/%3e%3c/svg%3e",v="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3crect%20width='24'%20height='24'%20rx='5.5'%20fill='%234A90D9'/%3e%3crect%20x='5'%20y='5'%20width='14'%20height='12'%20rx='1.5'%20fill='%236DB3F2'/%3e%3crect%20x='5'%20y='5'%20width='14'%20height='3.5'%20rx='1.5'%20fill='%233D7ABF'/%3e%3ccircle%20cx='8.5'%20cy='6.8'%20r='.8'%20fill='%23FF5F57'/%3e%3ccircle%20cx='11'%20cy='6.8'%20r='.8'%20fill='%23FEBC2E'/%3e%3ccircle%20cx='13.5'%20cy='6.8'%20r='.8'%20fill='%2328C840'/%3e%3crect%20x='7'%20y='10.5'%20width='10'%20height='1'%20rx='.5'%20fill='%23fff'%20opacity='.7'/%3e%3crect%20x='7'%20y='13'%20width='7'%20height='1'%20rx='.5'%20fill='%23fff'%20opacity='.5'/%3e%3c/svg%3e",L={claude:o,codex:g,gemini:a,telegram:n,feishu:r,weixin:d,playwright:w,appium:h,vscode:x,cursor:f,windsurf:A,finder:v};function C({brand:i,size:e=18,className:l}){const c=L[i];return c?t.jsx("img",{src:c,alt:"","aria-hidden":"true",draggable:!1,className:s("shrink-0 object-contain select-none",l),style:{width:e,height:e}}):null}export{C as B};
1
+ import{j as t}from"./react-vendor-DTcmqLiz.js";import{c as s}from"./index-D5sKCspB.js";const o="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAF+0lEQVRYha2XbXBUZxXHf+e5u4SkCZjg0NIWnQLJLgRF5UWnL75MP9gMjqPT2eyC0qlMiYxOUAR206LOyhiSTVscp52O0xamWgu7WTp0qLUz6kht6Qed1L7M5GUTsAoDTRSIJJos2b33+GFfWMJuNqmcT/c595z/+d3nOc+9zxXKWE9Li7tm0fjyqmT6H0t/Fp8sFz9XM+UCauouH8Rx+ifmWWdP7Q0sLRbT98g3lySC/mcSQd+GGwrQt2vzx1G2ZEa6KJ3S1mJxlpOKIDyEmEM3FGCk5vw5YCw3FmFbb9hXfV2gcm/26vINBfhS+LU0qgcKXB9xT1hbr6kdDhtgcYaDxHSNwVBg92Ao0DMY8n97zgAAZnK8U2AoX1D0++rzWfkC44k6wAVghP7C3EQo8Iiijyq61oEDiV2bPjojwKk234pEsPnh/lDgzpyv/olXrwi6qyDsjsQy2ZQXmJdefPWWvp0v3uZ/CLQ9NxZINpxJj84IYDvmOUT2G/T1DD0CUB/pflnhd1eT5Mcnwl90Adi23JzPl9TbAEN7fF9AeapQW5AOicftGQFEOJ+9tEDbB9v8x99r21wLYBlnJ5AGUKhfklz8QEbY3J71nVnZceziUPAbtzvGxAB3wdPH6yPRx6cXvw4gbbm/B5zIO5SvVKjdMxAMrKvviPcpHMyLqvyoN+ybh7AUwIi+M9TaVOGI/SJwc4Fsf6rS2SqgxQBkukPDYTM40RdCZB/Z5gKmEGmzjStq2alBoDqbvF2hEWgF9oEuAvlugdx/Deaz9ZEjvcWKFwXIWaLNv14cDqmwugDvFRVOi8qOrOMdhT6BzQhvoNxzjbjItxo6o8+VqjEjAMBQa1OFXbXwh4KGuLqmDleXToHzwG1FpLs9kah/uvf98IPz08nkSuZbp+vDL4zNCJAHaQt82lH9JfCJ2cQrTFjq8hiZGrfVtQGcDQhrFNYAywELuFw15SwRgN6dvrrahcnkreGXJ0pCtDZVOFULwsCerEBJExhVGAY8FH/Z2cBvPJHY1ySx13cbaXMaqACSwCVRLqlhVNBRVTOm4lxCOSdqPkB0FdA2m5kosGGEHpC3UP2z6uRJb9fx8SwsJEL+nwBNwEKgWqBSoXaORQqtH+VNhDdErJMNnYf/ViqwbBNO3lRbVZFSS9yyIG1jucRuVuGnM6TZZL4d/wS9KEgawIH/gF5EzAWBvzecto9KPG7PqgkBTu0NLHVs7VBlcxnwS8ALgtyp6Kco3S9/OF850lQWYCD41RpMZUiUH5BZmgkRDqmyVaCqeJYeS1dqwJq4UoG56S5w7hb4PMp6YH426LJR1+qSAOrzWYPLZCvIPuAWAIHXxGGXY3geWAV6DOTrJRR+r5q8P9dskNtJ1etBVl4R19FPdh4eLQowEPR5RKxfgebOeGMqGvLMX/V0YrK/W+B+4ATCYZRnEJ5E+Q5gFM4AFwQ+I8hbLks2Ltt/ZKTUg163Rwfamrcj5q/54spvLZes9nZ2/yIx0b8jW/wCLmeLOLoCAEdeAjmYnaWPGXga9Jiia1O28+bAbt8dswJQEFF5IrO2chGVBzxdsY0r2qNnBx5uvkuELkAFedDTHj+nIl4AIzJsjL2XTAOisB+XtqryKLBcLHNyKLSpsSyAgKrKJoRtbksaPV3R5yFz7BaHOOBGOdAQib6SRV4L4KQZqe+I/wvYmZWqE1ue8nbFggjbgDoH/VOxY3vZXdDT0uKuqR37I+jdIH9JV9r3NIbjU717fLe4jPkASDVEYhW5730i2PwqIvdlZkK3eCPdv06E/GuAbmCBJxJbUnIGill13b8fyxRnRG070BiOTwG4MeuyszBSeNiw3KZFYDTzdPLzU7u3LPZEYu+qTq5Tlev+K2YESAQD94rKjqzgl72Pxd/P3VNLsgAyXJizoj161kG3Z4d1aZP6HIC36/i4tyt6dE4AasQNDIhxNnoisXevvZndJcLw9DxvpLsb5XGE9yzD2ZlqzPpVPN0SIf854FaUZz1dsW0fVqdsD5Q05Qhgg7z+oTX+Xyv2pzNX+x+eTlGviPgh3AAAAABJRU5ErkJggg==",g="/assets/codex-DYadqqp0.png",r="/assets/feishu-C4OMrjCW.ico",a="/assets/gemini-BYkEpiWr.svg",n="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='16px'%20height='16px'%20viewBox='0%200%2016%2016'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cdefs%3e%3clinearGradient%20x1='50%25'%20y1='0%25'%20x2='50%25'%20y2='100%25'%20id='linearGradient-1'%3e%3cstop%20stop-color='%2338AEEB'%20offset='0%25'%3e%3c/stop%3e%3cstop%20stop-color='%23279AD1'%20offset='100%25'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3cg%20id='Artboard'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3ccircle%20id='Oval'%20fill='url(%23linearGradient-1)'%20cx='8'%20cy='8'%20r='8'%3e%3c/circle%3e%3cpath%20d='M3.17026167,7.83635602%20C5.78750201,6.74265999%207.53273882,6.02162863%208.40597211,5.67326193%20C10.8992306,4.67860423%2011.2454541,4.53439191%2011.5831299,4.52864956%20C11.6573986,4.52743168%2011.8385417,4.55776042%2011.9798438,4.67645833%20C12.1211458,4.79515625%2012.1635786,4.87206678%2012.1755371,4.93908691%20C12.1874957,5.00610705%2012.1862759,5.21456762%2012.1744385,5.3338623%20C12.0393279,6.69547283%2011.5259342,9.83829771%2011.2285121,11.3633248%20C11.1026617,12.008621%2010.8548582,12.2249854%2010.6149558,12.2461596%20C10.0935924,12.2921758%209.69769267,11.9156852%209.19272668,11.5981993%20C8.40255458,11.1013965%208.13911734,10.9180161%207.3721185,10.4332283%20C6.48571864,9.87297217%206.85080034,9.6784879%207.35595703,9.17524981%20C7.48815894,9.04355001%209.67825076,7.04590073%209.71077046,6.86250183%20C9.7391276,6.70257812%209.7494847,6.68189389%209.67664063,6.60973958%20C9.60379655,6.53758527%209.51674192,6.54658941%209.46083149,6.55876051%20C9.38158015,6.57601267%208.17521836,7.33962686%205.84174612,8.84960308%20C5.48344358,9.08558775%205.15890428,9.20056741%204.86812819,9.19454205%20C4.54757089,9.18789957%203.93094724,9.02070014%203.47255094,8.87778221%20C2.91030922,8.70248755%202.46345069,8.609808%202.50236203,8.31210343%20C2.52262946,8.15704047%202.74526267,7.998458%203.17026167,7.83635602%20Z'%20id='Path-3'%20fill='%23FFFFFF'%3e%3c/path%3e%3c/g%3e%3c/svg%3e",d="data:image/svg+xml,%3csvg%20width='128'%20height='128'%20viewBox='0%200%20128%20128'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='128'%20height='128'%20rx='28'%20fill='%2307C160'/%3e%3cpath%20d='M42%2033c-16.569%200-30%2011.64-30%2026%200%208.084%204.283%2015.306%2011.008%2020.073L18%2095l20.832-8.102A37.33%2037.33%200%200%200%2042%2087c16.569%200%2030-11.64%2030-26S58.569%2033%2042%2033Z'%20fill='%23fff'/%3e%3cpath%20d='M85%2048c-13.807%200-25%209.402-25%2021%200%2011.598%2011.193%2021%2025%2021%202.545%200%205-.319%207.29-.91L109%2095l-4.772-12.27C109.078%2079.05%20112%2074.232%20112%2069c0-11.598-12.193-21-27-21Z'%20fill='%23fff'%20opacity='.95'/%3e%3ccircle%20cx='33'%20cy='56'%20r='4.5'%20fill='%2307C160'/%3e%3ccircle%20cx='50'%20cy='56'%20r='4.5'%20fill='%2307C160'/%3e%3ccircle%20cx='77'%20cy='66'%20r='4'%20fill='%2307C160'/%3e%3ccircle%20cx='92'%20cy='66'%20r='4'%20fill='%2307C160'/%3e%3c/svg%3e",w="/assets/playwright-BldPFZgC.ico",h="/assets/appium-Ra-JU1qL.png",x="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M23.15%202.587L18.21.21a1.494%201.494%200%200%200-1.705.29l-9.46%208.63-4.12-3.128a.999.999%200%200%200-1.276.057L.327%207.261A1%201%200%200%200%20.326%208.74L3.899%2012%20.326%2015.26a1%201%200%200%200%20.001%201.479L1.65%2017.94a.999.999%200%200%200%201.276.057l4.12-3.128%209.46%208.63a1.492%201.492%200%200%200%201.704.29l4.942-2.377A1.5%201.5%200%200%200%2024%2020.06V3.939a1.5%201.5%200%200%200-.85-1.352zm-5.146%2014.861L10.826%2012l7.178-5.448v10.896z'%20fill='%23007ACC'/%3e%3c/svg%3e",f="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3crect%20width='24'%20height='24'%20rx='5.5'%20fill='%2319191C'/%3e%3cpath%20d='M7%205l10%207-4.5%201.5L15.5%2019l-2.2.8-3-5.5L7%2017z'%20fill='%23fff'/%3e%3c/svg%3e",A="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3crect%20width='24'%20height='24'%20rx='5.5'%20fill='%230BA48A'/%3e%3cpath%20d='M8%2018l2-12h2.5l-1.2%205h4.2L10%2018H8zm3.5-3.5l3-7.5'%20fill='%23fff'%20fill-rule='evenodd'/%3e%3c/svg%3e",v="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3crect%20width='24'%20height='24'%20rx='5.5'%20fill='%234A90D9'/%3e%3crect%20x='5'%20y='5'%20width='14'%20height='12'%20rx='1.5'%20fill='%236DB3F2'/%3e%3crect%20x='5'%20y='5'%20width='14'%20height='3.5'%20rx='1.5'%20fill='%233D7ABF'/%3e%3ccircle%20cx='8.5'%20cy='6.8'%20r='.8'%20fill='%23FF5F57'/%3e%3ccircle%20cx='11'%20cy='6.8'%20r='.8'%20fill='%23FEBC2E'/%3e%3ccircle%20cx='13.5'%20cy='6.8'%20r='.8'%20fill='%2328C840'/%3e%3crect%20x='7'%20y='10.5'%20width='10'%20height='1'%20rx='.5'%20fill='%23fff'%20opacity='.7'/%3e%3crect%20x='7'%20y='13'%20width='7'%20height='1'%20rx='.5'%20fill='%23fff'%20opacity='.5'/%3e%3c/svg%3e",L={claude:o,codex:g,gemini:a,telegram:n,feishu:r,weixin:d,playwright:w,appium:h,vscode:x,cursor:f,windsurf:A,finder:v};function C({brand:i,size:e=18,className:l}){const c=L[i];return c?t.jsx("img",{src:c,alt:"","aria-hidden":"true",draggable:!1,className:s("shrink-0 object-contain select-none",l),style:{width:e,height:e}}):null}export{C as B};
@@ -1 +1 @@
1
- import{r,j as e}from"./react-vendor-DTcmqLiz.js";import{a as I,k as P,S as z}from"./index-BPyYJAu2.js";function W({initialPath:x,maxHeight:j=420,minHeight:N=200,onSelect:p,compact:l,t:o}){const[y,k]=r.useState(""),[h,m]=r.useState(""),[g,w]=r.useState([]),[i,S]=r.useState(""),[C,$]=r.useState(!1),[D,B]=r.useState([]),[E,c]=r.useState(!1),[u,d]=r.useState(""),a=r.useCallback(async t=>{c(!0),d("");try{const s=await I.lsDir(t);if(!s.ok){d(s.error||o("modal.cannotRead")),c(!1);return}k(s.path),m(s.path),w(s.dirs),S(s.parent),$(s.isGit);const G=s.path.split("/").filter(Boolean);let v="";B(G.map(b=>(v+="/"+b,{label:b,path:v}))),p?.(s.path,s.isGit)}catch{d(o("modal.loadFailed"))}finally{c(!1)}},[o,p]);r.useEffect(()=>{x!==void 0&&a(x||void 0)},[]);const n=l?"text-[11px]":"text-xs",f=l?"py-[5px]":"py-[7px]";return e.jsxs("div",{children:[e.jsxs("div",{className:`flex items-center gap-1 ${l?"text-[10px]":"text-[11px]"} font-mono text-fg-4 mb-2 flex-wrap`,children:[e.jsx("span",{className:"cursor-pointer hover:text-fg-2 transition-colors",onClick:()=>a("/"),children:"~"}),D.map((t,s)=>e.jsxs("span",{children:[e.jsx("span",{className:"text-fg-6",children:"/"}),e.jsx("span",{className:"cursor-pointer hover:text-fg-2 transition-colors",onClick:()=>a(t.path),children:t.label})]},s)),C&&e.jsx(P,{variant:"accent",className:"ml-1 !text-[9px] !py-0 !px-1.5",children:"git"})]}),e.jsxs("div",{className:"relative",children:[!l&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 h-5 rounded-t-lg",style:{background:"linear-gradient(to bottom, var(--th-panel-alt), rgba(0, 0, 0, 0))"}}),e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 h-5 rounded-b-lg",style:{background:"linear-gradient(to top, var(--th-panel-alt), rgba(0, 0, 0, 0))"}})]}),e.jsx("div",{className:"border border-edge rounded-lg overflow-y-auto overscroll-contain scroll-smooth bg-panel-alt",style:{maxHeight:j,minHeight:N,scrollbarGutter:"stable"},children:E?e.jsx("div",{className:`${n} text-fg-5 p-4 text-center flex items-center justify-center gap-2`,children:e.jsx(z,{className:"h-3 w-3 text-fg-5"})}):u?e.jsx("div",{className:`${n} text-red-500/70 p-4`,children:u}):e.jsxs(e.Fragment,{children:[i&&i!==y&&e.jsxs("div",{className:`flex items-center gap-2 px-3 ${f} cursor-pointer hover:bg-panel transition-colors border-b border-edge`,onClick:()=>a(i),children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",className:"text-fg-5 shrink-0",children:e.jsx("polyline",{points:"15 18 9 12 15 6"})}),e.jsx("span",{className:`${n} text-fg-4`,children:".."})]}),g.length===0&&!i&&e.jsx("div",{className:`${n} text-fg-5 p-4 text-center`,children:o("modal.emptyDir")}),g.map(t=>e.jsxs("div",{className:`flex items-center gap-2 px-3 ${f} cursor-pointer hover:bg-panel transition-colors`,onClick:()=>a(t.path),children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:t.name===".git"?"var(--th-primary)":"currentColor",strokeWidth:"1.8",className:"text-fg-5 shrink-0",children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}),e.jsx("span",{className:`${n} text-fg-3`,children:t.name})]},t.path))]})})]}),e.jsx("div",{className:"mt-2",children:e.jsx("input",{className:`w-full rounded-lg border border-edge bg-inset px-2.5 py-1.5 ${n} font-mono text-fg outline-none placeholder:text-fg-5 focus:border-edge-h transition-colors`,placeholder:o("modal.manualInput"),value:h,onChange:t=>m(t.target.value),onKeyDown:t=>{t.key==="Enter"&&a(h)}})})]})}export{W as D};
1
+ import{r,j as e}from"./react-vendor-DTcmqLiz.js";import{a as I,k as P,S as z}from"./index-D5sKCspB.js";function W({initialPath:x,maxHeight:j=420,minHeight:N=200,onSelect:p,compact:l,t:o}){const[y,k]=r.useState(""),[h,m]=r.useState(""),[g,w]=r.useState([]),[i,S]=r.useState(""),[C,$]=r.useState(!1),[D,B]=r.useState([]),[E,c]=r.useState(!1),[u,d]=r.useState(""),a=r.useCallback(async t=>{c(!0),d("");try{const s=await I.lsDir(t);if(!s.ok){d(s.error||o("modal.cannotRead")),c(!1);return}k(s.path),m(s.path),w(s.dirs),S(s.parent),$(s.isGit);const G=s.path.split("/").filter(Boolean);let v="";B(G.map(b=>(v+="/"+b,{label:b,path:v}))),p?.(s.path,s.isGit)}catch{d(o("modal.loadFailed"))}finally{c(!1)}},[o,p]);r.useEffect(()=>{x!==void 0&&a(x||void 0)},[]);const n=l?"text-[11px]":"text-xs",f=l?"py-[5px]":"py-[7px]";return e.jsxs("div",{children:[e.jsxs("div",{className:`flex items-center gap-1 ${l?"text-[10px]":"text-[11px]"} font-mono text-fg-4 mb-2 flex-wrap`,children:[e.jsx("span",{className:"cursor-pointer hover:text-fg-2 transition-colors",onClick:()=>a("/"),children:"~"}),D.map((t,s)=>e.jsxs("span",{children:[e.jsx("span",{className:"text-fg-6",children:"/"}),e.jsx("span",{className:"cursor-pointer hover:text-fg-2 transition-colors",onClick:()=>a(t.path),children:t.label})]},s)),C&&e.jsx(P,{variant:"accent",className:"ml-1 !text-[9px] !py-0 !px-1.5",children:"git"})]}),e.jsxs("div",{className:"relative",children:[!l&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 h-5 rounded-t-lg",style:{background:"linear-gradient(to bottom, var(--th-panel-alt), rgba(0, 0, 0, 0))"}}),e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 h-5 rounded-b-lg",style:{background:"linear-gradient(to top, var(--th-panel-alt), rgba(0, 0, 0, 0))"}})]}),e.jsx("div",{className:"border border-edge rounded-lg overflow-y-auto overscroll-contain scroll-smooth bg-panel-alt",style:{maxHeight:j,minHeight:N,scrollbarGutter:"stable"},children:E?e.jsx("div",{className:`${n} text-fg-5 p-4 text-center flex items-center justify-center gap-2`,children:e.jsx(z,{className:"h-3 w-3 text-fg-5"})}):u?e.jsx("div",{className:`${n} text-red-500/70 p-4`,children:u}):e.jsxs(e.Fragment,{children:[i&&i!==y&&e.jsxs("div",{className:`flex items-center gap-2 px-3 ${f} cursor-pointer hover:bg-panel transition-colors border-b border-edge`,onClick:()=>a(i),children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",className:"text-fg-5 shrink-0",children:e.jsx("polyline",{points:"15 18 9 12 15 6"})}),e.jsx("span",{className:`${n} text-fg-4`,children:".."})]}),g.length===0&&!i&&e.jsx("div",{className:`${n} text-fg-5 p-4 text-center`,children:o("modal.emptyDir")}),g.map(t=>e.jsxs("div",{className:`flex items-center gap-2 px-3 ${f} cursor-pointer hover:bg-panel transition-colors`,onClick:()=>a(t.path),children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:t.name===".git"?"var(--th-primary)":"currentColor",strokeWidth:"1.8",className:"text-fg-5 shrink-0",children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}),e.jsx("span",{className:`${n} text-fg-3`,children:t.name})]},t.path))]})})]}),e.jsx("div",{className:"mt-2",children:e.jsx("input",{className:`w-full rounded-lg border border-edge bg-inset px-2.5 py-1.5 ${n} font-mono text-fg outline-none placeholder:text-fg-5 focus:border-edge-h transition-colors`,placeholder:o("modal.manualInput"),value:h,onChange:t=>m(t.target.value),onKeyDown:t=>{t.key==="Enter"&&a(h)}})})]})}export{W as D};
@@ -1 +1 @@
1
- import{r as m,j as s}from"./react-vendor-DTcmqLiz.js";import{u as p,b as B,a as R,B as g,k as w,S as N}from"./index-BPyYJAu2.js";import{B as k}from"./BrandIcon-DI28YjL9.js";import{a as S,b as C,c as b,d as y}from"./shared-Diw6OFf-.js";import"./router-emLofBBH.js";function t(a,e,n){return a==="zh-CN"?e:n}function _(a,e,n){const r=a?.browser;return r?r.enabled?r.status==="chrome_missing"?{label:t(e,"Chrome 未安装","Chrome missing"),variant:"err"}:r.status==="needs_setup"?{label:t(e,"需要配置","Needs setup"),variant:"warn"}:r.running?{label:t(e,"浏览器已打开","Browser open"),variant:"ok"}:r.status==="ready"?{label:t(e,"已就绪","Available"),variant:"ok"}:{label:t(e,"需要检查","Needs attention"),variant:"warn"}:{label:t(e,"已关闭","Disabled"),variant:"muted"}:{label:n("status.loading"),variant:"muted"}}function E(a,e,n){const r=a?.desktop;return r?r.installed?r.running?{label:t(e,"运行中","Running"),variant:"ok"}:r.enabled?{label:t(e,"已启用","Enabled"),variant:"accent"}:{label:t(e,"已关闭","Disabled"),variant:"muted"}:{label:t(e,"未安装","Not installed"),variant:"muted"}:{label:n("status.loading"),variant:"muted"}}function V(a,e){const n=t(e,"配置文件","Profile"),r=t(e,"运行方式","Mode"),o=t(e,"Chrome","Chrome"),l=a?.profileCreated?t(e,"已创建","Created"):t(e,"待创建","Not created"),d=a?.enabled?a.headlessMode==="headed"?t(e,"可见窗口","Visible window"):t(e,"后台运行","Headless"):t(e,"已关闭","Disabled"),u=a?.chromeInstalled?t(e,"已安装","Installed"):t(e,"未安装","Not installed");return[{label:n,value:l},{label:r,value:d},{label:o,value:u}]}function z(a,e){const n=t(e,"连接地址","Address"),r=t(e,"驱动","Driver"),o=t(e,"服务状态","Service"),l=a?.appiumUrl||"http://127.0.0.1:4723",d=t(e,"Appium Mac2","Appium Mac2"),u=a?a.running?t(e,"运行中","Running"):a.enabled?t(e,"已启用","Enabled"):t(e,"已关闭","Disabled"):t(e,"加载中","Loading");return[{label:n,value:l},{label:r,value:d},{label:o,value:u}]}function L(a,e){return a?a.enabled?a.running?t(e,"独立浏览器已打开,可继续补充登录态。","The managed browser is open and ready for login."):a.status==="ready"?t(e,"已就绪,可在后续会话中直接使用。","Ready for upcoming sessions."):a.status==="chrome_missing"?t(e,"本机未检测到 Chrome。","Chrome was not detected on this machine."):a.detail||t(e,"需要先完成一次浏览器配置。","Setup is required before browser automation can be used."):t(e,"当前不会向 Agent 会话注入 browser MCP。","Browser MCP will not be injected into agent sessions."):t(e,"正在读取浏览器状态。","Loading browser status.")}function T(a,e){return a?a.installed?a.running?t(e,"桌面自动化服务已启动。","The desktop automation service is running."):a.enabled?t(e,"已启用,可在后续会话中直接调用。","Enabled and ready for upcoming sessions."):t(e,"当前不会向 Agent 会话注入桌面自动化能力。","Desktop automation will not be injected into agent sessions."):t(e,"需要先安装 Appium Mac2 驱动。","Appium Mac2 must be installed first."):t(e,"正在读取桌面自动化状态。","Loading desktop automation status.")}function U({onOpenBrowserSetup:a,onOpenDesktopSetup:e}){const n=p(i=>i.locale),r=p(i=>i.toast),o=p(i=>i.state),l=m.useMemo(()=>B(n),[n]),[d,u]=m.useState(null),[M,h]=m.useState(!1),f=m.useCallback(async()=>{h(!0);try{u(await R.getBrowser())}catch(i){r(i instanceof Error?i.message:l("config.applyFailed"),!1)}finally{h(!1)}},[l,r]);m.useEffect(()=>{f()},[f,o]);const c=d?.browser,x=d?.desktop,v=_(d,n,l),j=E(d,n,l),D=V(c,n),A=z(x,n);return s.jsxs("div",{className:"animate-in space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end sm:justify-between",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx("div",{className:"text-[13px] leading-relaxed text-fg-4",children:l("ext.hint")})}),s.jsx(g,{variant:"outline",size:"sm",onClick:()=>{f()},disabled:M,children:l("perm.guideRefresh")})]}),s.jsxs(S,{className:"xl:grid-cols-[minmax(0,235px)_minmax(240px,0.95fr)_minmax(0,1.1fr)_auto]",children:[s.jsx(C,{icon:s.jsx(k,{brand:"playwright",size:22}),title:l("ext.browser"),subtitle:l("ext.browserDesc")}),s.jsxs(b,{label:t(n,"状态","Status"),children:[s.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:s.jsxs(w,{variant:v.variant,children:[!d&&s.jsx(N,{}),v.label]})}),s.jsx("div",{className:"mt-1 text-[13px] leading-relaxed text-fg-3",children:L(c,n)})]}),s.jsx(b,{label:t(n,"当前配置","Current config"),children:s.jsx("div",{className:"space-y-1.5 text-[13px] leading-relaxed text-fg-3",children:D.map(i=>s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"w-16 shrink-0 text-fg-5",children:i.label}),s.jsx("span",{className:"min-w-0 break-words",children:i.value})]},i.label))})}),s.jsx(y,{children:s.jsx(g,{variant:c?.enabled?"outline":"primary",size:"sm",onClick:a,children:c?.enabled?t(n,"管理","Manage"):l("ext.setup")})})]}),s.jsxs(S,{className:"xl:grid-cols-[minmax(0,235px)_minmax(240px,0.95fr)_minmax(0,1.1fr)_auto]",children:[s.jsx(C,{icon:s.jsx(k,{brand:"appium",size:22}),title:l("ext.desktop"),subtitle:l("ext.desktopDesc")}),s.jsxs(b,{label:t(n,"状态","Status"),children:[s.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:s.jsxs(w,{variant:j.variant,children:[!d&&s.jsx(N,{}),j.label]})}),s.jsx("div",{className:"mt-1 text-[13px] leading-relaxed text-fg-3",children:T(x,n)})]}),s.jsx(b,{label:t(n,"当前配置","Current config"),children:s.jsx("div",{className:"space-y-1.5 text-[13px] leading-relaxed text-fg-3",children:A.map(i=>s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"w-16 shrink-0 text-fg-5",children:i.label}),s.jsx("span",{className:/^https?:\/\//.test(i.value)?"min-w-0 break-words font-mono text-[12px]":"min-w-0 break-words",children:i.value})]},i.label))})}),s.jsx(y,{children:s.jsx(g,{variant:x?.enabled?"outline":"primary",size:"sm",onClick:e,children:x?.enabled?t(n,"管理","Manage"):l("ext.setup")})})]})]})}export{U as ExtensionsTab};
1
+ import{r as m,j as s}from"./react-vendor-DTcmqLiz.js";import{u as p,b as B,a as R,B as g,k as w,S as N}from"./index-D5sKCspB.js";import{B as k}from"./BrandIcon-BoMxvhBf.js";import{a as S,b as C,c as b,d as y}from"./shared-6sWbm5Tj.js";import"./router-emLofBBH.js";function t(a,e,n){return a==="zh-CN"?e:n}function _(a,e,n){const r=a?.browser;return r?r.enabled?r.status==="chrome_missing"?{label:t(e,"Chrome 未安装","Chrome missing"),variant:"err"}:r.status==="needs_setup"?{label:t(e,"需要配置","Needs setup"),variant:"warn"}:r.running?{label:t(e,"浏览器已打开","Browser open"),variant:"ok"}:r.status==="ready"?{label:t(e,"已就绪","Available"),variant:"ok"}:{label:t(e,"需要检查","Needs attention"),variant:"warn"}:{label:t(e,"已关闭","Disabled"),variant:"muted"}:{label:n("status.loading"),variant:"muted"}}function E(a,e,n){const r=a?.desktop;return r?r.installed?r.running?{label:t(e,"运行中","Running"),variant:"ok"}:r.enabled?{label:t(e,"已启用","Enabled"),variant:"accent"}:{label:t(e,"已关闭","Disabled"),variant:"muted"}:{label:t(e,"未安装","Not installed"),variant:"muted"}:{label:n("status.loading"),variant:"muted"}}function V(a,e){const n=t(e,"配置文件","Profile"),r=t(e,"运行方式","Mode"),o=t(e,"Chrome","Chrome"),l=a?.profileCreated?t(e,"已创建","Created"):t(e,"待创建","Not created"),d=a?.enabled?a.headlessMode==="headed"?t(e,"可见窗口","Visible window"):t(e,"后台运行","Headless"):t(e,"已关闭","Disabled"),u=a?.chromeInstalled?t(e,"已安装","Installed"):t(e,"未安装","Not installed");return[{label:n,value:l},{label:r,value:d},{label:o,value:u}]}function z(a,e){const n=t(e,"连接地址","Address"),r=t(e,"驱动","Driver"),o=t(e,"服务状态","Service"),l=a?.appiumUrl||"http://127.0.0.1:4723",d=t(e,"Appium Mac2","Appium Mac2"),u=a?a.running?t(e,"运行中","Running"):a.enabled?t(e,"已启用","Enabled"):t(e,"已关闭","Disabled"):t(e,"加载中","Loading");return[{label:n,value:l},{label:r,value:d},{label:o,value:u}]}function L(a,e){return a?a.enabled?a.running?t(e,"独立浏览器已打开,可继续补充登录态。","The managed browser is open and ready for login."):a.status==="ready"?t(e,"已就绪,可在后续会话中直接使用。","Ready for upcoming sessions."):a.status==="chrome_missing"?t(e,"本机未检测到 Chrome。","Chrome was not detected on this machine."):a.detail||t(e,"需要先完成一次浏览器配置。","Setup is required before browser automation can be used."):t(e,"当前不会向 Agent 会话注入 browser MCP。","Browser MCP will not be injected into agent sessions."):t(e,"正在读取浏览器状态。","Loading browser status.")}function T(a,e){return a?a.installed?a.running?t(e,"桌面自动化服务已启动。","The desktop automation service is running."):a.enabled?t(e,"已启用,可在后续会话中直接调用。","Enabled and ready for upcoming sessions."):t(e,"当前不会向 Agent 会话注入桌面自动化能力。","Desktop automation will not be injected into agent sessions."):t(e,"需要先安装 Appium Mac2 驱动。","Appium Mac2 must be installed first."):t(e,"正在读取桌面自动化状态。","Loading desktop automation status.")}function U({onOpenBrowserSetup:a,onOpenDesktopSetup:e}){const n=p(i=>i.locale),r=p(i=>i.toast),o=p(i=>i.state),l=m.useMemo(()=>B(n),[n]),[d,u]=m.useState(null),[M,h]=m.useState(!1),f=m.useCallback(async()=>{h(!0);try{u(await R.getBrowser())}catch(i){r(i instanceof Error?i.message:l("config.applyFailed"),!1)}finally{h(!1)}},[l,r]);m.useEffect(()=>{f()},[f,o]);const c=d?.browser,x=d?.desktop,v=_(d,n,l),j=E(d,n,l),D=V(c,n),A=z(x,n);return s.jsxs("div",{className:"animate-in space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end sm:justify-between",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx("div",{className:"text-[13px] leading-relaxed text-fg-4",children:l("ext.hint")})}),s.jsx(g,{variant:"outline",size:"sm",onClick:()=>{f()},disabled:M,children:l("perm.guideRefresh")})]}),s.jsxs(S,{className:"xl:grid-cols-[minmax(0,235px)_minmax(240px,0.95fr)_minmax(0,1.1fr)_auto]",children:[s.jsx(C,{icon:s.jsx(k,{brand:"playwright",size:22}),title:l("ext.browser"),subtitle:l("ext.browserDesc")}),s.jsxs(b,{label:t(n,"状态","Status"),children:[s.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:s.jsxs(w,{variant:v.variant,children:[!d&&s.jsx(N,{}),v.label]})}),s.jsx("div",{className:"mt-1 text-[13px] leading-relaxed text-fg-3",children:L(c,n)})]}),s.jsx(b,{label:t(n,"当前配置","Current config"),children:s.jsx("div",{className:"space-y-1.5 text-[13px] leading-relaxed text-fg-3",children:D.map(i=>s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"w-16 shrink-0 text-fg-5",children:i.label}),s.jsx("span",{className:"min-w-0 break-words",children:i.value})]},i.label))})}),s.jsx(y,{children:s.jsx(g,{variant:c?.enabled?"outline":"primary",size:"sm",onClick:a,children:c?.enabled?t(n,"管理","Manage"):l("ext.setup")})})]}),s.jsxs(S,{className:"xl:grid-cols-[minmax(0,235px)_minmax(240px,0.95fr)_minmax(0,1.1fr)_auto]",children:[s.jsx(C,{icon:s.jsx(k,{brand:"appium",size:22}),title:l("ext.desktop"),subtitle:l("ext.desktopDesc")}),s.jsxs(b,{label:t(n,"状态","Status"),children:[s.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:s.jsxs(w,{variant:j.variant,children:[!d&&s.jsx(N,{}),j.label]})}),s.jsx("div",{className:"mt-1 text-[13px] leading-relaxed text-fg-3",children:T(x,n)})]}),s.jsx(b,{label:t(n,"当前配置","Current config"),children:s.jsx("div",{className:"space-y-1.5 text-[13px] leading-relaxed text-fg-3",children:A.map(i=>s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"w-16 shrink-0 text-fg-5",children:i.label}),s.jsx("span",{className:/^https?:\/\//.test(i.value)?"min-w-0 break-words font-mono text-[12px]":"min-w-0 break-words",children:i.value})]},i.label))})}),s.jsx(y,{children:s.jsx(g,{variant:x?.enabled?"outline":"primary",size:"sm",onClick:e,children:x?.enabled?t(n,"管理","Manage"):l("ext.setup")})})]})]})}export{U as ExtensionsTab};
@@ -1 +1 @@
1
- import{r as S,j as i}from"./react-vendor-DTcmqLiz.js";import{u as p,l as y,k as v,S as C,B as D}from"./index-BPyYJAu2.js";import{B as A}from"./BrandIcon-DI28YjL9.js";import{a as j,b as V,c as w,d as N}from"./shared-Diw6OFf-.js";import"./router-emLofBBH.js";function L(t){return t==="zh-CN"?{status:"状态",summary:"接入摘要",loading:"加载中",chats:"个 chat",notConnected:"未接入",configuring:"配置中",connected:"已接入",failed:"配置异常",configure:"去配置",continueSetup:"继续配置",viewSettings:"查看设置",noWeixin:"尚未登录微信账号",noTelegram:"未配置 Bot Token",noFeishu:"未配置 App ID 与应用凭证",pendingValidation:"凭证已保存,等待验证。",connectedReady:"机器人已可正常接收消息。",validationFailed:"校验失败,请检查凭证或网络。",accountLinked:"已绑定账号",tokenSaved:"Token 已保存",appCredentialsSaved:"应用凭证已保存",allowedChats:"允许",notConnectedDetail:"尚未配置账号与接入凭证。"}:{status:"Status",summary:"Summary",loading:"Loading",chats:"chats",notConnected:"Not connected",configuring:"Configuring",connected:"Connected",failed:"Needs attention",configure:"Configure",continueSetup:"Continue setup",viewSettings:"View settings",noWeixin:"Weixin account not connected yet",noTelegram:"Bot token not configured",noFeishu:"App ID and credentials not configured",pendingValidation:"Credentials are saved and waiting for validation.",connectedReady:"This channel can receive messages.",validationFailed:"Validation failed. Check credentials or network.",accountLinked:"Account linked",tokenSaved:"Token saved",appCredentialsSaved:"Credentials saved",allowedChats:"Allows",notConnectedDetail:"Account and access credentials have not been configured yet."}}function g(t,e=4,a=4){const s=t.trim();return s?s.length<=e+a+3?s:`${s.slice(0,e)}...${s.slice(-a)}`:""}function B(t){return String(t||"").split(/[\n,;]/).map(e=>e.trim()).filter(Boolean).length}function u(t,e){return String(t?.[e]||"").trim()}function R(t,e){if(!t)return e;try{return new URL(t).host||t}catch{return t}}function h(t,e,a){if(t==="weixin"){const n=u(e,"weixinAccountId"),l=u(e,"weixinBaseUrl");return n?l?`${g(n)} · ${R(l,l)}`:`${a.accountLinked} ${g(n)}`:a.noWeixin}if(t==="telegram"){const n=u(e,"telegramBotToken"),l=B(u(e,"telegramAllowedChatIds"));return n?l>0?`${a.tokenSaved} · ${a.allowedChats} ${l} ${a.chats}`:a.tokenSaved:a.noTelegram}const s=u(e,"feishuAppId"),o=u(e,"feishuAppSecret");return!s||!o?a.noFeishu:`App ID ${g(s)} · ${a.appCredentialsSaved}`}function f(t,e){return!t||!t.configured?{statusLabel:e.notConnected,statusVariant:"muted",statusDescription:t?.detail||e.notConnectedDetail,actionLabel:e.configure}:t.ready?{statusLabel:e.connected,statusVariant:"ok",statusDescription:t.detail||e.connectedReady,actionLabel:e.viewSettings}:y(t)?{statusLabel:e.configuring,statusVariant:"accent",statusDescription:t.detail||e.pendingValidation,actionLabel:e.continueSetup}:{statusLabel:e.failed,statusVariant:"warn",statusDescription:t.detail||e.validationFailed,actionLabel:e.continueSetup}}function $({meta:t,locale:e}){const a=L(e);return i.jsxs(j,{children:[i.jsx(V,{icon:i.jsx(A,{brand:t.key,size:22}),title:t.title,subtitle:t.subtitle}),i.jsxs(w,{label:a.status,children:[i.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:i.jsxs(v,{variant:t.statusVariant,children:[t.loading&&i.jsx(C,{className:"h-3 w-3"}),t.statusLabel]})}),i.jsx("div",{className:"mt-1 text-[13px] leading-relaxed text-fg-3 xl:truncate xl:whitespace-nowrap",title:t.statusDescription,children:t.statusDescription})]}),i.jsx(w,{label:t.summaryLabel,children:i.jsx("div",{className:"break-words text-[13px] leading-relaxed text-fg-3",children:t.summary})}),i.jsx(N,{children:i.jsxs(D,{variant:t.channel?.ready?"outline":"primary",size:"sm",onClick:t.onAction,disabled:t.actionDisabled,children:[t.loading&&i.jsx(C,{className:"h-3 w-3"}),t.actionLabel]})})]})}function M({onOpenWeixin:t,onOpenTelegram:e,onOpenFeishu:a}){const s=p(r=>r.state),o=p(r=>r.locale),n=L(o),l=!s,d=s?.setupState?.channels||[],m=s?.config||{},k=S.useMemo(()=>{const r=d.find(c=>c.channel==="weixin")||null,b=d.find(c=>c.channel==="telegram")||null,x=d.find(c=>c.channel==="feishu")||null;return l?[{key:"weixin",title:"Weixin",subtitle:o==="zh-CN"?"二维码登录与账号接入":"QR login and account routing",channel:null,loading:!0,summary:n.loading,summaryLabel:n.summary,statusLabel:n.loading,statusVariant:"muted",statusDescription:n.loading,actionLabel:n.loading,actionDisabled:!0,onAction:t},{key:"telegram",title:"Telegram",subtitle:o==="zh-CN"?"Bot Token 与 chat allowlist":"Bot token and chat allowlist",channel:null,loading:!0,summary:n.loading,summaryLabel:n.summary,statusLabel:n.loading,statusVariant:"muted",statusDescription:n.loading,actionLabel:n.loading,actionDisabled:!0,onAction:e},{key:"feishu",title:"Feishu",subtitle:o==="zh-CN"?"应用凭证与机器人身份":"App credentials and bot identity",channel:null,loading:!0,summary:n.loading,summaryLabel:n.summary,statusLabel:n.loading,statusVariant:"muted",statusDescription:n.loading,actionLabel:n.loading,actionDisabled:!0,onAction:a}]:[{key:"weixin",title:"Weixin",subtitle:o==="zh-CN"?"二维码登录与账号接入":"QR login and account routing",channel:r,summary:h("weixin",m,n),summaryLabel:n.summary,...f(r,n),actionDisabled:!1,onAction:t},{key:"telegram",title:"Telegram",subtitle:o==="zh-CN"?"Bot Token 与 chat allowlist":"Bot token and chat allowlist",channel:b,summary:h("telegram",m,n),summaryLabel:n.summary,...f(b,n),actionDisabled:!1,onAction:e},{key:"feishu",title:"Feishu",subtitle:o==="zh-CN"?"应用凭证与机器人身份":"App credentials and bot identity",channel:x,summary:h("feishu",m,n),summaryLabel:n.summary,...f(x,n),actionDisabled:!1,onAction:a}]},[d,m,n,l,o,a,e,t]);return i.jsx("div",{className:"animate-in space-y-3",children:k.map(r=>i.jsx($,{meta:r,locale:o},r.key))})}export{M as IMAccessTab};
1
+ import{r as S,j as i}from"./react-vendor-DTcmqLiz.js";import{u as p,l as y,k as v,S as C,B as D}from"./index-D5sKCspB.js";import{B as A}from"./BrandIcon-BoMxvhBf.js";import{a as j,b as V,c as w,d as N}from"./shared-6sWbm5Tj.js";import"./router-emLofBBH.js";function L(t){return t==="zh-CN"?{status:"状态",summary:"接入摘要",loading:"加载中",chats:"个 chat",notConnected:"未接入",configuring:"配置中",connected:"已接入",failed:"配置异常",configure:"去配置",continueSetup:"继续配置",viewSettings:"查看设置",noWeixin:"尚未登录微信账号",noTelegram:"未配置 Bot Token",noFeishu:"未配置 App ID 与应用凭证",pendingValidation:"凭证已保存,等待验证。",connectedReady:"机器人已可正常接收消息。",validationFailed:"校验失败,请检查凭证或网络。",accountLinked:"已绑定账号",tokenSaved:"Token 已保存",appCredentialsSaved:"应用凭证已保存",allowedChats:"允许",notConnectedDetail:"尚未配置账号与接入凭证。"}:{status:"Status",summary:"Summary",loading:"Loading",chats:"chats",notConnected:"Not connected",configuring:"Configuring",connected:"Connected",failed:"Needs attention",configure:"Configure",continueSetup:"Continue setup",viewSettings:"View settings",noWeixin:"Weixin account not connected yet",noTelegram:"Bot token not configured",noFeishu:"App ID and credentials not configured",pendingValidation:"Credentials are saved and waiting for validation.",connectedReady:"This channel can receive messages.",validationFailed:"Validation failed. Check credentials or network.",accountLinked:"Account linked",tokenSaved:"Token saved",appCredentialsSaved:"Credentials saved",allowedChats:"Allows",notConnectedDetail:"Account and access credentials have not been configured yet."}}function g(t,e=4,a=4){const s=t.trim();return s?s.length<=e+a+3?s:`${s.slice(0,e)}...${s.slice(-a)}`:""}function B(t){return String(t||"").split(/[\n,;]/).map(e=>e.trim()).filter(Boolean).length}function u(t,e){return String(t?.[e]||"").trim()}function R(t,e){if(!t)return e;try{return new URL(t).host||t}catch{return t}}function h(t,e,a){if(t==="weixin"){const n=u(e,"weixinAccountId"),l=u(e,"weixinBaseUrl");return n?l?`${g(n)} · ${R(l,l)}`:`${a.accountLinked} ${g(n)}`:a.noWeixin}if(t==="telegram"){const n=u(e,"telegramBotToken"),l=B(u(e,"telegramAllowedChatIds"));return n?l>0?`${a.tokenSaved} · ${a.allowedChats} ${l} ${a.chats}`:a.tokenSaved:a.noTelegram}const s=u(e,"feishuAppId"),o=u(e,"feishuAppSecret");return!s||!o?a.noFeishu:`App ID ${g(s)} · ${a.appCredentialsSaved}`}function f(t,e){return!t||!t.configured?{statusLabel:e.notConnected,statusVariant:"muted",statusDescription:t?.detail||e.notConnectedDetail,actionLabel:e.configure}:t.ready?{statusLabel:e.connected,statusVariant:"ok",statusDescription:t.detail||e.connectedReady,actionLabel:e.viewSettings}:y(t)?{statusLabel:e.configuring,statusVariant:"accent",statusDescription:t.detail||e.pendingValidation,actionLabel:e.continueSetup}:{statusLabel:e.failed,statusVariant:"warn",statusDescription:t.detail||e.validationFailed,actionLabel:e.continueSetup}}function $({meta:t,locale:e}){const a=L(e);return i.jsxs(j,{children:[i.jsx(V,{icon:i.jsx(A,{brand:t.key,size:22}),title:t.title,subtitle:t.subtitle}),i.jsxs(w,{label:a.status,children:[i.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:i.jsxs(v,{variant:t.statusVariant,children:[t.loading&&i.jsx(C,{className:"h-3 w-3"}),t.statusLabel]})}),i.jsx("div",{className:"mt-1 text-[13px] leading-relaxed text-fg-3 xl:truncate xl:whitespace-nowrap",title:t.statusDescription,children:t.statusDescription})]}),i.jsx(w,{label:t.summaryLabel,children:i.jsx("div",{className:"break-words text-[13px] leading-relaxed text-fg-3",children:t.summary})}),i.jsx(N,{children:i.jsxs(D,{variant:t.channel?.ready?"outline":"primary",size:"sm",onClick:t.onAction,disabled:t.actionDisabled,children:[t.loading&&i.jsx(C,{className:"h-3 w-3"}),t.actionLabel]})})]})}function M({onOpenWeixin:t,onOpenTelegram:e,onOpenFeishu:a}){const s=p(r=>r.state),o=p(r=>r.locale),n=L(o),l=!s,d=s?.setupState?.channels||[],m=s?.config||{},k=S.useMemo(()=>{const r=d.find(c=>c.channel==="weixin")||null,b=d.find(c=>c.channel==="telegram")||null,x=d.find(c=>c.channel==="feishu")||null;return l?[{key:"weixin",title:"Weixin",subtitle:o==="zh-CN"?"二维码登录与账号接入":"QR login and account routing",channel:null,loading:!0,summary:n.loading,summaryLabel:n.summary,statusLabel:n.loading,statusVariant:"muted",statusDescription:n.loading,actionLabel:n.loading,actionDisabled:!0,onAction:t},{key:"telegram",title:"Telegram",subtitle:o==="zh-CN"?"Bot Token 与 chat allowlist":"Bot token and chat allowlist",channel:null,loading:!0,summary:n.loading,summaryLabel:n.summary,statusLabel:n.loading,statusVariant:"muted",statusDescription:n.loading,actionLabel:n.loading,actionDisabled:!0,onAction:e},{key:"feishu",title:"Feishu",subtitle:o==="zh-CN"?"应用凭证与机器人身份":"App credentials and bot identity",channel:null,loading:!0,summary:n.loading,summaryLabel:n.summary,statusLabel:n.loading,statusVariant:"muted",statusDescription:n.loading,actionLabel:n.loading,actionDisabled:!0,onAction:a}]:[{key:"weixin",title:"Weixin",subtitle:o==="zh-CN"?"二维码登录与账号接入":"QR login and account routing",channel:r,summary:h("weixin",m,n),summaryLabel:n.summary,...f(r,n),actionDisabled:!1,onAction:t},{key:"telegram",title:"Telegram",subtitle:o==="zh-CN"?"Bot Token 与 chat allowlist":"Bot token and chat allowlist",channel:b,summary:h("telegram",m,n),summaryLabel:n.summary,...f(b,n),actionDisabled:!1,onAction:e},{key:"feishu",title:"Feishu",subtitle:o==="zh-CN"?"应用凭证与机器人身份":"App credentials and bot identity",channel:x,summary:h("feishu",m,n),summaryLabel:n.summary,...f(x,n),actionDisabled:!1,onAction:a}]},[d,m,n,l,o,a,e,t]);return i.jsx("div",{className:"animate-in space-y-3",children:k.map(r=>i.jsx($,{meta:r,locale:o},r.key))})}export{M as IMAccessTab};
@@ -1 +1 @@
1
- import{j as t}from"./react-vendor-DTcmqLiz.js";import{c as r}from"./index-BPyYJAu2.js";function a({className:o,...e}){return t.jsx("input",{className:r("flex h-8 w-full rounded-md border border-edge bg-inset px-2.5 py-1.5 text-[13px] text-fg shadow-sm","transition-[border-color,box-shadow,background] duration-200 outline-none","placeholder:text-fg-5","focus:border-edge-h focus:shadow-[0_0_0_4px_var(--th-glow-a)]",o),...e})}function d({children:o,className:e}){return t.jsx("label",{className:r("mb-2 block text-sm font-medium text-fg-3",e),children:o})}export{a as I,d as L};
1
+ import{j as t}from"./react-vendor-DTcmqLiz.js";import{c as r}from"./index-D5sKCspB.js";function a({className:o,...e}){return t.jsx("input",{className:r("flex h-8 w-full rounded-md border border-edge bg-inset px-2.5 py-1.5 text-[13px] text-fg shadow-sm","transition-[border-color,box-shadow,background] duration-200 outline-none","placeholder:text-fg-5","focus:border-edge-h focus:shadow-[0_0_0_4px_var(--th-glow-a)]",o),...e})}function d({children:o,className:e}){return t.jsx("label",{className:r("mb-2 block text-sm font-medium text-fg-3",e),children:o})}export{a as I,d as L};
@@ -1 +1 @@
1
- import{r as o,j as e}from"./react-vendor-DTcmqLiz.js";import{c as d,B as c}from"./index-BPyYJAu2.js";function h({open:t,onClose:a,wide:r,panelStyle:i,children:n}){return o.useEffect(()=>{if(!t)return;const s=l=>{l.key==="Escape"&&a()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[t,a]),t?e.jsxs("div",{className:"fixed inset-0 z-100 flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 backdrop-blur-[10px] backdrop-saturate-125",style:{background:"linear-gradient(180deg, color-mix(in oklab, var(--th-overlay) 68%, transparent), color-mix(in oklab, var(--th-overlay) 92%, transparent))"},onClick:a}),e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{background:"radial-gradient(circle at center, color-mix(in oklab, white 12%, transparent), transparent 38%)"}}),e.jsx("div",{className:d("glass-strong relative max-h-[min(88vh,860px)] w-full overflow-hidden rounded-xl border border-edge-h shadow-[0_32px_96px_rgba(2,6,23,0.28),0_8px_24px_rgba(15,23,42,0.08)] animate-scale",r?"max-w-[720px]":"max-w-[480px]"),style:{...i,background:"linear-gradient(180deg, color-mix(in oklab, var(--th-modal-bg) 90%, white 10%), color-mix(in oklab, var(--th-modal-bg) 97%, white 3%))"},children:e.jsx("div",{className:"max-h-[inherit] overflow-y-auto p-6",children:n})})]}):null}function v({title:t,description:a,onClose:r}){return e.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-base font-semibold tracking-tight text-fg",children:t}),a&&e.jsx("div",{className:"mt-1 text-sm leading-relaxed text-fg-4",children:a})]}),e.jsx(c,{variant:"ghost",size:"icon",onClick:r,className:"-mr-1 -mt-1 h-8 w-8 shrink-0",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})}export{h as M,v as a};
1
+ import{r as o,j as e}from"./react-vendor-DTcmqLiz.js";import{c as d,B as c}from"./index-D5sKCspB.js";function h({open:t,onClose:a,wide:r,panelStyle:i,children:n}){return o.useEffect(()=>{if(!t)return;const s=l=>{l.key==="Escape"&&a()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[t,a]),t?e.jsxs("div",{className:"fixed inset-0 z-100 flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 backdrop-blur-[10px] backdrop-saturate-125",style:{background:"linear-gradient(180deg, color-mix(in oklab, var(--th-overlay) 68%, transparent), color-mix(in oklab, var(--th-overlay) 92%, transparent))"},onClick:a}),e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{background:"radial-gradient(circle at center, color-mix(in oklab, white 12%, transparent), transparent 38%)"}}),e.jsx("div",{className:d("glass-strong relative max-h-[min(88vh,860px)] w-full overflow-hidden rounded-xl border border-edge-h shadow-[0_32px_96px_rgba(2,6,23,0.28),0_8px_24px_rgba(15,23,42,0.08)] animate-scale",r?"max-w-[720px]":"max-w-[480px]"),style:{...i,background:"linear-gradient(180deg, color-mix(in oklab, var(--th-modal-bg) 90%, white 10%), color-mix(in oklab, var(--th-modal-bg) 97%, white 3%))"},children:e.jsx("div",{className:"max-h-[inherit] overflow-y-auto p-6",children:n})})]}):null}function v({title:t,description:a,onClose:r}){return e.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-base font-semibold tracking-tight text-fg",children:t}),a&&e.jsx("div",{className:"mt-1 text-sm leading-relaxed text-fg-4",children:a})]}),e.jsx(c,{variant:"ghost",size:"icon",onClick:r,className:"-mr-1 -mt-1 h-8 w-8 shrink-0",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})}export{h as M,v as a};
@@ -1 +1 @@
1
- import{r as a,j as e}from"./react-vendor-DTcmqLiz.js";import{u as S,b as U,B as I,a as C,k as K}from"./index-BPyYJAu2.js";import{L as M,I as R}from"./Input-BzRdrrQl.js";import{M as A,a as L}from"./Modal-BWEFrRB_.js";import{D as X}from"./DirBrowser-B1ZrMmei.js";import"./router-emLofBBH.js";const P="https://ilinkai.weixin.qq.com";function Q(d){return d instanceof Error&&(d.name==="AbortError"||/aborted/i.test(d.message))}function H(d,p){return d instanceof Error&&/timed out/i.test(d.message)?p("modal.requestTimeout"):p("modal.networkError")}function ae({open:d,onClose:p}){const y=S(o=>o.state),c=S(o=>o.toast),B=S(o=>o.reloadUntil),t=S(o=>o.locale),s=a.useMemo(()=>U(t),[t]),[u,v]=a.useState(""),[b,h]=a.useState(""),[w,j]=a.useState(!1),[k,i]=a.useState(!1),[f,r]=a.useState(null),n=a.useRef(null),F=a.useRef(y);F.current=y,a.useEffect(()=>{d?(v(F.current?.config.telegramBotToken||""),h(F.current?.config.telegramAllowedChatIds||""),j(!1),r(null)):(n.current?.abort(),n.current=null,i(!1))},[d]),a.useEffect(()=>()=>{n.current?.abort(),n.current=null},[]);const m=async()=>{if(!u.trim()){c(s("modal.inputToken"),!1);return}n.current?.abort();const o=new AbortController;n.current=o,i(!0),r(null);let x=!1;try{const N=await C.validateTelegramConfig(u.trim(),b.trim(),{signal:o.signal,timeoutMs:12e3});if(!N.ok){r({ok:!1,text:"✗ "+(N.error||s("modal.validationFailed"))});return}const l=N.normalizedAllowedChatIds??b.trim();r({ok:!0,text:"✓ @"+(N.bot?.username||"bot")+(N.bot?.displayName?" ("+N.bot.displayName+")":"")});const g=new Set((y?.setupState?.channels||[]).filter(D=>(D.ready||D.configured)&&D.channel!=="telegram").map(D=>D.channel));if(g.add("telegram"),await C.saveConfig({telegramBotToken:u.trim(),telegramAllowedChatIds:l,channels:[...g]}),!await B(D=>{const q=D.setupState?.channels?.find(z=>z.channel==="telegram");return D.config.telegramBotToken===u.trim()&&(D.config.telegramAllowedChatIds||"")===l&&!!q?.ready},{attempts:10,intervalMs:350})){r({ok:!1,text:"✗ "+s("modal.refreshStateFailed")}),c(s("modal.refreshStateFailed"),!1);return}c(s("modal.tgSaved")),x=!0}catch(N){if(Q(N))return;const l=H(N,s);r({ok:!1,text:"✗ "+l}),c(l,!1)}finally{n.current===o&&(n.current=null),i(!1),x&&p()}},T=()=>{n.current?.abort(),n.current=null,p()};return e.jsxs(A,{open:d,onClose:T,children:[e.jsx(L,{title:s("modal.configureTelegram"),onClose:T}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(M,{children:s("modal.botToken")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(R,{type:w?"text":"password",className:"flex-1 font-mono text-xs",placeholder:s("modal.pasteToken"),value:u,onChange:o=>v(o.target.value)}),e.jsx(I,{variant:"ghost",size:"sm",className:"!w-[34px] !p-0",onClick:()=>j(!w),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[e.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})})]})]}),f&&e.jsx("div",{className:"text-xs",style:{color:f.ok?"var(--th-ok)":"var(--th-err)"},children:f.text}),e.jsxs("div",{children:[e.jsxs(M,{children:[s("modal.allowedIds")," ",e.jsxs("span",{className:"text-fg-5",children:["(",s("modal.optional"),")"]})]}),e.jsx(R,{className:"font-mono text-xs",placeholder:s("modal.commaSep"),value:b,onChange:o=>h(o.target.value)})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-6",children:[e.jsx(I,{variant:"ghost",onClick:T,children:s("modal.cancel")}),e.jsx(I,{variant:"primary",disabled:k,onClick:m,children:s(k?"modal.validating":"modal.validateSave")})]})]})}function le({open:d,onClose:p}){const y=S(m=>m.state),c=S(m=>m.toast),B=S(m=>m.reloadUntil),t=S(m=>m.locale),s=a.useMemo(()=>U(t),[t]),[u,v]=a.useState(""),[b,h]=a.useState(""),[w,j]=a.useState(!1),[k,i]=a.useState(null),f=a.useRef(null),r=a.useRef(y);r.current=y,a.useEffect(()=>{d?(v(r.current?.config.feishuAppId||""),h(r.current?.config.feishuAppSecret||""),i(null)):(f.current?.abort(),f.current=null,j(!1))},[d]),a.useEffect(()=>()=>{f.current?.abort(),f.current=null},[]);const n=async()=>{if(!u.trim()){c(s("modal.inputAppId"),!1);return}f.current?.abort();const m=new AbortController;f.current=m,j(!0),i(null);let T=!1;try{const o=await C.validateFeishuConfig(u.trim(),b.trim(),{signal:m.signal,timeoutMs:2e4});if(!o.ok){i({ok:!1,text:"✗ "+(o.error||s("modal.validationFailed"))});return}i({ok:!0,text:"✓ "+(o.app?.displayName||o.app?.appId||u.trim())});const x=new Set((y?.setupState?.channels||[]).filter(l=>(l.ready||l.configured)&&l.channel!=="feishu").map(l=>l.channel));if(x.add("feishu"),await C.saveConfig({feishuAppId:u.trim(),feishuAppSecret:b.trim(),channels:[...x]}),!await B(l=>{const g=l.setupState?.channels?.find(W=>W.channel==="feishu");return l.config.feishuAppId===u.trim()&&l.config.feishuAppSecret===b.trim()&&!!g?.ready},{attempts:10,intervalMs:350})){i({ok:!1,text:"✗ "+s("modal.refreshStateFailed")}),c(s("modal.refreshStateFailed"),!1);return}c(s("modal.feishuSaved")),T=!0}catch(o){if(Q(o))return;const x=H(o,s);i({ok:!1,text:"✗ "+x}),c(x,!1)}finally{f.current===m&&(f.current=null),j(!1),T&&p()}},F=()=>{f.current?.abort(),f.current=null,p()};return e.jsxs(A,{open:d,onClose:F,children:[e.jsx(L,{title:s("modal.configureFeishu"),onClose:F}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(M,{children:s("modal.appId")}),e.jsx(R,{className:"font-mono text-xs",placeholder:s("modal.feishuPlaceholder"),value:u,onChange:m=>v(m.target.value)})]}),e.jsxs("div",{children:[e.jsx(M,{children:s("modal.appSecret")}),e.jsx(R,{type:"password",className:"font-mono text-xs",placeholder:s("modal.appSecret"),value:b,onChange:m=>h(m.target.value)})]}),k&&e.jsx("div",{className:"text-xs",style:{color:k.ok?"var(--th-ok)":"var(--th-err)"},children:k.text})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-6",children:[e.jsx(I,{variant:"ghost",onClick:F,children:s("modal.cancel")}),e.jsx(I,{variant:"primary",disabled:w,onClick:n,children:s(w?"modal.validating":"modal.validateSave")})]})]})}function re({open:d,onClose:p}){const y=S(x=>x.state),c=S(x=>x.toast),B=S(x=>x.reloadUntil),t=S(x=>x.locale),s=a.useMemo(()=>U(t),[t]),[u,v]=a.useState(P),[b,h]=a.useState(!1),[w,j]=a.useState(""),[k,i]=a.useState(""),[f,r]=a.useState(null),n=a.useRef(null),F=a.useRef(y);F.current=y,a.useEffect(()=>{d?(v(F.current?.config.weixinBaseUrl||P),h(!1),j(""),i(""),r(null)):(n.current?.abort(),n.current=null,h(!1))},[d]),a.useEffect(()=>()=>{n.current?.abort(),n.current=null},[]);const m=()=>{n.current?.abort(),n.current=null,p()},T=a.useCallback(async(x,N,l)=>{for(;!x.signal.aborted;){const g=await C.waitWeixinLogin(N,l,{signal:x.signal,timeoutMs:45e3});if(!g.ok&&!g.connected)return r({ok:!1,text:"✗ "+(g.error||g.message||s("modal.validationFailed"))}),!1;if(g.qrcodeUrl&&j(g.qrcodeUrl),g.status==="scaned"?r({ok:!0,text:s("modal.weixinScanned")}):g.status==="expired"?r({ok:!0,text:s("modal.weixinQrRefreshed")}):g.connected||r({ok:!0,text:s("modal.weixinWaitingScan")}),!g.connected)continue;r({ok:!0,text:s("modal.weixinLoginSuccess")});const W=g.baseUrl||l,D=g.botToken||"",q=g.accountId||"",z=await C.validateWeixinConfig(W,D,q,{signal:x.signal,timeoutMs:12e3});if(!z.ok)return r({ok:!1,text:"✗ "+(z.error||s("modal.validationFailed"))}),!1;const _=z.normalizedBaseUrl||W,G=new Set((F.current?.setupState?.channels||[]).filter(E=>(E.ready||E.configured)&&E.channel!=="weixin").map(E=>E.channel));return G.add("weixin"),await C.saveConfig({weixinBaseUrl:_,weixinBotToken:D,weixinAccountId:q,channels:[...G]}),await B(E=>{const O=E.setupState?.channels?.find(V=>V.channel==="weixin");return E.config.weixinBaseUrl===_&&E.config.weixinBotToken===D&&E.config.weixinAccountId===q&&!!O?.ready},{attempts:12,intervalMs:350})?(c(s("modal.weixinSaved")),!0):(r({ok:!1,text:"✗ "+s("modal.refreshStateFailed")}),c(s("modal.refreshStateFailed"),!1),!1)}return!1},[B,s,c]),o=async()=>{if(!u.trim()){c(s("modal.inputWeixinBaseUrl"),!1);return}n.current?.abort();const x=new AbortController;n.current=x,h(!0),j(""),i(""),r(null);let N=!1;try{const l=await C.startWeixinLogin(u.trim(),{signal:x.signal,timeoutMs:12e3});if(!l.ok||!l.qrcodeUrl){r({ok:!1,text:"✗ "+(l.error||l.message||s("modal.validationFailed"))});return}j(l.qrcodeUrl),i(l.sessionKey),r({ok:!0,text:s("modal.weixinWaitingScan")}),N=await T(x,l.sessionKey,u.trim())}catch(l){if(Q(l))return;const g=H(l,s);r({ok:!1,text:"✗ "+g}),c(g,!1)}finally{n.current===x&&(n.current=null),h(!1),N&&p()}};return e.jsxs(A,{open:d,onClose:m,children:[e.jsx(L,{title:s("modal.configureWeixin"),onClose:m}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"text-xs leading-relaxed text-fg-4",children:s("modal.weixinScanHint")}),e.jsxs("div",{children:[e.jsx(M,{children:s("modal.weixinBaseUrl")}),e.jsx(R,{className:"font-mono text-xs",value:u,onChange:x=>v(x.target.value),placeholder:P}),e.jsx("div",{className:"mt-1 text-[11px] text-fg-5",children:s("modal.weixinDefaultBaseUrlHint")})]}),w&&e.jsxs("div",{className:"rounded-xl border border-edge bg-panel-alt p-4",children:[e.jsx("img",{src:w,alt:s("modal.weixinQrAlt"),className:"mx-auto h-56 w-56 rounded-lg bg-white p-3 object-contain"}),k&&e.jsx("div",{className:"mt-2 truncate text-center font-mono text-[10px] text-fg-5",children:k})]}),f&&e.jsx("div",{className:"text-xs",style:{color:f.ok?"var(--th-ok)":"var(--th-err)"},children:f.text})]}),e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx(I,{variant:"ghost",onClick:m,children:s("modal.cancel")}),e.jsx(I,{variant:"primary",disabled:b,onClick:o,children:s(b?w?"modal.validating":"modal.weixinGeneratingQr":w?"modal.weixinRetry":"modal.weixinGenerateQr")})]})]})}function ne({open:d,onClose:p}){const y=S(r=>r.state),c=S(r=>r.toast),B=S(r=>r.reload),t=S(r=>r.locale),s=a.useMemo(()=>U(t),[t]),u=y?.bot?.workdir||y?.runtimeWorkdir||"",[v,b]=a.useState(""),[h,w]=a.useState(!1),[j,k]=a.useState(0);a.useEffect(()=>{d&&(b(u),k(r=>r+1))},[d,u]);const i=a.useCallback(r=>{b(r)},[]),f=async()=>{const r=v.trim();if(!r){c(s("modal.selectDirFirst"),!1);return}w(!0);try{const n=await C.switchWorkdir(r);n.ok?(c(s("modal.switchedTo")+n.workdir),p(),setTimeout(B,300)):c(n.error||s("modal.switchFailed"),!1)}catch{c(s("modal.switchFailed"),!1)}finally{w(!1)}};return e.jsxs(A,{open:d,onClose:p,panelStyle:{width:"min(500px, calc(100vw - 2rem))",maxWidth:"min(500px, calc(100vw - 2rem))"},children:[e.jsx(L,{title:s("modal.switchWorkdir"),onClose:p}),e.jsx(X,{initialPath:u,onSelect:i,t:s},j),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(I,{variant:"ghost",onClick:p,disabled:h,children:s("modal.cancel")}),e.jsx(I,{variant:"primary",onClick:f,disabled:h,children:s(h?"status.loading":"modal.selectDir")})]})]})}function oe({open:d,onClose:p,onSaved:y}){const c=S(l=>l.toast),B=S(l=>l.locale),t=a.useMemo(()=>U(B),[B]),[s,u]=a.useState(null),[v,b]=a.useState(!1),[h,w]=a.useState(!1),[j,k]=a.useState(null);a.useEffect(()=>{d&&(b(!1),k(null),C.getBrowser().then(l=>{u(l),w(!!l.browser.enabled)}).catch(()=>u(null)))},[d]);const i=s?.browser,f=!!i?.enabled,r=!!i&&f!==h,n=i?.profileDir||"",F=t("ext.profileDir"),m=n,T=!!i?.chromeInstalled&&!!i?.profileCreated,o=s?i?.enabled?T?t("ext.browserReady"):i?.chromeInstalled?t("ext.chromeInstalled"):t("ext.needsSetup"):t("ext.disabled"):t("status.loading"),x=s&&i?.enabled?T?"ok":i?.chromeInstalled?"warn":"err":"muted",N=async()=>{b(!0),k(null);try{await C.saveConfig({browserEnabled:h});const l=await C.getBrowser();u(l),y?.()}catch{k({ok:!1,text:"✗ "+t("ext.browserModeSaveFailed")}),c(t("ext.browserModeSaveFailed"),!1),b(!1);return}if(!h){k({ok:!0,text:"✓ "+t("ext.browserDisabledSaved")}),c(t("ext.browserDisabledSaved")),b(!1);return}try{const l=await C.setupBrowser();if(!l.ok){k({ok:!1,text:"✗ "+(l.error||t("ext.browserLaunchFailed"))}),c(l.error||t("ext.browserLaunchFailed"),!1);return}u(g=>g?{...g,browser:l.browser}:{browser:l.browser,desktop:{enabled:!1,installed:!1,running:!1,appiumUrl:""}}),k({ok:!0,text:"✓ "+t("ext.browserEnabledLaunched")}),c(t("ext.browserEnabledLaunched")),y?.()}catch{k({ok:!1,text:"✗ "+t("ext.browserLaunchFailed")}),c(t("ext.browserLaunchFailed"),!1)}finally{b(!1)}};return e.jsxs(A,{open:d,onClose:p,children:[e.jsx(L,{title:t("ext.setupBrowser"),description:t("ext.setupBrowserDesc"),onClose:p}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"rounded-lg border border-edge bg-panel-alt p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(K,{variant:x,children:o}),i&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:f?"accent":"muted",children:t(f?"ext.enabled":"ext.disabled")}),r&&e.jsx(K,{variant:"warn",children:t("ext.pendingModeChange")}),i.running&&e.jsxs(K,{variant:"accent",children:[t("ext.browserOpen"),i.pid?` · PID ${i.pid}`:""]})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx(M,{children:F}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{className:"font-mono text-xs flex-1",value:m||"—",readOnly:!0,onClick:l=>l.target.select()}),e.jsx(I,{variant:"outline",size:"sm",disabled:!m,onClick:()=>{m&&(navigator.clipboard.writeText(m),c(t("ext.step2Copied")))},children:t("ext.copyPath")})]})]}),e.jsx("div",{className:"mt-3 text-xs text-fg-5",children:t(h?"ext.profileModeDesc":"ext.browserDescDisabled")}),i?.detail&&e.jsx("div",{className:"mt-2 text-xs text-fg-5",children:i.detail}),j&&e.jsx("div",{className:"mt-3 text-xs",style:{color:j.ok?"var(--th-ok)":"var(--th-err)"},children:j.text})]}),e.jsx("div",{className:"rounded-lg border border-edge bg-panel-alt p-4",children:e.jsxs("label",{className:"flex cursor-pointer items-start gap-3",children:[e.jsx("input",{type:"checkbox",checked:h,onChange:l=>w(l.target.checked),className:"mt-0.5 h-4 w-4 rounded border border-edge bg-inset"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-fg-2 mb-1",children:t("ext.browserEnableToggle")}),e.jsx("div",{className:"text-xs text-fg-4",children:t("ext.browserEnableToggleDesc")})]})]})}),e.jsxs("div",{className:"rounded-lg border border-edge bg-panel-alt p-4",children:[e.jsx("div",{className:"text-sm font-medium text-fg-2 mb-1",children:t(h?"ext.step2Title":"ext.browserDisabledStepTitle")}),e.jsx("div",{className:"text-xs text-fg-4",children:t(h?"ext.step2Desc":"ext.browserDisabledHint")})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-6",children:[e.jsx(I,{variant:"ghost",onClick:p,children:t("modal.cancel")}),e.jsx(I,{variant:"primary",disabled:v,onClick:N,children:t(v?"ext.launching":h?"ext.enableAndLaunchBrowser":"ext.saveBrowserDisabled")})]})]})}function ie({open:d,onClose:p,onSaved:y}){const c=S(o=>o.toast),B=S(o=>o.locale),t=a.useMemo(()=>U(B),[B]),[s,u]=a.useState(!1),[v,b]=a.useState(!1),[h,w]=a.useState(!1),[j,k]=a.useState(!1),[i,f]=a.useState(!1),[r,n]=a.useState(null);a.useEffect(()=>{d&&(u(!1),k(!1),f(!1),n(null),C.getBrowser().then(o=>{b(o.desktop.installed),w(o.desktop.enabled)}).catch(()=>{}))},[d]);const F=async()=>{u(!0),n(null);try{const o=await C.desktopInstall();o.ok?(b(!0),n({ok:!0,text:"✓ "+t("ext.desktopInstalled")}),c(t("ext.desktopInstalled"))):n({ok:!1,text:"✗ "+(o.error||t("ext.desktopInstallFailed"))})}catch{n({ok:!1,text:"✗ "+t("ext.desktopInstallFailed")})}finally{u(!1)}},m=async()=>{k(!0),n(null);try{const o=await C.desktopToggle(!0);o.ok?(w(!0),n({ok:!0,text:"✓ "+t("ext.desktopStarted")}),c(t("ext.desktopStarted")),y?.()):n({ok:!1,text:"✗ "+(o.error||t("ext.desktopInstallFailed"))})}catch{n({ok:!1,text:"✗ "+t("ext.desktopInstallFailed")})}finally{k(!1)}},T=async()=>{f(!0),n(null);try{const o=await C.desktopToggle(!1);o.ok?(w(!1),n({ok:!0,text:"✓ "+t("ext.desktopStopped")}),c(t("ext.desktopStopped")),y?.()):n({ok:!1,text:"✗ "+(o.error||t("ext.desktopInstallFailed"))})}catch{n({ok:!1,text:"✗ "+t("ext.desktopInstallFailed")})}finally{f(!1)}};return e.jsxs(A,{open:d,onClose:p,children:[e.jsx(L,{title:t("ext.setupDesktop"),description:t("ext.setupDesktopDesc"),onClose:p}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"rounded-lg border border-edge bg-panel-alt p-4",children:[e.jsx("div",{className:"text-sm font-medium text-fg-2 mb-1",children:t("ext.desktopStep1Title")}),e.jsx("div",{className:"text-xs text-fg-4 mb-3",children:t("ext.desktopStep1Desc")}),r&&!v&&e.jsx("div",{className:"mb-2 text-xs",style:{color:r.ok?"var(--th-ok)":"var(--th-err)"},children:r.text}),e.jsx(I,{variant:v?"ghost":"outline",size:"sm",disabled:s||v,onClick:F,children:t(s?"ext.desktopInstalling":v?"ext.desktopStep1Done":"ext.desktopStep1Action")})]}),e.jsxs("div",{className:"rounded-lg border border-edge bg-panel-alt p-4",children:[e.jsx("div",{className:"text-sm font-medium text-fg-2 mb-1",children:t("ext.desktopStep2Title")}),e.jsx("div",{className:"text-xs text-fg-4 mb-3",children:t("ext.desktopStep2Desc")}),r&&v&&e.jsx("div",{className:"mb-2 text-xs",style:{color:r.ok?"var(--th-ok)":"var(--th-err)"},children:r.text}),e.jsx("div",{className:"flex items-center gap-2",children:h?e.jsx(I,{variant:"outline",size:"sm",disabled:i,onClick:T,children:t(i?"ext.desktopStopping":"ext.disable")}):e.jsx(I,{variant:"primary",size:"sm",disabled:!v||j,onClick:m,children:t(j?"ext.desktopStarting":"ext.desktopStep2Action")})})]})]}),e.jsx("div",{className:"flex justify-end gap-2 mt-6",children:e.jsx(I,{variant:"ghost",onClick:p,children:t("modal.cancel")})})]})}export{oe as BrowserSetupModal,ie as DesktopSetupModal,le as FeishuModal,ae as TelegramModal,re as WeixinModal,ne as WorkdirModal};
1
+ import{r as a,j as e}from"./react-vendor-DTcmqLiz.js";import{u as S,b as U,B as I,a as C,k as K}from"./index-D5sKCspB.js";import{L as M,I as R}from"./Input-DJydTgbG.js";import{M as A,a as L}from"./Modal-CtsiLdVr.js";import{D as X}from"./DirBrowser-B9mMMFZi.js";import"./router-emLofBBH.js";const P="https://ilinkai.weixin.qq.com";function Q(d){return d instanceof Error&&(d.name==="AbortError"||/aborted/i.test(d.message))}function H(d,p){return d instanceof Error&&/timed out/i.test(d.message)?p("modal.requestTimeout"):p("modal.networkError")}function ae({open:d,onClose:p}){const y=S(o=>o.state),c=S(o=>o.toast),B=S(o=>o.reloadUntil),t=S(o=>o.locale),s=a.useMemo(()=>U(t),[t]),[u,v]=a.useState(""),[b,h]=a.useState(""),[w,j]=a.useState(!1),[k,i]=a.useState(!1),[f,r]=a.useState(null),n=a.useRef(null),F=a.useRef(y);F.current=y,a.useEffect(()=>{d?(v(F.current?.config.telegramBotToken||""),h(F.current?.config.telegramAllowedChatIds||""),j(!1),r(null)):(n.current?.abort(),n.current=null,i(!1))},[d]),a.useEffect(()=>()=>{n.current?.abort(),n.current=null},[]);const m=async()=>{if(!u.trim()){c(s("modal.inputToken"),!1);return}n.current?.abort();const o=new AbortController;n.current=o,i(!0),r(null);let x=!1;try{const N=await C.validateTelegramConfig(u.trim(),b.trim(),{signal:o.signal,timeoutMs:12e3});if(!N.ok){r({ok:!1,text:"✗ "+(N.error||s("modal.validationFailed"))});return}const l=N.normalizedAllowedChatIds??b.trim();r({ok:!0,text:"✓ @"+(N.bot?.username||"bot")+(N.bot?.displayName?" ("+N.bot.displayName+")":"")});const g=new Set((y?.setupState?.channels||[]).filter(D=>(D.ready||D.configured)&&D.channel!=="telegram").map(D=>D.channel));if(g.add("telegram"),await C.saveConfig({telegramBotToken:u.trim(),telegramAllowedChatIds:l,channels:[...g]}),!await B(D=>{const q=D.setupState?.channels?.find(z=>z.channel==="telegram");return D.config.telegramBotToken===u.trim()&&(D.config.telegramAllowedChatIds||"")===l&&!!q?.ready},{attempts:10,intervalMs:350})){r({ok:!1,text:"✗ "+s("modal.refreshStateFailed")}),c(s("modal.refreshStateFailed"),!1);return}c(s("modal.tgSaved")),x=!0}catch(N){if(Q(N))return;const l=H(N,s);r({ok:!1,text:"✗ "+l}),c(l,!1)}finally{n.current===o&&(n.current=null),i(!1),x&&p()}},T=()=>{n.current?.abort(),n.current=null,p()};return e.jsxs(A,{open:d,onClose:T,children:[e.jsx(L,{title:s("modal.configureTelegram"),onClose:T}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(M,{children:s("modal.botToken")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(R,{type:w?"text":"password",className:"flex-1 font-mono text-xs",placeholder:s("modal.pasteToken"),value:u,onChange:o=>v(o.target.value)}),e.jsx(I,{variant:"ghost",size:"sm",className:"!w-[34px] !p-0",onClick:()=>j(!w),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[e.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})})]})]}),f&&e.jsx("div",{className:"text-xs",style:{color:f.ok?"var(--th-ok)":"var(--th-err)"},children:f.text}),e.jsxs("div",{children:[e.jsxs(M,{children:[s("modal.allowedIds")," ",e.jsxs("span",{className:"text-fg-5",children:["(",s("modal.optional"),")"]})]}),e.jsx(R,{className:"font-mono text-xs",placeholder:s("modal.commaSep"),value:b,onChange:o=>h(o.target.value)})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-6",children:[e.jsx(I,{variant:"ghost",onClick:T,children:s("modal.cancel")}),e.jsx(I,{variant:"primary",disabled:k,onClick:m,children:s(k?"modal.validating":"modal.validateSave")})]})]})}function le({open:d,onClose:p}){const y=S(m=>m.state),c=S(m=>m.toast),B=S(m=>m.reloadUntil),t=S(m=>m.locale),s=a.useMemo(()=>U(t),[t]),[u,v]=a.useState(""),[b,h]=a.useState(""),[w,j]=a.useState(!1),[k,i]=a.useState(null),f=a.useRef(null),r=a.useRef(y);r.current=y,a.useEffect(()=>{d?(v(r.current?.config.feishuAppId||""),h(r.current?.config.feishuAppSecret||""),i(null)):(f.current?.abort(),f.current=null,j(!1))},[d]),a.useEffect(()=>()=>{f.current?.abort(),f.current=null},[]);const n=async()=>{if(!u.trim()){c(s("modal.inputAppId"),!1);return}f.current?.abort();const m=new AbortController;f.current=m,j(!0),i(null);let T=!1;try{const o=await C.validateFeishuConfig(u.trim(),b.trim(),{signal:m.signal,timeoutMs:2e4});if(!o.ok){i({ok:!1,text:"✗ "+(o.error||s("modal.validationFailed"))});return}i({ok:!0,text:"✓ "+(o.app?.displayName||o.app?.appId||u.trim())});const x=new Set((y?.setupState?.channels||[]).filter(l=>(l.ready||l.configured)&&l.channel!=="feishu").map(l=>l.channel));if(x.add("feishu"),await C.saveConfig({feishuAppId:u.trim(),feishuAppSecret:b.trim(),channels:[...x]}),!await B(l=>{const g=l.setupState?.channels?.find(W=>W.channel==="feishu");return l.config.feishuAppId===u.trim()&&l.config.feishuAppSecret===b.trim()&&!!g?.ready},{attempts:10,intervalMs:350})){i({ok:!1,text:"✗ "+s("modal.refreshStateFailed")}),c(s("modal.refreshStateFailed"),!1);return}c(s("modal.feishuSaved")),T=!0}catch(o){if(Q(o))return;const x=H(o,s);i({ok:!1,text:"✗ "+x}),c(x,!1)}finally{f.current===m&&(f.current=null),j(!1),T&&p()}},F=()=>{f.current?.abort(),f.current=null,p()};return e.jsxs(A,{open:d,onClose:F,children:[e.jsx(L,{title:s("modal.configureFeishu"),onClose:F}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(M,{children:s("modal.appId")}),e.jsx(R,{className:"font-mono text-xs",placeholder:s("modal.feishuPlaceholder"),value:u,onChange:m=>v(m.target.value)})]}),e.jsxs("div",{children:[e.jsx(M,{children:s("modal.appSecret")}),e.jsx(R,{type:"password",className:"font-mono text-xs",placeholder:s("modal.appSecret"),value:b,onChange:m=>h(m.target.value)})]}),k&&e.jsx("div",{className:"text-xs",style:{color:k.ok?"var(--th-ok)":"var(--th-err)"},children:k.text})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-6",children:[e.jsx(I,{variant:"ghost",onClick:F,children:s("modal.cancel")}),e.jsx(I,{variant:"primary",disabled:w,onClick:n,children:s(w?"modal.validating":"modal.validateSave")})]})]})}function re({open:d,onClose:p}){const y=S(x=>x.state),c=S(x=>x.toast),B=S(x=>x.reloadUntil),t=S(x=>x.locale),s=a.useMemo(()=>U(t),[t]),[u,v]=a.useState(P),[b,h]=a.useState(!1),[w,j]=a.useState(""),[k,i]=a.useState(""),[f,r]=a.useState(null),n=a.useRef(null),F=a.useRef(y);F.current=y,a.useEffect(()=>{d?(v(F.current?.config.weixinBaseUrl||P),h(!1),j(""),i(""),r(null)):(n.current?.abort(),n.current=null,h(!1))},[d]),a.useEffect(()=>()=>{n.current?.abort(),n.current=null},[]);const m=()=>{n.current?.abort(),n.current=null,p()},T=a.useCallback(async(x,N,l)=>{for(;!x.signal.aborted;){const g=await C.waitWeixinLogin(N,l,{signal:x.signal,timeoutMs:45e3});if(!g.ok&&!g.connected)return r({ok:!1,text:"✗ "+(g.error||g.message||s("modal.validationFailed"))}),!1;if(g.qrcodeUrl&&j(g.qrcodeUrl),g.status==="scaned"?r({ok:!0,text:s("modal.weixinScanned")}):g.status==="expired"?r({ok:!0,text:s("modal.weixinQrRefreshed")}):g.connected||r({ok:!0,text:s("modal.weixinWaitingScan")}),!g.connected)continue;r({ok:!0,text:s("modal.weixinLoginSuccess")});const W=g.baseUrl||l,D=g.botToken||"",q=g.accountId||"",z=await C.validateWeixinConfig(W,D,q,{signal:x.signal,timeoutMs:12e3});if(!z.ok)return r({ok:!1,text:"✗ "+(z.error||s("modal.validationFailed"))}),!1;const _=z.normalizedBaseUrl||W,G=new Set((F.current?.setupState?.channels||[]).filter(E=>(E.ready||E.configured)&&E.channel!=="weixin").map(E=>E.channel));return G.add("weixin"),await C.saveConfig({weixinBaseUrl:_,weixinBotToken:D,weixinAccountId:q,channels:[...G]}),await B(E=>{const O=E.setupState?.channels?.find(V=>V.channel==="weixin");return E.config.weixinBaseUrl===_&&E.config.weixinBotToken===D&&E.config.weixinAccountId===q&&!!O?.ready},{attempts:12,intervalMs:350})?(c(s("modal.weixinSaved")),!0):(r({ok:!1,text:"✗ "+s("modal.refreshStateFailed")}),c(s("modal.refreshStateFailed"),!1),!1)}return!1},[B,s,c]),o=async()=>{if(!u.trim()){c(s("modal.inputWeixinBaseUrl"),!1);return}n.current?.abort();const x=new AbortController;n.current=x,h(!0),j(""),i(""),r(null);let N=!1;try{const l=await C.startWeixinLogin(u.trim(),{signal:x.signal,timeoutMs:12e3});if(!l.ok||!l.qrcodeUrl){r({ok:!1,text:"✗ "+(l.error||l.message||s("modal.validationFailed"))});return}j(l.qrcodeUrl),i(l.sessionKey),r({ok:!0,text:s("modal.weixinWaitingScan")}),N=await T(x,l.sessionKey,u.trim())}catch(l){if(Q(l))return;const g=H(l,s);r({ok:!1,text:"✗ "+g}),c(g,!1)}finally{n.current===x&&(n.current=null),h(!1),N&&p()}};return e.jsxs(A,{open:d,onClose:m,children:[e.jsx(L,{title:s("modal.configureWeixin"),onClose:m}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"text-xs leading-relaxed text-fg-4",children:s("modal.weixinScanHint")}),e.jsxs("div",{children:[e.jsx(M,{children:s("modal.weixinBaseUrl")}),e.jsx(R,{className:"font-mono text-xs",value:u,onChange:x=>v(x.target.value),placeholder:P}),e.jsx("div",{className:"mt-1 text-[11px] text-fg-5",children:s("modal.weixinDefaultBaseUrlHint")})]}),w&&e.jsxs("div",{className:"rounded-xl border border-edge bg-panel-alt p-4",children:[e.jsx("img",{src:w,alt:s("modal.weixinQrAlt"),className:"mx-auto h-56 w-56 rounded-lg bg-white p-3 object-contain"}),k&&e.jsx("div",{className:"mt-2 truncate text-center font-mono text-[10px] text-fg-5",children:k})]}),f&&e.jsx("div",{className:"text-xs",style:{color:f.ok?"var(--th-ok)":"var(--th-err)"},children:f.text})]}),e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx(I,{variant:"ghost",onClick:m,children:s("modal.cancel")}),e.jsx(I,{variant:"primary",disabled:b,onClick:o,children:s(b?w?"modal.validating":"modal.weixinGeneratingQr":w?"modal.weixinRetry":"modal.weixinGenerateQr")})]})]})}function ne({open:d,onClose:p}){const y=S(r=>r.state),c=S(r=>r.toast),B=S(r=>r.reload),t=S(r=>r.locale),s=a.useMemo(()=>U(t),[t]),u=y?.bot?.workdir||y?.runtimeWorkdir||"",[v,b]=a.useState(""),[h,w]=a.useState(!1),[j,k]=a.useState(0);a.useEffect(()=>{d&&(b(u),k(r=>r+1))},[d,u]);const i=a.useCallback(r=>{b(r)},[]),f=async()=>{const r=v.trim();if(!r){c(s("modal.selectDirFirst"),!1);return}w(!0);try{const n=await C.switchWorkdir(r);n.ok?(c(s("modal.switchedTo")+n.workdir),p(),setTimeout(B,300)):c(n.error||s("modal.switchFailed"),!1)}catch{c(s("modal.switchFailed"),!1)}finally{w(!1)}};return e.jsxs(A,{open:d,onClose:p,panelStyle:{width:"min(500px, calc(100vw - 2rem))",maxWidth:"min(500px, calc(100vw - 2rem))"},children:[e.jsx(L,{title:s("modal.switchWorkdir"),onClose:p}),e.jsx(X,{initialPath:u,onSelect:i,t:s},j),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(I,{variant:"ghost",onClick:p,disabled:h,children:s("modal.cancel")}),e.jsx(I,{variant:"primary",onClick:f,disabled:h,children:s(h?"status.loading":"modal.selectDir")})]})]})}function oe({open:d,onClose:p,onSaved:y}){const c=S(l=>l.toast),B=S(l=>l.locale),t=a.useMemo(()=>U(B),[B]),[s,u]=a.useState(null),[v,b]=a.useState(!1),[h,w]=a.useState(!1),[j,k]=a.useState(null);a.useEffect(()=>{d&&(b(!1),k(null),C.getBrowser().then(l=>{u(l),w(!!l.browser.enabled)}).catch(()=>u(null)))},[d]);const i=s?.browser,f=!!i?.enabled,r=!!i&&f!==h,n=i?.profileDir||"",F=t("ext.profileDir"),m=n,T=!!i?.chromeInstalled&&!!i?.profileCreated,o=s?i?.enabled?T?t("ext.browserReady"):i?.chromeInstalled?t("ext.chromeInstalled"):t("ext.needsSetup"):t("ext.disabled"):t("status.loading"),x=s&&i?.enabled?T?"ok":i?.chromeInstalled?"warn":"err":"muted",N=async()=>{b(!0),k(null);try{await C.saveConfig({browserEnabled:h});const l=await C.getBrowser();u(l),y?.()}catch{k({ok:!1,text:"✗ "+t("ext.browserModeSaveFailed")}),c(t("ext.browserModeSaveFailed"),!1),b(!1);return}if(!h){k({ok:!0,text:"✓ "+t("ext.browserDisabledSaved")}),c(t("ext.browserDisabledSaved")),b(!1);return}try{const l=await C.setupBrowser();if(!l.ok){k({ok:!1,text:"✗ "+(l.error||t("ext.browserLaunchFailed"))}),c(l.error||t("ext.browserLaunchFailed"),!1);return}u(g=>g?{...g,browser:l.browser}:{browser:l.browser,desktop:{enabled:!1,installed:!1,running:!1,appiumUrl:""}}),k({ok:!0,text:"✓ "+t("ext.browserEnabledLaunched")}),c(t("ext.browserEnabledLaunched")),y?.()}catch{k({ok:!1,text:"✗ "+t("ext.browserLaunchFailed")}),c(t("ext.browserLaunchFailed"),!1)}finally{b(!1)}};return e.jsxs(A,{open:d,onClose:p,children:[e.jsx(L,{title:t("ext.setupBrowser"),description:t("ext.setupBrowserDesc"),onClose:p}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"rounded-lg border border-edge bg-panel-alt p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(K,{variant:x,children:o}),i&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:f?"accent":"muted",children:t(f?"ext.enabled":"ext.disabled")}),r&&e.jsx(K,{variant:"warn",children:t("ext.pendingModeChange")}),i.running&&e.jsxs(K,{variant:"accent",children:[t("ext.browserOpen"),i.pid?` · PID ${i.pid}`:""]})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx(M,{children:F}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{className:"font-mono text-xs flex-1",value:m||"—",readOnly:!0,onClick:l=>l.target.select()}),e.jsx(I,{variant:"outline",size:"sm",disabled:!m,onClick:()=>{m&&(navigator.clipboard.writeText(m),c(t("ext.step2Copied")))},children:t("ext.copyPath")})]})]}),e.jsx("div",{className:"mt-3 text-xs text-fg-5",children:t(h?"ext.profileModeDesc":"ext.browserDescDisabled")}),i?.detail&&e.jsx("div",{className:"mt-2 text-xs text-fg-5",children:i.detail}),j&&e.jsx("div",{className:"mt-3 text-xs",style:{color:j.ok?"var(--th-ok)":"var(--th-err)"},children:j.text})]}),e.jsx("div",{className:"rounded-lg border border-edge bg-panel-alt p-4",children:e.jsxs("label",{className:"flex cursor-pointer items-start gap-3",children:[e.jsx("input",{type:"checkbox",checked:h,onChange:l=>w(l.target.checked),className:"mt-0.5 h-4 w-4 rounded border border-edge bg-inset"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-fg-2 mb-1",children:t("ext.browserEnableToggle")}),e.jsx("div",{className:"text-xs text-fg-4",children:t("ext.browserEnableToggleDesc")})]})]})}),e.jsxs("div",{className:"rounded-lg border border-edge bg-panel-alt p-4",children:[e.jsx("div",{className:"text-sm font-medium text-fg-2 mb-1",children:t(h?"ext.step2Title":"ext.browserDisabledStepTitle")}),e.jsx("div",{className:"text-xs text-fg-4",children:t(h?"ext.step2Desc":"ext.browserDisabledHint")})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-6",children:[e.jsx(I,{variant:"ghost",onClick:p,children:t("modal.cancel")}),e.jsx(I,{variant:"primary",disabled:v,onClick:N,children:t(v?"ext.launching":h?"ext.enableAndLaunchBrowser":"ext.saveBrowserDisabled")})]})]})}function ie({open:d,onClose:p,onSaved:y}){const c=S(o=>o.toast),B=S(o=>o.locale),t=a.useMemo(()=>U(B),[B]),[s,u]=a.useState(!1),[v,b]=a.useState(!1),[h,w]=a.useState(!1),[j,k]=a.useState(!1),[i,f]=a.useState(!1),[r,n]=a.useState(null);a.useEffect(()=>{d&&(u(!1),k(!1),f(!1),n(null),C.getBrowser().then(o=>{b(o.desktop.installed),w(o.desktop.enabled)}).catch(()=>{}))},[d]);const F=async()=>{u(!0),n(null);try{const o=await C.desktopInstall();o.ok?(b(!0),n({ok:!0,text:"✓ "+t("ext.desktopInstalled")}),c(t("ext.desktopInstalled"))):n({ok:!1,text:"✗ "+(o.error||t("ext.desktopInstallFailed"))})}catch{n({ok:!1,text:"✗ "+t("ext.desktopInstallFailed")})}finally{u(!1)}},m=async()=>{k(!0),n(null);try{const o=await C.desktopToggle(!0);o.ok?(w(!0),n({ok:!0,text:"✓ "+t("ext.desktopStarted")}),c(t("ext.desktopStarted")),y?.()):n({ok:!1,text:"✗ "+(o.error||t("ext.desktopInstallFailed"))})}catch{n({ok:!1,text:"✗ "+t("ext.desktopInstallFailed")})}finally{k(!1)}},T=async()=>{f(!0),n(null);try{const o=await C.desktopToggle(!1);o.ok?(w(!1),n({ok:!0,text:"✓ "+t("ext.desktopStopped")}),c(t("ext.desktopStopped")),y?.()):n({ok:!1,text:"✗ "+(o.error||t("ext.desktopInstallFailed"))})}catch{n({ok:!1,text:"✗ "+t("ext.desktopInstallFailed")})}finally{f(!1)}};return e.jsxs(A,{open:d,onClose:p,children:[e.jsx(L,{title:t("ext.setupDesktop"),description:t("ext.setupDesktopDesc"),onClose:p}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"rounded-lg border border-edge bg-panel-alt p-4",children:[e.jsx("div",{className:"text-sm font-medium text-fg-2 mb-1",children:t("ext.desktopStep1Title")}),e.jsx("div",{className:"text-xs text-fg-4 mb-3",children:t("ext.desktopStep1Desc")}),r&&!v&&e.jsx("div",{className:"mb-2 text-xs",style:{color:r.ok?"var(--th-ok)":"var(--th-err)"},children:r.text}),e.jsx(I,{variant:v?"ghost":"outline",size:"sm",disabled:s||v,onClick:F,children:t(s?"ext.desktopInstalling":v?"ext.desktopStep1Done":"ext.desktopStep1Action")})]}),e.jsxs("div",{className:"rounded-lg border border-edge bg-panel-alt p-4",children:[e.jsx("div",{className:"text-sm font-medium text-fg-2 mb-1",children:t("ext.desktopStep2Title")}),e.jsx("div",{className:"text-xs text-fg-4 mb-3",children:t("ext.desktopStep2Desc")}),r&&v&&e.jsx("div",{className:"mb-2 text-xs",style:{color:r.ok?"var(--th-ok)":"var(--th-err)"},children:r.text}),e.jsx("div",{className:"flex items-center gap-2",children:h?e.jsx(I,{variant:"outline",size:"sm",disabled:i,onClick:T,children:t(i?"ext.desktopStopping":"ext.disable")}):e.jsx(I,{variant:"primary",size:"sm",disabled:!v||j,onClick:m,children:t(j?"ext.desktopStarting":"ext.desktopStep2Action")})})]})]}),e.jsx("div",{className:"flex justify-end gap-2 mt-6",children:e.jsx(I,{variant:"ghost",onClick:p,children:t("modal.cancel")})})]})}export{oe as BrowserSetupModal,ie as DesktopSetupModal,le as FeishuModal,ae as TelegramModal,re as WeixinModal,ne as WorkdirModal};
@@ -1 +1 @@
1
- import{r as l,j as e}from"./react-vendor-DTcmqLiz.js";import{u,b as R,a as D,B as f,k as N}from"./index-BPyYJAu2.js";import{a as L,b as O,c as j,d as z}from"./shared-Diw6OFf-.js";import"./router-emLofBBH.js";const E=[{key:"accessibility",labelKey:"perm.accessibility",reasonZh:"允许控制桌面应用、点击和输入。",reasonEn:"Allows controlling desktop apps with clicks and typing.",guidePathKey:"perm.pathAccessibility",icon:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),e.jsx("path",{d:"M12 7.7v10.2"}),e.jsx("path",{d:"M8.4 10h7.2"}),e.jsx("path",{d:"M9.6 19.2 12 15.1l2.4 4.1"})]})},{key:"screenRecording",labelKey:"perm.screenRecording",reasonZh:"允许读取屏幕内容,用于截图和界面分析。",reasonEn:"Allows reading the screen for screenshots and UI inspection.",guidePathKey:"perm.pathScreenRecording",icon:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"4",y:"5.5",width:"11.5",height:"10",rx:"2.4"}),e.jsx("path",{d:"m17.5 8.4 2.7-1.5v7.2l-2.7-1.5"}),e.jsx("circle",{cx:"9.75",cy:"10.5",r:"1.1",fill:"currentColor",stroke:"none"})]})},{key:"fullDiskAccess",labelKey:"perm.fullDiskAccess",reasonZh:"允许访问桌面、下载等受保护目录。",reasonEn:"Allows access to protected folders like Desktop and Downloads.",guidePathKey:"perm.pathFullDiskAccess",icon:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"6.2",y:"10.1",width:"11.6",height:"8.6",rx:"2.6"}),e.jsx("path",{d:"M9 10V7.8a3 3 0 1 1 6 0V10"}),e.jsx("circle",{cx:"12",cy:"13.5",r:"0.9",fill:"currentColor",stroke:"none"}),e.jsx("path",{d:"M12 14.6v1.8"})]})}];function K(o){return o==="zh-CN"?{introWithHost:"请在 macOS 中为 {hostApp} 开启以下权限。",intro:"请在 macOS 中开启以下权限。",status:"状态",summary:"系统位置",loading:"检查中",needsGrant:"需要授权",granted:"已授权",authorize:"授权",openSettings:"前往设置",refreshState:"刷新状态",checking:"检查中...",hostGranted:"{hostApp} 已可直接使用此权限。",hostGrantedFallback:"当前宿主应用已可直接使用此权限。",needsGrantDetail:"尚未授权,可通过右侧按钮发起系统授权。",needsSettingsDetail:"需要在系统设置中手动开启此权限。"}:{introWithHost:"Grant the following permissions to {hostApp} in macOS.",intro:"Grant the following permissions in macOS.",status:"Status",summary:"System path",loading:"Checking",needsGrant:"Needs access",granted:"Granted",authorize:"Authorize",openSettings:"Open settings",refreshState:"Refresh status",checking:"Checking...",hostGranted:"{hostApp} can use this permission now.",hostGrantedFallback:"The current host app can use this permission now.",needsGrantDetail:"Access has not been granted yet. Use the button on the right to trigger the macOS prompt.",needsSettingsDetail:"This permission needs to be enabled manually in System Settings."}}function B(){const o=u(t=>t.state),d=u(t=>t.locale),h=u(t=>t.reload),i=u(t=>t.toast),a=l.useMemo(()=>R(d),[d]),s=K(d),g=o?.permissions||{},p=o?.hostApp||null,c=!o,[m,x]=l.useState(null),b=l.useMemo(()=>E.map(t=>({...t,permission:g[t.key]})),[g]),S=l.useCallback(async t=>{if(!m){x(t);try{const n=await D.requestPermission(t);if(!n.ok){i(n.error||a("perm.requestFailed"),!1);return}n.action==="already_granted"?i(a("perm.alreadyGranted")):n.action==="prompted"?i(a("perm.promptOpened")):i(a("perm.settingsOpened")),await h()}catch(n){i(n instanceof Error?n.message:a("perm.requestFailed"),!1)}finally{x(n=>n===t?null:n)}}},[h,m,a,i]),k=l.useCallback(async()=>{await h()},[h]);return e.jsxs("div",{className:"animate-in space-y-3",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("div",{className:"text-[13px] leading-relaxed text-fg-4",children:p?s.introWithHost.replace("{hostApp}",p):s.intro})}),e.jsx(f,{variant:"outline",size:"sm",onClick:()=>{k()},children:s.refreshState})]}),b.map(t=>{const n=t.permission,r=!!n?.granted,y=!!n&&n.checkable,w=c?s.loading:n&&r?s.granted:s.needsGrant,v=c?"muted":r?"ok":"warn",A=c?s.loading:r?p?s.hostGranted.replace("{hostApp}",p):s.hostGrantedFallback:y?s.needsGrantDetail:s.needsSettingsDetail,G=c?s.checking:r?s.refreshState:y?s.authorize:s.openSettings,C=r?k:()=>{S(t.key)};return e.jsxs(L,{children:[e.jsx(O,{icon:t.icon,title:a(t.labelKey),subtitle:d==="zh-CN"?t.reasonZh:t.reasonEn}),e.jsxs(j,{label:s.status,children:[e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:e.jsx(N,{variant:v,children:w})}),e.jsx("div",{className:"mt-1 text-[13px] leading-relaxed text-fg-3",children:A})]}),e.jsx(j,{label:s.summary,children:e.jsx("div",{className:"break-words text-[13px] leading-relaxed text-fg-3",children:a(t.guidePathKey)})}),e.jsx(z,{children:e.jsx(f,{variant:r?"outline":"primary",size:"sm",disabled:c||!!m,onClick:C,children:m===t.key?s.checking:G})})]},t.key)})]})}export{B as PermissionsTab};
1
+ import{r as l,j as e}from"./react-vendor-DTcmqLiz.js";import{u,b as R,a as D,B as f,k as N}from"./index-D5sKCspB.js";import{a as L,b as O,c as j,d as z}from"./shared-6sWbm5Tj.js";import"./router-emLofBBH.js";const E=[{key:"accessibility",labelKey:"perm.accessibility",reasonZh:"允许控制桌面应用、点击和输入。",reasonEn:"Allows controlling desktop apps with clicks and typing.",guidePathKey:"perm.pathAccessibility",icon:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),e.jsx("path",{d:"M12 7.7v10.2"}),e.jsx("path",{d:"M8.4 10h7.2"}),e.jsx("path",{d:"M9.6 19.2 12 15.1l2.4 4.1"})]})},{key:"screenRecording",labelKey:"perm.screenRecording",reasonZh:"允许读取屏幕内容,用于截图和界面分析。",reasonEn:"Allows reading the screen for screenshots and UI inspection.",guidePathKey:"perm.pathScreenRecording",icon:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"4",y:"5.5",width:"11.5",height:"10",rx:"2.4"}),e.jsx("path",{d:"m17.5 8.4 2.7-1.5v7.2l-2.7-1.5"}),e.jsx("circle",{cx:"9.75",cy:"10.5",r:"1.1",fill:"currentColor",stroke:"none"})]})},{key:"fullDiskAccess",labelKey:"perm.fullDiskAccess",reasonZh:"允许访问桌面、下载等受保护目录。",reasonEn:"Allows access to protected folders like Desktop and Downloads.",guidePathKey:"perm.pathFullDiskAccess",icon:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"6.2",y:"10.1",width:"11.6",height:"8.6",rx:"2.6"}),e.jsx("path",{d:"M9 10V7.8a3 3 0 1 1 6 0V10"}),e.jsx("circle",{cx:"12",cy:"13.5",r:"0.9",fill:"currentColor",stroke:"none"}),e.jsx("path",{d:"M12 14.6v1.8"})]})}];function K(o){return o==="zh-CN"?{introWithHost:"请在 macOS 中为 {hostApp} 开启以下权限。",intro:"请在 macOS 中开启以下权限。",status:"状态",summary:"系统位置",loading:"检查中",needsGrant:"需要授权",granted:"已授权",authorize:"授权",openSettings:"前往设置",refreshState:"刷新状态",checking:"检查中...",hostGranted:"{hostApp} 已可直接使用此权限。",hostGrantedFallback:"当前宿主应用已可直接使用此权限。",needsGrantDetail:"尚未授权,可通过右侧按钮发起系统授权。",needsSettingsDetail:"需要在系统设置中手动开启此权限。"}:{introWithHost:"Grant the following permissions to {hostApp} in macOS.",intro:"Grant the following permissions in macOS.",status:"Status",summary:"System path",loading:"Checking",needsGrant:"Needs access",granted:"Granted",authorize:"Authorize",openSettings:"Open settings",refreshState:"Refresh status",checking:"Checking...",hostGranted:"{hostApp} can use this permission now.",hostGrantedFallback:"The current host app can use this permission now.",needsGrantDetail:"Access has not been granted yet. Use the button on the right to trigger the macOS prompt.",needsSettingsDetail:"This permission needs to be enabled manually in System Settings."}}function B(){const o=u(t=>t.state),d=u(t=>t.locale),h=u(t=>t.reload),i=u(t=>t.toast),a=l.useMemo(()=>R(d),[d]),s=K(d),g=o?.permissions||{},p=o?.hostApp||null,c=!o,[m,x]=l.useState(null),b=l.useMemo(()=>E.map(t=>({...t,permission:g[t.key]})),[g]),S=l.useCallback(async t=>{if(!m){x(t);try{const n=await D.requestPermission(t);if(!n.ok){i(n.error||a("perm.requestFailed"),!1);return}n.action==="already_granted"?i(a("perm.alreadyGranted")):n.action==="prompted"?i(a("perm.promptOpened")):i(a("perm.settingsOpened")),await h()}catch(n){i(n instanceof Error?n.message:a("perm.requestFailed"),!1)}finally{x(n=>n===t?null:n)}}},[h,m,a,i]),k=l.useCallback(async()=>{await h()},[h]);return e.jsxs("div",{className:"animate-in space-y-3",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("div",{className:"text-[13px] leading-relaxed text-fg-4",children:p?s.introWithHost.replace("{hostApp}",p):s.intro})}),e.jsx(f,{variant:"outline",size:"sm",onClick:()=>{k()},children:s.refreshState})]}),b.map(t=>{const n=t.permission,r=!!n?.granted,y=!!n&&n.checkable,w=c?s.loading:n&&r?s.granted:s.needsGrant,v=c?"muted":r?"ok":"warn",A=c?s.loading:r?p?s.hostGranted.replace("{hostApp}",p):s.hostGrantedFallback:y?s.needsGrantDetail:s.needsSettingsDetail,G=c?s.checking:r?s.refreshState:y?s.authorize:s.openSettings,C=r?k:()=>{S(t.key)};return e.jsxs(L,{children:[e.jsx(O,{icon:t.icon,title:a(t.labelKey),subtitle:d==="zh-CN"?t.reasonZh:t.reasonEn}),e.jsxs(j,{label:s.status,children:[e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:e.jsx(N,{variant:v,children:w})}),e.jsx("div",{className:"mt-1 text-[13px] leading-relaxed text-fg-3",children:A})]}),e.jsx(j,{label:s.summary,children:e.jsx("div",{className:"break-words text-[13px] leading-relaxed text-fg-3",children:a(t.guidePathKey)})}),e.jsx(z,{children:e.jsx(f,{variant:r?"outline":"primary",size:"sm",disabled:c||!!m,onClick:C,children:m===t.key?s.checking:G})})]},t.key)})]})}export{B as PermissionsTab};
@@ -1 +1 @@
1
- import{r as s,j as e,b as H}from"./react-vendor-DTcmqLiz.js";import{c}from"./index-BPyYJAu2.js";function _(u,h){return!!(u&&h instanceof Node&&u.contains(h))}function M({value:u,options:h,onChange:y,className:w,placeholder:a="—",disabled:x=!1,readOnly:p=!1}){const f=h.find(n=>n.value===u),m=p||h.length<=1,[i,g]=s.useState(!1),[t,l]=s.useState(null),o=s.useRef(null),j=s.useRef(null);if(s.useEffect(()=>{if(!i)return;const n=d=>{_(o.current,d.target)||_(j.current,d.target)||g(!1)},r=d=>{d.key==="Escape"&&g(!1)};return document.addEventListener("mousedown",n),document.addEventListener("keydown",r),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("keydown",r)}},[i]),s.useLayoutEffect(()=>{if(!i)return;const n=()=>{const r=o.current;if(!r)return;const d=r.getBoundingClientRect(),k=window.innerHeight-d.bottom-12,E=d.top-12,N=k<220&&E>k,L=Math.max(140,Math.min(260,N?E:k));l({left:d.left,top:N?Math.max(12,d.top-L-8):d.bottom+8,width:d.width,maxHeight:L})};return n(),window.addEventListener("resize",n),window.addEventListener("scroll",n,!0),()=>{window.removeEventListener("resize",n),window.removeEventListener("scroll",n,!0)}},[i]),m)return e.jsx("div",{className:c("flex h-8 w-full items-center rounded-md border border-edge bg-panel-alt px-2.5 text-[13px] text-fg-3 shadow-[inset_0_1px_0_var(--th-inset-hl),0_1px_2px_rgba(15,23,42,0.05)]",x&&"cursor-not-allowed opacity-50",w),children:e.jsx("span",{className:c("truncate",!f&&"text-fg-5"),children:f?.label||a})});const v=n=>{x||(y(n),g(!1))},b=i&&t?H.createPortal(e.jsx("div",{ref:j,role:"listbox",className:"fixed z-[220] overflow-hidden rounded-xl border border-edge-h bg-[var(--th-dropdown)] p-1.5 shadow-[0_24px_64px_rgba(2,6,23,0.22)] backdrop-blur-xl",style:{left:t.left,top:t.top,width:t.width},children:e.jsx("div",{className:"overflow-y-auto",style:{maxHeight:t.maxHeight},children:h.map(n=>{const r=n.value===u;return e.jsxs("button",{type:"button",role:"option","aria-selected":r,onClick:()=>v(n.value),className:c("flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-[13px] transition-colors duration-200",r?"bg-panel text-fg shadow-[inset_0_1px_0_rgba(255,255,255,0.03)]":"text-fg-3 hover:bg-panel-alt hover:text-fg-2"),children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:n.label}),r&&e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"shrink-0 text-fg-4",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})]},n.value)})})}),document.body):null;return e.jsxs("div",{ref:o,className:c("relative",w),children:[e.jsxs("button",{type:"button",disabled:x,"aria-haspopup":"listbox","aria-expanded":i,onClick:()=>g(n=>!n),className:c("flex h-8 w-full items-center rounded-md border border-edge bg-inset px-2.5 pr-8 text-left text-[13px] text-fg shadow-[inset_0_1px_0_var(--th-inset-hl),0_1px_2px_rgba(15,23,42,0.05)]","transition-[border-color,box-shadow,background] duration-200 outline-none","hover:border-edge-h hover:bg-panel","focus-visible:border-edge-h focus-visible:shadow-[0_0_0_4px_var(--th-glow-a)]","disabled:cursor-not-allowed disabled:opacity-50",i&&"border-edge-h bg-panel shadow-[0_0_0_4px_var(--th-glow-a)]"),children:[e.jsx("span",{className:c("min-w-0 flex-1 truncate",!f&&"text-fg-5"),children:f?.label||a}),e.jsx("span",{className:c("pointer-events-none absolute inset-y-0 right-3 flex items-center text-fg-4 transition-transform duration-200",i&&"rotate-180"),children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),b]})}function B({value:u,options:h,onChange:y,renderIcon:w}){const[a,x]=s.useState(!1),[p,f]=s.useState(null),m=s.useRef(null),i=s.useRef(null);s.useEffect(()=>{if(!a)return;const t=o=>{_(m.current,o.target)||_(i.current,o.target)||x(!1)},l=o=>{o.key==="Escape"&&x(!1)};return document.addEventListener("mousedown",t),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("keydown",l)}},[a]),s.useLayoutEffect(()=>{if(!a)return;const t=()=>{const l=m.current;if(!l)return;const o=l.getBoundingClientRect(),v=window.innerHeight-o.bottom-12,b=o.top-12,n=v<220&&b>v,r=Math.max(140,Math.min(260,n?b:v));f({left:o.left,top:n?Math.max(12,o.top-r-8):o.bottom+8,width:Math.max(o.width,160),maxHeight:r})};return t(),window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[a]);const g=a&&p?H.createPortal(e.jsx("div",{ref:i,role:"listbox",className:"fixed z-[220] overflow-hidden rounded-xl border border-edge-h bg-[var(--th-dropdown)] p-1.5 shadow-[0_24px_64px_rgba(2,6,23,0.22)] backdrop-blur-xl",style:{left:p.left,top:p.top,width:p.width},children:e.jsx("div",{className:"overflow-y-auto",style:{maxHeight:p.maxHeight},children:h.map(t=>{const l=t.value===u;return e.jsxs("button",{type:"button",role:"option","aria-selected":l,onClick:()=>{y(t.value),x(!1)},className:c("flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[13px] transition-colors duration-200",l?"bg-panel text-fg shadow-[inset_0_1px_0_rgba(255,255,255,0.03)]":"text-fg-3 hover:bg-panel-alt hover:text-fg-2"),children:[w(t.value),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.label}),l&&e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"shrink-0 text-fg-4",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})]},t.value)})})}),document.body):null;return e.jsxs("div",{ref:m,className:"relative shrink-0",children:[e.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":a,onClick:()=>x(t=>!t),className:c("inline-flex items-center gap-1.5 rounded-lg border border-edge bg-inset px-2 py-1.5","transition-[border-color,box-shadow,background] duration-200 outline-none","hover:border-edge-h hover:bg-panel","focus-visible:border-edge-h focus-visible:shadow-[0_0_0_4px_var(--th-glow-a)]",a&&"border-edge-h bg-panel shadow-[0_0_0_4px_var(--th-glow-a)]"),children:[w(u),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:c("text-fg-5 transition-transform duration-200",a&&"rotate-180"),children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),g]})}export{B as I,M as S};
1
+ import{r as s,j as e,b as H}from"./react-vendor-DTcmqLiz.js";import{c}from"./index-D5sKCspB.js";function _(u,h){return!!(u&&h instanceof Node&&u.contains(h))}function M({value:u,options:h,onChange:y,className:w,placeholder:a="—",disabled:x=!1,readOnly:p=!1}){const f=h.find(n=>n.value===u),m=p||h.length<=1,[i,g]=s.useState(!1),[t,l]=s.useState(null),o=s.useRef(null),j=s.useRef(null);if(s.useEffect(()=>{if(!i)return;const n=d=>{_(o.current,d.target)||_(j.current,d.target)||g(!1)},r=d=>{d.key==="Escape"&&g(!1)};return document.addEventListener("mousedown",n),document.addEventListener("keydown",r),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("keydown",r)}},[i]),s.useLayoutEffect(()=>{if(!i)return;const n=()=>{const r=o.current;if(!r)return;const d=r.getBoundingClientRect(),k=window.innerHeight-d.bottom-12,E=d.top-12,N=k<220&&E>k,L=Math.max(140,Math.min(260,N?E:k));l({left:d.left,top:N?Math.max(12,d.top-L-8):d.bottom+8,width:d.width,maxHeight:L})};return n(),window.addEventListener("resize",n),window.addEventListener("scroll",n,!0),()=>{window.removeEventListener("resize",n),window.removeEventListener("scroll",n,!0)}},[i]),m)return e.jsx("div",{className:c("flex h-8 w-full items-center rounded-md border border-edge bg-panel-alt px-2.5 text-[13px] text-fg-3 shadow-[inset_0_1px_0_var(--th-inset-hl),0_1px_2px_rgba(15,23,42,0.05)]",x&&"cursor-not-allowed opacity-50",w),children:e.jsx("span",{className:c("truncate",!f&&"text-fg-5"),children:f?.label||a})});const v=n=>{x||(y(n),g(!1))},b=i&&t?H.createPortal(e.jsx("div",{ref:j,role:"listbox",className:"fixed z-[220] overflow-hidden rounded-xl border border-edge-h bg-[var(--th-dropdown)] p-1.5 shadow-[0_24px_64px_rgba(2,6,23,0.22)] backdrop-blur-xl",style:{left:t.left,top:t.top,width:t.width},children:e.jsx("div",{className:"overflow-y-auto",style:{maxHeight:t.maxHeight},children:h.map(n=>{const r=n.value===u;return e.jsxs("button",{type:"button",role:"option","aria-selected":r,onClick:()=>v(n.value),className:c("flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-[13px] transition-colors duration-200",r?"bg-panel text-fg shadow-[inset_0_1px_0_rgba(255,255,255,0.03)]":"text-fg-3 hover:bg-panel-alt hover:text-fg-2"),children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:n.label}),r&&e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"shrink-0 text-fg-4",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})]},n.value)})})}),document.body):null;return e.jsxs("div",{ref:o,className:c("relative",w),children:[e.jsxs("button",{type:"button",disabled:x,"aria-haspopup":"listbox","aria-expanded":i,onClick:()=>g(n=>!n),className:c("flex h-8 w-full items-center rounded-md border border-edge bg-inset px-2.5 pr-8 text-left text-[13px] text-fg shadow-[inset_0_1px_0_var(--th-inset-hl),0_1px_2px_rgba(15,23,42,0.05)]","transition-[border-color,box-shadow,background] duration-200 outline-none","hover:border-edge-h hover:bg-panel","focus-visible:border-edge-h focus-visible:shadow-[0_0_0_4px_var(--th-glow-a)]","disabled:cursor-not-allowed disabled:opacity-50",i&&"border-edge-h bg-panel shadow-[0_0_0_4px_var(--th-glow-a)]"),children:[e.jsx("span",{className:c("min-w-0 flex-1 truncate",!f&&"text-fg-5"),children:f?.label||a}),e.jsx("span",{className:c("pointer-events-none absolute inset-y-0 right-3 flex items-center text-fg-4 transition-transform duration-200",i&&"rotate-180"),children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),b]})}function B({value:u,options:h,onChange:y,renderIcon:w}){const[a,x]=s.useState(!1),[p,f]=s.useState(null),m=s.useRef(null),i=s.useRef(null);s.useEffect(()=>{if(!a)return;const t=o=>{_(m.current,o.target)||_(i.current,o.target)||x(!1)},l=o=>{o.key==="Escape"&&x(!1)};return document.addEventListener("mousedown",t),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("keydown",l)}},[a]),s.useLayoutEffect(()=>{if(!a)return;const t=()=>{const l=m.current;if(!l)return;const o=l.getBoundingClientRect(),v=window.innerHeight-o.bottom-12,b=o.top-12,n=v<220&&b>v,r=Math.max(140,Math.min(260,n?b:v));f({left:o.left,top:n?Math.max(12,o.top-r-8):o.bottom+8,width:Math.max(o.width,160),maxHeight:r})};return t(),window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[a]);const g=a&&p?H.createPortal(e.jsx("div",{ref:i,role:"listbox",className:"fixed z-[220] overflow-hidden rounded-xl border border-edge-h bg-[var(--th-dropdown)] p-1.5 shadow-[0_24px_64px_rgba(2,6,23,0.22)] backdrop-blur-xl",style:{left:p.left,top:p.top,width:p.width},children:e.jsx("div",{className:"overflow-y-auto",style:{maxHeight:p.maxHeight},children:h.map(t=>{const l=t.value===u;return e.jsxs("button",{type:"button",role:"option","aria-selected":l,onClick:()=>{y(t.value),x(!1)},className:c("flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[13px] transition-colors duration-200",l?"bg-panel text-fg shadow-[inset_0_1px_0_rgba(255,255,255,0.03)]":"text-fg-3 hover:bg-panel-alt hover:text-fg-2"),children:[w(t.value),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.label}),l&&e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"shrink-0 text-fg-4",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})]},t.value)})})}),document.body):null;return e.jsxs("div",{ref:m,className:"relative shrink-0",children:[e.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":a,onClick:()=>x(t=>!t),className:c("inline-flex items-center gap-1.5 rounded-lg border border-edge bg-inset px-2 py-1.5","transition-[border-color,box-shadow,background] duration-200 outline-none","hover:border-edge-h hover:bg-panel","focus-visible:border-edge-h focus-visible:shadow-[0_0_0_4px_var(--th-glow-a)]",a&&"border-edge-h bg-panel shadow-[0_0_0_4px_var(--th-glow-a)]"),children:[w(u),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:c("text-fg-5 transition-transform duration-200",a&&"rotate-180"),children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),g]})}export{B as I,M as S};
@@ -1 +1 @@
1
- import{r as t,j as s}from"./react-vendor-DTcmqLiz.js";import{u as de,b as be,g as je,s as Le,a as L,S as ge,j as Y}from"./index-BPyYJAu2.js";import{l as He,n as me,m as Ee,a as Ne,p as Pe,u as Ce,b as Me,T as we,U as De,c as Ue,d as he,L as _e,I as $e}from"./index-N1ReybwG.js";import"./router-emLofBBH.js";import"./Select-CzehncNR.js";import"./Modal-BWEFrRB_.js";import"./BrandIcon-DI28YjL9.js";import"./DirBrowser-B1ZrMmei.js";import"./markdown-DMQUjobV.js";const F=12,pe=160,Ae=96,qe=20,T=new Map;function Be(R,r){return`${R}:${r}`}function Qe(R,r){for(T.delete(R),T.set(R,r);T.size>qe;)T.delete(T.keys().next().value)}const Ze=t.memo(function({session:r,workdir:d,active:J=!0,onSessionChange:U,initialPendingPrompt:H,onPendingPromptConsumed:Z}){const ee=de(e=>e.locale),_=de(e=>e.agentStatus?.agents?.find(n=>n.agent===r.agent)?.selectedEffort??null),m=t.useMemo(()=>be(ee),[ee]),$=je(r.agent||""),te=Le(r),[a,A]=t.useState(null),[q,re]=t.useState(!0),[y,ne]=t.useState(!1),[c,v]=t.useState(null),[E,I]=t.useState(!1),[Se,B]=t.useState(null),[xe,se]=t.useState(0),[Te,Q]=t.useState(null),[Re,N]=t.useState(null),[u,K]=t.useState(null),[O,le]=t.useState([]),[ye,X]=t.useState(!1),[ve,ae]=t.useState(null),z=t.useRef([]),ue=t.useRef(c),ce=t.useRef(E);ue.current=c,ce.current=E;const h=t.useRef(null),P=t.useRef(null),k=t.useRef(!0),p=t.useRef(!1),G=t.useRef(!1),V=t.useRef(!1),S=t.useRef(!1),b=t.useRef(!1),W=t.useRef(!1);t.useEffect(()=>{W.current||!H||(W.current=!0,K(H),S.current=!0,se(e=>e+1),Z?.())},[H,Z]);const f=t.useCallback(()=>{K(null),le(e=>{for(const n of e)URL.revokeObjectURL(n);return[]}),z.current=[],X(!1)},[]),oe=t.useCallback((e,n)=>{for(const i of z.current)URL.revokeObjectURL(i);K(e||null);const l=n||[];le(l),z.current=l,X(!!ue.current||ce.current)},[]),C=t.useCallback(async(e,n={})=>{try{const l=await He({workdir:d,agent:r.agent||"",sessionId:r.sessionId,rich:!0,turnOffset:e.turnOffset,turnLimit:e.turnLimit,lastNTurns:e.lastNTurns},{force:n.force});return l.ok?me(l):null}catch{return null}},[d,r.agent,r.sessionId]),o=t.useCallback(async({keepOlder:e,force:n=!1})=>{if(G.current)return!1;G.current=!0;try{const l=await C({turnOffset:0,turnLimit:F},{force:n});return l?(A(i=>!i||!e?l:Ee(i,l)),b.current&&(b.current=!1,f()),!0):!1}finally{G.current=!1}},[C,f]),M=t.useCallback(async()=>{if(!a?.hasOlder||V.current)return;const e=h.current;e&&(P.current={scrollHeight:e.scrollHeight,scrollTop:e.scrollTop}),V.current=!0,ne(!0);try{const n=await C({turnOffset:Math.max(0,a.totalTurns-a.startTurn),turnLimit:F});n?A(l=>l?Ne(l,n):n):P.current=null}finally{V.current=!1,ne(!1)}},[C,a]),w=t.useRef(null),x=t.useCallback(e=>{if(e?.sessionId&&e.sessionId!==r.sessionId){U?.({agent:r.agent||"",sessionId:e.sessionId,workdir:d});return}if(!e){const n=w.current;v(null),I(!1),n==="streaming"?(k.current&&(p.current=!0),b.current=!0,o({keepOlder:!0,force:!0})):n==="done"?f():n===null&&S.current&&o({keepOlder:!0,force:!0}),S.current=!1,Q(null),B(null),N(null),w.current=null;return}B(e.phase),Q(e.taskId||null),N(e.queuedTaskId||null),e.phase==="streaming"?(v({phase:"streaming",text:e.text||"",thinking:e.thinking||"",activity:e.activity,plan:e.plan??null}),I(!0),e.queuedTaskId||X(!1),k.current&&(p.current=!0)):e.phase==="queued"?(v(null),I(!1)):e.phase==="done"&&(v(null),I(!1),w.current!=="done"&&(k.current&&(p.current=!0),e.queuedTaskId||(b.current=!0),o({keepOlder:!0,force:!0})),e.queuedTaskId||(S.current=!1)),w.current=e.phase},[f,o,r.sessionId,r.agent,U,d]),fe=t.useCallback(()=>{S.current=!0,se(e=>e+1)},[]),Ie=t.useCallback(async e=>{try{await L.recallSessionMessage(e),f(),N(n=>n===e?null:n),Q(n=>n===e?null:n)}catch{}},[f]),Oe=t.useCallback(async e=>{try{await L.steerSession(e)}catch{}},[]),D=Be(r.agent||"",r.sessionId);t.useEffect(()=>{let e=!1;const n=Pe({workdir:d,agent:r.agent||"",sessionId:r.sessionId,rich:!0,turnOffset:0,turnLimit:F},{allowStale:!0}),l=!!H&&!W.current,i=n?.ok?me(n):T.get(D)||null;return re(l?!1:!i),A(i),v(null),I(!1),B(null),N(null),k.current=!0,p.current=!0,l||o({keepOlder:!1,force:!0}).finally(()=>{e||re(!1)}),()=>{e=!0}},[o,r.agent,r.sessionId,d,D]),t.useEffect(()=>{a&&a.turns.length>0&&Qe(D,a)},[D,a]),t.useEffect(()=>{J&&o({keepOlder:!0,force:!0})},[J,o]);const ie=t.useRef(`${r.agent}:${r.sessionId}`);ie.current=`${r.agent}:${r.sessionId}`,Ce("stream-update",t.useCallback(e=>{e.key===ie.current&&x(e.snapshot??null)},[x])),t.useEffect(()=>{let e=!0;return L.getSessionStreamState(r.agent||"",r.sessionId).then(n=>{e&&x(n.state)}).catch(()=>{}),()=>{e=!1}},[x,r.agent,r.sessionId,xe]),Me(t.useCallback(()=>{L.getSessionStreamState(r.agent||"",r.sessionId).then(e=>{x(e.state)}).catch(()=>{}),o({keepOlder:!0,force:!0})},[x,r.agent,r.sessionId,o])),t.useEffect(()=>{te!=="running"&&!E&&!c&&(f(),S.current=!1)},[te,E,c,f]),t.useLayoutEffect(()=>{const e=P.current,n=h.current;!e||!n||(P.current=null,n.scrollTop=e.scrollTop+(n.scrollHeight-e.scrollHeight))},[a?.turns.length]),t.useLayoutEffect(()=>{if(!p.current)return;const e=h.current;e&&(p.current=!1,e.scrollTop=e.scrollHeight)},[a?.turns.length,c]),t.useLayoutEffect(()=>{if(!u)return;const e=h.current;e&&(e.scrollTop=e.scrollHeight)},[u]),t.useEffect(()=>{if(!a?.hasOlder||q||y)return;const e=h.current;e&&e.scrollHeight<=e.clientHeight+pe&&M()},[a?.hasOlder,a?.turns.length,M,q,y]);const ke=t.useCallback(()=>{const e=h.current;if(!e)return;const n=e.scrollHeight-e.scrollTop-e.clientHeight;k.current=n<=Ae,e.scrollTop<=pe&&M()},[M]),g=a?.turns||[],j=t.useMemo(()=>{if(!c||!g.length)return g;const e=g[g.length-1];return!e.assistant||u&&e.user?.text?.trim()!==u.trim()?g:[...g.slice(0,-1),{...e,assistant:null}]},[g,c,u]);return s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsx("div",{ref:h,onScroll:ke,className:"flex-1 overflow-y-auto overscroll-contain",children:q?s.jsx("div",{className:"flex items-center justify-center py-20",children:s.jsx(ge,{className:"h-5 w-5 text-fg-4"})}):j.length===0&&!u&&!O.length&&!c?s.jsx("div",{className:"py-20 text-center text-[13px] text-fg-5",children:m("hub.noMessages")}):s.jsxs("div",{className:"max-w-[900px] mx-auto px-6 py-6 space-y-0",children:[(a?.hasOlder||y)&&s.jsxs("div",{className:"mb-4 flex items-center justify-center gap-2 text-[11px] text-fg-5",children:[y?s.jsx(ge,{className:"h-3 w-3 text-fg-5"}):s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-fg-5/35"}),s.jsx("span",{children:m(y?"hub.loadingOlderTurns":"hub.loadOlderTurnsHint")})]}),j.map((e,n)=>s.jsx(we,{turn:e,agent:r.agent||"",meta:$,model:r.model?Y(r.model):void 0,effort:_,t:m,onResend:l=>{p.current=!0,oe(l),L.sendSessionMessage(d,r.agent||"",r.sessionId,l).then(i=>{i.ok&&fe()}).catch(()=>{f()})},onEdit:l=>ae(l)},`${a?.startTurn||0}:${n}`)),(u||O.length>0)&&!ye&&!b.current&&!(u&&j.length>0&&j[j.length-1]?.user?.text?.trim()===u.trim())&&s.jsxs("div",{className:"session-turn",children:[s.jsx(De,{text:u||"",blocks:O.map(e=>({type:"image",content:e})),t:m}),!c&&s.jsx("div",{className:"mt-3 mb-5 animate-in",children:s.jsx(Ue,{className:"text-fg-5"})})]}),c&&s.jsxs("div",{className:"mb-6",children:[!u&&!O.length&&s.jsx(he,{agent:r.agent||"",meta:$,model:r.model?Y(r.model):void 0,effort:_}),(u||O.length>0)&&s.jsx(he,{agent:r.agent||"",meta:$,model:r.model?Y(r.model):void 0,effort:_}),s.jsx(_e,{stream:c,t:m})]}),s.jsx("div",{className:"h-4"})]})}),s.jsx($e,{session:r,workdir:d,onStreamQueued:fe,onSendStart:oe,onSessionChange:U,t:m,streamPhase:Se,streamTaskId:Te,queuedTaskId:Re,pendingPrompt:u,onRecall:Ie,onSteer:Oe,editDraft:ve,onEditDraftConsumed:()=>ae(null)})]})});export{Ze as SessionPanel};
1
+ import{r as t,j as s}from"./react-vendor-DTcmqLiz.js";import{u as de,b as be,g as je,s as Le,a as L,S as ge,j as Y}from"./index-D5sKCspB.js";import{l as He,n as me,m as Ee,a as Ne,p as Pe,u as Ce,b as Me,T as we,U as De,c as Ue,d as he,L as _e,I as $e}from"./index-Cg6dJMex.js";import"./router-emLofBBH.js";import"./Select-D6Uav_-v.js";import"./Modal-CtsiLdVr.js";import"./BrandIcon-BoMxvhBf.js";import"./DirBrowser-B9mMMFZi.js";import"./markdown-DMQUjobV.js";const F=12,pe=160,Ae=96,qe=20,T=new Map;function Be(R,r){return`${R}:${r}`}function Qe(R,r){for(T.delete(R),T.set(R,r);T.size>qe;)T.delete(T.keys().next().value)}const Ze=t.memo(function({session:r,workdir:d,active:J=!0,onSessionChange:U,initialPendingPrompt:H,onPendingPromptConsumed:Z}){const ee=de(e=>e.locale),_=de(e=>e.agentStatus?.agents?.find(n=>n.agent===r.agent)?.selectedEffort??null),m=t.useMemo(()=>be(ee),[ee]),$=je(r.agent||""),te=Le(r),[a,A]=t.useState(null),[q,re]=t.useState(!0),[y,ne]=t.useState(!1),[c,v]=t.useState(null),[E,I]=t.useState(!1),[Se,B]=t.useState(null),[xe,se]=t.useState(0),[Te,Q]=t.useState(null),[Re,N]=t.useState(null),[u,K]=t.useState(null),[O,le]=t.useState([]),[ye,X]=t.useState(!1),[ve,ae]=t.useState(null),z=t.useRef([]),ue=t.useRef(c),ce=t.useRef(E);ue.current=c,ce.current=E;const h=t.useRef(null),P=t.useRef(null),k=t.useRef(!0),p=t.useRef(!1),G=t.useRef(!1),V=t.useRef(!1),S=t.useRef(!1),b=t.useRef(!1),W=t.useRef(!1);t.useEffect(()=>{W.current||!H||(W.current=!0,K(H),S.current=!0,se(e=>e+1),Z?.())},[H,Z]);const f=t.useCallback(()=>{K(null),le(e=>{for(const n of e)URL.revokeObjectURL(n);return[]}),z.current=[],X(!1)},[]),oe=t.useCallback((e,n)=>{for(const i of z.current)URL.revokeObjectURL(i);K(e||null);const l=n||[];le(l),z.current=l,X(!!ue.current||ce.current)},[]),C=t.useCallback(async(e,n={})=>{try{const l=await He({workdir:d,agent:r.agent||"",sessionId:r.sessionId,rich:!0,turnOffset:e.turnOffset,turnLimit:e.turnLimit,lastNTurns:e.lastNTurns},{force:n.force});return l.ok?me(l):null}catch{return null}},[d,r.agent,r.sessionId]),o=t.useCallback(async({keepOlder:e,force:n=!1})=>{if(G.current)return!1;G.current=!0;try{const l=await C({turnOffset:0,turnLimit:F},{force:n});return l?(A(i=>!i||!e?l:Ee(i,l)),b.current&&(b.current=!1,f()),!0):!1}finally{G.current=!1}},[C,f]),M=t.useCallback(async()=>{if(!a?.hasOlder||V.current)return;const e=h.current;e&&(P.current={scrollHeight:e.scrollHeight,scrollTop:e.scrollTop}),V.current=!0,ne(!0);try{const n=await C({turnOffset:Math.max(0,a.totalTurns-a.startTurn),turnLimit:F});n?A(l=>l?Ne(l,n):n):P.current=null}finally{V.current=!1,ne(!1)}},[C,a]),w=t.useRef(null),x=t.useCallback(e=>{if(e?.sessionId&&e.sessionId!==r.sessionId){U?.({agent:r.agent||"",sessionId:e.sessionId,workdir:d});return}if(!e){const n=w.current;v(null),I(!1),n==="streaming"?(k.current&&(p.current=!0),b.current=!0,o({keepOlder:!0,force:!0})):n==="done"?f():n===null&&S.current&&o({keepOlder:!0,force:!0}),S.current=!1,Q(null),B(null),N(null),w.current=null;return}B(e.phase),Q(e.taskId||null),N(e.queuedTaskId||null),e.phase==="streaming"?(v({phase:"streaming",text:e.text||"",thinking:e.thinking||"",activity:e.activity,plan:e.plan??null}),I(!0),e.queuedTaskId||X(!1),k.current&&(p.current=!0)):e.phase==="queued"?(v(null),I(!1)):e.phase==="done"&&(v(null),I(!1),w.current!=="done"&&(k.current&&(p.current=!0),e.queuedTaskId||(b.current=!0),o({keepOlder:!0,force:!0})),e.queuedTaskId||(S.current=!1)),w.current=e.phase},[f,o,r.sessionId,r.agent,U,d]),fe=t.useCallback(()=>{S.current=!0,se(e=>e+1)},[]),Ie=t.useCallback(async e=>{try{await L.recallSessionMessage(e),f(),N(n=>n===e?null:n),Q(n=>n===e?null:n)}catch{}},[f]),Oe=t.useCallback(async e=>{try{await L.steerSession(e)}catch{}},[]),D=Be(r.agent||"",r.sessionId);t.useEffect(()=>{let e=!1;const n=Pe({workdir:d,agent:r.agent||"",sessionId:r.sessionId,rich:!0,turnOffset:0,turnLimit:F},{allowStale:!0}),l=!!H&&!W.current,i=n?.ok?me(n):T.get(D)||null;return re(l?!1:!i),A(i),v(null),I(!1),B(null),N(null),k.current=!0,p.current=!0,l||o({keepOlder:!1,force:!0}).finally(()=>{e||re(!1)}),()=>{e=!0}},[o,r.agent,r.sessionId,d,D]),t.useEffect(()=>{a&&a.turns.length>0&&Qe(D,a)},[D,a]),t.useEffect(()=>{J&&o({keepOlder:!0,force:!0})},[J,o]);const ie=t.useRef(`${r.agent}:${r.sessionId}`);ie.current=`${r.agent}:${r.sessionId}`,Ce("stream-update",t.useCallback(e=>{e.key===ie.current&&x(e.snapshot??null)},[x])),t.useEffect(()=>{let e=!0;return L.getSessionStreamState(r.agent||"",r.sessionId).then(n=>{e&&x(n.state)}).catch(()=>{}),()=>{e=!1}},[x,r.agent,r.sessionId,xe]),Me(t.useCallback(()=>{L.getSessionStreamState(r.agent||"",r.sessionId).then(e=>{x(e.state)}).catch(()=>{}),o({keepOlder:!0,force:!0})},[x,r.agent,r.sessionId,o])),t.useEffect(()=>{te!=="running"&&!E&&!c&&(f(),S.current=!1)},[te,E,c,f]),t.useLayoutEffect(()=>{const e=P.current,n=h.current;!e||!n||(P.current=null,n.scrollTop=e.scrollTop+(n.scrollHeight-e.scrollHeight))},[a?.turns.length]),t.useLayoutEffect(()=>{if(!p.current)return;const e=h.current;e&&(p.current=!1,e.scrollTop=e.scrollHeight)},[a?.turns.length,c]),t.useLayoutEffect(()=>{if(!u)return;const e=h.current;e&&(e.scrollTop=e.scrollHeight)},[u]),t.useEffect(()=>{if(!a?.hasOlder||q||y)return;const e=h.current;e&&e.scrollHeight<=e.clientHeight+pe&&M()},[a?.hasOlder,a?.turns.length,M,q,y]);const ke=t.useCallback(()=>{const e=h.current;if(!e)return;const n=e.scrollHeight-e.scrollTop-e.clientHeight;k.current=n<=Ae,e.scrollTop<=pe&&M()},[M]),g=a?.turns||[],j=t.useMemo(()=>{if(!c||!g.length)return g;const e=g[g.length-1];return!e.assistant||u&&e.user?.text?.trim()!==u.trim()?g:[...g.slice(0,-1),{...e,assistant:null}]},[g,c,u]);return s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsx("div",{ref:h,onScroll:ke,className:"flex-1 overflow-y-auto overscroll-contain",children:q?s.jsx("div",{className:"flex items-center justify-center py-20",children:s.jsx(ge,{className:"h-5 w-5 text-fg-4"})}):j.length===0&&!u&&!O.length&&!c?s.jsx("div",{className:"py-20 text-center text-[13px] text-fg-5",children:m("hub.noMessages")}):s.jsxs("div",{className:"max-w-[900px] mx-auto px-6 py-6 space-y-0",children:[(a?.hasOlder||y)&&s.jsxs("div",{className:"mb-4 flex items-center justify-center gap-2 text-[11px] text-fg-5",children:[y?s.jsx(ge,{className:"h-3 w-3 text-fg-5"}):s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-fg-5/35"}),s.jsx("span",{children:m(y?"hub.loadingOlderTurns":"hub.loadOlderTurnsHint")})]}),j.map((e,n)=>s.jsx(we,{turn:e,agent:r.agent||"",meta:$,model:r.model?Y(r.model):void 0,effort:_,t:m,onResend:l=>{p.current=!0,oe(l),L.sendSessionMessage(d,r.agent||"",r.sessionId,l).then(i=>{i.ok&&fe()}).catch(()=>{f()})},onEdit:l=>ae(l)},`${a?.startTurn||0}:${n}`)),(u||O.length>0)&&!ye&&!b.current&&!(u&&j.length>0&&j[j.length-1]?.user?.text?.trim()===u.trim())&&s.jsxs("div",{className:"session-turn",children:[s.jsx(De,{text:u||"",blocks:O.map(e=>({type:"image",content:e})),t:m}),!c&&s.jsx("div",{className:"mt-3 mb-5 animate-in",children:s.jsx(Ue,{className:"text-fg-5"})})]}),c&&s.jsxs("div",{className:"mb-6",children:[!u&&!O.length&&s.jsx(he,{agent:r.agent||"",meta:$,model:r.model?Y(r.model):void 0,effort:_}),(u||O.length>0)&&s.jsx(he,{agent:r.agent||"",meta:$,model:r.model?Y(r.model):void 0,effort:_}),s.jsx(_e,{stream:c,t:m})]}),s.jsx("div",{className:"h-4"})]})}),s.jsx($e,{session:r,workdir:d,onStreamQueued:fe,onSendStart:oe,onSessionChange:U,t:m,streamPhase:Se,streamTaskId:Te,queuedTaskId:Re,pendingPrompt:u,onRecall:Ie,onSteer:Oe,editDraft:ve,onEditDraftConsumed:()=>ae(null)})]})});export{Ze as SessionPanel};
@@ -1 +1 @@
1
- import{j as s,r as j}from"./react-vendor-DTcmqLiz.js";import{m as f,c as d,o as b,u as g,b as w,B as k}from"./index-BPyYJAu2.js";import{S as u}from"./shared-Diw6OFf-.js";import"./router-emLofBBH.js";function h(e){switch(e){case"ok":return"text-emerald-200";case"warn":return"text-amber-200";case"err":return"text-red-200";default:return"text-fg-2"}}function P(e){return e>=85?"bg-red-500 shadow-[0_0_8px_var(--th-err-glow)]":e>=65?"bg-amber-500 shadow-[0_0_8px_var(--th-warn-glow)]":"bg-primary shadow-[0_0_8px_var(--th-glow-a)]"}function m(e){return Number.isFinite(e??NaN)?Math.max(0,Math.min(100,Number(e))):null}function y(e){return Number.isFinite(e??NaN)?Number(e).toFixed(2):null}function $(e){return e?[e.hostName||"—",e.platform,e.arch].filter(Boolean).join(" · "):""}function S(e,t){if(!e)return[];const a=e.totalMem||0,i=e.memoryUsed||a-(e.freeMem||0),r=m(e.memoryPercent||(a>0?i/a*100:0)),n=m(e.cpuUsage?.usedPercent),l=e.loadAverage||null,o=y(l?.one),v=y(l?.five),N=y(l?.fifteen),x=m(l?l.one/Math.max(e.cpuCount||1,1)*100:null),p=[{key:"cpu",label:t("sessions.cpu"),value:n!=null?`${n.toFixed(0)}%`:`${e.cpuCount} cores`,detail:[`${e.cpuCount} cores`,e.cpuModel||""].filter(Boolean),tone:n!=null&&n>=85?"warn":"ok",progressPercent:n},...o&&v&&N?[{key:"cpu-load",label:t("system.cpuLoad"),value:`1m ${o}`,detail:[`5m ${v}`,`15m ${N}`],tone:x!=null&&x>=85?"warn":"muted",progressPercent:x}]:[],{key:"memory",label:t("sessions.memory"),value:`${b(i)} / ${b(a)}`,detail:r!=null?`${r.toFixed(0)}%`:void 0,tone:r!=null&&r>=85?"warn":"ok",progressPercent:r}];if(e.disk){const c=m(parseFloat(String(e.disk.percent).replace("%","")));p.push({key:"disk",label:t("sessions.disk"),value:`${e.disk.used} / ${e.disk.total}`,detail:e.disk.percent,tone:c!=null&&c>=85?"warn":"muted",progressPercent:c})}else if(e.battery){const c=m(parseFloat(String(e.battery.percent).replace("%","")));p.push({key:"battery",label:t("sessions.battery"),value:e.battery.percent,detail:e.battery.state,tone:c!=null&&c<=20?"warn":"muted",progressPercent:c})}return p}function F({items:e,loading:t,compact:a,className:i}){if(t){const r=a?2:4;return s.jsx("div",{className:d("grid gap-3 sm:grid-cols-2 xl:grid-cols-3",i),children:Array.from({length:r},(n,l)=>s.jsxs(u,{className:"space-y-3 !p-4",children:[s.jsx(f,{className:"h-3 w-14"}),s.jsx(f,{className:"h-5 w-24"}),s.jsx(f,{className:"h-2 w-full"})]},l))})}return s.jsx("div",{className:d("grid gap-3 sm:grid-cols-2 xl:grid-cols-3",i),children:e.map(r=>s.jsxs(u,{className:d("space-y-2.5 !p-4",a&&"!p-3.5"),children:[s.jsx("div",{className:"text-[10px] uppercase tracking-[0.14em] text-fg-5",children:r.label}),s.jsx("div",{className:d("text-[13px] font-medium leading-snug",h(r.tone),r.mono&&"font-mono text-[12px]"),children:r.value}),Array.isArray(r.detail)?s.jsx("div",{className:"space-y-1 text-[10px] leading-relaxed text-fg-5",children:r.detail.map(n=>s.jsx("div",{children:n},n))}):r.detail?s.jsx("div",{className:"text-[10px] leading-relaxed text-fg-5",children:r.detail}):null,r.progressPercent!=null&&s.jsx("div",{className:"h-1 overflow-hidden rounded-full bg-panel",children:s.jsx("div",{className:d("h-1 rounded-full transition-all duration-500",P(r.progressPercent)),style:{width:`${r.progressPercent.toFixed(0)}%`}})})]},r.key))})}function B({onOpenWorkdir:e}){const t=g(o=>o.state),a=g(o=>o.host),i=g(o=>o.locale),r=j.useMemo(()=>w(i),[i]),n=t?.bot?.workdir||t?.runtimeWorkdir||t?.config.workdir||"",l=$(a);return s.jsxs("div",{className:"animate-in space-y-3",children:[s.jsx(u,{className:"space-y-3",children:s.jsxs("div",{className:"flex flex-col gap-2 lg:flex-row lg:items-start lg:justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-base font-semibold tracking-tight text-fg",children:r("config.workdir")}),s.jsx("div",{className:"mt-0.5 text-[13px] leading-relaxed text-fg-4",children:r("config.workspaceHint")}),s.jsx("div",{className:"mt-2.5 break-words font-mono text-[12px] leading-relaxed text-fg-2",children:n||r("sidebar.notSet")})]}),s.jsx(k,{variant:"outline",size:"sm",onClick:e,children:r("sidebar.switchDir")})]})}),s.jsxs(u,{className:"space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-2 lg:flex-row lg:items-start lg:justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-base font-semibold tracking-tight text-fg",children:r("app.systemInfo")}),s.jsx("div",{className:"mt-0.5 text-[13px] leading-relaxed text-fg-4",children:l||r("status.loading")})]}),s.jsxs("div",{className:"text-[12px] leading-relaxed text-fg-5",children:[t?.version?`Pikiclaw v${t.version}`:"Pikiclaw",t?.nodeVersion?` · Node ${t.nodeVersion}`:""]})]}),s.jsx(F,{items:S(a,r),loading:!a})]})]})}export{B as SystemTab};
1
+ import{j as s,r as j}from"./react-vendor-DTcmqLiz.js";import{m as f,c as d,o as b,u as g,b as w,B as k}from"./index-D5sKCspB.js";import{S as u}from"./shared-6sWbm5Tj.js";import"./router-emLofBBH.js";function h(e){switch(e){case"ok":return"text-emerald-200";case"warn":return"text-amber-200";case"err":return"text-red-200";default:return"text-fg-2"}}function P(e){return e>=85?"bg-red-500 shadow-[0_0_8px_var(--th-err-glow)]":e>=65?"bg-amber-500 shadow-[0_0_8px_var(--th-warn-glow)]":"bg-primary shadow-[0_0_8px_var(--th-glow-a)]"}function m(e){return Number.isFinite(e??NaN)?Math.max(0,Math.min(100,Number(e))):null}function y(e){return Number.isFinite(e??NaN)?Number(e).toFixed(2):null}function $(e){return e?[e.hostName||"—",e.platform,e.arch].filter(Boolean).join(" · "):""}function S(e,t){if(!e)return[];const a=e.totalMem||0,i=e.memoryUsed||a-(e.freeMem||0),r=m(e.memoryPercent||(a>0?i/a*100:0)),n=m(e.cpuUsage?.usedPercent),l=e.loadAverage||null,o=y(l?.one),v=y(l?.five),N=y(l?.fifteen),x=m(l?l.one/Math.max(e.cpuCount||1,1)*100:null),p=[{key:"cpu",label:t("sessions.cpu"),value:n!=null?`${n.toFixed(0)}%`:`${e.cpuCount} cores`,detail:[`${e.cpuCount} cores`,e.cpuModel||""].filter(Boolean),tone:n!=null&&n>=85?"warn":"ok",progressPercent:n},...o&&v&&N?[{key:"cpu-load",label:t("system.cpuLoad"),value:`1m ${o}`,detail:[`5m ${v}`,`15m ${N}`],tone:x!=null&&x>=85?"warn":"muted",progressPercent:x}]:[],{key:"memory",label:t("sessions.memory"),value:`${b(i)} / ${b(a)}`,detail:r!=null?`${r.toFixed(0)}%`:void 0,tone:r!=null&&r>=85?"warn":"ok",progressPercent:r}];if(e.disk){const c=m(parseFloat(String(e.disk.percent).replace("%","")));p.push({key:"disk",label:t("sessions.disk"),value:`${e.disk.used} / ${e.disk.total}`,detail:e.disk.percent,tone:c!=null&&c>=85?"warn":"muted",progressPercent:c})}else if(e.battery){const c=m(parseFloat(String(e.battery.percent).replace("%","")));p.push({key:"battery",label:t("sessions.battery"),value:e.battery.percent,detail:e.battery.state,tone:c!=null&&c<=20?"warn":"muted",progressPercent:c})}return p}function F({items:e,loading:t,compact:a,className:i}){if(t){const r=a?2:4;return s.jsx("div",{className:d("grid gap-3 sm:grid-cols-2 xl:grid-cols-3",i),children:Array.from({length:r},(n,l)=>s.jsxs(u,{className:"space-y-3 !p-4",children:[s.jsx(f,{className:"h-3 w-14"}),s.jsx(f,{className:"h-5 w-24"}),s.jsx(f,{className:"h-2 w-full"})]},l))})}return s.jsx("div",{className:d("grid gap-3 sm:grid-cols-2 xl:grid-cols-3",i),children:e.map(r=>s.jsxs(u,{className:d("space-y-2.5 !p-4",a&&"!p-3.5"),children:[s.jsx("div",{className:"text-[10px] uppercase tracking-[0.14em] text-fg-5",children:r.label}),s.jsx("div",{className:d("text-[13px] font-medium leading-snug",h(r.tone),r.mono&&"font-mono text-[12px]"),children:r.value}),Array.isArray(r.detail)?s.jsx("div",{className:"space-y-1 text-[10px] leading-relaxed text-fg-5",children:r.detail.map(n=>s.jsx("div",{children:n},n))}):r.detail?s.jsx("div",{className:"text-[10px] leading-relaxed text-fg-5",children:r.detail}):null,r.progressPercent!=null&&s.jsx("div",{className:"h-1 overflow-hidden rounded-full bg-panel",children:s.jsx("div",{className:d("h-1 rounded-full transition-all duration-500",P(r.progressPercent)),style:{width:`${r.progressPercent.toFixed(0)}%`}})})]},r.key))})}function B({onOpenWorkdir:e}){const t=g(o=>o.state),a=g(o=>o.host),i=g(o=>o.locale),r=j.useMemo(()=>w(i),[i]),n=t?.bot?.workdir||t?.runtimeWorkdir||t?.config.workdir||"",l=$(a);return s.jsxs("div",{className:"animate-in space-y-3",children:[s.jsx(u,{className:"space-y-3",children:s.jsxs("div",{className:"flex flex-col gap-2 lg:flex-row lg:items-start lg:justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-base font-semibold tracking-tight text-fg",children:r("config.workdir")}),s.jsx("div",{className:"mt-0.5 text-[13px] leading-relaxed text-fg-4",children:r("config.workspaceHint")}),s.jsx("div",{className:"mt-2.5 break-words font-mono text-[12px] leading-relaxed text-fg-2",children:n||r("sidebar.notSet")})]}),s.jsx(k,{variant:"outline",size:"sm",onClick:e,children:r("sidebar.switchDir")})]})}),s.jsxs(u,{className:"space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-2 lg:flex-row lg:items-start lg:justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-base font-semibold tracking-tight text-fg",children:r("app.systemInfo")}),s.jsx("div",{className:"mt-0.5 text-[13px] leading-relaxed text-fg-4",children:l||r("status.loading")})]}),s.jsxs("div",{className:"text-[12px] leading-relaxed text-fg-5",children:[t?.version?`Pikiclaw v${t.version}`:"Pikiclaw",t?.nodeVersion?` · Node ${t.nodeVersion}`:""]})]}),s.jsx(F,{items:S(a,r),loading:!a})]})]})}export{B as SystemTab};