openmausbot 0.1.97 → 0.1.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/ActivityPanel-H6D3SD39.js +1 -0
- package/dist/assets/BotSettingsDialog-Dqz_AiBZ.js +7 -0
- package/dist/assets/CloudBackendPicker-iezpJFpF.js +1 -0
- package/dist/assets/ComputerPanel-DZPj-IWu.js +1 -0
- package/dist/assets/DesktopViewer-utONms1p.js +5 -0
- package/dist/assets/InspectorPanel-OVaBVrzC.js +5 -0
- package/dist/assets/KeyboardShortcutsModal-gk9mvHj_.js +1 -0
- package/dist/assets/LocalVmWorkspace-DLIvd2kC.js +1 -0
- package/dist/assets/MacLocalControl-bJv8yiPB.js +1 -0
- package/dist/assets/NewBotDialog-1qGOAdUM.js +2 -0
- package/dist/assets/RemoteAgentSettingsPanel-DqKr0HkO.js +1 -0
- package/dist/assets/RoutinesPage-BM2D4qGi.js +1 -0
- package/dist/assets/RoutinesSection-Dny9ra-c.js +1 -0
- package/dist/assets/SettingsModal-gC6XJJmt.js +11 -0
- package/dist/assets/TeamMapPage-B6fuu4r_.js +8 -0
- package/dist/assets/TriggersPanel-j0qTP2CO.js +1 -0
- package/dist/assets/VisibilitySection-DT0FqPvu.js +12 -0
- package/dist/assets/WebhooksPanel--YQyCjKO.js +3 -0
- package/dist/assets/{abnfDiagram-O67JEVCF-k1UCNXb7.js → abnfDiagram-O67JEVCF-BsjcFX0-.js} +1 -1
- package/dist/assets/activity-BxOkayvD.js +1 -0
- package/dist/assets/{arc-BUWGa9UU.js → arc-CJNA94c6.js} +1 -1
- package/dist/assets/architectureDiagram-NJMV4G6O-dz2ud7lP.js +36 -0
- package/dist/assets/{blockDiagram-BEXU5L5S-Ag9nLW4H.js → blockDiagram-BEXU5L5S-ChBEALoR.js} +1 -1
- package/dist/assets/brain-CFZ7PEXc.js +1 -0
- package/dist/assets/{c4Diagram-YGBWAQC7-Bh0sjgUa.js → c4Diagram-YGBWAQC7-KZNRKDQe.js} +1 -1
- package/dist/assets/channel-WhFyujhZ.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-BFBcIIqu.js → chunk-2Q5K7J3B-BLLwmCET.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-Dvfpex-f.js → chunk-3FUC2YCW-CQxyreBZ.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-CMjP2YZW.js → chunk-5VM5RSS4-D6sFMW0u.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-BryoeTc7.js → chunk-GTNCS2PH-BaZ1YgLF.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-BhfvcchO.js → chunk-GWA4HPMP-CcalphmC.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-bcCVp8rp.js → chunk-JWPE2WC7-CSk8R3ve.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-yKIjIlkQ.js → chunk-NETBCI7D-CTmLjA57.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-D3Zqbmup.js → chunk-WEXAMYUT-CM9Z77Ne.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-CjVoIMG6.js → chunk-XXDRQBXY-B1fxpMS2.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-mUCWdVyH.js → classDiagram-v2-NBCMYWYE-DCCyoLpj.js} +1 -1
- package/dist/assets/computer-control-NLov352p.js +1 -0
- package/dist/assets/cose-bilkent-JH36ORCC-KyImBKvE.js +1 -0
- package/dist/assets/{cynefin-OW5HDTMX-BpRrxoO4.js → cynefin-OW5HDTMX-fsZc6MGa.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-D3VBWCPK.js → cynefinDiagram-VND7K2PF-CGmHsShB.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-DxEIACOO.js → dagre-6A5THRUB-Dah1h-CH.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-BANgZEOS.js → diagram-22UHCM2B-BIu71OyV.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-Cnq7nJir.js → diagram-3UASUU5V-gxhUB_Mu.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-4TBDIWnz.js → diagram-ATOU4E4O-CBhusUBn.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-CD_B39D4.js → diagram-CDSNMT55-BdPrc86x.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-CzvnFhEC.js → diagram-MLGK6HIB-Clp110R_.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-C4w2SNml.js → diagram-MPIPVDR6-DJKfbugw.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-gkUEBm2s.js → ebnfDiagram-ZINNZB2B-DnsltoBu.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-B_56X6mw.js → elk-276RUBZZ-jWdq6gqH.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-C_oByoDS.js → erDiagram-OPXOYQCR-DArPVf8u.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-CR9xXJkC.js → flowDiagram-KWPJA3E3-D2HZ-2f7.js} +1 -1
- package/dist/assets/ganttDiagram-FUAMR5RP--o0KIxEo.js +292 -0
- package/dist/assets/{gitGraphDiagram-X574FWY7-VJ6-Tp_p.js → gitGraphDiagram-X574FWY7-CsoXr2D7.js} +1 -1
- package/dist/assets/image-plus-BbVjGHin.js +1 -0
- package/dist/assets/index-BrPW5HDO.css +1 -0
- package/dist/assets/index-C3NqfdVU.js +585 -0
- package/dist/assets/{index-Cp4S4NOL.js → index-CJTp9JEp.js} +1 -1
- package/dist/assets/{infoDiagram-VRGFBTTK-2Lu9te4D.js → infoDiagram-VRGFBTTK-g-6lNp7r.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-DR49XY-e.js → ishikawaDiagram-OU5B5YK6-B1d6qVTV.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-ZoR0M305.js → journeyDiagram-ZHPQQLJL-BTPuiU6T.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-DLKHxrO-.js → kanban-definition-PNTS6WVX-bDDuRJvP.js} +1 -1
- package/dist/assets/{linear-BASsfWly.js → linear-BVVKbEMy.js} +1 -1
- package/dist/assets/{mermaid.core-BVidiPkk.js → mermaid.core-JJdoKyKB.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-g_Qx0U5C.js → mindmap-definition-NLK3R4M7-B4aE3T0q.js} +1 -1
- package/dist/assets/module-DCUsy2BQ.js +3 -0
- package/dist/assets/page-visible-BBo_Zm8g.js +1 -0
- package/dist/assets/{pegDiagram-GJSIUBJH-DI9Cjs8w.js → pegDiagram-GJSIUBJH-DFKQWpR7.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-sRI0Uhr5.js → pieDiagram-5QR66LMP-Iv7OKVJi.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-CamKTby3.js → quadrantDiagram-O4NWA36T-U2YnfwBk.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-DOLlkbf3.js → railroadDiagram-XR7U4H2S-CuPy6RqM.js} +1 -1
- package/dist/assets/remote-desktop-panel-BNEj7tUx.js +1 -0
- package/dist/assets/{requirementDiagram-PLB6GJNP-DrRQ5r97.js → requirementDiagram-PLB6GJNP-bMI5AK7T.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-DGS_lXcX.js → sankeyDiagram-IPEJSGJF-BKcFE2WQ.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-CkjWqwtf.js → sequenceDiagram-PO4LG4MO-Bn9q88kl.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-CepRgful.js → sizeCapture-INFHLROL-Cvmdq9HD.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-hykr-9RS.js → stateDiagram-v2-GCMORJYK-JJQYw3eQ.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-CKOHEZbI.js → swimlanes-2SLR337P-BkSCBEwp.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-CmTirbVT.js +8 -0
- package/dist/assets/table-file.worker-KkMx-SNx.js +10 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-CB8pJ6AC.js → timeline-definition-EJHVYXUP-DsaM4GHr.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-DrclJHdl.js → usecaseDiagram-POWQR4AR-3FOwLq7B.js} +1 -1
- package/dist/assets/user-DcZBnAuv.js +1 -0
- package/dist/assets/{vennDiagram-UO4OBE2U-zS23qjv8.js → vennDiagram-UO4OBE2U-DyNjJsKt.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-52jgeKxz.js → wardleyDiagram-VNRHLVJA-Y4ZMcnBC.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-DSdl9rQ8.js → xychartDiagram-PMCCYNJV-BXZpg955.js} +1 -1
- package/dist/index.html +2 -2
- package/dist-server/cloud-home-start.js +19 -8
- package/dist-server/container-mcp.js +8 -0
- package/dist-server/desktop-entry.mjs +54 -0
- package/dist-server/drivers/agents-proxy.js +21 -4
- package/dist-server/index.js +1412 -821
- package/dist-server/openmausbot.js +837 -571
- package/dist-server/pair-cli.js +837 -571
- package/dist-server/permission-proxy.js +2 -0
- package/dist-server/server/atomic.js +70 -2
- package/dist-server/server/cloud-home-start.js +3 -3
- package/dist-server/server/config.js +22 -1
- package/dist-server/server/connector-card-text.js +15 -0
- package/dist-server/server/default-model-selection.js +7 -4
- package/dist-server/server/drivers/acp/core.js +10 -0
- package/dist-server/server/drivers/acp/grok.js +47 -5
- package/dist-server/server/drivers/agents-catalog.js +24 -4
- package/dist-server/server/drivers/agents-proxy.js +1 -0
- package/dist-server/server/drivers/chat-mcp-tools.js +5 -3
- package/dist-server/server/drivers/claude-login-auth.js +1 -1
- package/dist-server/server/drivers/claude.js +35 -11
- package/dist-server/server/drivers/codex-device-auth.js +27 -319
- package/dist-server/server/drivers/device-auth.js +342 -0
- package/dist-server/server/drivers/openai-chat.js +12 -4
- package/dist-server/server/fleet-agent.js +18 -5
- package/dist-server/server/harness/http.js +5 -2
- package/dist-server/server/harness/registry.js +19 -0
- package/dist-server/server/harness-capabilities.js +7 -4
- package/dist-server/server/hosted-models.js +3 -1
- package/dist-server/server/index.js +268 -54
- package/dist-server/server/key-rejections.js +57 -0
- package/dist-server/server/message-file.js +7 -4
- package/dist-server/server/permission-proxy.js +4 -0
- package/dist-server/server/provider-key-check.js +5 -1
- package/dist-server/server/request-auth.js +1 -1
- package/dist-server/server/room-turn-timeout.js +28 -0
- package/dist-server/server/routes/thread-models.js +36 -0
- package/dist-server/server/routines.js +2 -2
- package/dist-server/server/skills.js +3 -2
- package/dist-server/server/store.js +148 -60
- package/dist-server/server/team-backup.js +19 -4
- package/dist-server/server/thread-model.js +25 -0
- package/dist-server/server/turn-continuation.js +8 -2
- package/dist-server/server/webhook-ingress.js +8 -3
- package/dist-server/server/webhooks.js +40 -5
- package/dist-server/shared/device-sign-in.js +57 -0
- package/dist-server/shared/team-backup.js +2 -0
- package/dist-server/shared/thread-model.js +13 -0
- package/dist-server/vps-container-mcp.js +8 -0
- package/dist-server/workspace-backup.worker.js +41 -22
- package/package.json +1 -1
- package/dist/assets/DesktopViewer-CPidMCtt.js +0 -5
- package/dist/assets/architectureDiagram-NJMV4G6O-DiPor3UT.js +0 -36
- package/dist/assets/channel-DR8eD6QW.js +0 -1
- package/dist/assets/cose-bilkent-JH36ORCC-BBmR1bbX.js +0 -1
- package/dist/assets/ganttDiagram-FUAMR5RP-gtYBTu0B.js +0 -292
- package/dist/assets/index-CpaIXRLp.js +0 -614
- package/dist/assets/index-Z81SMsgR.css +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-D-8vqZ4-.js +0 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as g,a as v,r,l as b,j as e,L as j,R as N,X as I,c as y}from"./index-C3NqfdVU.js";import{g as C,o as A,f as E}from"./activity-BxOkayvD.js";const $=300,w={ok:"bg-accent/12 text-accent",danger:"bg-danger/15 text-danger",accent:"bg-accent/12 text-accent",warn:"bg-warning/15 text-warning"};function T({bot:t}){const{dispatch:o}=g(),{padClass:p}=v(),[n,u]=r.useState(null),[d,h]=r.useState(null),c=r.useRef(null),i=r.useCallback(async()=>{c.current?.abort();const s=new AbortController;c.current=s;try{const a=await fetch(`/api/bots/${t.id}/activity?limit=${$}`,{signal:s.signal});if(!a.ok)throw new Error(`${a.status}`);const x=await a.json();if(s.signal.aborted)return;u(x.rows),h(null)}catch(a){if(s.signal.aborted)return;h(a instanceof Error?a.message:String(a))}finally{c.current===s&&(c.current=null)}},[t.id]);r.useEffect(()=>(u(null),i(),()=>c.current?.abort()),[i]);const m=r.useMemo(()=>new Set([t.threadId,...(t.tasks??[]).map(s=>s.threadId)]),[t.threadId,t.tasks]);r.useEffect(()=>{let s=null;const a=b({onMissedFrames:()=>{i()},onFrame:x=>{if(x.kind!=="runtime")return;const l=x.event;m.has(l.threadId)&&(l.type==="turn.completed"||l.type==="runtime.error"||l.type==="request.opened"||l.type==="request.resolved"||l.type==="item.completed")&&(s&&clearTimeout(s),s=setTimeout(()=>{i()},400))}});return()=>{a(),s&&clearTimeout(s)}},[m,i]);const f=r.useMemo(()=>n?C(n,new Date):[],[n]),k=s=>{s.threadId!==t.threadId&&m.has(s.threadId)&&o({type:"switchTask",botId:t.id,threadId:s.threadId})};return e.jsxs("aside",{"aria-label":`${t.name} activity`,className:"animate-panel-in flex h-full w-[400px] max-w-full shrink-0 flex-col border-l border-hairline/40 bg-panel max-md:absolute max-md:inset-y-0 max-md:right-0 max-md:z-30",children:[e.jsxs("div",{className:y("flex items-center justify-between px-4 py-3",p),children:[e.jsxs("span",{className:"flex items-center gap-2 text-[15px] font-semibold text-ink",children:[e.jsx(j,{size:16,className:"text-ink-secondary"})," Activity"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>{i()},className:"rounded-md p-1 text-ink-secondary hover:bg-raised hover:text-ink",title:"Reload","aria-label":"Reload activity",children:e.jsx(N,{size:14})}),e.jsx("button",{onClick:()=>o({type:"toggleActivity",open:!1}),"aria-label":"Close Activity",title:"Close Activity",className:"rounded-md p-1 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(I,{size:18})})]})]}),e.jsxs("p",{className:"border-b border-hairline/40 px-4 pb-3 text-[12px] text-ink-secondary",children:["Every tool ",t.name," used and every approval it asked for, newest first."]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[d&&e.jsxs("div",{className:"px-4 py-3 text-[13px] text-danger",children:["couldn't load: ",d]}),n&&n.length===0&&!d&&e.jsxs("div",{className:"px-4 py-6 text-[13px] text-ink-secondary",children:["Nothing yet. Once ",t.name," runs a tool or asks for an approval, it shows up here."]}),!n&&!d&&e.jsx("div",{className:"px-4 py-6 text-[13px] text-ink-secondary",children:"Loading…"}),f.map(s=>e.jsxs("section",{children:[e.jsx("h3",{className:"sticky top-0 bg-panel px-4 pt-3 pb-1 text-[11px] font-semibold tracking-wide text-ink-secondary uppercase",children:s.label}),s.rows.map(a=>e.jsx(L,{row:a,current:a.threadId===t.threadId,onJump:()=>k(a)},`${a.threadId}:${a.at}:${a.tool}:${a.requestId??""}`))]},s.key))]})]})}function L({row:t,current:o,onJump:p}){const n=A(t.outcome);return e.jsxs("button",{type:"button",onClick:p,className:"flex w-full items-start gap-3 border-b border-hairline/20 px-4 py-2 text-left hover:bg-raised/60",title:o?t.tool:`${t.tool} — in another task; click to open it`,children:[e.jsx("span",{className:"mt-[2px] shrink-0 tabular-nums text-[11px] text-ink-secondary",children:E(t.at)}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-[13px] text-ink",children:[t.app&&e.jsx("span",{className:"font-medium",children:t.app}),t.app&&e.jsx("span",{className:"text-ink-secondary",children:"·"}),e.jsx("span",{className:"truncate",children:t.label})]}),t.summary&&e.jsx("span",{className:"mt-0.5 block truncate font-mono text-[11px] text-ink-secondary",children:t.summary})]}),e.jsx("span",{className:y("mt-[2px] shrink-0 rounded px-1.5 py-0.5 text-[10.5px] font-medium",w[n.tone]),children:n.text})]})}export{T as ActivityPanel};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{k as re,aO as Se,aE as Ae,C as Ue,aL as Be,ae as De,aP as Ie,aQ as Pe,j as t,a7 as Ce,c as k,r as u,t as m,a3 as pe,E as ze,g as b,A as $e,av as He,u as le,aR as Fe,aS as _e,q as Me,F as Re,T as qe,aT as Ve,aU as We,aV as Ke,aW as Je,aX as Ye,aY as Ge,aZ as he,a_ as Qe,a$ as Xe,b0 as Ze,X as Le,B as et,U as ge,b1 as tt,b2 as st,a8 as nt,b3 as at,ak as it,a5 as rt,b4 as lt,b5 as ot,b6 as ye,al as ct,a as dt,b7 as xt,ah as mt,Q as ut,S as pt,aK as ht}from"./index-C3NqfdVU.js";import{U as gt,C as yt}from"./user-DcZBnAuv.js";import{B as ft}from"./brain-CFZ7PEXc.js";import{w as Ee}from"./RoutinesPage-BM2D4qGi.js";import{i as fe,u as vt,b as kt,c as bt,d as jt,V as Nt,P as wt,M as St,A as Ct,a as $t,S as Mt,I as Rt}from"./VisibilitySection-DT0FqPvu.js";import{R as Lt}from"./RoutinesSection-Dny9ra-c.js";import"./WebhooksPanel--YQyCjKO.js";import"./image-plus-BbVjGHin.js";import"./CloudBackendPicker-iezpJFpF.js";const Et=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Ot=re("cpu",Et);const Tt=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],At=re("history",Tt);const Ut=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],Bt=re("layout-dashboard",Ut);const Dt=[["rect",{width:"3",height:"8",x:"13",y:"2",rx:"1.5",key:"diqz80"}],["path",{d:"M19 8.5V10h1.5A1.5 1.5 0 1 0 19 8.5",key:"183iwg"}],["rect",{width:"3",height:"8",x:"8",y:"14",rx:"1.5",key:"hqg7r1"}],["path",{d:"M5 15.5V14H3.5A1.5 1.5 0 1 0 5 15.5",key:"76g71w"}],["rect",{width:"8",height:"3",x:"14",y:"13",rx:"1.5",key:"1kmz0a"}],["path",{d:"M15.5 19H14v1.5a1.5 1.5 0 1 0 1.5-1.5",key:"jc4sz0"}],["rect",{width:"8",height:"3",x:"2",y:"8",rx:"1.5",key:"1omvl4"}],["path",{d:"M8.5 5H10V3.5A1.5 1.5 0 1 0 8.5 5",key:"16f3cl"}]],It=re("slack",Dt),Pt=[{id:"overview",label:"Overview",icon:Bt,keywords:["summary","status","what it does","won't","prompt","what the model sees"]},{id:"identity",label:"Identity",icon:gt,keywords:["name","title","avatar","blurb","instructions"]},{id:"slack",label:"Slack",icon:It,keywords:["slack","slack app","admin","message","direct messages","mentions"]},{id:"soul",label:"Soul",icon:Se,keywords:["standing instructions","instructions","persona","rules","soul.md"]},{id:"skills",label:"Skills",icon:Ae,keywords:["skills","learned","procedures","teach"]},{id:"memory",label:"Memory",icon:ft,keywords:["memory","notes","remember","topics"]},{id:"routines",label:"Routines",icon:Ue,keywords:["schedule","routines","cron","tasks"]},{id:"access",label:"Access",icon:Be,keywords:["works on","computer","vm","cloud","vps","folder","workspace","browser","connected apps","composio","webhooks","always allow","grants","tool selection","tools","mcp","allow","exclude"]},{id:"model",label:"Model",icon:Ot,keywords:["engine","model","provider","cli","effort"]},{id:"permissions",label:"Permissions",icon:De,keywords:["auto mode","approve","auto approve","review","routine approvals","peers","contact","coordination","chief of staff","section"]},{id:"voice",label:"Voice & alerts",icon:Ie,keywords:["voice","alerts","notifications","speak"]},{id:"visibility",label:"Who can see it",labelKey:"botSettings.visibility.title",icon:Pe,keywords:["visibility","who can see","private","people","admins","members","access","hide"]},{id:"history",label:"History",icon:At,keywords:["history","changes","undo","rollback","log"]},{id:"usage",label:"Usage",icon:yt,keywords:["tokens","cost","billing"]}];function zt({data:e,error:s,open:i,onToggle:a}){return t.jsxs("div",{className:"rounded-xl bg-card p-4",children:[t.jsxs("button",{type:"button",onClick:a,"aria-expanded":i,className:"flex w-full items-center justify-between gap-3 text-left",children:[t.jsx("span",{className:"text-[15px] font-medium text-ink",children:e?`Prompt preview · ${e.totalBytes.toLocaleString()} bytes ≈ ${e.approxTokens.toLocaleString()} tokens`:"Prompt preview"}),t.jsx(Ce,{size:16,className:k("shrink-0 text-ink-secondary transition-transform",i&&"rotate-180")})]}),i&&!e&&s&&t.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:"Couldn’t load the prompt preview."}),i&&!e&&!s&&t.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:"Loading…"}),i&&e&&t.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[e.sections.map(l=>t.jsxs("details",{className:"rounded-lg border border-hairline/40 bg-inset px-3 py-2",children:[t.jsxs("summary",{className:"flex cursor-pointer items-center justify-between gap-3 text-[13px] text-ink",children:[t.jsx("span",{children:l.label}),t.jsxs("span",{className:"shrink-0 tabular-nums text-ink-secondary",children:[l.bytes.toLocaleString()," bytes"]})]}),t.jsx("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words font-mono text-[12px] leading-relaxed text-ink",children:l.text})]},l.id)),e.note&&t.jsx("div",{className:"text-[11px] text-ink-secondary",children:e.note})]})]})}function Ht({overview:e,refreshError:s,prompt:i,promptError:a,onOpen:l,onSetup:r}){const[o,y]=u.useState(!1);if(!e)return t.jsx("div",{className:"text-[13px] text-ink-secondary",children:"Loading…"});const f=(e.setup??[]).filter(h=>!h.done);return t.jsxs("div",{className:"flex flex-col gap-4",children:[s&&t.jsx("div",{className:"rounded-lg bg-inset px-3 py-2 text-[12.5px] text-ink-secondary",children:"Couldn’t refresh — showing the last loaded overview."}),f.length>0&&t.jsxs("div",{className:"rounded-xl border border-accent/30 bg-accent/[0.06] p-4",children:[t.jsx("div",{className:"text-[15px] font-medium text-ink",children:m("botSetup.ideas")}),t.jsx("p",{className:"mt-1 text-[13px] text-ink-secondary",children:m("botSetup.optional")}),t.jsx("ul",{className:"mt-2 flex flex-col gap-1",children:f.map(h=>t.jsx("li",{children:h.section?t.jsxs("button",{type:"button",onClick:()=>l(h.section),className:"flex w-full items-center gap-2.5 rounded-lg px-1 py-1 text-left text-[13px] text-ink hover:bg-inset",children:[t.jsx(pe,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),t.jsx("span",{className:"flex-1",children:h.label}),t.jsx("span",{className:"text-[12px] text-ink-secondary",children:"→"})]}):t.jsxs("div",{className:"flex items-center gap-2.5 px-1 py-1 text-[13px] text-ink",children:[t.jsx(pe,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),t.jsx("span",{children:h.label})]})},h.id))}),r&&t.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[t.jsxs("button",{type:"button",onClick:r,className:"flex items-center gap-1.5 rounded-lg bg-accent px-3 py-2 text-[12.5px] font-medium text-accent-ink hover:brightness-110",children:[t.jsx(Se,{size:14})," ",m("botSetup.withBot")]}),t.jsx("span",{className:"text-[12px] text-ink-secondary",children:m("botSetup.help")})]})]}),t.jsxs("div",{className:"rounded-xl bg-card p-4",children:[t.jsx("div",{className:"text-[15px] font-medium text-ink",children:e.who.name}),e.who.title&&t.jsx("div",{className:"mt-0.5 text-[13px] text-ink-secondary",children:e.who.title}),e.who.blurb&&t.jsx("p",{className:"mt-2 text-[13px] leading-relaxed text-ink",children:e.who.blurb}),e.who.soulLead&&t.jsxs("div",{className:"mt-3 rounded-lg bg-inset px-3 py-2.5",children:[t.jsx("p",{className:"text-[13px] leading-relaxed text-ink-secondary",children:e.who.soulLead}),t.jsx("button",{type:"button",onClick:()=>l("soul"),className:"mt-1.5 rounded-md text-[12px] font-medium text-accent-text hover:underline",children:"Read all"})]})]}),t.jsxs("div",{className:"rounded-xl bg-card p-4",children:[t.jsx("div",{className:"text-[15px] font-medium text-ink",children:"Does"}),e.does.length===0?t.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:"Nothing scheduled or learned yet."}):t.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:e.does.map((h,p)=>t.jsx("li",{children:h},p))})]}),t.jsxs("div",{className:"rounded-xl bg-card p-4",children:[t.jsx("div",{className:"text-[15px] font-medium text-ink",children:"Can reach"}),e.reaches.length===0?t.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:"Nothing yet."}):t.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:e.reaches.map((h,p)=>t.jsx("li",{children:h},p))})]}),t.jsxs("div",{className:"rounded-xl bg-card p-4",children:[t.jsx("div",{className:"text-[15px] font-medium text-ink",children:"Won’t"}),t.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:e.wont.map((h,p)=>t.jsx("li",{children:h},p))})]}),t.jsx(zt,{data:i,error:a,open:o,onToggle:()=>y(h=>!h)}),t.jsxs("div",{className:"rounded-xl bg-card p-4",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[t.jsx("div",{className:"text-[15px] font-medium text-ink",children:"Recent changes"}),t.jsx("button",{type:"button",onClick:()=>l("history"),className:"shrink-0 text-[12px] text-ink-secondary hover:text-ink",children:"View all →"})]}),e.recent.length===0?t.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:"Nothing changed recently."}):t.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] text-ink",children:e.recent.map((h,p)=>t.jsxs("li",{className:"flex items-baseline justify-between gap-3",children:[t.jsx("span",{className:"min-w-0 truncate",children:h.summary}),t.jsxs("span",{className:"shrink-0 text-[11.5px] text-ink-secondary",children:["· ",Ee(h.at)]})]},p))})]})]})}function Ft({managementUrl:e}){return t.jsxs("div",{className:"flex flex-col gap-3 text-[13px] leading-relaxed text-ink-secondary",children:[t.jsx("p",{children:m("botSlack.body")}),t.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"flex w-fit items-center gap-2 rounded-lg bg-control px-3 py-2 font-medium text-ink hover:bg-control/70",children:[m("botSlack.manage")," ",t.jsx(ze,{size:14,"aria-hidden":"true"})]})]})}function _t(e){if(!e||typeof e!="object")return null;const{available:s,managementUrl:i}=e;if(s!==!0||typeof i!="string")return null;try{return new URL(i).protocol==="https:"?i:null}catch{return null}}function qt(e){const[s,i]=u.useState(null);return u.useEffect(()=>{const a=new AbortController;return b(`/api/bots/${encodeURIComponent(e)}/slack-management`,{signal:a.signal,timeoutMs:1e4}).then(l=>{a.signal.aborted||i({botId:e,url:_t(l)})}).catch(()=>{a.signal.aborted||i({botId:e,url:null})}),()=>a.abort()},[e]),s?.botId===e?s.url:null}const D="MEMORY.md";function Vt(e){return b(`/api/bots/${e}/memory`)}function ve(e,s){return b(`/api/bots/${e}/memory/file?path=${encodeURIComponent(s)}`)}async function Wt(e,s,i,a){const l=await fetch(`/api/bots/${e}/memory/file`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({path:s,text:i,expectedHash:a})}),r=await l.json().catch(()=>({}));if(l.status===409&&typeof r.current=="string"&&typeof r.currentHash=="string")return{ok:!1,conflict:!0,current:r.current,currentHash:r.currentHash};if(!l.ok)throw new $e(typeof r.error=="string"?r.error:`${l.status} ${l.statusText}`,l.status);const o=r;return{ok:!0,doc:{path:o.path,text:o.text,hash:o.hash,exists:o.exists},overview:o.overview}}function Kt(e,s){return b(`/api/bots/${e}/memory/file?path=${encodeURIComponent(s)}`,{method:"DELETE"})}async function G(e,s=50){return(await b(`/api/bots/${e}/memory/journal?limit=${s}`)).entries}function Jt(e,s){return b(`/api/bots/${e}/memory/journal/${encodeURIComponent(s)}/revert`,{method:"POST"})}function xe(e){return e?e.added+(e.topics??0):0}function ke(e){return b(`/api/bots/${e}/memory/upkeep`)}function Yt(e,s){return b(`/api/bots/${e}/memory/reviewed`,{method:"POST",body:JSON.stringify({token:s})})}function Gt(e){return b(`/api/bots/${e}/memory/tidy`,{method:"POST"})}function Oe(e){const s=[];e.expired&&s.push(`archived ${e.expired} expired note${e.expired===1?"":"s"}`),e.duplicates&&s.push(`merged ${e.duplicates} duplicate${e.duplicates===1?"":"s"}`),e.superseded&&s.push(`crossed out ${e.superseded} contradicted note${e.superseded===1?"":"s"}`),e.organized&&s.push(`filed ${e.organized} note${e.organized===1?"":"s"} into topics`);const i=s.length?s.join(", "):"nothing to tidy";return i.charAt(0).toUpperCase()+i.slice(1)}function Qt(e,s){return b(`/api/bots/${e}/memory/open`,{method:"POST",body:JSON.stringify({target:s})})}function I(e){return e<1024?`${e} B`:`${Math.round(e/102.4)/10} KB`}function ie(e,s=Date.now()){const i=Math.max(0,Math.round((s-e)/1e3));if(i<45)return"just now";const a=Math.round(i/60);if(a<60)return`${a} min ago`;const l=Math.round(a/60);if(l<24)return`${l} hr ago`;const r=Math.round(l/24);return r===1?"yesterday":r<7?`${r} days ago`:new Date(e).toLocaleDateString([],{month:"short",day:"numeric"})}function Xt(e){const s=e.maxLines?e.lines/e.maxLines:0,i=e.maxBytes?e.bytes/e.maxBytes:0,a=e.truncated?"over":Math.max(s,i)>=.8?"near":"ok",l=`${e.lines} of ${e.maxLines} lines · ${I(e.bytes)} of ${I(e.maxBytes)} — only the first ${e.maxLines} lines load each turn.`;let r=null;if(e.truncated){const o=e.lines-e.loadedLines;r=o>0?`${e.lines} lines saved, ${e.loadedLines} load into every conversation — ${o} ${o===1?"line is":"lines are"} not being loaded. Trim this file or move notes into a topic file.`:`${I(e.bytes)} saved, ${I(e.loadedBytes)} load into every conversation — the rest is not being loaded. Trim this file or move notes into a topic file.`}return{level:a,lineShare:s,byteShare:i,sentence:l,warning:r}}function Zt(e){return e===D?"MEMORY.md":e.startsWith("memory/log/")?`the ${e.slice(11).replace(/\.md$/,"")} log`:e.replace(/^memory\//,"").replace(/\.md$/,"")}function es(e,s){const i=e.actor==="bot"?s:e.actor==="import"?"An import":e.actor==="upkeep"?"Memory upkeep":"You",a=Zt(e.path),r=e.path===D||e.path.startsWith("memory/log/")?a:`the ${a} topic`;return e.kind==="created"?`${i} created ${r}${e.added?` with ${ae(e.added,"line")}`:""}`:e.kind==="deleted"?`${i} deleted ${r}`:e.added&&!e.removed?`${i} added ${ae(e.added,"line")} to ${r}`:e.removed&&!e.added?`${i} removed ${ae(e.removed,"line")} from ${r}`:`${i} rewrote ${ae(Math.max(e.added,e.removed),"line")} in ${r}`}function ae(e,s){return`${e} ${s}${e===1?"":"s"}`}function ts(e){return e.via==="revert"?"undo":e.via==="disk"?"changed outside the app":e.via==="tidy"?"tidy-up":e.via==="organize"?"filed into topics":e.via==="capture"?e.threadTitle?`noticed in chat “${e.threadTitle}”`:"noticed in a chat":e.threadTitle?`from chat “${e.threadTitle}”`:e.actor==="bot"?"during a task":e.via==="ui"?"in Settings":e.via==="api"?"through the API":null}function ss(e){return e==="darwin"?"Show in Finder":e==="win32"?"Show in Explorer":"Show in file manager"}function ns(e){const s=e.trim().replace(/\.md$/i,"").replace(/[^\w .-]+/g,"-").replace(/^[^\w]+/,"").trim();return s?`${s}.md`:null}const T="rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",me="rounded-md px-2 py-1 text-[12.5px] text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-50",O=e=>e instanceof Error?e.message:String(e);function as({changed:e,stale:s,busy:i,onReviewed:a}){return t.jsxs("div",{role:"status",className:"rounded-xl border border-danger/40 bg-card p-4",children:[t.jsx("p",{className:"text-[13px] leading-relaxed text-ink",children:m(s?"memory.lendingReviewStale":"memory.lendingReview")}),e.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:m("memory.lendingReviewChanged")}),t.jsx("ul",{className:"mt-1 space-y-0.5",children:e.map(l=>t.jsx("li",{className:"break-all font-mono text-[12px] text-ink",children:l},l))})]}),t.jsx("button",{type:"button",className:k(T,"mt-3"),disabled:i,onClick:a,children:m("memory.lendingReviewed")})]})}function is({bot:e,active:s=!0,onToggle:i}){const{capabilities:a}=He(),[l,r]=u.useState(null),[o,y]=u.useState(null),[c,f]=u.useState(null),[h,p]=u.useState(null),[j,N]=u.useState(null),[R,v]=u.useState(null),[w,C]=u.useState(null),[$,P]=u.useState(!1),[A,U]=u.useState(null),[x,L]=u.useState(""),[Q,z]=u.useState(null),[oe,X]=u.useState(!1),[q,V]=u.useState(null),[W,Z]=u.useState(!1),[ee,K]=u.useState(!1),{dispatch:J}=le(),te=async n=>{const[d,M,B]=await Promise.all([Vt(e.id),G(e.id),ke(e.id).catch(()=>null)]);if(r(d),V(d.lendingReview??null),y(M),z(B),n){const E=await ve(e.id,n);f({path:E.path,text:E.text,hash:E.hash,dirty:!1,readOnly:n.startsWith("memory/log/")})}};u.useEffect(()=>{if(!s)return;let n=!1;v(null);const d=c?.dirty===!0;return te(d?void 0:c?.path??D).catch(M=>{n||v(O(M))}),()=>{n=!0}},[s,e.id]);const S=async n=>{v(null),p(null);try{const d=await ve(e.id,n);f({path:d.path,text:d.text,hash:d.hash,dirty:!1,readOnly:n.startsWith("memory/log/")})}catch(d){v(O(d))}},Y=async n=>{if(c){P(!0),v(null);try{const d=await Wt(e.id,c.path,c.text,n);if(!d.ok){p({path:c.path,current:d.current,currentHash:d.currentHash});return}p(null),N(null),f({...c,text:d.doc.text,hash:d.doc.hash,dirty:!1}),r(d.overview),y(await G(e.id))}catch(d){v(O(d))}finally{P(!1)}}},se=()=>{!h||!c||(N(c.text),f({...c,text:h.current,hash:h.currentHash,dirty:!1}),p(null))},H=async n=>{if(window.confirm(`Delete ${n.name}? The journal below can bring it back.`)){v(null);try{const{overview:d}=await Kt(e.id,n.path);r(d),y(await G(e.id)),c?.path===n.path&&f(null)}catch(d){v(O(d))}}},F=async()=>{const n=ns(x);if(!n){v("Give the topic a name — letters, numbers, spaces, dots or dashes.");return}L(""),await S(`memory/${n}`),f(d=>d&&{...d,dirty:!0,text:d.text||rs(n)})},ce=async n=>{U(n.id),v(null);try{const d=await Jt(e.id,n.id);r(d.overview),y(await G(e.id)),c?.path===n.path&&!c.dirty&&f({...c,text:d.text,hash:d.hash}),C(`Put ${n.path} back the way it was.`)}catch(d){v(O(d))}finally{U(null)}},_=async n=>{v(null),C(null);try{await Qt(e.id,n)}catch(d){v(O(d))}},de=()=>{const n=e.memoryUpkeep===!1;J({type:"updateBot",botId:e.id,patch:{memoryUpkeep:n}}),z(d=>d&&{...d,enabled:n})},ne=async()=>{X(!0),v(null),C(null);try{const{report:n,overview:d}=await Gt(e.id);r(d),y(await G(e.id)),z(await ke(e.id)),c&&!c.dirty&&await S(c.path),C(`${Oe(n)}.${n.note?` ${n.note}`:""}`)}catch(n){v(O(n))}finally{X(!1)}},g=a.host.homeDir;return t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"rounded-xl bg-card p-4",children:[t.jsx("div",{className:"text-[15px] font-medium text-ink",children:"Memory"}),t.jsxs("label",{className:"mt-3 flex items-center gap-2 text-[13px] text-ink",children:[t.jsx("input",{type:"checkbox",checked:e.memoryEnabled!==!1,disabled:e.busy,onChange:n=>i(n.target.checked)}),"Let this bot use memory"]}),t.jsxs("p",{className:"mt-1 text-[12.5px] text-ink-secondary",children:["Off stops memory prompts, recall, native memory tools, upkeep, and automatic turn logs. Existing files remain available for review.",e.busy?" Stop this bot's turn before changing this setting.":""]}),t.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:"Notes this bot keeps between tasks. They are plain markdown files in a folder on this computer — open them in any editor, or in Obsidian."}),l&&t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink-secondary",title:l.workspacePath,children:Fe(l.workspacePath,g)}),t.jsx("button",{type:"button",className:T,onClick:()=>{_("obsidian")},children:"Open in Obsidian"}),t.jsxs("button",{type:"button",className:k(T,"inline-flex items-center gap-1.5"),onClick:()=>{_("folder")},children:[t.jsx(_e,{size:14}),ss(a.host.platform)]})]})]}),q&&t.jsx(as,{changed:q.changed,stale:W,busy:ee,onReviewed:()=>{K(!0),Yt(e.id,q.token).then(()=>{V(null),Z(!1)}).catch(n=>{if(n instanceof $e&&n.status===409)return Z(!0),te();v(O(n))}).finally(()=>K(!1))}}),l&&t.jsx(os,{index:l.index}),e.memoryEnabled!==!1&&t.jsx(ls,{enabled:e.memoryUpkeep!==!1,status:Q,tidying:oe,onToggle:de,onTidy:()=>{ne()}}),c&&t.jsxs("div",{className:"rounded-xl bg-card p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"truncate font-mono text-[12.5px] text-ink",children:c.path}),c.path!==D&&t.jsx("button",{type:"button",className:me,onClick:()=>{S(D)},children:"Back to MEMORY.md"})]}),h&&t.jsx(cs,{botName:e.name,busy:$,onReload:se,onOverwrite:()=>{Y(h.currentHash)}}),t.jsx("textarea",{className:k(fe,"mt-2 min-h-[200px] resize-y font-mono text-[12.5px] leading-relaxed"),value:c.text,readOnly:c.readOnly,placeholder:c.path===D?"Nothing remembered yet. The bot writes durable notes here — or add your own.":"Write the note here.","aria-label":c.path===D?"Bot memory":`Memory file ${c.path}`,onChange:n=>f({...c,text:n.target.value,dirty:!0})}),c.readOnly?t.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:"Daily logs are the bot's own record of what it did; they are not loaded into conversations and are read-only here."}):t.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[t.jsx("button",{type:"button",onClick:()=>{Y(c.hash)},disabled:$||!c.dirty,className:T,children:$?"Saving…":"Save"}),c.dirty&&t.jsx("button",{type:"button",className:me,disabled:$,onClick:()=>{S(c.path)},children:"Discard changes"})]}),j!==null&&t.jsxs("div",{className:"mt-3",children:[t.jsx("div",{className:"mb-1 text-[12px] text-ink-secondary",children:"Your unsaved draft, kept so nothing is lost:"}),t.jsx("pre",{className:"max-h-[160px] overflow-auto whitespace-pre-wrap rounded-lg border border-hairline/40 bg-inset p-3 font-mono text-[12px] leading-relaxed text-ink",children:j}),t.jsx("button",{type:"button",className:k(me,"mt-1"),onClick:()=>N(null),children:"Dismiss draft"})]})]}),l&&t.jsxs("div",{className:"rounded-xl bg-card p-4",children:[t.jsx(je,{title:"Topic files",hint:"Longer notes the bot reads on demand. Click one to edit it.",files:l.topics,selected:c?.path,onOpen:n=>{S(n.path)},onDelete:n=>{H(n)}}),t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[t.jsx("input",{className:k(fe,"py-1.5 text-[13px]"),value:x,placeholder:"New topic name, e.g. clients","aria-label":"New topic name",onChange:n=>L(n.target.value),onKeyDown:n=>{n.key==="Enter"&&F()}}),t.jsx("button",{type:"button",className:T,disabled:!x.trim(),onClick:()=>{F()},children:"New topic"})]}),l.logs.length>0&&t.jsx("div",{className:"mt-4",children:t.jsx(je,{title:"Daily logs",hint:"What the bot did each day, in its own words. Not loaded into conversations.",files:l.logs,selected:c?.path,onOpen:n=>{S(n.path)},onDelete:n=>{H(n)}})})]}),t.jsxs("div",{className:"rounded-xl bg-card p-4",children:[t.jsx("div",{className:"text-[15px] font-medium text-ink",children:"Changes"}),t.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:"Every change to these files, whoever made it. Undo puts a file back the way it was before that change."}),t.jsx("div",{className:"mt-3",children:t.jsx(ds,{rows:o,botName:e.name,reverting:A,onRevert:n=>{ce(n)}})})]}),w&&t.jsx("div",{className:"text-[12.5px] text-ink-secondary",children:w}),R&&t.jsx("div",{className:"text-[12.5px] text-danger",children:R})]})}function rs(e){return`---
|
|
2
|
+
title: ${e.replace(/\.md$/,"")}
|
|
3
|
+
description:
|
|
4
|
+
aliases: []
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
`}function ls({enabled:e,status:s,tidying:i,onToggle:a,onTidy:l}){return t.jsxs("div",{className:"rounded-xl bg-card p-4",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[15px] font-medium text-ink",children:"Memory upkeep"}),t.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:"Keeps these notes in shape without the bot having to remember to: notices facts you mention in chats and files them — core facts here, detail in topic files it creates — and tidies up every night: expired notes are archived, duplicates merged, contradicted notes crossed out. Facts about you are added to About me (Settings → General), where every bot reads them and you can remove any. Every change shows below and can be undone."})]}),t.jsx(Me,{checked:e,"aria-label":"Memory upkeep",onClick:a})]}),e&&s&&!s.modelSteps&&t.jsx("p",{className:"mt-2 text-[12.5px] text-ink-secondary",children:"This bot's engine can't make the quick background model call upkeep uses, so it only archives expired notes and merges exact duplicates. Claude and chat-model engines can do the rest."}),e&&t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3",children:[t.jsx("button",{type:"button",className:T,disabled:i,onClick:l,children:i?"Tidying…":"Tidy up now"}),t.jsxs("span",{className:"text-[12.5px] text-ink-secondary",children:[s?.lastTidy?`Last tidy-up ${ie(s.lastTidy.at)}: ${Oe(s.lastTidy).toLowerCase()}.`:"Not tidied yet.",s?.lastCapture&&xe(s.lastCapture)?` Last noticed ${xe(s.lastCapture)} fact${xe(s.lastCapture)===1?"":"s"} ${ie(s.lastCapture.at)}.`:""]})]})]})}function os({index:e}){const s=Xt(e),i=s.level==="over"?"bg-danger":s.level==="near"?"bg-warning":"bg-accent";return t.jsxs("div",{className:k("rounded-xl p-4",s.level==="over"?"border border-danger/30 bg-danger/10":"bg-card"),children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 text-[13px]",children:[t.jsx("span",{className:"font-medium text-ink",children:"How much of MEMORY.md loads"}),t.jsxs("span",{className:k("text-[12px]",s.level==="over"?"text-danger":"text-ink-secondary"),children:[e.lines," / ",e.maxLines," lines · ",I(e.bytes)," / ",I(e.maxBytes)]})]}),t.jsx(be,{label:"Lines",share:s.lineShare,fill:i}),t.jsx(be,{label:"Size",share:s.byteShare,fill:i}),t.jsx("p",{className:k("mt-2 text-[12.5px] leading-relaxed",s.level==="over"?"text-danger":"text-ink-secondary"),children:s.warning??s.sentence}),s.warning&&t.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:s.sentence})]})}function be({label:e,share:s,fill:i}){const a=`${Math.min(100,Math.round(s*100))}%`;return t.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11.5px] text-ink-secondary",children:[t.jsx("span",{className:"w-10 shrink-0",children:e}),t.jsx("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-inset",role:"meter","aria-label":`${e} used`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.min(100,Math.round(s*100)),children:t.jsx("div",{className:k("h-full rounded-full",i),style:{width:a}})})]})}function cs({botName:e,busy:s,onReload:i,onOverwrite:a}){return t.jsxs("div",{className:"mt-2 rounded-lg border border-warning/25 bg-warning/10 p-3 text-[12.5px] leading-relaxed text-ink",children:[t.jsxs("div",{className:"font-medium",children:[e," changed this file while you were editing."]}),t.jsxs("div",{className:"mt-0.5 text-ink-secondary",children:["Nothing has been saved. Reload to see ",e,"'s version (your draft is kept below), or overwrite it with yours."]}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx("button",{type:"button",className:T,disabled:s,onClick:i,children:"Reload"}),t.jsx("button",{type:"button",className:T,disabled:s,onClick:a,children:"Overwrite with mine"})]})]})}function je({title:e,hint:s,files:i,selected:a,onOpen:l,onDelete:r}){return t.jsxs("div",{children:[t.jsx("div",{className:"text-[12px] font-medium uppercase tracking-[0.08em] text-ink-secondary",children:e}),t.jsx("div",{className:"mt-0.5 text-[12px] text-ink-secondary",children:s}),i.length===0?t.jsx("div",{className:"mt-2 text-[12.5px] text-ink-secondary",children:"None yet."}):t.jsx("div",{className:"mt-2 overflow-hidden rounded-lg border border-hairline/40",children:i.map(o=>t.jsxs("div",{className:k("flex items-center gap-2 border-b border-hairline/40 px-3 py-2 last:border-b-0",a===o.path?"bg-control/60":"hover:bg-control/40"),children:[t.jsxs("button",{type:"button",onClick:()=>l(o),className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[t.jsx(Re,{size:14,className:"shrink-0 text-ink-secondary"}),t.jsx("span",{className:"truncate font-mono text-[12.5px] text-ink",children:o.name}),t.jsxs("span",{className:"shrink-0 text-[11.5px] text-ink-secondary",children:[I(o.bytes)," · ",ie(o.modifiedAt)]})]}),t.jsx("button",{type:"button",onClick:()=>r(o),"aria-label":`Delete ${o.name}`,title:"Delete",className:"shrink-0 rounded-md p-1 text-ink-secondary hover:bg-control hover:text-danger",children:t.jsx(qe,{size:14})})]},o.path))})]})}function ds({rows:e,botName:s,reverting:i,onRevert:a,now:l=Date.now()}){return e?e.length===0?t.jsx("div",{className:"text-[13px] text-ink-secondary",children:"No changes recorded yet."}):t.jsx("div",{className:"flex flex-col gap-2",children:e.map(r=>{const o=ts(r);return t.jsxs("div",{className:"rounded-lg bg-inset px-3 py-2",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1 text-[13px] leading-relaxed text-ink",children:[t.jsx("span",{children:es(r,s)})," · ",t.jsx("span",{className:"text-ink-secondary",children:ie(r.at,l)}),o&&t.jsxs(t.Fragment,{children:[" · ",t.jsx("span",{className:"text-ink-secondary",children:o})]})]}),r.canRevert?t.jsxs("button",{type:"button",disabled:i!==null,onClick:()=>a(r),className:"inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[12px] font-medium text-accent-text hover:bg-accent/10 disabled:opacity-50",children:[t.jsx(Ve,{size:12}),i===r.id?"Undoing…":"Undo"]}):t.jsx("span",{className:"shrink-0 text-[11.5px] text-ink-secondary",title:r.revertUnavailableReason,children:"Can't undo"})]}),r.diff&&t.jsxs("details",{className:"mt-1",children:[t.jsxs("summary",{className:"cursor-pointer text-[12px] text-ink-secondary",children:["+",r.added," −",r.removed," · show what changed"]}),t.jsx("pre",{className:"mt-1 max-h-[240px] overflow-auto whitespace-pre-wrap rounded-md bg-card p-2 font-mono text-[11.5px] leading-relaxed text-ink",children:r.diff})]})]},r.id)})}):t.jsx("div",{className:"text-[13px] text-ink-secondary",children:"Loading…"})}function xs({bot:e,rows:s,refreshError:i,onRollback:a,rollingBack:l}){if(!s)return t.jsx("div",{className:"text-[13px] text-ink-secondary",children:"Loading…"});if(s.length===0)return t.jsx("div",{className:"text-[13px] text-ink-secondary",children:"No changes recorded yet."});const r=[...s].sort((o,y)=>y.at-o.at);return t.jsxs("div",{className:"flex flex-col gap-2",children:[i&&t.jsx("div",{className:"rounded-lg bg-inset px-3 py-2 text-[12.5px] text-ink-secondary",children:"Couldn’t refresh history."}),r.map(o=>t.jsxs("div",{className:"rounded-xl bg-card p-4",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1 text-[13px] leading-relaxed text-ink",children:[t.jsx("span",{className:"text-ink-secondary",children:Ee(o.at)})," · ",t.jsxs("span",{children:[o.actor," via ",o.via]})," · ",t.jsx("span",{children:o.summary})]}),o.field==="soul"&&o.canRestore===!0&&t.jsx("button",{type:"button",disabled:l,onClick:()=>a(o.id),className:"shrink-0 rounded-md px-2 py-1 text-[12px] font-medium text-accent-text hover:bg-accent/10 disabled:opacity-50",children:"Undo this change"})]}),o.field==="soul"&&o.canRestore!==!0&&t.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:o.restoreUnavailableReason??"The exact previous instructions are unavailable, so this change cannot be undone."})]},`${e.id}-${o.id}`))]})}function ms({bot:e}){const{state:s,dispatch:i}=le(),a=We(e),l=s.instances.find(r=>r.instanceId===e.modelSelection.instanceId);return a.turns===0?t.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:m("usage.bot.empty")}):t.jsxs("div",{className:"rounded-xl bg-card p-4",children:[t.jsxs("div",{className:"flex items-baseline justify-between",children:[t.jsx("div",{className:"text-[15px] font-medium text-ink",children:m("usage.title")}),t.jsxs("button",{onClick:()=>i({type:"toggleAppSettings",open:!0,section:"usage"}),className:"text-[12px] text-ink-secondary hover:text-ink",children:[m("usage.allBots")," →"]})]}),t.jsxs("div",{className:"mt-3 grid grid-cols-3 gap-3 text-[13px]",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-[11.5px] uppercase tracking-wide text-ink-secondary",children:m("usage.colTurns")}),t.jsx("div",{className:"mt-0.5 tabular-nums text-ink",children:a.turns})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[11.5px] uppercase tracking-wide text-ink-secondary",children:Ke(a)}),t.jsx("div",{className:"mt-0.5 tabular-nums text-ink",title:Ge(a),children:Je(Ye(a))})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[11.5px] uppercase tracking-wide text-ink-secondary",children:m("usage.colCost")}),t.jsx("div",{className:"mt-0.5 tabular-nums text-ink",children:he(a.costUsd)?Qe(a.costUsd):"—"})]})]}),t.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:he(a.costUsd)?m("usage.costLine",{caption:Xe(l?.snapshot.billing)}):m("usage.bot.unpriced")})]})}const Ne="w-full rounded-xl border border-hairline/40 bg-inset px-3 py-2.5 text-[14px] text-ink placeholder:text-ink-tertiary focus:border-accent-border focus:outline-none",ue="mb-1.5 block text-[12px] text-ink-secondary";function us(e){const s=[],i=new Set;for(const a of[...rt(e)].reverse()){const l=[];if(s.push(l),a.role!=="bot"||a.kind!=="text")continue;const r=lt(a.attachments),o=[...r.files,...ot(a.text??"",[...r.images,...r.files.map(c=>c.path)])],y=(c,f,h)=>{i.has(c)||(i.add(c),l.push({key:`${a.id}:${c}`,name:f,kind:h,at:a.at,messageId:a.id}))};for(const c of r.images)y(c,ye(c),"image");for(const c of o)y(c.path,c.name||ye(c.path),"file")}return s.flat()}function ps({bot:e,derived:s,headerClassName:i,onClose:a,onAllSettings:l,onAddSkill:r}){const{dispatch:o}=le(),[y,c]=u.useState("details"),[f,h]=u.useState(null),p=vt(e),{patch:j,approvalMode:N,engine:R,trustedModesAvailable:v}=s,w=R?.driverKind==="antigravityAgent"&&N==="auto"?"ask":N,C=Ze(R?.driverKind??"",v).some(x=>x.mode==="auto"),$=x=>{if(!(e.busy||x===N)){if(x==="auto"&&e.computer==="local"){h(e.id);return}j({approvalMode:x})}},P=w!=="ask"&&w!=="auto",A=u.useMemo(()=>y==="library"?us(e):[],[y,e]),U=x=>k("rounded-full px-4 py-1.5 text-[13px] font-medium transition-colors",x?"bg-raised text-ink shadow-sm":"text-ink-secondary hover:text-ink");return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:k("flex shrink-0 items-center justify-end px-4 py-3",i),children:t.jsx("button",{type:"button",onClick:a,"aria-label":m("botSettings.simple.close"),className:"rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink",children:t.jsx(Le,{size:18,className:"pointer-events-none"})})}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-5 pb-6",children:[t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(et,{bot:e,size:72,state:s.activeState}),t.jsx("h2",{id:"bot-settings-title",className:"max-w-full truncate text-[17px] font-semibold text-ink",children:e.name})]}),t.jsx("div",{className:"mt-4 flex justify-center",children:t.jsxs("div",{role:"tablist","aria-label":m("botSettings.simple.tabs"),className:"inline-flex rounded-full bg-inset p-1",children:[t.jsx("button",{type:"button",role:"tab","aria-selected":y==="details","data-simple-tab":"details",onClick:()=>c("details"),className:U(y==="details"),children:m("botSettings.simple.details")}),t.jsx("button",{type:"button",role:"tab","aria-selected":y==="library","data-simple-tab":"library",onClick:()=>c("library"),className:U(y==="library"),children:m("botSettings.simple.library")})]})}),y==="details"?t.jsxs("div",{role:"tabpanel",className:"mt-5 flex flex-col gap-5",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("label",{htmlFor:`simple-bot-name-${e.id}`,className:ue,children:m("botSettings.simple.name")}),t.jsx("input",{id:`simple-bot-name-${e.id}`,className:Ne,maxLength:ge.name,value:e.name,onChange:x=>j({name:x.target.value})})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("label",{htmlFor:`simple-bot-job-${e.id}`,className:ue,children:m("botSettings.simple.job")}),t.jsx("input",{id:`simple-bot-job-${e.id}`,className:Ne,maxLength:ge.title,placeholder:m("botSettings.simple.jobPlaceholder"),value:e.title,onChange:x=>j({title:x.target.value})})]})]}),t.jsx(kt,{bot:e,onPatch:j,simple:{label:m("botSettings.simple.instructions"),placeholder:m("botSettings.simple.instructionsPlaceholder",{name:e.name})}}),t.jsxs("div",{"data-simple-default-model":!0,children:[t.jsx(tt,{bot:e,contained:!0,label:t.jsx("span",{className:"text-[12px] text-ink-secondary",children:m("botSettings.simple.defaultModel")})}),t.jsx(st,{bot:e,className:"mt-2"})]}),t.jsxs("div",{children:[t.jsx("div",{className:ue,children:m("botSettings.simple.beforeActs",{name:e.name})}),t.jsx("div",{className:"grid grid-cols-2 gap-3",children:[{mode:"ask",title:m("botSettings.simple.ask"),hint:m("botSettings.simple.askHint"),offered:!0},{mode:"auto",title:m("botSettings.simple.decide"),hint:m("botSettings.simple.decideHint"),offered:C}].map(x=>{const L=w===x.mode;return t.jsxs("button",{type:"button","data-approval-choice":x.mode,"aria-pressed":L,disabled:!!e.busy||!x.offered,onClick:()=>$(x.mode),className:k("flex min-w-0 flex-col items-start gap-0.5 rounded-xl border px-3 py-3 text-left transition-colors disabled:cursor-not-allowed disabled:opacity-50",L?"border-accent-border bg-raised-hover":"border-hairline/40 bg-inset enabled:hover:bg-raised"),children:[t.jsx("span",{className:"text-[14px] font-medium text-ink",children:x.title}),t.jsx("span",{className:"text-[12px] text-ink-secondary",children:x.hint})]},x.mode)})}),P&&t.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary","data-approval-custom":!0,children:m("botSettings.simple.customMode")})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-[12px] text-ink-secondary",children:m("botSettings.simple.skills")}),t.jsx("button",{type:"button","data-simple-add-skill":!0,onClick:r,className:"rounded-md px-1.5 py-0.5 text-[12px] font-medium text-accent-text hover:bg-raised",children:m("botSettings.simple.addSkill")})]}),!p.loading&&p.skills.length===0?t.jsx("div",{className:"text-[12.5px] text-ink-tertiary",children:m("botSettings.simple.noSkills")}):t.jsx("div",{className:"flex flex-col gap-2",children:p.skills.map(x=>t.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-hairline/40 bg-inset px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-[13.5px] font-medium text-ink",children:x.name}),t.jsx("div",{className:"truncate text-[12px] text-ink-secondary",children:x.description||x.source})]}),t.jsx(Me,{checked:x.enabled,"aria-label":m("botSettings.simple.skillToggle",{name:x.name}),disabled:!!p.working,onClick:()=>{p.toggle(x)}})]},x.name))}),p.error&&!p.reviewing&&t.jsx("div",{role:"alert",className:"mt-2 text-[12px] text-danger",children:p.error})]}),t.jsxs("button",{type:"button","data-simple-all-settings":!0,onClick:l,className:"flex items-center gap-2 rounded-xl border border-dashed border-hairline px-4 py-3 text-left text-[13px] text-ink-secondary hover:bg-raised hover:text-ink",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"font-semibold text-ink",children:m("botSettings.simple.allSettings")})," — ",m("botSettings.simple.allSettingsHint")]}),t.jsx(nt,{size:15,className:"shrink-0"})]})]}):t.jsx("div",{role:"tabpanel",className:"mt-5",children:A.length===0?t.jsx("div",{className:"px-4 py-12 text-center text-[13px] leading-relaxed text-ink-secondary",children:m("botSettings.simple.libraryEmpty",{name:e.name})}):t.jsx("div",{className:"flex flex-col gap-1.5",children:A.map(x=>{const L=x.kind==="image"?at:Re;return t.jsxs("button",{type:"button","data-library-item":x.messageId,title:m("botSettings.simple.libraryOpen",{name:x.name}),onClick:()=>o({type:"focusMessage",threadId:e.threadId,messageId:x.messageId}),className:"flex items-center gap-3 rounded-xl border border-hairline/40 bg-inset px-3 py-2.5 text-left hover:bg-raised",children:[t.jsx(L,{size:16,className:"shrink-0 text-ink-secondary"}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-[13.5px] text-ink",children:x.name}),t.jsx("span",{className:"shrink-0 text-[12px] text-ink-tertiary",children:new Date(x.at).toLocaleDateString(void 0,{month:"short",day:"numeric"})})]},x.key)})})})]}),p.reviewing&&t.jsx(bt,{skill:p.reviewing.skill,text:p.reviewing.text,error:p.error,working:p.working===p.reviewing.skill.name,onCancel:()=>p.setReviewing(null),onEnable:()=>{p.enableReviewed()}}),t.jsx(it,{open:f!==null,onCancel:()=>h(null),onConfirm:()=>{const x=f;h(null),x&&o({type:"updateBot",botId:x,patch:{approvalMode:"auto",acknowledgeLocalAuto:!0}})}})]})}const Te=e=>e.labelKey?m(e.labelKey):e.label,hs=new Set(["overview","identity","soul"]);function we(e,s){return s?[e.label,Te(e),...e.keywords].some(i=>i.toLowerCase().includes(s)):!0}function Ss({bot:e,overlay:s=!1}){const{state:i,dispatch:a,flushBotPatches:l}=le(),r=i.botSettingsSection,o=ct(e),y=u.useRef(null),{padClass:c}=dt(),[f,h]=u.useState(""),p=!i.botSettingsExpandAccordion,j=f.trim().toLowerCase(),N=xt(),R=!p&&!hs.has(r),[v,w]=u.useState(R);u.useEffect(()=>{R&&w(!0)},[R,r]);const C=!N&&!v,$=qt(e.id),P=mt(),A=Pt.filter(g=>g.id!=="slack"||$!==null).filter(g=>g.id!=="visibility"||!window.ogb&&P===!0),U=A.filter(g=>we(g,j)),[x,L]=u.useState(null),[Q,z]=u.useState(!1),[oe,X]=u.useState(null),[q,V]=u.useState(!1),[W,Z]=u.useState(null),[ee,K]=u.useState(!1),[J,te]=u.useState(null),S=u.useRef(0),[Y,se]=u.useState(!1),[H,F]=u.useState(null),ce=u.useMemo(()=>JSON.stringify([e.name,e.title,e.description,e.soul,e.computer,e.cloudBackend,e.cwd,e.autoApprove,e.approvePeerComms,e.peers,e.section,e.composio,e.browser,e.mcpServers,e.chiefOfStaff,e.managedSections,e.modelSelection]),[e.name,e.title,e.description,e.soul,e.computer,e.cloudBackend,e.cwd,e.autoApprove,e.approvePeerComms,e.peers,e.section,e.composio,e.browser,e.mcpServers,e.chiefOfStaff,e.managedSections,e.modelSelection]);u.useEffect(()=>{if(r!=="overview"||C)return;let g=!1;return(async()=>(await l(e.id),!g&&(b(`/api/bots/${e.id}/overview`).then(d=>{g||(L(d),z(!1))}).catch(()=>{g||z(!0)}),b(`/api/bots/${e.id}/system-prompt`).then(d=>{g||(X(d),V(!1))}).catch(()=>{g||V(!0)}))))(),()=>{g=!0}},[e.id,r,C,ce,i.routines,i.webhooks,l]);const _=u.useCallback(()=>{const g=++S.current;return K(!1),l(e.id).then(()=>b(`/api/bots/${e.id}/history?limit=100`)).then(n=>{g===S.current&&(Z(n.rows),te(n.revision))}).catch(()=>{g===S.current&&K(!0)})},[e.id,l]);u.useEffect(()=>{if(r==="history")return _(),()=>{S.current++}},[r,_]);const de=async g=>{if(!Y){F(null),se(!0);try{await l(e.id),await b(`/api/bots/${e.id}/history/rollback`,{method:"POST",body:JSON.stringify(g)})}catch(n){a({type:"error",message:n instanceof Error?n.message:"Couldn't undo that change."})}finally{await _(),se(!1)}}};u.useEffect(()=>{if(!p){if(j){h("");return}y.current?.querySelector(`[data-bot-settings-section="${r}"]`)?.scrollIntoView({block:"nearest"})}},[p,r,j]),u.useEffect(()=>{const g=document.activeElement instanceof HTMLElement?document.activeElement:null,n=y.current;n?.focus();const d=M=>{const B=n?.querySelector('[role="dialog"], [role="alertdialog"]');B&&B.getClientRects().length>0||n&&M.target instanceof Node&&!n.contains(M.target)||M.key==="Escape"&&(M.preventDefault(),a({type:"toggleSettings",open:!1}))};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d),g?.focus()}},[a]);const ne=g=>{switch(g){case"overview":return x===null&&Q?t.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:"Couldn’t load the overview."}):t.jsx(Ht,{overview:x,refreshError:x!==null&&Q,prompt:oe,promptError:q,onOpen:n=>a({type:"toggleSettings",open:!0,section:n}),onSetup:o.canCoordinate&&!e.busy?()=>{a({type:"toggleSettings",open:!1}),a({type:"send",botId:e.id,text:"/setup",threadId:e.threadId})}:void 0});case"identity":return t.jsx(Rt,{bot:e,patch:o.patch,activeState:o.activeState,mascotMotion:o.mascotMotion});case"soul":return t.jsx(Mt,{bot:e,patch:o.patch});case"slack":return $?t.jsx(Ft,{managementUrl:$}):null;case"skills":return t.jsx($t,{bot:e});case"memory":return t.jsx(is,{bot:e,active:!p&&r==="memory",onToggle:n=>o.patch({memoryEnabled:n})});case"routines":return t.jsx(Lt,{bot:e,routines:o.botRoutines,runs:i.routineRuns});case"access":return t.jsx(Ct,{bot:e,derived:o});case"model":return t.jsx(St,{bot:e});case"permissions":return t.jsx(wt,{bot:e,derived:o});case"voice":return t.jsx(Nt,{bot:e,derived:o});case"visibility":return t.jsx(jt,{bot:e});case"history":return W===null&&ee?t.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:"Couldn’t load history."}):t.jsx(xs,{bot:e,rows:W,refreshError:W!==null&&ee,onRollback:n=>{J&&F({id:n,expectedRevision:J})},rollingBack:Y||!J});case"usage":return t.jsx(ms,{bot:e});default:return null}};return t.jsxs(t.Fragment,{children:[t.jsx("aside",{ref:y,role:"dialog","aria-labelledby":"bot-settings-title",tabIndex:-1,className:k("animate-panel-in absolute inset-0 z-40 flex h-full min-w-0 flex-col border-l border-hairline/40 bg-panel outline-none focus-visible:outline-none",s?"md:inset-auto md:right-0 md:top-0 md:bottom-0 md:w-[min(420px,42vw)] md:shadow-2xl":"md:static md:z-auto md:w-[min(420px,42vw)] md:shrink-0"),children:C?t.jsx(ps,{bot:e,derived:o,headerClassName:c,onClose:()=>a({type:"toggleSettings",open:!1}),onAllSettings:()=>w(!0),onAddSkill:()=>{w(!0),a({type:"toggleSettings",open:!0,section:"skills"})}}):t.jsxs(t.Fragment,{children:[!N&&t.jsxs("button",{type:"button","data-bot-settings-back":!0,onClick:()=>w(!1),className:k("flex shrink-0 items-center gap-1 self-start px-3 pt-3 text-[13px] text-ink-secondary hover:text-ink",c),children:[t.jsx(ut,{size:15,className:"pointer-events-none"}),m("botSettings.simple.back")]}),t.jsxs("div",{className:k("flex shrink-0 items-center justify-between px-4 py-3",N?c:void 0),children:[t.jsx("span",{id:"bot-settings-title",className:"truncate text-[15px] font-semibold text-ink",children:e.name}),t.jsx("button",{type:"button",onClick:()=>a({type:"toggleSettings",open:!1}),"aria-label":"Close settings",className:"rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink",children:t.jsx(Le,{size:18,className:"pointer-events-none"})})]}),t.jsxs("div",{className:"mx-4 mb-2 flex shrink-0 items-center gap-2 rounded-lg border border-transparent bg-control/70 px-2.5 py-2 focus-within:border-focus",children:[t.jsx(pt,{size:14,className:"shrink-0 text-ink-secondary"}),t.jsx("input",{value:f,onChange:g=>{h(g.target.value),a({type:"toggleSettings",open:!0})},onKeyDown:g=>{g.key==="Escape"&&(g.stopPropagation(),f?h(""):a({type:"toggleSettings",open:!1}))},placeholder:"Search","aria-label":"Search settings",className:"w-full bg-transparent text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto",children:[U.length===0&&t.jsxs("div",{className:"px-4 py-4 text-[12.5px] leading-relaxed text-ink-secondary",children:["Nothing matches “",f.trim(),"”"]}),A.map(g=>{const{id:n,icon:d}=g,M=Te(g),B=we(g,j);if(!B&&n!=="memory")return null;const E=!p&&r===n;return t.jsxs("div",{"data-bot-settings-section":n,className:"border-b border-hairline/30",hidden:!B,children:[t.jsxs("button",{type:"button",onClick:()=>{if(r===n&&!p){a({type:"toggleSettings",open:!0});return}a({type:"toggleSettings",open:!0,section:n})},"aria-expanded":E,className:k("flex w-full shrink-0 items-center gap-2.5 px-4 py-2.5 text-left text-[14px]",E?"bg-control/60 text-ink":"text-ink-secondary hover:bg-control/40 hover:text-ink"),children:[t.jsx(d,{size:15,className:"shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:M}),t.jsx(Ce,{size:16,className:k("shrink-0 text-ink-secondary transition-transform",E&&"rotate-180")})]}),n==="memory"?t.jsx("div",{hidden:!E,className:"px-4 pb-4 pt-1",children:ne("memory")}):E&&t.jsx("div",{className:"px-4 pb-4 pt-1",children:ne(n)})]},n)})]})]})}),t.jsx(ht,{open:H!==null,title:"Restore previous instructions?",body:"Replaces current SOUL with the version before this change. Current version stays in History.",confirmLabel:"Restore instructions",tone:"neutral",returnFocusRef:y,onCancel:()=>F(null),onConfirm:()=>{H&&de(H)}})]})}export{Ss as BotSettingsDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as d,j as e,c as a}from"./index-C3NqfdVU.js";function c({value:o,compact:r=!1,onChange:s}){const{state:n}=d();return n.config?.cloudHome?null:e.jsxs("div",{className:"mt-3 rounded-lg bg-inset p-3",children:[e.jsx("div",{className:"text-[12px] font-medium text-ink",children:r?"Cloud provider":"Cloud backend"}),e.jsx("div",{className:"mt-0.5 text-[11.5px] text-ink-secondary",children:r?o==="vps"?"Your own server, connected over SSH.":"A hosted computer managed by Boat.":o==="vps"?"Auto reuses a running VPS by default. Enable Start VPS automatically to let Auto create or wake its managed container, or choose Cloud to do it explicitly. Open the live desktop securely from the computer panel.":"Boat is the default hosted computer. Choose Self-hosted VPS to use your SSH-configured Linux Docker host."}),e.jsx("div",{className:"mt-2 flex overflow-hidden rounded-lg border border-hairline/40",children:["box","vps"].map((t,i)=>e.jsx("button",{onClick:()=>s(t),className:a("flex-1 py-1.5 text-[12px]",i>0&&"border-l border-hairline/40",o===t?"bg-raised text-ink":"text-ink-secondary hover:bg-raised/60 hover:text-ink"),children:t==="vps"?"Self-hosted VPS":"Boat"},t))})]})}export{c as C};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as et,u as It,av as Pt,j as e,t as r,aS as Ln,aR as kn,F as er,a5 as tr,r as a,d as U,b8 as Tt,M as Ve,b9 as Fn,ae as nr,ba as Vn,a3 as rr,aT as Qt,g as W,bb as Zt,au as We,X as St,P as sr,m as ar,O as _e,bc as or,c as Fe,N as Wt,a2 as ir,bd as pt,E as lr,a as cr,be as ur,bf as dr,bg as pr,aM as jn,bh as mr,bi as xr,bj as fr,bk as br,bl as hr,b7 as gr,bm as Nn,bn as vr,bo as Sn,bp as Cn,bq as yr,l as wr,q as kr,br as jr,bs as Nr,aO as Sr,v as Cr,aJ as Er,bt as Rr,bu as Tr,bv as En,bw as Ir,bx as Pr,C as Rn,by as zr,o as Ar,bz as Ht,bA as Dr,bB as Mr,ak as Or,bC as Lr,A as Fr,z as Vr,D as _r,G as $r,bD as Br,bE as Kr,bF as Ur,bG as qr}from"./index-C3NqfdVU.js";import{R as Wr,g as Hr,h as Xr,b as Yr,i as Jr,j as Gr}from"./WebhooksPanel--YQyCjKO.js";import{B as Zr,A as Qr,M as Tn,a as es,w as ts}from"./MacLocalControl-bJv8yiPB.js";import{u as en}from"./page-visible-BBo_Zm8g.js";import{C as ns}from"./CloudBackendPicker-iezpJFpF.js";import{R as rs}from"./RoutinesSection-Dny9ra-c.js";import{t as ss}from"./computer-control-NLov352p.js";import"./RoutinesPage-BM2D4qGi.js";const as=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],os=et("columns-2",as);const is=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],ls=et("ellipsis-vertical",is);const cs=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],us=et("minimize-2",cs);const ds=[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m14.305 7.53.923-.382",key:"1mlnsw"}],["path",{d:"m15.228 4.852-.923-.383",key:"82mpwg"}],["path",{d:"m16.852 3.228-.383-.924",key:"ln4sir"}],["path",{d:"m16.852 8.772-.383.923",key:"1dejw0"}],["path",{d:"m19.148 3.228.383-.924",key:"192kgf"}],["path",{d:"m19.53 9.696-.382-.924",key:"fiavlr"}],["path",{d:"m20.772 4.852.924-.383",key:"1j8mgp"}],["path",{d:"m20.772 7.148.924.383",key:"zix9be"}],["path",{d:"M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"1tnzv8"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]],ps=et("monitor-cog",ds);const ms=[["circle",{cx:"10",cy:"7",r:"1",key:"dypaad"}],["circle",{cx:"4",cy:"20",r:"1",key:"22iqad"}],["path",{d:"M4.7 19.3 19 5",key:"1enqfc"}],["path",{d:"m21 3-3 1 2 2Z",key:"d3ov82"}],["path",{d:"M9.26 7.68 5 12l2 5",key:"1esawj"}],["path",{d:"m10 14 5 2 3.5-3.5",key:"v8oal5"}],["path",{d:"m18 12 1-1 1 1-1 1Z",key:"1bh22v"}]],xs=et("usb",ms);const fs=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],bs=et("user-round",fs),hs=20;function gs(t,c=hs){const l=new Set,d=[],p=tr(t);for(let b=p.length-1;b>=0&&d.length<c;b-=1){const E=p[b].digest?.files;if(E){for(const w of E.deleted)l.add(w);for(const w of[...E.added,...E.changed])if(!l.has(w)&&(l.add(w),d.push(w),d.length>=c))break}}return d}function vs(t){const c=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return c<0?{name:t,folder:""}:{name:t.slice(c+1),folder:t.slice(0,c)}}function ys({bot:t}){const{dispatch:c}=It(),{capabilities:l}=Pt(),d=l.host.homeDir,p=gs(t);return e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 pb-5","data-testid":"computer-files",children:[e.jsxs("div",{className:"mt-2 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:r("computer.files.folder")}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx(Ln,{size:15,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink",title:t.cwd??void 0,children:t.cwd?kn(t.cwd,d):r("computer.files.privateFolder",{name:t.name})}),e.jsx("button",{type:"button",onClick:()=>{c({type:"toggleComputer",open:!1}),c({type:"toggleSettings",open:!0,section:"access"})},className:"shrink-0 rounded-lg bg-control px-2.5 py-1 text-[12px] text-ink hover:bg-raised-hover",children:r("computer.files.changeFolder")})]})]}),e.jsxs("div",{className:"mt-3 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:r("computer.files.recent")}),p.length===0?e.jsx("p",{className:"mt-2 text-[12px] leading-5 text-ink-secondary",children:r("computer.files.empty",{name:t.name})}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1",children:p.map(b=>{const{name:E,folder:w}=vs(b);return e.jsxs("li",{className:"flex min-w-0 items-center gap-2 rounded-lg px-1 py-1",title:b,children:[e.jsx(er,{size:14,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 truncate text-[12.5px] text-ink",children:E}),w&&e.jsx("span",{className:"min-w-0 flex-1 truncate text-right text-[11px] text-ink-tertiary",children:kn(w,d)})]},b)})})]})]})}function ws({src:t,name:c,error:l,starting:d,opening:p,disabled:b,refreshing:E=!1,retry:w=0,onOpen:f,onRetry:C}){const[z,N]=a.useState(null),[j,I]=a.useState(null);a.useEffect(()=>{I(null)},[w]);const S=!!(t&&z===t&&j!==t),h=l??(t&&j===t?r("computer.preview.imageFailed"):null);return e.jsxs("div",{className:"relative h-full w-full","aria-busy":!h&&(!S||p||E),children:[t&&e.jsxs("button",{type:"button",onClick:f,disabled:b||d||p||!S,className:"group absolute inset-0 flex h-full w-full items-center justify-center disabled:cursor-wait","aria-label":r("computer.openLiveDesktopAria",{name:c}),title:r("computer.openLiveDesktop"),children:[e.jsx("img",{src:t,alt:r("computer.screenOf",{name:c}),onLoad:()=>{N(t),I(null)},onError:()=>I(t),className:`h-full w-full object-contain transition group-hover:brightness-75 ${S?"":"invisible"}`},w),S&&e.jsxs("span",{className:"absolute right-2 top-2 flex items-center gap-1 rounded-md bg-black/70 px-2 py-1 text-[11px] font-medium text-white",children:[p?e.jsx(U,{size:12,className:"animate-spin"}):e.jsx(Tt,{size:12}),p?r("computer.preview.connecting"):r("computer.open")]})]}),!S&&!h&&e.jsxs("div",{role:"status",className:"absolute inset-0 flex flex-col items-center justify-center gap-2 px-6 text-center text-[12px] text-ink-secondary",children:[e.jsx(U,{size:18,className:"animate-spin"}),d?r("computer.phase.starting"):r("computer.preview.connectingScreen")]}),S&&E&&!h&&e.jsxs("div",{role:"status",className:"absolute bottom-2 left-2 flex items-center gap-1 rounded-md bg-black/70 px-2 py-1 text-[11px] text-white",children:[e.jsx(U,{size:12,className:"animate-spin"}),r("computer.preview.connectingScreen")]}),h&&e.jsxs("div",{role:"alert",className:`absolute inset-x-0 flex flex-col items-center justify-center gap-2 bg-card/95 p-4 text-center text-[12px] text-ink-secondary ${S?"bottom-0":"inset-y-0"}`,children:[!S&&e.jsx(Ve,{size:22}),e.jsxs("span",{children:[S?r("computer.preview.paused"):r("computer.preview.cantConnect")," ",h]}),e.jsx("button",{type:"button",onClick:()=>C(!S),className:"rounded-md bg-control px-3 py-1.5 text-ink hover:bg-raised-hover",children:r("computer.preview.retry")})]})]})}const ks={available:!1,devices:[]};function js(){const t=window.ogb?.androidDevice,[c,l]=a.useState(ks),d=en();return a.useEffect(()=>{if(!t||!d)return;let p=!0;const b=async()=>{try{const w=await t.status();p&&l(w)}catch(w){p&&l({available:!1,devices:[],reasonCode:"adb-failed",message:w instanceof Error?w.message:String(w)})}};b();const E=window.setInterval(()=>{b()},2e3);return()=>{p=!1,window.clearInterval(E)}},[t,d]),c}function kt(t){return t.model==="Android device"?t.serial:t.model}function Ns({status:t}){const c=window.ogb?.androidDevice,l=en(),d=t.devices.filter(u=>u.state==="device"),[p,b]=a.useState(d[0]?.serial??t.devices[0]?.serial??""),[E,w]=a.useState(null),[f,C]=a.useState({width:0,height:0}),[z,N]=a.useState(null),j=a.useRef(null),I=a.useRef(null),S=a.useRef({x:0,y:0,timer:null}),h=t.devices.find(u=>u.serial===p)??t.devices[0],R=h?.serial,O=h?.state;a.useEffect(()=>{!h&&t.devices[0]&&b(t.devices[0].serial),h&&!t.devices.some(u=>u.serial===h.serial)&&b(t.devices[0]?.serial??"")},[h,t.devices]),a.useEffect(()=>{if(!c||!R||O!=="device"||!l){if(!l)return;w(null);return}let u=!0,v=null;const A=async()=>{try{const s=await c.frame(R);u&&(w(s.dataUrl),N(null))}catch(s){u&&N(s instanceof Error?s.message:String(s))}finally{u&&(v=window.setTimeout(()=>{A()},850))}};return A(),()=>{u=!1,v!==null&&window.clearTimeout(v)}},[c,R,O,l]),a.useEffect(()=>()=>{S.current.timer&&clearTimeout(S.current.timer)},[]);const D=u=>{!c||!h||h.state!=="device"||c.input(h.serial,u).catch(v=>{N(v instanceof Error?v.message:String(v))})},o=(u,v=!1)=>{if(!j.current||!f.width||!f.height)return null;const s=u.currentTarget.getBoundingClientRect(),le=Math.min(s.width/f.width,s.height/f.height),je=f.width*le,Z=f.height*le,q=s.left+(s.width-je)/2,V=s.top+(s.height-Z)/2,H=(u.clientX-q)/je,ce=(u.clientY-V)/Z;return v?{x:Math.max(0,Math.min(1,H)),y:Math.max(0,Math.min(1,ce))}:H>=0&&H<=1&&ce>=0&&ce<=1?{x:H,y:ce}:null},B=u=>{if(u.metaKey||u.ctrlKey||u.altKey)return;const v={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",Backspace:"delete",Delete:"delete",Enter:"enter",Escape:"back",Tab:"tab"};v[u.key]?(u.preventDefault(),D({type:"key",key:v[u.key]})):/^[A-Za-z0-9 _.,@-]$/.test(u.key)&&(u.preventDefault(),D({type:"text",text:u.key}))},_=u=>{if(!f.width||!f.height)return;u.preventDefault();const v=S.current;v.x+=u.deltaX,v.y+=u.deltaY,v.timer&&clearTimeout(v.timer),v.timer=setTimeout(()=>{const A=Math.abs(v.x)>Math.abs(v.y),s=A?v.x:v.y;if(v.x=0,v.y=0,v.timer=null,Math.abs(s)<2)return;const le=Math.max(.18,Math.min(.45,Math.abs(s)/500)),je=s>0?-1:1,Z=A?{x:.5,y:.5}:{x:.5,y:.65},q=A?{x:Z.x+je*le,y:Z.y}:{x:Z.x,y:Z.y+je*le};D({type:"swipe",fromX:Z.x,fromY:Z.y,toX:q.x,toY:q.y,durationMs:260,width:f.width,height:f.height})},80)};if(!h)return null;const G=h.state==="device";return e.jsxs("div",{className:"space-y-3 pb-5",children:[e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-[15px] font-medium text-ink",children:[e.jsx(Fn,{size:16,className:"text-success"})," ",kt(h)]}),e.jsx("div",{className:"mt-1 text-[12px] leading-relaxed text-ink-secondary",children:r("computer.android.usbSubtitle")})]}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-[11px] text-success",children:[e.jsx(nr,{size:12})," ",r("computer.android.usb")]})]}),t.devices.length>1&&e.jsx("select",{value:h.serial,onChange:u=>b(u.target.value),className:"mt-3 w-full rounded-lg border border-hairline/40 bg-inset px-3 py-2 text-[12px] text-ink",children:t.devices.map(u=>e.jsxs("option",{value:u.serial,children:[kt(u)," · ",u.state]},u.serial))})]}),G?e.jsxs(e.Fragment,{children:[e.jsx("div",{role:"application","aria-label":r("computer.android.screenAria",{name:kt(h)}),tabIndex:0,onKeyDown:B,onWheel:_,onPointerDown:u=>{const v=o(u);v&&(u.currentTarget.setPointerCapture(u.pointerId),I.current={point:v,at:performance.now()})},onPointerUp:u=>{const v=I.current,A=o(u,!0);if(I.current=null,!v||!A)return;Math.hypot(A.x-v.point.x,A.y-v.point.y)<.012?D({type:"tap",...A,...f}):D({type:"swipe",fromX:v.point.x,fromY:v.point.y,toX:A.x,toY:A.y,durationMs:performance.now()-v.at,...f}),u.currentTarget.focus()},onPointerCancel:()=>{I.current=null},className:"mx-auto flex h-[520px] w-full touch-none cursor-pointer items-center justify-center overflow-hidden overscroll-none rounded-[28px] bg-black outline-none ring-1 ring-white/10 focus:ring-2 focus:ring-accent",children:E?e.jsx("img",{ref:j,src:E,alt:r("computer.android.screenAlt",{name:kt(h)}),draggable:!1,onLoad:u=>{C({width:u.currentTarget.naturalWidth,height:u.currentTarget.naturalHeight})},className:"pointer-events-none h-full w-full select-none object-contain"}):e.jsx(U,{size:20,className:"animate-spin text-ink-secondary"})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("button",{onClick:()=>D({type:"key",key:"back"}),className:"flex items-center justify-center gap-1.5 rounded-lg bg-raised py-2 text-[12px] text-ink hover:bg-raised-hover",children:[e.jsx(Vn,{size:13})," ",r("computer.android.back")]}),e.jsxs("button",{onClick:()=>D({type:"key",key:"home"}),className:"flex items-center justify-center gap-1.5 rounded-lg bg-raised py-2 text-[12px] text-ink hover:bg-raised-hover",children:[e.jsx(rr,{size:12})," ",r("computer.android.home")]}),e.jsxs("button",{onClick:()=>D({type:"key",key:"recent"}),className:"flex items-center justify-center gap-1.5 rounded-lg bg-raised py-2 text-[12px] text-ink hover:bg-raised-hover",children:[e.jsx(Qt,{size:13})," ",r("computer.android.recent")]})]}),e.jsx("div",{className:"text-center text-[11px] leading-relaxed text-ink-secondary",children:r("computer.android.hint")})]}):e.jsx("div",{className:"rounded-xl border border-warning/25 bg-warning/10 p-4 text-[12px] leading-relaxed text-warning",children:h.state==="unauthorized"?r("computer.android.unauthorized"):r("computer.android.badState",{state:h.state})}),z&&e.jsx("div",{className:"rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:z}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[13px] font-medium text-ink",children:[e.jsx(xs,{size:15,className:"text-accent"})," ",r("computer.android.setupTitle")]}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-1.5 pl-4 text-[11.5px] leading-relaxed text-ink-secondary",children:[e.jsx("li",{children:r("computer.android.step1")}),e.jsx("li",{children:r("computer.android.step2").split(/(\{buildNumber\}|\{usbDebugging\})/).map((u,v)=>u==="{buildNumber}"||u==="{usbDebugging}"?e.jsx("span",{className:"text-ink",children:r(u==="{buildNumber}"?"computer.android.buildNumber":"computer.android.usbDebugging")},v):u)}),e.jsxs("li",{children:[r("computer.android.step3a")," ",e.jsx("span",{className:"text-ink",children:r("computer.android.allowUsbDebugging")})," ",r("computer.android.step3b")]})]}),e.jsx("div",{className:"mt-2 text-[11px] leading-relaxed text-ink-secondary",children:r("computer.android.agentNote")}),e.jsx("div",{className:"mt-2 rounded-lg bg-inset px-3 py-2 text-[11px] leading-relaxed text-ink-secondary",children:r("computer.android.harnessNote")})]})]})}const Qe=t=>Number(t.altKey)+Number(t.ctrlKey)*2+Number(t.metaKey)*4+Number(t.shiftKey)*8,Ss=new Set(["Alt","Control","Meta","Shift"]);function _n(t,c,l,d){const p=c*l/t;return Math.abs(p-d)<=Math.max(1,l/t)?{width:l,height:d}:{width:l,height:Math.round(p)}}function Cs(t,c,l,d,p,b,E,w=!1){if(![t.width,t.height,c,l,d,p].every(h=>Number.isFinite(h)&&h>0)||![b,E].every(Number.isFinite))return null;const{width:f,height:C}=_n(c,l,d,p),z=Math.min(t.width/c,t.height/l),N=c*z,j=l*z,I=b-t.left-(t.width-N)/2,S=E-t.top-(t.height-j)/2;return!w&&(I<0||S<0||I>=N||S>=j)?null:{x:Math.max(0,Math.min(f-1,I*f/N)),y:Math.max(0,Math.min(C-1,S*C/j))}}function Es(t){const c=new Map;return{send(l){const p=l.type==="input_keyboard"?`key:${l.code||l.key}`:`mouse:${l.button}`;if((l.eventType==="keyDown"||l.eventType==="mousePressed")&&c.set(p,{...l}),(l.eventType==="keyUp"||l.eventType==="mouseReleased")&&c.delete(p),l.eventType==="mouseMoved")for(const b of c.values())b.type==="input_mouse"&&(b.x=l.x,b.y=l.y);t(l)},release(){const l=[...c.values()].reverse();c.clear();for(const{text:d,...p}of l)t({...p,eventType:p.type==="input_keyboard"?"keyUp":"mouseReleased",modifiers:0})}}}function Rs({frame:t,width:c,height:l,driving:d,input:p,acknowledge:b,onDecodeError:E,onReturnToToolbar:w}){const f=a.useRef(null),C=a.useRef(""),z=a.useRef(-1),N=t.metadata?.deviceWidth??c,j=t.metadata?.deviceHeight??l,I=`data:image/${t.format==="png"?"png":"jpeg"};base64,${t.data}`,S=a.useMemo(()=>Es(p),[p]),h=S.send,R=a.useRef(!1);a.useLayoutEffect(()=>(d||S.release(),S.release),[d,S]),a.useEffect(()=>(window.addEventListener("blur",S.release),()=>window.removeEventListener("blur",S.release)),[S]);const O=()=>{if(f.current?.complete&&f.current.naturalWidth>0&&f.current.currentSrc===I){if(f.current.currentSrc===C.current&&t.seq===z.current)return;C.current=f.current.currentSrc,z.current=t.seq,b(t.seq)}};a.useEffect(()=>{const o=requestAnimationFrame(O);return()=>cancelAnimationFrame(o)},[t]);const D=(o,B,_=!1)=>{const G=f.current;return!G?.complete||G.currentSrc!==I?null:Cs(G.getBoundingClientRect(),G.naturalWidth,G.naturalHeight,N,j,o,B,_)};return a.useEffect(()=>{const o=f.current;if(!o||!d)return;const B=_=>{_.preventDefault();const G=D(_.clientX,_.clientY);if(!G)return;const u=_.deltaMode===2?_n(o.naturalWidth,o.naturalHeight,N,j).height:0,v=_.deltaMode===1?16:_.deltaMode===2?u:1,A=s=>Math.max(-1e4,Math.min(1e4,s*v));h({type:"input_mouse",eventType:"mouseWheel",...G,deltaX:A(_.deltaX),deltaY:A(_.deltaY),modifiers:Qe(_)})};return o.addEventListener("wheel",B,{passive:!1}),()=>o.removeEventListener("wheel",B)},[d,h,N,j,I]),e.jsx(e.Fragment,{children:e.jsx("img",{ref:f,src:I,alt:"Live bot browser",draggable:!1,tabIndex:d?0:-1,title:d?"Shift+Escape returns to the browser address bar.":void 0,"aria-description":d?r("browser.viewport.keysHint"):void 0,"aria-keyshortcuts":d?"Shift+Escape":void 0,className:`block h-full w-full object-contain select-none outline-none focus:ring-2 focus:ring-inset focus:ring-accent ${d?"cursor-default touch-none":"cursor-not-allowed"}`,onLoad:O,onError:E,onBlur:()=>{R.current=!1,S.release()},onContextMenu:o=>{d&&o.preventDefault()},onPointerDown:o=>{if(!d)return;const B=D(o.clientX,o.clientY);B&&(o.preventDefault(),o.currentTarget.focus(),o.currentTarget.setPointerCapture(o.pointerId),R.current=!0,h({type:"input_mouse",eventType:"mousePressed",...B,button:o.button===2?"right":o.button===1?"middle":"left",clickCount:Math.min(3,o.detail||1),modifiers:Qe(o)}))},onPointerUp:o=>{if(!d)return;o.preventDefault();const B=D(o.clientX,o.clientY,o.currentTarget.hasPointerCapture(o.pointerId));if(!B){S.release();return}h({type:"input_mouse",eventType:"mouseReleased",...B,button:o.button===2?"right":o.button===1?"middle":"left",clickCount:Math.min(3,o.detail||1),modifiers:Qe(o)})},onPointerCancel:S.release,onPointerMove:o=>{if(!d)return;const B=D(o.clientX,o.clientY,o.currentTarget.hasPointerCapture(o.pointerId));B&&h({type:"input_mouse",eventType:"mouseMoved",...B,button:o.buttons&1?"left":o.buttons&2?"right":o.buttons&4?"middle":"none",modifiers:Qe(o)})},onKeyDown:o=>{if(!(!d||o.nativeEvent.isComposing)){if(o.key==="Escape"&&o.shiftKey){o.preventDefault(),o.stopPropagation(),S.release(),w();return}o.key==="Tab"&&!R.current||(Ss.has(o.key)||(R.current=!0),!((o.metaKey||o.ctrlKey)&&o.key.toLowerCase()==="v")&&(o.preventDefault(),h({type:"input_keyboard",eventType:"keyDown",key:o.key,code:o.code,windowsVirtualKeyCode:o.keyCode,modifiers:Qe(o),...o.key.length===1&&!o.metaKey&&!o.ctrlKey&&!o.altKey?{text:o.key}:{}})))}},onKeyUp:o=>{if(!(!d||(o.metaKey||o.ctrlKey)&&o.key.toLowerCase()==="v")){if(o.key==="Escape"&&o.shiftKey){o.preventDefault(),o.stopPropagation();return}o.key==="Tab"&&!R.current||(o.preventDefault(),h({type:"input_keyboard",eventType:"keyUp",key:o.key,code:o.code,windowsVirtualKeyCode:o.keyCode,modifiers:Qe(o)}))}},onPaste:o=>{d&&(o.preventDefault(),R.current=!0,h({type:"input_keyboard",eventType:"char",text:o.clipboardData.getData("text/plain").slice(0,4096)}))}})})}const jt=t=>t.type==="input_mouse"&&["mouseMoved","mouseWheel"].includes(String(t.eventType)),Xt=t=>t.type==="input_mouse"&&t.eventType==="mouseReleased"||t.type==="input_keyboard"&&t.eventType==="keyUp",Nt=t=>typeof t=="number"&&Number.isFinite(t)?t:0,In=t=>Math.max(-1e4,Math.min(1e4,t));function Ts(t,c){let l=[],d=null,p=0,b=!1;const E=f=>{l=l.filter(Xt),b||(b=!0,c(f))},w=()=>{if(d||!l.length)return;const f=p;d=(async()=>{for(;f===p&&l.length;){const C=l.shift();try{await t(C)}catch(z){f===p&&E(z)}}})().finally(()=>{d=null,w()})};return{enqueue(f){if(b&&!Xt(f))return;const C=l.at(-1);if(C&&jt(f)&&C.type===f.type&&C.eventType===f.eventType&&C.modifiers===f.modifiers&&C.button===f.button){l[l.length-1]=f.eventType==="mouseWheel"?{...f,deltaX:In(Nt(C.deltaX)+Nt(f.deltaX)),deltaY:In(Nt(C.deltaY)+Nt(f.deltaY))}:{...f};return}if(l.length>=32){if(jt(f))return;const z=l.findIndex(jt);if(z>=0)l.splice(z,1);else if(E(new Error(r("browser.input.tooSlow"))),!Xt(f)||l.length>=32)return}l.push({...f}),w()},async drain(){for(l=l.filter(f=>!jt(f));d||l.length;)w(),await d},async settle(){for(;d||l.length;)w(),await d},size(){return l.length+(d?1:0)},clear(){p++,l=[],b=!1},stopped(){return b}}}const Is=8e3,Ps=300,zs=16,$n=new Set(["Alt","Control","Meta","Shift"]),As=new Set(["Backspace","Enter","Tab","Escape","Delete","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),Ds=new Set(["navigate","tab-new"]);function Yt(t){if("command"in t)return!0;const{eventType:c,key:l}=t.input;return c==="mousePressed"||c==="mouseWheel"||c==="char"||c==="keyDown"&&!$n.has(String(l))}const Jt=({type:t,code:c,key:l,button:d})=>t==="input_keyboard"?`key:${c||l}`:`mouse:${d}`,Pn=({eventType:t})=>t==="keyDown"||t==="mousePressed",zn=({eventType:t})=>t==="keyUp"||t==="mouseReleased";function Ms(t){if(t.type!=="input_keyboard")return!0;const c=String(t.key);return $n.has(c)?!0:As.has(c)?!1:!t.modifiers||t.modifiers===8&&[...c].length===1}const Os=t=>t?.waited===!0;function Ls(t){let c="bot",l="",d=[],p=!1,b=!1,E=!1,w=!1,f=0,C=Promise.resolve(),z,N;const j=new Set,I=new Set,S=u=>{l=u,t.onTakeStatus(u)},h=u=>{Pn(u)&&Ms(u)?j.add(Jt(u)):zn(u)&&j.delete(Jt(u))},R=()=>!b&&!E&&!p&&!j.size&&!t.busy()&&(c==="held"||c==="bot"&&t.owned()),O=()=>{clearTimeout(z),z=b?void 0:setTimeout(()=>{z=void 0,o()},w?0:Is)},D=()=>{c="releasing",l==="stale"&&S(""),C=C.then(()=>b?void 0:t.release()).catch(()=>{}).then(()=>{c==="releasing"&&(c="bot")})},o=async()=>{if(!R())return;const u=f;await t.queue.drain(),u===f&&R()&&D()},B=()=>{const u=d.filter(A=>"command"in A&&Ds.has(String(A.command.type))),v=d.some(A=>!u.includes(A)&&Yt(A));d=u;for(const A of j)I.add(A);return j.clear(),v},_=async()=>{p=!0;try{for(let u=d.shift();u&&!b;u=d.shift())"command"in u?await t.command(u.command):(t.queue.enqueue(u.input),t.queue.size()>=zs&&await t.queue.settle())}finally{p=!1,d=[]}},G=()=>{c="taking",t.onError(""),S("pending"),clearTimeout(N),N=setTimeout(()=>{!b&&c==="taking"&&S("slow")},Ps),C=C.then(async()=>{if(b)return;const u=await t.take().then(v=>({reply:v}),v=>(b||t.onError(v instanceof Error?v.message:String(v)),null));clearTimeout(N),!b&&(u?(c="held",S(Os(u.reply)&&B()?"stale":""),await _()):(S(""),c="bot",d=[],j.clear()),O())}).catch(()=>{})};return{interact(u){if(b)return;if("input"in u){const A=Jt(u.input);if(zn(u.input)&&I.delete(A))return;Pn(u.input)&&I.delete(A)}const v=c==="taking"||p;if(c!=="held"&&!v){if(!Yt(u))return;if("input"in u&&t.queue.stopped()){t.onHalted();return}}if(!("command"in u&&v&&d.some(A=>"command"in A))){if(Yt(u)&&(w=!1,l==="stale"&&S("")),"input"in u&&h(u.input),f++,O(),c==="held"&&!v){"input"in u?t.queue.enqueue(u.input):t.command(u.command).then(O);return}d.push(u),v||G()}},observe(){!b&&z===void 0&&t.owned()&&O()},handBack(){b||(w=!0,O())},hold(u){b||E===u||(E=u,u||O())},leave(){!R()||t.queue.size()||(c="releasing",t.release().catch(()=>{}))},close(){b=!0,clearTimeout(z),clearTimeout(N),d=[],j.clear(),I.clear()}}}const Ne="rounded-md p-1.5 text-ink-secondary hover:bg-inset hover:text-ink disabled:opacity-40 disabled:cursor-not-allowed",Fs=[1e3,2e3,4e3,8e3,15e3],An="Connection interrupted. Reconnecting the browser view…",Gt={held:!1,controlling:!1,owned:!1};function Vs({bot:t}){const{state:c}=It(),[l,d]=a.useState(0),[p,b]=a.useState(null),[E,w]=a.useState([]),[f,C]=a.useState(""),[z,N]=a.useState(!1),[j,I]=a.useState({held:!1,controlling:!1,owned:!1}),[S,h]=a.useState(!1),[R,O]=a.useState(""),[D,o]=a.useState(!1),[B,_]=a.useState(!1),[G,u]=a.useState({width:1280,height:720}),[v,A]=a.useState(""),[s,le]=a.useState(!1),[je,Z]=a.useState(!1),q=a.useRef(""),V=a.useRef(0),H=a.useRef(null),ce=a.useRef(null),Se=a.useRef(null),$e=a.useRef(null),tt=a.useRef(null),se=a.useRef(null),ne=a.useRef(null),Ce=a.useRef(Gt),Ae=a.useRef(""),Ee=a.useRef(!1),De=a.useRef(0),mt=a.useRef(""),m=t.browserProfile==="guest"?"Temporary browser":c.config?.browserProfiles?.find(g=>g.id===t.browserProfile)?.name??`${t.name}’s own browser`;a.useEffect(()=>{D?$e.current?.showModal():$e.current?.close()},[D]),a.useEffect(()=>{ne.current?.hold(B),B?tt.current?.showModal():tt.current?.close()},[B]);const k=a.useCallback(async(g,X=q.current)=>{if(!X)throw new Error("Open the browser connection first.");return W(`/api/bots/${encodeURIComponent(t.id)}/browser/action`,{method:"POST",body:JSON.stringify({...g,viewerId:X}),timeoutMs:12e4})},[t.id]),Re=a.useCallback(g=>{Ce.current.held&&!Ce.current.owned||ne.current?.interact(g)},[]),nt=a.useCallback(g=>Re({input:g}),[Re]),ie=g=>Re({command:g}),ae=a.useCallback(()=>{V.current++,De.current=0,q.current="",se.current?.clear(),se.current=null,ne.current?.close(),ne.current=null,H.current=null,d(g=>g+1)},[]);a.useEffect(()=>{const g=++V.current,X=()=>V.current===g,ue=JSON.stringify([t.id,t.browserProfile]);mt.current!==ue&&(mt.current=ue,De.current=0);let Oe=!1,oe;q.current="",H.current=null,Ae.current="",Ee.current=!1,b(null),w([]),C(""),N(!1),O(""),Z(!1),I({held:!1,controlling:!1,owned:!1}),h(!1),Ce.current=Gt,A("");const Xe=new EventSource(`/api/bots/${encodeURIComponent(t.id)}/browser/live`),de=(F,Q)=>Xe.addEventListener(F,ge=>{if(!(Oe||!X()))try{Q(JSON.parse(ge.data))}catch{}});return de("waiting",()=>{q.current||Z(!0)}),de("ready",F=>{if(typeof F.viewerId!="string"||!F.viewerId)return;Z(!1);const Q=F.viewerId;q.current=Q;const ge=Ts(async me=>{X()&&q.current===Q&&await k(me,Q)},me=>{!X()||q.current!==Q||(Ae.current=me instanceof Error?me.message:String(me),O(Ae.current))});se.current=ge,ne.current=Ls({queue:ge,take:()=>k({type:"take"},Q),release:()=>k({type:"release"},Q),command:me=>He(me),busy:()=>H.current!==null,owned:()=>Ce.current.owned,onTakeStatus:A,onError:O,onHalted:()=>O(Ae.current)}),N(!0)}),de("heartbeat",()=>{De.current=0}),de("frame",F=>{q.current&&b({...F,viewerId:q.current,generation:g})}),de("tabs",F=>{if(!Array.isArray(F.tabs))return;w(F.tabs);const Q=F.tabs.find(ge=>ge.active);Q&&!Ee.current&&C(Q.url==="about:blank"?"":Q.url)}),de("url",F=>{typeof F.url=="string"&&!Ee.current&&C(F.url==="about:blank"?"":F.url)}),de("status",F=>{F.viewportWidth>0&&F.viewportHeight>0&&u({width:F.viewportWidth,height:F.viewportHeight})}),de("control",F=>{Ce.current=F,I(F),F.held&&!F.owned&&(b(null),w([]),C("")),ne.current?.observe()}),Xe.addEventListener("error",F=>{if(Oe||!X())return;Oe=!0;let Q="Browser connection ended. Reconnect to continue watching.",ge=!(F instanceof MessageEvent);if(F instanceof MessageEvent)try{const ve=JSON.parse(F.data);Q=ve.message||Q,ge=ve.retryable===!0}catch{}const me=ge?Fs[De.current]:void 0;me!==void 0&&(De.current++,Q=An,oe=setTimeout(()=>{X()&&(V.current++,d(ve=>ve+1))},me)),O(Q),Z(!1),N(!1),b(null),I({held:!1,controlling:!1,owned:!1}),Ce.current=Gt,A(""),q.current="",se.current?.clear(),se.current=null,ne.current?.close(),ne.current=null,Xe.close()}),()=>{Oe=!0,clearTimeout(oe),X()&&(ne.current?.leave(),ne.current?.close(),ne.current=null,V.current++,q.current="",H.current=null,se.current?.clear(),se.current=null),Xe.close()}},[t.id,t.browserProfile,l,k]),a.useEffect(()=>{const g=()=>le(!!ce.current&&document.fullscreenElement===ce.current);return document.addEventListener("fullscreenchange",g),()=>document.removeEventListener("fullscreenchange",g)},[]);const rt=()=>{const g=!!ce.current&&document.fullscreenElement===ce.current;(g?document.exitFullscreen():ce.current?.requestFullscreen())?.catch(()=>O(g?"Could not leave full screen. Press Esc instead.":"Full screen is unavailable in this browser."))},He=async g=>{if(H.current!==null)return;const X=q.current,ue=V.current,Oe=se.current;H.current=ue,h(!0),O("");try{if(await Oe?.drain(),V.current!==ue||q.current!==X)return;await k(g,X),se.current?.stopped()&&V.current===ue&&O(Ae.current),V.current===ue&&g.type==="restart"&&ae()}catch(oe){V.current===ue&&O(oe instanceof Error?oe.message:String(oe))}finally{V.current===ue&&H.current===ue&&(H.current=null,h(!1))}},M=j.held&&!j.owned,Me=z&&!M&&!S,re=Me&&j.owned&&j.controlling,he=v==="pending"||v==="slow",K=Me&&!he,Te=R===An,Ie="flex max-w-full items-center gap-1.5 whitespace-nowrap rounded-full border bg-menu px-2.5 py-1 text-[11px] shadow-sm sm:text-[12px]";return e.jsxs("div",{ref:ce,className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-2xl border border-hairline/40 bg-card text-ink",children:[e.jsxs("div",{className:"flex min-h-12 items-center gap-1 px-2 pt-1.5",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[E.length?E.map(g=>e.jsxs("div",{className:`flex max-w-52 shrink-0 items-center gap-1 rounded-xl px-1 text-[12px] ${g.active?"bg-inset text-ink":"text-ink-secondary"}`,children:[e.jsx(We,{size:13,className:"ml-1.5 shrink-0 opacity-60"}),e.jsx("button",{className:"truncate px-1 py-2 text-left disabled:cursor-default",disabled:!K,onClick:()=>ie({type:"tab-select",tabId:g.tabId}),title:g.title||g.url,children:g.title||"New tab"}),e.jsx("button",{className:Ne,"aria-label":`Close ${g.title||"tab"}`,disabled:!K,onClick:()=>ie({type:"tab-close",tabId:g.tabId}),children:e.jsx(St,{size:13})})]},g.tabId)):e.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-inset px-3 py-2 text-[12px] text-ink-secondary",children:[e.jsx(We,{size:13}),"New tab"]}),e.jsx("button",{className:`${Ne} shrink-0`,disabled:!K,"aria-label":"New tab",title:"New tab",onClick:()=>ie({type:"tab-new"}),children:e.jsx(sr,{size:17})})]}),e.jsx("button",{className:Ne,title:s?"Exit full screen":"Full screen","aria-label":s?"Exit full screen":"Full screen",onClick:rt,children:s?e.jsx(us,{size:16}):e.jsx(Tt,{size:16})}),e.jsx("button",{className:`${Ne} rounded-xl bg-inset p-2`,title:`Browser profile: ${m}`,"aria-label":"Browser profiles","aria-expanded":D,onClick:()=>{ne.current?.handBack(),o(!0)},children:e.jsx(bs,{size:16})})]}),e.jsxs("form",{className:"flex h-12 items-center gap-1 border-b border-hairline/40 px-2",onSubmit:g=>{g.preventDefault(),K&&f.trim()&&ie({type:"navigate",url:/^https?:\/\//i.test(f.trim())?f.trim():`https://${f.trim()}`})},children:[e.jsxs("div",{className:"flex shrink-0 items-center",children:[e.jsx("button",{type:"button",className:Ne,disabled:!K,"aria-label":"Back",onClick:()=>ie({type:"back"}),children:e.jsx(Vn,{size:17})}),e.jsx("button",{type:"button",className:Ne,disabled:!K,"aria-label":"Forward",onClick:()=>ie({type:"forward"}),children:e.jsx(ar,{size:17})}),e.jsx("button",{type:"button",className:Ne,disabled:!K,"aria-label":"Reload page",onClick:()=>ie({type:"reload"}),children:e.jsx(Wr,{size:17})})]}),e.jsx("input",{ref:Se,"aria-label":"Browser address",readOnly:!K,value:f,onChange:g=>C(g.target.value),onFocus:g=>{Ee.current=!0,K&&g.target.select()},onBlur:()=>{Ee.current=!1},placeholder:z?"about:blank":"Connecting…",spellCheck:!1,className:"mx-1 min-w-0 flex-1 rounded-lg bg-transparent px-2 py-1.5 text-center text-[12px] outline-none placeholder:text-ink-secondary focus:bg-inset focus:text-left"}),e.jsxs("details",{className:"relative shrink-0",children:[e.jsx("summary",{className:`${Ne} list-none cursor-pointer [&::-webkit-details-marker]:hidden`,"aria-label":"Browser menu",title:"Browser menu",children:e.jsx(ls,{size:17})}),e.jsxs("div",{className:"absolute right-0 top-full z-20 mt-2 flex w-44 flex-col rounded-xl border border-hairline/50 bg-card p-1.5 text-[12px] shadow-xl",children:[e.jsx("button",{type:"button",className:"rounded-md px-3 py-2 text-left hover:bg-inset disabled:opacity-40",disabled:!re,onClick:g=>{g.currentTarget.closest("details")?.removeAttribute("open"),_(!0)},children:"Type or paste text…"}),e.jsx("button",{type:"button",className:"rounded-md px-3 py-2 text-left hover:bg-inset",onClick:g=>{g.currentTarget.closest("details")?.removeAttribute("open"),ae()},children:"Reconnect view"}),e.jsx("button",{type:"button",className:"rounded-md px-3 py-2 text-left hover:bg-inset disabled:opacity-40",disabled:!z||S||he,onClick:g=>{g.currentTarget.closest("details")?.removeAttribute("open"),window.confirm("Restart this profile’s browser? Open tabs will close. Saved logins are kept. Stop any bots using it first.")&&He({type:"restart"})},children:"Restart browser…"})]})]})]}),R&&e.jsxs("div",{role:Te?"status":"alert",className:`flex items-center justify-between gap-2 border-b border-hairline/30 px-3 py-2 text-[12px] ${Te?"text-ink-secondary":"text-danger"}`,children:[e.jsx("span",{children:R}),!z&&e.jsx("button",{className:"shrink-0 underline",onClick:ae,children:"Reconnect"})]}),e.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-inset/40",children:[p?e.jsx(Rs,{frame:p,...G,driving:Me,input:nt,onReturnToToolbar:()=>Se.current?.focus(),acknowledge:g=>{V.current===p.generation&&q.current===p.viewerId&&k({type:"ack",seq:g},p.viewerId).catch(()=>{})},onDecodeError:()=>{V.current===p.generation&&q.current===p.viewerId&&O("A browser frame could not be decoded. Close and reopen the panel to reconnect.")}}):e.jsxs("div",{className:"flex min-h-64 flex-col items-center justify-center gap-3 p-6 text-center text-[13px] text-ink-secondary",children:[z&&M?e.jsx(_e,{size:24}):R&&!Te?e.jsx(We,{size:24}):e.jsx(U,{size:24,className:"animate-spin"}),e.jsx("span",{children:M?"Live view paused for human control":Te?"Reconnecting…":R?"Browser disconnected":je?r("browser.live.botBusy",{name:t.name}):"Opening the live browser…"})]}),e.jsx("div",{role:"status",className:"pointer-events-none absolute inset-x-0 top-2 flex justify-center px-3",children:v==="slow"?e.jsxs("span",{className:`${Ie} border-hairline text-ink-secondary`,children:[e.jsx(U,{size:13,className:"shrink-0 animate-spin","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:r("browser.control.waiting",{name:t.name})})]}):v==="stale"?e.jsxs("span",{className:`${Ie} border-accent-border text-accent-text`,children:[e.jsx(_e,{size:13,className:"shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:r("browser.control.stale",{name:t.name})})]}):!v&&j.owned&&j.controlling?e.jsxs("span",{className:`${Ie} border-accent-border text-accent-text`,"aria-description":r("browser.control.yoursHint",{name:t.name}),children:[e.jsx(_e,{size:13,className:"shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:r("browser.control.yours")})]}):null})]}),e.jsxs("dialog",{ref:$e,onClose:()=>o(!1),onClick:g=>{g.target===g.currentTarget&&o(!1)},className:"m-auto w-[min(420px,calc(100%-32px))] max-h-[80vh] overflow-auto rounded-2xl border border-hairline/50 bg-card p-5 text-ink shadow-2xl backdrop:bg-black/40",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsx("h2",{className:"text-[15px] font-medium",children:"Browser profiles"}),e.jsx("button",{className:Ne,"aria-label":"Close browser profiles",onClick:()=>o(!1),children:e.jsx(St,{size:16})})]}),(M||j.owned&&(S||he))&&e.jsx("p",{className:"mb-3 text-[12px] text-ink-secondary",children:r(M?"browser.profiles.heldElsewhere":"browser.profiles.busy")}),e.jsx(Zr,{bot:t,disabled:S||j.held,onProfileChanged:()=>{o(!1),ae()}})]}),e.jsxs("dialog",{ref:tt,onClose:()=>_(!1),className:"m-auto w-[min(420px,calc(100%-32px))] rounded-2xl border border-hairline/50 bg-card p-5 text-ink shadow-2xl backdrop:bg-black/40",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h2",{className:"text-[14px] font-medium",children:"Type into the selected page field"}),e.jsx("button",{className:Ne,"aria-label":"Close typing",onClick:()=>_(!1),children:e.jsx(St,{size:16})})]}),e.jsxs("form",{className:"flex flex-col gap-3",onSubmit:g=>{g.preventDefault();const X=g.currentTarget.elements.namedItem("pageText");re&&X.value&&(nt({type:"input_keyboard",eventType:"char",text:X.value}),X.value="",_(!1))},children:[e.jsx("input",{name:"pageText","aria-label":"Text for the page",autoComplete:"off",maxLength:4096,placeholder:"Type or paste text",className:"rounded-lg bg-inset px-3 py-2 text-[13px] outline-none focus:ring-1 focus:ring-accent"}),e.jsx("button",{disabled:!re,className:"self-end rounded-lg bg-accent px-4 py-2 text-[12px] text-accent-ink disabled:opacity-40",children:"Type"})]})]})]})}function _s({bot:t}){const{state:c}=It(),l=c.config?.browserEngine,[d,p]=a.useState(!1),[b,E]=a.useState(null),[w,f]=a.useState(null);a.useEffect(()=>{let N=!0;return W("/api/auth/session").then(j=>{N&&f(j.scopes.includes("admin"))}).catch(()=>{N&&f(!1)}),()=>{N=!1}},[]);const C=d||l?.installing===!0,z=async()=>{E(null),p(!0);try{await W("/api/browser-engine/install",{method:"POST"})}catch(N){E(N instanceof Error?N.message:String(N))}finally{p(!1)}};return w===!1?e.jsx("div",{className:"p-5 text-[13px] text-ink-secondary",children:"Only admins of this installation can view or control saved browser sessions."}):t.browser===!1?e.jsx("div",{className:"p-5 text-[13px] text-ink-secondary",children:"Enable the browser in this bot’s profile to use it."}):l?.kind==="engine"&&!C&&!l.installError?w===null?e.jsx("div",{className:"p-5 text-[13px] text-ink-secondary",children:"Loading browser…"}):e.jsx(Vs,{bot:t},t.id):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-start justify-center gap-3 rounded-xl bg-card p-5",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:l?.kind==="engine"?"Browser installation incomplete":"Browser engine not installed"}),e.jsx("p",{className:"text-[13px] leading-relaxed text-ink-secondary",children:l?.kind==="engine"?"agent-browser is installed, but Chrome setup has not finished. Retry the browser installation.":Zt(c.config)}),l?.installable||l?.kind==="engine"?e.jsx("button",{type:"button",onClick:()=>{z()},disabled:C||w!==!0,className:"rounded-lg bg-accent px-3 py-1.5 text-[13px] font-medium text-accent-ink disabled:opacity-60",children:C?"Installing… (a one-time download of about 160 MB)":l?.kind==="engine"?"Retry browser installation":"Install the browser engine"}):null,(l?.installError||b)&&e.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:b??l?.installError})]})}function Ct(t){for(const c of t?.getTracks()??[])c.stop()}function $s(t){const c=t instanceof DOMException?t.name:"";return c==="NotAllowedError"||c==="AbortError"?{ok:!1,phase:"cancelled",messageKey:"computer.screen.cancelled"}:c==="NotFoundError"||c==="NotReadableError"||c==="NotSupportedError"||c==="SecurityError"?{ok:!1,phase:"unavailable",messageKey:"computer.screen.unavailableNow"}:{ok:!1,phase:"error",messageKey:"computer.screen.error"}}async function Bs({beginIntent:t,getDisplayMedia:c}){try{if(!t())return{ok:!1,phase:"unavailable",messageKey:"computer.screen.unavailableWindow"};const l=await c({video:!0,audio:!1});return l.getVideoTracks().length===0?(Ct(l),{ok:!1,phase:"unavailable",messageKey:"computer.screen.noVideoTrack"}):{ok:!0,stream:l}}catch(l){return $s(l)}}const dt={idle:"computer.screen.idle",ended:"computer.screen.ended",unavailable:"computer.screen.unavailable"};function Ks(){const{capabilities:t,ready:c}=Pt(),l=t.screenPreview,d=t.host.platform==="linux",[p,b]=a.useState("idle"),[E,w]=a.useState(dt.idle),[f,C]=a.useState(""),z=a.useRef(null),N=a.useRef(null),j=a.useRef(0),I=a.useCallback((O,D)=>{j.current+=1;const o=N.current;N.current=null,z.current&&(z.current.srcObject=null),Ct(o),b(O),w(D)},[]);a.useEffect(()=>()=>{j.current+=1;const O=N.current;N.current=null,Ct(O)},[]);const S=async()=>{if(!l.available||!window.ogb?.beginScreenPreviewIntent||!navigator.mediaDevices?.getDisplayMedia){b("unavailable"),w(dt.unavailable);return}I("requesting","computer.screen.waiting");const O=j.current,D=await Bs({beginIntent:()=>window.ogb.beginScreenPreviewIntent(),getDisplayMedia:G=>navigator.mediaDevices.getDisplayMedia(G)});if(O!==j.current){D.ok&&Ct(D.stream);return}if(!D.ok){b(D.phase),w(D.messageKey);return}const o=D.stream,B=o.getVideoTracks()[0];N.current=o,C(B.label),B.addEventListener("ended",()=>{N.current===o&&I("ended",dt.ended)},{once:!0});const _=z.current;if(!_){I("error","computer.screen.displayFailed");return}_.srcObject=o;try{await _.play()}catch{O===j.current&&N.current===o&&I("error","computer.screen.displayFailed");return}O!==j.current||N.current!==o||(b("streaming"),w("computer.screen.active"))};if(!d)return null;const h=f||r("computer.screen.selected"),R=p==="cancelled"||p==="ended"||p==="unavailable"||p==="error";return e.jsxs("section",{className:"mt-4 rounded-xl bg-card p-4","aria-labelledby":"local-preview-title",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{id:"local-preview-title",className:"text-[15px] font-medium text-ink",children:r("computer.screen.title")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:r("computer.screen.subtitle")})]}),e.jsx("span",{className:"shrink-0 rounded-full bg-raised px-2 py-1 text-[10px] font-medium text-ink-secondary",children:r("computer.screen.badge")})]}),e.jsxs("div",{className:"relative mt-3 flex aspect-[16/10] items-center justify-center overflow-hidden rounded-lg bg-panel",children:[e.jsx("video",{ref:z,autoPlay:!0,muted:!0,playsInline:!0,"aria-label":r("computer.screen.videoAria"),className:p==="streaming"?"h-full w-full object-contain":"hidden"}),p!=="streaming"&&e.jsxs("div",{className:"flex flex-col items-center gap-2 px-6 text-center text-ink-secondary",children:[p==="requesting"?e.jsx(U,{size:18,className:"animate-spin"}):e.jsx(Ve,{size:22}),e.jsx("span",{className:"text-[12px]","aria-live":"polite",children:c?r(l.available?E:dt.unavailable):r("computer.screen.checking")})]})]}),p==="streaming"&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-3 text-[11px] text-ink-secondary",children:[e.jsx("span",{className:"truncate",title:h,children:l.interaction==="portal-picker"?h:r("vm.dest.local")}),e.jsxs("span",{className:"flex items-center gap-1.5 text-success",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-success"})," ",r("computer.screen.sharing")]})]}),e.jsxs("button",{type:"button",disabled:p==="requesting"||!l.available&&p!=="streaming",onClick:p==="streaming"?()=>I("idle",dt.idle):()=>{S()},className:"mt-3 flex w-full items-center justify-center gap-2 rounded-lg bg-raised py-2 text-[13px] text-ink hover:bg-raised-hover disabled:cursor-not-allowed disabled:opacity-50",children:[p==="requesting"?e.jsx(U,{size:14,className:"animate-spin"}):p==="streaming"?e.jsx(or,{size:13}):R?e.jsx(Qt,{size:14}):e.jsx(Ve,{size:14}),p==="requesting"?r("computer.screen.choosing"):p==="streaming"?r("computer.screen.stop"):R?r("computer.linux.tryAgain"):l.interaction==="portal-picker"?r("computer.screen.choose"):r("computer.screen.start")]})]})}const Us="https://github.com/milind-soni/OpenMausBot/blob/main/docs/linux-desktop.md#enable-local-control";function qs(){const{capabilities:t}=Pt(),c=t.localComputer,[l,d]=a.useState(null),[p,b]=a.useState(null);if(t.host.platform!=="linux")return null;const E=l!==null||c.status==="checking"||c.status==="starting",w=c.available,f=c.reasonCode==="linux-wayland-seat-safety-blocked",C=t.host.session==="wayland",z=c.driverSource==="bundled",N=async j=>{if(window.ogb?.localControl){d(j),b(null);try{if((j==="disable"||j==="retry")&&!(await fetch("/api/local-computer/interrupt",{method:"POST"})).ok){b({key:"computer.linux.stopFailed"});return}await window.ogb.localControl[j]()}catch(I){b(I instanceof Error?I.message:String(I))}finally{d(null)}}};return e.jsxs("section",{className:"mt-4 rounded-xl bg-card p-4","aria-labelledby":"linux-local-control-title",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{id:"linux-local-control-title",className:"flex items-center gap-2 text-[15px] font-medium text-ink",children:[e.jsx(ps,{size:16,className:w?"text-success":"text-ink-secondary"}),r("computer.linux.title")]}),e.jsx("div",{className:"mt-1 text-[12px] leading-relaxed text-ink-secondary",children:r("computer.linux.meta",{session:C?"Wayland":"Xorg"})})]}),e.jsx("span",{className:Fe("shrink-0 rounded-full px-2 py-1 text-[10px] font-medium",w?"bg-success/10 text-success":f?"bg-danger/10 text-danger":c.enabled?"bg-warning/10 text-warning":"bg-raised text-ink-secondary"),children:w?r("computer.linux.ready"):f?r("computer.linux.waylandBadge"):c.enabled?r("vm.state.attention"):r("vm.dest.off")})]}),f?e.jsx("div",{className:"mt-3 rounded-lg border border-danger/20 bg-danger/5 p-3",children:e.jsxs("div",{className:"flex gap-2 text-[12px] leading-relaxed text-ink-secondary",children:[e.jsx(Wt,{size:15,className:"mt-0.5 shrink-0 text-danger"}),e.jsxs("span",{children:[r("computer.linux.waylandBefore")," ",e.jsx("strong",{className:"font-medium text-ink",children:r("computer.linux.waylandXorg")})," ",r("computer.linux.waylandAfter")]})]})}):c.enabled?e.jsxs("div",{className:"mt-3 rounded-lg bg-panel p-3 text-[12px] text-ink-secondary",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[w?e.jsx(ir,{size:15,className:"mt-0.5 shrink-0 text-success"}):E?e.jsx(U,{size:15,className:"mt-0.5 shrink-0 animate-spin"}):e.jsx(Wt,{size:15,className:"mt-0.5 shrink-0 text-warning"}),e.jsx("span",{"aria-live":"polite",children:w?r("computer.linux.readyMsg"):c.message??r("computer.linux.checking")})]}),c.driverPath&&e.jsxs("div",{className:"mt-2 break-all font-mono text-[10px] text-ink-tertiary",title:c.driverPath,children:[z?r("computer.linux.bundledDriver"):c.driverPath,c.driverVersion?` · ${c.driverVersion}`:""]})]}):e.jsx("div",{className:"mt-3 rounded-lg border border-warning/20 bg-warning/5 p-3",children:e.jsxs("div",{className:"flex gap-2 text-[12px] leading-relaxed text-ink-secondary",children:[e.jsx(Wt,{size:15,className:"mt-0.5 shrink-0 text-warning"}),e.jsxs("span",{children:[r("computer.linux.enableBefore")," ",e.jsx("strong",{className:"font-medium text-ink",children:r("vm.dest.local")})," ",r("computer.linux.enableAfter"),C&&` ${r("computer.linux.waylandInput")}`]})]})}),p&&e.jsx("div",{className:"mt-2 text-[12px] text-danger",children:typeof p=="string"?p:r(p.key)}),!f&&e.jsx("div",{className:"mt-3 flex gap-2",children:c.enabled?e.jsxs(e.Fragment,{children:[!w&&e.jsxs("button",{type:"button",disabled:E,onClick:()=>{N("retry")},className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-raised py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[l==="retry"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(Qt,{size:14}),r("computer.linux.tryAgain")]}),e.jsxs("button",{type:"button",disabled:l!==null,onClick:()=>{N("disable")},className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-raised py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[l==="disable"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(pt,{size:14}),r("computer.linux.disable")]})]}):e.jsxs("button",{type:"button",disabled:E,onClick:()=>{N("enable")},className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-accent py-2 text-[13px] font-medium text-white hover:opacity-90 disabled:opacity-50",children:[l==="enable"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(pt,{size:14}),r("computer.linux.enable")]})}),e.jsxs("button",{type:"button",onClick:()=>window.open(Us,"_blank","noopener,noreferrer"),className:"mt-2 flex w-full items-center justify-center gap-1.5 rounded-lg py-1.5 text-[11px] text-ink-secondary hover:bg-raised hover:text-ink",children:[t.host.packaged?r("computer.linux.guide"):r("computer.linux.driverSetup")," ",e.jsx(lr,{size:11})]})]})}class te extends Error{constructor(c,l,d){super(c),this.key=c,this.problem=l,this.fallbackKey=d}key;problem;fallbackKey}function Dn(t){return t instanceof te?r(t.key,t.fallbackKey?{problem:t.problem??r(t.fallbackKey)}:void 0):t instanceof Error?t.message:t}const Mn=Vr({held:$r().optional().default(!1),helpReason:_r().nullable().optional().default(null)}).passthrough(),Bn="omb-computer-panel-width",Et=360,Rt=960,Ws=400,On=40;function Hs(){try{const t=Number(localStorage.getItem(Bn));if(Number.isFinite(t)&&t>=Et&&t<=Rt)return t}catch{}return Ws}function na({bot:t,onOpenVmWorkspace:c}){const{padClass:l}=cr(),[d,p]=a.useState(Hs),b=a.useRef(null),E=n=>{try{localStorage.setItem(Bn,String(n))}catch{}},w=n=>{b.current={x:n.clientX,width:d},n.currentTarget.setPointerCapture(n.pointerId)},f=n=>{if(!b.current)return;const i=Math.min(Rt,Math.max(Et,b.current.width+(b.current.x-n.clientX)));p(i)},C=n=>{b.current&&(b.current=null,n.currentTarget.releasePointerCapture(n.pointerId),E(d))},z=n=>{p(i=>{const x=Math.min(Rt,Math.max(Et,i+n));return E(x),x})},N=a.useRef(null),[j,I]=a.useState(null);a.useEffect(()=>{const n=N.current?.closest("aside");if(!n)return;const i=()=>I(n.offsetWidth);i();const x=new ResizeObserver(i);return x.observe(n),()=>x.disconnect()},[]);const S=n=>{if(n.ctrlKey||n.metaKey||n.altKey)return;const i=n.key==="ArrowLeft"?On:n.key==="ArrowRight"?-On:null;i===null||j===null||(n.preventDefault(),z(i))},{state:h,dispatch:R,flushBotPatches:O}=It(),D=t.tasks?.find(n=>n.threadId===t.threadId),o=ur(t,D),B=dr(t),_=`${t.id}:${t.threadId}:${o}:${t.cloudBackend??"box"}:${B.modelSelection.instanceId}`,[G,u]=a.useState(null),v=G?.key===_,A=o!=="auto"||v,s={...B,computer:o==="auto"?v?G.surface:void 0:o},le=`${s.id}:${s.threadId}:${s.computer}:${s.cloudBackend??"box"}`,je=a.useRef(le);je.current=le;const Z=a.useRef(null);a.useEffect(()=>()=>Z.current?.abort(),[le]);const q=!!s.busy,V=a.useCallback(n=>`/api/bots/${t.id}/${n}?threadId=${encodeURIComponent(t.threadId)}`,[t.id,t.threadId]),H=t.computer==="cloud"&&o==="cloud",ce=t.computer==="vm"&&o==="vm",{capabilities:Se,ready:$e}=Pt(),tt=Se.localComputer.available,se=Se.host.platform==="linux",ne=pr(h.instances,s),Ce=jn("local",h.config)&&mr({capabilities:Se,providerSupportsLocal:ne}),[Ae,Ee]=a.useState(null),De=xr({capabilities:Se,providerSupportsLocal:ne}),mt=fr(h.config,Se.host.platform),[m,k]=a.useState("checking"),[Re,nt]=a.useState(null),[ie,ae]=a.useState(null),[rt,He]=a.useState(null),M=s.cloudBackend??"box",Me=!!(Re&&Re.botId===s.id&&Re.computer===t.computer&&Re.cloudBackend===M&&Re.section===(s.section?.trim()??"")),re=!!(ie&&ie.botId===s.id&&ie.threadId===s.threadId&&ie.computer===s.computer&&ie.cloudBackend===M),he=re&&o==="auto"&&M==="box"&&rt?.botId===s.id&&rt.section===(s.section?.trim()??"")?rt:null,K=re&&br({computer:s.computer,cloudBackend:M,phase:m,botId:s.id,resolvedBotId:ie?.botId??null,resolvedComputer:ie?.computer??null,resolvedCloudBackend:ie?.cloudBackend??null}),Te=a.useCallback(n=>{ae(null),He(null),k("checking"),R({type:"updateBot",botId:s.id,patch:n})},[s.id,R]);a.useEffect(()=>{let n=!0;return nt(null),O(s.id).then(i=>{n&&(i&&!hr({computer:t.computer,cloudBackend:M,persistedBot:i})||i&&(i.section?.trim()??"")!==(s.section?.trim()??"")||nt({botId:s.id,computer:t.computer,cloudBackend:M,section:s.section?.trim()??""}))}),()=>{n=!1}},[s.id,t.computer,s.section,M,O]);const[Ie,g]=a.useState(null),[X,ue]=a.useState(null),[Oe,oe]=a.useState(null),[Xe,de]=a.useState(!1),[F,Q]=a.useState(0),[ge,me]=a.useState(null),[ve,tn]=a.useState(null),[ye,xt]=a.useState(null),[nn,zt]=a.useState(null),[Kn,rn]=a.useState(null),[P,we]=a.useState(null),[ke,ft]=a.useState(!1),[bt,sn]=a.useState(!1),[ht,L]=a.useState(null),Be=Dn(ht),ee=gr(),[st,At]=a.useState(()=>Nn(s.id)),$=ee?st==="files"?"computer":st:st==="routines"||st==="android"?"computer":st,an=js(),gt=an.devices.length>0,on=vr(h.config),Le=Sn(h.config)&&s.browser!==!1&&(on||h.config?.browserEngine?.installable===!0),[ln,Ye]=a.useState(0);a.useEffect(()=>{if(o!=="auto"||!Me)return;const n=new AbortController;return u(null),W(V("computer"),{signal:n.signal}).then(i=>{if(n.signal.aborted)return;const x=i.surface;u({key:_,surface:x==="cloud"||x==="vm"||x==="local"||x==="browser"||x==="off"?x:void 0})}).catch(i=>{n.signal.aborted||(L(i instanceof Error?i:String(i)),k("error"))}),()=>n.abort()},[_,o,Me,V,ln]);const Dt=m==="vm-unavailable"&&ye?.resumable===!0,at=a.useRef(0),Ke=a.useRef(null);a.useEffect(()=>(Ke.current?.signal.aborted&&(Ke.current=null,we(null)),()=>{Ke.current?.abort()}),[s.id,s.threadId,s.computer,$]);const vt=h.instances.find(n=>n.instanceId===s.modelSelection.instanceId),Ue=n=>{At(n),Cn(s.id,n)},cn=a.useRef(null);a.useEffect(()=>{const n=cn.current;n===le&&!(s.computer==="browser"&&Le)||(cn.current=le,At(s.computer==="browser"&&Le?"browser":n===null?Nn(s.id):"computer"))},[le,s.id,s.computer,Le]),a.useEffect(()=>{let n=!0;const i=window.ogb?.desktopViewer;i?.currentState&&i.currentState().then(y=>{n&&sn(y.open&&y.contextId===s.id)}).catch(()=>{});const x=i?.onState(y=>{y.contextId===s.id&&sn(y.open)});return()=>{n=!1,x?.()}},[s.id]),a.useEffect(()=>{!gt&&$==="android"&&(At("computer"),Cn(s.id,"computer"))},[gt,s.id,$]),a.useEffect(()=>{at.current=0},[s.id,s.computer]);const un=!!(vt?.snapshot.state==="available"&&vt.capabilities?.computerMcp),Mt=Hr(Xr(vt)),dn=h.routines.filter(n=>n.botId===s.id).sort((n,i)=>Number(i.enabled)-Number(n.enabled)||(n.nextRunAt??1/0)-(i.nextRunAt??1/0)),Un=!!(h.config?.box.configured&&Yr(h.instances,s.modelSelection.instanceId)?.snapshot.state==="available"),ot=h.routineRuns.find(n=>n.botId===s.id&&["queued","running","waiting"].includes(n.status));a.useEffect(()=>{if($!=="computer")return;let n=!0;if(ae(null),He(null),k("checking"),ue(null),oe(null),me(null),tn(null),xt(null),zt(null),rn(null),L(null),!(!Me||!A)){if(s.computer===void 0){k("auto-unavailable");return}if(s.computer==="off"){k("off");return}if(s.computer==="browser"){k("browser");return}if(s.computer==="local"){ne||L(new te("computer.err.localEngine")),k($e&&tt&&ne?"local":"local-unavailable"),ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M});return}if(s.computer==="vm"){if(!un){L(new te("computer.err.vmEngine")),k("vm-unavailable");return}let i;return W(V("local-computer")).then(x=>{if(!n)return;const y=x;ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),xt(y);const T=String(y.viewer_url??"");if((T.startsWith("http")||T.startsWith("/desktop-viewer#"))&&tn(new URL(T,window.location.href).href),y.ready)at.current=0,k("vm");else if(y.container==="running"&&y.imageMatches&&y.managed&&y.network==="loopback"&&y.security==="hardened"&&y.persistence==="durable"&&!y.desktopReady&&at.current<15)at.current+=1,L(null),k("checking"),i=window.setTimeout(()=>Ye(Y=>Y+1),2e3);else{const Y=y.mode==="per-bot"&&y.container==="missing"&&y.image&&y.create_supported;L(Y||y.resumable?null:new te("computer.err.vmOpenSettings",y.problem,"computer.err.vmNotReady")),k("vm-unavailable")}}).catch(x=>{n&&(L(x.message),k("vm-unavailable"))}),()=>{n=!1,i!==void 0&&window.clearTimeout(i)}}if(s.computer==="cloud"&&!Mt){k("error");return}if(!(s.computer!=="cloud"&&!$e))return M==="vps"?(W(V("computer")).then(i=>{if(!n)return;const x=i;if(zt(x),ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),!x.configured){L(new te("computer.err.vpsAlias")),k("vps-unconfigured");return}if(x.ready){g(x.container??null),k("ready");return}if(x.managed&&x.container!=="missing"&&!x.imageMatches){L(x.problem),k("vps-incompatible");return}if(H)return k("starting"),W(`/api/bots/${s.id}/computer/provision`,{method:"POST"}).then(y=>{n&&(g(y.container??null),y.ready?(ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),k("ready")):(L(y.problem??new te("computer.err.vpsNotReady")),k("error")))});g(x.container??null),L(s.autoStartVps?new te("computer.err.vpsAuto",x.problem,"computer.err.vpsNoContainer"):new te("computer.err.vpsManual",x.problem,"computer.err.vpsNoContainer")),k(x.container==="stopped"?"vps-stopped":"vps-unconfigured")}).catch(i=>{n&&(L(i.message),k("error"))}),()=>{n=!1}):(W(V("computer")).then(i=>{if(!n)return;const x=yr({computer:o==="cloud"?"cloud":void 0,configured:!!i.configured,boatState:typeof i.box?.state=="string"?i.box.state:null,canUseCloud:Mt,autoLocal:!1,teamComputer:typeof i.teamComputer?.id=="string"&&typeof i.teamComputer?.name=="string",busy:t.busy});if(ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),!i.configured&&s.computer==="cloud"&&!i.teamComputer){k("unconfigured");return}if(x==="team-boat"){He({id:i.teamComputer.id,name:i.teamComputer.name,botId:s.id,section:s.section?.trim()??""}),g(typeof i.box?.state=="string"?i.box.state:i.configured?"missing":"unavailable"),L(typeof i.problem=="string"?i.problem:null),k("team-boat");return}if(x==="attach-ready-boat"||s.computer==="cloud"&&x==="show-ready-boat"){g(typeof i.box?.state=="string"?i.box.state:null),k("ready");return}g(typeof i.box?.state=="string"?i.box.state:null),k(x)}).catch(i=>{n&&(L(i.message),k("error"))}),()=>{n=!1})}},[s.id,s.threadId,s.computer,s.section,s.autoStartVps,M,ln,$e,Ce,se,ne,vt?.driverKind,un,Mt,h.config?.vps?.sshAlias,$,Me,A,H,o,V]),a.useEffect(()=>{if(m!=="busy-boat")return;let n=!0;const i=()=>{if(!t.busy&&o==="cloud"){Ye(y=>y+1);return}W(V("computer")).then(y=>{if(!n)return;const T=typeof y.box?.state=="string"?y.box.state:null;g(T),Lr(T)&&k("ready")}).catch(()=>{})},x=window.setInterval(i,5e3);return()=>{n=!1,window.clearInterval(x)}},[m,V,t.busy,o]);const Je=en(),Ge=a.useRef(0),Ot=a.useRef(s.busy);a.useEffect(()=>{Ot.current=s.busy},[s.busy]),a.useEffect(()=>{if(Ge.current=0,!!K)return wr({onFrame:n=>{n.kind!=="screen"||n.botId!==s.id||n.threadId!==s.threadId||(Ge.current=Date.now(),ue({png:n.png,mime:n.mime??"image/png"}),oe(null),de(!1))}})},[K,s.id,s.threadId]),a.useEffect(()=>{if($!=="computer"||!K||bt||!Je||P||ke)return;let n=!1,i=-1/0,x=null,y=null;const T=new AbortController;oe(null),de(!0);const Y=async()=>{if(n||T.signal.aborted||Date.now()-i<(x??(Ot.current?4e3:3e4))||Ot.current&&Date.now()-Ge.current<1e4)return;n=!0,x=null;const J=Date.now();try{const{png:pe,format:ze}=await W(V("computer/screenshot"),{method:"POST",signal:AbortSignal.any([T.signal,AbortSignal.timeout(9e4)])});if(!T.signal.aborted&&Ge.current<=J){if(typeof pe!="string"||!pe.trim())throw new te("computer.err.emptyFrame");ue({png:pe,mime:ze==="jpeg"?"image/jpeg":"image/png"}),oe(null),de(!1),y=null}}catch(pe){if(!T.signal.aborted&&Ge.current<=J)if(pe instanceof Fr&&Jr(pe)){x=1e3,y??=Date.now();const ze=Date.now()-y>=1e4;oe(ze?pe:null),de(!ze)}else y=null,de(!1),oe(pe instanceof Error&&pe.name==="TimeoutError"?new te("computer.err.frameTimeout"):pe instanceof Error?pe:new te("computer.err.screenUnavailable"))}finally{n=!1,i=Date.now()}};Y();const fe=setInterval(Y,1e3);return()=>{T.abort(),clearInterval(fe)}},[$,K,V,M,bt,Je,P,ke,F]),a.useEffect(()=>{if($!=="computer"||m!=="vm"||!re||bt||!Je)return;const n=new AbortController;let i=!1,x=-1/0,y=null,T=!0;const Y=async()=>{if(!(i||n.signal.aborted)&&!(Date.now()-x<(y??(s.busy?3e3:3e4)))){i=!0,y=null;try{const{image:J}=await W(V("local-computer/screenshot"),{method:"POST",signal:n.signal});!n.signal.aborted&&typeof J=="string"&&(me(J),oe(null))}catch(J){n.signal.aborted||(y=5e3,T?L(J instanceof Error?J.message:String(J)):oe(J instanceof Error?J:new te("computer.err.screenUnavailable")))}finally{i=!1,T=!1,x=Date.now()}}};Y();const fe=window.setInterval(()=>{Y()},s.busy?3e3:3e4);return()=>{n.abort(),window.clearInterval(fe)}},[$,m,re,V,bt,Je,s.busy,L,oe,me]);const[pn,Lt]=a.useState(0);a.useEffect(()=>{if($!=="computer"||m!=="local"||!re||!window.ogb||se||!Je)return;let n=!0;Lt(0);const i=async()=>{try{const y=await window.ogb.screenFrame();n&&y?rn(y):n&&Lt(T=>T+1)}catch{n&&Lt(y=>y+1)}};i();const x=setInterval(i,s.busy?3e3:3e4);return()=>{n=!1,clearInterval(x)}},[$,m,re,se,Je,s.busy,s.id,s.threadId]);const Ze=re?m==="vm"?ge:m==="local"&&!se?Kn:K||s.computer==="cloud"&&m==="starting"?X&&`data:${X.mime};base64,${X.png}`:null:null,qn=!!(Ze&&(m==="vm"&&ve||K)),xe=h.computerControl[s.id]??{held:!1,helpReason:null};a.useEffect(()=>{let n=!0;return W(`/api/bots/${s.id}/computer/control`).then(i=>{if(!n)return;const x=Mn.parse(i);R({type:"computerControl",botId:s.id,held:x.held===!0,helpReason:x.helpReason})}).catch(()=>{}),()=>{n=!1}},[s.id]);const mn=a.useCallback(async n=>{const i=Mn.parse(await W(`/api/bots/${s.id}/computer/control`,{method:"POST",body:JSON.stringify({action:n})}));return R({type:"computerControl",botId:s.id,held:i.held===!0,helpReason:i.helpReason}),i},[s.id,R]),xn=a.useCallback(async()=>!0,[]),yt=a.useCallback(async n=>ss({action:n,syncNativeBrowser:$!=="browser",requestControl:mn,setNativeBrowserControl:xn}),[$,mn,xn]),Ft=a.useCallback(async n=>{ft(!0),L(null);try{return await yt(n),!0}catch(i){return L(i instanceof Error?i.message:String(i)),!1}finally{ft(!1)}},[yt]),Pe=async()=>{const n=new AbortController;Z.current=n;const i=()=>!n.signal.aborted&&je.current===le;we("join"),ft(!0),L(null);let x=!1,y=null;!window.ogb?.desktopViewer&&!window.ogb?.openExternal&&(y=window.open("","_blank"),y&&(y.opener=null));try{if(xe.held||(await yt("take"),x=!0),!i())throw new DOMException("The selected conversation changed","AbortError");let T=ve;if(K){const Y=await W(V("computer/join"),{method:"POST",signal:n.signal});T=Y.joinUrl?.constructor===String?String(Y.joinUrl):null}if(!i())throw new DOMException("The selected conversation changed","AbortError");if(!T)throw new te("computer.err.noDesktopLink");if(window.ogb?.desktopViewer){if(!await window.ogb.desktopViewer.open(T,r("computer.viewerTitle",{name:s.name}),s.id))throw new te("computer.err.openDesktop")}else if(y)y.location.replace(T);else if(window.ogb?.openExternal){if(!await window.ogb.openExternal(T))throw new te("computer.err.openDesktopLink")}else if(!window.open(T,"_blank","noopener"))throw new te("computer.err.popupBlocked")}catch(T){y?.close(),x&&await yt("release").catch(()=>{}),K&&M==="vps"&&await W(V("computer/viewer-close"),{method:"POST",body:"{}"}).catch(()=>{}),i()&&L(T instanceof Error?T:String(T))}finally{Z.current===n&&(Z.current=null,we(null),ft(!1))}},Vt=n=>{we(n),L(null),W(`/api/bots/${s.id}/computer/${n}`,{method:"POST"}).then(i=>{n==="provision"&&(g(i.container??null),i.ready?(s.computer==="cloud"&&ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),k("ready")):(L(i.problem??new te("computer.err.vpsNotReady")),k("error"))),n==="sleep"&&(ae(null),g(M==="vps"?"stopped":"archived"),k(M==="vps"?"vps-stopped":H?"cloud-asleep":"show-sleeping-boat"))}).catch(i=>{L(i.message)}).finally(()=>we(null))},Wn=()=>{we("provision"),L(null),k("starting"),W(`/api/bots/${s.id}/computer/provision`,{method:"POST"}).then(n=>{g(n.state??null),ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),k("ready")}).catch(n=>{if(Gr(n)){k("busy-boat");return}L(n.message),k("error")}).finally(()=>we(null))},_t=async n=>{if((n==="vm-recreate"||n==="vm-delete")&&!window.confirm(n==="vm-delete"?r("computer.confirm.deleteVm",{name:s.name}):r("computer.confirm.replaceVm",{name:s.name}))||Ke.current)return;const i=new AbortController;Ke.current=i,we(n),L(null),at.current=0;try{if((n==="vm-recreate"||n==="vm-delete")&&await W(`/api/bots/${s.id}/local-computer/remove`,{method:"POST",body:"{}",signal:i.signal}),n!=="vm-delete"){const x=n==="vm-start"&&ye?.mode!=="per-bot"?"/api/local-computer/start":`/api/bots/${s.id}/local-computer/${n==="vm-start"?"start":"run"}`,y=await W(x,{method:"POST",body:"{}",signal:i.signal}),T=await ts(y,()=>W(V("local-computer"),{signal:i.signal}),i.signal);if(!T.ready)throw new Error(T.problem??r("computer.err.vmNotReady"));xt(T),k("vm")}else xt(x=>x&&{...x,container:"missing",ready:!1}),k("vm-unavailable")}catch(x){if(i.signal.aborted)return;L(x instanceof Error?x.message:String(x)),k("vm-unavailable")}finally{Ke.current===i&&!i.signal.aborted&&(Ke.current=null,we(null),Ye(x=>x+1))}},Hn=async()=>{if(window.confirm(r("computer.confirm.replaceVps",{name:s.name}))){we("vps-replace"),L(null);try{await W(`/api/bots/${s.id}/computer/remove`,{method:"POST",body:"{}"});const n=await W(`/api/bots/${s.id}/computer/provision`,{method:"POST",body:"{}"});zt(n),g(n.container??null),n.ready&&s.computer==="cloud"&&ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),k(n.ready?"ready":"error"),n.ready||L(n.problem??new te("computer.err.vpsReplaceNotReady"))}catch(n){L(n instanceof Error?n.message:String(n)),k("error")}finally{we(null),Ye(n=>n+1)}}},fn=()=>{window.sessionStorage.setItem("openmausbot.settings.section","computer"),R({type:"toggleAppSettings",open:!0})},bn=()=>{R({type:"toggleAppSettings",open:!0,section:"connections"})},$t=on||h.config?.browserEngine?.installable===!0,[hn,gn]=a.useState(!1),vn=async()=>{if(!hn){gn(!0),L(null);try{if(!Sn(h.config)){const n=await W("/api/config",{method:"PATCH",body:JSON.stringify({features:{browser:!0}})});R({type:"configStatus",config:n})}t.browser===!1&&R({type:"updateBot",botId:t.id,patch:{browser:!0}})}catch(n){L(n instanceof Error?n.message:r("settings.experimental.error"))}finally{gn(!1)}}},Xn=()=>{L(null),R({type:"updateBot",botId:t.id,patch:{browser:!1}})},yn=e.jsxs("div",{"data-testid":"browser-switch-row",className:"mb-3 flex items-center gap-3 rounded-xl bg-card px-3 py-2.5",children:[e.jsx(We,{size:15,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:r("computer.browserSwitch.title",{name:s.name})}),!$t&&e.jsx("div",{className:"text-[11.5px] text-ink-secondary",children:Zt(h.config)})]}),e.jsx(kr,{checked:Le,disabled:hn||!Le&&!$t,"aria-label":r("computer.browserSwitch.title",{name:s.name}),onClick:()=>Le?Xn():void vn()})]}),Bt=h.config?.managedPolicy,Kt=jr(Ie,t.busy===!0),Yn=!re||o!=="cloud"||M!=="box"?void 0:m==="starting"?"starting":m==="busy-boat"?Kt.spinner?"starting":Kt.line==="computer.cloud.asleep"?"asleep":"none":m==="ready"?"on":Ie==="archived"||Ie==="stopped"?"asleep":void 0,it=(n,i)=>Br({...Kr({bot:s,place:n,seat:mt,config:h.config,instances:h.instances,local:{ready:Ce,reason:De??r("computer.unavailableLocal")},...n==="cloud"?{computer:Yn}:{},...n==="auto"&&he?{teamComputer:he.name}:{}}),...i?{refusal:i}:{}}),Ut=s.computer==="cloud"&&M==="box"&&m==="error"&&ht&&!(ht instanceof te)?Nr({message:Be??"",status:Number(ht.status??0)||void 0},h.config?.box?.included===!0):void 0,be=it("cloud",Ut),qe=it("auto"),lt=[[null,"vm.dest.auto","computer.dest.autoDesc",Sr],["cloud","place.cloud","computer.dest.cloudDesc",Cr],["vm","vm.dest.vm","computer.dest.vmDesc",Er],["local","vm.dest.local","computer.dest.localDesc",Ve],["browser","vm.dest.browser","computer.dest.browserDesc",We],["off","vm.dest.off","computer.dest.offDesc",pt]].filter(([n])=>n===null||n==="off"||jn(n,h.config)).map(([n,i,x,y])=>{const T=n===null?!t.computer:t.computer===n,Y=n==="local"?"thisComputer":n==="vm"?"localVm":n==="cloud"?t.cloudBackend==="vps"?"vps":"box":null,fe=Bt&&Y&&!Bt.computers[Y]?r("policy.managedBy",{organization:Bt.organizationName}):void 0,J=n===null?qe:n==="cloud"?be:it(n),pe=!!fe||En(J),ze=!fe&&Rr(J),Qn=fe??(ze?J.line:n==="browser"?r("computer.browserOnlyTitle"):void 0);return{mode:n,labelKey:i,descriptionKey:x,Icon:y,simpleLabel:Tr(n??void 0,Se.host.platform),selected:T,managedBy:fe,disabled:pe,unavailableTitle:Qn,view:J,issue:ze}}),wt=lt.find(({selected:n})=>n)?.view??qe,Jn=n=>{if(n==="start"||n==="wake")return Wn();if(n==="try-again")return Ye(i=>i+1);if(n==="turn-on-browser")return void vn();if(n==="open-vm-settings")return fn();qr(n,{botId:t.id,threadId:t.threadId},R)},Gn=n=>!!n&&n!=="watch"&&n!=="open-computer-panel"&&(n!=="start"&&n!=="wake"||H&&!t.busy),ct=(n,i="mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover")=>n.action&&Gn(n.action.id)?e.jsx("button",{type:"button","data-testid":"place-action",onClick:()=>Jn(n.action.id),className:i,children:n.action.label}):null,wn=n=>{n===null&&t.computer===void 0||n===t.computer||(n==="local"&&Ur(t)==="auto"?Ee(s.id):Te(n==="browser"?{computer:n,browser:!0}:{computer:n}))},qt=D?.surface&&!D.surfaceAuto&&t.computer!=="off"&&D.surface!==t.computer?D.surface:void 0,ut=n=>Fe("flex items-center gap-1.5 rounded-full px-3 py-1 text-[12.5px] transition-colors",n?"bg-raised text-ink shadow-sm":"text-ink-secondary hover:text-ink"),Zn={checking:r("computer.phase.checking"),starting:M==="vps"?r("computer.phase.starting"):be.line,"busy-boat":be.line,unconfigured:be.line,"auto-unavailable":qe.line,"team-boat":qe.line,"show-ready-boat":r("computer.phase.showReadyBoat"),"show-sleeping-boat":r("computer.phase.showSleepingBoat"),"show-pending-boat":r("computer.phase.showPendingBoat"),"cloud-new":be.line,"cloud-asleep":be.line,"vps-unconfigured":r("computer.phase.vpsUnconfigured"),"vps-incompatible":r("computer.phase.vpsIncompatible"),"vps-stopped":r("computer.phase.vpsStopped"),"local-unavailable":De??r("computer.phase.localUnavailable"),"vm-unavailable":r("computer.phase.vmUnavailable"),browser:it("browser").line,off:it("off").line,error:s.computer==="cloud"&&(Ut||En(be))?be.line:r("computer.phase.error")};return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:Fe("animate-panel-in relative flex h-full shrink-0 flex-col border-l border-hairline/40 bg-panel","max-md:absolute max-md:inset-0 max-md:z-40 max-md:w-full!"),style:{width:d},children:[e.jsx("div",{ref:N,role:"separator","aria-orientation":"vertical","aria-label":r("computer.resizeAria"),"aria-valuemin":Et,"aria-valuemax":Rt,"aria-valuenow":j??void 0,tabIndex:0,onKeyDown:S,onPointerDown:w,onPointerMove:f,onPointerUp:C,onPointerCancel:C,className:"absolute inset-y-0 left-0 z-10 w-1.5 cursor-col-resize hover:bg-accent/40 focus-visible:bg-accent/60 max-md:hidden"}),e.jsx("div",{className:Fe("px-4 py-3",l),children:e.jsxs("div",{className:"relative flex min-h-7 items-center justify-center",children:[ee&&e.jsx("button",{onClick:()=>{R({type:"toggleComputer",open:!1}),R({type:"toggleSettings",open:!0,section:"access"})},className:"absolute left-0 top-1/2 -translate-y-1/2 rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink",title:r("computer.botSettings"),children:e.jsx(Ir,{size:18})}),e.jsxs("div",{className:"mx-9 flex min-w-0 flex-wrap justify-center gap-0.5 rounded-full bg-inset p-0.5","data-tour":"computer-tabs","data-testid":"computer-tabs","aria-label":"Bot panel view",children:[e.jsxs("button",{onClick:()=>Ue("computer"),"aria-pressed":$==="computer",className:ut($==="computer"),children:[e.jsx(Ve,{size:13})," ",r("computer.tab.computer"),q&&Pr(o)&&e.jsx("span",{className:"size-1.5 animate-pulse rounded-full bg-success",role:"img","aria-label":r("place.live"),"data-testid":"computer-tab-live"})]}),ee&&e.jsxs("button",{type:"button",onClick:()=>Ue("routines"),"aria-pressed":$==="routines",className:ut($==="routines"),children:[e.jsx(Rn,{size:13}),r("computer.tab.routines")]}),ee&>&&e.jsxs("button",{onClick:()=>Ue("android"),"aria-pressed":$==="android",className:ut($==="android"),children:[e.jsx(Fn,{size:13})," ",r("computer.tab.android")]}),e.jsxs("button",{"data-tour":"computer-browser",onClick:()=>{L(null),Ue("browser")},"aria-pressed":$==="browser",className:ut($==="browser"),children:[e.jsx(We,{size:13})," ",r("computer.tab.browser"),q&&o==="browser"&&e.jsx("span",{className:"size-1.5 animate-pulse rounded-full bg-success",role:"img","aria-label":r("place.live"),"data-testid":"browser-tab-live"})]}),!ee&&e.jsxs("button",{type:"button",onClick:()=>Ue("files"),"aria-pressed":$==="files",className:ut($==="files"),children:[e.jsx(Ln,{size:13})," ",r("computer.tab.files")]})]}),e.jsx("button",{onClick:()=>R({type:"toggleComputer",open:!1}),className:"absolute right-0 top-1/2 -translate-y-1/2 rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink","aria-label":r("computer.close"),title:r("computer.close"),children:e.jsx(St,{size:18})})]})}),$==="routines"?e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-4",children:e.jsx(rs,{bot:s,routines:dn,runs:h.routineRuns,defaultRunOn:Un?"cloud":"maus"},s.id)}):$==="browser"&&Le?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col px-4 pb-4",children:[yn,e.jsx(_s,{bot:s}),Be&&e.jsx("div",{role:"alert",className:"mt-2 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:Be})]}):$==="browser"?e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 pb-5","data-testid":"browser-off",children:[yn,e.jsxs("div",{className:"mt-2 flex flex-col items-center gap-3 rounded-xl bg-card px-6 py-8 text-center",children:[e.jsx(We,{size:22,className:"text-ink-secondary","aria-hidden":"true"}),e.jsx("div",{className:"text-[14px] font-medium text-ink",children:r("computer.browserOff.title")}),e.jsx("p",{className:"text-[12px] leading-5 text-ink-secondary",children:$t?r("computer.browserOff.body",{name:s.name}):Zt(h.config)}),Be&&e.jsx("div",{role:"alert",className:"w-full rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:Be})]})]}):$==="files"?e.jsx(ys,{bot:s}):$==="android"&>?e.jsx("div",{className:"flex-1 overflow-y-auto px-4 pt-2",children:e.jsx(Ns,{status:an})}):e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 pb-5",children:[e.jsxs("div",{className:"mb-1.5 mt-2 flex items-center justify-between text-[13px] text-ink-secondary",children:[e.jsx("span",{children:r("computer.screenOf",{name:s.name})}),he&&e.jsx("span",{className:"text-[11px]",children:qe.short}),m==="local"&&e.jsx("span",{className:"text-[11px]",children:r("computer.badge.local")}),m==="vm"&&e.jsx("span",{className:"text-[11px]",children:r("vm.dest.vm")}),(m==="show-ready-boat"||m==="show-sleeping-boat"||m==="show-pending-boat")&&e.jsx("span",{className:"text-[11px]",children:r("computer.badge.autoBoat")}),re&&s.computer==="cloud"&&M==="vps"&&(m==="ready"||m==="starting")&&e.jsx("span",{className:"text-[11px]",children:r("computer.badge.vps")})]}),e.jsx("div",{className:"relative flex aspect-[16/10] w-full items-center justify-center overflow-hidden rounded-xl bg-card",children:K||s.computer==="cloud"&&m==="starting"?e.jsx(ws,{src:Ze,name:s.name,error:Dn(Oe),refreshing:Xe,retry:F,starting:m==="starting",opening:P==="join",disabled:ke,onOpen:()=>{Pe()},onRetry:n=>{Ge.current=0,n&&ue(null),oe(null),de(!0),Q(i=>i+1)}},`${s.id}:${s.threadId}:${s.computer}:${M}`):Ze&&qn?e.jsxs("button",{type:"button",onClick:()=>{Pe()},disabled:ke||P==="join",className:"group relative flex h-full w-full cursor-pointer items-center justify-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-wait","aria-label":r("computer.openLiveDesktopAria",{name:s.name}),title:r("computer.openLiveDesktop"),children:[e.jsx("img",{src:Ze,alt:r("computer.screenOf",{name:s.name}),className:"h-full w-full object-contain transition group-hover:brightness-75 group-focus-visible:brightness-75"}),e.jsxs("span",{className:"pointer-events-none absolute right-2 top-2 flex items-center gap-1 rounded-md bg-black/70 px-2 py-1 text-[11px] font-medium text-white opacity-80 shadow-sm transition group-hover:opacity-100 group-focus-visible:opacity-100",children:[P==="join"?e.jsx(U,{size:12,className:"animate-spin"}):e.jsx(Tt,{size:12}),r("computer.open")]})]}):Ze?e.jsx("img",{src:Ze,alt:r("computer.screenOf",{name:s.name}),className:"h-full w-full object-contain",title:m==="vm"?r("computer.watchOnly"):void 0}):e.jsxs("div",{className:"flex flex-col items-center gap-2 px-6 text-center text-ink-secondary",children:[m==="checking"||m==="starting"||m==="busy-boat"&&Kt.spinner||m==="vm"||m==="local"&&!se?e.jsx(U,{size:18,className:"animate-spin"}):m==="off"?e.jsx(pt,{size:22}):e.jsx(Ve,{size:22}),e.jsx("span",{className:"text-[12px]",children:he?qe.line:K?r("computer.waitingFrame"):m==="ready"?r("computer.autoChooseCloudOpen"):m==="vm"?r("computer.capturingVm"):m==="local"?se?r("computer.linuxReady"):pn>=3?r("computer.needsScreenPerm"):r("computer.capturingLocal"):Dt?r(P==="vm-start"?"vm.setup.starting":"computer.phase.vmStopped"):Zn[m]}),he&&ct(qe),s.computer==="cloud"&&(m==="unconfigured"||m==="error")&&be.action?.id!=="add-boat-key"&&ct(be),m==="local"&&!se&&pn>=3&&e.jsx("button",{onClick:()=>window.ogb?.permOpenSettings?.("screen"),className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:r("computer.openSettings")}),m==="browser"&&Le&&e.jsx("button",{onClick:()=>Ue("browser"),className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:r("computer.openBrowserTab")}),(m==="show-ready-boat"||m==="show-sleeping-boat"||m==="show-pending-boat")&&e.jsx("button",{type:"button",onClick:()=>Te({computer:"cloud"}),className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:m==="show-sleeping-boat"?r("computer.chooseCloudWake"):m==="show-ready-boat"?r("computer.chooseCloudOpen"):r("computer.chooseCloudManage")}),P===null&&(m==="cloud-new"||m==="cloud-asleep")&&ct(be),Dt&&P!=="vm-start"&&e.jsx("p",{className:"text-[12px]",children:r(ye?.stop_reason==="idle"?"vm.stopped.idle":"vm.stopped.detail")}),m==="vm-unavailable"&&(ce&&Dt&&ye.mode!=="pool"?e.jsxs("button",{onClick:()=>{_t("vm-start")},disabled:P!==null,"aria-busy":P==="vm-start",className:"mt-1 flex items-center gap-1.5 rounded-lg bg-accent px-3 py-1.5 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[P==="vm-start"&&e.jsx(U,{size:13,className:"animate-spin"}),r(P==="vm-start"?"vm.setup.starting":"vm.setup.start")]}):ce&&ye?.mode==="per-bot"&&ye.image&&ye.create_supported?e.jsxs("button",{onClick:()=>{_t(ye.container==="missing"?"vm-create":"vm-recreate")},disabled:P!==null,className:"mt-1 rounded-lg bg-accent px-3 py-1.5 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[(P==="vm-create"||P==="vm-recreate")&&e.jsx(U,{size:13,className:"mr-1.5 inline animate-spin"}),ye.container==="missing"?r("computer.createVm",{name:s.name}):r("computer.replaceVm",{name:s.name})]}):e.jsx("button",{onClick:fn,className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:r("computer.openVmSetup")})),!ee&&re&&(m==="vps-unconfigured"||m==="vps-stopped"||m==="vps-incompatible")&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[12px]",children:r("computer.simple.needsSetup",{name:s.name})}),e.jsx("button",{type:"button",onClick:()=>zr(!0),className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:r("computer.simple.showAdvanced")})]}),ee&&re&&(m==="vps-unconfigured"||m==="vps-stopped")&&e.jsx("button",{onClick:bn,className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:r("computer.openVpsSettings")}),ee&&re&&(m==="vps-stopped"||m==="vps-unconfigured"&&nn?.configured)&&H&&e.jsxs("button",{onClick:()=>Vt("provision"),disabled:P==="provision",className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[P==="provision"&&e.jsx(U,{size:13,className:"mr-1.5 inline animate-spin"}),m==="vps-stopped"?r("computer.startVps"):r("computer.prepareVps")]}),ee&&re&&m==="vps-incompatible"&&nn?.managed&&H&&e.jsxs("button",{onClick:()=>{Hn()},disabled:P==="vps-replace",className:"mt-1 rounded-lg bg-accent px-3 py-1.5 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[P==="vps-replace"&&e.jsx(U,{size:13,className:"mr-1.5 inline animate-spin"}),r("computer.replaceVps")]})]})}),Be&&!Ut&&e.jsx("div",{className:"mt-2 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:Be}),m==="unconfigured"&&be.action?.id==="add-boat-key"&&e.jsx("div",{className:"mt-3 rounded-xl bg-card p-4",children:e.jsx(Qr,{section:"box",onSaved:n=>n&&Ye(i=>i+1)})}),ee&&m==="vps-unconfigured"&&e.jsxs("div",{className:"mt-3 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"mb-3 text-[13px] text-ink-secondary",children:r("computer.vpsAliasHint")}),e.jsx("button",{onClick:bn,className:"rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover",children:r("computer.openVpsSettings")})]}),ee&&m==="vm"&&ye?.mode==="per-bot"&&window.ogb?.desktopWorkspace&&c&&e.jsxs("button",{type:"button",onClick:()=>c(s.id),disabled:P!==null,className:"mt-3 flex w-full items-center justify-center gap-2 rounded-lg border border-accent/30 bg-accent/10 py-2 text-[13px] font-medium text-ink hover:bg-accent/15 disabled:opacity-50",title:r("computer.twoDesktopsTitle"),children:[e.jsx(os,{size:14}),r("computer.twoDesktops")]}),(K||m==="vm"||he)&&xe.helpReason&&!xe.held&&e.jsxs("div",{className:"mt-3 rounded-xl border border-warning/25 bg-warning/10 p-4",children:[e.jsxs("div",{className:"text-[13px] leading-relaxed text-warning",children:[e.jsx("b",{children:s.name})," ",r("computer.askedHands")," ",xe.helpReason]}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsxs("button",{onClick:()=>m==="vm"||K?void Pe():Ft("take"),disabled:ke||P==="join",className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-accent py-2 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[P==="join"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(_e,{size:14}),r("computer.takeControl")]}),e.jsx("button",{onClick:()=>Ft("dismiss-help"),disabled:ke,className:"rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:r("computer.dismiss")})]})]}),(K||m==="vm"||he)&&xe.held&&e.jsxs("div",{className:"mt-3 rounded-xl border border-accent/25 bg-accent/10 p-4",children:[e.jsxs("div",{className:"text-[13px] leading-relaxed text-ink",children:[r("computer.youHaveWheel"),K&&` ${r(ee?"computer.useOpenDesktop":"computer.simple.useFullScreen")}`,m==="vm"&&` ${r(ee?"computer.useOpenDesktopVm":"computer.simple.useFullScreenVm")}`]}),e.jsxs("button",{onClick:()=>{Ft("release"),window.ogb?.desktopViewer?.close(s.id)},disabled:ke,className:"mt-2 flex w-full items-center justify-center gap-2 rounded-lg bg-accent py-2 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[e.jsx(_e,{size:14}),r("computer.handBack")]})]}),ee&&m==="vm"&&ve&&xe.held&&e.jsxs("button",{onClick:()=>{Pe()},disabled:P==="join",className:"mt-3 flex w-full items-center justify-center gap-2 rounded-lg bg-control py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:r("computer.openVmDesktopTitle"),children:[P==="join"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(Ve,{size:14}),r("computer.openLiveDesktop")]}),ee&&m==="vm"&&!xe.held&&!xe.helpReason&&e.jsxs("button",{onClick:()=>{Pe()},disabled:ke||P==="join"||!ve,className:"mt-3 flex w-full items-center justify-center gap-2 rounded-lg bg-control py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:r("computer.takeControlVmTitle"),children:[P==="join"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(_e,{size:14}),r("computer.takeControl")]}),ee&&ce&&m==="vm"&&ye?.mode==="per-bot"&&e.jsxs("button",{onClick:()=>{_t("vm-delete")},disabled:P!==null||t.busy,className:"mt-2 flex w-full items-center justify-center gap-2 rounded-lg border border-danger/30 py-2 text-[13px] text-danger hover:bg-danger/10 disabled:opacity-50",title:t.busy?r("computer.deleteVmBlocked"):r("computer.deleteVmTitle",{name:s.name}),children:[P==="vm-delete"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(pt,{size:14}),r("computer.deleteVm")]}),!ee&&(K||m==="vm")&&e.jsxs("div",{className:"mt-3 flex gap-2","data-testid":"computer-actions",children:[!xe.held&&!xe.helpReason&&e.jsxs("button",{type:"button",onClick:()=>{Pe()},disabled:ke||P==="join"||m==="vm"&&!ve,className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-accent py-2 text-[13px] font-medium text-accent-ink hover:brightness-110 disabled:opacity-50",title:m==="vm"?r("computer.takeControlVmTitle"):r("computer.takeControlTitle"),children:[P==="join"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(_e,{size:14}),r("computer.takeControl")]}),e.jsxs("button",{type:"button",onClick:()=>{Pe()},disabled:P==="join"||!xe.held&&ke||m==="vm"&&!ve,className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-control py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:r("computer.openLiveDesktop"),children:[e.jsx(Tt,{size:14}),r("computer.fullScreen")]}),K&&H&&(M==="vps"||Ie!=="archived")&&e.jsxs("button",{type:"button",onClick:()=>Vt("sleep"),disabled:P==="sleep"||t.busy,className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:r("computer.sleepTitle"),children:[P==="sleep"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(Tn,{size:14}),r("vm.cloud.sleep")]})]}),ee&&K&&e.jsxs("div",{className:"mt-3 flex gap-2",children:[!xe.held&&!xe.helpReason&&e.jsxs("button",{onClick:()=>{Pe()},disabled:ke||P==="join",className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-control py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:r("computer.takeControlTitle"),children:[P==="join"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(_e,{size:14}),r("computer.takeControl")]}),xe.held&&e.jsxs("button",{onClick:()=>{Pe()},disabled:P==="join",className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-control py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[P==="join"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(Ve,{size:14}),r("computer.openLiveDesktop")]}),H&&(M==="vps"||Ie!=="archived")&&e.jsxs("button",{onClick:()=>Vt("sleep"),disabled:P==="sleep"||t.busy,className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:r("computer.sleepTitle"),children:[P==="sleep"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(Tn,{size:14}),r("vm.cloud.sleep")]})]}),m!=="team-boat"&&(s.computer!==void 0||re)&&e.jsxs(e.Fragment,{children:[e.jsx(Ks,{}),e.jsx(qs,{}),e.jsx(es,{})]}),ee?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-4 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:r("computer.worksOn")}),e.jsx("p",{className:"mt-1 text-[12px] leading-5 text-ink-secondary",children:r(h.config?.cloudHome?"computer.worksOnHintCloudHome":"computer.worksOnHint")}),e.jsx("div",{role:"group","aria-label":r("computer.destinationAria"),className:"mt-3 grid auto-rows-fr grid-cols-2 gap-2",children:lt.map(({mode:n,labelKey:i,descriptionKey:x,Icon:y,selected:T,managedBy:Y,disabled:fe,unavailableTitle:J,issue:pe,view:ze})=>e.jsxs("button",{disabled:fe,title:J,onClick:()=>wn(n),type:"button","aria-pressed":T,className:Fe("min-w-0 rounded-lg border px-2.5 py-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-card",T?"border-accent/60 bg-accent/10 text-ink":"border-hairline/50 bg-panel/30 text-ink-secondary",fe?"cursor-not-allowed":"hover:border-accent/40 hover:bg-control/60"),children:[e.jsxs("span",{className:"flex items-center gap-2 text-[12px] font-medium leading-4",children:[T?e.jsx(Ar,{size:14,className:"shrink-0 text-accent"}):e.jsx(y,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{children:r(i)})]}),e.jsx("span",{className:"mt-1.5 block text-[11px] leading-4 text-ink-secondary",children:Y??(pe?ze.short:r(x))})]},n??"auto"))}),D?.surface&&e.jsx("p",{className:"mt-2 text-[11.5px] leading-5 text-ink-secondary","data-testid":"place-pinned-note",children:r("place.pinnedNote",{place:r(Ht(D.surface))})}),e.jsxs("div",{className:"mt-3 border-t border-hairline/40 pt-3 text-[11.5px] leading-5 text-ink-secondary","aria-live":"polite","data-testid":"place-line",children:[wt.line,ct(wt,"mt-1 block font-medium text-accent hover:underline")]}),t.computer==="cloud"&&e.jsx(ns,{compact:!0,value:M,onChange:n=>Te({cloudBackend:n})})]}),e.jsxs("button",{type:"button",onClick:()=>Ue("routines"),className:"mt-4 flex w-full items-start gap-3 rounded-xl bg-card p-4 text-left hover:bg-raised",children:[e.jsx(Rn,{size:17,className:"mt-0.5 shrink-0 text-accent"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"block text-[14px] font-medium text-ink",children:[r("computer.tab.routines")," ",e.jsx("span",{className:"ml-1 text-[11px] text-ink-secondary",children:dn.length})]}),e.jsx("span",{className:Fe("mt-1 block truncate text-[11.5px]",ot?Mr(ot):"text-ink-secondary"),children:ot?`${ot.routineName} · ${Dr(ot)}`:r("computer.routines.openTitle")})]}),e.jsx("span",{className:"text-ink-secondary","aria-hidden":"true",children:"→"})]})]}):e.jsxs("div",{className:"mt-4 rounded-xl bg-card p-4","data-testid":"where-works",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:r("computer.simple.whereWorks",{name:s.name})}),e.jsx("div",{role:"group","aria-label":r("computer.destinationAria"),className:"mt-3 grid grid-cols-3 gap-2",children:lt.map(({mode:n,Icon:i,selected:x,disabled:y,unavailableTitle:T,simpleLabel:Y,issue:fe,view:J})=>e.jsxs("button",{type:"button",disabled:y,title:T,"aria-pressed":x,onClick:()=>wn(n),className:Fe("flex min-w-0 flex-col items-center gap-1.5 rounded-lg border px-1.5 py-2.5 text-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-card",x?"border-accent/60 bg-accent/10 text-ink":"border-hairline/50 bg-panel/30 text-ink-secondary",y?"cursor-not-allowed opacity-50":"hover:border-accent/40 hover:bg-control/60"),children:[e.jsx(i,{size:16,className:Fe("shrink-0",x?"text-accent":"text-ink-secondary"),"aria-hidden":"true"}),e.jsx("span",{className:"w-full truncate text-[12px] font-medium leading-4",children:Y}),fe&&e.jsx("span",{className:"w-full truncate text-[10.5px] leading-3 text-ink-secondary",children:J.short})]},n??"auto"))}),e.jsxs("div",{className:"mt-3 text-[11.5px] leading-5 text-ink-secondary","data-testid":"place-line",children:[wt.line,ct(wt,"mt-1 block font-medium text-accent hover:underline")]}),qt&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("p",{className:"min-w-0 flex-1 text-[11.5px] leading-5 text-ink-secondary","data-testid":"place-pinned-note",children:r("place.pinnedNoteSimple",{place:lt.find(({mode:n})=>n===qt)?.simpleLabel??r(Ht(qt))})}),e.jsx("button",{type:"button",disabled:!!s.busy,title:s.busy?r("place.busy"):void 0,onClick:()=>R({type:"updateTask",botId:t.id,threadId:t.threadId,patch:{surface:null}}),className:"shrink-0 rounded-md px-2 py-0.5 text-[11.5px] font-medium leading-5 text-accent-text transition-colors hover:bg-control focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-45 disabled:hover:bg-transparent","data-testid":"place-unpin",children:r("place.unpinSimple",{place:lt.find(({selected:n})=>n)?.simpleLabel??r(Ht(t.computer??"auto"))})})]})]})]})]}),e.jsx(Or,{open:Ae!==null,onCancel:()=>Ee(null),onConfirm:()=>{const n=Ae;Ee(null),n&&(n===s.id&&(ae(null),k("checking")),R({type:"updateBot",botId:n,patch:{computer:"local",acknowledgeLocalAuto:!0}}))}})]})}export{na as ComputerPanel};
|