pikiclaw 0.3.2 → 0.3.3

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.
Files changed (83) hide show
  1. package/dashboard/dist/assets/AgentTab-CU6E6n9q.js +1 -0
  2. package/dashboard/dist/assets/{BrandIcon-B9y9j0jh.js → BrandIcon-D4tX23F9.js} +1 -1
  3. package/dashboard/dist/assets/{DirBrowser-D4Y8bm_k.js → DirBrowser-D8Y8BdoJ.js} +1 -1
  4. package/dashboard/dist/assets/{ExtensionsTab-DvPbSlc8.js → ExtensionsTab-BR0koG7B.js} +1 -1
  5. package/dashboard/dist/assets/{IMAccessTab-AL06xxWE.js → IMAccessTab-rIWYW8aB.js} +1 -1
  6. package/dashboard/dist/assets/{Modals-CSIL3K6j.js → Modals-2tsObnv7.js} +1 -1
  7. package/dashboard/dist/assets/{PermissionsTab-4L-PgQ1X.js → PermissionsTab-KrbCXbG9.js} +1 -1
  8. package/dashboard/dist/assets/{SessionPanel-DTILWbVA.js → SessionPanel-BJMpjCVF.js} +1 -1
  9. package/dashboard/dist/assets/{SessionsTab-BzDzSqml.js → SessionsTab-CHEsq50k.js} +2 -2
  10. package/dashboard/dist/assets/{SystemTab-D_Q8vDMf.js → SystemTab-t4ZjPpl3.js} +1 -1
  11. package/dashboard/dist/assets/index-BRsMNLir.css +1 -0
  12. package/dashboard/dist/assets/index-C6rqoQ_Q.js +3 -0
  13. package/dashboard/dist/assets/{shared-rdDL3t6R.js → shared-DYK11EN0.js} +1 -1
  14. package/dashboard/dist/index.html +2 -2
  15. package/dist/{agent-auto-update.js → agent/auto-update.js} +154 -13
  16. package/dist/{driver-claude.js → agent/drivers/claude.js} +13 -11
  17. package/dist/{driver-codex.js → agent/drivers/codex.js} +5 -5
  18. package/dist/{driver-gemini.js → agent/drivers/gemini.js} +3 -3
  19. package/dist/agent/index.js +33 -0
  20. package/dist/{mcp-bridge.js → agent/mcp/bridge.js} +8 -8
  21. package/dist/{mcp-playwright-proxy.js → agent/mcp/playwright-proxy.js} +5 -2
  22. package/dist/{mcp-session-server.js → agent/mcp/session-server.js} +1 -1
  23. package/dist/{tools → agent/mcp/tools}/types.js +4 -1
  24. package/dist/{agent-npm.js → agent/npm.js} +11 -0
  25. package/dist/{code-agent.js → agent/session.js} +63 -783
  26. package/dist/{project-skills.js → agent/skills.js} +3 -0
  27. package/dist/agent/stream.js +435 -0
  28. package/dist/agent/types.js +13 -0
  29. package/dist/agent/utils.js +366 -0
  30. package/dist/{bot.js → bot/bot.js} +15 -368
  31. package/dist/{bot-command-ui.js → bot/command-ui.js} +4 -1
  32. package/dist/{bot-commands.js → bot/commands.js} +6 -6
  33. package/dist/bot/host.js +192 -0
  34. package/dist/{human-loop-codex.js → bot/human-loop-codex.js} +3 -0
  35. package/dist/{human-loop.js → bot/human-loop.js} +3 -0
  36. package/dist/{bot-menu.js → bot/menu.js} +3 -0
  37. package/dist/{bot-orchestration.js → bot/orchestration.js} +5 -2
  38. package/dist/{bot-render-shared.js → bot/render-shared.js} +2 -2
  39. package/dist/{session-hub.js → bot/session-hub.js} +3 -3
  40. package/dist/{session-status.js → bot/session-status.js} +3 -0
  41. package/dist/{bot-streaming.js → bot/streaming.js} +3 -0
  42. package/dist/browser-profile.js +4 -1
  43. package/dist/{bot-feishu.js → channels/feishu/bot.js} +16 -16
  44. package/dist/{channel-feishu.js → channels/feishu/channel.js} +4 -4
  45. package/dist/{feishu-markdown.js → channels/feishu/markdown.js} +3 -0
  46. package/dist/{bot-feishu-render.js → channels/feishu/render.js} +8 -8
  47. package/dist/{channel-states.js → channels/states.js} +3 -0
  48. package/dist/{bot-telegram.js → channels/telegram/bot.js} +17 -17
  49. package/dist/{channel-telegram.js → channels/telegram/channel.js} +3 -3
  50. package/dist/{bot-telegram-directory.js → channels/telegram/directory.js} +5 -2
  51. package/dist/{bot-telegram-live-preview.js → channels/telegram/live-preview.js} +5 -2
  52. package/dist/{bot-telegram-render.js → channels/telegram/render.js} +6 -3
  53. package/dist/{weixin-api.js → channels/weixin/api.js} +4 -1
  54. package/dist/{bot-weixin.js → channels/weixin/bot.js} +9 -6
  55. package/dist/{channel-weixin.js → channels/weixin/channel.js} +6 -3
  56. package/dist/{cli-channels.js → cli/channels.js} +3 -0
  57. package/dist/{cli.js → cli/main.js} +14 -14
  58. package/dist/{onboarding.js → cli/onboarding.js} +4 -1
  59. package/dist/{run.js → cli/run.js} +5 -5
  60. package/dist/{setup-wizard.js → cli/setup-wizard.js} +5 -2
  61. package/dist/{runtime-config.js → core/config/runtime-config.js} +4 -1
  62. package/dist/{user-config.js → core/config/user-config.js} +4 -1
  63. package/dist/{config-validation.js → core/config/validation.js} +7 -4
  64. package/dist/{logging.js → core/logging.js} +3 -0
  65. package/dist/{process-control.js → core/process-control.js} +3 -0
  66. package/dist/core/utils.js +178 -0
  67. package/dist/{version.js → core/version.js} +4 -1
  68. package/dist/{dashboard-platform.js → dashboard/platform.js} +2 -2
  69. package/dist/{routes → dashboard/routes}/agents.js +58 -9
  70. package/dist/{routes → dashboard/routes}/config.js +12 -15
  71. package/dist/{routes → dashboard/routes}/sessions.js +6 -9
  72. package/dist/{runtime.js → dashboard/runtime.js} +8 -8
  73. package/dist/{server.js → dashboard/server.js} +3 -7
  74. package/dist/{session-control.js → dashboard/session-control.js} +3 -0
  75. package/package.json +3 -3
  76. package/dashboard/dist/assets/AgentTab-DarwJ-6D.js +0 -1
  77. package/dashboard/dist/assets/index-BxuA85oI.js +0 -3
  78. package/dashboard/dist/assets/index-NO1v_zlB.css +0 -1
  79. /package/dist/{agent-driver.js → agent/driver.js} +0 -0
  80. /package/dist/{tools → agent/mcp/tools}/desktop.js +0 -0
  81. /package/dist/{tools → agent/mcp/tools}/workspace.js +0 -0
  82. /package/dist/{channel-base.js → channels/base.js} +0 -0
  83. /package/dist/{constants.js → core/constants.js} +0 -0
@@ -0,0 +1 @@
1
+ import{r as o,j as e}from"./react-vendor-C7Sl8SE7.js";import{u as W,a as fe,b as y,h as L,e as E,M as ue,g as me,L as B,l as z,E as xe,S as K,B as X,c as pe}from"./index-C6rqoQ_Q.js";import{B as ge}from"./BrandIcon-D4tX23F9.js";import{S as Y}from"./shared-DYK11EN0.js";import"./router-Rwafsu7Y.js";const he=["claude","codex","gemini"];function ve(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 be(t,s){const n=t.filter(r=>r.installed);return(n.length?n:t).map(r=>({value:r.agent,label:`${L(r.agent).label} · ${r.installed?r.version||s.installed:s.notInstalled}`}))}function je(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 Ne(t){return t?xe[t.agent].map(s=>({value:s,label:s})):[]}function Me(t,s){if(!t.models.length)return s.noModel;const n=t.selectedModel?t.models.find(r=>r.id===t.selectedModel):t.models[0],d=n?.alias||n?.id||s.noModel;return`${s.currentModelPrefix}: ${d} · ${t.models.length} ${s.availableModelsSuffix}`}function ee(t){return t?t.alias||t.id:"—"}function te(t,s){if(!t.models.length)return s.noModel;const n=t.selectedModel?t.models.find(d=>d.id===t.selectedModel):t.models[0];return ee(n)}function ke(t,s=4){const n=new Set;return t.models.map(r=>({key:r.id,label:ee(r)})).filter(r=>n.has(r.key)?!1:(n.add(r.key),!0)).slice(0,s)}function D(t,s){t({defaultAgent:s.defaultAgent,agents:s.agents})}function Z(t,s){return{agent:t?.agent||s,model:t?.selectedModel||"",effort:t?.selectedEffort||""}}function P({label:t,value:s,hint:n,loading:d=!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:[d&&e.jsx(K,{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 Ee({agent:t,copy:s,t:n,installing:d,onInstall:r,updatingAgent:j,checkingAgent:F,onUpdate:T,onCheckUpdate:I,loading:c=!1}){const x=L(t.agent),H=Me(t,s),A=te(t,s),U=x.advantageKey?n(x.advantageKey):"—",g=ke(t),h=Math.max(0,t.models.length-g.length),i=t.selectedEffort||s.noEffort,M=t.version||s.noVersion,w=c?n("status.loading"):t.installed?s.installed:s.notInstalled,u=c?"muted":t.installed?"ok":"warn",v=c?n("status.loading"):t.installed?s.readyHint:s.installHint,k=c?n("status.loading"):A,p=c?n("status.loading"):i,G=c?n("status.loading"):U,V=c?n("status.loading"):H;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(ge,{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:x.label}),t.isDefault&&e.jsx(X,{variant:"accent",children:s.defaultBadge})]}),e.jsxs("div",{className:"mt-1 text-[12px] leading-relaxed text-fg-5",children:[s.version,": ",M,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(X,{variant:u,children:[c&&e.jsx(K,{className:"h-3 w-3"}),w]})}),e.jsx("div",{className:"mt-1.5 text-[12px] leading-relaxed text-fg-5",children:v})]}),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:k})]}),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&&g.length>0?g.map(S=>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:S.key,children:e.jsx("span",{className:"truncate",children:S.label})},S.key)):e.jsx("span",{className:"text-[12px] text-fg-5",children:c?n("status.loading"):s.noModel}),!c&&h>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(h)})]}),e.jsx("div",{className:"mt-1.5 text-[12px] leading-relaxed text-fg-5",children:V})]}),e.jsxs("div",{className:pe("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(K,{className:"h-3 w-3"}),n("status.loading")]}),!c&&!t.installed&&e.jsx(E,{variant:"outline",size:"sm",disabled:d,onClick:()=>r(t),children:d?s.installing:s.install}),!c&&t.installed&&t.updateAvailable&&e.jsx(E,{variant:"primary",size:"sm",disabled:j,onClick:()=>T(t),children:j?s.updating:s.update}),!c&&t.installed&&!t.updateAvailable&&e.jsx(E,{variant:"ghost",size:"sm",disabled:F,onClick:()=>I(t),children:F?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 De(){const t=W(a=>a.locale),s=W(a=>a.toast),n=o.useMemo(()=>fe(t),[t]),d=ve(t),[r,j]=o.useState(null),[F,T]=o.useState(!0),[I,c]=o.useState(null),[x,H]=o.useState(!1),[A,U]=o.useState(null),[g,h]=o.useState(!1),[i,M]=o.useState({agent:"codex",model:"",effort:""}),w=o.useRef(!1),u=o.useCallback(async()=>{w.current||T(!0);try{const a=await y.getAgentStatus();return D(j,a),c(null),w.current=!0,a}catch(a){const l=a instanceof Error?a.message:d.loadFailed;return c(l),w.current||s(l,!1),null}finally{T(!1)}},[d.loadFailed,s]);o.useEffect(()=>{u()},[u]);const v=o.useMemo(()=>{const a=r?.agents||[],l=new Map(a.map(f=>[f.agent,f]));return he.map(f=>{const C=l.get(f);if(C)return C;const b=L(f);return{agent:f,label:b.label,installed:!1,version:void 0,installCommand:void 0,selectedModel:null,selectedEffort:null,isDefault:r?.defaultAgent===f,models:[],usage:null}})},[r]),k=r?.defaultAgent||"codex",p=v.find(a=>a.agent===k)||null,V=v.filter(a=>a.installed).length>0,S=be(v,d),m=v.find(a=>a.agent===i.agent)||null,O=je(m),_=Ne(m),q=o.useCallback(async a=>{H(!0);try{const l=await y.updateRuntimeAgent(a);if(!l.ok)throw new Error(l.error||n("config.applyFailed"));return D(j,l),l}catch(l){const f=l instanceof Error?l.message:n("config.applyFailed");return s(f,!1),u(),null}finally{H(!1)}},[u,n,s]);o.useEffect(()=>{g&&M(Z(p,k))},[k,p,g]),o.useEffect(()=>{if(!g||!m)return;const a=m.selectedModel||"",l=!i.model||O.some(b=>b.value===i.model),f=m.selectedEffort||"",C=!i.effort||_.some(b=>b.value===i.effort);l&&C||M(b=>({...b,model:l?b.model:a,effort:C?b.effort:f}))},[g,i.effort,i.model,m,_,O]);const se=o.useCallback(a=>{const l=v.find(f=>f.agent===a);l?.installed&&M(Z(l,l.agent))},[v]),le=o.useCallback(async()=>{if(!m?.installed)return;const a={};if(i.agent!==k&&(a.defaultAgent=i.agent),i.model&&i.model!==(m.selectedModel||"")&&(a.agent=i.agent,a.model=i.model),i.effort&&i.effort!==(m.selectedEffort||"")&&(a.agent=i.agent,a.effort=i.effort),Object.keys(a).length===0){h(!1);return}await q(a)&&(s(d.defaultsSaved),h(!1))},[d.defaultsSaved,k,i.agent,i.effort,i.model,m,s,q]),ae=o.useCallback(async a=>{if(!A){U(a.agent);try{const l=await y.installAgent(a.agent);if(!l.ok)throw new Error(l.error||n("config.agentInstallFailed"));D(j,l),s(n("config.agentInstalled"))}catch(l){const f=l instanceof Error?l.message:n("config.agentInstallFailed");s(f,!1),u()}finally{U(l=>l===a.agent?null:l)}}},[A,u,n,s]),[$,J]=o.useState(null),[R,Q]=o.useState(null),ne=o.useCallback(async a=>{if(!$){J(a.agent);try{const l=await y.updateAgent(a.agent);if(!l.ok)throw new Error(l.error||n("config.agentInstallFailed"));D(j,l),s(d.upToDate)}catch(l){const f=l instanceof Error?l.message:d.updateFailed;s(f,!1),u()}finally{J(l=>l===a.agent?null:l)}}},[d.updateFailed,d.upToDate,u,n,s,$]),de=o.useCallback(async a=>{if(!R){Q(a.agent);try{const l=await y.checkAgentUpdate(a.agent);if(!l.ok)throw new Error(l.error||d.loadFailed);D(j,l)}catch(l){const f=l instanceof Error?l.message:d.loadFailed;s(f,!1),u()}finally{Q(l=>l===a.agent?null:l)}}},[R,d.loadFailed,u,s]),N=F&&!r,ie=N?n("status.loading"):p?L(p.agent).label:d.notInstalled,re=N?n("status.loading"):p?.installed?d.installed:d.notInstalled,oe=N?n("status.loading"):p?te(p,d):d.noModel,ce=N?n("status.loading"):p?.selectedEffort||d.noEffort;return e.jsxs("div",{className:"animate-in space-y-4",children:[e.jsx("section",{className:"space-y-3",children:e.jsxs(Y,{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(E,{variant:"secondary",onClick:()=>h(!0),disabled:x||!V,children:d.editDefaults})})]}),e.jsxs("div",{className:"grid gap-2.5 lg:grid-cols-3",children:[e.jsx(P,{label:d.defaultAgent,value:ie,hint:re,loading:N}),e.jsx(P,{label:d.defaultModel,value:oe,loading:N}),e.jsx(P,{label:d.defaultEffort,value:ce,loading:N})]})]})}),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:v.map(a=>e.jsx(Ee,{agent:a,copy:d,t:n,installing:A===a.agent,loading:N,onInstall:ae,updatingAgent:$===a.agent,checkingAgent:R===a.agent,onUpdate:ne,onCheckUpdate:de},a.agent))})]}),I&&e.jsx(Y,{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:I}),e.jsx(E,{variant:"outline",size:"sm",onClick:()=>{u()},children:n("sessions.retry")})]})}),e.jsxs(ue,{open:g,onClose:()=>h(!1),children:[e.jsx(me,{title:d.defaultsEditTitle,description:d.defaultsEditHint,onClose:()=>h(!1)}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(B,{children:d.defaultAgent}),e.jsx(z,{value:i.agent,options:S,onChange:se,disabled:x||!V,placeholder:d.notInstalled})]}),e.jsxs("div",{children:[e.jsx(B,{children:d.defaultModel}),e.jsx(z,{value:i.model,options:O,onChange:a=>M(l=>({...l,model:a})),disabled:x||!m?.installed||O.length===0,placeholder:d.noModel})]}),e.jsxs("div",{children:[e.jsx(B,{children:d.defaultEffort}),e.jsx(z,{value:i.effort,options:_,onChange:a=>M(l=>({...l,effort:a})),disabled:x||!m?.installed||_.length===0,placeholder:d.noEffort})]})]}),e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx(E,{variant:"ghost",onClick:()=>h(!1),children:n("modal.cancel")}),e.jsx(E,{variant:"primary",disabled:x||!m?.installed,onClick:()=>{le()},children:n(x?"config.validating":"modal.save")})]})]})]})}export{De as AgentTab,De as default};
@@ -1 +1 @@
1
- import{j as t}from"./react-vendor-C7Sl8SE7.js";import{c as s}from"./index-BxuA85oI.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-C7Sl8SE7.js";import{c as s}from"./index-C6rqoQ_Q.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-C7Sl8SE7.js";import{b as I,B as P,S as z}from"./index-BxuA85oI.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-C7Sl8SE7.js";import{b as I,B as P,S as z}from"./index-C6rqoQ_Q.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-C7Sl8SE7.js";import{u as p,a as B,b as R,e as g,B as w,S as N}from"./index-BxuA85oI.js";import{B as S}from"./BrandIcon-B9y9j0jh.js";import{a as k,b as C,c as b,d as y}from"./shared-rdDL3t6R.js";import"./router-Rwafsu7Y.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(k,{className:"xl:grid-cols-[minmax(0,235px)_minmax(240px,0.95fr)_minmax(0,1.1fr)_auto]",children:[s.jsx(C,{icon:s.jsx(S,{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(k,{className:"xl:grid-cols-[minmax(0,235px)_minmax(240px,0.95fr)_minmax(0,1.1fr)_auto]",children:[s.jsx(C,{icon:s.jsx(S,{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-C7Sl8SE7.js";import{u as p,a as B,b as R,e as g,B as w,S as N}from"./index-C6rqoQ_Q.js";import{B as S}from"./BrandIcon-D4tX23F9.js";import{a as k,b as C,c as b,d as y}from"./shared-DYK11EN0.js";import"./router-Rwafsu7Y.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(k,{className:"xl:grid-cols-[minmax(0,235px)_minmax(240px,0.95fr)_minmax(0,1.1fr)_auto]",children:[s.jsx(C,{icon:s.jsx(S,{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(k,{className:"xl:grid-cols-[minmax(0,235px)_minmax(240px,0.95fr)_minmax(0,1.1fr)_auto]",children:[s.jsx(C,{icon:s.jsx(S,{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-C7Sl8SE7.js";import{u as p,m as y,B as v,S as C,e as D}from"./index-BxuA85oI.js";import{B as A}from"./BrandIcon-B9y9j0jh.js";import{a as j,b as V,c as w,d as N}from"./shared-rdDL3t6R.js";import"./router-Rwafsu7Y.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-C7Sl8SE7.js";import{u as p,m as y,B as v,S as C,e as D}from"./index-C6rqoQ_Q.js";import{B as A}from"./BrandIcon-D4tX23F9.js";import{a as j,b as V,c as w,d as N}from"./shared-DYK11EN0.js";import"./router-Rwafsu7Y.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{r as a,j as e}from"./react-vendor-C7Sl8SE7.js";import{u as j,a as U,M as A,g as L,L as M,p as R,e as I,b as C,B as K}from"./index-BxuA85oI.js";import{D as X}from"./DirBrowser-D4Y8bm_k.js";import"./router-Rwafsu7Y.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,h){return d instanceof Error&&/timed out/i.test(d.message)?h("modal.requestTimeout"):h("modal.networkError")}function te({open:d,onClose:h}){const S=j(n=>n.state),c=j(n=>n.toast),B=j(n=>n.reloadUntil),t=j(n=>n.locale),s=a.useMemo(()=>U(t),[t]),[u,v]=a.useState(""),[g,b]=a.useState(""),[y,w]=a.useState(!1),[k,l]=a.useState(!1),[x,i]=a.useState(null),o=a.useRef(null),F=a.useRef(S);F.current=S,a.useEffect(()=>{d?(v(F.current?.config.telegramBotToken||""),b(F.current?.config.telegramAllowedChatIds||""),w(!1),i(null)):(o.current?.abort(),o.current=null,l(!1))},[d]),a.useEffect(()=>()=>{o.current?.abort(),o.current=null},[]);const m=async()=>{if(!u.trim()){c(s("modal.inputToken"),!1);return}o.current?.abort();const n=new AbortController;o.current=n,l(!0),i(null);let f=!1;try{const N=await C.validateTelegramConfig(u.trim(),g.trim(),{signal:n.signal,timeoutMs:12e3});if(!N.ok){i({ok:!1,text:"✗ "+(N.error||s("modal.validationFailed"))});return}const r=N.normalizedAllowedChatIds??g.trim();i({ok:!0,text:"✓ @"+(N.bot?.username||"bot")+(N.bot?.displayName?" ("+N.bot.displayName+")":"")});const p=new Set((S?.setupState?.channels||[]).filter(D=>(D.ready||D.configured)&&D.channel!=="telegram").map(D=>D.channel));if(p.add("telegram"),await C.saveConfig({telegramBotToken:u.trim(),telegramAllowedChatIds:r,channels:[...p]}),!await B(D=>{const q=D.setupState?.channels?.find(z=>z.channel==="telegram");return D.config.telegramBotToken===u.trim()&&(D.config.telegramAllowedChatIds||"")===r&&!!q?.ready},{attempts:10,intervalMs:350})){i({ok:!1,text:"✗ "+s("modal.refreshStateFailed")}),c(s("modal.refreshStateFailed"),!1);return}c(s("modal.tgSaved")),f=!0}catch(N){if(Q(N))return;const r=H(N,s);i({ok:!1,text:"✗ "+r}),c(r,!1)}finally{o.current===n&&(o.current=null),l(!1),f&&h()}},T=()=>{o.current?.abort(),o.current=null,h()};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:y?"text":"password",className:"flex-1 font-mono text-xs",placeholder:s("modal.pasteToken"),value:u,onChange:n=>v(n.target.value)}),e.jsx(I,{variant:"ghost",size:"sm",className:"!w-[34px] !p-0",onClick:()=>w(!y),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"})]})})]})]}),x&&e.jsx("div",{className:"text-xs",style:{color:x.ok?"var(--th-ok)":"var(--th-err)"},children:x.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:g,onChange:n=>b(n.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 se({open:d,onClose:h}){const S=j(m=>m.state),c=j(m=>m.toast),B=j(m=>m.reloadUntil),t=j(m=>m.locale),s=a.useMemo(()=>U(t),[t]),[u,v]=a.useState(""),[g,b]=a.useState(""),[y,w]=a.useState(!1),[k,l]=a.useState(null),x=a.useRef(null),i=a.useRef(S);i.current=S,a.useEffect(()=>{d?(v(i.current?.config.feishuAppId||""),b(i.current?.config.feishuAppSecret||""),l(null)):(x.current?.abort(),x.current=null,w(!1))},[d]),a.useEffect(()=>()=>{x.current?.abort(),x.current=null},[]);const o=async()=>{if(!u.trim()){c(s("modal.inputAppId"),!1);return}x.current?.abort();const m=new AbortController;x.current=m,w(!0),l(null);let T=!1;try{const n=await C.validateFeishuConfig(u.trim(),g.trim(),{signal:m.signal,timeoutMs:2e4});if(!n.ok){l({ok:!1,text:"✗ "+(n.error||s("modal.validationFailed"))});return}l({ok:!0,text:"✓ "+(n.app?.displayName||n.app?.appId||u.trim())});const f=new Set((S?.setupState?.channels||[]).filter(r=>(r.ready||r.configured)&&r.channel!=="feishu").map(r=>r.channel));if(f.add("feishu"),await C.saveConfig({feishuAppId:u.trim(),feishuAppSecret:g.trim(),channels:[...f]}),!await B(r=>{const p=r.setupState?.channels?.find(W=>W.channel==="feishu");return r.config.feishuAppId===u.trim()&&r.config.feishuAppSecret===g.trim()&&!!p?.ready},{attempts:10,intervalMs:350})){l({ok:!1,text:"✗ "+s("modal.refreshStateFailed")}),c(s("modal.refreshStateFailed"),!1);return}c(s("modal.feishuSaved")),T=!0}catch(n){if(Q(n))return;const f=H(n,s);l({ok:!1,text:"✗ "+f}),c(f,!1)}finally{x.current===m&&(x.current=null),w(!1),T&&h()}},F=()=>{x.current?.abort(),x.current=null,h()};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:g,onChange:m=>b(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:y,onClick:o,children:s(y?"modal.validating":"modal.validateSave")})]})]})}function ae({open:d,onClose:h}){const S=j(f=>f.state),c=j(f=>f.toast),B=j(f=>f.reloadUntil),t=j(f=>f.locale),s=a.useMemo(()=>U(t),[t]),[u,v]=a.useState(P),[g,b]=a.useState(!1),[y,w]=a.useState(""),[k,l]=a.useState(""),[x,i]=a.useState(null),o=a.useRef(null),F=a.useRef(S);F.current=S,a.useEffect(()=>{d?(v(F.current?.config.weixinBaseUrl||P),b(!1),w(""),l(""),i(null)):(o.current?.abort(),o.current=null,b(!1))},[d]),a.useEffect(()=>()=>{o.current?.abort(),o.current=null},[]);const m=()=>{o.current?.abort(),o.current=null,h()},T=a.useCallback(async(f,N,r)=>{for(;!f.signal.aborted;){const p=await C.waitWeixinLogin(N,r,{signal:f.signal,timeoutMs:45e3});if(!p.ok&&!p.connected)return i({ok:!1,text:"✗ "+(p.error||p.message||s("modal.validationFailed"))}),!1;if(p.qrcodeUrl&&w(p.qrcodeUrl),p.status==="scaned"?i({ok:!0,text:s("modal.weixinScanned")}):p.status==="expired"?i({ok:!0,text:s("modal.weixinQrRefreshed")}):p.connected||i({ok:!0,text:s("modal.weixinWaitingScan")}),!p.connected)continue;i({ok:!0,text:s("modal.weixinLoginSuccess")});const W=p.baseUrl||r,D=p.botToken||"",q=p.accountId||"",z=await C.validateWeixinConfig(W,D,q,{signal:f.signal,timeoutMs:12e3});if(!z.ok)return i({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):(i({ok:!1,text:"✗ "+s("modal.refreshStateFailed")}),c(s("modal.refreshStateFailed"),!1),!1)}return!1},[B,s,c]),n=async()=>{if(!u.trim()){c(s("modal.inputWeixinBaseUrl"),!1);return}o.current?.abort();const f=new AbortController;o.current=f,b(!0),w(""),l(""),i(null);let N=!1;try{const r=await C.startWeixinLogin(u.trim(),{signal:f.signal,timeoutMs:12e3});if(!r.ok||!r.qrcodeUrl){i({ok:!1,text:"✗ "+(r.error||r.message||s("modal.validationFailed"))});return}w(r.qrcodeUrl),l(r.sessionKey),i({ok:!0,text:s("modal.weixinWaitingScan")}),N=await T(f,r.sessionKey,u.trim())}catch(r){if(Q(r))return;const p=H(r,s);i({ok:!1,text:"✗ "+p}),c(p,!1)}finally{o.current===f&&(o.current=null),b(!1),N&&h()}};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:f=>v(f.target.value),placeholder:P}),e.jsx("div",{className:"mt-1 text-[11px] text-fg-5",children:s("modal.weixinDefaultBaseUrlHint")})]}),y&&e.jsxs("div",{className:"rounded-xl border border-edge bg-panel-alt p-4",children:[e.jsx("img",{src:y,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})]}),x&&e.jsx("div",{className:"text-xs",style:{color:x.ok?"var(--th-ok)":"var(--th-err)"},children:x.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:g,onClick:n,children:s(g?y?"modal.validating":"modal.weixinGeneratingQr":y?"modal.weixinRetry":"modal.weixinGenerateQr")})]})]})}function le({open:d,onClose:h}){const S=j(l=>l.state),c=j(l=>l.toast),B=j(l=>l.reload),t=j(l=>l.locale),s=a.useMemo(()=>U(t),[t]),u=S?.bot?.workdir||S?.runtimeWorkdir||"",[v,g]=a.useState(""),[b,y]=a.useState(0);a.useEffect(()=>{d&&(g(u),y(l=>l+1))},[d,u]);const w=a.useCallback(l=>{g(l)},[]),k=async()=>{const l=v.trim();if(!l){c(s("modal.selectDirFirst"),!1);return}try{const x=await C.switchWorkdir(l);x.ok?(c(s("modal.switchedTo")+x.workdir),h(),setTimeout(B,300)):c(x.error||s("modal.switchFailed"),!1)}catch{c(s("modal.switchFailed"),!1)}};return e.jsxs(A,{open:d,onClose:h,panelStyle:{width:"min(500px, calc(100vw - 2rem))",maxWidth:"min(500px, calc(100vw - 2rem))"},children:[e.jsx(L,{title:s("modal.switchWorkdir"),onClose:h}),e.jsx(X,{initialPath:u,onSelect:w,t:s},b),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(I,{variant:"ghost",onClick:h,children:s("modal.cancel")}),e.jsx(I,{variant:"primary",onClick:k,children:s("modal.selectDir")})]})]})}function re({open:d,onClose:h,onSaved:S}){const c=j(r=>r.toast),B=j(r=>r.locale),t=a.useMemo(()=>U(B),[B]),[s,u]=a.useState(null),[v,g]=a.useState(!1),[b,y]=a.useState(!1),[w,k]=a.useState(null);a.useEffect(()=>{d&&(g(!1),k(null),C.getBrowser().then(r=>{u(r),y(!!r.browser.enabled)}).catch(()=>u(null)))},[d]);const l=s?.browser,x=!!l?.enabled,i=!!l&&x!==b,o=l?.profileDir||"",F=t("ext.profileDir"),m=o,T=!!l?.chromeInstalled&&!!l?.profileCreated,n=s?l?.enabled?T?t("ext.browserReady"):l?.chromeInstalled?t("ext.chromeInstalled"):t("ext.needsSetup"):t("ext.disabled"):t("status.loading"),f=s&&l?.enabled?T?"ok":l?.chromeInstalled?"warn":"err":"muted",N=async()=>{g(!0),k(null);try{await C.saveConfig({browserEnabled:b});const r=await C.getBrowser();u(r),S?.()}catch{k({ok:!1,text:"✗ "+t("ext.browserModeSaveFailed")}),c(t("ext.browserModeSaveFailed"),!1),g(!1);return}if(!b){k({ok:!0,text:"✓ "+t("ext.browserDisabledSaved")}),c(t("ext.browserDisabledSaved")),g(!1);return}try{const r=await C.setupBrowser();if(!r.ok){k({ok:!1,text:"✗ "+(r.error||t("ext.browserLaunchFailed"))}),c(r.error||t("ext.browserLaunchFailed"),!1);return}u(p=>p?{...p,browser:r.browser}:{browser:r.browser,desktop:{enabled:!1,installed:!1,running:!1,appiumUrl:""}}),k({ok:!0,text:"✓ "+t("ext.browserEnabledLaunched")}),c(t("ext.browserEnabledLaunched")),S?.()}catch{k({ok:!1,text:"✗ "+t("ext.browserLaunchFailed")}),c(t("ext.browserLaunchFailed"),!1)}finally{g(!1)}};return e.jsxs(A,{open:d,onClose:h,children:[e.jsx(L,{title:t("ext.setupBrowser"),description:t("ext.setupBrowserDesc"),onClose:h}),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:f,children:n}),l&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:x?"accent":"muted",children:t(x?"ext.enabled":"ext.disabled")}),i&&e.jsx(K,{variant:"warn",children:t("ext.pendingModeChange")}),l.running&&e.jsxs(K,{variant:"accent",children:[t("ext.browserOpen"),l.pid?` · PID ${l.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:r=>r.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(b?"ext.profileModeDesc":"ext.browserDescDisabled")}),l?.detail&&e.jsx("div",{className:"mt-2 text-xs text-fg-5",children:l.detail}),w&&e.jsx("div",{className:"mt-3 text-xs",style:{color:w.ok?"var(--th-ok)":"var(--th-err)"},children:w.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:b,onChange:r=>y(r.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(b?"ext.step2Title":"ext.browserDisabledStepTitle")}),e.jsx("div",{className:"text-xs text-fg-4",children:t(b?"ext.step2Desc":"ext.browserDisabledHint")})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-6",children:[e.jsx(I,{variant:"ghost",onClick:h,children:t("modal.cancel")}),e.jsx(I,{variant:"primary",disabled:v,onClick:N,children:t(v?"ext.launching":b?"ext.enableAndLaunchBrowser":"ext.saveBrowserDisabled")})]})]})}function ne({open:d,onClose:h,onSaved:S}){const c=j(n=>n.toast),B=j(n=>n.locale),t=a.useMemo(()=>U(B),[B]),[s,u]=a.useState(!1),[v,g]=a.useState(!1),[b,y]=a.useState(!1),[w,k]=a.useState(!1),[l,x]=a.useState(!1),[i,o]=a.useState(null);a.useEffect(()=>{d&&(u(!1),k(!1),x(!1),o(null),C.getBrowser().then(n=>{g(n.desktop.installed),y(n.desktop.enabled)}).catch(()=>{}))},[d]);const F=async()=>{u(!0),o(null);try{const n=await C.desktopInstall();n.ok?(g(!0),o({ok:!0,text:"✓ "+t("ext.desktopInstalled")}),c(t("ext.desktopInstalled"))):o({ok:!1,text:"✗ "+(n.error||t("ext.desktopInstallFailed"))})}catch{o({ok:!1,text:"✗ "+t("ext.desktopInstallFailed")})}finally{u(!1)}},m=async()=>{k(!0),o(null);try{const n=await C.desktopToggle(!0);n.ok?(y(!0),o({ok:!0,text:"✓ "+t("ext.desktopStarted")}),c(t("ext.desktopStarted")),S?.()):o({ok:!1,text:"✗ "+(n.error||t("ext.desktopInstallFailed"))})}catch{o({ok:!1,text:"✗ "+t("ext.desktopInstallFailed")})}finally{k(!1)}},T=async()=>{x(!0),o(null);try{const n=await C.desktopToggle(!1);n.ok?(y(!1),o({ok:!0,text:"✓ "+t("ext.desktopStopped")}),c(t("ext.desktopStopped")),S?.()):o({ok:!1,text:"✗ "+(n.error||t("ext.desktopInstallFailed"))})}catch{o({ok:!1,text:"✗ "+t("ext.desktopInstallFailed")})}finally{x(!1)}};return e.jsxs(A,{open:d,onClose:h,children:[e.jsx(L,{title:t("ext.setupDesktop"),description:t("ext.setupDesktopDesc"),onClose:h}),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")}),i&&!v&&e.jsx("div",{className:"mb-2 text-xs",style:{color:i.ok?"var(--th-ok)":"var(--th-err)"},children:i.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")}),i&&v&&e.jsx("div",{className:"mb-2 text-xs",style:{color:i.ok?"var(--th-ok)":"var(--th-err)"},children:i.text}),e.jsx("div",{className:"flex items-center gap-2",children:b?e.jsx(I,{variant:"outline",size:"sm",disabled:l,onClick:T,children:t(l?"ext.desktopStopping":"ext.disable")}):e.jsx(I,{variant:"primary",size:"sm",disabled:!v||w,onClick:m,children:t(w?"ext.desktopStarting":"ext.desktopStep2Action")})})]})]}),e.jsx("div",{className:"flex justify-end gap-2 mt-6",children:e.jsx(I,{variant:"ghost",onClick:h,children:t("modal.cancel")})})]})}export{re as BrowserSetupModal,ne as DesktopSetupModal,se as FeishuModal,te as TelegramModal,ae as WeixinModal,le as WorkdirModal};
1
+ import{r as a,j as e}from"./react-vendor-C7Sl8SE7.js";import{u as j,a as U,M as A,g as L,L as M,p as R,e as I,b as C,B as K}from"./index-C6rqoQ_Q.js";import{D as X}from"./DirBrowser-D8Y8BdoJ.js";import"./router-Rwafsu7Y.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,h){return d instanceof Error&&/timed out/i.test(d.message)?h("modal.requestTimeout"):h("modal.networkError")}function te({open:d,onClose:h}){const S=j(n=>n.state),c=j(n=>n.toast),B=j(n=>n.reloadUntil),t=j(n=>n.locale),s=a.useMemo(()=>U(t),[t]),[u,v]=a.useState(""),[g,b]=a.useState(""),[y,w]=a.useState(!1),[k,l]=a.useState(!1),[x,i]=a.useState(null),o=a.useRef(null),F=a.useRef(S);F.current=S,a.useEffect(()=>{d?(v(F.current?.config.telegramBotToken||""),b(F.current?.config.telegramAllowedChatIds||""),w(!1),i(null)):(o.current?.abort(),o.current=null,l(!1))},[d]),a.useEffect(()=>()=>{o.current?.abort(),o.current=null},[]);const m=async()=>{if(!u.trim()){c(s("modal.inputToken"),!1);return}o.current?.abort();const n=new AbortController;o.current=n,l(!0),i(null);let f=!1;try{const N=await C.validateTelegramConfig(u.trim(),g.trim(),{signal:n.signal,timeoutMs:12e3});if(!N.ok){i({ok:!1,text:"✗ "+(N.error||s("modal.validationFailed"))});return}const r=N.normalizedAllowedChatIds??g.trim();i({ok:!0,text:"✓ @"+(N.bot?.username||"bot")+(N.bot?.displayName?" ("+N.bot.displayName+")":"")});const p=new Set((S?.setupState?.channels||[]).filter(D=>(D.ready||D.configured)&&D.channel!=="telegram").map(D=>D.channel));if(p.add("telegram"),await C.saveConfig({telegramBotToken:u.trim(),telegramAllowedChatIds:r,channels:[...p]}),!await B(D=>{const q=D.setupState?.channels?.find(z=>z.channel==="telegram");return D.config.telegramBotToken===u.trim()&&(D.config.telegramAllowedChatIds||"")===r&&!!q?.ready},{attempts:10,intervalMs:350})){i({ok:!1,text:"✗ "+s("modal.refreshStateFailed")}),c(s("modal.refreshStateFailed"),!1);return}c(s("modal.tgSaved")),f=!0}catch(N){if(Q(N))return;const r=H(N,s);i({ok:!1,text:"✗ "+r}),c(r,!1)}finally{o.current===n&&(o.current=null),l(!1),f&&h()}},T=()=>{o.current?.abort(),o.current=null,h()};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:y?"text":"password",className:"flex-1 font-mono text-xs",placeholder:s("modal.pasteToken"),value:u,onChange:n=>v(n.target.value)}),e.jsx(I,{variant:"ghost",size:"sm",className:"!w-[34px] !p-0",onClick:()=>w(!y),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"})]})})]})]}),x&&e.jsx("div",{className:"text-xs",style:{color:x.ok?"var(--th-ok)":"var(--th-err)"},children:x.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:g,onChange:n=>b(n.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 se({open:d,onClose:h}){const S=j(m=>m.state),c=j(m=>m.toast),B=j(m=>m.reloadUntil),t=j(m=>m.locale),s=a.useMemo(()=>U(t),[t]),[u,v]=a.useState(""),[g,b]=a.useState(""),[y,w]=a.useState(!1),[k,l]=a.useState(null),x=a.useRef(null),i=a.useRef(S);i.current=S,a.useEffect(()=>{d?(v(i.current?.config.feishuAppId||""),b(i.current?.config.feishuAppSecret||""),l(null)):(x.current?.abort(),x.current=null,w(!1))},[d]),a.useEffect(()=>()=>{x.current?.abort(),x.current=null},[]);const o=async()=>{if(!u.trim()){c(s("modal.inputAppId"),!1);return}x.current?.abort();const m=new AbortController;x.current=m,w(!0),l(null);let T=!1;try{const n=await C.validateFeishuConfig(u.trim(),g.trim(),{signal:m.signal,timeoutMs:2e4});if(!n.ok){l({ok:!1,text:"✗ "+(n.error||s("modal.validationFailed"))});return}l({ok:!0,text:"✓ "+(n.app?.displayName||n.app?.appId||u.trim())});const f=new Set((S?.setupState?.channels||[]).filter(r=>(r.ready||r.configured)&&r.channel!=="feishu").map(r=>r.channel));if(f.add("feishu"),await C.saveConfig({feishuAppId:u.trim(),feishuAppSecret:g.trim(),channels:[...f]}),!await B(r=>{const p=r.setupState?.channels?.find(W=>W.channel==="feishu");return r.config.feishuAppId===u.trim()&&r.config.feishuAppSecret===g.trim()&&!!p?.ready},{attempts:10,intervalMs:350})){l({ok:!1,text:"✗ "+s("modal.refreshStateFailed")}),c(s("modal.refreshStateFailed"),!1);return}c(s("modal.feishuSaved")),T=!0}catch(n){if(Q(n))return;const f=H(n,s);l({ok:!1,text:"✗ "+f}),c(f,!1)}finally{x.current===m&&(x.current=null),w(!1),T&&h()}},F=()=>{x.current?.abort(),x.current=null,h()};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:g,onChange:m=>b(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:y,onClick:o,children:s(y?"modal.validating":"modal.validateSave")})]})]})}function ae({open:d,onClose:h}){const S=j(f=>f.state),c=j(f=>f.toast),B=j(f=>f.reloadUntil),t=j(f=>f.locale),s=a.useMemo(()=>U(t),[t]),[u,v]=a.useState(P),[g,b]=a.useState(!1),[y,w]=a.useState(""),[k,l]=a.useState(""),[x,i]=a.useState(null),o=a.useRef(null),F=a.useRef(S);F.current=S,a.useEffect(()=>{d?(v(F.current?.config.weixinBaseUrl||P),b(!1),w(""),l(""),i(null)):(o.current?.abort(),o.current=null,b(!1))},[d]),a.useEffect(()=>()=>{o.current?.abort(),o.current=null},[]);const m=()=>{o.current?.abort(),o.current=null,h()},T=a.useCallback(async(f,N,r)=>{for(;!f.signal.aborted;){const p=await C.waitWeixinLogin(N,r,{signal:f.signal,timeoutMs:45e3});if(!p.ok&&!p.connected)return i({ok:!1,text:"✗ "+(p.error||p.message||s("modal.validationFailed"))}),!1;if(p.qrcodeUrl&&w(p.qrcodeUrl),p.status==="scaned"?i({ok:!0,text:s("modal.weixinScanned")}):p.status==="expired"?i({ok:!0,text:s("modal.weixinQrRefreshed")}):p.connected||i({ok:!0,text:s("modal.weixinWaitingScan")}),!p.connected)continue;i({ok:!0,text:s("modal.weixinLoginSuccess")});const W=p.baseUrl||r,D=p.botToken||"",q=p.accountId||"",z=await C.validateWeixinConfig(W,D,q,{signal:f.signal,timeoutMs:12e3});if(!z.ok)return i({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):(i({ok:!1,text:"✗ "+s("modal.refreshStateFailed")}),c(s("modal.refreshStateFailed"),!1),!1)}return!1},[B,s,c]),n=async()=>{if(!u.trim()){c(s("modal.inputWeixinBaseUrl"),!1);return}o.current?.abort();const f=new AbortController;o.current=f,b(!0),w(""),l(""),i(null);let N=!1;try{const r=await C.startWeixinLogin(u.trim(),{signal:f.signal,timeoutMs:12e3});if(!r.ok||!r.qrcodeUrl){i({ok:!1,text:"✗ "+(r.error||r.message||s("modal.validationFailed"))});return}w(r.qrcodeUrl),l(r.sessionKey),i({ok:!0,text:s("modal.weixinWaitingScan")}),N=await T(f,r.sessionKey,u.trim())}catch(r){if(Q(r))return;const p=H(r,s);i({ok:!1,text:"✗ "+p}),c(p,!1)}finally{o.current===f&&(o.current=null),b(!1),N&&h()}};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:f=>v(f.target.value),placeholder:P}),e.jsx("div",{className:"mt-1 text-[11px] text-fg-5",children:s("modal.weixinDefaultBaseUrlHint")})]}),y&&e.jsxs("div",{className:"rounded-xl border border-edge bg-panel-alt p-4",children:[e.jsx("img",{src:y,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})]}),x&&e.jsx("div",{className:"text-xs",style:{color:x.ok?"var(--th-ok)":"var(--th-err)"},children:x.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:g,onClick:n,children:s(g?y?"modal.validating":"modal.weixinGeneratingQr":y?"modal.weixinRetry":"modal.weixinGenerateQr")})]})]})}function le({open:d,onClose:h}){const S=j(l=>l.state),c=j(l=>l.toast),B=j(l=>l.reload),t=j(l=>l.locale),s=a.useMemo(()=>U(t),[t]),u=S?.bot?.workdir||S?.runtimeWorkdir||"",[v,g]=a.useState(""),[b,y]=a.useState(0);a.useEffect(()=>{d&&(g(u),y(l=>l+1))},[d,u]);const w=a.useCallback(l=>{g(l)},[]),k=async()=>{const l=v.trim();if(!l){c(s("modal.selectDirFirst"),!1);return}try{const x=await C.switchWorkdir(l);x.ok?(c(s("modal.switchedTo")+x.workdir),h(),setTimeout(B,300)):c(x.error||s("modal.switchFailed"),!1)}catch{c(s("modal.switchFailed"),!1)}};return e.jsxs(A,{open:d,onClose:h,panelStyle:{width:"min(500px, calc(100vw - 2rem))",maxWidth:"min(500px, calc(100vw - 2rem))"},children:[e.jsx(L,{title:s("modal.switchWorkdir"),onClose:h}),e.jsx(X,{initialPath:u,onSelect:w,t:s},b),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(I,{variant:"ghost",onClick:h,children:s("modal.cancel")}),e.jsx(I,{variant:"primary",onClick:k,children:s("modal.selectDir")})]})]})}function re({open:d,onClose:h,onSaved:S}){const c=j(r=>r.toast),B=j(r=>r.locale),t=a.useMemo(()=>U(B),[B]),[s,u]=a.useState(null),[v,g]=a.useState(!1),[b,y]=a.useState(!1),[w,k]=a.useState(null);a.useEffect(()=>{d&&(g(!1),k(null),C.getBrowser().then(r=>{u(r),y(!!r.browser.enabled)}).catch(()=>u(null)))},[d]);const l=s?.browser,x=!!l?.enabled,i=!!l&&x!==b,o=l?.profileDir||"",F=t("ext.profileDir"),m=o,T=!!l?.chromeInstalled&&!!l?.profileCreated,n=s?l?.enabled?T?t("ext.browserReady"):l?.chromeInstalled?t("ext.chromeInstalled"):t("ext.needsSetup"):t("ext.disabled"):t("status.loading"),f=s&&l?.enabled?T?"ok":l?.chromeInstalled?"warn":"err":"muted",N=async()=>{g(!0),k(null);try{await C.saveConfig({browserEnabled:b});const r=await C.getBrowser();u(r),S?.()}catch{k({ok:!1,text:"✗ "+t("ext.browserModeSaveFailed")}),c(t("ext.browserModeSaveFailed"),!1),g(!1);return}if(!b){k({ok:!0,text:"✓ "+t("ext.browserDisabledSaved")}),c(t("ext.browserDisabledSaved")),g(!1);return}try{const r=await C.setupBrowser();if(!r.ok){k({ok:!1,text:"✗ "+(r.error||t("ext.browserLaunchFailed"))}),c(r.error||t("ext.browserLaunchFailed"),!1);return}u(p=>p?{...p,browser:r.browser}:{browser:r.browser,desktop:{enabled:!1,installed:!1,running:!1,appiumUrl:""}}),k({ok:!0,text:"✓ "+t("ext.browserEnabledLaunched")}),c(t("ext.browserEnabledLaunched")),S?.()}catch{k({ok:!1,text:"✗ "+t("ext.browserLaunchFailed")}),c(t("ext.browserLaunchFailed"),!1)}finally{g(!1)}};return e.jsxs(A,{open:d,onClose:h,children:[e.jsx(L,{title:t("ext.setupBrowser"),description:t("ext.setupBrowserDesc"),onClose:h}),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:f,children:n}),l&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:x?"accent":"muted",children:t(x?"ext.enabled":"ext.disabled")}),i&&e.jsx(K,{variant:"warn",children:t("ext.pendingModeChange")}),l.running&&e.jsxs(K,{variant:"accent",children:[t("ext.browserOpen"),l.pid?` · PID ${l.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:r=>r.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(b?"ext.profileModeDesc":"ext.browserDescDisabled")}),l?.detail&&e.jsx("div",{className:"mt-2 text-xs text-fg-5",children:l.detail}),w&&e.jsx("div",{className:"mt-3 text-xs",style:{color:w.ok?"var(--th-ok)":"var(--th-err)"},children:w.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:b,onChange:r=>y(r.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(b?"ext.step2Title":"ext.browserDisabledStepTitle")}),e.jsx("div",{className:"text-xs text-fg-4",children:t(b?"ext.step2Desc":"ext.browserDisabledHint")})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-6",children:[e.jsx(I,{variant:"ghost",onClick:h,children:t("modal.cancel")}),e.jsx(I,{variant:"primary",disabled:v,onClick:N,children:t(v?"ext.launching":b?"ext.enableAndLaunchBrowser":"ext.saveBrowserDisabled")})]})]})}function ne({open:d,onClose:h,onSaved:S}){const c=j(n=>n.toast),B=j(n=>n.locale),t=a.useMemo(()=>U(B),[B]),[s,u]=a.useState(!1),[v,g]=a.useState(!1),[b,y]=a.useState(!1),[w,k]=a.useState(!1),[l,x]=a.useState(!1),[i,o]=a.useState(null);a.useEffect(()=>{d&&(u(!1),k(!1),x(!1),o(null),C.getBrowser().then(n=>{g(n.desktop.installed),y(n.desktop.enabled)}).catch(()=>{}))},[d]);const F=async()=>{u(!0),o(null);try{const n=await C.desktopInstall();n.ok?(g(!0),o({ok:!0,text:"✓ "+t("ext.desktopInstalled")}),c(t("ext.desktopInstalled"))):o({ok:!1,text:"✗ "+(n.error||t("ext.desktopInstallFailed"))})}catch{o({ok:!1,text:"✗ "+t("ext.desktopInstallFailed")})}finally{u(!1)}},m=async()=>{k(!0),o(null);try{const n=await C.desktopToggle(!0);n.ok?(y(!0),o({ok:!0,text:"✓ "+t("ext.desktopStarted")}),c(t("ext.desktopStarted")),S?.()):o({ok:!1,text:"✗ "+(n.error||t("ext.desktopInstallFailed"))})}catch{o({ok:!1,text:"✗ "+t("ext.desktopInstallFailed")})}finally{k(!1)}},T=async()=>{x(!0),o(null);try{const n=await C.desktopToggle(!1);n.ok?(y(!1),o({ok:!0,text:"✓ "+t("ext.desktopStopped")}),c(t("ext.desktopStopped")),S?.()):o({ok:!1,text:"✗ "+(n.error||t("ext.desktopInstallFailed"))})}catch{o({ok:!1,text:"✗ "+t("ext.desktopInstallFailed")})}finally{x(!1)}};return e.jsxs(A,{open:d,onClose:h,children:[e.jsx(L,{title:t("ext.setupDesktop"),description:t("ext.setupDesktopDesc"),onClose:h}),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")}),i&&!v&&e.jsx("div",{className:"mb-2 text-xs",style:{color:i.ok?"var(--th-ok)":"var(--th-err)"},children:i.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")}),i&&v&&e.jsx("div",{className:"mb-2 text-xs",style:{color:i.ok?"var(--th-ok)":"var(--th-err)"},children:i.text}),e.jsx("div",{className:"flex items-center gap-2",children:b?e.jsx(I,{variant:"outline",size:"sm",disabled:l,onClick:T,children:t(l?"ext.desktopStopping":"ext.disable")}):e.jsx(I,{variant:"primary",size:"sm",disabled:!v||w,onClick:m,children:t(w?"ext.desktopStarting":"ext.desktopStep2Action")})})]})]}),e.jsx("div",{className:"flex justify-end gap-2 mt-6",children:e.jsx(I,{variant:"ghost",onClick:h,children:t("modal.cancel")})})]})}export{re as BrowserSetupModal,ne as DesktopSetupModal,se as FeishuModal,te as TelegramModal,ae as WeixinModal,le as WorkdirModal};
@@ -1 +1 @@
1
- import{r as l,j as e}from"./react-vendor-C7Sl8SE7.js";import{u,a as R,b as D,e as f,B as N}from"./index-BxuA85oI.js";import{a as L,b as O,c as j,d as z}from"./shared-rdDL3t6R.js";import"./router-Rwafsu7Y.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-C7Sl8SE7.js";import{u,a as R,b as D,e as f,B as N}from"./index-C6rqoQ_Q.js";import{a as L,b as O,c as j,d as z}from"./shared-DYK11EN0.js";import"./router-Rwafsu7Y.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,4 +1,4 @@
1
- import{r,j as e,a as we}from"./react-vendor-C7Sl8SE7.js";import{u as _e,a as We,h as je,s as Ue,b as A,d as Se,S as oe,c as P,E as Fe}from"./index-BxuA85oI.js";import{B as ie}from"./BrandIcon-B9y9j0jh.js";import{h as te,P as Ee}from"./SessionsTab-BzDzSqml.js";import{M as de,r as ue}from"./markdown-Chkk3cWU.js";import"./router-Rwafsu7Y.js";import"./DirBrowser-D4Y8bm_k.js";const Ce=12,Te=160,De=96,bt=r.memo(function({session:s,workdir:n,active:o=!0}){const u=_e(c=>c.locale),i=r.useMemo(()=>We(u),[u]),d=je(s.agent||""),a=Ue(s),[m,p]=r.useState(null),[b,C]=r.useState(!0),[g,y]=r.useState(!1),[k,T]=r.useState(null),[G,N]=r.useState(!1),[Q,F]=r.useState(null),[D,I]=r.useState(0),[E,O]=r.useState(null),[X,J]=r.useState(null),L=r.useRef(null),j=r.useRef(null),B=r.useRef(!0),M=r.useRef(!1),$=r.useRef(!1),H=r.useRef(!1),R=r.useRef(!1),q=r.useCallback(async c=>{try{const x=await A.getSessionMessages(n,s.agent||"",s.sessionId,{rich:!0,turnOffset:c.turnOffset,turnLimit:c.turnLimit,lastNTurns:c.lastNTurns});return x.ok?$e(x):null}catch{return null}},[n,s.agent,s.sessionId]),S=r.useCallback(async({keepOlder:c})=>{if($.current)return!1;$.current=!0;try{const x=await q({turnOffset:0,turnLimit:Ce});return x?(p(w=>!w||!c?x:Ke(w,x)),!0):!1}finally{$.current=!1}},[q]),z=r.useCallback(async()=>{if(!m?.hasOlder||H.current)return;const c=L.current;c&&(j.current={scrollHeight:c.scrollHeight,scrollTop:c.scrollTop}),H.current=!0,y(!0);try{const x=await q({turnOffset:Math.max(0,m.totalTurns-m.startTurn),turnLimit:Ce});x?p(w=>w?qe(w,x):x):j.current=null}finally{H.current=!1,y(!1)}},[q,m]),K=r.useCallback(()=>{R.current=!0,I(c=>c+1)},[]);r.useEffect(()=>{let c=!1;return C(!0),p(null),T(null),N(!1),F(null),B.current=!0,M.current=!0,S({keepOlder:!1}).finally(()=>{c||C(!1)}),()=>{c=!0}},[S]),r.useEffect(()=>{o&&S({keepOlder:!0})},[o,S]),r.useEffect(()=>{if(!o)return;let c=!0,x=null,w=null;const _=()=>{w&&(clearInterval(w),w=null)},ee=()=>{w||(w=setInterval(()=>{pe()},800))},pe=async()=>{if(c)try{const V=await A.getSessionStreamState(s.agent||"",s.sessionId);if(!c)return;const v=V.state,ne=v?.phase??null,W=Se(a,R.current,ne,x);if(!v){x==="streaming"?(T(null),N(!1),B.current&&(M.current=!0),S({keepOlder:!0})):x==="done"&&T(null),(x==="queued"||x==="streaming"||x==="done")&&(R.current=!1),F(null),x=null,W?ee():_();return}F(v.phase),v.phase==="streaming"?(O(null),T({phase:"streaming",text:v.text||"",thinking:v.thinking||"",activity:v.activity,plan:v.plan??null}),N(!0),B.current&&(M.current=!0)):v.phase==="queued"?(T(null),N(!1)):v.phase==="done"&&(O(null),T(te(v.plan)||v.text||v.thinking||v.activity?{phase:"done",text:v.text||"",thinking:v.thinking||"",activity:v.activity||"",plan:v.plan??null}:null),N(!1),x!=="done"&&(B.current&&(M.current=!0),S({keepOlder:!0})),R.current=!1),W?ee():_(),x=v.phase}catch{}};return Se(a,R.current,null,null)&&ee(),pe(),()=>{c=!1,_()}},[o,a,S,s.agent,s.sessionId,D]),r.useEffect(()=>{if(!o||a!=="running"||G)return;const c=setInterval(()=>{S({keepOlder:!0})},3e3);return()=>clearInterval(c)},[o,a,S,G]),r.useLayoutEffect(()=>{const c=j.current,x=L.current;!c||!x||(j.current=null,x.scrollTop=c.scrollTop+(x.scrollHeight-c.scrollHeight))},[m?.turns.length]),r.useLayoutEffect(()=>{if(!M.current)return;const c=L.current;c&&(M.current=!1,c.scrollTop=c.scrollHeight)},[m?.turns.length,k]),r.useLayoutEffect(()=>{if(!E)return;const c=L.current;c&&(c.scrollTop=c.scrollHeight)},[E]),r.useEffect(()=>{if(!m?.hasOlder||b||g)return;const c=L.current;c&&c.scrollHeight<=c.clientHeight+Te&&z()},[m?.hasOlder,m?.turns.length,z,b,g]);const Y=r.useCallback(()=>{const c=L.current;if(!c)return;const x=c.scrollHeight-c.scrollTop-c.clientHeight;B.current=x<=De,c.scrollTop<=Te&&z()},[z]),se=s.title||s.lastQuestion?.slice(0,80)||s.sessionId.slice(0,16),Z=m?.turns||[];return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-2.5 px-5 h-10 border-b border-edge/50 bg-panel/40 backdrop-blur-md z-10",children:[e.jsx(ie,{brand:s.agent||"",size:14}),e.jsx("span",{className:"flex-1 min-w-0 text-[13px] font-medium text-fg truncate",children:se}),s.model&&e.jsx("span",{className:"text-[10px] font-mono text-fg-5 px-1.5 py-0.5 rounded bg-panel-alt/40",children:s.model}),a==="running"&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-[5px] w-[5px] rounded-full bg-ok animate-pulse"}),e.jsx("span",{className:"text-[10px] text-ok font-medium",children:i("status.running")})]})]}),e.jsx("div",{ref:L,onScroll:Y,className:"flex-1 overflow-y-auto overscroll-contain",children:b?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(oe,{className:"h-5 w-5 text-fg-4"})}):Z.length===0&&!E&&!k?e.jsx("div",{className:"py-20 text-center text-[13px] text-fg-5",children:i("hub.noMessages")}):e.jsxs("div",{className:"max-w-[900px] mx-auto px-6 py-6 space-y-0",children:[(m?.hasOlder||g)&&e.jsxs("div",{className:"mb-4 flex items-center justify-center gap-2 text-[11px] text-fg-5",children:[g?e.jsx(oe,{className:"h-3 w-3 text-fg-5"}):e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-fg-5/35"}),e.jsx("span",{children:i(g?"hub.loadingOlderTurns":"hub.loadOlderTurnsHint")})]}),Z.map((c,x)=>e.jsx(Qe,{turn:c,agent:s.agent||"",meta:d,t:i,onResend:w=>{M.current=!0,O(w),A.sendSessionMessage(n,s.agent||"",s.sessionId,w).then(_=>{_.ok&&K()}).catch(()=>{O(null)})},onEdit:w=>J(w)},`${m?.startTurn||0}:${x}`)),E&&!k&&e.jsxs("div",{className:"session-turn",children:[e.jsx(ve,{text:E,t:i}),e.jsx(ae,{agent:s.agent||"",meta:d}),e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"flex items-center gap-2.5 rounded-md border border-fg-6 bg-panel px-3.5 py-3 shadow-sm",children:[e.jsxs("span",{className:"relative flex h-4 w-4 items-center justify-center",children:[e.jsx("span",{className:"absolute h-full w-full rounded-full bg-fg-4/20 animate-ping"}),e.jsx("span",{className:"relative h-2 w-2 rounded-full bg-fg-4/60"})]}),e.jsx("span",{className:"text-[12.5px] text-fg-4",children:i("hub.sending")})]})})]}),k&&e.jsxs("div",{className:"mb-6",children:[!E&&e.jsx(ae,{agent:s.agent||"",meta:d}),E&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{text:E,t:i}),e.jsx(ae,{agent:s.agent||"",meta:d})]}),e.jsx(Ye,{stream:k,t:i})]}),e.jsx("div",{className:"h-4"})]})}),e.jsx(ct,{session:s,workdir:n,onStreamQueued:K,onSendStart:O,t:i,streamPhase:Q,editDraft:X,onEditDraftConsumed:()=>J(null)})]})});function $e(t){const s=t.richMessages?.length?t.richMessages:t.messages?.map(d=>({role:d.role,text:d.text,blocks:[{type:"text",content:d.text}]}))||[],n=Ge(s),o=Math.max(t.window?.totalTurns??t.totalTurns??n.length,n.length),u=t.window?.endTurn??o,i=t.window?.startTurn??Math.max(0,u-n.length);return{turns:n,startTurn:i,endTurn:u,totalTurns:o,hasOlder:t.window?.hasOlder??i>0}}function qe(t,s){const n=Math.max(0,t.startTurn-s.startTurn);return{turns:[...s.turns.slice(0,n),...t.turns],startTurn:s.startTurn,endTurn:t.endTurn,totalTurns:Math.max(t.totalTurns,s.totalTurns),hasOlder:s.hasOlder}}function Ke(t,s){if(s.startTurn<=t.startTurn)return s;const n=Math.max(0,s.startTurn-t.startTurn);return{turns:[...t.turns.slice(0,n),...s.turns],startTurn:t.startTurn,endTurn:s.endTurn,totalTurns:s.totalTurns,hasOlder:t.startTurn>0}}function Ve(t,s){const n=[t.text,s.text].filter(Boolean);return{role:t.role,text:n.join(`
1
+ import{r,j as e,a as we}from"./react-vendor-C7Sl8SE7.js";import{u as _e,a as We,h as je,s as Ue,b as A,d as Se,S as oe,c as P,E as Fe}from"./index-C6rqoQ_Q.js";import{B as ie}from"./BrandIcon-D4tX23F9.js";import{h as te,P as Ee}from"./SessionsTab-CHEsq50k.js";import{M as de,r as ue}from"./markdown-Chkk3cWU.js";import"./router-Rwafsu7Y.js";import"./DirBrowser-D8Y8BdoJ.js";const Ce=12,Te=160,De=96,bt=r.memo(function({session:s,workdir:n,active:o=!0}){const u=_e(c=>c.locale),i=r.useMemo(()=>We(u),[u]),d=je(s.agent||""),a=Ue(s),[m,p]=r.useState(null),[b,C]=r.useState(!0),[g,y]=r.useState(!1),[k,T]=r.useState(null),[G,N]=r.useState(!1),[Q,F]=r.useState(null),[D,I]=r.useState(0),[E,O]=r.useState(null),[X,J]=r.useState(null),L=r.useRef(null),j=r.useRef(null),B=r.useRef(!0),M=r.useRef(!1),$=r.useRef(!1),H=r.useRef(!1),R=r.useRef(!1),q=r.useCallback(async c=>{try{const x=await A.getSessionMessages(n,s.agent||"",s.sessionId,{rich:!0,turnOffset:c.turnOffset,turnLimit:c.turnLimit,lastNTurns:c.lastNTurns});return x.ok?$e(x):null}catch{return null}},[n,s.agent,s.sessionId]),S=r.useCallback(async({keepOlder:c})=>{if($.current)return!1;$.current=!0;try{const x=await q({turnOffset:0,turnLimit:Ce});return x?(p(w=>!w||!c?x:Ke(w,x)),!0):!1}finally{$.current=!1}},[q]),z=r.useCallback(async()=>{if(!m?.hasOlder||H.current)return;const c=L.current;c&&(j.current={scrollHeight:c.scrollHeight,scrollTop:c.scrollTop}),H.current=!0,y(!0);try{const x=await q({turnOffset:Math.max(0,m.totalTurns-m.startTurn),turnLimit:Ce});x?p(w=>w?qe(w,x):x):j.current=null}finally{H.current=!1,y(!1)}},[q,m]),K=r.useCallback(()=>{R.current=!0,I(c=>c+1)},[]);r.useEffect(()=>{let c=!1;return C(!0),p(null),T(null),N(!1),F(null),B.current=!0,M.current=!0,S({keepOlder:!1}).finally(()=>{c||C(!1)}),()=>{c=!0}},[S]),r.useEffect(()=>{o&&S({keepOlder:!0})},[o,S]),r.useEffect(()=>{if(!o)return;let c=!0,x=null,w=null;const _=()=>{w&&(clearInterval(w),w=null)},ee=()=>{w||(w=setInterval(()=>{pe()},800))},pe=async()=>{if(c)try{const V=await A.getSessionStreamState(s.agent||"",s.sessionId);if(!c)return;const v=V.state,ne=v?.phase??null,W=Se(a,R.current,ne,x);if(!v){x==="streaming"?(T(null),N(!1),B.current&&(M.current=!0),S({keepOlder:!0})):x==="done"&&T(null),(x==="queued"||x==="streaming"||x==="done")&&(R.current=!1),F(null),x=null,W?ee():_();return}F(v.phase),v.phase==="streaming"?(O(null),T({phase:"streaming",text:v.text||"",thinking:v.thinking||"",activity:v.activity,plan:v.plan??null}),N(!0),B.current&&(M.current=!0)):v.phase==="queued"?(T(null),N(!1)):v.phase==="done"&&(O(null),T(te(v.plan)||v.text||v.thinking||v.activity?{phase:"done",text:v.text||"",thinking:v.thinking||"",activity:v.activity||"",plan:v.plan??null}:null),N(!1),x!=="done"&&(B.current&&(M.current=!0),S({keepOlder:!0})),R.current=!1),W?ee():_(),x=v.phase}catch{}};return Se(a,R.current,null,null)&&ee(),pe(),()=>{c=!1,_()}},[o,a,S,s.agent,s.sessionId,D]),r.useEffect(()=>{if(!o||a!=="running"||G)return;const c=setInterval(()=>{S({keepOlder:!0})},3e3);return()=>clearInterval(c)},[o,a,S,G]),r.useLayoutEffect(()=>{const c=j.current,x=L.current;!c||!x||(j.current=null,x.scrollTop=c.scrollTop+(x.scrollHeight-c.scrollHeight))},[m?.turns.length]),r.useLayoutEffect(()=>{if(!M.current)return;const c=L.current;c&&(M.current=!1,c.scrollTop=c.scrollHeight)},[m?.turns.length,k]),r.useLayoutEffect(()=>{if(!E)return;const c=L.current;c&&(c.scrollTop=c.scrollHeight)},[E]),r.useEffect(()=>{if(!m?.hasOlder||b||g)return;const c=L.current;c&&c.scrollHeight<=c.clientHeight+Te&&z()},[m?.hasOlder,m?.turns.length,z,b,g]);const Y=r.useCallback(()=>{const c=L.current;if(!c)return;const x=c.scrollHeight-c.scrollTop-c.clientHeight;B.current=x<=De,c.scrollTop<=Te&&z()},[z]),se=s.title||s.lastQuestion?.slice(0,80)||s.sessionId.slice(0,16),Z=m?.turns||[];return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-2.5 px-5 h-10 border-b border-edge/50 bg-panel/40 backdrop-blur-md z-10",children:[e.jsx(ie,{brand:s.agent||"",size:14}),e.jsx("span",{className:"flex-1 min-w-0 text-[13px] font-medium text-fg truncate",children:se}),s.model&&e.jsx("span",{className:"text-[10px] font-mono text-fg-5 px-1.5 py-0.5 rounded bg-panel-alt/40",children:s.model}),a==="running"&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-[5px] w-[5px] rounded-full bg-ok animate-pulse"}),e.jsx("span",{className:"text-[10px] text-ok font-medium",children:i("status.running")})]})]}),e.jsx("div",{ref:L,onScroll:Y,className:"flex-1 overflow-y-auto overscroll-contain",children:b?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(oe,{className:"h-5 w-5 text-fg-4"})}):Z.length===0&&!E&&!k?e.jsx("div",{className:"py-20 text-center text-[13px] text-fg-5",children:i("hub.noMessages")}):e.jsxs("div",{className:"max-w-[900px] mx-auto px-6 py-6 space-y-0",children:[(m?.hasOlder||g)&&e.jsxs("div",{className:"mb-4 flex items-center justify-center gap-2 text-[11px] text-fg-5",children:[g?e.jsx(oe,{className:"h-3 w-3 text-fg-5"}):e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-fg-5/35"}),e.jsx("span",{children:i(g?"hub.loadingOlderTurns":"hub.loadOlderTurnsHint")})]}),Z.map((c,x)=>e.jsx(Qe,{turn:c,agent:s.agent||"",meta:d,t:i,onResend:w=>{M.current=!0,O(w),A.sendSessionMessage(n,s.agent||"",s.sessionId,w).then(_=>{_.ok&&K()}).catch(()=>{O(null)})},onEdit:w=>J(w)},`${m?.startTurn||0}:${x}`)),E&&!k&&e.jsxs("div",{className:"session-turn",children:[e.jsx(ve,{text:E,t:i}),e.jsx(ae,{agent:s.agent||"",meta:d}),e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"flex items-center gap-2.5 rounded-md border border-fg-6 bg-panel px-3.5 py-3 shadow-sm",children:[e.jsxs("span",{className:"relative flex h-4 w-4 items-center justify-center",children:[e.jsx("span",{className:"absolute h-full w-full rounded-full bg-fg-4/20 animate-ping"}),e.jsx("span",{className:"relative h-2 w-2 rounded-full bg-fg-4/60"})]}),e.jsx("span",{className:"text-[12.5px] text-fg-4",children:i("hub.sending")})]})})]}),k&&e.jsxs("div",{className:"mb-6",children:[!E&&e.jsx(ae,{agent:s.agent||"",meta:d}),E&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{text:E,t:i}),e.jsx(ae,{agent:s.agent||"",meta:d})]}),e.jsx(Ye,{stream:k,t:i})]}),e.jsx("div",{className:"h-4"})]})}),e.jsx(ct,{session:s,workdir:n,onStreamQueued:K,onSendStart:O,t:i,streamPhase:Q,editDraft:X,onEditDraftConsumed:()=>J(null)})]})});function $e(t){const s=t.richMessages?.length?t.richMessages:t.messages?.map(d=>({role:d.role,text:d.text,blocks:[{type:"text",content:d.text}]}))||[],n=Ge(s),o=Math.max(t.window?.totalTurns??t.totalTurns??n.length,n.length),u=t.window?.endTurn??o,i=t.window?.startTurn??Math.max(0,u-n.length);return{turns:n,startTurn:i,endTurn:u,totalTurns:o,hasOlder:t.window?.hasOlder??i>0}}function qe(t,s){const n=Math.max(0,t.startTurn-s.startTurn);return{turns:[...s.turns.slice(0,n),...t.turns],startTurn:s.startTurn,endTurn:t.endTurn,totalTurns:Math.max(t.totalTurns,s.totalTurns),hasOlder:s.hasOlder}}function Ke(t,s){if(s.startTurn<=t.startTurn)return s;const n=Math.max(0,s.startTurn-t.startTurn);return{turns:[...t.turns.slice(0,n),...s.turns],startTurn:t.startTurn,endTurn:s.endTurn,totalTurns:s.totalTurns,hasOlder:t.startTurn>0}}function Ve(t,s){const n=[t.text,s.text].filter(Boolean);return{role:t.role,text:n.join(`
2
2
 
3
3
  `),blocks:[...t.blocks,...s.blocks]}}function Ge(t){const s=[];let n={user:null,assistant:null};for(const o of t)o.role==="user"?((n.user||n.assistant)&&(s.push(n),n={user:null,assistant:null}),n.user=o):n.assistant?n.assistant=Ve(n.assistant,o):n.assistant=o;return(n.user||n.assistant)&&s.push(n),s}const Qe=r.memo(function({turn:s,agent:n,meta:o,t:u,onResend:i,onEdit:d}){const a=s.user&&!s.assistant&&Xe(s.user.text);return e.jsxs("div",{className:"session-turn",children:[s.user&&!a&&e.jsx(ve,{text:s.user.text,blocks:s.user.blocks,t:u,onResend:i,onEdit:d}),a&&s.user&&e.jsx("div",{className:"mb-4 px-4 py-3 rounded-lg bg-[rgba(255,255,255,0.02)] border border-edge/20 text-[12.5px] leading-[1.7] text-fg-4",children:e.jsx(de,{remarkPlugins:[ue],components:xe,children:s.user.text})}),s.assistant&&e.jsx(ae,{agent:n,meta:o}),s.assistant&&e.jsx("div",{className:"mb-6",children:e.jsx(Je,{message:s.assistant,t:u})})]})});function Xe(t){return t.length>800?!0:["continued from a previous","summary below covers","earlier portion of the conversation","Summary:","Key Technical Concepts"].some(n=>t.includes(n))}function Le({src:t,onClose:s}){return r.useEffect(()=>{const n=o=>{o.key==="Escape"&&s()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[s]),we.createPortal(e.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm cursor-zoom-out",onClick:s,children:e.jsx("img",{src:t,className:"max-w-[90vw] max-h-[90vh] object-contain rounded-lg shadow-2xl",onClick:n=>n.stopPropagation()})}),document.body)}function ve({text:t,blocks:s,t:n,onResend:o,onEdit:u}){const[i,d]=r.useState(!1),[a,m]=r.useState(!1),[p,b]=r.useState(null),C=!!(o||u),g=s?.filter(k=>k.type==="image")||[],y=()=>{navigator.clipboard.writeText(t).then(()=>{m(!0),setTimeout(()=>m(!1),1500)}).catch(()=>{})};return e.jsxs("div",{className:"flex flex-col items-end mb-5 group/bubble",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[e.jsxs("div",{className:"max-w-[72%] rounded-md border border-fg-6 bg-panel px-4 py-3 text-[13.5px] leading-[1.72] text-fg shadow-sm",children:[t&&e.jsx("div",{className:"whitespace-pre-wrap break-words",children:t}),g.length>0&&e.jsx("div",{className:P("flex flex-wrap gap-2",t&&"mt-2"),children:g.map((k,T)=>e.jsx("img",{src:k.content,className:"max-w-[280px] max-h-[200px] rounded border border-fg-6/50 object-cover cursor-zoom-in hover:opacity-90 transition-opacity",onClick:()=>b(k.content)},T))})]}),p&&e.jsx(Le,{src:p,onClose:()=>b(null)}),C&&e.jsxs("div",{className:P("flex items-center gap-1 mt-1.5 mr-1 transition-all duration-200",i?"opacity-100 translate-y-0":"opacity-0 -translate-y-1 pointer-events-none"),children:[e.jsx(ge,{label:n(a?"hub.copied":"hub.copy"),onClick:y,children:a?e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#34d399",strokeWidth:"2",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),o&&e.jsx(ge,{label:n("hub.rerun"),onClick:()=>o(t),children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})}),u&&e.jsx(ge,{label:n("hub.edit"),onClick:()=>u(t),children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})]})]})}function ge({label:t,onClick:s,children:n}){return e.jsx("button",{onClick:s,title:t,className:"flex items-center justify-center w-7 h-7 rounded border border-fg-6 bg-panel text-fg-4 shadow-sm hover:text-fg-2 hover:border-edge-h hover:bg-panel-h transition-colors",children:n})}function ae({agent:t,meta:s}){return e.jsxs("div",{className:"flex items-center gap-3 my-4",children:[e.jsx("div",{className:"flex-1 h-px bg-edge/60"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-fg-5",children:[e.jsx(ie,{brand:t,size:12}),e.jsx("span",{style:{color:s.color,opacity:.6},className:"font-medium",children:s.label})]}),e.jsx("div",{className:"flex-1 h-px bg-edge/60"})]})}function Je({message:t,t:s}){const{activityBlocks:n,thinkingBlocks:o,processNotes:u,planBlocks:i,outputBlocks:d}=Ze(t.blocks),a=[...i].reverse().find(m=>te(m.plan));return e.jsxs("div",{className:"space-y-3",children:[(n.length>0||u.length>0)&&e.jsx(et,{blocks:n,notes:u,t:s}),a?.plan&&e.jsx(Ee,{plan:a.plan,phase:"done",t:s,className:"max-w-[760px]"}),o.length>0&&e.jsx(st,{blocks:o,t:s}),d.length>0&&e.jsx(rt,{blocks:d})]})}function Ye({stream:t,t:s}){const n=te(t.plan),[o,u]=r.useState(!1),[i,d]=r.useState(!1),a=r.useRef(null),m=r.useRef(null),p=!!t.text||!!t.activity||!!t.thinking,b=r.useMemo(()=>(t.activity||"").split(`
4
4
  `).filter(Boolean),[t.activity]),C=b[b.length-1]||"";return r.useLayoutEffect(()=>{const g=a.current;g&&o&&(g.scrollTop=g.scrollHeight)},[o,t.activity]),r.useLayoutEffect(()=>{const g=m.current;g&&i&&(g.scrollTop=g.scrollHeight)},[i,t.thinking]),e.jsxs("div",{className:"space-y-3 animate-in",children:[n&&e.jsx(Ee,{plan:t.plan,phase:t.phase,t:s,className:"mb-1 max-w-[760px]"}),b.length>0&&e.jsxs("div",{className:"rounded-md border border-fg-6 bg-panel overflow-hidden shadow-sm",children:[e.jsxs("button",{onClick:()=>u(g=>!g),className:"w-full flex items-center gap-2.5 px-3.5 py-2.5 text-left hover:bg-white/[0.02] transition-colors",children:[e.jsx("span",{className:"h-[7px] w-[7px] rounded-full bg-cyan-400/60 shrink-0 animate-pulse"}),e.jsx("span",{className:"text-[10.5px] font-semibold uppercase tracking-[0.14em] text-fg-5",children:s("hub.activity")}),e.jsx("span",{className:"flex-1 min-w-0 text-[12px] text-fg-4 truncate",children:C}),b.length>1&&e.jsx("span",{className:"rounded border border-fg-6 bg-inset px-1.5 py-0.5 text-[10px] font-mono text-fg-5",children:b.length}),e.jsx(ce,{open:o})]}),o&&e.jsx("div",{ref:a,className:"border-t border-fg-6 px-3.5 py-2.5 space-y-0.5 max-h-[240px] overflow-y-auto",children:b.map((g,y)=>e.jsxs("div",{className:"flex items-center gap-1.5 py-[2px]",children:[e.jsx("span",{className:"w-1 h-1 rounded-full shrink-0 bg-fg-5/30"}),e.jsx("span",{className:"text-[11px] font-mono text-fg-5/60 truncate",children:g})]},y))})]}),t.thinking&&e.jsxs("div",{className:"rounded-md border border-fg-6 bg-panel overflow-hidden shadow-sm",children:[e.jsxs("button",{onClick:()=>d(g=>!g),className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-left hover:bg-white/[0.02] transition-colors",children:[e.jsx("span",{className:"h-[6px] w-[6px] rounded-full bg-violet-400/50 shrink-0 animate-pulse"}),e.jsx("span",{className:"text-[10.5px] font-semibold uppercase tracking-[0.14em] text-fg-5",children:s("hub.thinking")}),e.jsx("div",{className:"flex-1"}),e.jsx(ce,{open:i})]}),!i&&e.jsx("div",{className:"px-3.5 pb-2.5 -mt-0.5 text-[12px] text-fg-4 leading-[1.65] whitespace-pre-wrap break-words line-clamp-3",children:Me(t.thinking,3)}),i&&e.jsx("div",{ref:m,className:"border-t border-fg-6 px-3.5 py-3 text-[12px] text-fg-4 leading-[1.7] whitespace-pre-wrap break-words max-h-[280px] overflow-y-auto",children:t.thinking})]}),t.text&&e.jsxs("div",{className:"session-md text-[13.5px] leading-[1.75] text-fg-2",children:[e.jsx(de,{remarkPlugins:[ue],components:xe,children:t.text}),t.phase==="streaming"&&e.jsx("span",{className:"inline-block w-[2px] h-[16px] bg-fg-3 animate-pulse ml-0.5 align-text-bottom"})]}),!n&&!p&&e.jsxs("div",{className:"flex items-center gap-2.5 py-1",children:[e.jsx(oe,{className:"h-3.5 w-3.5 text-fg-5"}),e.jsx("span",{className:"text-[12px] text-fg-5",children:s("status.running")})]})]})}function Ze(t){const s=t.filter(a=>a.type==="plan"||a.type==="tool_use"||a.type==="tool_result"||a.type==="image"||!!a.content.trim()),n=s.some(a=>a.type==="text"&&!!a.phase);if(!s.some(a=>a.type!=="text"&&a.type!=="image")&&!n)return{activityBlocks:[],thinkingBlocks:[],processNotes:[],planBlocks:[],outputBlocks:s};if(n)return{activityBlocks:s.filter(a=>a.type==="tool_use"||a.type==="tool_result"),thinkingBlocks:s.filter(a=>a.type==="thinking"),processNotes:s.filter(a=>a.type==="text"&&a.phase==="commentary"),planBlocks:s.filter(a=>a.type==="plan"&&te(a.plan)),outputBlocks:s.filter(a=>a.type==="image"||a.type==="text"&&a.phase!=="commentary")};let u=s.length;for(;u>0&&(s[u-1].type==="text"||s[u-1].type==="image");)u--;const i=u<s.length?s.slice(0,u):s,d=u<s.length?s.slice(u):[];return{activityBlocks:i.filter(a=>a.type==="tool_use"||a.type==="tool_result"),thinkingBlocks:i.filter(a=>a.type==="thinking"),planBlocks:i.filter(a=>a.type==="plan"&&te(a.plan)),processNotes:i.filter(a=>a.type==="text"),outputBlocks:[...d,...i.filter(a=>a.type==="image")]}}function et({blocks:t,notes:s,t:n}){const[o,u]=r.useState(!1),i=t.filter(p=>p.type==="tool_use").map(p=>p.toolName||"tool").filter((p,b,C)=>C.indexOf(p)===b),d=t.length+s.length,a=s.map(p=>p.content.split(`
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionPanel-DTILWbVA.js","assets/react-vendor-C7Sl8SE7.js","assets/index-BxuA85oI.js","assets/router-Rwafsu7Y.js","assets/index-NO1v_zlB.css","assets/BrandIcon-B9y9j0jh.js","assets/markdown-Chkk3cWU.js","assets/DirBrowser-D4Y8bm_k.js"])))=>i.map(i=>d[i]);
2
- import{r as o,j as e}from"./react-vendor-C7Sl8SE7.js";import{c as y,u as A,a as oe,b as T,s as H,S as $,_ as ie,d as Z,B as z,f as ee,I as le,e as K,M as ce,g as de,h as ue,i as xe,j as he,k as pe,D as fe}from"./index-BxuA85oI.js";import{B as te}from"./BrandIcon-B9y9j0jh.js";import{D as ge}from"./DirBrowser-D4Y8bm_k.js";function se(s){return!!s?.steps?.length}function me(s,t){let a=s;for(const[i,r]of Object.entries(t))a=a.replace(new RegExp(`\\{${i}\\}`,"g"),r);return a}function be({status:s}){return s==="completed"?e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-ok",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):s==="inProgress"?e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-cyan-400 animate-pulse"}):e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-fg-5/25"})}function je({open:s}){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:y("text-fg-5/30 transition-transform duration-200 ml-0.5",s&&"rotate-180"),children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}function ve({plan:s,phase:t,t:a,className:i}){const[r,l]=o.useState(!1);if(!se(s))return null;const u=s.steps.length,f=s.steps.filter(d=>d.status==="completed").length,h=t==="done"||f===u,w=me(a("hub.planProgress"),{done:String(f),total:String(u)}),m=h?"bg-emerald-400/60":"bg-cyan-400/60";return e.jsxs("div",{className:y("rounded-md border border-fg-6 bg-panel overflow-hidden shadow-sm",i),children:[e.jsxs("button",{onClick:()=>l(d=>!d),className:"w-full flex items-center gap-2.5 px-3.5 py-2.5 text-left hover:bg-white/[0.02] transition-colors",children:[e.jsx("span",{className:y("h-[7px] w-[7px] rounded-full shrink-0",m)}),e.jsx("span",{className:"text-[10.5px] font-semibold uppercase tracking-[0.14em] text-fg-5",children:w}),s.explanation&&e.jsx("span",{className:"flex-1 min-w-0 text-[11.5px] text-fg-4 truncate",children:s.explanation}),!s.explanation&&e.jsx("span",{className:"flex-1"}),e.jsx("span",{className:y("rounded border px-1.5 py-0.5 text-[10px] font-mono",h?"border-ok/20 text-ok":"border-fg-6 text-fg-5"),children:a(h?"hub.planDone":"hub.planInProgress")}),e.jsx(je,{open:r})]}),r&&e.jsx("div",{className:"border-t border-fg-6 px-3.5 py-2.5 space-y-1",children:s.steps.map((d,b)=>{const g=d.status==="completed"?"text-fg-5 line-through decoration-fg-5/40":d.status==="inProgress"?"text-fg-3":"text-fg-4";return e.jsxs("div",{className:"flex items-center gap-2 py-[2px]",children:[e.jsx("span",{className:"shrink-0 flex items-center justify-center w-[10px]",children:e.jsx(be,{status:d.status})}),e.jsx("span",{className:y("text-[12px] leading-[1.5]",g),children:d.step})]},`${b}:${d.step}`)})})]})}const ke=o.lazy(async()=>({default:(await ie(async()=>{const{SessionPanel:s}=await import("./SessionPanel-DTILWbVA.js");return{SessionPanel:s}},__vite__mapDeps([0,1,2,3,4,5,6,7]))).SessionPanel})),U=5,we=5e3,V=(s,t)=>`${s}:${t}`;function ye(s){return s==="vscode"||s==="cursor"||s==="windsurf"||s==="finder"||s==="default"}function J(s,t){const a=String(s||"").toLowerCase();return a.includes("cursor")?"cursor":a.includes("windsurf")?"windsurf":a.includes("code")||t==="darwin"?"vscode":"default"}function ne(s){switch(s){case"cursor":return"hub.openTargetCursor";case"windsurf":return"hub.openTargetWindsurf";case"finder":return"hub.openTargetFinder";case"default":return"hub.openTargetDefault";default:return"hub.openTargetVsCode"}}const Ne=o.memo(function({active:t=!0}){const a=A(n=>n.locale),i=A(n=>n.state?.runtimeWorkdir??null),r=o.useMemo(()=>oe(a),[a]),[l,u]=o.useState([]),[f,h]=o.useState({}),[w,m]=o.useState({}),[d,b]=o.useState(null),[g,k]=o.useState(!1),[v,C]=o.useState(""),[N,j]=o.useState("all"),I=o.useRef(!1),B=o.useRef({}),W=o.useCallback(async()=>{try{const n=await T.getWorkspaces(),c=n.ok?n.workspaces:[];c.length&&u(c),I.current=!0}catch{I.current=!0}},[]);o.useEffect(()=>{W()},[W]);const S=o.useCallback(async(n,c={})=>{if(!B.current[n]){B.current[n]=!0,c.background||m(x=>({...x,[n]:!0}));try{const x=await T.getWorkspaceSessions(n);h(L=>({...L,[n]:x.sessions||[]}))}catch{c.background||h(x=>({...x,[n]:[]}))}finally{B.current[n]=!1,c.background||m(x=>({...x,[n]:!1}))}}},[]);o.useEffect(()=>{if(t)for(const n of l)!f[n.path]&&!w[n.path]&&S(n.path)},[t,S,w,f,l]),o.useEffect(()=>{if(!t||!I.current||l.length===0)return;const c=setInterval(()=>{if(!(typeof document<"u"&&document.visibilityState==="hidden"))for(const x of l)S(x.path,{background:!0})},we);return()=>clearInterval(c)},[t,l,S]),o.useEffect(()=>{if(!t||!I.current||l.length===0)return;const n=()=>{if(!(typeof document<"u"&&document.visibilityState==="hidden"))for(const x of l)S(x.path,{background:!0})};if(n(),typeof document>"u"||typeof window>"u")return;const c=()=>{document.visibilityState==="visible"&&n()};return document.addEventListener("visibilitychange",c),window.addEventListener("focus",c),()=>{document.removeEventListener("visibilitychange",c),window.removeEventListener("focus",c)}},[t,S,l]);const D=o.useCallback(async n=>{try{(await T.addWorkspace(n)).ok&&(k(!1),await W(),S(n))}catch{}},[W,S]),R=o.useCallback(async n=>{try{await T.removeWorkspace(n),u(c=>c.filter(x=>x.path!==n)),h(c=>{const x={...c};return delete x[n],x}),b(c=>c?.workdir===n?null:c)}catch{}},[]),F=o.useCallback((n,c)=>{b({agent:n.agent||"",sessionId:n.sessionId,workdir:c})},[]),P=o.useCallback(n=>{let c=n;if(N==="running"?c=c.filter(x=>H(x)==="running"):N==="review"&&(c=c.filter(x=>H(x)==="incomplete")),v.trim()){const x=v.toLowerCase();c=c.filter(L=>(L.lastMessageText||"").toLowerCase().includes(x)||(L.lastQuestion||"").toLowerCase().includes(x)||(L.lastAnswer||"").toLowerCase().includes(x)||(L.title||"").toLowerCase().includes(x)||(L.agent||"").toLowerCase().includes(x))}return c},[N,v]),M=o.useMemo(()=>{const n={};for(const c of l)n[c.path]=P(f[c.path]||[]);return n},[l,f,P]),E=o.useMemo(()=>d?(f[d.workdir]||[]).find(n=>n.sessionId===d.sessionId&&n.agent===d.agent)??null:null,[d,f]),p=d?V(d.agent,d.sessionId):null;return e.jsxs("div",{className:"h-full overflow-hidden p-4 flex gap-3 mx-auto max-w-[1680px]",children:[e.jsxs("div",{className:"panel-isolated w-[252px] shrink-0 flex flex-col overflow-hidden rounded-xl border border-edge bg-panel backdrop-blur-sm",style:{boxShadow:"var(--th-card-shadow)"},children:[e.jsxs("div",{className:"px-3 pt-3 pb-2 space-y-2",children:[e.jsxs("div",{className:"relative group",children:[e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-5/40 group-focus-within:text-fg-4 transition-colors",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{value:v,onChange:n=>C(n.target.value),placeholder:r("hub.search"),className:"w-full rounded-lg border border-edge/40 bg-inset/50 pl-8 pr-7 py-1.5 text-[12px] text-fg outline-none placeholder:text-fg-5/30 focus:border-primary/30 focus:bg-inset focus:shadow-[0_0_0_3px_rgba(99,102,241,0.06)] transition-all duration-200"}),v&&e.jsx("button",{onClick:()=>C(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-0.5 rounded text-fg-5/30 hover:text-fg-4 transition-colors",children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsx("div",{className:"flex items-center rounded-lg bg-inset/30 border border-edge/20 p-0.5",children:["all","running","review"].map(n=>e.jsx("button",{onClick:()=>j(n),className:y("flex-1 px-2 py-[5px] rounded-md text-[11px] font-medium transition-all duration-200",N===n?"bg-panel-h text-fg-2 shadow-[0_1px_2px_rgba(0,0,0,0.1),inset_0_1px_0_rgba(255,255,255,0.04)]":"text-fg-5/60 hover:text-fg-4"),children:r(`hub.filter${n[0].toUpperCase()+n.slice(1)}`)},n))})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:l.length===0&&!g?e.jsx("div",{className:"py-12 text-center text-[13px] text-fg-5",children:r("hub.noWorkspaces")}):l.map(n=>e.jsx(Ce,{workspace:n,sessions:M[n.path]||[],loading:!!w[n.path],selectedKey:p,onSelectSession:F,onRefresh:S,onRemove:R,t:r},n.path))}),e.jsx("div",{className:"shrink-0 px-3 py-2 border-t border-edge/20",children:e.jsxs("button",{onClick:()=>k(n=>!n),className:"flex items-center justify-center gap-1.5 w-full px-2 py-1.5 rounded-lg text-[11px] font-medium text-fg-5/60 hover:text-fg-3 hover:bg-panel-h/60 border border-transparent hover:border-edge/20 transition-all duration-200",children:[e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),r("hub.addWorkspace")]})})]}),e.jsx("div",{className:"panel-scroll-safe flex-1 min-w-0 overflow-hidden rounded-xl border border-edge bg-panel",style:{boxShadow:"var(--th-card-shadow)"},children:!E||!d?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-[14px] text-fg-4",children:r("hub.selectSession")}),e.jsx("div",{className:"mt-1 text-[12px] text-fg-5",children:r("hub.selectSessionHint")})]})}):e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-fg-4",children:[e.jsx($,{}),"Loading session..."]})}),children:e.jsx(ke,{session:E,workdir:d.workdir,active:t},V(d.agent,d.sessionId))})}),e.jsx(Pe,{session:E,workdir:d?.workdir||"",active:t,t:r}),e.jsx(Se,{open:g,initialPath:i||void 0,onAdd:D,onClose:()=>k(!1),t:r})]})});function Se({open:s,initialPath:t,onAdd:a,onClose:i,t:r}){const[l,u]=o.useState(""),f=o.useCallback(h=>u(h),[]);return o.useEffect(()=>{s&&u("")},[s]),e.jsxs(ce,{open:s,onClose:i,children:[e.jsx(de,{title:r("hub.addWorkspace"),onClose:i}),e.jsx(ge,{initialPath:t,maxHeight:360,minHeight:200,onSelect:f,t:r}),e.jsxs("div",{className:"flex gap-2 mt-4",children:[e.jsx(K,{disabled:!l,onClick:()=>l&&a(l),className:"flex-1",children:r("hub.add")}),e.jsx(K,{variant:"secondary",onClick:i,className:"flex-1",children:r("hub.cancel")})]})]})}const Ce=o.memo(function({workspace:t,sessions:a,loading:i,selectedKey:r,onSelectSession:l,onRefresh:u,onRemove:f,t:h}){const[w,m]=o.useState(!0),[d,b]=o.useState(U),[g,k]=o.useState(!1);o.useEffect(()=>{b(U)},[a.length]);const v=a.slice(0,d),C=a.length-d,N=t.path;return e.jsxs("div",{className:"border-b border-edge/30",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-panel-h/50 transition-colors",onClick:()=>m(j=>!j),onMouseEnter:()=>k(!0),onMouseLeave:()=>k(!1),children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:y("shrink-0 text-fg-5 transition-transform duration-150",w&&"rotate-90"),children:e.jsx("polyline",{points:"9 6 15 12 9 18"})}),e.jsx("span",{className:"flex-1 min-w-0 truncate text-[12px] font-semibold text-fg-3",children:t.name}),e.jsx("span",{className:"shrink-0 text-[10px] text-fg-5 tabular-nums",children:i?"":`(${a.length})`}),g&&e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e.jsx("button",{onClick:j=>{j.stopPropagation(),u(N)},className:"p-0.5 rounded text-fg-5 hover:text-fg-2 transition-colors",children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})}),e.jsx("button",{onClick:j=>{j.stopPropagation(),f(N)},className:"p-0.5 rounded text-fg-5 hover:text-red-400 transition-colors",children:e.jsxs("svg",{width:"10",height:"10",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"})]})})]})]}),w&&e.jsx("div",{className:"pb-1",children:i?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx($,{className:"h-3 w-3 text-fg-5"})}):a.length===0?e.jsx("div",{className:"py-3 text-center text-[11px] text-fg-5",children:h("sessions.noSessions")}):e.jsxs(e.Fragment,{children:[v.map(j=>e.jsx(Le,{session:j,isSelected:r===V(j.agent||"",j.sessionId),onClick:()=>l(j,N)},V(j.agent||"",j.sessionId))),C>0&&e.jsxs("button",{onClick:()=>b(j=>j+U),className:"flex items-center gap-1.5 w-full px-3 py-1.5 text-[11px] text-fg-5 hover:text-fg-3 hover:bg-panel-h/50 transition-colors",children:[e.jsxs("span",{children:["+ ",h("hub.nMore").replace("{n}",String(C))]}),e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]})]})})]})}),Le=o.memo(function({session:t,isSelected:a,onClick:i}){const r=ue(t.agent||""),l=H(t),u=xe(t).slice(0,500)||t.sessionId.slice(0,16),f=he(t,u).slice(0,500),h=t.model?pe(t.model):null;return e.jsxs("button",{onClick:i,className:y("w-full px-3 py-2 text-left transition-all duration-100","hover:bg-panel-h/60",a&&"bg-panel-h/80"),style:a?{borderLeft:`2px solid ${r.color}`,paddingLeft:10}:void 0,children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-fg-5",children:[e.jsx(te,{brand:t.agent||"",size:10}),e.jsx("span",{className:"font-medium shrink-0",style:{color:r.color},children:r.shortLabel}),h&&e.jsx("span",{className:"truncate max-w-[72px] font-mono text-fg-5/40 text-[9px]",children:h}),e.jsxs("div",{className:"ml-auto flex items-center gap-1.5 shrink-0",children:[!!t.numTurns&&e.jsxs("span",{className:"flex items-center gap-0.5 text-fg-5/50 tabular-nums",children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"opacity-50",children:e.jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),t.numTurns]}),e.jsx("span",{className:"tabular-nums",children:ee(t.runUpdatedAt||t.createdAt)})]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(fe,{variant:l==="running"?"ok":l==="incomplete"?"warn":"idle",pulse:l==="running"}),e.jsx("span",{className:"truncate text-[12px] leading-snug text-fg-2",children:u})]}),f&&e.jsx("div",{className:"mt-0.5 pl-[11px]",children:e.jsx("span",{className:"block truncate text-[10px] leading-snug text-fg-5",children:f})})]})});function X(s){return s&&s[0].toUpperCase()+s.slice(1)}function We(s){if(s.userStatus)return s.userStatus;switch(s.classification?.outcome){case"answer":return"done";case"partial":return"active";case"proposal":case"implementation":case"blocked":case"conversation":return"review";default:return"inbox"}}function Te(s){switch(s){case"done":return"ok";case"review":return"warn";case"active":return"accent";default:return"muted"}}function Ie(s){switch(s){case"blocked":return"err";case"partial":return"warn";case"implementation":case"proposal":return"accent";case"answer":return"ok";default:return"muted"}}function Me(s,t){const a=s.classification?.summary?.trim();if(a)return a;const i=s.lastAnswer?.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionPanel-BJMpjCVF.js","assets/react-vendor-C7Sl8SE7.js","assets/index-C6rqoQ_Q.js","assets/router-Rwafsu7Y.js","assets/index-BRsMNLir.css","assets/BrandIcon-D4tX23F9.js","assets/markdown-Chkk3cWU.js","assets/DirBrowser-D8Y8BdoJ.js"])))=>i.map(i=>d[i]);
2
+ import{r as o,j as e}from"./react-vendor-C7Sl8SE7.js";import{c as y,u as A,a as oe,b as T,s as H,S as $,_ as ie,d as Z,B as z,f as ee,I as le,e as K,M as ce,g as de,h as ue,i as xe,j as he,k as pe,D as fe}from"./index-C6rqoQ_Q.js";import{B as te}from"./BrandIcon-D4tX23F9.js";import{D as ge}from"./DirBrowser-D8Y8BdoJ.js";function se(s){return!!s?.steps?.length}function me(s,t){let a=s;for(const[i,r]of Object.entries(t))a=a.replace(new RegExp(`\\{${i}\\}`,"g"),r);return a}function be({status:s}){return s==="completed"?e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-ok",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):s==="inProgress"?e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-cyan-400 animate-pulse"}):e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-fg-5/25"})}function je({open:s}){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:y("text-fg-5/30 transition-transform duration-200 ml-0.5",s&&"rotate-180"),children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}function ve({plan:s,phase:t,t:a,className:i}){const[r,l]=o.useState(!1);if(!se(s))return null;const u=s.steps.length,f=s.steps.filter(d=>d.status==="completed").length,h=t==="done"||f===u,w=me(a("hub.planProgress"),{done:String(f),total:String(u)}),m=h?"bg-emerald-400/60":"bg-cyan-400/60";return e.jsxs("div",{className:y("rounded-md border border-fg-6 bg-panel overflow-hidden shadow-sm",i),children:[e.jsxs("button",{onClick:()=>l(d=>!d),className:"w-full flex items-center gap-2.5 px-3.5 py-2.5 text-left hover:bg-white/[0.02] transition-colors",children:[e.jsx("span",{className:y("h-[7px] w-[7px] rounded-full shrink-0",m)}),e.jsx("span",{className:"text-[10.5px] font-semibold uppercase tracking-[0.14em] text-fg-5",children:w}),s.explanation&&e.jsx("span",{className:"flex-1 min-w-0 text-[11.5px] text-fg-4 truncate",children:s.explanation}),!s.explanation&&e.jsx("span",{className:"flex-1"}),e.jsx("span",{className:y("rounded border px-1.5 py-0.5 text-[10px] font-mono",h?"border-ok/20 text-ok":"border-fg-6 text-fg-5"),children:a(h?"hub.planDone":"hub.planInProgress")}),e.jsx(je,{open:r})]}),r&&e.jsx("div",{className:"border-t border-fg-6 px-3.5 py-2.5 space-y-1",children:s.steps.map((d,b)=>{const g=d.status==="completed"?"text-fg-5 line-through decoration-fg-5/40":d.status==="inProgress"?"text-fg-3":"text-fg-4";return e.jsxs("div",{className:"flex items-center gap-2 py-[2px]",children:[e.jsx("span",{className:"shrink-0 flex items-center justify-center w-[10px]",children:e.jsx(be,{status:d.status})}),e.jsx("span",{className:y("text-[12px] leading-[1.5]",g),children:d.step})]},`${b}:${d.step}`)})})]})}const ke=o.lazy(async()=>({default:(await ie(async()=>{const{SessionPanel:s}=await import("./SessionPanel-BJMpjCVF.js");return{SessionPanel:s}},__vite__mapDeps([0,1,2,3,4,5,6,7]))).SessionPanel})),U=5,we=5e3,V=(s,t)=>`${s}:${t}`;function ye(s){return s==="vscode"||s==="cursor"||s==="windsurf"||s==="finder"||s==="default"}function J(s,t){const a=String(s||"").toLowerCase();return a.includes("cursor")?"cursor":a.includes("windsurf")?"windsurf":a.includes("code")||t==="darwin"?"vscode":"default"}function ne(s){switch(s){case"cursor":return"hub.openTargetCursor";case"windsurf":return"hub.openTargetWindsurf";case"finder":return"hub.openTargetFinder";case"default":return"hub.openTargetDefault";default:return"hub.openTargetVsCode"}}const Ne=o.memo(function({active:t=!0}){const a=A(n=>n.locale),i=A(n=>n.state?.runtimeWorkdir??null),r=o.useMemo(()=>oe(a),[a]),[l,u]=o.useState([]),[f,h]=o.useState({}),[w,m]=o.useState({}),[d,b]=o.useState(null),[g,k]=o.useState(!1),[v,C]=o.useState(""),[N,j]=o.useState("all"),I=o.useRef(!1),B=o.useRef({}),W=o.useCallback(async()=>{try{const n=await T.getWorkspaces(),c=n.ok?n.workspaces:[];c.length&&u(c),I.current=!0}catch{I.current=!0}},[]);o.useEffect(()=>{W()},[W]);const S=o.useCallback(async(n,c={})=>{if(!B.current[n]){B.current[n]=!0,c.background||m(x=>({...x,[n]:!0}));try{const x=await T.getWorkspaceSessions(n);h(L=>({...L,[n]:x.sessions||[]}))}catch{c.background||h(x=>({...x,[n]:[]}))}finally{B.current[n]=!1,c.background||m(x=>({...x,[n]:!1}))}}},[]);o.useEffect(()=>{if(t)for(const n of l)!f[n.path]&&!w[n.path]&&S(n.path)},[t,S,w,f,l]),o.useEffect(()=>{if(!t||!I.current||l.length===0)return;const c=setInterval(()=>{if(!(typeof document<"u"&&document.visibilityState==="hidden"))for(const x of l)S(x.path,{background:!0})},we);return()=>clearInterval(c)},[t,l,S]),o.useEffect(()=>{if(!t||!I.current||l.length===0)return;const n=()=>{if(!(typeof document<"u"&&document.visibilityState==="hidden"))for(const x of l)S(x.path,{background:!0})};if(n(),typeof document>"u"||typeof window>"u")return;const c=()=>{document.visibilityState==="visible"&&n()};return document.addEventListener("visibilitychange",c),window.addEventListener("focus",c),()=>{document.removeEventListener("visibilitychange",c),window.removeEventListener("focus",c)}},[t,S,l]);const D=o.useCallback(async n=>{try{(await T.addWorkspace(n)).ok&&(k(!1),await W(),S(n))}catch{}},[W,S]),R=o.useCallback(async n=>{try{await T.removeWorkspace(n),u(c=>c.filter(x=>x.path!==n)),h(c=>{const x={...c};return delete x[n],x}),b(c=>c?.workdir===n?null:c)}catch{}},[]),F=o.useCallback((n,c)=>{b({agent:n.agent||"",sessionId:n.sessionId,workdir:c})},[]),P=o.useCallback(n=>{let c=n;if(N==="running"?c=c.filter(x=>H(x)==="running"):N==="review"&&(c=c.filter(x=>H(x)==="incomplete")),v.trim()){const x=v.toLowerCase();c=c.filter(L=>(L.lastMessageText||"").toLowerCase().includes(x)||(L.lastQuestion||"").toLowerCase().includes(x)||(L.lastAnswer||"").toLowerCase().includes(x)||(L.title||"").toLowerCase().includes(x)||(L.agent||"").toLowerCase().includes(x))}return c},[N,v]),M=o.useMemo(()=>{const n={};for(const c of l)n[c.path]=P(f[c.path]||[]);return n},[l,f,P]),E=o.useMemo(()=>d?(f[d.workdir]||[]).find(n=>n.sessionId===d.sessionId&&n.agent===d.agent)??null:null,[d,f]),p=d?V(d.agent,d.sessionId):null;return e.jsxs("div",{className:"h-full overflow-hidden p-4 flex gap-3 mx-auto max-w-[1680px]",children:[e.jsxs("div",{className:"panel-isolated w-[252px] shrink-0 flex flex-col overflow-hidden rounded-xl border border-edge bg-panel backdrop-blur-sm",style:{boxShadow:"var(--th-card-shadow)"},children:[e.jsxs("div",{className:"px-3 pt-3 pb-2 space-y-2",children:[e.jsxs("div",{className:"relative group",children:[e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-5/40 group-focus-within:text-fg-4 transition-colors",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{value:v,onChange:n=>C(n.target.value),placeholder:r("hub.search"),className:"w-full rounded-lg border border-edge/40 bg-inset/50 pl-8 pr-7 py-1.5 text-[12px] text-fg outline-none placeholder:text-fg-5/30 focus:border-primary/30 focus:bg-inset focus:shadow-[0_0_0_3px_rgba(99,102,241,0.06)] transition-all duration-200"}),v&&e.jsx("button",{onClick:()=>C(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-0.5 rounded text-fg-5/30 hover:text-fg-4 transition-colors",children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsx("div",{className:"flex items-center rounded-lg bg-inset/30 border border-edge/20 p-0.5",children:["all","running","review"].map(n=>e.jsx("button",{onClick:()=>j(n),className:y("flex-1 px-2 py-[5px] rounded-md text-[11px] font-medium transition-all duration-200",N===n?"bg-panel-h text-fg-2 shadow-[0_1px_2px_rgba(0,0,0,0.1),inset_0_1px_0_rgba(255,255,255,0.04)]":"text-fg-5/60 hover:text-fg-4"),children:r(`hub.filter${n[0].toUpperCase()+n.slice(1)}`)},n))})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:l.length===0&&!g?e.jsx("div",{className:"py-12 text-center text-[13px] text-fg-5",children:r("hub.noWorkspaces")}):l.map(n=>e.jsx(Ce,{workspace:n,sessions:M[n.path]||[],loading:!!w[n.path],selectedKey:p,onSelectSession:F,onRefresh:S,onRemove:R,t:r},n.path))}),e.jsx("div",{className:"shrink-0 px-3 py-2 border-t border-edge/20",children:e.jsxs("button",{onClick:()=>k(n=>!n),className:"flex items-center justify-center gap-1.5 w-full px-2 py-1.5 rounded-lg text-[11px] font-medium text-fg-5/60 hover:text-fg-3 hover:bg-panel-h/60 border border-transparent hover:border-edge/20 transition-all duration-200",children:[e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),r("hub.addWorkspace")]})})]}),e.jsx("div",{className:"panel-scroll-safe flex-1 min-w-0 overflow-hidden rounded-xl border border-edge bg-panel",style:{boxShadow:"var(--th-card-shadow)"},children:!E||!d?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-[14px] text-fg-4",children:r("hub.selectSession")}),e.jsx("div",{className:"mt-1 text-[12px] text-fg-5",children:r("hub.selectSessionHint")})]})}):e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-fg-4",children:[e.jsx($,{}),"Loading session..."]})}),children:e.jsx(ke,{session:E,workdir:d.workdir,active:t},V(d.agent,d.sessionId))})}),e.jsx(Pe,{session:E,workdir:d?.workdir||"",active:t,t:r}),e.jsx(Se,{open:g,initialPath:i||void 0,onAdd:D,onClose:()=>k(!1),t:r})]})});function Se({open:s,initialPath:t,onAdd:a,onClose:i,t:r}){const[l,u]=o.useState(""),f=o.useCallback(h=>u(h),[]);return o.useEffect(()=>{s&&u("")},[s]),e.jsxs(ce,{open:s,onClose:i,children:[e.jsx(de,{title:r("hub.addWorkspace"),onClose:i}),e.jsx(ge,{initialPath:t,maxHeight:360,minHeight:200,onSelect:f,t:r}),e.jsxs("div",{className:"flex gap-2 mt-4",children:[e.jsx(K,{disabled:!l,onClick:()=>l&&a(l),className:"flex-1",children:r("hub.add")}),e.jsx(K,{variant:"secondary",onClick:i,className:"flex-1",children:r("hub.cancel")})]})]})}const Ce=o.memo(function({workspace:t,sessions:a,loading:i,selectedKey:r,onSelectSession:l,onRefresh:u,onRemove:f,t:h}){const[w,m]=o.useState(!0),[d,b]=o.useState(U),[g,k]=o.useState(!1);o.useEffect(()=>{b(U)},[a.length]);const v=a.slice(0,d),C=a.length-d,N=t.path;return e.jsxs("div",{className:"border-b border-edge/30",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-panel-h/50 transition-colors",onClick:()=>m(j=>!j),onMouseEnter:()=>k(!0),onMouseLeave:()=>k(!1),children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:y("shrink-0 text-fg-5 transition-transform duration-150",w&&"rotate-90"),children:e.jsx("polyline",{points:"9 6 15 12 9 18"})}),e.jsx("span",{className:"flex-1 min-w-0 truncate text-[12px] font-semibold text-fg-3",children:t.name}),e.jsx("span",{className:"shrink-0 text-[10px] text-fg-5 tabular-nums",children:i?"":`(${a.length})`}),g&&e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e.jsx("button",{onClick:j=>{j.stopPropagation(),u(N)},className:"p-0.5 rounded text-fg-5 hover:text-fg-2 transition-colors",children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})}),e.jsx("button",{onClick:j=>{j.stopPropagation(),f(N)},className:"p-0.5 rounded text-fg-5 hover:text-red-400 transition-colors",children:e.jsxs("svg",{width:"10",height:"10",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"})]})})]})]}),w&&e.jsx("div",{className:"pb-1",children:i?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx($,{className:"h-3 w-3 text-fg-5"})}):a.length===0?e.jsx("div",{className:"py-3 text-center text-[11px] text-fg-5",children:h("sessions.noSessions")}):e.jsxs(e.Fragment,{children:[v.map(j=>e.jsx(Le,{session:j,isSelected:r===V(j.agent||"",j.sessionId),onClick:()=>l(j,N)},V(j.agent||"",j.sessionId))),C>0&&e.jsxs("button",{onClick:()=>b(j=>j+U),className:"flex items-center gap-1.5 w-full px-3 py-1.5 text-[11px] text-fg-5 hover:text-fg-3 hover:bg-panel-h/50 transition-colors",children:[e.jsxs("span",{children:["+ ",h("hub.nMore").replace("{n}",String(C))]}),e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]})]})})]})}),Le=o.memo(function({session:t,isSelected:a,onClick:i}){const r=ue(t.agent||""),l=H(t),u=xe(t).slice(0,500)||t.sessionId.slice(0,16),f=he(t,u).slice(0,500),h=t.model?pe(t.model):null;return e.jsxs("button",{onClick:i,className:y("w-full px-3 py-2 text-left transition-all duration-100","hover:bg-panel-h/60",a&&"bg-panel-h/80"),style:a?{borderLeft:`2px solid ${r.color}`,paddingLeft:10}:void 0,children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-fg-5",children:[e.jsx(te,{brand:t.agent||"",size:10}),e.jsx("span",{className:"font-medium shrink-0",style:{color:r.color},children:r.shortLabel}),h&&e.jsx("span",{className:"truncate max-w-[72px] font-mono text-fg-5/40 text-[9px]",children:h}),e.jsxs("div",{className:"ml-auto flex items-center gap-1.5 shrink-0",children:[!!t.numTurns&&e.jsxs("span",{className:"flex items-center gap-0.5 text-fg-5/50 tabular-nums",children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"opacity-50",children:e.jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),t.numTurns]}),e.jsx("span",{className:"tabular-nums",children:ee(t.runUpdatedAt||t.createdAt)})]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(fe,{variant:l==="running"?"ok":l==="incomplete"?"warn":"idle",pulse:l==="running"}),e.jsx("span",{className:"truncate text-[12px] leading-snug text-fg-2",children:u})]}),f&&e.jsx("div",{className:"mt-0.5 pl-[11px]",children:e.jsx("span",{className:"block truncate text-[10px] leading-snug text-fg-5",children:f})})]})});function X(s){return s&&s[0].toUpperCase()+s.slice(1)}function We(s){if(s.userStatus)return s.userStatus;switch(s.classification?.outcome){case"answer":return"done";case"partial":return"active";case"proposal":case"implementation":case"blocked":case"conversation":return"review";default:return"inbox"}}function Te(s){switch(s){case"done":return"ok";case"review":return"warn";case"active":return"accent";default:return"muted"}}function Ie(s){switch(s){case"blocked":return"err";case"partial":return"warn";case"implementation":case"proposal":return"accent";case"answer":return"ok";default:return"muted"}}function Me(s,t){const a=s.classification?.summary?.trim();if(a)return a;const i=s.lastAnswer?.split(`
3
3
  `).find(l=>l.trim())?.trim();if(i)return i.length>180?i.slice(0,177)+"...":i;const r=s.runDetail?.trim();return r||t("hub.noSummary")}function Be(s,t,a){const i=s.classification?.suggestedNextAction?.trim();return i||a(t==="incomplete"?"hub.continueTask":"hub.noNextAction")}const Pe=o.memo(function({session:t,workdir:a,active:i,t:r}){const l=A(p=>p.state?.hostApp??null),u=A(p=>p.state?.platform??null),f=A(p=>p.toast),h=t?H(t):"completed",w=t?.agent||"",m=t?.sessionId||"",[d,b]=o.useState("vscode"),[g,k]=o.useState(!0),[v,C]=o.useState(null),N=o.useRef(!1);o.useEffect(()=>{b(p=>{if(p==="finder"&&u!=="darwin")return J(l,u);if(N.current)return p;const n=J(l,u);return p===n?p:n})},[l,u]),o.useEffect(()=>{if(!i||!t){C(null);return}let p=!0,n=null,c=null;const x=()=>{c&&(clearInterval(c),c=null)},L=()=>{c||(c=setInterval(()=>{q()},1200))},q=async()=>{try{const _=await T.getSessionStreamState(t.agent||"",t.sessionId);if(!p)return;const Q=_.state?.phase??null;C(_.state?{phase:_.state.phase,activity:_.state.activity,thinking:_.state.thinking,plan:_.state.plan??null}:null),Z(h,!1,Q,n)?L():x(),n=Q}catch{}};return q(),Z(h,!1,null,null)&&L(),()=>{p=!1,x()}},[i,h,t,w,m]);const j=(u==="darwin"?["vscode","finder"]:["vscode"]).map(p=>({value:p,label:r(ne(p))})),I=o.useCallback(async p=>{try{const n=await T.openInEditor(p,d);if(!n.ok)throw new Error(n.error||`Failed to open ${p}`)}catch(n){f(n?.message||String(n),!1)}},[d,f]);if(!t||!a)return e.jsx("div",{className:"panel-isolated w-[252px] shrink-0 flex flex-col overflow-hidden rounded-xl border border-edge bg-panel backdrop-blur-sm",style:{boxShadow:"var(--th-card-shadow)"},children:e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-[12px] text-fg-5",children:r("hub.selectSessionHint")})});const B=We(t),W=t.classification?.outcome||null,S=Me(t,r),D=Be(t,h,r),R=v?.activity?.trim()||(v?.thinking?r("hub.thinkingLive"):""),F=se(v?.plan)?v.plan:null,P=t.workspacePath||a,M=!!t.workspacePath,E=t.linkedSessions?.length||0;return e.jsxs("div",{className:"panel-isolated w-[252px] shrink-0 flex flex-col overflow-hidden rounded-xl border border-edge bg-panel backdrop-blur-sm",style:{boxShadow:"var(--th-card-shadow)"},children:[e.jsx("div",{className:"shrink-0 px-3 pt-3 pb-2",children:e.jsx("div",{className:"text-[12px] font-semibold text-fg-3",children:r("hub.result")})}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-2 pb-2 space-y-3",children:[e.jsxs("div",{className:"rounded-lg border border-edge/50 bg-panel-alt/40 px-3 py-3 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(z,{variant:Te(B),children:r(`hub.status${X(B)}`)}),W&&e.jsx(z,{variant:Ie(W),children:r(`hub.outcome${X(W)}`)}),h==="running"&&e.jsx(z,{variant:"accent",children:r("hub.live")})]}),e.jsx(Y,{label:r("hub.summary"),content:S}),e.jsx(Y,{label:r("hub.nextAction"),content:D,muted:D===r("hub.noNextAction")}),F&&e.jsx(ve,{plan:F,phase:v?.phase??null,t:r,compact:!0}),R&&e.jsxs("div",{className:"rounded-md border border-ok/15 bg-ok/[0.06] px-2.5 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-[6px] w-[6px] rounded-full bg-ok animate-pulse shrink-0"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ok",children:r("hub.live")})]}),e.jsx("div",{className:"mt-1 pl-[14px] text-[11px] text-fg-4 font-mono break-words",children:R})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsx(O,{label:r("hub.lastUpdated"),value:ee(t.runUpdatedAt||t.createdAt)}),e.jsx(O,{label:r("hub.turns"),value:t.numTurns?String(t.numTurns):"—"}),e.jsx(O,{label:r("hub.workspace"),value:r(M?"hub.artifacts":"hub.projectFiles")}),e.jsx(O,{label:r("hub.linked"),value:E?String(E):"—"})]})]}),e.jsxs("div",{className:"px-2 flex items-center gap-2",children:[e.jsx(le,{value:d,options:j,onChange:p=>{ye(p)&&(N.current=!0,b(p))},renderIcon:p=>e.jsx(re,{target:p,size:18})}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>I(a),className:"flex-1 min-w-0",children:r("hub.openProject")})]}),e.jsx(Ee,{title:r(M?"hub.artifacts":"hub.projectFiles"),open:g,onToggle:()=>k(p=>!p)}),g&&(P?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"rounded-lg border border-edge/40 bg-panel-alt/20 px-3 py-2",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-fg-5",children:r(M?"hub.workspacePath":"hub.projectPath")}),e.jsx("div",{className:"mt-1 break-all font-mono text-[10px] leading-[1.5] text-fg-4",children:P}),!M&&e.jsx("div",{className:"mt-1 text-[10px] leading-[1.5] text-fg-5",children:r("hub.projectFilesHint")})]}),e.jsx(_e,{basePath:P,includeHidden:M,openTarget:d,onOpenPath:I,t:r})]}):e.jsx("div",{className:"py-3 text-center text-[11px] text-fg-5",children:r("hub.noFiles")}))]})]})});function Y({label:s,content:t,muted:a}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-fg-5",children:s}),e.jsx("div",{className:y("mt-1 text-[12px] leading-[1.6] text-fg-2",a&&"text-fg-5"),children:t})]})}function O({label:s,value:t}){return e.jsxs("div",{className:"rounded-md border border-edge/30 bg-panel/40 px-2 py-1.5",children:[e.jsx("div",{className:"text-[10px] text-fg-5",children:s}),e.jsx("div",{className:"mt-0.5 text-[11px] font-medium text-fg-2",children:t})]})}function re({target:s,size:t=16}){return s==="default"?e.jsxs("svg",{width:t,height:t,viewBox:"0 0 16 16",className:"shrink-0 text-fg-4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 3H4a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-2"}),e.jsx("path",{d:"M9 2h5v5"}),e.jsx("path",{d:"M14 2L7 9"})]}):e.jsx(te,{brand:s,size:t})}function Ee({title:s,badge:t,open:a,onToggle:i}){return e.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 w-full px-1 pt-2.5 pb-1",children:[e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:y("shrink-0 text-fg-5/50 transition-transform duration-150",a&&"rotate-90"),children:e.jsx("polyline",{points:"9 6 15 12 9 18"})}),e.jsx("span",{className:"text-[10px] font-semibold text-fg-5 uppercase tracking-wider",children:s}),t!=null&&t>0&&e.jsx("span",{className:"ml-auto text-[9px] font-medium text-fg-5 bg-panel-h rounded-full px-1.5 py-0.5 tabular-nums",children:t})]})}function _e({basePath:s,includeHidden:t=!1,openTarget:a,onOpenPath:i,t:r}){const[l,u]=o.useState([]),[f,h]=o.useState(!0);o.useEffect(()=>{let m=!1;return h(!0),T.lsDir(s,!0,t).then(d=>{!m&&d.ok&&u(d.dirs.slice(0,50).map(b=>({entry:b,expanded:!1,children:null,loading:!1})))}).catch(()=>{}).finally(()=>{m||h(!1)}),()=>{m=!0}},[s,t]);const w=o.useCallback(m=>{const d=b=>b.map(g=>g.entry.path===m?g.expanded?{...g,expanded:!1}:g.children===null?(T.lsDir(m,!0,t).then(k=>{k.ok&&u(v=>G(v,m,{children:k.dirs.slice(0,50).map(C=>({entry:C,expanded:!1,children:null,loading:!1})),loading:!1}))}).catch(()=>{u(k=>G(k,m,{children:[],loading:!1}))}),{...g,loading:!0,expanded:!0}):{...g,expanded:!0}:g.children?{...g,children:d(g.children)}:g);u(b=>d(b))},[t]);return f?e.jsx("div",{className:"flex justify-center py-3",children:e.jsx($,{className:"h-3 w-3 text-fg-5"})}):l.length===0?e.jsx("div",{className:"py-3 text-center text-[11px] text-fg-5",children:"—"}):e.jsx("div",{className:"space-y-px",children:e.jsx(ae,{nodes:l,depth:0,onToggle:w,openTarget:a,onOpenPath:i,t:r})})}function ae({nodes:s,depth:t,onToggle:a,openTarget:i,onOpenPath:r,t:l}){return e.jsx(e.Fragment,{children:s.map(u=>e.jsx(Ae,{node:u,depth:t,onToggle:a,openTarget:i,onOpenPath:r,t:l},u.entry.path))})}function Ae({node:s,depth:t,onToggle:a,openTarget:i,onOpenPath:r,t:l}){const{entry:u,expanded:f,children:h,loading:w}=s,m=t*14,[d,b]=o.useState(!1),g=l(ne(i)),k=l("hub.openWithTarget").replace("{target}",g);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{onClick:u.isDir?()=>a(u.path):void 0,onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1),className:y("flex items-center gap-1.5 py-1 rounded text-[11px] text-fg-3 transition-colors",u.isDir?"hover:bg-panel-h/50 cursor-pointer":"hover:bg-panel-h/50 cursor-default"),style:{paddingLeft:8+m,paddingRight:8},children:[u.isDir?w?e.jsx($,{className:"h-2 w-2 text-fg-5 shrink-0"}):e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:y("shrink-0 text-fg-5/40 transition-transform duration-150",f&&"rotate-90"),children:e.jsx("polyline",{points:"9 6 15 12 9 18"})}):e.jsx("span",{className:"w-2 shrink-0"}),u.isDir?e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",className:"shrink-0 text-blue-400/70",children:e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h9a2 2 0 012 2v10a2 2 0 01-2 2H4a2 2 0 01-2-2V6z",fill:"currentColor",opacity:"0.25",stroke:"currentColor",strokeWidth:"1.5"})}):e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"shrink-0 text-fg-5",children:[e.jsx("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]}),e.jsx("span",{className:"truncate flex-1",children:u.name}),d&&e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e.jsx("button",{onClick:v=>{v.stopPropagation(),r(u.path)},className:"inline-flex items-center gap-1 rounded px-1 py-0.5 text-fg-5 hover:text-blue-400 transition-colors",title:k,children:e.jsx(re,{target:i,subtle:!0})}),!u.isDir&&e.jsx(De,{filePath:u.path,t:l})]})]}),u.isDir&&f&&h&&h.length>0&&e.jsx(ae,{nodes:h,depth:t+1,onToggle:a,openTarget:i,onOpenPath:r,t:l})]})}function De({filePath:s,t}){const[a,i]=o.useState(!1);return e.jsx("button",{onClick:r=>{r.stopPropagation(),navigator.clipboard.writeText(s).then(()=>{i(!0),setTimeout(()=>i(!1),1500)}).catch(()=>{})},className:y("p-0.5 rounded transition-colors",a?"text-ok":"text-fg-5 hover:text-fg-3"),title:t("hub.copied"),children:a?e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})})}function G(s,t,a){return s.map(i=>i.entry.path===t?{...i,...a}:i.children?{...i,children:G(i.children,t,a)}:i)}function Re({active:s=!0}){return e.jsx(Ne,{active:s})}const ze=Object.freeze(Object.defineProperty({__proto__:null,SessionsTab:Re},Symbol.toStringTag,{value:"Module"}));export{ve as P,ze as S,se as h};
@@ -1 +1 @@
1
- import{j as s,r as j}from"./react-vendor-C7Sl8SE7.js";import{n as f,c as d,o as b,u as g,a as w,e as k}from"./index-BxuA85oI.js";import{S as u}from"./shared-rdDL3t6R.js";import"./router-Rwafsu7Y.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-C7Sl8SE7.js";import{n as f,c as d,o as b,u as g,a as w,e as k}from"./index-C6rqoQ_Q.js";import{S as u}from"./shared-DYK11EN0.js";import"./router-Rwafsu7Y.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};